akhauriyash/Code-Regression huggingface dataset:
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int sum = 0;
        loop(1, n + 1) {
            if (i % 3 != 0 && i % 5 != 0) {
                sum += i;
            }
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

char ss[26];
int main(){
    int x, t;
    cin >> x >> t;
    int ans;
    if(x-t<0) ans = 0;
    else ans = x-t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    string s; cin >> s;
    string res = "yes";
    rep(i,s.length()){
        rep(j,s.length()){
            if(i!=j){
                if(s[i]==s[j]) res="no";
            }
        }
    }
    pr(res);

    
}



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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 5007;
const int MX = 1e9 + 7;
const LL INF = 1LL * MX * MX;

int n, a, b;
int dp[N][N][3];

void add(int &a, int b){
	a += b;
	if(a >= MX)
		a -= MX;
}

int main(){
	scanf("%d %d %d", &n, &a, &b);
	if(a > b)
		swap(a, b);

	if(a == 1){
		int ans = 1;
		while(n--)
			add(ans, ans);
		printf("%d\n", ans);
		exit(0);
	}

	dp[1][a - 1][0] = 1;
	dp[1][b - 1][1] = 1;
	dp[a][0][2] = 1;
	
	for(int i = 1; i < n; ++i){
		for(int c = 0; c < 3; ++c)
			add(dp[i + 1][0][2], dp[i][0][c]);
		
		for(int c = 0; c < 3; ++c)
			if(i + 1 < b)
				add(dp[i + 1][b - i - 1][1], dp[i][0][c]);
			else
				add(dp[i + 1][0][2], dp[i][0][c]);
		
		for(int j = 1; j < b && n - i >= j; ++j){
			{	//c = 0
				if(j > 1)
					add(dp[i + 1][j - 1][0], dp[i][j][0]);
				add(dp[i + 1][b - 1][1], dp[i][j][0]);
			}
			
			{	//c = 1
				add(dp[i + 1][j - 1][1], dp[i][j][1]);
				if(i + a <= n)
					add(dp[i + a][max(j - a, 0)][2], dp[i][j][1]);
				add(dp[i + 1][a - 1][0], dp[i][j][1]);
			}
			
			{	//c = 2
				add(dp[i + 1][j - 1][2], dp[i][j][2]);
				add(dp[i + 1][j - 1][1], dp[i][j][2]);
			}
		}
	}
	
	int ans = 0;
	for(int c = 0; c < 3; ++c)
		add(ans, dp[n][0][c]);
	printf("%d\n", ans);
	return 0;
}

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



int main()
{
  int d,n;
  cin>>d>>n;
  if(n!=100){
    cout<<(int)pow(100, d)*n;
  }else{
    cout<<(int)pow(100, d)*(n+1);
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  int s=x,t=y;
  int u=x,v=y;
  if(y/2==x&&y%2==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(y/4==x&&y%4==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  
  while(x>0){
    if(y-6>=0){
      y-=6;
      x-=2;
    }
    else if(y-4>=0){
      y-=4;
      x--;
    }
   
    else break;
  }
  if(y==0&&x==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  
  while(s>0){
    if(t-6>=0){
      t-=6;
      s-=2;
    }
    else if(t-2>=0){
      t-=2;
      s--;
    }
    else break;
  }
  if(t==0&&s==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  
   while(u>0){
    if(v-4>=0){
      v-=4;
      u--;
    }
    else if(v-2>=0){
      v-=2;
      u--;
    }
    else break;
  }
 
  if(u==0&&v==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	lint H;
	cin >> H;
	lint A = 1;
	while (A <= H) {
		A <<= 1;
	}
	cou(A - 1);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bits/stdc++.h>
//#define LOCAL
using namespace std;
typedef long long ll;


int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll num1,num2;
cin>>num1>>num2;
bitset<32>a(num1), b(num2);
cout<< (a&b) <<endl;
cout<< (a|b) <<endl;
cout<< (a^b) <<endl;


#ifdef LOCAL
fin.close();
#endif // LOCAL
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
/*
*/
int main () {
	int n, a, b, c, aa, ab, ac;
	cin >> n;
	n--;
	cin >> a >> b >> c;
	aa = a;
	ab = b;
	ac = c;
	int ca=aa, cb=ab, cc=ac;
	while (n--) {
		cin >> a >> b >> c;
		ca = aa; cb=ab; cc=ac;
		aa = max(cb, cc)+a;
		ab = max(ca, cc)+b;
		ac = max(ca, cb)+c;
	}
	cout << max(max(aa, ab), ac);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    
    char temp;
    for(int i=0;i<s.length();i++){
        for(int j=s.length()-1;j>i;j--){
            if(s[j]<s[j-1]){
                temp=s[j];
                s[j]=s[j-1];
                s[j-1]=temp;
            }
        }
    }
    
    for(int i=0;i<t.length();i++){
        for(int j=t.length()-1;j>i;j--){
            if(t[j]>t[j-1]){
                temp=t[j];
                t[j]=t[j-1];
                t[j-1]=temp;
            }
        }
    }
    int minlength=min(s.length(),t.length());
    
    for(int i=0;i<minlength;i++){
        if(s[i]==t[i]){
            continue;
        }else if(s[i]<t[i]){
            cout<<"Yes"<<endl;
            return 0;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(s.length()<t.length()){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        cout<<"No"<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
string s; char s1,s2; int a,b;
int main(){
  cin >> s;
  s1 = s[0];
  if(s1 != s[1]) s2 = s[1];
  else s2 = s[2];
  for (size_t i = 0; i < 4; i++) {
    if(s[i] == s1)a++;
    if(s[i] == s2)b++;
  }
  cout << (a==2 && b==2 ? "Yes":"No") << endl;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string K;
    cin >> K;
    int D;
    cin >> D;
    int mod = 1e9 + 7;
    int N = K.size();
    vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(D, vector<int>(2)));
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            for (int k = 0; k <= K[i] - '0'; k++) {
                dp[i + 1][(j + k) % D][(k != (K[i] - '0'))] += dp[i][j][0];
                dp[i + 1][(j + k) % D][(k != (K[i] - '0'))] %= mod;
            }
            for (int k = 0; k < 10; k++) {
                dp[i + 1][(j + k) % D][1] += dp[i][j][1];
                dp[i + 1][(j + k) % D][1] %= mod;
            }
        }
    }

    cout << (dp[N][0][0] + dp[N][0][1] + mod - 1) % mod << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 55424
import java.util.*;

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

Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
String pos = "Impossible";
if(a % 3 == 0){
pos = "Possible";
}
if(b % 3 == 0){
pos = "Possible";
}
if((a + b) % 3 == 0){
pos = "Possible";
}
System.out.println(pos);

}
}

Measured memory_bytes: 23636
#include<iostream>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b){
        if(b < c){
            cout << a << " " << b << " " << c << endl;
        }else if(a < c){
            cout << a << " " << c << " " << b << endl;
        }else{
            cout << c << " " << a << " " << b << endl;
        }
    }else{
        if(a < c){
            cout << b << " " << a << " " << c << endl;
        }else if(b < c){
            cout << b << " " << c << " " << a << endl;
        }else{
            cout << c << " " << b << " " << a << endl;
        }
    }
    
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m; cin >> n >> m;
  vector<int> ecasdqina(n);
  while(m--) {
    int a, b; cin >> a >> b;
    if(a == 1 || a == n) ecasdqina[b-1]++;
    if(b == 1 || b == n) ecasdqina[a-1]++;
    if(ecasdqina[a-1] >=2 || ecasdqina[b-1] >= 2) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mem(x,y) memset((x), (y), sizeof (x));
#define point complex <double>
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define PI acos(-1)
const ll mod = 1e9 + 7;
const ll maxN = 1e5 + 5;
const ll INF = 1e18;

ll fact[maxN], inv[maxN];

ll modPow (ll a, ll b){
    if(b == 0)
        return 1;
    ll ret = modPow(a, b / 2);
    ret = ((ret % mod) * (ret %mod))%mod;
    if(b % 2)
        ret = (ret * (a % mod))%mod;
    return ret;
}


void calcFacAndInv(int n){
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = modPow(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % mod * inv[n-r]) % mod;
}

int main() {
	Omar45
	calcFacAndInv(maxN);
    ll n, k; cin >> n >> k;
    for (int i=1; i<=k; i++) {
        if (i > n-k+1) {
            cout << "0" << endl;
            continue;
        }
        ll ans = ncr(n-k+1, i);
        ans *= ncr(k-1, i-1);
        ans %= mod;

        cout << ans << endl;
    }
}

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

int n, k, t1, t2, b[200001];
vector<int> g[200001], v;

int dfs(int p, int pr) {
    if(p == n) {
        return 1;
    }
    for(int i: g[p]) {
         if(i != pr) {
            if(dfs(i, p)) {
                v.push_back(i);
                return 1;
            }
        }
    }
    return 0;
}

int dfs2(int p, int pr) {
    int s = 1;
    for(int i: g[p])
        if(i != pr)
            s += dfs2(i, p);
    return s;
}

int main() {
    cin >> n;
    for(int i = 0; i < n - 1; ++i)
        cin >> t1 >> t2, g[t1].push_back(t2), g[t2].push_back(t1);
    (void)dfs(1, -1);
    v.push_back(1);
    //for(int i: v)
    //    cout << i << " ";
    //cout << endl;
    int f = 0, s = 0, i = 0, j = v.size() - 1, p = 1;
    while(i <= j) {
        if(p & 1) {
            b[v[j--]] = 1, ++s;
        } else {
            b[v[i++]] = 2, ++f;
        }
        p ^= 1;
    }
    //cout << s << " " << f << endl;
    for(int i: v) 
        for(int j: g[i])
            if(!b[j])
                if(b[i] == 1)
                    s += dfs2(j, i);
                else
                    f += dfs2(j, i);
    //cout << s << " " << f << endl;
    cout << vector<string>{"Fennec", "Snuke"}[s <= f] << endl;
    
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

vector<vll> g(200020);
vll cnt(200020, 0);

vector<bool> b(200020, false);

void dfs(ll node, ll cost){
    b[node] = true;

    for (int i = 0; i < g[node].size(); i++) {
        int t = g[node][i];

        if(!b[t]){
            cnt[t] += cost;
            dfs(t, cnt[t]);
        }
    }
}

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

    int n, q;
    cin >> n >> q;

    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }


    rep(i, q) {
        int p;
        ll t;
        cin >> p >> t;
        p--;
        cnt[p] += t;
    }

    dfs(0, cnt[0]);

    for (int i = 0; i < n; i++){
        cout << cnt[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 24320
#include<stdio.h>
int main(){
	char a[1205];
	scanf("%[^\n]",a);
	int p=0;
	while(a[p]!='\0'){
		p++;
	}
	for(int i=0;i<p;i++){
		if(a[i]>='a'&&a[i]<='z'){
			a[i]=a[i]-32;
		}
		else if(a[i]>='A'&& a[i]<='Z'){
			a[i]=a[i]+32;
		}
	}
	printf("%s",a);
	printf("\n");

return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
string s[305];
bool check(int a){
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			int x = (a+i)%N;
			int y = (a+j)%N;
			if(s[x][j]!=s[y][i])return false;
		}
	}
	return true;
}
int main(){
	cin >> N;
	for(int i=0;i<N;i++)cin >> s[i];
	int ans = 0;
	for(int i=0;i<N;i++){
		if(check(i))ans += N;
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int mod = 1000000007;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    int cnt = 0;
    rep(i, S.size()) {
        if (S[i] == 'S') {
            cnt = 0;
        } else {
            cnt++;
            chmax(ans, cnt);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main() {
  int N; string S; cin >> N >> S;
  long r,g,b,rg,gb,br,rgb;
  r=g=b=rg=gb=br=rgb=0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') { r++; rg += g; br += b; rgb += gb; }
    else if (S[i] == 'G') { g++; rg += r; gb += b; rgb += br; }
    else if (S[i] == 'B') { b++; gb += g; br += r; rgb += rg; }
  }
  for (int i = 0; i < N-2; i++) {
    for (int j = i+1; j < N-1; j++) {
      int k = 2 * j - i;
      if (k >= N) break;
      set<char> s;
      s.insert(S[i]);
      s.insert(S[j]);
      s.insert(S[k]);
      if (s.size() == 3) rgb--;
    }
  }
  cout << rgb << endl;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

// 頂点の持つ情報
struct edge {
    int to;
    int cost;
};

//最短距離と、頂点の番号
using P = pair<int, int>;

int V = 10;
int inf = 1e9;
// グラフと距離
vector<vector<edge>> G(10);
vector<int> d(10);

void dijkstra(int s) {
    // Pの最初の値（距離）が小さい順で並べるpriority_queue
    priority_queue<P, vector<P>, greater<P>> que;
    // 距離をinfで初期化
    d.assign(V, inf);
    d[s] = 0;
    que.push({0, s});

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        //　戻る場合や他の方が早い場合は最短にならないので飛ばす
        if (d[v] < p.first)
            continue;

        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            // 他より早い場合は更新
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int Y, X;
    cin >> Y >> X;
    vector<vector<int>> wall(Y, vector<int>(X));
    rep(i, 10) {
        rep(j, 10) {
            int cost;
            cin >> cost;
            G[j].push_back({i, cost});
        }
    }

    map<int, int> ma;
    rep(i, Y) {
        rep(j, X) {
            cin >> wall[i][j];
            if (wall[i][j] != -1 && wall[i][j] != 1)
                ma[wall[i][j]]++;
        }
    }

    dijkstra(1);
    ll ans = 0;
    for (auto m : ma) {
        ans += (d[m.first] * m.second);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 2e5 + 4;
  vi adj[maxn];
  vi vis(maxn);
  int cnt=0;
  
  void dfs(int src){
    vis[src]=1;
    cnt++;
    for(int x:adj[src]){
      if(!vis[x]){
         dfs(x);
      }
    } 
    // deb(cnt);
  }
  
  
  
  void solve(){
    map<pair<int,int>,int>mp;
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
      int a,b;
      cin >> a >> b;
      if(mp[{min(a,b),max(a,b)}]==1)continue;
      else{
        adj[a].pb(b);
        adj[b].pb(a);
        mp[{min(a,b),max(a,b)}]=1;
      }
    }
    int mx=0;
    for(int i=1;i<=n;i++){
       if(!vis[i]){
           dfs(i);
          mx = max(mx,cnt);
          cnt = 0;
       }
    }
    cout << mx;
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow


Measured memory_bytes: 33796
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a,b;
	cin>>a;
	b=sqrt(a*1.);
	cout<<b*b<<endl;
	
    return 0;
}

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

using namespace std;

#define pq priority_queue
#define MZ 1000000007

long long num[200005];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&num[i]);
        num[i]-=i;
    }
    sort(num+1,num+1+n);
    long long ans=0;
    for(int i=1;i<=n;i++)
        ans+=abs(num[i]-num[(n+1)/2]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
s=0
a.sort()
if a[0]==0:
    if a.count(a[0])==n:
        s=1
    if n%3==0:
        if (a.count(a[0])==n//3 and a.count(a[n//3])==n//3*2):
            s=1
else:
    if n%3==0:
        if a.count(a[0])==n//3 and a.count(a[n//3])==n//3 and a.count(a[n//3*2])==n//3:
            x=a[0]
            y=a[n//3]
            z=a[n//3*2]
            if x^y==z and y^z==x and z^x==y:
                s=1
if s==1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll h, w;
    cin >> h >> w;
    vector<pair<ll, ll>> ab(h);
    REP(i, h){
        ll ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        ab.at(i) = {ai, bi};
    }

    vector<ll> ans(h, -1);

    set<pair<ll, ll>> es;
    multiset<ll> nx;
    REP(i, w){
        es.emplace(i, i);
        nx.insert(0);
    }

    REP(i, h){
        const ll ai = ab.at(i).first;
        const ll bi = ab.at(i).second;
        auto it = es.lower_bound(make_pair(ai, -1));
        ll max_s = -1;
        while(it != es.end() && ai <= it->first && it->first <= bi){
            max_s = it->second;
            const ll d = it->first - it->second;
            nx.erase(nx.find(d));
            it = es.erase(it);
        }
        if(max_s != -1 && bi + 1 < w){
            es.emplace(bi + 1, max_s);
            nx.insert(bi + 1 - max_s);
        }
        if(nx.size()){
            ans.at(i) = *nx.begin() + i + 1;
        }else{
            break;
        }
    }

    for(ll ansi : ans){
        cout << ansi << endl;
    }
    return 0;
}


Measured memory_bytes: 29820
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
bool cmp (int i, int j) {
  return a[i] < a[j];
}
int main() {
  int n;
  cin >> n;
  int N = (1 << n);
  a.resize(N);
  vector<int> ret(N), M(N), m(N);
  for (int bs = 0; bs < N; bs++) cin >> a[bs];
  M[0] = 0;
  m[0] = 0;
  vector<int> rpr;
  for (int bs = 1; bs < N; bs++) {
    rpr.clear();
    rpr.push_back(bs);
    for (int i = 0; i < n; i++) if ((bs >> i) & 1) {
      int cs = bs ^ (1 << i);
      rpr.push_back(M[cs]);
      rpr.push_back(m[cs]);
    }
    sort(rpr.begin(), rpr.end(), cmp);
    rpr.resize(unique(rpr.begin(), rpr.end()) - rpr.begin());
    auto it = rpr.end();
    M[bs] = *(--it);
    m[bs] = *(--it);
    ret[bs] = a[M[bs]] + a[m[bs]];
  }
  int now = 0;
  for (int bs = 1; bs < N; bs++) {
    now = max(now, ret[bs]);
    cout << now << '\n';
  }
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  
  vector<int>V(N);
  vector<int>C(N);
  
  for(int i=0;i<N;i++)
    cin>>V.at(i);
  
  for(int i=0;i<N;i++)
    cin>>C.at(i);
  
  
  int res=0;
  
  for(int i=0;i<N;i++){
   if(V.at(i)>C.at(i))
     res+=V.at(i)-C.at(i);
  }
  
  cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fop(i,a,b) for(int i = a;i < b;i++)
using namespace std;
int main(){
	int N;
	cin >> N;
	int h[N];
	fop(i,0,N) cin >> h[i];
	int dp[N];
	int dif[N];
	fop(i,0,N){
		if(i == 0){
			dp[i] = 0;
		}else if(i == 1){
			dp[i] = abs(h[i] - h[i-1]);
		}else{
			dp[i] = min(abs(h[i] - h[i-1])+ dp[i-1],abs(h[i] - h[i-2])+ dp[i-2]);
		}
	}
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 4272
package main
import (
  "fmt"
  //"math"
  // "sort"
  //"regexp"
)
 
func main(){
  var n int
  var a string
  mame := map[string]int { "P": 0, "W": 0, "G": 0, "Y": 0 }
  fmt.Scan(&n)
  for i := 0; i < n; i++{
    fmt.Scan(&a)
    mame[a]++
  } 
  if mame["P"] != 0 && mame["W"] != 0 && mame["G"] != 0 && mame["Y"] != 0 {
    fmt.Print("Four\n")
  } else {
    fmt.Print("Three\n")
  }
}

Measured memory_bytes: 1836
c = []
for i in range(3):
    x,y,z = map(int,input().split())
    c.append([x,y,z])

if (c[1][0]-c[0][0] == c[1][1]-c[0][1] == c[1][2]-c[0][2]) and (c[2][0]-c[0][0] == c[2][1]-c[0][1] == c[2][2]-c[0][2]):
    print('Yes')

else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<algorithm>
#include<cmath>
#define ll long long
#define pb push_back
#define vi vector<int>
#define si set<int>
#define msi multiset<int>
#define vll vector<ll>
#define ff first
#define ss second
#define pii pair<int,int>
#define mp make_pair
#define all(a) a.begin(),a.end()
#define f(i,x,n) for(int i=x;i<n;i++)
#define fd(i,n,x) for (int i=n;i>=x;i--)
#define itr :: iterator it
#define endl '\n'
#define INF 1e9
#define mod 1e9+7

using namespace std;
ll step(ll i,ll n,vector<ll>&h,vector<ll>&dp)
{
    if(i==n-1)
        return 0;
    if(i>=n)
        return INF;
    if(dp[i]!=-1)
        return dp[i];

        ll left=abs(h[i]-h[i+2])+step(i+2,n,h,dp);
        ll right;
        /*if(i+2>=n)
        right=INF;
        else*/
        right=abs(h[i]-h[i+1])+step(i+1,n,h,dp);
        return dp[i]=min(left,right);

}
int main()
{
    ll n;
    cin>>n;
    vector<ll>h;
    vector<ll> dp(n,-1);
    for(ll i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        h.push_back(a);
    }
    cout<<step(0,n,h,dp);
}


Measured memory_bytes: 7888
n = int(input())
g = {}
cnt = 0
for i in range(n):
    cnt += 1
    l,p = map(str,input().split())
    if l in g:
        g[l].append([p,cnt])
    else:
        g[l] = [[p,cnt],]

for i in g:
    g[i].sort(key = lambda x:int(x[0]) ,reverse = True)
    
g = sorted(g.items())

for j in g:
    for k in j[1]:
        print(k[1])

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define RREP(i, s, n) for (int i = n-1; i >= (int)(s); --i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n;
  ccin >> n;
  vector<ll> a(3 * n);
  rep(i, 3 * n) {
    ccin >> a[i];
  }
  priority_queue<ll, ll1d, greater<>> f_que;
  ll f_sum = 0;
  rep(i, n) {
    f_sum += a[i];
    f_que.push(a[i]);
  }
  vector<ll> v_f_sum(n + 1);
  v_f_sum[0] = f_sum;
  REP(i, n, 2 * n) {
    f_que.push(a[i]);
    ll popped = f_que.top();
    f_que.pop();
    v_f_sum[i - n + 1] = v_f_sum[i - n] + a[i] - popped;
  }

  priority_queue<ll, ll1d, less<>> b_que;
  ll b_sum = 0;
  rep(i, n) {
    b_sum += a[2 * n + i];
    b_que.push(a[2 * n + i]);
  }

  vector<ll> v_b_sum(n + 1);
  v_b_sum[n] = b_sum;
  for (int i = 1; i < n + 1; ++i) {
    ll ii = 2*n -i;
    b_que.push(a[ii]);
    ll popped = b_que.top();
    b_que.pop();
    v_b_sum[n-i] = v_b_sum[n-i+1] + a[ii] - popped;
  }
  ll ans = -inf;
  rep(i, n+1){
    ans = max(ans, v_f_sum[i] - v_b_sum[i]);
  }

  ccout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 5876
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            //ここから

            var n = IO.ReadLineToInt();
            var ans = ((n + 1) / 2) * 1.0 / n;

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToArray(); }
        static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include<complex.h>
#include<string>

int main(void){
    int N;
    std::cin >> N;
    std::string s;
    std::cin >> s;
    std::string ans;
    int n[N];
    for(int i = 0;i < N;i++)n[i] = 0;
    for(int i = 0;i < N;i++){
        if(s[i] == '('){
            for(int j = i;j < N;j++){
                if(s[j] == ')' && n[j] == 0){
                    n[i] = 1;
                    n[j] = 1;
                    break;
                }
                
            }
        }
    }
    ans = s;
    for(int i = 0;i < N;i++){
        if(s[i] == ')' && n[i] == 0)ans = "("+ans;
        else if(s[i] == '(' && n[i] == 0)ans = ans+")";
    }
    std::cout << ans;
}


Measured memory_bytes: 256
n, c = map(int, input().split())
D = [tuple(map(int, input().split())) for _ in range(c)]
C = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(n)]

# 全ての色について違和感を記録
dst = [[0, 0, 0] for _ in range(c)]
for ci in range(c):
    for i in range(n):
        for j in range(n):
            c_from = C[i][j]
            dst[ci][(i+j)%3] += D[c_from][ci]

from itertools import permutations
d = 1000*500*500
for p0, p1, p2 in permutations(list(range(c)), 3):
    d = min(d, dst[p0][0] + dst[p1][1] + dst[p2][2])
print(d)


Measured memory_bytes: 47988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n;
  cin >> n;
  int i;
  while (i * i <= n) ++i;
  out(--i * i);
}
int main(void) { solve(); }


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var H = HW[0];
                var W = HW[1];
                if (H == 0)
                    break;
                foreach (var i in Enumerable.Range(0, H))
                {
                    foreach (var j in Enumerable.Range(0, W - 1))
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine("#");
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9348
import sys

readline = sys.stdin.readline

def main():
    N, M = map(int, readline().split())

    S = []
    for i in range(M):
        k, *tmp = [int(i) for i in readline().split()]
        S.append(tmp)
    
    p = list(map(int, readline().split()))

    # bit
    ans = 0
    for i in range(2**N):
        select = []
        for j in range(N):
            if (i>>j) & 1:
                select.append(j+1)
        
        for m in range(M):
            flag = 1
            if sum([1 for x in S[m] if x in select])%2 != p[m]:
                flag = 0
                break
        if flag  == 1:
            ans += 1
        
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
else:
    num = list(set(range(-200, 200)) ^ set(p))
    num = sorted([[abs(i - x), i] for i in num])
    if len(num) >= 2 and num[0][0] == num[1][0]:
        print(min(num[0][1], num[1][1]))
    else:
        print(num[0][1])


Measured memory_bytes: 9204
#include "bits/stdc++.h"
    using namespace std ;
    int main()
    {
        bool f1 = false , f2 = false ;
        string a ;
        cin >> a ;
        for(auto i : a) f1 = f1 ||(i=='A') ,f2 = f2 ||(i=='B');
        if(f1&&f2) cout << "Yes\n" ;
        else cout << "No" ;
    }

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long n = saori.saorihayami();
		long a = saori.saorihayami();
		long b = saori.saorihayami();
		long ans = 0;
		long num = n%(a+b);
		long num2 = n/(a+b);
		if(num == 0){
			ans = num2*a;
		} else if(num2 > 0){
			ans = num2 * a;
			if(num >= a){
				ans += a;
			} else {
				ans = ans + num;
			}
		} else {
			if(n >= a){
				ans = a;
			} else {
				ans = n;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    string S,T;
    int count = 0;
    cin >> S;
    cin >> T;
    for(int i=0;i<S.length();i++){
        if(S[i] != T[i]) count++;
    }
    cout << count;
}

Measured memory_bytes: 3912
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(0,b-a+d-c-max(b,d)+min(a,c))<<endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      long r = (long)sc.nextInt();
      long c = (long)sc.nextInt();

      if(r >= 10){
				System.out.println(c);
			}
			else System.out.println(c+(100*(10-r)));


      
    }
    public static long calc(long a,long b){
      System.out.println(factorial(a)+" "+factorial(b));
      return factorial(a+b)/(factorial(a)*factorial(b));
    }

    public static long factorial(long n){
      if(n == 0){
        return new Long(1);
       }
       System.out.println(n * factorial(n-1));

      return n * factorial(n-1);
    }
}


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

int main(){
    int H, W;

    while(cin>>H>>W){
        if(H==0 && W==0){
            break;
        }else{
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if(i==0 || i==H-1){
                        cout << "#";
                    }else if(j==0 || j==W-1){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
                cout << endl;
            }
        }
        cout << endl;
    }
    return 0;
}
    

Measured memory_bytes: 1152
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

class ABiscuitGenerator {
public:
	void solve(std::istream& in, std::ostream& out) {
		int A, B, T;
		in>>A>>B>>T;
		int t = A, cnt = 2;
		int res = 0;
		while(t <= T){
			res += B;
			t = cnt*A;
			cnt ++;
		}
		out<<res<<endl;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ABiscuitGenerator solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
def get_divs x
    arr = []
    1.upto(x){|y|
        arr << y if x % y == 0
    }
    return arr
end

n = gets.to_i
arr = gets.chomp.split.map(&:to_i)
divs = []
arr.each_with_index{|x, i| divs[i] = get_divs(x)}
cd = divs[0].find_all{|x| divs.all?{|ar| ar.include?(x)}}
puts cd


Measured memory_bytes: 6872
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

void init(){

}

void solve(){
    int n, k;
    scanf("%d %d", &n, &k);
    int s = 0, ans = 0;
    while(n-- && s <= k){
        int p; scanf("%d", &p);
        s += p; ans++;
    }
    if(n <= 0 && s <= k) ans++;
    printf("%d", ans);
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
#define inf 10000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i>=b; i--)
#define f first
#define s second
#define pb push_back
#define mt make_tuple

ll dist[101010], lnk[101010],sze[101010] ;
vector<tuple<ll, ll , ll>> e;
bool vis[101010];

ll fnd(ll a){
while(a!=lnk[a])a=lnk[a];
return a;
}

void unite(ll a, ll b){

a = fnd(a);
b = fnd(b);

if(sze[a]<sze[b])swap(a,b);

lnk[b]=a;
sze[a]+=sze[b];

}

int main(){
ll n, x[101010],a,b;
cin >> n >> a >> b;

rep(i, 1, n){
cin >> x[i];
lnk[i]=i;
sze[i]=1;
}

e.pb(mt(0,1,0));
rep(i, 2, n){
e.pb(mt(b,0,i));
}

rep(i, 1, n-1){
e.pb(mt(a*(x[i+1]-x[i]), i, i+1));
//e.pb(mt(a*(x[i+1]-x[i]), i+1, 1));
}

sort(e.begin(), e.end());

ll mst = 0;

for(auto u: e){
    int w,g,c;
    tie(w,g,c)=u;
    if(fnd(g)!=fnd(c)){
        unite(g,c);
        mst+=w;
    }
}


cout << mst << endl;

return 0;}


Measured memory_bytes: 10864
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1000000007;

int N;
int a[100000];

int main(){
    cin>>N;
    rep(i,N) cin>>a[i];

    int zero=0,two=0,four=0;
    rep(i,N){
        if(a[i]%4==0) four++;
        else if(a[i]%2==0) two++;
        else zero++;
    }

    string ans;
    if(zero<=four || (zero-1==four && two==0)) ans="Yes";
    else ans="No";

    cout<<ans<<endl;
}

Measured memory_bytes: 3932
#include <iostream>
#include <algorithm>
// #include <functional>

using namespace std;

int main() {
    int N;
    cin >> N;

    int a[N], i;
    for(i=0; i<N; i++) {
        cin >> a[i];
    }

    sort(a, a+N, greater<int>());

    int A=0, B=0;
    for(i=0; i<N; i++) {
        if(i%2) B += a[i];
        else A += a[i];
    }

    cout << A-B << endl;


    return 0;

}

Measured memory_bytes: 256
def solve(A, B, C, X, Y):
    i = 0
    k = 0
    v = X

    while i <= 10000:
        if v == Y[k]:
            k += 1
        if k == len(Y):
            return i
        v = (v*A + B) % C
        i += 1

    return -1

while True:
    N, A, B, C, X = map(int, raw_input().split(" "))
    if (N, A, B, C, X) == (0, 0, 0, 0, 0):
        break
    Y = map(int, raw_input().split(" "))

    print solve(A, B, C, X, Y)


Measured memory_bytes: 4228