akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;

const int MOD = 998244353;
const ll INF = 1e16;

int main() {
    FASTIO

    int n, k;
    cin >> n >> k;
    int b[k][2];
    for(int i=0; i<k; i++) {
        cin >> b[i][0] >> b[i][1];
    }
    
    vector<int> dp(n+1,0);
    dp[1] = 1;
    for(int i=2; i<=n; i++) {
        for(int j=0; j<k; j++) {
            dp[i] += dp[max(i-b[j][0],0)] - dp[max(i-b[j][1]-1,0)];
            if(dp[i] < 0) dp[i] += MOD;
            else dp[i] %= MOD;
        }
        dp[i] += dp[i-1];
        if(dp[i] < 0) dp[i] += MOD;
        else dp[i] %= MOD;
    }
    int ways = dp[n]-dp[n-1];
    if(ways < 0) cout << ways+MOD << "\n";
    else cout << ways%MOD << "\n";
        
    return 0;
}

Measured memory_bytes: 3964
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    ans += 1
    print(ans)



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );}
using namespace std;



int main()
{
    int n,k;
    cin >> n >> k;
    
    int i = 0;
    while(true){
        if(n < pow(k,i)){
            break;
        }
        i++;
    }
    
    cout << i << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
struct data{
	int cnt;string str;
	data(int a,string b):cnt(a),str(b){}
	data(){}
	bool operator<(const data&d)const{
		if(cnt!=d.cnt)return cnt>d.cnt;
		return str<d.str;
	}
};
int main(){
	int n;
	while(cin>>n&&n){
		map<string,int> dat;
		string s;
		cin.ignore();
		for(int i=0;i<n;i++){
			getline(cin,s);
			stringstream ss(s);
			while(ss>>s){
				dat[s]++;
			}
		}
		vector<data> ans[26];
		map<string,int>::iterator it;
		for(it=dat.begin();it!=dat.end();it++){
			string s=it->first;
			ans[s[0]-'a'].PB(data(it->second,s));
		}
		for(int i=0;i<26;i++)sort(ans[i].begin(),ans[i].end());
		char r;
		cin>>r;
		if(ans[r-'a'].size()==0)cout<<"NA"<<endl;
		else{
			for(int i=0;i<min(5,(int)ans[r-'a'].size());i++){
				if(i)cout<<" ";
				cout<<ans[r-'a'][i].str;
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n;
	cin>>n;
	vector<lli> h(n+1);
	vector<lli> dp(n+1);
	REP(i,0,n)cin>>h[i];

	dp[n-1]=0;
	dp[n]=INF;
	h[n]=INF;

	for(lli i=n-2;i>=0;i--){
		dp[i] = min(dp[i+1]+abs(h[i+1]-h[i]), dp[i+2]+abs(h[i+2]-h[i]));
	}
	cout<<dp[0]<<endl;
	return 0;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

ll dist[333][333];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	#endif
	int n;
	cin>>n;
	vector<vector<ll>> e(n,vector<ll> (n));
	vector<pair<ll,pair<ll,ll>>> edge;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
			cin>>e[i][j];
			dist[i][j] = 1e18;
			if(i > j){
				edge.push_back({e[i][j],{i,j}});
			}
		}
	ll ans = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			bool good = 1;
			for(int x=0;x<n;x++){
				if(i == j || i == x || j == x)continue;
				if(e[x][j] + e[x][i] < e[i][j]){
					cout << "-1\n";
					return 0;
				}
				// cout << i << ' ' << j << ' ' << x << endl;
				// cout << e[x][j] + e[x][i] << ' ' << e[i][j] << endl;
				if(e[x][j] + e[x][i] == e[i][j])good=0;
			}
			ans += e[i][j] * good;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3324
const main = (inputs) => {
  var TW = 2019;
  var L = inputs[0].split(" ")[0]-0;
  var R = inputs[0].split(" ")[1]-0;
  var mods = [];
  var thflg = false;  // 3
  var mnsflg = false; // 673
  for(var i=L;i<=R;i++){
    var val = i%TW;
    mods.push(i);
    if(val == 0){
      console.log(0);
      return;
    }else if(val == 3){
      thflg = true;
    }else if(val == 673){
      mnsflg = true;
    }
    if(thflg && mnsflg){
      console.log(0);
      return;
    }
  }
  var ans = TW;
  for(var i=0;i<mods.length;i++)
  for(var j=i+1;j<mods.length;j++){
    ans = Math.min(ans, ((mods[i]%TW)*(mods[j]%TW))%TW);
  }
  console.log(ans);

}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));


Measured memory_bytes: 7488
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,k=0,n,x,y;
    cin>>n>>x;
    for(i=0 ; i<x ; i++)
    {
        cin>>y;
        k=k+y;
    }
    if(n-k<0)
        cout<<"-1"<<endl;
    else
        cout<<n-k<<endl;
    return 0;
}


Measured memory_bytes: 3652
def resolve():
  n, m, x = map(int, input().split())
  a = list(map(int, input().split()))
  l = len([i for i in a if i < x])
  r = len([i for i in a if i > x])
  print(min(l, r))
  return

if __name__ == "__main__":
  resolve()


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, i;

    cin >> N >> i;

    cout << (N - i + 1) << endl;

    return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

vector<pll> G[101010];
vector<ll> res(101010);
ll K = 0;

void dfs(ll now, ll par, ll col){
	//dump(now)
	//dump(col)
	ll idx = 0;
	REP(i, G[now].size()){
		if(idx == col) idx++;
		ll next = G[now][i].first;
		if(next == par) continue;
		res[G[now][i].second] = idx;
		//dump(res[G[now][i].second])
		dfs(next, now, idx);
		idx++;
	}
}

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

    ll N;
    cin >> N;
    REP(i, N-1){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	G[a].push_back({b, i});
    	G[b].push_back({a, i});
    }

    REP(i, N) K = max(K, (ll)G[i].size());

    dfs(0, -1, -1);

    cout << K << endl;
    REP(i, N-1) cout << res[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>
int main()
 { int i,N; 
    double t; 
    scanf("%d",&N);
     for(i=1; i<=9; i=i+1)
     { if(N%i==0)
          { 
        t= N/i; 
            if(t<=9)
             { printf("Yes\n"); return 0;
                 }
            }
        } 
                printf("No\n");
                 return 0; }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    ll n;
    cin >> n;
    vector<ll>h(n);
    ll ans = 0;
    rep(i, n) cin >> h[i];
    ll c  = 1;
    for (int i = n - 2; i >= 0; i--) {
        if (h[i] >= h[i+1]) {
            c++;
            ans = max(ans, c);
        }else {
            c = 1;
        }
    }
    if (ans == 0) {
        ans = 1;
    }
    cout << ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 4060
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> M;

    if(N==M) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3668
#include<stdio.h>
int main(void)
{
	char s[7];
	scanf("%s",s);
	if(s[2]==s[3]){
		if(s[4]==s[5]){
		printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(s) s.begin(),s.end()
#define uniq(a) a.erase(unique(all(a)),a.end())

int main(void){
    int n;
    while(cin>>n, n){
        vector<string> s(n);
        int a[256] = {};
        bool not_zero[256] = {};
        string c;
        rep(i,n){
            cin>>s[i];
            int k = s[i].size();
            if(k>1) not_zero[s[i][0]] = true;
            reverse(all(s[i]));
            rep(j,k){
                a[s[i][j]] += pow(10,j)*(i==n-1 ? -1 : 1);
                c += s[i][j];
            }
        }
        
        sort(all(c));
        uniq(c);
        c += string(10-(int)c.size(), '-');
        sort(all(c));
        int res = 0;
        do{
            if(not_zero[c[0]]) continue;
            int sum = 0;
            rep(i,10) sum += i*a[c[i]];
            if(sum == 0) res++;
        }while(next_permutation(all(c)));
        cout<<res<<endl;
    }

    return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
int main()
{
	int N,K,P,a;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d %d",&K,&P);
		a=K%P;
		if(a==0)
			printf("%d\n",P);
		else
			printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 1028
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    int[] nums = new int[4];
    for(int i = 0; i < 4; i++) nums[i] = s[i]-'A';
    Array.Sort(nums);
    if(nums[0] == nums[1] && nums[1] != nums[2] && nums[2] == nums[3]) Console.WriteLine("Yes");
    else Console.WriteLine("No");
	}
}

Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

int len[256][100][100];

int main(){
	int n, m, e, s, t, r;
	cin >> n >> m >> e >> s >> t >> r;
	memset(len, 0x3f, sizeof(len));
	FOR(i, m){
		int a, b; cin >> a >> b;
		len[0][a][b] = 1;
		len[0][b][a] = 1;
	}
	FOR(i, n) len[0][i][i] = 0;
	FOR(k, n) FOR(i, n) FOR(j, n) len[0][i][j] = min(len[0][i][j], len[0][i][k] + len[0][k][j]);

	vector<tuple<int, int, int>> v;
	FOR(i, e){
		int a, b, c; cin >> a >> b >> c;
		v.emplace_back(a, b, c);
	}

	FOR(i, 1 << e){
		if (i == 0) continue;
		int us = -1;
		FOR(j, e) if (i & (1 << j)) us = j;
		int pv = i ^ (1 << us);
		int x, y;
		tie(x, y, ignore) = v[us];
		FOR(a, n) FOR(b, n){
			len[i][a][b] = min(len[pv][a][b], min(len[pv][a][x] + len[pv][y][b], len[pv][a][y] + len[pv][x][b]) + 1);
		}
	}

	int order[8];
	FOR(i, 8) order[i] = i;

	int ans = 0x3f3f3f3f;
	do {
		int cur = s;
		int sum = 0;
		int ruse = 0;
		int F = 0;
		FOR(i, e + 1){
			int to;
			if (i == e) to = t;
			else to = get<2>(v[order[i]]);

			int goal_len = len[F][cur][t];
			if (ruse + goal_len <= r) {
				ans = min(ans, goal_len + sum);
			}
			int goal_len2 = 1 + len[F][s][t];
			if (goal_len2 - 1 <= r) {
				ans = min(ans, goal_len2 + sum);
			}

			int to_len = len[F][cur][to];
			int to_len2 = len[F][s][to] + 1;
			if (ruse + to_len <= r && to_len < to_len2) {
				ruse += to_len;
				sum += to_len;
				cur = to;
				F |= (1 << order[i]);
			} else if (to_len2 - 1 <= r) {
				ruse = to_len2 - 1;
				sum += to_len2;
				cur = to;
				F |= (1 << order[i]);
			} else {
				break;
			}
		}
	}
	while (next_permutation(order, order + e));

	if (ans == 0x3f3f3f3f) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 11204
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a,T b){for(T i=a;i!=b;++i)cout<<*i<<" ";cout<<endl;}
template<class T> void chmin(T &t,T f){if(t>f)t=f;}
template<class T> void chmax(T &t,T f){if(t<f)t=f;}
int in(){int x;scanf("%d",&x);return x;}

string str;

int main(){
	getline(cin,str);
	int i;
	for(i=0;i<str.size()-4;i++){
		if(str.substr(i,5)=="apple"){
			str[i]='p';
			str[i+1]='e';
			str[i+2]='a';
			str[i+3]='c';
			str[i+4]='h';
		}else if(str.substr(i,5)=="peach"){
			str[i]='a';
			str[i+1]='p';
			str[i+2]='p';
			str[i+3]='l';
			str[i+4]='e';
		}
	}
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define int long long
#define N1097 1000000007
#define MAX(a,b) ((a) > (b)) ? (a) : (b)
#define MIN(a,b) ((a) < (b)) ? (a) : (b)
#define REP(val, count) for(int (val)=0; (val)<(count); ++(val))

using namespace std;

signed main()
{
	int n, a, b;
	cin >> n >> a >> b;
	vector<int> xi;
	REP(i, n)
	{
		int x;
		cin >> x;
		xi.push_back(x);
	}
	int sum = 0;
	REP(i, n - 1)
	{
		int l = xi[i+1] - xi[i];
		if (l * a <= b)
		{
			sum += l * a;
		}
		else
		{
			sum += b;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 1528
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
vector<int>dp(1000,-1);
int f(int n){
  if(dp[n]!=-1)return dp[n];
  return dp[n]=f(n-1)+f(n-2);
}
int solve(){
  int n;
  cin>>n;
  dp[0]=1;
  dp[1]=1;
  cout<<f(n)<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 3104
def resolve():
    c = list(list(map(int, input().split())) for _ in range(3))
    b = [c[0][0], c[0][1], c[0][2]]
    a = [0, c[1][0] - b[0], c[2][0] - b[0]]
    for i in range(3):
        for j in range(3):
            if c[i][j] != a[i] + b[j]:
                print("No")
                return "No"
    print("Yes")
    return "Yes"


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int gcd(int a, int b){
    //cout << a << "," << b << endl;
    if( b == 0 ){
        return a;
    }
    if( a < b ){
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return gcd(b, a % b);
}

int main(){
    int X;

    cin >> X;
    cout << ( (X * 360) / gcd(360,X) ) / X << endl;
   
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<string.h>

int main()
{
  char s[100]={};
  int i;
  
  scanf("%s",s);
  
  int n=strlen(s);
  int tmp=1;
  
  for(i=0;i<n/2;i++)
  {
    if(s[i]!=s[n-1-i])
    {
      tmp=0;
    }
  }
  if(tmp==1)
  {
    for(i=0;i<(n-1)/4;i++)
    {
      if(s[i]!=s[(n-1)/2-i-1])
      {
        tmp=0;
      }
    }
    for(i=(n+3)/2;i<n/2;i++)
    {
      if(s[i]!=s[n-i-1])
      {
        tmp=0;
      }
    }
  }
        
    if(tmp==1)
    {
      printf("Yes\n");
      return 0;
    }
   if(tmp==0)
  {
    printf("No\n");
    return 0;
  }
}
  

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>

using namespace std;

void ng(){
  cout << "No" << endl;
  exit(0);
}

void ok(){
  cout << "Yes" << endl;
  exit(0);
}
int a[108000], n;
int main(){
  cin >> n;
  int mn = n + 1;
  int mx = 0;
  int mxcnt = 0;
  int mncnt = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
  }

  if(mx == mn){
    if(2 * mx <= n || mx == n-1)ok();
    else ng();
  }
  if(mx - mn > 1)ng();
  
  for(int i = 0;i < n;i++){
    mncnt += a[i] == mn;
    mxcnt += a[i] == mx;
  }
  if(mx < mncnt + 1)ng();
  if((mx - mncnt) * 2 <= mxcnt)ok();
  else ng();
}

Measured memory_bytes: 888
a = int(input())
t = list(str(input()))
u = []
if a % 2 != 0:
    print('No')
else:
    for i in range(a//2):
        if t[i] != t[i + a//2]:
            u.append(1)
    if 1 in u:
        print('No')
    else:
        print('Yes')

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

int main(){
  
  char b;
  cin >> b;
  
  if (b == 'A') cout << 'T';
  if (b == 'T') cout << 'A';
  if (b == 'G') cout << 'C';
  if (b == 'C') cout << 'G';
  
  cout << endl;
      
}

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

using namespace std;
using ll = long long;

int main() {
    ll x;
    cin>>x;
    ll ans=0;
    ans+=(x/500)*1000;
    x%=500;
    ans+=(x/5)*5;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    ll n;
    cin>>n;
    int res=0;
    ll v=0;
    ll ten=1;
    for(int i=0;i<17;i++){
        for(int j=9;j>=0;j--){
            if(ten*j+v<=n){
                v+=ten*j;
                res+=j;
                break;
            }
        }
        ten*=10;
    }

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
def solve
  n, m = gets.split.map!(&:to_i)
  a = gets.split.map!(&:to_i)
  tot_votes = 0
  a.map { |vote| tot_votes += vote }
  cnt = 0
  (0..(n - 1)).each do |i|
    cnt += 1 if a[i] >= tot_votes / (4 * m).to_f
  end

  return 'Yes' if cnt >= m

  'No'
end
print solve


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

int main(){
    int N;
    string str1, str2;
    string list[100];
    cin >> N;
    cin >> str1;
    list[0] = str1;
    for(int i=0; i<N-1; i++){
        cin >> str2;
        for(int j=0; j<i+1; j++){
            if(str2 == list[j]){
                cout << "No" << endl;
                return 0;
            }
        }
        list[i+1] = str2;
        if(str1[str1.size()-1] != str2[0]){
            cout << "No" << endl;
            return 0;
        }
        str1 = str2;
    }

  cout << "Yes" << '\n';
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc100/tasks/abc100_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

int main(void) {
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) {
        cout << "Yay!\n";
    } else {
        cout << ":(\n";
    }

    return 0;
}


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

long long int n;
string s;
int K;

  long long com(long long N, long long R) {
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    else if (R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}

long long pow(long long N, long long k) {
    long long res = 1;
    for (int i = 0; i < k; ++i) res *= N;
    return res;
}


int main(){
  cin >> n ;
long long int ans = 0;
  while(n > 1){
  
    n /= 2;
    
    ans++;
    
  }
  
  
  cout << (long long) pow(2,ans+1)-1 << endl;
}


Measured memory_bytes: 512
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<ll, ll> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 55;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    ll a, b, c;
    cin >> a >> b >> c;
    if (c >= a + b) cout << "0 0";
    else {
        if (c <= a) cout << a - c << ' ' << b;
        else cout << 0 << ' ' << b - (c - a);
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m,d;
    cin>>m>>d;
    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            int d1 = j%10;
            int d10 = j/10;
            if(d1>=2 && d10>=2 && d1*d10==i)ans++;
        }
    }
    PUTS(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n;
  cin >> n;
  if(n%2) {
    cout << 0 << "\n";
    return;
  }
  n /= 2;
  ll ans = 0;
  while(n > 0) {
    ans += n / 5;
    n /= 5;
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 256
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]

t=[0]*D

S=0


last=[0]*26
for d in range(D):
    bestchoice=0
    bestscore=-1000000

    plusscore=0
    minusscore=0

    for i in range(26):
        plusscore=s[d][i]
        minusscore=c[i]*(d+1 - last[i])

        if bestscore<(plusscore+minusscore):
            bestscore=(plusscore+minusscore)
            bestchoice=i
    
    t[d]=bestchoice+1
    S+=s[d][bestchoice]
    last[bestchoice]=d+1

    for i in range(26):
        S-=c[i]*(d+1 - last[i])

for d in range(D):
    print(t[d])

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

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> dp(n + 3, vector<int>(3));
  for (int i = 1; i < n + 1; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = c + max(dp[i-1][0], dp[i-1][1]);
  }
  cout << max(dp[n][0], max(dp[n][1], dp[n][2]));

  return 0;
}


Measured memory_bytes: 5760
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0

for i in range(N):
    A = list(map(int, input().split()))
    naiseki = 0
    for j in range(M):
        naiseki += A[j] * B[j]
    if naiseki > -C:
        ans += 1

print(ans)

Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split()))
dp = [0, abs(h[0] - h[1])]
for i in range(2, n):
    dp.append(min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i])))
print(dp[-1])


Measured memory_bytes: 20644
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll N, x;
	cin >> N >> x;

	if (x == 1 || x == 2 * N - 1) { cout << "No"; }

	else {
		cout << "Yes"<<endl;

		if (N == 2) {
			repn(i, 2 * N - 1) {
				cout << i << endl;
			}
		}

		else if (x < 2 * N - 2) {
			vector<ll> a(2 * N - 4);
			repn(i, 2 * N - 5) {
				if (i < x - 1) { a[i] = i; }
				else { a[i] = i + 4; }
			}

			repn(i, N - 3) { cout << a[i] << endl; }
			cout << x + 1 << endl;
			cout << x - 1 << endl;
			cout << x << endl;
			cout << x + 2 << endl;
			repn(i, N - 2) { cout << a[N-3+i] << endl; }
		}

		else {
			repn(i, N - 3) { cout << i << endl; }
			cout << 2 * N - 3 << endl;
			cout << 2 * N - 1 << endl;
			cout << 2 * N - 2 << endl;
			cout << 2 * N - 4 << endl;
			repn(i, N - 2) { cout << N - 3 + i << endl; }
		}
	}

	system("PAUSE");
}


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

using namespace std;

int main(){
	int n, ans = 0; cin >> n;
	char pre;
	string s; cin >> s;
	
	for(int i = 0; i < n; ++i){
		if(i == 0){
			ans++; pre = s[i];
		}else if(s[i] != pre){
			ans++;
			pre = s[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];

    int a = 0;
    int b = 0;
    
    vector<int> v(n);
    rep(i,n) v[i] = i+1;
    
    do {
        ++a;
        if (p == v) break;
    } while(next_permutation(all(v)));
    rep(i,n) v[i] = i+1;
    do {
        ++b;
        if (q == v) break;
    } while(next_permutation(all(v)));

    cout << abs(a-b) << 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;
  cin >> N;
  int ans = 0;
  for(int i=1; i<=N; i+=2){
    int cnt = 0;
    for(int j=1; j<=i; j++){
      if(i%j == 0) cnt++;
    }
    if(cnt == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef pair<string, int> P;

int main() {
	P hyou[20];
	hyou[0] = P("yotta", 24);
	hyou[1] = P("zetta", 21);
	hyou[2] = P("exa", 18);
	hyou[3] = P("peta", 15);
	hyou[4] = P("tera", 12);
	hyou[5] = P("giga", 9);
	hyou[6] = P("mega", 6);
	hyou[7] = P("kilo", 3);
	hyou[8] = P("hecto", 2);
	hyou[9] = P("deca", 1);
	hyou[10] = P("deci", -1);
	hyou[11] = P("centi", -2);
	hyou[12] = P("milli", -3);
	hyou[13] = P("micro", -6);
	hyou[14] = P("nano", -9);
	hyou[15] = P("pico", -12);
	hyou[16] = P("femto", -15);
	hyou[17] = P("ato", -18);
	hyou[18] = P("zepto", -21);
	hyou[19] = P("yocto", -24);
	int n;
	cin >> n;
	string k;
	getline(cin, k);
	for (int i = 0; i < n; i++) {
		string a;
		getline(cin, a);
		string d = a.substr(0, a.find(' '));
		a = a.substr(a.find(' ')+1);
		int counter = 0;
		for (int j = 0; j < 20; j++) {
			if (a.find(hyou[j].first) != string::npos) {
				counter = hyou[j].second;
				a = a.substr(a.find(' ')+1);
				break;
			}
		}
		if (d.find('.') == string::npos) {
			counter += d.size()-1;
			if (d.substr(1) != "\0") {
				cout << d[0] << '.' << d.substr(1) << " * 10^" << counter << ' ' << a << endl;
			} else {
				cout << d[0] << " * 10^" << counter << ' ' << a << endl;
			}
		} else {
			if (d[1] == '.') {
				if (d[0] == '0') {
					for (int j = 2; j < d.size(); j++) {
						counter--;
						if (d[j] == '0') {
						} else {
							d = d.substr(j);
							break;
						}
					}
					if (d.substr(1) != "\0") {
						cout << d[0] << '.' << d.substr(1) << " * 10^" << counter << ' ' << a << endl;
					} else {
						cout << d[0] << " * 10^" << counter << ' ' << a << endl;
					}
				} else {
					cout << d << " * 10^" << counter << ' ' << a << endl;
				}
			} else {
				counter += d.find('.')-1;
				d = d.substr(0, d.find('.')) + d.substr(d.find('.')+1);
				cout << d[0] << '.' << d.substr(1) << " * 10^" << counter << ' ' << a << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>
int n,A[2010] ,dp[2010][2010];  //输入n个数到数组A[]中
int solve(int i,int m){
    //从输入值M中减去所选元素的递归函数
    if(m==0) return dp[i][m]=1;
    else if(i>=n) return dp[i][m]=0;
    else if(solve(i+1, m)) return dp[i][m] = 1;
    else if(solve(i+1, m-A[i])) return dp[i][m]=1;
    else dp[i][m]=0;
    return dp[i][m];
}
int main(){
    int q,M,i;  //输入q个值为M的数
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&M);
        if(solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
int a[3005];
ll dp[3005][3005][2];

int n;
ll go(int i, int j, int chance) {
    if(i > j) {
        return 0;
    }
    if(dp[i][j][chance] != -1e17) {
        return dp[i][j][chance];
    }
    ll ans;
    if(chance == 0) {
        ans = -1e17;;
        ans = max(ans, a[i] + go(i + 1, j, 1));
        ans = max(ans, a[j] + go(i, j - 1, 1));
    } else {
        ans = 1e17;
        ans = min(ans, go(i + 1, j, 0) - a[i]);
        ans = min(ans, go(i, j - 1, 0) - a[j]);
    }
    return dp[i][j][chance] = ans;
}
int main() {
    cin>>n;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            dp[i][j][0] = -1e17;
            dp[i][j][1] = -1e17;
        }
    }
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    cout<<go(0, n - 1, 0);
}

Measured memory_bytes: 144728
#include <iostream>
#include <vector>
#include <utility>
#include <cstdlib>

using namespace std;

void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int distance(const pair<int, int>& from, const pair<int, int>& to)
{
    return abs(from.first - to.first) + abs(from.second - to.second);
}

int main()
{
    use_io_optimizations();

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i].first >> s[i].second;
    }
    vector<pair<int, int>> c(m);
    for (int i = 0; i < m; ++i) {
        cin >> c[i].first >> c[i].second;
    }
    for (int i = 0; i < n; ++i) {
        int min_index = 0;
        int min_dist = distance(s[i], c[0]);
        for (int j = 1; j < m; ++j) {
            auto d = distance(s[i], c[j]);
            if (min_dist > d) {
                min_dist = d;
                min_index = j;
            }
        }
        cout << min_index + 1 << '\n';
    }

    return 0;
}


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

long long t[200050][2];
long long MAX = 100005;


class UnionFind{
    public:
    vector<int> parent;
 
    UnionFind(int N) {
        parent = vector<int>(N, -1);
    }
 
    int root(int A) {
        if (parent[A] < 0) return A;
        return parent[A] = root(parent[A]);
    }
 
    int size(int A) {
        return - parent[root(A)];
    }
 
    bool unite(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) return false; 
 
        if (size(A) < size(B)) swap(A,B);
 
        parent[A] += parent[B];
        parent[B] = A;
        t[A][0] += t[B][0];
        t[A][1] += t[B][1];
        return true;
    }
 
    bool same(int A, int B) {
        return root(A) == root(B);
    } 
};
 
 
int main() {
    long long n; cin >> n;
    UnionFind uni(200050);
    for (int i = 0; i < MAX; i++) {
        t[i][0] = 1;
    }
    for (int i = MAX; i < MAX+MAX; i++) {
        t[i][1] = 1;
    }
    for (int i = 0; i < n; i++) {
        long long x, y; cin >> x >> y;
        uni.unite(x, y + MAX);
    }

    long long ans = 0;
    for (int i = 0; i < MAX + MAX; i++) {
        if (uni.root(i) == i && t[i][0] && t[i][1]) {
            long long ret = t[i][0] * t[i][1];
            ans += ret;
        }
    }

    ans -= n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N, M;
    int[] a, b;
    int[,] G;
    void Solve() {
        //input
        N = io.Int;
        M = io.Int;
        a = new int[M];
        b = new int[M];
        for (int i = 0; i < M; ++i) {
            a[i] = io.Int;
            b[i] = io.Int;
        }
        //cal
        var ans = 0;
        //i番目の辺を除いてUnionFind
        //処理後、i番目の辺を構成する頂点が同じ親を持てばiを除いても連結グラフ
        for (int i = 0; i < M; ++i) {
            var uf = new UnionFind(N);
            for(int j = 0; j < M; ++j) {
                if (i == j) continue;
                uf.Unite(a[j], b[j]);
            }
            if (!uf.Find(a[i], b[i])) ans++;
        }
        //ret
        Console.WriteLine(ans);
    }
    class UnionFind {
        int[] dat;
        public UnionFind() { }
        public UnionFind(int N) { Init(N); }
        public void Init(int n) { dat = new int[n + 1]; for (int i = 0; i <= n; ++i) dat[i] = -1; }
        public void Unite(int x, int y) {
            x = Root(x); y = Root(y); if (x == y) return;
            if (dat[y] < dat[x]) swap(ref x, ref y); dat[x] += dat[y]; dat[y] = x;
        }
        public bool Find(int x, int y) { return Root(x) == Root(y); }
        public int Root(int x) { return dat[x] < 0 ? x : dat[x] = Root(dat[x]); }
        public int Size(int x) { return -dat[Root(x)]; }
        void swap(ref int a, ref int b) { int tmp = b; b = a; a = tmp; }
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() { Solve(); io.writeFlush(); }
}
class SimpleIO {
    SimpleIO(bool isAutoFlush = false) { this.isAutoFlush = isAutoFlush; }
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    public bool isAutoFlush;
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        if (!isAutoFlush) Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ull = unsigned long long;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  ull N, M, K;
  cin >> N >> M >> K;

  vector<ull> As(N + 1);
  vector<ull> Bs(M + 1);

  Rep(n, N) {
    ull i;
    cin >> i;
    As[n + 1] = As[n] + i;
  }

  Rep(m, M) {
    ull i;
    cin >> i;
    Bs[m + 1] = Bs[m] + i;
  }

  int answer = 0;
  int m = M;
  Rep(n, N + 1) {
    if (K < As[n]) break;

    while (K - As[n] < Bs[m]) {
      m--;
    }
    answer = max(answer, n + m);
  }

  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 6352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;

const int MOD=1000000007;
const int INF=1000000009;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



signed main(){
  int w,n;
  cin>>w>>n;
  int a[33];
  rep(i,w)a[i]=i;
  rep(i,n){
    int x,y;
    char e;
    cin>>x>>e>>y;
    x--;y--;
    swap(a[x],a[y]);
  }
  rep(i,w){
    cout<<a[i]+1<<endl;
  }

  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b;cin>>a>>b;
  P((a+b+1)/2);
  return 0;
}


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

int main()
{
    int n, m; scanf("%d%d", &n, &m);
    vector<int> d(n+1, -1);
    bool err = false;
    while(m--){
        int s, c; scanf("%d%d", &s, &c);
        if (d[s] == c) continue;
        if (d[s] == -1) d[s] = c;
        else err = true;
    }
    int num = 0, b = 1;
    for (int i = n; i >= 1; i--){
        if (d[i] == -1){
            if (i == 1 && n != 1) d[i] = 1;
            else d[i] = 0;
        }
        num += (d[i] * b);
        b *= 10;
    }
    int tmp = num, cnt = 0;
    while(tmp != 0){ tmp /= 10; ++cnt;}
    if (n > 1 && cnt < n) err = true;
    if (err) puts("-1");
    else printf("%d\n", num);
    return 0;
}


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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	ll a, b, n; cin >> a >> b >> n;
	/*
	for (int i = 1; i <= n; i++) {
		ll j = a * i / b - a * (i / b);
		cerr << i << ' ' << j << endl;
	}
	*/
	ll x = b - 1;
	x = min(n, x);
	cout << a * x / b - a * (x / b) << endl;
	return 0;
}

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

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
		Integer[] a = new Integer[n];

		int sum = 0;


		for(int i = 0;i < n;i++) {
			a[i] = scan.nextInt();

			 sum += a[i];
		}

		Arrays.sort(a,Comparator.reverseOrder());

	double min = (double)sum/(4*m);

		System.out.println(a[m-1] >= min ? "Yes":"No");

		scan.close();

	}

}


Measured memory_bytes: 27076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef pair<int, int> ii;
typedef long long int64;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> m(n);
    for (int i = 0; i < n; ++i) {
	cin >> m[i];
    }
    if (m.size() < 2) {
	cout << "Yes" << endl;
	return 0;
    }
    --m[0];
    int last = m[0];
    for (int i = 1; i < m.size(); ++i) {
	if (m[i] - 1 >= m[i - 1]) {
	    m[i]--;
	}
	if (m[i] < last) {
	    cout << "No" << endl;
	    return 0;
	}
	last = m[i];
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int x[4], y, i;
	
	for (i = 0; i < 4; i++){
		scanf("%d %d", &x[i], &y);
		if(x[i] == 1){
			x[i] = 6000 * y;
		} else if (x[i] == 2){
			x[i] = 4000 * y;
		} else if (x[i] == 3){
			x[i] = 3000 * y;
		} else if (x[i] == 4){
			x[i] = 2000 * y;
		}
	}
	
	for(i = 0; i < 4; i++){
		printf("%d\n", x[i]);
	}
	return 0;
}

Measured memory_bytes: 600