akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,q,k;
vector<P>edge[100005];
ll L[100005];
void dfs(int v,int u,ll sum){
	L[v] = sum;
	rep(i,edge[v].size()){
		if(edge[v][i].fi == u) continue;
		dfs(edge[v][i].fi,v,sum+1LL*edge[v][i].sc);
	}
}
int main(){
	cin>>n;
	rep(i,n-1){
		int a,b,c; scanf("%d%d%d",&a,&b,&c);
		edge[a].pb(mp(b,c));
		edge[b].pb(mp(a,c));
	}
	cin >> q >> k;
	dfs(k,-1,0LL);
	rep(i,q){
		int a,b; scanf("%d%d",&a,&b);
		printf("%lld\n",L[a]+L[b]);
	}
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(y % 2 == 0 && y >= 2 * x && 4 * x >= y)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                      
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = {1171, 3307}, Mod = {1e9 + 7, 1e9 + 9};
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, v, u, dp[N][2];
vi g[N];


void dfs (int v, int p = 0) {
	dp[v][0] = 1;
	dp[v][1] = 1;

	for (auto to : g[v])
		if (to != p) {
			dfs(to, v);
			dp[v][0] = dp[v][0] * 1ll * dp[to][1] % mod;
			dp[v][1] = dp[v][1] * 1ll * (dp[to][0] + dp[to][1]) % mod;
		}
}


main () {
	cin >> n;
	forn (i, 1, n - 1) {
		cin >> v >> u;
		g[v].pb(u);
		g[u].pb(v);
	}

	dfs(1);
	cout << (dp[1][0] + dp[1][1]) % mod;
}

    

Measured memory_bytes: 13440
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll Q;cin>>Q;
    REP(i,Q){
        string s1,s2;cin>>s1>>s2;
        ll n1=s1.size(),n2=s2.size();
        ll dp[n1+1][n2+1]={};
        REPS(i,n1){
            REPS(j,n2){
                if(s1[i-1]==s2[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
        cout<<dp[n1][n2]<<"\n";
    }
}


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

int main()
{
    int n;
    cin>>n;
    
    int arr[n],arr1[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    
    arr1[n-1]=0;
    arr1[n-2]=abs(arr[n-1]-arr[n-2])+arr1[n-1];
    
    for(int i=n-3;i>=0;i--)
    {
        int a,b;
        a=abs(arr[i+1]-arr[i]);
        b=abs(arr[i+2]-arr[i]);
        arr1[i]=min(a+arr1[i+1],b+arr1[i+2]);
    }
    cout<<arr1[0];
    
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int K;
  cin>>K;
  ll A[K];
  for(int i=0;i<K;++i) cin>>A[i];
  ll mini=2, maxi=2;
  bool can = true;
  for(int i=K-1;i>=0;--i) {
    mini += (A[i]-mini%A[i])%A[i];
    if(mini>maxi) can = false;
    maxi = maxi/A[i]*A[i]+A[i]-1;
  }
  if(can) cout<<mini<<" "<<maxi<<endl;
  else cout<<-1<<endl;
}



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

using namespace std;

int main(void){
  int x[5];
 
  while(scanf("%d,%d,%d,%d,%d"
	       ,&x[0],&x[1],&x[2],&x[3],&x[4])!=EOF){
    sort(x,x+5);

    int cnt[15];
    fill(cnt,cnt+15,0);
    for(int i=0;i<5;i++){
      cnt[x[i]]++;
      if(x[i]==1)cnt[14]++;
    }

    int fg=0;
    for(int i=0;i<15;i++)
      if(cnt[i]==4){
	cout << "four card" << endl;
	fg=1;
	break;;
      }
    if(fg)continue;

    int fg2=0,fg3=0;
    for(int i=0;i<14;i++){
      if(cnt[i]==2)fg2++;
      if(cnt[i]==3)fg3=1;
    }
    if(fg2 && fg3){
      	cout << "full house" << endl;
	continue;
    }

    for(int i=0;i+4<15;i++){
      if(cnt[i] & cnt[i+1] & cnt[i+2] & cnt[i+3] &cnt[i+4]){
	cout << "straight" << endl;
	fg=1;
	break;;
      }
    }
    if(fg)continue;

    if(fg3){
      cout << "three card" << endl;
      continue;
    }

    if(fg2==2){
      cout << "two pair" << endl;
      continue;
    }

    if(fg2==1){
      cout <<"one pair" << endl;
      continue;
    }

    cout << "null" << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	long long n,c=0,count=0,ans=0;
	cin>>n;
	vector<long long>a(n+1);
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)a[i]+=a[i-1];
	sort(a.begin(),a.end());
	for(int i=0;i<=n;i++){
		if(a[i]==c)count++;
		else {
			ans+=count*(count-1)/2;
			count=1;
			c=a[i];
		}
	}
	ans+=count*(count-1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
x = []
x = input().split()
x[0],x[1],x[2]=int(x[0]),int(x[1]),int(x[2])
if x[0] > x[1]:
    a = x[0]
    x[0] = x[1]
    x[1] = a
if x[1] > x[2]:
    a = x[2]
    x[2] = x[1]
    x[1] = a
if x[0] > x[1]:
    a = x[0]
    x[0] = x[1]
    x[1] = a
print(str(x[0]),str(x[1]),str(x[2]))


Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n,t;
  cin>>n>>t;
  vector<pair<int,int> > a(n);
  for(int i=0;i<n;i++){
    int b,c;
    cin>>b>>c;
    a[i]=make_pair(b,c);
  }
  int ans=1e9;
  for(int i=0;i<n;i++){
    if(a[i].second<=t)ans=min(ans,a[i].first);
  }
  if(ans==1e9)cout<<"TLE"<<endl;
  else cout<<ans<<endl;
}


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


int n,cnt,sum;

int main(){
	
	
	while(cin>>n,n){
		cnt=0;
		for(int i=1;i<501;i++){
			sum=i;
			for(int j=i+1;sum<=n && j<501;j++){
				sum+=j;
				if(sum==n){
					cnt++;
					break;
				}
			}
		}
		cout<<cnt<<endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,m;

// first UD
// before UD
// 0-start right ongoing loop at up
// 0-start right ongoing loop at down
// 0-start left ongoing loop at up
// 0-start left ongoing loop at down
// 1-start right ongoing loop at up
// 1-start right ongoing loop at down
// 1-start left ongoing loop at up
// 1-start left ongoing loop at down
// 2^10 !?
ll dp[1252][1024];

int f(int a,int b,int c,int d,int e,int f,int g,int h,int i,int j){
  int ret = 0;
  ret |= a<<0;
  ret |= b<<1;
  ret |= c<<2;
  ret |= d<<3;
  ret |= e<<4;
  ret |= f<<5;
  ret |= g<<6;
  ret |= h<<7;
  ret |= i<<8;
  ret |= j<<9;
  return ret;
}

int main(){
  scanf("%d%d",&n,&m);
  dp[0][f(0,0, 1,1,1,0, 0,1,1,1)] = 1;
  dp[0][f(1,1, 1,0,1,1, 1,1,0,1)] = 1;
  int te = 0;
  REP(i,n)REP(state,1024){
    REP(ud,2)REP(uprl,2)REP(dorl,2){
      int first = state>>0&1;
      int before = state>>1&1;
      int usru = state>>2&1;
      int usrd = state>>3&1;
      int uslu = state>>4&1;
      int usld = state>>5&1;
      int dsru = state>>6&1;
      int dsrd = state>>7&1;
      int dslu = state>>8&1;
      int dsld = state>>9&1;
      if(i==n-1){
        if(first != ud)continue;
      }
      if(before && uprl && !ud && !dorl)continue;
      if(!before && !uprl && ud && dorl)continue;
      int nfirst = first;
      int nbefore = ud;
      int nusru = (usru && uprl) || (usrd && dorl && ud);
      int nusrd = (usru && uprl && !ud) || (usrd && dorl);
      int nuslu = (uslu && !uprl) || (usld && !ud && !dorl);
      int nusld = (uslu && ud && !uprl) || (usld && !dorl);
      int ndsru = (dsru && uprl) || (dsrd && ud && dorl);
      int ndsrd = (dsru && !ud && uprl) || (dsrd && dorl);
      int ndslu = (dslu && !uprl) || (dsld && !ud && !dorl);
      int ndsld = (dslu && ud && !uprl) || (dsld && !dorl);
      // if(i==n-1 && dp[i][state] > 0){
      //   printf("%d %d: %lld\n",i,state,dp[i][state]);
      //   te += dp[i][state];
      // }
      if(i==n-1){
        if(nusru || nuslu || ndsrd || ndsld)continue;
      }
      int nstate = f(nfirst,nbefore,nusru,nusrd,nuslu,nusld,ndsru,ndsrd,ndslu,ndsld);
      (dp[i+1][nstate] += dp[i][state]) %= m;
    }
  }
  // DEBUG(te);
  ll ans = 0;
  REP(state,1024){
    ans += dp[n][state];
    ans %= m;
  }
  printf("%lld\n",ans);
  return 0;
}



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

int n, q;
vector<int> nodes;
vector<vector<int>> edges;

void dfs(int root, vector<int>& ans, vector<int>& vi, int extra) {
 	vi[root] = 1;
	ans[root] += (nodes[root] + extra);
  	vector<int>& es = edges[root];
  	for (int e : es) {
    	if (vi[e] == 0) {
         	dfs(e, ans, vi, extra + nodes[root]); 
        }
    }
}

int main() {
 	cin >> n >> q;
  	nodes.resize(n + 1, 0);
  	edges.resize(n + 1, vector<int>());
  	for (int i = 1; i < n; i++) {
    	int x, y;
    	cin >> x >> y;
      	edges[x].push_back(y);
      	edges[y].push_back(x);
    }
  	for (int i = 1; i <= q; i++) {
     	int x, y;
      	cin >> x >> y;
      	nodes[x] += y;
    }
  	vector<int> vi(n + 1, 0);
  	vector<int> ans(n + 1, 0);
    dfs(1, ans, vi, 0);
  	for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  	cout << endl;
}

Measured memory_bytes: 28160
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
ways = [[] for _ in range(N)]
for ab in AB:
    ways[ab[0] - 1].append(ab[1] - 1)
    ways[ab[1] - 1].append(ab[0] - 1)
c = 0
for i in range(N):
    if len(ways[i]) == 0:
        c += 1
        continue
    t = 0
    for j in ways[i]:
        if H[i] <= H[j]:
            break
    else:
        c += 1
print(c)


Measured memory_bytes: 106408
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		long W = sc.nextLong();
		long H = sc.nextLong();
		long x = sc.nextLong();
		long y = sc.nextLong();
		int result = (x*2 == W && y*2 == H)?1:0;
		sc.close();
		System.out.print((double)(W*H)/2 + " " + result);
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int z=1000000007;
int main(){
	int m,n;
	cin >> m >> n;
	char arr[m][n];
	for(int i=0;i<m;i++){
	for(int j=0;j<n;j++)cin >> arr[i][j];
	}
	int x=1;
	int ans[m][n];
	ans[0][0]=1;
	for(int i=1;i<m;i++){
	if(arr[i][0]=='#')x=0;
	ans[i][0]=x;
	}
	x=1;
	for(int j=1;j<n;j++){
	if(arr[0][j]=='#')x=0;
	ans[0][j]=x;
	}
	for(int i=1;i<m;i++){
	for(int j=1;j<n;j++){
	if(arr[i][j]!='#'){
	ans[i][j]=(ans[i-1][j]%z + ans[i][j-1]%z)%z;
	}
	else{
		ans[i][j]=0;
	}
	}
	}
	cout << ans[m-1][n-1] << endl;

}

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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

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

    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (s == t) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3612
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  s<-getLine
  print $ sscheck s

sscheck = judge .init

judge str
  |odd (length str) = sscheck str
  |left/=right = sscheck str
  |left==right = length str
    where left  = take (div (length str) 2) str
          right = drop (div (length str) 2) str

Measured memory_bytes: 4388
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t;
	cin>>t;
	ll x,ans;
	cin>>x;
	ans=x;
	t--;
	while(t--)
	{
		cin>>x;
		ans=ans/gcd(ans,x)*x;
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)


int main(void){
	int n1, n2; cin >> n1 >> n2;
	vector<int> a(n1), b(n2);
	rep(i, n1) cin >> a[i];
	rep(i, n2) cin >> b[i];

	int ans = 0;
	for (int i = 0; i < n2; ++i){//b?????£?¶???¨??????top??????????????\????????????????±???????
		int tmp = 0, next = 0;
		bool flag = false;
		for (int j = i; j < n2; ++j){
			for (int k = next; k < n1; ++k){//a????????§?????´????????????????????????????????????
				if(b[j] == a[k]){
					tmp++; next = k + 1;
					ans = max(ans, tmp);
					break;
				}
				if(k == n1 - 1){ flag = true; break; }
			}
			if(flag) break;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;
using ll=int64_t;

int f(ll n){
  int ret = 0;
  while(n){
    ret++;
    n/=10;
  }
  return ret;
}

int main(){
  ll N;
  cin >> N;
  ll n = static_cast<ll>(floor(sqrt(N)));
  for(;n>=1;n--){
    if(N / n * n == N){
      cout << f(N / n) << endl;
      break;
    }
  }
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong a[100005];

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

    llong ans = 0;
    for (int i = 1; i <= n; i++) {
        if (a[a[i]] == i) ans++;
    }

    cout << ans / 2 << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////



int main(){

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

    if(a == b || (a+b)%2 == 0) {
        cout << (a+b)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}

// EOF



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K >> L >> R;
	cout << min({ N,M,K }) + min(L, R) - 50 << endl;
	return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include<math.h>
#include <vector>
#include <set>
using namespace std;

void func_d3() {

	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);

	for (int i = 0; i < N; i++)
		cin >> A[i];

	int M = 0;
	for (int i = N - 1; i >= 0; i--) {
		int sum = 0;
		for (int j = i; j < N; j += (i + 1)) {
			sum += B[j];
		}
		if (sum % 2 != A[i]) {
			B[i] = 1;
			M++;
		}
	}
	cout << M << endl;
	for (int i = 0; i < N; i++) {
		if (B[i])
			cout << i + 1 << " ";
	}

}

int main()
{
	func_d3();
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
ll a[200005];
int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    ll A;
    cin >> A;
    a[i] = A - (i + 1);
    //cout << a[i] << endl;
  }
  sort(a,a+n);
  ll s[3] = {a[n / 2 - 1],a[n / 2],a[n / 2 + 1]};
  ll ans = 1e14;
 
  for(int i = 0; i < 3; i++) {
    ll cur = 0;
    for(int j = 0; j < n; j++) {
      cur += abs(s[i] - a[j]);
    }
    //  cout << cur << endl;
    ans = min(ans,cur);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int N,K,i,j,*S,B,a;
	while(a=1,cin>>N>>K,N||K){
		S=new int[K];
		for(i=K;i--;)cin>>S[i];
		for(i=0;i<N;++i)for(j=K;j--;)cin>>B,S[j]-=B,S[j]<0?a=0:0;
		cout<<(a?"Yes":"No")<<endl;
	}
}

Measured memory_bytes: 1200
LI = lambda: list(map(int, input().split()))

N, K = LI()
H = LI()

INF = 10 ** 15


def main():
    h = [0] + H
    dp = [[INF] * (N + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(1, N + 1):
        for j in range(1, i + 1):
            v = INF
            for k in range(i):
                x = max(0, h[i] - h[k])
                v = min(v, dp[k][j - 1] + x)
            dp[i][j] = v

    ans = min([dp[i][N - K] for i in range(N - K, N + 1)])
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    char b;
  	cin >> b;
  	switch (b) {
      case 'A':
        cout << 'T' << endl;
        break;
      case 'T':
        cout << 'A' << endl;
        break;
      case 'C':
        cout << 'G' << endl;
        break;
      case 'G':
        cout << 'C' << endl;
        break;
    }
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int cta=0,cv=1;
    for(int i=0;i<n;i++){
        if((cv+k)<(cv*2)){
            cv+=k;
            cta++;
        }else{
            cv*=2;
        }
    }
    cout<<cv<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  #define f(i,a,b) for(int i=a;i<b;i++)
  #define ll long long
  #define vll vector<long long>
  #define mll map<ll,ll>
  #define pll pair<long long,long long>
  #define pb(x) push_back(x)
  #define F first
  #define S second
  #define print(v) for(auto it:v)cout<<it<<" "
  #define mod 1000000007   //10^9 +7
  #define sorty(v) sort(v.begin(),v.end())
  #define it(v) v.begin(),v.end()
using namespace std;  

int main() {
  string s,rt="",lt="";
  char ch;
  cin>>s;
  ll q,hold,cont=0,p,a=1;
  cin>>q;
  while(q--){
    cin>>hold;
    if(hold==1){
      cont++;
      a=!a;
    }  
    else{
      cin>>p>>ch;
      if(a==1 && p==1)lt=ch+lt;
      else if(a==0 && p==1)rt=rt+ch;
      else if(a==1 && p==2)rt=rt+ch;
      else lt=ch+lt;
    } 
  }
  cont=cont%2;
  if(cont==1){
    reverse(s.begin(),s.end());
    reverse(rt.begin(),rt.end());
    reverse(lt.begin(),lt.end());
    s=rt+s+lt;
  }  
  else s=lt+s+rt;
  cout<<s;


	return 0;
}

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

using namespace std;

int strange(int a, int b, int c){
  if(a % 2 == b % 2) return c;
  else if(a % 2 == c % 2) return b;
  else return a;
}

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  int cnt;
  
  if(a % 2 == b % 2 && b % 2 == c % 2){
    cnt = (3 * max(a, max(b, c)) - a - b - c) / 2;
  }else{
    if(strange(a, b, c) == max(a, max(b, c))){
      cnt = (3 * (max(a, max(b, c))) - a - b - c) / 2;
    }else{
      cnt = (3 * (max(a, max(b, c)) + 1) - a - b - c) / 2;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int c[100005];

int main()
{
	IO_OP;
	
	string s;
	cin >> s;
	int n = s.size(), l = 0, r = 0, cut = 0;
	vector<pi> a, b;
	for(int i=0;i<n;i++) {
		if(s[i] == 'L') l++;
		else r++;
		if(s[i] == 'R' && s[i] != s[i+1]) cut = i;
		if(s[i] == 'L' && (i == n-1 || s[i] != s[i+1])) {
			a.EB(r, cut), b.EB(l,cut);
			r = l = 0;
		}
	}
	for(int i=0;i<a.size();i++) {
		int t = a[i].F + b[i].F;
		int j = a[i].S;
		c[j] = t / 2;
		c[j+1] = (t + 1) / 2;
		if(a[i].F < b[i].F)
			swap(c[j], c[j+1]);
		if(max(a[i].F, b[i].F) & 1)
			swap(c[j], c[j+1]);
	}
	for(int i=0;i<n;i++)
		cout << c[i] << " \n"[i==n-1];
}



Measured memory_bytes: 1988
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;



void Main(){
    ll N, V = 0, E = 0, u, v;
    sll(N);
    rep(i, N-1){
        sll(u);
        sll(v);
        if(u>v){
            swap(u, v);
        }
        E += u * (N-v + 1);
    }


    rep(i, N){
        V += (i + 1) * (N - i);
    }

    cout << V - E <<endl;

}

int main(){
    Main();
    // string S = "ksdfjl";
    // char v = S[3];
    // S[3] = 'a';
    // cout << S <<endl;
}

Measured memory_bytes: 3192
/* ex3_4
   shu_t */

#include<stdio.h>
#include<stdlib.h>

int main(void){
  int number;
  //roop variable
  int i,j;
  
  int LIMIT = 9;
  //input number
  scanf("%d",&number);
  
  //full search
  for(i=1; i <= LIMIT; i++){
    for(j=1; j<= LIMIT; j++){
      //number equal 1~9 multipled by 1~9
      if(number == i*j){
        printf("Yes\n");
        //forced termination
        exit(0);
      }
    }
  }
  //nothing
  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,int> mp;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]-1]++;
    mp[a[i]]++;
    mp[a[i]+1]++;
  }
  int m=0;
  for(pair<int,int> p:mp){
    m=max(m,p.second);
  }
  cout<<m;
}

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

priority_queue<int,vector<int>,greater<int>>pq;

int main()
{
    int n,ans;
    int t1,t2;
    cin >> n;
    
    for(int i=0;i<n;i++)
    {
        cin >> t1;
        pq.push(t1);
    }

    ans=pq.top();
    while((pq.size())>1 && ans!=1)
    {
        t1=pq.top();
        pq.pop();
        t2=pq.top();
        pq.pop();
        pq.push(t1);
        t2=(t2%t1);
        if(t2)
        {
            ans=min(ans,t2);
            pq.push(t2);
        }
    }

    cout << min(ans,pq.top()) << "\n";
    
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>

using namespace std;
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)


int main()
{
	int N;

	cin >> N;

	string judge = "No";

	For(i, 1, 10) {
		if (((N % i) == 0) && (((N / i) >=1) && ((N / i) <= 9))) {
			judge = "Yes";
		}
	}
	
	cout << judge << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(){
    char str[1002];
    scanf("%s",str);
    for(int i=0;i<strlen(str);i++){
        if(str[i]>'C')str[i]-=3;
        else str[i]='X'+(str[i]-'A');
    }
    printf("%s\n",str);
}

Measured memory_bytes: 0
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int main()
{
	fio;
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll p=1;
	vect(z);
	forin(i,0,n-2)
	{
		if(s[i]==s[i+1])
		{
			p++;
		}
		else
		{	
			z.push_back(p);
			p=1;
		}
	}
	z.push_back(p);
	cout<<z.size()<<endl;
}



Measured memory_bytes: 1480
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
	int N, M; 
	cin >> N >> M;
	int K[15] = {}; 
	vector<int> S[15] = {}; 
	int P[15] = {}; 
	for(int i = 1; i <= M; i++){
		cin >> K[i]; 
		for(int j = 0; j < K[i]; j++){
			int a; cin >> a; S[a].push_back(i); 
		}
	}
	for(int i = 1; i <= M; i++){
		cin >> P[i]; 
	}
	int count = 0; 
	for(int bit = 0; bit < (1 << N); bit ++){
		int kosuu[15] = {}; 
		bool ok = true; 
		for(int i = 0; i < N; i++){
			if((bit >> i) & 1){
				for(int j = 0; j < S[i+1].size(); j++){
					kosuu[S[i+1].at(j)] ++; 
				}
			}
		}
		for(int i = 1; i <= M; i++){
			if((kosuu[i] % 2) != P[i]) ok = false; 
		}
		if(ok) count ++; 
	}
	cout << count << endl; 
}

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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<ll, ll> Pair;
typedef vector<Pair> VP;

#define MOD 1000000007
#define times(n) rep(_idx, n)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define in(a, l, r) (l <= a && a < r)
#define pb push_back
#define mk make_pair
#define out(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;

template<typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}

int main() {
    int A, B; cin >> A >> B;
    if (A < 10 && B < 10) {
        out(A * B);
    } else {
        out(-1);
    }
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

using Graph = vector<vector<pint>>;

void dfs(const Graph &g, vint &dist, const int v)
{
    for (const auto nv : g[v])
    {
        if (dist[nv.first] != -1)
            continue;
        dist[nv.first] = dist[v] + nv.second;
        dfs(g, dist, nv.first);
    }
}

void Main()
{
    int n = in();
    Graph g(n);
    rep(i, n - 1)
    {
        int u = in(), v = in(), w = in();
        --u, --v, w %= 2;
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }

    vint dist(n, -1);
    dist[0] = 0;
    dfs(g, dist, 0);
    rep(i, n)
    {
        cout << dist[i] % 2 << endl;
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 8192
import fractions

lis=list(map(int,input().split()))
gCD=fractions.gcd(lis[2],lis[3])
CD=int((lis[2]*lis[3])/gCD)
lis[0]=lis[0]-1
AC=lis[0]//lis[2]
AD=lis[0]//lis[3]
ACD=lis[0]//CD
BC=lis[1]//lis[2]
BD=lis[1]//lis[3]
BCD=lis[1]//CD
A=lis[0]-AC-AD+ACD
B=lis[1]-BC-BD+BCD
ans=B-A
print(ans)
#print(AC,AD,BC,BD,CD,ACD,BCD)
#print(lis)


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

int main() {
  string s;
  cin >> s;
  
  int price = 700;
  
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'o')
      price += 100;
  }
  
  cout << price << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}

int main(void)
{
	ll k, s; cin >> k >> s;
	ll ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			ll tmp = s - x - y;
			if(tmp <= k && tmp>=0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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


#define ll long long
#define pb push_back

#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const ll inf = 2e18+5;


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

    ll n,m,x,y;
    cin>>n>>m;
    vi a(n,0);
    loop(i,0,m){
        cin>>x>>y;
        a[x-1]+=1;
        if(y<n)
            a[y]-=1;
    }
    ll s=0,c=0;
    loop(i,0,n){
        s+=a[i];
        if(s>=m)
            c++;
    }
    cout<<c<<endl;
    return 0;
}   

Measured memory_bytes: 640
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, a);
    IN(ll, b);
    IN(ll, c);
    YES(b - a == c - b, "YES", "NO");
}

Measured memory_bytes: 3584
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j,k;
	int N, K;
	int x[150] = {};
	cin >> N >> K;
	for (i = 0; i < N; ++i) {
		cin >> x[i];
	}
	int typeA = 0;
	int typeB = 0;
	int sum = 0;
	int typemin =0;//typemin=min(typeA,typeB)
	int mid = K / 2;
	for (i = 0; i < N; ++i) {
		typemin = min(x[i], K - x[i]);
		sum += typemin;
	}
	cout << 2*sum << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s,t;
    cin >> s >> t;
    bool ans = false;
    rep(i,s.size()) if(s.at(i) != t.at(i)) ans = true;
   if(ans){
     cout << "No" << endl;
   }else{
     cout << "Yes" << endl;
   }
    
return 0;
}


Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	red := make([]bool, n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		nums[i] = 1
	}
	red[0] = true

	var x, y int
	for i := 0; i < m; i++ {
		fmt.Scan(&x, &y)
		x--
		y--
		if red[x] {
			red[y] = true
		}
		nums[x]--
		nums[y]++
		if nums[x] == 0 {
			red[x] = false
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		if red[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e5 + 7;
int n, m;
LL a[maxx], cost, ans;
priority_queue <LL> qua;

void Init() {
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		qua.push(a[i]);
	}
}

void Solve() {
	while(m) {
		cost = qua.top();
		cost /= 2;
		m--;
		qua.pop();
		qua.push(cost);
	}
	while(!qua.empty()) {
		ans += qua.top();
		qua.pop();
	}
	cout << ans << endl;
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 1912
#include <iostream>
#include <string>
#define llint long long

using namespace std;

string s;
llint k;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s >> k;
	for(int i = 0; i < (llint)s.size()-1; i++){
		if(s[i] == 'a') continue;
		llint c = s[i]-'a';
		if(26-c<=k){
			k -= 26-c;
			s[i] = 'a';
		}
	}
	k %= 26;
	llint c = s[(int)s.size()-1] - 'a';
	s[(int)s.size()-1] = (c+k) % 26 + 'a';
	
	cout << s << endl;
	
	return 0;
}

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

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)) cout << "A";
    else cout << "B";
}


Measured memory_bytes: 256
(defun concat-strings (list)
  (apply #'concatenate 'string list))

(defun get-colorful-tiles (len)
   (loop :for i :from 1 :to len
         :collect (if (zerop (mod i 2)) #\1 #\0)))

(defun get-reverse-colorful-tiles (len)
   (loop :for i :from 1 :to len
         :collect (if (zerop (mod i 2)) #\0 #\1)))

(defun solve (s)
  (let* ((size (length s))
         (tile1 (get-colorful-tiles size))
         (tile2 (get-reverse-colorful-tiles size)))
    (min (loop :for c :across s
               :for c2 :in tile1
               :count (not (char-equal c c2)))
         (loop :for c :across s
               :for c2 :in tile2
               :count (not (char-equal c c2))))))

(defun main ()
  (let ((s (read-line)))
    (format t "~A~%" (solve s))))

(main)


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

int main(int argc, char *argv[]) {
  int n;
  std::string s;
  std::cin >> n >> s;
  if (s.substr(0,n/2) == s.substr(n/2)) {
    std::cout << "Yes" << std::endl;
    return 0;
  } 
  std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <unordered_map>
#include <array>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <random>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const int INFINT_LIM = (1LL << 31) - 1;              // 2.15x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);  // 9.22x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 52;
int N;
string str1, str2;

int main() {
  cin >> N >> str1 >> str2;
  vector<int> pattern;

  for (int i = 0; i < N; ++i) {
    if (str1[i] == str2[i]) pattern.push_back(1);
    else {
      pattern.push_back(2);
      ++i;
    }
  }

  ll ans;
  if (pattern[0] == 1) ans = 3;
  else ans = 6;

  for (int i = 1; i < pattern.size(); ++i) {
    if (pattern[i-1] == 1 && pattern[i] == 1) (ans *= 2) %= MOD;
    else if (pattern[i-1] == 1 && pattern[i] == 2) (ans *= 2) %= MOD;
    else if (pattern[i-1] == 2 && pattern[i] == 2) (ans *= 3) %= MOD;
  }

  cout << ans << endl;

  return 0;
}



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

li = 0
print(li, flush=True)
ls = input()
if ls == 'Vacant':
    exit()

ri = N - 1
print(ri, flush=True)
rs = input()
if rs == 'Vacant':
    exit()

for _ in range(18):
    mid = (li + ri) // 2

    print(mid, flush=True)
    s = input()

    if s == 'Vacant':
        exit()

    # [li, mid]に空席がある
    c1 = (mid - li) % 2 == 1 and ls == s
    c2 = (mid - li) % 2 == 0 and ls != s
    if c1 or c2:
        ri = mid
        rs = s
    else:
        li = mid
        ls = s

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 7;
const LL LINF = INF * INF;

const int mod = 1e9 + 7;
 
inline int add(int x, int y)
{
	if (x + y >= mod)
		return x + y - mod;
	return x + y;
}
 
inline int mult(int x, int y)
{
	return x * (LL) y % mod;
}

const int MAX = 100000 + 7;
int n, k;
int a[MAX];
int dp[107][MAX];
int sum[107][MAX];

int get(int i, int l, int r)
{
	int res = sum[i][r];
	if (l)
		res = add(res, mod - sum[i][l - 1]);
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> n >> k;
	FOR(i, 0, n)
		cin >> a[i];
	
	dp[0][0] = 1;
	FOR(i, 0, k + 1)
		sum[0][i] = 1;
	
	FOR(i, 1, n + 1)
	{
		FOR(j, 0, k + 1)
			dp[i][j] = get(i - 1, max(0, j - a[i - 1]),j);
		
		sum[i][0] = dp[i][0];
		FOR(j, 1, k + 1)	
			sum[i][j] = add(sum[i][j - 1], dp[i][j]);
	}
	
	cout << dp[n][k] << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 84224
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    string A, B; cin >> A >> B;

    string ans;
    if (A.size() > B.size()) {
      ans = "GREATER";
    } else if (A.size() < B.size()) {
      ans = "LESS";
    } else if (A > B) {
      ans = "GREATER";        
    } else if (A < B) {
      ans = "LESS";      
    } else {
      ans = "EQUAL";
    }

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


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;

  if (a <= b && b <= c){
    cout << a << " " << b << " " << c << endl;
  }else if(a <= c && c <= b){
    cout << a << " " << c << " " << b << endl;
  }else if(b <= c && c <= a){
    cout << b << " " << c << " " << a << endl;
  }else if(b <= a && a <= c){
    cout << b << " " << a << " " << c << endl;
  }else if(c <= a && a <= b){
    cout << c << " " << a << " " << b << endl;
  }else{
    cout << c << " " << b << " " << a << endl;
  }
}


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

int main() {
  int n, d;
  cin >> n;
  map<int, int> mp;
  rep(i, n) {
    cin >> d;
    mp[d]++;
  }
  cout << mp.size() << endl;
  return 0;
}


Measured memory_bytes: 3636
K = int(input())
mod = K
if K == 1:
    print(1)
elif K % 2 == 0 or K % 5 == 0:
    print(-1)
elif K % 7 != 0:
    x = 10 % mod
    X = [1] * K
    S = [1] * K
    for i in range(1, K + 1):
        X[i] = (X[i - 1] * x) % mod
        S[i] = S[i - 1] + X[i]
        if S[i] % mod == 0:
            print(i + 1)
            exit()
    print(-1)
else:
    mod = K // 7
    if mod == 1:
        print(1)
    else:
        x = 10 % mod
        y = 1 % mod
        X = [y] * K
        S = [y] * K
        for i in range(1, K + 1):
            X[i] = (X[i - 1] * x) % mod
            S[i] = S[i - 1] + X[i]
            if S[i] % mod == 0:
                print(i + 1)
                exit()
        print(-1)

Measured memory_bytes: 103820
import java.awt.*;
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int D = sc.nextInt();

        Point[] numPoint = new Point[H * W + 1];
        for (int i = 1; i < H + 1; i++) {
            for (int j = 1; j < W + 1; j++) {
                numPoint[sc.nextInt()] = new Point(i, j);
            }
        }

        int Q = sc.nextInt();
        int[] L = new int[Q];
        int[] R = new int[Q];
        for (int i = 0; i < Q; i++) {
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
        }

        // 整数nに移動するまでに必要な魔力
        long[] accum = new long[H * W + 1];
        for (int n = D + 1; n < H * W + 1; n++) {
            accum[n] = accum[n - D] + calcMagic(numPoint[n - D], numPoint[n]);
        }

        for (int i = 0; i < Q; i++) {
            out.println(accum[R[i]] - accum[L[i]]);
        }
    }

    static long calcMagic(Point xy1, Point xy2){
        return Math.abs(xy1.x - xy2.x) + Math.abs(xy1.y - xy2.y);
    }
}

Measured memory_bytes: 98460