akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  string ans="YES";
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
  sort(a.begin(),a.end());
 for(int i=0;i<n-1;i++){
  if(a[i]==a[i+1]){
    ans="NO";
    break;
  }
 }
  cout<<ans<<endl;
}


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

int parent[200005], ranks[200005];

void initset(int n) {
    for (int i = 0; i < n; i++) {
        parent[i] = i;
        ranks[i] = 0;
    }
}

int findset(int x) {
    if (parent[x] == x) return x;
    parent[x] = findset(parent[x]); // path compression
    return parent[x];
}

bool sameset(int x, int y) {
    return findset(x) == findset(y);
}

void mergeset(int x, int y) {
    x = findset(x); // find representatives
    y = findset(y);
    if (ranks[x] > ranks[y]) {
        parent[y] = x;
    } else { // rank[x] <= rank[y]
        parent[x] = y;
        if (ranks[x] == ranks[y]) {
            ranks[y]++;
        }
    }
}

int N, M, K, L;

int main() {

    cin >> N >> M;
    initset(N+M+5); // 5 is a bit of buffer
    for (int i = 0; i < N; i++) {
        cin >> K;
        for (int j = 0; j < K; j++) {
            cin >> L;
            mergeset(i+1, N+L);
        }
    }

    for (int i = 1; i <= N; i++) {
        if (!sameset(i, 1)) {
            cout << "NO\n";
            return 0;
        }
    }

    cout << "YES\n";

}




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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    vector<ll> sum(n+1, 0);
    map<ll, ll> m;
    m[0] = 1;
    ll ans = 0;
    rep(i, n) {
        ll a; cin >> a;
        sum[i+1] = sum[i] + a;
        if(m.count(sum[i+1])) ans += m[sum[i+1]];
        
        if(m.count(sum[i+1])) m[sum[i+1]]++;
        else m[sum[i+1]] = 1;
    }

    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	ll w, h, x, y;
	cin >> w >> h >> x >> y;

	double ans = 1.*(h * w) / 2.;
	cout << setprecision(15);
	cout << ans << " " ;
	if(h  == 2 * y && w == 2*x){
		cout << 1;
	} else cout << 0;
	cout << endl;
}


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

string str, ans;

int main()
{
	cin >> str;
	for (int i = 0; i < str.length(); i++)
		if (str[i] == 'B')
		{
			if (!ans.empty()) ans.pop_back();
		}
		else ans += str[i];

	cout << ans << endl;

	return 0;
}


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


int main()
{
    int N,A,B,C;
    cin>>N;
    vector <int> va;
    for(int i=0; i<N; i++)
    {
        cin>>A;
        va.push_back(A);
    }

    vector <int> vb;
    for(int i=0; i<N; i++)
    {
        cin>>B;
        vb.push_back(B);
    }

    vector <int> vc;
    for(int i=1; i<N; i++)
    {
        cin>>C;
        vc.push_back(C);
    }

    int ans=0;
    for(int j=0; j<N; j++)
    {
		ans += vb[va[j]-1];
		if(j>0&&va[j]-va[j-1]==1)
        {
            ans += vc[va[j]-2];
        }
	}

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



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

using namespace std;

int main(){

string S;

cin >> S;

string days[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

for (int i = 0; i < 7; i++)
{
	if (days[i] == S)
	{
		cout << 7-i;
		break;
	}
}


}

Measured memory_bytes: 256
X= int(input())

while True:
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    #print(pf)

    if (len(pf)==1) and (list(pf.values())[0]==1):
        break
    else:
        X +=1
        
print(m)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int H,W; cin >> H >> W;
  vector<string> s(H);
  for (int i = 0; i < H; i++) cin >> s[i];
  
  vector<vector<int>> dist(H, vector<int>(W,-1));
  dist[0][0] = 1;
  queue<pair<int, int>> que;
  que.push(make_pair(0,0));
  const vector<int> dy = {-1,0,0,1};
  const vector<int> dx = {0,-1,1,0};
  
  while(!que.empty()) {
    int y = que.front().first;
    int x = que.front().second;
    que.pop();
    for (int i = 0; i < 4; i++) {
      const int yy = y + dy[i];
      const int xx = x + dx[i];
      if (yy >= 0 && yy < H && xx >= 0 && xx < W && s[yy][xx] == '.' && dist[yy][xx] == -1) {
        que.push(make_pair(yy,xx));
        dist[yy][xx] = dist[y][x] + 1;
      }
    }
  }
  int count = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '.') count++;
    }
  }
  
  if (dist[H-1][W-1] == -1) cout << -1 << endl;
  else cout << count - dist[H-1][W-1] << endl;   
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long max=max(A,B);
		long cnt=0;
		long sqmax=(long)Math.sqrt(max);
		for(long i=1;i<=sqmax;i++) {
			if(max%i==0) {
				long j=max/i;
				if(sosu(i)) {
					cnt++;
				}
				if(i!=j&&sosu(j)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
	public static boolean sosu(long a) {
		long x=(long)Math.sqrt(a);
		for(long i=2;i<=x;i++) {
			if(a%i==0) {
				return false;
			}
		}

		return true;
	}
	public static long max(long a,long b) {
		long x=(long)Math.sqrt(a);
		for(long i=1;i<=x;i++) {
			if(a%i==0) {
				i=a/i;
				if(b%i==0) {
					return i;
				}
				i=a/i;
			}
		}
		for(long i=x;i>0;i--) {
			if(a%i==0) {
				//x=a/x;
				if(b%i==0) {
					return i;
				}
				//x=a/x;
			}
		}
		return 1;
	}

}

Measured memory_bytes: 23760
N = int(input())

def read(i):
    print(i, flush=True)
    s = input()
    if s == 'Vacant':
        exit()
    return s

s = read(0)
isMale = 0 if s == 'Male' else 1
s = read(N - 1)

A = [i % 2 == isMale for i in range(N)]

ok = 0
ng = N
while ng - ok > 1:
    mid = (ok + ng) // 2
    s = read(mid)

    isMale = s == 'Male'

    if isMale == A[mid]:
        ok = mid
    else:
        ng = mid

read(ng)
read(ok)
exit()


Measured memory_bytes: 4584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int n;

bool b[222222];
int a[222222];
int main(void)
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

	int bind = 1;

	for (int i = n; i >= 1; i-=2)
	{
		printf("%d ", a[i]);
		b[i] = true;
	}
	for (int i = 1; i <= n; i++)
	{
		if (b[i]) continue;
		printf("%d ", a[i]);
	}
	printf("\n");
	return false;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <math.h>
 
int main() {
 
  double a,b,c;
  double S,L2, L, h;
 
  scanf("%lf %lf %lf",&a,&b,&c);
 
  S = 0.5*a*b*sin(c*3.14159265359/180);
  L2 = a*a+b*b-2*a*b*cos(c*3.1415926359/180);
  L = sqrt(L2)+a+b;
  h = 2*S/a;
 
  printf("%.11lf\n%.11lf\n%.11lf\n",S ,L,h); 
 
  return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int X; cin >> X;
	for (int i = -118; i < 120; ++i) {
		for (int j = -119; j < 119; ++j) {
			if (X == (pow(i, 5) - pow(j, 5))) {
				cout << i << " " << j << endl;
				return;
			}
		}
	}	
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4048
use std::io;


fn main() {
    let _ = read_one::<usize>();
    let (s, t) = {
        let i = read::<String>();
        (i[0].clone(), i[1].clone())
    };
    let s = s.chars().collect::<Vec<_>>();
    let t = t.chars().collect::<Vec<_>>();
    for (a, b) in s.iter().zip(t.iter()) {
        print!("{}{}", a, b);
    }
    println!();
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int cnt1=0,cnt2=0,n;
	string s,w;
	cin>>s;
	n=s.length();
	vector<string>a((n-1)/2),ac((n-1)/2),b(n-(n+3)/2+1),bc(n-(n+3)/2+1);
	for(int i=0;i<(n-1)/2;i++){
		a.at(i)=s.substr(i,1);
	}
	ac=a;
	reverse(a.begin(),a.end());
	if(a==ac){
		cnt2++;
	}
	for(int i=((n+3)/2)-1;i<n;i++){
		b.at(cnt1)=s.substr(i,1);
		cnt1++;
	}
	bc=b;
	reverse(b.begin(),b.end());
	if(b==bc){
		cnt2++;
	}
	w=s;
	reverse(w.begin(),w.end());
	if(s==w){
		cnt2++;
	}
	if(cnt2>=3){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int ssn;
	int i;
	int bit1[7] = {0};
	int bit2[7] = {0};
	int sd[10][7] = {
		{0, 1, 1, 1, 1, 1, 1},
	    {0, 0, 0, 0, 1, 1, 0},
	    {1, 0, 1, 1, 0, 1, 1},
	    {1, 0, 0, 1, 1, 1, 1},
	    {1, 1, 0, 0, 1, 1, 0},
	    {1, 1, 0, 1, 1, 0, 1},
	    {1, 1, 1, 1, 1, 0, 1},
	    {0, 1, 0, 0, 1, 1, 1},
	    {1, 1, 1, 1, 1, 1, 1},
	    {1, 1, 0, 1, 1, 1, 1},
	};
	
	while (scanf("%d", &n), n != -1){
		
		while (n--){
			scanf("%d", &ssn);
			for (i = 0; i < 7; i++){
				bit1[i] = sd[ssn][i];
			}
			for (i = 0; i < 7; i++){
				if (bit1[i] == bit2[i]){
					printf("0");
				}
				else {
					printf("1");
				}
				bit2[i] = bit1[i];
			}
			printf("\n");
		}
		for (i = 0; i < 7; i++){
			bit2[i] = 0;
		}
	}
	
	return (0);
}

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

std::string o, e;

int main(){
std::cin >> o >> e;
std::vector<char> answer(o.size()+e.size());

for(int i = 0; i < o.size()+e.size(); ++i){
	if(i%2 == 0){
		answer[i] = o[i/2];
	}
	else{
		answer[i] = e[i/2];
	}
}
for(int i = 0; i < o.size()+e.size(); ++i){
	if(i == o.size()+e.size()-1){
    	std::cout << answer[i] << std::endl; 
    }
	else{
    	std::cout << answer[i];
	}
}
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long linf = 4523372036854775807;
const int inf = 1500000000;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n, a, b, sum = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		string s = to_string(i);
		int res = 0;
		for (int j = 0; j < s.size(); j++)
			res += (int)s[j] - '0';
		if (a <= res&&res <= b)
			sum += i;
	}
	cout << sum << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll a,b,c;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> a >> b >> c;
}

int solve(){
    if(c<a+b) {cout << "No" << endl; return 0;}
    ll low=4*a*b;
    ll up=(c-a-b)*(c-a-b);
    // double low = sqrt(a)+sqrt(b);
    // double up = sqrt(c);
    string ans = (low<up) ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int A,B,C,X,Y;
    long long int yen=0;
    scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);

    if(A+B>2*C){
        if(X>=Y){
            yen+=Y*2*C;
            X-=Y;
            Y=0;
            if(A<2*C){
                yen+=A*X;
                X=0;
            } else {
                yen+=C*2*X;
                X=0;
            }
        } else {
            yen+=X*2*C;
            Y-=X;
            X=0;
            if(B<2*C){
                yen+=B*Y;
                Y=0;
            } else {
                yen+=C*2*Y;
                Y=0;
            }
        }
    } else {
        if(X>=Y){
            yen+=(A+B)*Y;
            X-=Y;
            Y=0;
            yen+=X*A;
        } else {
            yen+=(A+B)*X;
            Y-=X;
            X=0;
            yen+=Y*B;
        }
    }

    printf("%lld\n",yen);

    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)
typedef long long ll;

bool check(int a, int b, int c) {
    if (a < c) {
        if (a < b && b < c) return true;
    } else {
        if (c < b && b < a) return true;
    }
    return false;
}

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

    int n;
    cin >> n;
    int p[n];
    rep (i, n) {
        cin >> p[i];
    }
    int res = 0;
    Rep (i, 1, n - 1) {
        if (check(p[i-1], p[i], p[i+1])) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3652
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();

		int amari = N % 10;
		int sho = N / 10;

		if (amari == 9) {
			System.out.println("Yes");
		} else if (sho == 9) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 26960
#!/usr/bin/env python3
from collections import defaultdict, deque
from copy import copy

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
grid = [list(map(int, input().split())) for _ in range(H)]

d = defaultdict(lambda: float("inf"))
d["1_1"] = 0
nums = [i for i in range(10) if i != 1]

q = deque([[[1], 0]])

while q:
    tmp = q.pop()
    num, cost = tmp[0], tmp[1]
    if len(num) > 1:
        key = str(num[-1]) + "_1"
        d[key] = min(d[key], cost)
    if len(num) < 10:
        for n in nums:
            num_tmp = copy(num)
            if n not in set(num_tmp):
                num_tmp.append(n)
                q.append([num_tmp, cost + c[n][num_tmp[-2]]])

ans = 0
for i in range(H):
    for j in range(W):
        tmp = grid[i - 1][j - 1] 
        if tmp >= 0:
            ans += d[str(tmp) + "_1"]
print(ans)

Measured memory_bytes: 47252
let to_list str =
  let n = String.length str in
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (str.[i] :: acc)
  in
  doit 0 []

let to_int c = int_of_char c - int_of_char '0'

let plus l1 l2 =
  let f x =
    if x <= 9 then (x, 0) else (x mod 10, 1)
  in
  let rec doit acc = function
    | ([], [], 1) -> 1 :: acc
    | ([], [], _) -> acc
    | (a :: b, [], z) ->
        let s, t = f (to_int a + z) in
        doit (s :: acc) (b, [], t)
    | ([], c :: d, z) ->
        let s, t = f (to_int c + z) in
        doit (s :: acc) ([], d, t)
    | (a :: b, c :: d, z) ->
        let s, t = f (to_int a + to_int c + z) in
        doit (s :: acc) (b, d, t)
  in
  doit [] (to_list l1, to_list l2, 0)

let () =
  let n = read_int () in
  let rec doit i =
    if i < n then begin
      let l1 = read_line () in
      let l2 = read_line () in
      let n1 = String.length l1 in
      let n2 = String.length l2 in
      if n1 > 80 || n2 > 80 then print_endline "overflow"
      else if n1 < 10 && n2 < 10 then Printf.printf "%d\n" (int_of_string l1 + int_of_string l2)
      else begin
        let ans = plus l1 l2 in
        if List.length ans > 80 then print_endline "overflow"
        else (List.iter (fun e -> print_int e) ans; print_newline ())
      end;
      doit (i + 1)
    end
  in
  doit 0

Measured memory_bytes: 2384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int count=0;
    for(int i=0;i<s1.size();i++)
        if(s1[i]!=s2[i]) count++;
    
    cout<<count<<endl;
    return 0;
}

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

int main()
{
  char s[11];
  char t[12];
  
  cin >> s;
  cin >> t;
  
  for(int i = 0; t[i] != '\0'; i++){
    if(s[i] == '\0'){
      cout << "Yes";
      break;
    }
    
    if(s[i] != t[i]){
      cout << "No";
      break;
    }
  }
  
  return 0;
}

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

int main() {
  int N;

  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }

  int Alice=0;
  int Bob=0;

  for(int i=0; i<N; i++){

    int card=0;
    for(int j=0; j<N; j++){
      card = max(card, a.at(j));
      }

    Alice += card;
    for(int j=0; j<N; j++){
      if(card == a.at(j)){
        a.at(j)=0;
        break;
      }
    }

    card =0;
    for(int j=0; j<N; j++){
      card = max(card, a.at(j));
    }

    Bob += card;
    for(int j=0; j<N; j++){
      if(card == a.at(j)){
        a.at(j)=0;
        break;
      }
    }
  }

  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

H, W = [int(x) for x in input().strip().split()]
S = [list(input().strip()) for _ in range(H)]
C = [['.'] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '#' and C[i][j] == '.':
            for i2, j2 in zip([1, 0, -1, 0],[0, 1, 0, -1]):
                if i+i2 < 0 or i+i2 >= H or j+j2 < 0 or j+j2 >= W:
                    continue
                if S[i+i2][j+j2] == '#':
                    C[i][j] = C[i+i2][j+j2] = '#'
                    break
            else:
                print('No')
                exit()

print('Yes')

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func kaibun(s string) bool {
	log.Println(s)
	for i := 0; i < len(s)/2; i++ {
		if s[i] != s[len(s)-i-1] {
			return false
		}
	}
	return true
}

func main() {
	S := nextString()
	if len(S)%2 == 1 {
		if kaibun(S) {
			if kaibun(S[(len(S)+3)/2-1:]) {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> MP(N + 1);
    for (ll i = 0; i < M; i++)
    {
        ll ai, bi;
        cin >> ai >> bi;
        MP[ai].push_back(bi);
        MP[bi].push_back(ai);
    }

    vector<ll> MIN(N + 1, -1);

    queue<ll> Q;
    Q.push(1);
    ll cnt = 1;
    while (!Q.empty())
    {
        queue<ll> NQ;

        while (!Q.empty())
        {
            ll top = Q.front();
            Q.pop();

            vector<ll> dist = MP[top];
            
            for (auto &&e : dist)
            {
                if (MIN[e] == -1)
                {
                    MIN[e] = top;
                    NQ.push(e);
                }
            }
        }
        Q = NQ;
        cnt += 1;
    }

    bool ok = true;
    for (ll i = 2; i <= N; i++)
    {
        if (MIN[i] == -1)
        {
            ok = false;
        }
    }

    if (ok == false)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
        for (ll i = 2; i <= N; i++)
        {
            cout << MIN[i] << endl;
        }
    }
}


Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define int ll
using ll=long long;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int N, D; cin >> N >> D;
    END( (N+D+D) / (D+D+1) );
}



Measured memory_bytes: 256
input = readlines()
n, m = input.shift.chomp.split("\s").map{|x| x.to_i}

tree = Array.new(n, -1)

def getRoot(tree, target)
  tmp = []
  while(tree[target] > -1)
    target = tree[target]
    tmp.push(target)
  end
  tmp.each do |t|
    tree[t] = target unless t == target
  end
  target
end

input.each do |l|
  a, b = l.chomp.split("\s").map{|x| x.to_i - 1}.sort
  a_root = getRoot(tree, a)
  b_root = getRoot(tree, b)
  next if a_root == b_root

  tree[a_root] += tree[b_root]
  tree[b_root] = a_root
end

max = 0
tree.each do |v|
  next if v > -1
  size = v * -1
  max = size if max < size
end

puts max


Measured memory_bytes: 35828
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> ret(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ret[x - 1] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        if (i > 0)cout << " ";
        cout << ret[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
	int f=0,cur=0,n;cin>>n;
	while(n--){
		int a,b;cin>>a>>b;
		if(a==b) cur++;
		else cur=0;
		if(cur==3) f=1;}
	cout<<(f? "Yes":"No");
	}



Measured memory_bytes: 3632
#include"bits/stdc++.h"

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;

using namespace std;

int main(void) {
	string S; cin >> S;
	int cnt = 0;
	ll ans = 0;

	rep(i, S.length()) {
		if (S[i] == 'W') {
			ans += i - cnt;
			cnt++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
int n,x,ans;
signed main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(i == 1)
            ans = x;
        else
            ans = __gcd(x,ans);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

map<int,vi> link;
map<int,int> add;
vi ans;
vector<bool> visited;

void dfs(int v, int a) {
    // printf("v:%d a:%d\n",v,a);
    a += add[v];
    ans[v] += a;
    visited[v] = true;
    for(auto c : link[v]) {
        if(visited[c]) continue;
        dfs(c,a);
    }
}

int main() {
    int t,x; cin >> t >> x;
    cout << (double)(1.0*t/x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
bool pr(ll n){
    for(int i = 2; i <= sqrt(n); i++){
        if(n%i==0)return false;
    }
    return true;
}
void foo(){
    int n;
    cin>>n;
    for(int i = 0; i < n; i++){
        if(pr(i+n)){
            cout<<i+n;
            return;
        }
    }   
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
	IOS;
	ll n, x;
	ll sum = 0;
	cin >> n >> x;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum == x)dump(n);
	else if (sum < x)dump(n - 1);
	else {
		sort(ALL(a));
		ll tmp = 0;
		ll ans = 0;
		REP(i, n) {
			tmp += a[i];
			if (tmp > x)break;
			ans++;
		}
		dump(ans);
	}
  	return 0;
}

Measured memory_bytes: 256
n, x = [int(i) for i in input().split()]

def tlen(L):
    l = 1
    for i in range(1, L):
        l = l*2 + 3
    return l

def tpat(L):
    p = 1
    for i in range(1, L):
        p = p*2 + 1
    return p

def maisu(n, x):
    tl = tlen(n)
    if x == 1:
        return(0)
    elif n == 1:
        b = "bpppb"
        b = b[:x]
        return(b.count("p"))
    elif 2 <= x <= 1+tl-1:
        return(maisu(n-1, x-1))
    elif x == 1+tl:
        return(tpat(n))
    elif x == 2+tl:
        return(tpat(n)+1)
    elif tl+3 <= x <= 1+tl*2:
        return(tpat(n)+1+maisu(n-1,x-2-tl))
    else:
        return(tpat(n)*2+1)  

print(maisu(n,x))

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


i64 N, A, B;


int main() {
    cin >> N >> A >> B;
    i64 s = A + B;
    if (s == 0) {
        cout << 0 << endl;
        return 0;
    }
    i64 res = (N / s) * A;
    res += min(N % s, A);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,M = MI()

if N == 1:
    ans = -1
    for i in range(M):
        s,c = MI()
        if ans == -1:
            ans = c
        elif c != ans:
            print(-1)
            break
    else:
        if M != 0:
            print(ans)
        else:
            print(0)
    exit()


ANS = [-1]*N
for i in range(M):
    s,c = MI()
    if ANS[s-1] == -1:
        ANS[s-1] = c
    elif ANS[s-1] != c:
        print(-1)
        exit()

for i in range(N):
    if i == 0 and ANS[i] == 0:
        print(-1)
        exit()
    elif i == 0 and ANS[i] == -1:
        ANS[i] = '1'
    elif ANS[i] == -1:
        ANS[i] = '0'
    else:
        ANS[i] = str(ANS[i])

print(''.join(ANS))


Measured memory_bytes: 61984
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, k) = get!(i64, i64);
    if k % 2 == 1 {
        let mut count: i64 = 0;
        for i in 1..n + 1 {
            if i % k == 0 {
                count += 1;
            }
        }
        println!("{}", count.pow(3));
    } else {
        let mut mod_a: i64 = 0;
        let mut mod_b: i64 = 0;
        for i in 1..n + 1 {
            if i % k == 0 {
                mod_a += 1;
            } else if i % (k / 2) == 0 {
                mod_b += 1;
            }
        }
        let mut ans = mod_a.pow(3);
        ans += mod_b.pow(3);
        println!("{}", ans);
    }
}


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

int main (void) {

    int N, K, X, Y;
    int sum = 0;

     cin >> N >> K >> X >> Y;

     for (int i = 1; i <= N; i++ ){

        if (N > K) {

            sum = ((K * X) + (N - K) * Y) ;
        
        }else {
            
            sum = N * X;
         
         } 
     }

    cout << sum << endl;


    return 0;
}



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

int main(){
int k;char f1,f2,f3;
cin >> k;
int keta = log10(k)+1;int tmp = k;
//printf("keta:%d\n",keta);
int num[keta];
for(int i=0;i<keta;i++){
  num[i]=tmp%10;
  tmp = (tmp-num[i])/10;
}
//for(int i=0;i<keta;i++){
  //cout << num[i] << "\n";
//}
for(int i=-1;i<=1;i+=2){
  for(int j=-1;j<=1;j+=2){
    for(int k=-1;k<=1;k+=2){
      if(num[3] + num[2]*i + num[1]*j + num[0]*k == 7){
        if(i==-1)f1='-';else f1='+';
        if(j==-1)f2='-';else f2='+';
        if(k==-1)f3='-';else f3='+';
        cout << num[3] << f1 << num[2] << f2 << num[1] << f3 << num[0] << "=7";
        return 0;
      }
    }
  }
}
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

struct move_coin{int from_y, from_x, to_y, to_x;};

std::vector<move_coin> ans;
int a[500][500];

void move(int from_y, int from_x, int to_y, int to_x){
  if(a[from_y-1][from_x-1]%2==0) return;
  move_coin m;
  m.from_y = from_y, m.from_x = from_x, m.to_y = to_y, m.to_x = to_x;
  ans.push_back(m);
  a[from_y-1][from_x-1]--;
  a[to_y-1][to_x-1]++;
}

int main(){
  int h,w;
  cin >> h >> w;
  REP(i,h)REP(j,w){
    cin >> a[i][j];
  }
  REP(i,h){
    if(i%2==0){
      REP(j,w-1){
        move(i+1,j+1,i+1,j+2);
      }
      if(i!=h-1){
        move(i+1,w,i+2,w);
      }
    }else{
      REP(j,w-1){
        move(i+1,w-j,i+1,w-j-1);
      }
      if(i!=h-1){
        move(i+1,1,i+2,1);
      }
    }
  }
  cout << ans.size() << endl;
  for(auto m : ans){
    printf("%d %d %d %d\n", m.from_y, m.from_x, m.to_y, m.to_x);
  }
  return 0;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
#define pa pair<int,int>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
const int maxn=1;

inline char gc(){
	return getchar();
	static const int maxs=1<<16;static char buf[maxs],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxs,stdin),p1==p2)?EOF:*p1++;
}
inline ll rd(){
    ll x=0;char c=gc();bool neg=0;
    while(c<'0'||c>'9'){if(c=='-') neg=1;c=gc();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-'0',c=gc();
    return neg?(~x+1):x;
}

ll A,B,C,D;

inline ll gcd(int a,int b){
	return a?gcd(b%a,a):b;
}

int main(){
    //freopen("","r",stdin);
    A=rd(),B=rd(),C=rd(),D=rd();
    ll E=C*D/gcd(C,D);
    printf("%lld\n",(B-A+1)-(B/C-(A-1)/C)-(B/D-(A-1)/D)+(B/E-(A-1)/E));
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}


struct edge {int to,cap,rev;};
const int MAX_V=30000,inf=1e9;
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
void init(int V){
	rep(i,V) G[i].clear();
}
void add_edge(int from, int to, int cap){
	edge e1={to,cap,G[to].size()},e2={from,0,G[from].size()};
	G[from].push_back(e1);
	G[to].push_back(e2);
}
void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s]=0;
	que.push(s);
	while(!que.empty()){
		int v=que.front();
		que.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;
				que.push(e.to);
			}
		}
	}
}
int dfs(int v,int t,int 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]){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int flow=0;
	while(true){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while( (f=dfs(s,t,inf))>0 ) flow+=f;
	}
}


int H,W;
string s[1000];

int main(){
	cin>>H>>W;
	rep(i,H) cin>>s[i];
//	V = H*W*2 + H+W;
	int S = -1, T = -1;
	rep(i,H) rep(j,W){
		int id = i*W+j;
		if(s[i][j]=='o') add_edge(id*2,id*2+1,1);
		add_edge(id*2+1,H*W*2+i,inf);
		add_edge(H*W*2+i,id*2,inf);
		add_edge(id*2+1,H*W*2+H+j,inf);
		add_edge(H*W*2+H+j,id*2,inf);
		if(s[i][j]=='S') S = id*2+1;
		if(s[i][j]=='T') T = id*2;
	}
	int f = max_flow(S,T);
	if(f>=1e5) puts("-1");
	else cout<<f<<endl;
}


Measured memory_bytes: 3072
/* Isn't passion overrated?*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll mod = 998244353;
ll power(ll a, ll x)
{
    if(x == 0)
        return 1;
    ll ans = power(a, x/2);
    ans *= ans;
    ans %= mod;
    if(x % 2)
        ans *= a;
    return ans % mod;
}

vector<ll>per(200010);

ll ncr(ll n, ll i)
{
    return (per[n] % mod * power(per[i], mod-2) % mod * power(per[n-i], mod-2) % mod)%mod;
}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n, m, k;
    cin >> n >> m >> k;
    per[0] = 1;
    ll h = per.size();
    for(ll i = 1; i < h; i++)
    {
        per[i] = i * per[i-1];
        per[i] %= mod;
    }
    ll ans = 0;
    for(ll i = 0; i <= k; i++)
    {
        ll temp = ncr(n-1, i)%mod;
        temp = (temp * m) % mod;
        temp = (temp * power(m-1,n-1-i) % mod) % mod;
        ans = ans + temp;
        ans %= mod;
    }
    cout<<ans % mod;
    return 0;
}


Measured memory_bytes: 4660
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
#include <set>
#include <unordered_set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int n;
ll c;

ll xVal[100002];
ll v[100002];
int f[100002];
int f2[100002];

ll calc(int a, int b) //a to b
{
    if (a < b) return -1e18;
    
    ll ret = 0;
    
    ll x = c-xVal[a];
    ll y = xVal[b];
    
    
    ret += v[n]-v[a-1]; //cover x
    ret += v[b]; //cover y

    ret -= min(2*x + y, 2*y + x);
    
    if (a == b)
    {
        return v[n] - min({2*x + y, 2*y + x, xVal[n], c-xVal[1]});
    }
    
    return ret;
}

ll solve()
{
    ll ret = 0;
    
    for (int a = 0; a <= n+1; a++) //fix A
    {
        ret = max(ret, calc(a,f[a]));
        ret = max(ret, calc(a,f2[a]));
        
        //cout << a << ' ' << f[a] << '\n';
        //cout << calc(a, f[a]) << "\n\n";
    }

    return ret;
}

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    cin >> n >> c;
    
    for (int i = 1; i <= n; i++) cin >> xVal[i] >> v[i];
    for (int i = 1; i <= n; i++) v[i] += v[i-1];
    xVal[n+1] = c;
    xVal[0] = 0;
    
    
    ll mx = 0;
    int w = 0; //best choice for B
    for (int i = 0; i <= n+1; i++)
    {
        ll cur = v[i]-xVal[i];
        f[i] = w;
        if (cur > mx)
        {
            mx = cur;
            w = i;
        }
    }
    
    mx = 0;
    w = 0; //best choice for B
    for (int i = 0; i <= n+1; i++)
    {
        ll cur = v[i]-2*xVal[i];
        f2[i] = w;
        if (cur > mx)
        {
            mx = cur;
            w = i;
        }
    }
    
    cout << solve() << '\n';
    
    return 0;
    
}




Measured memory_bytes: 2560
import math
import bisect
N=1000000
prime=[1]*(N+1)
prime[0]=0
prime[1]=0
for i in range(2,int(math.sqrt(N))):
    if prime[i]==1:
        j=i
        while i*j<=N:
            prime[i*j]=0
            j+=1
prime=[i for i in range(N+1) if prime[i]==1]

while True:
    n=input()
    if n==0:break
    cnt=0
    for i in range(n):
        p,m=map(int,raw_input().split())
        l=bisect.bisect_left(prime,p-m)
        u=bisect.bisect_left(prime,p+m+1)
        cnt+=u-l
    print cnt-n

Measured memory_bytes: 44724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int c[] = new int[N];
		int v[] = new int[N];
		int p[] = new int[N];

		for (int i = 0; i < v.length; i++) {
			v[i] = sc.nextInt();
		}
		for (int i = 0; i < v.length; i++) {
			c[i] = sc.nextInt();
			p[i] = v[i] - c[i];
		}

		int ans=0;
		for (int i = 0; i < N; i++) {
			if (p[i] >=0) {
				ans += p[i];
			}
		}
		System.out.println(ans);

	}
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

int main()
{
    int N;
    cin >> N;
    vector<vector<long long>> a(N, vector<long long>(N));
    REP(i, N){
        REP(j, N) cin >> a[i][j];
    }

    // count[i]: i の bit が立っているうさぎで一つのグループを作るときの点数
    vector<long long> count(1<<N);
    REP(i, 1<<N){
        REP(j, N){
            FOR(k, j+1, N){
                if(i & (1<<j) and i & (1<<k)) count[i] += a[j][k];
            }
        }
    }
    // dp[i]: i の bit が立っているうさぎのグループが決まっているとした場合の得点の最大値
    vector<long long> dp(1<<N);
    REP(i, 1<<N){
        for(int j = i; j > 0; --j){
            j &= i;
            dp[i] = max(dp[i], dp[i-j]+count[j]);
        }
    }
    cout << dp[(1<<N)-1] << endl;

    return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC108_A();
        }

        static void ABC108_A()
        {
            var K = int.Parse(Console.ReadLine());
            var a = 0;
            var b = 0;
            for(var i = 1; i <= K; i+=2)
                    a++;

            for (var i = 2; i <= K; i+=2)
                    b++;

            Console.WriteLine(a * b);
        }
    }
}

Measured memory_bytes: 11092