akhauriyash/Code-Regression huggingface dataset:
class Dice
  def initialize(numbers)
    @numbers = numbers
    @map = {:top => 1, :R => 6, :S => 2, :E => 3, :N => 5, :W => 4}
  end
 
  def move(vec)
    case vec
    when "N"
      temp = @map.clone
      temp[:top] = @map[:S]
      temp[:R] = @map[:N]
      temp[:S] = @map[:R]
      temp[:N] = @map[:top]
      @map = temp.clone
    when "W"
      temp = @map.clone
      temp[:top] = @map[:E]
      temp[:R] = @map[:W]
      temp[:E] = @map[:R]
      temp[:W] = @map[:top]
      @map = temp.clone
    when "S"
      temp = @map.clone
      temp[:top] = @map[:N]
      temp[:R] = @map[:S]
      temp[:S] = @map[:top]
      temp[:N] = @map[:R]
      @map = temp.clone
    when "E"
      temp = @map.clone
      temp[:top] = @map[:W]
      temp[:R] = @map[:E]
      temp[:E] = @map[:top]
      temp[:W] = @map[:R]
      @map = temp.clone
    end
  end
 
  def spin
    temp = @map.clone
    temp[:E] = @map[:N]
    temp[:W] = @map[:S]
    temp[:S] = @map[:E]
    temp[:N] = @map[:W]
    @map = temp.clone
  end
 
  def top_number
    @numbers[@map[:top] - 1]
  end
 
  def right_number
    @numbers[@map[:E] - 1]
  end
 
  def front_number
    @numbers[@map[:S] - 1]
  end
 
  def back_number
    @numbers[@map[:N] - 1]
  end
 
  def left_number
    @numbers[@map[:W] - 1]
  end
 
  def bottom_number
    @numbers[@map[:R] - 1]
  end
 
  def get_place(number)
    index = @numbers.index(number)
    @map.key(index + 1)
  end
 
  def numbers
    @numbers
  end
 
  def map
    @map
  end
 
  def equal?(dice)
    count = 1
    while count <= 6 do
      if dice.top_number == self.top_number
        4.times do
          if dice.left_number == self.left_number &&
             dice.right_number == self.right_number &&
             dice.front_number == self.front_number &&
             dice.back_number == self.back_number &&
             dice.bottom_number == self.bottom_number then
             return true
          end
          dice.spin
        end
      end
      if count % 2 == 0
        dice.move("N")
      else
        dice.move("W")
      end
      count += 1
    end
    return false
  end
end
 
dice1 = Dice.new(gets.split.map(&:to_i))
dice2 = Dice.new(gets.split.map(&:to_i))
 
if dice1.equal?(dice2)
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8780
#include<iostream>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    }
    else if (a > b) {
        cout << "a > b" << endl;
    }
    else {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n,m,x; cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n);
  for(int i = 0; i < n; i++){
    cin >> c[i];
    for(int j = 0; j < m; j++){
      int temp; cin >> temp;
      a[i].push_back(temp);
    }
  }
  vector<int> ans(m);
  int mn = 999999999;
  for(int bit = 0; bit < (1<<n); bit++){
    rep(i,m) ans[i] = 0;
    int money = 0;
    for(int i = 0; i < n; i++){
      if(bit & (1<<i)){
        money += c[i];
        rep(j,m){
          ans[j] += a[i][j];
        }
      }
    }
    bool flg = true;
    rep(i,m){
      if(x > ans[i]) flg = false;
    }
    if(flg) mn = min(mn, money);
  }
  if(mn == 999999999) mn = -1;
  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  int A, B, K; cin>>A>>B>>K;

  int gcdv=gcd(A,B);
  vector<int> v;
  REP(i,gcdv) if(gcdv%(i+1)==0) v.push_back(i+1);

  reverse(ALL(v));
  cout<<v[K-1]<<endl;

  return 0;
}

Measured memory_bytes: 256
l = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
n = int(input())
s = input()
for i in range(len(s)):
    for j in range(len(l)):
        if j+n > 25 and s[i] ==l[j]:
            s = s[:i] +l[j-26+n]+s[i+1:]
            break
        elif s[i] == l[j]:
            s = s[:i]+l[j+n]+s[i+1:]
            break
            
print(s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  vector<ll> doubleA(N);
  for (int i = 0; i < N; i++)
    doubleA[i] = 2 * A[i];
  vector<ll> ans(N);
  ans[0] = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0)
      ans[0] += A[i];
    else
      ans[0] -= A[i];
  }
  for (int i = 1; i < N; i++)
  {
    ans[i] = doubleA[i - 1] - ans[i - 1];
  }
  for (auto a : ans)
    cout << a << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  string a,b; cin >> a >> b;
  int n=a.length(),m=b.length();
  if(n==m){
    for(int i=0;i<n;i++) cout << a[i] << b[i];
    cout<<endl;
  }
  else{
    for(int i=0;i<m;i++) cout << a[i] << b[i];
    cout<<a[n-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	string s;cin>>s;
	int n=s.size(),a=s[0]-'0',ans;
	bool flg=true;
	for(int i=1;i<n;i++){if(s[i]!='9')flg=false;}
	if(flg)ans=a+9*(n-1);
	else ans=a+9*(n-1)-1;
	
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int x;
    cin >> x;
    int a=360*x/__gcd(x,360);
    cout << a/x << endl;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
typedef vector<string> vecst;

int main(){
    ll N, K;
    cin >> N >> K;
    db ans = 0;
    for(ll i = 0; i < N; i++){
        db ans_ = 1;
        db ii = i + 1;
        while(ii < K){
            ii *= 2;
            ans_ /= 2;
        }
        ans += ans_;
    }
    ans /= N;
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))
using namespace std;

int main(){
	int m,nmin,nmax;
	while(cin>>m>>nmin>>nmax,m){
		int P[201];
		int maxg=0;
		int ans;
		REP(i,0,m) cin>>P[i];
		REP(i,nmin,nmax+1){
			int gap=P[i-1]-P[i];
			if(gap>=maxg){
				maxg=gap;
				ans=i;
			}
		}
		p(ans);
	}
	return 0;
}

Measured memory_bytes: 2988
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        double a = 360*H/12 + (double)360*M/(12*60);
        double b = 360*M/60;

        double r;
        if (Math.abs(a-b) > 180) {
            r = 360-Math.abs(a-b);
        } else {
            r = Math.abs(a-b);
        }
        //System.out.println(r);
        double rd = Math.toRadians(r);
        double xx = A*A+B*B-2*A*B*Math.cos(rd);
        System.out.println(Math.sqrt(xx));
    }
}


Measured memory_bytes: 35952
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;




int main(int argc, char *args[]) {
	int N;
	cin >> N;
	if (N % 2 == 0)cout << N << endl;
	else cout << 2 * N << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  co(a*(a-1)/2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll A, B;

void solve() {
  ll res = 0;
  if (A > B) {
    res += A;
    A--;
  } else {
    res += B;
    B--;
  }
  if (A > B) {
    res += A;
    A--;
  } else {
    res += B;
    B--;
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> A >> B;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    double n;
    cin>>n;
    cout<<2*n*3.1415926<<endl;
}

Measured memory_bytes: 3804
def pf(N):
    A = []
    while N % 2 == 0:
        A.append(2)
        N //= 2
    f = 3
    while f * f <= N:
        if N % f == 0:
            A.append(f)
            N //= f
        else:
            f += 2
    if N != 1:
        A.append(N)
    return A

n = int(input())
a = list(map(int, input().split()))
b = [0]*1000001
for i in range(n):
    x = pf(a[i])
    x = list(set(x))
    for j in x:
        b[j] += 1
#print(b)
tnp = 0
for i in range(1000001):
    if (b[i]>1):
        tnp += 1
        break
if (tnp==0):
    print("pairwise coprime")
    exit()
        
for i in range(1000001):
    if (b[i]==n):
        print("not coprime")
        exit()
print("setwise coprime")
    

Measured memory_bytes: 205356
# -*- coding: utf-8 -*-
"""
selection sort
"""
N = int(input())
aN = list(map(str, input().split()))

cnt = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if int(aN[j]) < int(aN[minj]):
            minj = j
    if i != minj:
        tmp = aN[i]
        aN[i] = aN[minj]
        aN[minj] = tmp
        cnt += 1
print(' '.join(aN))
print(cnt)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> A(N),B(M),Sa(N+1),Sb(M+1);
    Sa[0] = 0;
    Sb[0] = 0;
    REP(i,N){
        cin >> A[i];
        Sa[i + 1] = A[i] + Sa[i];
    }

    REP(i,M){
        cin >> B[i];
        Sb[i + 1] = B[i] + Sb[i];
    }

    ll ans = 0;
    Sb.push_back(1e10);

    FORq(i,0,N){
        ll Ncost = Sa[i];
        if (Ncost > K) continue;
        auto it = upper_bound(ALL(Sb), K - Ncost);
        ll bcount = it - Sb.begin() - 1;
        ll nans = (ll)i + bcount;
        //DB2(i,bcount);
        chmax(ans,nans);
    }


    // REP(i,N+1){
    //     DB2(i,Sa[i]);
    // }

    // REP(i,M+1){
    //     DB2(i,Sb[i]);
    // }

    cout << ans << endl;
}

Measured memory_bytes: 11180
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



bool judgeSosuu(ll N);
ll gcd(ll a, ll b);

int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	ll A, B;
	cin >> A >> B;

	ll ans = 1;
	ll gcdNum = gcd(A, B);


	for (int i = 1; i <= sqrt(gcdNum); i++) {
		if (gcdNum % i == 0) {// 公約数であるとき

			if (judgeSosuu(i)) {
				ans++;
			}

			ll temp = gcdNum / i;
			
			if (judgeSosuu(temp)) {
				ans++;
			}
		}


	}

	cout << ans;
	


}

bool judgeSosuu(ll N) {

	if (N < 2) {
		return false;
	}
	else if (N == 2) {
		return true;
	}
	else if (N % 2 == 0) {
		return false;
	}

	for (ll i = 3; i <= sqrt(N); i += 2) {
		if (N % i == 0) {
			return false;
		}
	}

	return true;

}

//---最大公約数を求める---
ll gcd(ll a, ll b) {
	if (a < b){
		ll tmp = a;
		a = b;
		b = tmp;
	}

	ll r = a%b;
	while (r != 0){
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int P = 1e9 + 7;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, m; long long s, mst;
int f[MAXN], x[MAXN], y[MAXN], z[MAXN], pos[MAXN];
int F(int x) {
	if (f[x] == x) return x;
	else return f[x] = F(f[x]);
}
long long MinimalSpanningTree() {
	for (int i = 1; i <= n; i++)
		f[i] = i;
	long long ans = 0;
	for (int i = 1; i <= m; i++) {
		int tmp = pos[i];
		int tx = F(x[tmp]), ty = F(y[tmp]);
		if (tx != ty) {
			f[tx] = ty;
			ans += z[tmp];
		}
	}
	return ans;
}
long long MinimalSpanningTree(int fixed) {
	for (int i = 1; i <= n; i++)
		f[i] = i;
	long long ans = z[fixed];
	f[x[fixed]] = y[fixed];
	for (int i = 1; i <= m; i++) {
		int tmp = pos[i];
		int tx = F(x[tmp]), ty = F(y[tmp]);
		if (tx != ty) {
			f[tx] = ty;
			ans += z[tmp];
		}
	}
	return ans;
}
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
bool cmp(int x, int y) {
	return z[x] < z[y];
}
int main() {
	read(n), read(m), read(s);
	for (int i = 1; i <= m; i++)
		read(x[i]), read(y[i]), read(z[i]), pos[i] = i;
	sort(pos + 1, pos + m + 1, cmp);
	mst = MinimalSpanningTree();
	if (mst > s) {
		printf("%d\n", 0);
		return 0;
	}
	if (mst == s) {
		int cnt = 0;
		for (int i = 1; i <= m; i++)
			cnt += MinimalSpanningTree(i) != mst;
		printf("%d\n", (power(2, m) - power(2, cnt + 1) + P) % P);
		return 0;
	}
	int cnt = 0, bnt = 0;
	for (int i = 1; i <= m; i++) {
		long long tmp = MinimalSpanningTree(i);
		if (tmp == s) bnt++;
		else if (tmp > s) cnt++, bnt++;
	}
	printf("%d\n", 2ll * (power(2, bnt) - power(2, cnt) + P) % P);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int Ans=0;
  int h;
  for(int i=0; i<N; i++){
    cin >> h;
    if(h>=K){
      Ans++;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
ll a[N];

int main()
{
	a[1] = 1;
	for(int i = 2 ; i < N ; i++)
	{
		ll x = a[i-1];
		int j = 0;
		while( (x%10 > (x/10)%10 && x/10 != 0) || x%10==9) {x/=10;j++;}
		
		x++;
		int d = x%10;
		while(j > 0)
		{
			x*=10;
			d = max(0,d-1);
			x += d;
			j--;
		}
		a[i] = x;
	}
	
	int k;
	scanf("%d",&k);
	printf("%lld\n",a[k]);
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {    
    public static void main(String[] args){

       Scanner sc = new Scanner(System.in);

       String S = sc.next();   
       
       S = S.replaceAll("eraser","");              
       S = S.replaceAll("erase","");
       S = S.replaceAll("dreamer","");
       S = S.replaceAll("dream","");
       
       if(S.length() != 0){
          System.out.println("NO");           
       }else{
          System.out.println("YES");            
       }
      
  }                                      
}

Measured memory_bytes: 31844
# A, B = [int(i) for i in input().split(" ")]
# A = int(input())
# As = [int(i) for i in input().split(" ")]

from math import factorial
def nCr(n, r):
  return factorial(n) // factorial(r) // factorial(n - r)

N = int(input())
Ss = ["".join(sorted(input())) for _ in range(N)]
m = {}
for s in Ss:
  m[s] = m.get(s, 0) + 1
ans = sum(nCr(n, 2) for n in m.values() if n >= 2)
print(ans)



Measured memory_bytes: 19392
#include <iostream>

int main(int argc, char const* argv[])
{
  int S;
  std::cin >> S;
  int h, m, s;
  h = S / 60 / 60;
  m = S / 60 % 60;
  s = S % 60;
  std::cout << h << ":" << m << ":" << s << std::endl;
  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
 
int main()
{
    char ch;
     
    while(scanf("%c", &ch) != EOF){
        if (ch == '\n') break;
        else if ('a' <= ch && ch <= 'z') printf("%c", toupper(ch));
        else if ('A' <= ch && ch <= 'Z') printf("%c", tolower(ch));
        else printf("%c", ch);
    }
    printf("\n");
    return 0;
}
 

Measured memory_bytes: 524
// Aizu 1610: Bamboo Blossoms
// 2017.9.21 bal4u@uu

#include <stdio.h>

#define MAX  7368792
char tbl[MAX + 5], *pmax = tbl + MAX;

int main()
{
	int m, n, i, j, cno = 0;
	register char *p, *q;

	while (scanf("%d%d", &m, &n) && m) { cno++;
		for (i = 0; i < n; i++) {
			for (j = m, q = p = tbl + m; p < pmax; p += j) *p = cno;
			while (*q++ == cno) m++;
		}
		printf("%d\n", m);
	}
	return 0;
}

Measured memory_bytes: 8920
//https://atcoder.jp/contests/dp/tasks/dp_q
//shauryakr
#include<bits/stdc++.h>
using namespace std;
long long int arr[200010], height[200010], n;
long long int BIT[200010];

void update(int ind, long long int val)
{
    while(ind > 0)
    {
        BIT[ind] = max(BIT[ind], val);
        ind -= ind&-ind;
    }
}

long long int getBit(int ind)
{
    long long int ans = 0;
    while(ind <= 200000)
    {
        ans = max(ans, BIT[ind]);
        ind += ind&-ind;
    }
    return ans;
}

int main()
{
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> height[i];
    }
    for(int i=1; i<=n; i++)
    {
        cin >> arr[i];
    }

    long long int ans = 0;
    for(int i=n; i>=1; i--)
    {
        long long int prev = getBit(height[i] + 1);
        ans = max(ans, prev + arr[i]);
        update(height[i], prev + arr[i]);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int N,M; cin>>N>>M;
  int a[N],b[N],c[M],d[M];
  for(int i=0;i<N;i++) cin>>a[i]>>b[i];
  for(int i=0;i<M;i++) cin>>c[i]>>d[i];

  for(int i=0;i<N;i++){
    int min_dist=1e18,min_idx=-1;
    for(int j=0;j<M;j++){
      int dist=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(dist<min_dist){
          min_dist=dist;
          min_idx=j+1;
      }
    }
    cout<<min_idx<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 #include <iomanip>
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int n,m;

void solve(istream& cin, ostream& cout) {
	int R;
	cin >> R;
	cout <<setprecision(12) << M_PI*R*2<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3828
#include<stdio.h>

int main()
{
  int i, h;
  long int node[251];
  for(i = 0; i < 251; i++)
    {
      node[i] = NULL;
    }
  
  scanf("%d", &h);
  for(i = 1; i <= h; i++)
    {
      scanf("%d", &node[i]);
    }
for(i = 1; i <= h; i++)
    {
      printf("node %d: key = %d, ", i, node[i]);
      
      if(node[i/2] != NULL)printf("parent key = %d, ", node[i/2]);
      if(2*i < 251 && node[2*i] != NULL)printf("left key = %d, ", node[2*i]);
      if(2*i+1 < 251 && node[2*i+1] != NULL)printf("right key = %d, ", node[2*i+1]);

      printf("\n");
    }
 
  return 0; 
}



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {

	public static void main (String[] args)  {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		

		
		if ((b-a)%2==0) {
			System.out.println((b-a)/2);
		} else {
			long x = b-1;
			long y = n-a;
			long z = a+(b-a-1)/2;
			long w = n-b+1+(n-(a+n-b+1))/2;
			
			System.out.println(Math.min(Math.min(x, y),Math.min(z, w)));
		}
	}

}


Measured memory_bytes: 23764
#include<stdio.h>
const int SIZE=100;
int data[SIZE];
int sp=0;
int size(){
  return sp;
}
int empty(){
  return sp<=0;
}
int top(){
  return data[sp-1];
}
void pop(){
  sp--;
}
void push(int v){
  data[sp]=v;
  sp++;
}
int main(){
  int n,k;
  while(scanf("%d",&n)!=EOF){
    if(n==0){
      printf("%d\n",top());
      pop();
    }else{
      push(n);
    }
  }
  return 0;
}

Measured memory_bytes: 2656
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  while(true){
    c -= b;
    if (c<=0){
      cout << "Yes" <<endl;
      break;
    }
    
    a -= d;
    if (a<=0){
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;

int main(){
  int n,m,k,ans;
  cin >> n >> m >>k;
  for(int i=0;i<=m;i++){
    for(int j=0;j<=n;j++){
      if( i*j+(n-j)*(m-i) ==k ){
        cout << "Yes" <<endl;
        return 0;
      }
    }
  }
  cout << "No" <<endl;
  return 0;
}


Measured memory_bytes: 256
def main():
  N=input()
  A=sorted(map(int,input().split()))
  M=A[-1]+1
  B=[0]*M
  for i in A:
    B[i]+=1
    if B[i]==1:
      for j in range(i*2,M,i):
        B[j]=2
  print(B.count(1))
main()

Measured memory_bytes: 32332
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int f,count=0;
	do{
		f=0;
		for(int i=0;i<n;i++){
			if(a[i]%2==0){
				a[i]=a[i]/2;
			}
			else{
				f=1;
				break;
			}
		}
		if(f==0)count++;
	}while(f==0);
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(200009);

int main(){
  int n,m;
  cin>>n>>m;

  map<int,int>mp;
  for(int i=2;i*i<=m;i++){
    while(m%i==0){
      mp[i]++;
      m/=i;
    }
  }
  if(m!=1)mp[m]=1;

  mint ans=1;
  for(auto x:mp){
    ans*=comb(x.se+n-1,x.se);
  }

  cout<<ans.x<<endl;
  return(0);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    int ans = a[n - 1];
    rep(i, n - k + 1)
    {
        ans = min(ans, a[i + k - 1] - a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 2e9;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j];
		}
	}
	int answer = inf;
	for (int mask = 0; mask < (1 << n); ++mask) {
		vector<int> cur(m);
		int cost = 0;
		for (int i = 0; i < n; ++i) {
			if ((mask >> i) & 1) {
				cost += c[i];
				for (int j = 0; j < m; ++j) {
					cur[j] += a[i][j];
				}
			}
		}
		bool ok = true;
		for (int j = 0; j < m; ++j) {
			if (cur[j] < x) {
				ok = false;
			}
		}
		if (ok) {
			answer = min(answer, cost);
		}
	}
	cout << (answer == inf ? -1 : answer) << '\n';
 	return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	while(cin>>n,n){
		vector<pair<string,string> >in(n);
		rep(i,n)cin>>in[i].first>>in[i].second;
		string S,T;
		cin>>S>>T;
		queue<pair<int,string> >que;
		que.push({0,S});
		while(!que.empty()){
			int co=que.front().first;
			string s=que.front().second;
			que.pop();
			
			rep(q,n){
				string t="";
				rep(i,s.size()){
					if(i+in[q].first.size()<=s.size()&&s.substr(i,in[q].first.size())==in[q].first){
						t+=in[q].second;
						i+=in[q].first.size()-1;
					}else t+=s[i];
				}
				if(t==T){
					cout<<co+1<<endl;
					goto end;
				}
				if(s!=t&&t.size()<T.size())que.push({co+1,t});
			}
		}
		cout<<-1<<endl;
		end:;
	}
}

Measured memory_bytes: 3208
//vvk
#include "bits/stdc++.h"
#define f first
#define s second
using namespace std;
using ll = long long;
const int N = 1e5 + 1;
const int mod = 1e9 + 7;
ll n , t , x , y , dp[101][N] , w , wt[N] , val[N]; 
int main()
{
 ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
 cin >> n >> w;
 for(int i = 1; i <= n; i++) {
 	cin >> wt[i] >> val[i];
 }
 for(int i = 1; i <= n; i++) {
 	for(int j = 0; j <= w; j++) {
 		if(wt[i] > j) dp[i][j] = dp[i - 1][j];
 		else dp[i][j] = max(val[i] + dp[i - 1][j - wt[i]] , dp[i - 1][j]);
 	}
 }
 cout << dp[n][w];
 return 0;
 }

Measured memory_bytes: 78720
#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/03  Problem: 019_agc_b / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string s;
	cin >> s;

	VVI cnt(SZ(s) + 1, VI(26, 0));
	FOR(i, 0, SZ(s)) {
		FOR(j, 0, 26) {
			cnt[i + 1][j] += cnt[i][j] + (s[i] - 'a' == j);
		}
	}
	ans = 1;
	FOR(i, 0, SZ(s)) {
		ans += i - cnt[i][s[i] - 'a'];
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 27028
#include<stdio.h>
#include<stdlib.h>
#include <math.h>
#include<string.h>
#include<limits.h>

int main(){
	double x,h,r,l,b,s=0.0;
	while(1){
	scanf("%lf%lf",&x,&h);
		if(x==0 && h==0)break;
	l=sqrt(x*x+x*x);
	b=sqrt(h*h+(l/2)*(l/2));
	r=sqrt(b*b-(x/2)*(x/2));
	s=x*x+r*x*2;
	
	printf("%f\n",s);
	}
return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <string>


using namespace std;
int main()
{
	long long a, b, k;

	cin >> a >> b >>k;
	
	if (a > 0) {
		if (a < k) {
			k -= a;
			a = 0;
		}
		else {
			a -= k;
			k = 0;
		}
	}

	if (b > 0 && k > 0) {
		if (b < k) {
			k -= b;
			b = 0;
		}
		else {
			b -= k;
			k = 0;
		}
	}

	cout << a <<" "<< b << endl;
	return 0;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  i64 N, X; cin >> N >> X;
  function<i64(i64,i64)> rec = [&](i64 a, i64 b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return a / b * 2 * b - b;
    else return a / b * 2 * b + rec(b, a % b);
  };
  i64 ans = X + (N - X) + rec(X, N - X);
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct Dinic {
	using Flow = int;
	struct Edge {
		int to, rev;
		Flow cap;
		Edge() {}
		Edge(int to, int rev, Flow cap) :to(to), rev(rev), cap(cap) {}
	};
	int n;
	vector<vector<Edge>> g;
	vector<bool> used;
	vector<int> level;
	vector<int> iter;
	Dinic(int n) :n(n), g(n), used(n), level(n), iter(n) {};
	void addArc(int from, int to, Flow cap) {
		g[from].emplace_back(to, (int)g[to].size(), cap);
		g[to].emplace_back(from, (int)g[from].size() - 1, 0);
	}
	void addEdge(int a, int b, Flow cap) {
		g[a].emplace_back(b, (int)g[b].size(), cap);
		g[b].emplace_back(a, (int)g[a].size() - 1, cap);
	}
	Flow maximumFlow(int s, int t) {
		Flow total = 0;
		while (true) {
			levelize(s);
			if (level[t] < 0)return total;
			fill(iter.begin(), iter.end(), 0);
			Flow f;
			while (true) {
				f = augment(s, t, INF);
				if (f == 0)break;
				total += f;
			}
		}
	}
	Flow augment(int v, int t, Flow f) {
		if (v == t)return f;
		for (int &i = iter[v]; i < g[v].size(); i++) {
			Edge &e = g[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				Flow d = augment(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					g[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	void levelize(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while (q.size()) {
			int v = q.front(); q.pop();
			for (int i = 0; i < g[v].size(); i++) {
				Edge &e = g[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	Dinic dnc(N);
	vector<vector<int>> g(N, vector<int>(N));
	vector<int> X(M), Y(M); rep(i, 0, M) {
		cin >> X[i] >> Y[i];
		X[i]--, Y[i]--;
		dnc.addEdge(X[i], Y[i], 1);
		g[X[i]][Y[i]] = i + 1;
	}
	int S, T; cin >> S >> T; S--, T--;
	cout << dnc.maximumFlow(S, T) << endl;
	vector<int> ans;
	rep(i, 0, N) {
		for (auto &e : dnc.g[i]) {
			if (g[i][e.to] && e.cap != 0) {
				ans.emplace_back(g[i][e.to]);
			}
		}
	}
	cout << ans.size() << endl;
	rep(i, 0, ans.size()) { cout << ans[i] << endl; }
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;

namespace AtCoderBeginnerContest142_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ab = Console.ReadLine().Split(' ');
            long A = long.Parse(ab[0]);
            long B = long.Parse(ab[1]);

            List<long> ans = new List<long>();
            long gcd = GreatestCommonDivisor(A, B);
            //Console.WriteLine(gcd);
            Dictionary<long, int> fac = Factorize(gcd);

            Console.WriteLine(fac.Count+1);
            //Console.WriteLine(string.Join(' ', fac.Keys));
            //Console.ReadKey();

        }

        public static Dictionary<long, int> Factorize(long n)
        {
            Dictionary<long, int> res = new Dictionary<long, int>();
            for(long i = 2; i*i < n; i++)
            {
                if (n % i != 0) continue;
                res.Add(i, 0);
                while(n%i == 0)
                {
                    n /= i;
                    res[i]++;
                }
            }
            if (n != 1) res.Add(n, 1);
            return res;
        }

        public static long GreatestCommonDivisor(long a, long b)
        {
            if(b == 0) { return a; }
            return GreatestCommonDivisor(b, a % b);
        }

    }
}


Measured memory_bytes: 13268
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AISing_2019_A solver = new AISing_2019_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class AISing_2019_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int w = in.nextInt();
            int h = in.nextInt();

            out.print((n - w + 1) * (n - h + 1));
        }

    }
}



Measured memory_bytes: 22864
#include<iostream>
#include<vector>
using namespace std;



int main(){
	int n;
	while(cin>>n &&n){
		vector<int> black;
		vector<int> white;
		int now;
		cin>>now;
		if(now==1)black.push_back(1);
		else white.push_back(1);
		for(int i=2;i<=n;i++){
			int in;
			cin>>in;
			
			if(i%2==0){
				if(in==now){
					if(in)black[black.size()-1]++;
					else white[white.size()-1]++;
					
				}
				else {
				
					if(in){
						if(!black.empty())black[black.size()-1]+=white[white.size()-1]+1;
						else black.push_back(white[white.size()-1]+1);
						white.pop_back();
					}
					else{
						if(!white.empty())white[white.size()-1]+=black[black.size()-1]+1;
						else white.push_back(black[black.size()-1]+1);
						black.pop_back();
					}
				}
				
			}
			else{
				if(in==now){
					if(in)black[black.size()-1]++;
					else white[white.size()-1]++;
				}
				else{
					if(in)black.push_back(1);
					else white.push_back(1);
				}
			}
			
			now=in;
		}
		int ans=0;
		for(int i=0;i<white.size();i++)ans+=white[i];
		cout<<ans<<endl;
		
	}
}

Measured memory_bytes: 1216
n = int(input())
h = list(map(int,input().split()))
g = [0]*n
ans = 0
l = 0
while not h == g:
  if not g[l] == h[l]:
    r = l+1
    while r <= n-1 and not g[r] == h[r]:
      r += 1
    #lは水やりが必要な左端、rはlより右で水やりが必要ない左端
    for i in range(l,r):
      g[i] += 1
    ans += 1
  if g[l] == h[l]:
    l += 1
print(ans)

Measured memory_bytes: 73348
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

INF=Float::INFINITY
class PriorityQueue
    attr_accessor:queue,:n
    def initialize(n)
        @n=0
        @queue=array(n,INF)
    end

    def push(x)
        i=@n
        @n+=1
        while i>0
          p=(i-1)/2
          break if x>=@queue[p]
          @queue[i]=@queue[p]
          i=p
        end
        @queue[i]=x
    end

    def pop()
       ret=@queue[0]
       @n-=1
       x=@queue[@n]
       i=0
       while i*2+1<@n
        l=i*2+1
        r=i*2+2 
        l=r if r<@n and @queue[l]>@queue[r]
        break if x<=@queue[l]
        @queue[i]=@queue[l]
        i=l
       end
       @queue[i]=x
       return ret
    end
end

N,M=get_i
pq=PriorityQueue.new(N)
ab=Array.new(M+1){[]}
N.times do|i|
    a,b=get_i
    ab[a].push(b) if M>=a
end
ans=0
1.upto(M) do|i|
    ab[i].each do|b|
        pq.push(-b)
    end
    if pq.n>0
        b=pq.pop
        ans-=b
    end
end
puts ans

Measured memory_bytes: 11260
#!/usr/bin/env python3
#!/usr/bin/env pypy3

from math import *

def main():
    import sys
    sys.dont_write_bytecode = True
    sys.setrecursionlimit(10000000)

    input = sys.stdin.readline

    #import numpy as np
    #import scipy as sp

    # Python 3 modules: https://docs.python.org/3/library/

    import os
    import math, itertools, operator
    from math import factorial as fact
    from operator import itemgetter, attrgetter
    from itertools import permutations, combinations
    from functools import reduce, lru_cache
    # Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
    # Before Python 3.5.  Import from math after it.
    from fractions import gcd
    from fractions import Fraction as Frac

    inf = float('inf')
    pow = __builtins__.pow

    def lcm(a, b):
        return a * b // gcd(a,b)

    def perm(a, b):
        import scipy.special
        return scipy.special.perm(a, b, exact = True)

    def comb(a, b):
        import scipy.special
        return scipy.special.comb(a, b, exact = True)

    def dfact(n):
        import scipy.special
        return scipy.special.factorial2(n, exact = True)

    def prod(l):
        return reduce(operator.mul, l)

    def input_ints(func = input, sep = None, conv = int):
        return list(map(conv, func().split(sep = sep)))

    if os.environ.get('GOROOT') is None:
        def dprint(*args, **kwargs):
            kwargs['file'] = sys.stderr
            import inspect
            frame = inspect.currentframe().f_back
            print('[' + os.path.basename(frame.f_code.co_filename)
                    + ':' + str(frame.f_lineno) + ']', *args, **kwargs)
    else:
        def dprint(*args, **kwargs):
            pass


    ############################################################################


    A, B, C = list(map(int, input().split()))
    print(max(C - (A - B), 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N;
  string s,a,b;
  int flag;
  flag=0;
  cin>>N>>s;
 if(N!=1&&N%2==0){
  for(int i=0;i<N/2;i++){
      
  if(s[i]!=s[i+N/2]){
    cout<<"No"<<endl;
         break;
  }else{}
     if(i==N/2-1)flag=1;
  }
    if(flag==1){cout<<"Yes"<<endl;}
   
   }else{   cout<<"No"<<endl;}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	char c;
	cin >> c;
	if (isupper(c)) {
		cout << "A" << endl;
	}
	else {
		cout << "a" << endl;
	}
	return 0;
}

Measured memory_bytes: 3632