akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  map<ll,ll>MP;
  ll an=0,o=0;
  set<ll> anv,ov;
  for(int i=0;i<n;i++){ll a;cin>>a;MP[a]++;}
  for(int j=0;j<m;j++){ll a;cin>>a;MP[a]++;}
  for(auto a:MP){
    if(a.S==1){o++;ov.insert(a.F);}
    else {o++;an++;ov.insert(a.F);anv.insert(a.F);}
  }
  cout<<an<<" "<<o<<endl;
  for(auto a:anv)cout<<a<<endl;
  for(auto a:ov)cout<<a<<endl;
  return 0;
}



Measured memory_bytes: 27828
#include <cstdio>
#include <iostream>
#include<vector>
#include<algorithm>
#include <set>
#include<cmath>
#include<string>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    string st;
//    st=new char(n);
    cin>>st;
    forn(i,st.length())
    {
        st[i]=(st[i]+n-'A')%26+'A';
    }
    printf("%s\n",st.c_str());
    return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N, K; cin >> N >> K;
    vector<int> a( N );
    REP( i, N ) cin >> a[i];

    sort( ALL( a ), greater<>() );

    int ans = 0;
    REP( i, K ){
        ans += a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cstdio>
using namespace std;
int a,b,c;
int main(){
  scanf("%d %d %d",&a,&b,&c);
  if(a < b&&b < c){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

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

int main(){
		int n, k, x, y;
		cin >> n >> k >> x >> y;
		if( n >= k){
			cout << k * x + (n - k) * y << endl;
		}
		else{
			cout << n * x << endl;
		}		
		return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<ll,int>> p(N);
  for(int i=0; i<N; i++){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(),p.end());
  ll ans = 0;
  int sum = 0;
  for(int i=0; i<N; i++){
    ans += p[i].first*(ll)min(M-sum,p[i].second);
    sum += min(M-sum,p[i].second);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] t = new long[n];
		long[] a = new long[n];
		for(int i=0; i<n; i++){
			t[i] = sc.nextLong();
		}
		for(int i=0; i<n; i++){
			a[i] = sc.nextLong();
		}
		sc.close();
		
		long ans = 1;
		int pos = -1;
		long top = 0;
		
		if(n==1){
			if(a[0] == t[0]){
				System.out.println("1");
				return;
			}else{
				System.out.println("0");
				return;
			}
		}
		
		for(int i=0; i<n; i++){
			if(a[i] == t[i]){
				pos = i;
				top = t[i];
				break;
			}
		}
		
		if(pos<0){
			System.out.println("0");
			return;
		}
		
		for(int i=pos; i<n; i++){
			if(t[i] > top){
				System.out.println("0");
				return;
			}
		}
		for(int i=pos; i>=0; i--){
			if(a[i] > top){
				System.out.println("0");
				return;
			}
		}
		
		for(int i=1; i<pos; i++){
			if(t[i] < t[i-1]){
				System.out.println("0");
				return;
			}else if(t[i] == t[i-1]){
				ans *= t[i];
				if(ans >= 1000000007){
					ans %= 1000000007;
				}
			}
		}
		
		
		for(int i=n-2; i>pos; i--){
			if(a[i] < a[i+1]){
				System.out.println("0");
				return;
			}else if(a[i] == a[i+1]){
				ans *= a[i];
				if(ans >= 1000000007){
					ans %= 1000000007;
				}
			}
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 68456
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;

	cout << (H - h) * (W - w) << endl;
}

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


using namespace std;

#define int long long
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define ff first 
#define ss second 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < 3; ++i){
		if(s[i] == t[i])ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int x, y;
    while(cin>>x>>y){
        ll ans=0;
        if(x==1&&y==1){
            ans+=400000;
        }
        if(x==1){
            ans+=300000;
        }
        else if(x==2){
            ans+=200000;
        }
        else if(x==3){
            ans+=100000;
        }
        x=y;

        if(x==1){
            ans+=300000;
        }
        else if(x==2){
            ans+=200000;
        }
        else if(x==3){
            ans+=100000;
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)

h.sort!
cnt = 0
for i in 0..n- 1 do
    cnt += h[i]
end

if n <= k
    puts 0
else
 for i in (n - k.. n - 1) do
     cnt -= h[i]
 end
 puts cnt 
end


Measured memory_bytes: 17648
#include<bits/stdc++.h>
using namespace std;
int TSP(const vector<vector<int>>& edge) {
  const int INF = 1e9;
  vector<vector<int>> dp(1 << edge.size(), vector<int>(edge.size(), INF));
  dp[1][0] = 0;
  for(int bit = 1; bit < (1 << edge.size()); ++bit)
    for(int last = 0; last < edge.size(); ++last)
      if((bit >> last) & 1) for(int next = 0; next < edge.size(); ++next)
        if(!((bit >> next) & 1)) dp[bit | (1 << next)][next] = min(dp[bit | (1 << next)][next], dp[bit][last] + edge[last][next]);
  int result = INF;
  for(int last = 0; last < edge.size(); ++last) result = min(result, dp[(1 << edge.size()) - 1][last] + edge[last][0]);
  return result;
}
int main() {
  int V, E;
  cin >> V >> E;
  vector<vector<int>> edge(V, vector<int>(V, 1e9));
  for(int i = 0; i < E; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    edge[s][t] = d;
  }
  auto result = TSP(edge);
  cout << (result == 1e9 ? -1 : result) << endl;
}

Measured memory_bytes: 4428
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);

		int A, B;

		A = scan.nextInt();
		B = scan.nextInt();

		if (B % A == 0) {
			System.out.println(A + B);
		} else {
			System.out.println(B - A);
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @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: 21332
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {

	long long N = 0, X=0, Y = 0,D=0;
	cin >> X >> Y;
	int l = 0;
	for (long long i = X; i <= Y; i *= 2) {
		l++;
		

	}
	
	cout << l << endl;
	return 0;


}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a, b, c, d;
    if (scanf("%d", &a) < 0) return 1;
    if (scanf("%d", &b) < 0) return 1;
    if (scanf("%d", &c) < 0) return 1;
    if (scanf("%d", &d) < 0) return 1;

    printf("%d\n", ((a <= b) ? a : b) + ((c <= d) ? c : d));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<59;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e5;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,q;
vl a,b;

int main(){
	cin>>n>>q;
	n*=2;
	a=b=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	ll sum=0,tmp=0;
	multiset<ll> st1,st2;
	for(int i=1;i<n-1;i++){
		ll t=a[i]-b[i];
		tmp+=b[i];
		if(t>0){
			st1.insert(t);
			sum+=t;
		}
		else st2.insert(t);
	}
	for(int i=0;i<q;i++){
		ll p,x,y;
		cin>>p>>x>>y;
		p--;
		if(0<p&&p<n-1){
			ll t=a[p]-b[p];
			if(t>0){
				st1.erase(st1.lower_bound(t));
				sum-=t;
			}
			else st2.erase(st2.lower_bound(t));
			tmp+=y-b[p];
			t=x-y;
			if(t>0){
				st1.insert(t);
				sum+=t;
			}
			else st2.insert(t);
		}
		a[p]=x;b[p]=y;
		if(st1.size()%2==0) cout<<sum+tmp+a[0]+a[n-1]<<endl;
		else{
			cout<<max(-*st1.begin(),(st2.empty()?-INF:*(--st2.end())))+sum+tmp+a[0]+a[n-1]<<endl;
		}
	}
}

Measured memory_bytes: 14208
#pragma GCC target("arch=ivybridge")
#include <cstdio>

int n;
int A[21];

constexpr int mod = 1000000007;

int dp[1<<21];

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      int x;
      scanf("%d", &x);
      if(x) A[i] |= 1 << j;
    }
  }

  dp[0] = 1;
  for(int x = 1; x < (1<<n); x++){
    int i = __builtin_popcount(x);
    long long int r = 0;
    for(int y = x & A[i-1]; y; y &= y-1){
      int j = y & -y;
      r += dp[x & ~j];
    }
    dp[x] = r % mod;
  }
  printf("%d\n", dp[(1<<n)-1]);
  return 0;
}


Measured memory_bytes: 8320
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

void initrand() {
    srand((ll)time(NULL));
}

ll dp[4][46];

int main() {
    ll N, K;
    cin >> N >> K;
    ll A[N];
    ll num[45];
    fill(num, num + 45, 0);
    REP(i, 0, N) {
        cin >> A[i];
        REP(j, 0, 45) {
            if (A[i] & ((ll)1 << j)) {
                num[j]++;
            }
        }
    }
    REP(i, 0, 4) {
        fill(dp[i], dp[i] + 46, 0);
    }
    REP(i, 0, 45) {
        ll po = (ll)1 << (44 - i);
        if (K & po) {
            dp[0][i + 1] = max(dp[0][i], dp[1][i]) + (N - num[44 - i]) * po;
            dp[3][i + 1] = max(dp[0][i], dp[1][i]) + num[44 - i] * po;
            if (dp[2][i] != 0) {
                dp[2][i + 1] = max(dp[2][i + 1], dp[2][i] + (N - num[44 - i]) * po);
                dp[3][i + 1] = max(dp[3][i + 1], dp[2][i] + num[44 - i] * po);
            }
            if (dp[3][i] != 0) {
                dp[2][i + 1] = max(dp[2][i + 1], dp[3][i] + (N - num[44 - i]) * po);
                dp[3][i + 1] = max(dp[3][i + 1], dp[3][i] + num[44 - i] * po);
            }
        } else {
            dp[1][i + 1] = max(dp[0][i], dp[1][i]) + num[44 - i] * po;
            if (dp[2][i] != 0) {
                dp[2][i + 1] = max(dp[2][i + 1], dp[2][i] + (N - num[44 - i]) * po);
                dp[3][i + 1] = max(dp[3][i + 1], dp[2][i] + num[44 - i] * po);
            }
            if (dp[3][i] != 0) {
                dp[2][i + 1] = max(dp[2][i + 1], dp[3][i] + (N - num[44 - i]) * po);
                dp[3][i + 1] = max(dp[3][i + 1], dp[3][i] + num[44 - i] * po);
            }
        }
    }
    ll ans = 0;
    REP(i, 0, 4) {
        ans = max(ans, dp[i][45]);
    }
    // initrand();
    // if ((rand() % 100) >= 8) {
    //     usleep(3000000);
    // }
    // if (((rand() * 2) % 100) >= 8) {
    //         ans = 0;
    // }
    cout << ans << endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;

int two(int n)
{
    for(int i = 0; ; i++){
        if(n % 2 != 0) return i;
        n /= 2;
    }
}

int main()
{
    int n, a, ans = INT_MAX;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        ans = min(ans, two(a));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

int main() {
  int V, E;
  scanf("%d%d", &V, &E);
  std::vector<std::vector<int>> edges(V, std::vector<int>());
  std::vector<int> cs(V, 0);
  for (int i = 0; i < E; i++) {
    int s, t;
    scanf("%d%d", &s, &t);
    edges[s].push_back(t);
    cs[t]++;
  }
  std::vector<int> todo;
  for (int v = 0; v < V; v++)
    if (cs[v] == 0)
      todo.push_back(v);
  while (todo.size()) {
    auto s = todo.back();
    todo.pop_back();
    printf("%d\n", s);
    for (auto&& t : edges[s]) {
      cs[t]--;
      if (cs[t] == 0)
        todo.push_back(t);
    }
  }
  return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;

  int res1 = a + b;
  int res2 = a - b;
  int res3 = a * b;
  
  int ans = max(res1 ,max(res2, res3));
  cout << ans;
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val graph = Array.fill[List[Int]](N+1)(Nil)
  for (i <- 1 until N) {
    val a, b = in.next().toInt
    graph(b) = a :: graph(b)
    graph(a) = b :: graph(a)
  }

  //
  val q = Queue[(Int, Int)]() // (node, color)
  val colors = Array.fill[Int](N+1)(-1)

  q.enqueue((1, 0))
  while (!q.isEmpty) {
    val (node, color) = q.dequeue()
    if (colors(node) == -1) {
      colors(node) = color
      for (e <- graph(node)) {
        q.enqueue((e, (color + 1) % 2))
      }
    }
  }


  var c1 = 0
  var c2 = 1
  var g1 = colors.count(_ == 0)
  var g2 = colors.count(_ == 1)

  val piyo = N / 3
  val hoge = N % 3
  val mods = Array(piyo, piyo + Math.min(1, hoge), piyo + Math.max(0, hoge-1))

  if (g1 > g2) {
    c1 = 1; c2 = 0

    val tmp = g1
    g1 = g2
    g2 = tmp
  }

  val ans = new Array[Int](N+1)
  val counter = new Array[Int](3)
  if (N/3 >= g1) {
    for (i <- 1 to N) {
      val now = colors(i)
      if (now == c1) {
        ans(i) = counter(0) * 3 + 3
        counter(0) += 1
      }
      else {
        if (counter(1) < mods(1)) {
          val m = 1
          ans(i) = counter(m) * 3 + m
          counter(m) += 1
        }
        else if (counter(2) < mods(2)) {
          val m = 2
          ans(i) = counter(m) * 3 + m
          counter(m) += 1
        }
        else {
          ans(i) = counter(0) * 3 + 3
          counter(0) += 1
        }
      }
    }

    println(ans.drop(1).mkString(" "))
  }
  else if (mods(1) <= g1 && mods(2) <= g2) {
    for (i <- 1 to N) {
      val now = colors(i)
      if (now == c1) {
        val m = 1
        if (counter(m) < mods(m)){
          ans(i) = counter(m) * 3 + m
          counter(m) += 1
        }
        else {
          ans(i) = counter(0) * 3 + 3
          counter(0) += 1
        }
      }
      else { // now == c2
        val m = 2
        if (counter(m) < mods(m)){
          ans(i) = counter(m) * 3 + m
          counter(m) += 1
        }
        else {
          ans(i) = counter(0) * 3 + 3
          counter(0) += 1
        }
      }
    }


    println(ans.drop(1).mkString(" "))
  }
  else {
    println(-1)
  }
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 

#define int long long
#define mod 1000000007
#define pb push_back
#define S second
#define F first
#define INF 1e18
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n" \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  if(s.back() == 's')
    s += "es";
  else 
    s += "s";

  cout << s;
  return 0;
}


Measured memory_bytes: 3660
N,K=map(int,input().split())
A=list(map(int,input().split()))
U=len(set(A))

import collections

if U > K:
  c = collections.Counter(A)
  d = c.most_common(K)
  print(N-(sum(x[1] for x in d)))
else:
  print(0)

Measured memory_bytes: 37044
#include <stdio.h>
#include <string.h>
int main()
{
	int n,bt[4]={0};
	char b[3];
	while(scanf("%d,%s",&n,b)!=EOF)
	{
		if(strlen(b)==2)bt[2]++;
		if(!(strcmp(b,"A")))bt[0]++;
		if(!(strcmp(b,"B")))bt[1]++;
		if(!(strcmp(b,"O")))bt[3]++;
	}
	printf("%d\n%d\n%d\n%d\n",bt[0],bt[1],bt[2],bt[3]);
	return 0;
}

Measured memory_bytes: 0
n,k = map(int,input().split())
l = list(map(int,input().split()))
s = set()
s.add(1)
pas1 = [1]
pas2 = []
now = 1
count = 0
if k == 1:
    print(l[0])
    exit()
for i in range(2*n):
    a = l[now-1]
    if a in s:
        index = pas1.index(a)
        k -= index
        le = len(pas1)-index
        print(pas1[k%le+index])
        
        exit()
    else:
        now = a
        s.add(a)
        count += 1
        pas1.append(a)
        
        if count == k:
            print(a)
            exit()
    


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

int main(){

    int n, k;
    cin >> n >> k;

    vector<ll> h(n);
    for (int i=0; i<n; i++){
        cin >> h.at(i);
    }

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

    ll ans = 1e9;
    k--;
    for (int i=0; i<n-k; i++){
        ll buf;
        buf = h.at(i+k) - h.at(i);
        ans = min(ans, buf);
    }

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

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

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

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, n-1) {
        if (s[i] == s[i+1]) {
            cnt++;
        }
    }
    int ans = 0;
    ans = min(cnt+2*k, n-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int n;
    cin >> n;
    rep(loop, n) {
        vector< unsigned int > input(8);
        unsigned int key;
        rep(i, 8) {
            scanf("%x", &input[i]);
        }
        scanf("%x", &key);
        unsigned int ans = 0, keta = 0;

        while (keta < 33) {
            unsigned int tmp = 0;
            rep(i, 8) {
                tmp += input[i];
            }
            if ( (((tmp >> keta)%2)+((key >> keta)%2)) % 2 ) {
                rep(i, 8) {
                    input[i] ^= (1 << keta);
                }
                ans |= (1 << keta);
            }
            keta++;
        }
        printf("%x\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b)
{
    return a / __gcd(a, b) * b;
} 
int n;
int a[100];
void solve()
{
    cin >> n;
    for (int i = 0; i < n;i++){
        cin >> a[i];
    }
    int to = 1000;
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1]){
            int j = to / a[i - 1];
            to %= a[i - 1];
            to += j * a[i];
        }
    }
    cout << to << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3644
while True:
    M,F,R = map(int,input().split())
    if M == -1 and F == -1 and R == -1:
        break
    if M == -1 or F == -1:
        print("F")
    elif M+F >= 80:
        print("A")
    elif M+F >= 65:
        print("B")
    elif M+F >= 50:
        print("C")
    elif M+F >= 30:
        if R >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5596
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int a[3]; cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  
  if((a[1]-a[0])%2 == 0){
    cout << ( (a[1]-a[0])/2 ) + a[2] - a[1];
  } else {
    cout << 1 + ( (a[1] - a[0] - 1)/2 ) + a[2] + 1 - a[1];
  }
 
 return 0;
}

Measured memory_bytes: 256
/*
在太阳西斜的这个世界里
置身天上之森。
等这场战争结束之后
不归之人与望眼欲穿的众人
人人本着正义之名
长存不灭的过去
逐渐消逝的未来
我回来了
纵使日薄西山
即便看不到未来
此时此刻的光辉
盼君勿忘
*/

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int n;
int d[110][2];

int main(){
    cin>>n;
    for(int i=1; i<=n; i++) cin>>d[i][0]>>d[i][1];
    for(int i=1; i<=n-2; i++)
        if(d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1])
            {
            	cout<<"Yes";
            	return 0;
			}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    ll n,h,w;
    cin >> n >> h >> w;
    ll a,b;
    ll ans = 0;
    for (ll i=0;i<n;i++){
        cin >> a >> b;
        if(a >= h and b>=w){
            ans++;
        }

    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

const int N = 2e5 + 5;
const int LOGN = 18;
int a[N], lol[N];
int tr[4 * N], tr1[4 * N];
int n, k;

void build(int nd,int s,int e) {
	if(s == e) {
		tr[nd] = a[s];
		tr1[nd] = a[s];
		return;
	}
	int m = (s + e) >> 1;
	build(nd << 1, s, m);
	build(nd << 1 | 1, m + 1, e);
	tr[nd] = min(tr[nd << 1], tr[nd << 1 | 1]);
	tr1[nd] = max(tr1[nd << 1], tr1[nd << 1 | 1]);
}

int get_min(int l,int r,int nd = 1, int s = 1, int e = n) {
	if(s > r || e < l) return 1e9;
	if(l <= s && e <= r) return tr[nd];
	int m = (s + e) >> 1;
	return min(get_min(l, r, nd << 1, s, m), get_min(l, r, nd << 1 | 1, m + 1, e));
}

int get_max(int l,int r,int nd = 1, int s = 1, int e = n) {
	if(s > r || e < l) return -1;
	if(l <= s && e <= r) return tr1[nd];
	int m = (s + e) >> 1;
	return max(get_max(l, r, nd << 1, s, m), get_max(l, r, nd << 1 | 1, m + 1, e));
}

void solve() {
	cin >> n >> k;
	set<pair<int,int>> s;
	int pt = 1;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++) {
		pt = max(pt, i);
		while(pt < n && a[pt + 1] > a[pt]) pt++;
		lol[i] = pt;
	}
	// for(int i = 1; i <= n; i++) {
	// 	cout << lol[i] << " ";
	// }
	// cout << endl;
	build(1, 1, n);
	for(int i = k; i <= n; i++) {
		int l = i - k + 1, r = i;
		if(lol[l] >= r) {
			s.insert({-1, -1});
			continue;
		}
		int lr = l - 1, rr = r;
		while(rr - lr > 1) {
			int m = (lr + rr) >> 1;
			if(lol[l] >= m && get_min(m + 1, r) > a[m]) {
				lr = m;
			}
			else {
				rr = m;
			}
		}
		int lans = rr;
		lr = l, rr = r + 1;
		while(rr - lr > 1) {
			int m = (lr + rr) >> 1;
			if(lol[m] >= r && get_max(l, m - 1) < a[m]) {
				rr = m;
			}
			else {
				lr = m;
			}
		}
		int rans = lr;
		s.insert({lans, rans});
		// cout << i << endl;
		// cout << lans << " " << rans << endl;
	}
	cout << s.size() << endl;
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		// cout << "Case #" << tt << ": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s;
  cin>>t;
  int n=t.length(),c=0;
  for(int i=0;i<n;i++)
  { if(s[i]==t[i])
      continue;
    else 
      c++;}
       if((c==0) || (c>1))
         cout<<"No";
       else
         cout<<"Yes";
}

Measured memory_bytes: 3628
K = int(input())

def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a % b)


gcds = [[gcd(i, j) for j in range(K + 1)] for i in range(K + 1)]

s = 0
for i in range(1, K + 1):
  for j in range(1, K + 1):
    for k in range(1, K + 1):
      s += gcds[gcds[i][j]][k]

print(s)


Measured memory_bytes: 9332
#include<iostream>
#include<stdio.h>  
#include<string.h>  
#include<algorithm>
using namespace std;
int n;
int a[105][2], b[105][2], ab[105][105], p[105], d[105];
bool dfs(int x) 
{
	for (int i = 1;i <= n;++i)
		if (!p[i] && (ab[x][i])) {
			p[i] = 1;
			if ((!d[i]) || dfs(d[i])) {
				d[i] = x;
				return true;
			}
		}
	return false;
}
int main()
{
	
	int sum = 0;
	scanf("%d", &n);
	for (int i = 1;i <= n;i++)
		scanf("%d%d", &a[i][0], &a[i][1]);
	for (int i = 1;i <= n;i++)
		scanf("%d%d", &b[i][0], &b[i][1]);
	for (int i = 1;i <= n;i++)
		for (int p = 1;p <= n;p++)
			if (b[p][0] > a[i][0] && b[p][1] > a[i][1])
				ab[i][p] = 1;

	for (int i = 1;i <= n;++i) 
	{
		memset(p, 0, sizeof(p));
		if (dfs(i))sum++;
	}
	printf("%d", sum);
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,k,x[101],i,ans;
	float mid;
	ans=0;
	cin>>n>>k;
	for(i=1;i<=n;i++) cin>>x[i];
	mid=k/2;
	for(i=1;i<=n;i++){ 
		if(x[i]<=mid) ans=ans+(x[i]*2);
		else  ans=ans+(k-x[i])*2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int mod=998244353;
const int maxn=2e5+5;
ll n,k,l[maxn],r[maxn],f[maxn],sum[maxn];
int main(){
    n=read(),k=read();
    for(int i=1;i<=k;i++){
        l[i]=read(),r[i]=read();
    }
    f[1]=sum[1]=1;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=k;j++){
            f[i]=(f[i]+sum[max(0ll,i-l[j])]-sum[max(0ll,i-r[j]-1)]+mod)%mod;
        }
        sum[i]=(sum[i-1]+f[i])%mod;
    }
    printf("%d\n",f[n]);
    return 0;
}


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

typedef long long ll;

ll n,x,d=0;

ll f(ll a, ll b){
    ll u=min(a, b), v=max(a, b);
    if(v%u==0)return u*(2*v/u-1);
    ll w=v/u;
    return u*w*2+f(u, v%u);
}

int main(void){
    cin>>n>>x;
    ll y=n+f(x, n-x);
    cout<<y<<endl;
}


Measured memory_bytes: 256
//By Don4ick 
//#define _GLIBCXX_DEBUG


#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = 105;

using namespace std;

int n, m, a[N][N], dp[N][N][N][N];

int get(int x1, int y1, int x2, int y2)
{
	if (x1 != x2 && y1 != y2)
		assert(false);	
	return max(0, a[x2][y2] - a[x1 - 1][y2] - a[x2][y1 - 1] + a[x1 - 1][y1 - 1]);
}

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n >> m;
	int x = -1, y = -1;
	forn(i, n)
	{
		string s;
		cin >> s;
		for (int j = 0; j < (int)s.size(); j++)
		{		
			if (s[j] == 'E')
			{
				x = i, y = j + 1;
			}
			else if (s[j] == 'o')
			{
				a[i][j + 1] = 1;
			}
		}
	}
	forn(i, n)
		forn(j, m)
			a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
	//~solve
	int ans = 0;
	for (int l = 0; l <= x - 1; l++)
	{	
		for (int r = 0; r <= n - x; r++)
		{
			for (int u = 0; u <= y - 1; u++)
			{
				for (int d = 0; d <= m - y; d++)
				{
					if (l < x - 1 && x - l - 1 >= r + 1)
						dp[l + 1][r][u][d] = max(dp[l + 1][r][u][d], dp[l][r][u][d] + get(x - l - 1, max(d + 1, y - u), x - l - 1, min(m - u, y + d)));
					if (r < n - x && x + r + 1 <= n - l)
						dp[l][r + 1][u][d] = max(dp[l][r + 1][u][d], dp[l][r][u][d]	+ get(x + r + 1, max(d + 1, y - u), x + r + 1, min(m - u, y + d)));
					if (u < y - 1 && y - u - 1 >= d + 1)
						dp[l][r][u + 1][d] = max(dp[l][r][u + 1][d], dp[l][r][u][d] + get(max(r + 1, x - l), y - u - 1, min(x + r, n - l), y - u - 1));
					if (d < m - y && y + d + 1 <= m - u)
						dp[l][r][u][d + 1] = max(dp[l][r][u][d + 1], dp[l][r][u][d] + get(max(r + 1, x - l), y + d + 1, min(x + r, n - l), y + d + 1));
					ans = max(ans, dp[l][r][u][d]);
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}



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

typedef long long int ll;

int main()
{
    ll a,b,c,k,sum=0;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);

    if(a>=k)
    {
        sum+=k;
    }
    else
    {
        sum+=a;
        k=k-a;
        if(k>b)
        {
            k=k-b;
            sum-=k;
        }
    }
    printf("%lld\n",sum);


    return 0;
}


Measured memory_bytes: 3812
from sys import stdin
import math
def input():
	return stdin.readline()[:-1]

def intput():
	return int(input().rstrip())

def sinput():
	return input().rstrip().split()

def intsput():
	return map(int, sinput())

def main():
	n = intput()
	print(n//2+(n%2))


if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    double T, X;
    in2(T, X);

    cout << setprecision(10) << setiosflags(ios::fixed);
    outl(T / X);

    return 0;
}


Measured memory_bytes: 3772
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

#define bigmod 1000000007
using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = ans * i;
    }
    return ans;
}

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b) cout <<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        long[] array = new long[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        long ans = 0;

        for (int i = 1; i < n; i++) {
            ans += Math.min((array[i] - array[i - 1]) * a, b);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50392
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
h = I()
w = I()
x = n-h+1
y = n-w+1
print(x*y)

Measured memory_bytes: 74532
#include <bits/stdc++.h>
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef long long ll;
const int N=200005;
const int mod=1e9+7;
int n,head[N],now=0;
int fa[N],lev[N],siz[N];
ll s[N];
using namespace std;

struct node
{
	int t,next;
}adj[N<<1];
void add(int s,int t)
{
	adj[++now]=(node){t,head[s]};
	head[s]=now;
}
void dfs(int s)
{
	int i;siz[s]=1;
	for (i=head[s];i;i=adj[i].next)
	if (adj[i].t!=fa[s]) fa[adj[i].t]=s,lev[adj[i].t]=lev[s]+1,dfs(adj[i].t),siz[s]+=siz[adj[i].t];
}
int calc(int a,int b)
{
	int ans=1,tmp=a;
	while (b)
	{
		if (b&1) ans=(ll)ans*tmp%mod;
		tmp=(ll)tmp*tmp%mod,b>>=1;
	}
	return ans;
}
inline int read()
{
	char c;int x;
	while (c=getchar(),c<'0' || c>'9');x=c^'0';
	while (c=getchar(),c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x;
}
void write(int x)
{
	if (x==0) return;
	write(x/10);
	putchar((x%10)+'0');
}
int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d",&n);
	int i,s,t;
	for (i=1;i<n;i++)
	scanf ("%d %d",&s,&t),add(s,t),add(t,s);
	lev[1]=1,dfs(1);
	int step=lev[n]/2-1;
	int x=n;
	while (step--) x=fa[x];
	int u=n-siz[x],v=siz[x];
	if (u>v) puts("Fennec");
	else puts("Snuke");
	return 0;
}


Measured memory_bytes: 7808
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = Math.abs(x - sc.nextInt());
		int b = Math.abs(x - sc.nextInt());

		System.out.println(a < b ? "A" : "B");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 21076
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <queue>
//#include <tr1/unordered_map>
#include <iostream>
#define maxn 10005
#define M 1000000007
using namespace std;
//using namespace tr1;
int main()
{
    //int a,b,c;
    //scanf("%d%d",&a,&b);
    //scanf("%d",&c);
    int n;
    scanf("%d",&n);
    /*for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);*/
    printf("%lf",n%2==0?1.0/2.0:(double)(n/2+1)/n);
    return 0;
}


Measured memory_bytes: 256
//atcoder 067 A
//2017.07.21

#include<iostream>

using namespace std;

int main() {

	int a, b;
	int point;
	cin >> a >> b;

	if (a % 3 == 0 || b % 3 == 0 || (a+b)%3 == 0) point = 1;
	else point = 0;

	if (point == 1) cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int n, a, b;

  cin >> n >> a >> b;

  cout << min(a, b) << " " << max(0, a + b - n) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

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

  vector<int> v(n);
  for (int& e : v) cin >> e;

  vector<vector<int>> dp(k + 1, vector<int>(2, 0));

  for (int i = 0; i <= k; i++) {
    for (int j = 0; j < 2; j++) {
      int& ans = dp[i][j];

      ans = !j;
      for (int e : v) {
        if (e > i) continue;

        if (j == 0) {
          ans = min(ans, dp[i - e][1]);
        } else {
          ans = max(ans, dp[i - e][0]);
        }
      }
    }
  }

  cout << (!dp[k][0] ? "First" : "Second") << endl;
  return 0;
}


Measured memory_bytes: 5760