akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main() {

  int x[21][21];
  int r[21][21];

 

  int m, n,i,j,k,l,o;
  int a,b,c,d,e;
  char ch[5];

  while (1) {
    k = 0;
    c = 10;
    d = 10;
    n = 0;

  for(j=0; j<21 ; j++) {
      for(i=0; i<21 ; i++) {
	x[i][j] = 10000;
	r[i][j] = 20000;
      }
      }


  scanf("%d",&n);
  if(n == 0) {
    break;
  }


  for(i=0; i<n; i++ ) {
    scanf("%d %d",&a,&b);
    x[a][b] = 1;
    // printf("x[%d][%d] = 1",a-1,b-1);
  }

  scanf("%d",&m);
  o = m;
  //printf(" m = %d\n",m);

  for(l=0;l<o;l++) {

    scanf("%s %d",ch,&e);

    // printf("ch%c  e%d\n",ch[0], e);

      if(ch[0] == 'N') {
	for(i = 1; i<=e ;i++){
	    r[c][d+i] = 1;
	    //printf("r[%d][%d] = 1\n",c, d+i);

	}
	d = d+e;
  
      } else if(ch[0] =='E') {
	for(i=1; i<=e;i++) {
	  r[c+i][d] = 1;
	  // printf("r[%d][%d] = 1\n",c+i, d);
	}
	c = c + e;
      } else if(ch[0] == 'S') {
	for(i=1;i<=e;i++) {
	  r[c][d-i] = 1;
	  //printf("r[%d][%d] = 1\n",c, d-i);
	}
	 d = d - e;
      } else if(ch[0] == 'W') {
	for(i = 1; i<=e;i++) {
	  r[c-i][d] = 1;
	  //printf("r[%d][%d] = 1\n",c-i, d);

	}
	
	c = c - e;
      }
  }
  k = 0;
      for(j=0; j<21 ; j++) {
      for(i=0; i<21 ; i++) {
	if(r[i][j] == x[i][j]){
	  // printf("r=%d x = %d\n",r[i][j], x[i][j]);
	  k = k +1;
	}
      }
      }
  
  
    if(k == n) {
      printf("Yes\n");
    } else { 
      printf("No\n");
    }
  }

  return 0;
}
  

Measured memory_bytes: 588
#include <stdio.h>
#include <math.h>

int main(){
  int i=0,j,sum=0;
  char ch;
  int str[6];
  while ((ch=getchar())!=EOF){
    if (isdigit(ch)!=0){
      str[i++]=ch-'0';
    }else if (i!=0){
      for (j=0;j<i;j++){
	sum+=str[j]*pow(10,i-j-1);
      }
      i=0;
    }
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 544
#include <bits/stdc++.h>
using namespace std;
int n, arr[100005], best, memo[100005];

int dp(int x){
	if(x==1 || x == 0){
		return 0;
	}
	if (x == 2){
		return abs(arr[x] - arr[x-1]);
	}
	if (memo[x] != -1){
		return memo[x];
	}
	best=min(dp(x-1)+abs(arr[x]-arr[x-1]), dp(x-2)+abs(arr[x-2]-arr[x]));
	memo[x] = best;
	return best;
}

int main(){
	ios_base::sync_with_stdio(0);
	memset(memo, -1, sizeof(memo));
	cin.tie();
	cout.tie();
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
	}
	cout << dp(n) << endl;
}

Measured memory_bytes: 2560
A,B,C,X,Y=[int(x) for x in input().split()]

if X>Y:
    ans=min(Y*2*C+(X-Y)*A,X*A+Y*B,X*2*C) 
else:
    ans=min(X*2*C+(Y-X)*B,X*A+Y*B,Y*2*C) 
print(ans)

Measured memory_bytes: 3060
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  rep(i,3){
    if(s[i] == s[i+1]){
      printf("Bad\n");
      return 0;
    }
  }
  printf("Good\n");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int n,m,k,i,j,l,f,p,ans;bool a[10],b[10];char q[10][10];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(l=1;l<=n;++l)
	for(f=1;f<=m;++f)cin>>q[l][f];
	for(i=0;i<(1<<n);++i)
	for(j=0;j<(1<<m);++j){
		for(l=p=0;l<=n;++l)a[l+1]=(i&(1<<l));
		for(l=0;l<=m;++l)b[l+1]=(j&(1<<l));
		for(l=1;l<=n;++l)
		for(f=1;f<=m;++f)
		if((q[l][f]=='#')&&(!a[l])&&(!b[f]))++p;
		if(p==k)++ans;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3768
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

ll LCM(ll x , ll y){
	return (x*y) / __gcd(x,y) ;
}

void start(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

vector<string> v;
map<string, int> m;
int main()
{
	start();
    int n; 
    cin >> n ;
    v.resize(n);
    string s1 ; cin >> s1 ;
    m[s1]++; 
    v[0] = (s1) ;
    forn(i,n-1){
        string s; cin >> s; 
        v[i+1] = (s);
        m[s]++;
    }
    char c = s1[s1.size() - 1];
    bool b = true ;
    for(auto s : m){
        if(s.second > 1){
            b = false;
        }
    }
    forn(i,n-1){
        if(v[i+1][0] != c){
            b = false;
        }
        // cout << v[i+1][0] << " -- " << c << endl; ;
        c = v[i+1][v[i+1].size() - 1] ;
    }
    cout << ((b)? "Yes" : "No") << endl ;
	return 0 ;
}


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

int n;
int li[10005];

int main()
{
   scanf("%d",&n);
   int ans=0;
   for(int i=1;i<=n;i++)
   {
      scanf("%d",&li[i]);
      while(li[i]%2==0)
      {
         ans++;
         li[i]/=2;
      }
   }
   printf("%d\n",ans);
 	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main(){
  int n;
  int array[105]={0};
  int sum[105]={0};
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>array[i];
  }
  
  for(int i=1;i<=n;i++){
    sum[i]=sum[i-1]+array[i];
  }
  
  int minimum=10000005;
  for(int i=1;i<n;i++){
    int s1=sum[i];
    int s2=sum[n]-sum[i];
    minimum=min(minimum,abs(s1-s2));
  }
  cout<<minimum<<endl;
  return(0);
}


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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char a = sc.next().toCharArray()[0];
		char b = sc.next().toCharArray()[0];

		if (a == 'H') {
			if (b == 'H') {
				System.out.println('H');
			} else {
				System.out.println('D');
			}
		} else {
			if (b == 'H') {
				System.out.println('D');
			} else {
				System.out.println('H');
			}
		}
	}

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

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

	public static class Scanner {
		private BufferedInputStream inputStream;

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

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

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

			return num;
		}

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

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

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

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

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

			return num;
		}

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

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

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

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

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

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

			return read;
		}
	}
}


Measured memory_bytes: 20692
a,b=map(int,input().split())

st=.08
lt=.1
s=[]
l=[]

for i in range(1262):
    if a/st<=i<(a+1)/st:
        s.append(i)

for i in range(1262):
    if b/lt<=i<(b+1)/lt:
        l.append(i)

t=[]

for i in s:
    if i in l:
        t.append(i)

if not t:
    print('-1')
else:
    print(min(t))

Measured memory_bytes: 9212
#include<bits/stdc++.h>
main(){int A,B,K,i;std::set<int> S;std::cin>>A>>B>>K;for(i=0;i<K;i++)if(B-A>=i)S.insert(A+i),S.insert(B-i);for(auto x:S)std::cout<<x<<'\n';}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buf = String::new();
    let mut stdin = io::stdin();
    stdin.read_line(&mut buf);
    let X: i64 = buf.trim_end().parse().unwrap();
    if X >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin >> l[i];
    sort(l.begin(), l.end());
 
    int count = 0;
 
    for(int i=0;i<n;i++) {
        for(int j=0;j<i;j++) {
            for(int k=0;k<j;k++) {
                if(l[i]<l[k]+l[j] && l[k]!=l[j] && l[i]!=l[j]){
                    count++;
                }
            }
        }
    }
 
    cout << count << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    h[0]--;
    for (int i = 1; i < n; i++){
        if (h[i] == h[i - 1]) continue;
        if (h[i] < h[i - 1]){
            cout << "No" << endl;
            exit(0);
        }
        h[i]--;
    }
    cout << "Yes" << endl;
}

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

int main(){
	
	cin >> Q;
	for(int i = 0; i < Q; i++){
		double c,a,n;
		cin >> c >> a >> n;
		int ccc = 0,cca = 0;
		int can = min(c,min(a,n));
		c -= min(a,n);
		if(c>0){
			a -= min(a,n);
			cca = min(floor(c/2), a);
			c -= min(floor(c/2), a)*2;
			if(c>0)ccc = floor(c/3);
		}
		cout << can+cca+ccc <<endl;
	}
	return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

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

  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  cout << a[a.size()-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int i, j, k, l,a, c, b;
    string p,   q;
    cin>>p>>q;

    l=p.length();


    for(i=0;i<l;i++)
    {
        if(p==q){
            cout<<"Yes";
            return 0;
        }
        string ss=p.substr(1,l-1);
        ss=ss+p[0];
        p=ss;
        ss="";
    }
    cout<<"No";



    return 0;
}


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

char s[300010];
int r_w[300010], r_e[300010];

int main() {
	int n;
	cin >> n;
	cin >> s;
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			count++;
		}
		r_w[i] = count;
	}
	count = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'E') {
			count++;
		}
		r_e[i] = count;
	}
	int ans, answer = 1e9;
	for (int i = 0; i < n; i++) {
		ans = r_w[i]+ r_e[i];
		if (s[i] == 'W') {
			ans--;
		}
		if (s[i] == 'E') {
			ans--;
		}
		answer = min(ans, answer);
	}
	cout << answer << endl;
	return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll dp[101][100001];

int main() {
  int n, W;
  cin >> n >> W;
  int w[n], v[n];
  REP(i, n) cin >> w[i] >> v[i];
  REP(i, 101) REP(j, 100001) dp[i][j] = 1e18;
  dp[0][0] = 0;
  REP(i, n) {
    for (int j = 0; j + v[i] <= 100000; ++j) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
    }
  }
  int ans = 0;
  REP(i, 100001) if (dp[n][i] <= W) ans = i;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,k,q;
  cin>>n>>k>>q;
  int cor[n];
  for(int i=0;i<n;i++){
    cor[i]=0;
  }
  for(int i=0;i<q;i++){
    int a;
    cin>>a;
    cor[a-1]++;
  }
  for(int i=0;i<n;i++){
    if(k-q+cor[i]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}


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

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

int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  
  int k=0;
  for(int i=2;;i++){
    if(i%5==1 && isP(i)){
      V[k] = i;
      k++;
      if(k==N) break;
    }
  }
  
  for(int i=0;i<N;i++){
    if(i) cout << " ";
    cout << V[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#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 mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;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;
vector<pair<P,int> >vec;
ll dp[1005][20005];
bool cmp(const pair<P,int>&a,const pair<P,int>&b){
	return a.fi.fi+a.fi.sc<b.fi.fi+b.fi.sc;
}
ll v[1005];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b; cin>>a>>b>>v[i];
		vec.pb(mp(mp(a,b),i));
	}
	sort(vec.begin(),vec.end(),cmp);
	rep(a,1005)rep(b,20005)dp[a][b] = -1e18;
	dp[0][0] = 0;
	ll ans = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<20005-vec[i].fi.fi;j++){
		    dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
		    ans = max(ans,dp[i+1][j]);
			if(j > vec[i].fi.sc) continue;
			dp[i+1][j+vec[i].fi.fi] = max(dp[i+1][j+vec[i].fi.fi],dp[i][j]+v[vec[i].sc]);
			ans = max(ans,dp[i+1][j+vec[i].fi.fi]);
		}
	}
cout<<ans<<endl;}


Measured memory_bytes: 157312
from itertools import accumulate

n, m, q = map(int, input().split())
rails = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    rails[l - 1][r - 1] += 1
rails = [list(accumulate(s)) for s in rails]
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(*rails)]
buf = []
for _ in range(q):
    p, q = map(int, input().split())
    buf.append(rails[q - 1][p - 1])
print('\n'.join(map(str, buf)))


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

using namespace std;

template <typename T> void printVector(vector<T> vector) {
  if (vector.size() > 0)
    cout << vector[0];
  for (auto it = ++vector.begin(); it != vector.end(); it++)
    cout << " " << *it;
  cout << ";\n";
}

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

  int A, B;
  cin >> A >> B;

  A += B;
  A %= 24;

  cout << A << endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 3632
while True:
    a = input()
    b = a.split()
    x = int(b[0])
    y = int(b[1])
    if x == 0 and y == 0 :
        break
    else:
        for i in range(x):
            if i == 0 or i == x-1:
                print("#"*y)
            else:
                print("#{}#".format("."*(y-2)))
                
    print()


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define mod 1000000007
#define rep(i,n)    for(ll i=0;i<n;++i)
#define forup(i,a,b)    for(ll i=a;i<=b;++i)
#define all(v)    v.begin(),v.end()
#define inf 1000000010
#define pii pair<ll,ll>
#define vl vector<ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define MAXN 110
#define bsze 555
#define endl '\n'
#define sz(v) v.size()
#define flush fflush(stdout)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ll power(ll x,ll y, ll md){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

int main(){
    fast;
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    rep(i,n)    cin>>a[i];
    sort(all(a));
    vector<pii> pa(m);
    rep(i,m){
        cin>>pa[i].s>>pa[i].f;
    }
    sort(pa.rbegin(),pa.rend());
    // rep(i,m)    cout<<pa[i].f<<" "<<pa[i].s<<"\n";cout<<endl;
    ll st=0;
    rep(i,m){
        ll lb = lower_bound(a.begin()+st,a.end(),pa[i].f)-(a.begin());
        lb--;
        ll en = st+min(pa[i].s,max((ll)0,lb-st+1));
        while(st!=en){
            a[st]=pa[i].f;
            st++;
        }
        // cout<<"#"<<st<<endl;
        // rep(i,n)    cout<<a[i]<<" ";cout<<endl;
    }
    ll ans=0;
    rep(i,n)    ans+=a[i];
    // rep(i,n)    cout<<a[i]<<" "<<endl;
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(){

	int k,a,b;
    scanf("%d",&k);
    scanf("%d",&a);
    scanf("%d",&b);
    
    for(int i = a; i <= b; i++){
    	
        if(i % k == 0){
        	printf("OK");
            return 0;
        }
    }
    printf("NG");
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


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

int main () {
  int i, j, k, N, D, X[10][10], count=0, sum;
  
  cin >> N >> D;
  
  rep(i,N){
    rep(j,D){
      cin >> X[i][j];
    }
  }
  

  rep(i,N-1){
    for(j=i+1;j<N;j++){
      sum = 0;
      for(k=0; k<D; k++){
        sum += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      for(k=0;k<1000;k++){
        if(sum==k*k){
          count +=1;
          break;
        }
      }
    }
  }
  cout << count;
}




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

public class Solution
{
    public static void Main()
    {
        var S = Console.ReadLine();
        var list = new LinkedList<char>();
        var reverse = false;
        foreach (var c in S)
        {
            list.AddLast(c);
        }
        var Q = int.Parse(Console.ReadLine());
        for (int i = 0; i < Q; i++)
        {
            var query = Console.ReadLine().Split().Select(s => s[0]).ToArray();
            if (query[0] == '1')
            {
                reverse = !reverse;
            }
            else
            {
                if (query[1] == '1')
                {
                    if (reverse)
                    {
                        list.AddLast(query[2]);
                    }
                    else
                    {
                        list.AddFirst(query[2]);
                    }
                }
                else
                {
                    if (reverse)
                    {
                        list.AddFirst(query[2]);
                    }
                    else
                    {
                        list.AddLast(query[2]);
                    }
                }
            }
        }

        string result;
        if (reverse)
        {
            result = string.Join("", list.Reverse());
        }
        else
        {
            result = string.Join("", list);
        }
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 35724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n;
ll dp[200005], a[200005], b, ans = -1e15;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%lld", a+i);
		dp[i] = (i>1?dp[i-2]:0) + a[i];
		if(i&1) dp[i] = max(dp[i], dp[i-1]);
	}
	if(n&1){
		for(int i=n-1; i>=0; i-=2){
			ans = max(ans, (i?dp[i-1]:0)+b);
			b += a[i];
		}
	}else ans = dp[n-1];
	printf("%lld\n", ans);
}


Measured memory_bytes: 6892
#include<bits/stdc++.h>
using namespace std;
int r,s,p;


int win(char c){
  if(c=='r') return p;
  else if(c=='s') return r;
  else return s;
}

int main(){
  int n,k,ans=0;
  string t;
  cin>> n >> k >> r >> s >> p >> t;
  for (int i=0; i<k; i++){
    string check;
    bool pre=true;
    for(int j=i; j<t.size(); j+=k){ check.push_back(t[j]); }
    ans+=win(check[0]);
    for(int j=1; j<check.size(); j++){
      if(check[j-1]==check[j] && pre){ pre=false; continue;}
      ans+=win(check[j]);
      pre=true;
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
#define int long long
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}
signed main(){
	int n;
	int a[100001],b[100001];
	vector<pair<int,bool>>v;
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
		v.push_back({a[i],true});
		v.push_back({b[i]+1,false});
	}
	sort(v.begin(),v.end());
	int cnt=0;
	int ans=0;
	rep(i,v.size()){
		if(v[i].second)cnt++;
		else cnt--;
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 8068
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    int taka_num = (b+c-1)/b;
    int aoki_num = (d+a-1)/d;

    if (taka_num <= aoki_num) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}



Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n>999)
    cout<<"ABD"<<endl;
  else
    cout<<"ABC"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n, m, i, j, k, ans, x, y;
char s[200005], t[200005];
int main()
{
	scanf ("%s%s", s, t);
	n = sizeof(s);
	for (i=0; i<n; i++)
	{
		if (s[i] != t[i])
		{
			ans++;
		}
	}
	printf ("%d", ans);
	return 0;
}

Measured memory_bytes: 2100
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    s = list(input())
    ans = 0
    for i in range(n-2):
        if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int N,W;
    cin>>N>>W;
    //vector<int> w(N);
    //vector<int> v(N);
    vector<vector<int>> w(4);
    int w1;
    rep(i,N){
        int we;
        int vi;
        cin>>we>>vi;
        if(i==0){
            w[0].pb(vi);
            w1=we;
        }
        else{
            w[we-w1].pb(vi);
        }
    }
    rep(i,4){
        sort(rall(w[i]));
        //debug(w[i].size());
    }
    ll ans=0;
    rep(i,w[0].size()+1){
        rep(j,w[1].size()+1){
            rep(k,w[2].size()+1){
                rep(l,w[3].size()+1){
                    if((i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3))>W) continue;
                    //cout<<(i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3))<<endl;
                    int memo=0;
                    rep(o,i){
                        memo+=w[0][o];
                    }
                    rep(op,j){
                        memo+=w[1][op];
                    }
                    rep(oq,k){
                        memo+=w[2][oq];
                    }
                    rep(oe,l){
                        memo+=w[3][oe];
                    }
                    ans=max(ans,memo);
                }
            }
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

void solve(){
    int r;
    cin >> r;
    cout << 2 * r * M_PI << endl;

}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 3768
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(a,b,c);
 
    out(c,a,b);
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 998244353;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

int modpow(int a, int n, int m = MOD){
    ll ret = 1;
    while(n>0){
        if(n&1) ret = (ret*a) % m;
        a = (a*a) % m;
        n >>= 1;
    }
    return ret % m;
}

signed main(){
    int n, x, m;
    cin >> n >> x >> m;
    map<int, int> mp;
    vi mem;
    int ans = 0;
    
    rep(i,n){
        mp[x] = i;
        mem.emplace_back(x);
        
        ans = ans + x;
        x = mod(x * x, m);
        
        if(mp.count(x)){

            int tmp = 0;
            int loopsize = mem.size() - mp[x];

            reps(j, mp[x], mem.size()-1){
                tmp += mem[j];
            }

            int loopleft = n - (i+1);
            ans += (loopleft / loopsize) * tmp;

            rep(j, loopleft % loopsize) {
                ans += x;
                x = mod(x * x, m);
            }

            break;
        }
    }
    
    cout << ans << endl;
}

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

int main() {
    string s;
    cin >> s;
    int K;
    cin >> K;

    int n = (int)s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a') continue;
        
        int shift = 'z' - (s[i]) + 1;
        if (shift <= K) {
            s[i] = 'a';
            K -= shift;
        }
    }

    if (K > 0) {
        K %= 26;
        int ascii = ((s[n - 1] - 'a') + K) % 26;
        s[n - 1] = char('a' + ascii);
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var N uint32
	fmt.Scanf("%d", &N)
	var i, j, k uint32

	x := make([][]int, N)
	y := make([][]int, N)
	A := make([]uint32, N)
	for i = 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
		x[i] = make([]int, A[i])
		y[i] = make([]int, A[i])
		for j = 0; j < A[i]; j++ {
			fmt.Scanf("%d %d", &x[i][j], &y[i][j])
		}
	}

	max := 0

	for i = 0; i < 2<<N; i++ {
		// 正直者 1, 不親切な人 0
		isValid := true
		for j = 0; j < N; j++ {
			if (i >> j % 2) == 0 {
				continue
			}
			// validate
			for k = 0; k < A[j]; k++ {
				var target uint
				target = uint(x[j][k] - 1)
				if y[j][k] == 1 {
					if (i >> target % 2) != 1 {
						isValid = false
						break
					}
				} else {
					if (i >> target % 2) == 1 {
						isValid = false
						break
					}
				}
			}
			if !isValid {
				break
			}
		}
		if isValid {
			count := 0
			for j = 0; j < N; j++ {
				if (i >> j % 2) == 1 {
					count++
				}
			}
			if count > max {
				max = count
			}
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
/**
 *    author:  tourist
 *    created: 16.11.2019 23:29:28       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, W;
  cin >> n >> W;
  int w1;
  cin >> w1;
  vector<vector<int>> a(4);
  int foo;
  cin >> foo;
  a[0].push_back(foo);
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[x - w1].push_back(y);
  }
  for (int i = 0; i < 4; i++) {
    sort(a[i].rbegin(), a[i].rend());
  }
  long long ans = 0;
  long long sumw = 0, sumv = 0;
  for (int i = 0; i <= (int) a[0].size(); i++) {
  long long b1 = sumw, b2 = sumv;
  for (int i1 = 0; i1 <= (int) a[1].size(); i1++) {
  long long c1 = sumw, c2 = sumv;
  for (int i2 = 0; i2 <= (int) a[2].size(); i2++) {
  long long d1 = sumw, d2 = sumv;
  for (int i3 = 0; i3 <= (int) a[3].size(); i3++) {
    if (sumw <= W) ans = max(ans, sumv);
    if (i3 < (int) a[3].size()) sumw += w1 + 3, sumv += a[3][i3];
  }
  sumw = d1, sumv = d2;
  if (i2 < (int) a[2].size()) sumw += w1 + 2, sumv += a[2][i2];
  }
  sumw = c1, sumv = c2;
  if (i1 < (int) a[1].size()) sumw += w1 + 1, sumv += a[1][i1];
  }
  sumw = b1, sumv = b2;
  if (i < (int) a[0].size()) sumw += w1, sumv += a[0][i];
  }
  cout << ans << '\n';
  return 0;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp[50][500][500];
void solve() {
    ll n, ma, mb;
    cin >> n >> ma >> mb;

    vec<tuple<ll, ll, ll>> abc(n);
    REP(i, n) {
        ll a, b, c;
        cin >> a >> b >> c;
        abc[i] = {a, b, c};
    }
    REP(i, 50) {
        REP(j, 500) {
            REP(k, 500) {
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    REP(i, n) {
        auto [a, b, c] = abc[i];
        REP(j, (n + 1) * 10) {
            REP(k, (n + 1) * 10) {
                if(dp[i][j][k] == INF)
                    continue;
                chmin(dp[i + 1][j][k], dp[i][j][k]);
                chmin(dp[i + 1][j + a][k + b], dp[i][j][k] + c);
            }
             }
    }

    ll ans = INF;
    for(ll i = 1; ma * i <= 400 and mb * i <= 400; i++) {
        chmin(ans, dp[n][i * ma][i * mb]);
    }
    if(ans == INF)
        cout << -1 << en;
    else
        cout << ans << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 101284
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> prime(100010, true);
    prime.at(1) = false;
    for(int i = 2; i <= 100000; i++) {
        if(prime.at(i)) {
            for(int j = i*2; j <= 100000; j += i) prime.at(j) = false;
        }
    }
    
    vector<int> like2017(100010);
    for(int i = 1; i <= 100000; i++) {
        if(i%2==1&&prime.at(i)&&prime.at((i+1)/2)) like2017.at(i) = like2017.at(i-1) + 1;
        else like2017.at(i) = like2017.at(i-1);
    }
    
    int Q; cin >> Q;
    for(int i = 0; i < Q; i++) {
        int l, r; cin >> l >> r;
        cout << like2017.at(r) - like2017.at(l-1) << endl;
    }
}


Measured memory_bytes: 1408
using System;

class Program
{
    public static void Main(string[] args)
    {
        string[] sta = Console.ReadLine().Split(' ');

        int a = int.Parse(sta[0]);
        int b = int.Parse(sta[1]);
        int c = int.Parse(sta[2]);

        double d = c + 0.5;

        int e = (int)d / a;
        int ans = e * b;
        if (a > c){
            ans = 0;
        }


        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
def gcd(a, b):
  if a%b == 0:
    return b
  else:
    return gcd(b, a%b)
a, b, c, d = map(int, input().split())
n = b - a + 1
mod_c = (n + a%c - 1)//c + 1 if a%c == 0 else (n + a%c - 1)//c
mod_d = (n + a%d - 1)//d + 1 if a%d == 0 else (n + a%d - 1)//d
mod_cd = (n + a%(int(c*d/gcd(c, d))) - 1)//(int(c*d/gcd(c,d))) + 1 if a%(c*d/gcd(c,d)) == 0 else (n + a%(int(c*d/gcd(c,d))) - 1)//(int(c*d/gcd(c,d)))
ans = n - mod_c - mod_d + mod_cd
print(int(ans))

Measured memory_bytes: 38640
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

vector<string> tokenize(const string &s) {
    vector<string> r;
    string item;
    REP(i, s.size()) {
        if (s[i] == '"') {
            r.emplace_back(item);
            item = "";
        } else {
            item.push_back(s[i]);
        }
    }
    r.push_back(item);
    return r;
}

// モジュール
bool is_close(const string &s1, const string &s2) {

    vector<string> token1 = tokenize(s1);
    vector<string> token2 = tokenize(s2);
    if (token1.size() != token2.size()) return false;
    ll diff = 0;
    REP(i, token1.size()) {
        if (token1[i] != token2[i]) {
            if (i % 2) {
                diff++;
            } else {
                return false;
            }
        }
    }

    return diff <= 1;

}

// 処理内容
int main() {

    vector<string> ans;
    
    string s1, s2;
    while (cin >> s1, s1 != ".") {

        cin >> s2;

        if (s1 == s2) {
            ans.emplace_back("IDENTICAL");
        } else if (is_close(s1, s2)) {
            ans.emplace_back("CLOSE");
        } else {
            ans.emplace_back("DIFFERENT");
        }

    }

    REP(i, ans.size()) {
        cout << ans[i] << endl;
    }
    
}


Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <set>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(void){
  char c;
  int n = 0;
  rep(i,3){
    cin>>c;
    if(c == '1')n++;
  }
  cout<<n<<endl;
  
}

Measured memory_bytes: 256
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;

const int N = 100005;

int n,p,ans;
LL m,a[N],b[N],V,v;

bool check(int x)
{
	v=V;
	for(int i=1;i<=n;i++)
		b[i]=a[i];
	LL val=a[x]+m;
	b[x]+=m;
	sort(b+1,b+1+n);
	reverse(b+1,b+1+n);
	for(int i=1;i<=n;i++)
		if(b[i]==val)
		{
			x=i;
			break;
		}
	if(x>p)
		return 0;
	b[x]-=m;
	v-=x;
	for(int i=1;i<=x;i++)
		b[i]+=m;
	sort(b+1,b+1+n);
	reverse(b+1,b+1+n);

	LL cnt=v*m;
	vector<LL> add;
	for(int i=x+1;i<=n;i++)
	{
		LL d=min(min(b[x]-b[i],m),cnt);
		b[i]+=d;
		add.PB(m-d);
		cnt-=d;
	}
	int k=p-x;
	sort(all(add));
	while(!add.empty() && k>0)
	{
		k--;
		cnt-=add.back();
		add.pop_back();
	}
	return (cnt<=0);
}

int main()
{
	cin>>n>>m>>V>>p;
	for(int i=1;i<=n;i++)
		scanf("%lld",a+i);
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	int l=p,r=n,mid;
	while(l<=r)
	{
		mid=(l+r)/2;
		if(check(mid))
		{
			ans=mid;
			l=mid+1;
		}
		else
			r=mid-1;

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

Measured memory_bytes: 3700
using System;

namespace aoj0168 {
	class Program {

		static void Main (string[] args) {
			int[] p = new int[30];
			p[0] = 1;
			p[1] = 2;
			p[2] = 4;
			for (int i = 3;i < 30;i++)
				p[i] = p[i - 1] + p[i - 2] + p[i - 3];
			while (true) {
				int n = int.Parse(Console.ReadLine());
				if (n == 0)
					break;
				Console.WriteLine(p[n - 1]/10/365+1);
			}
		}
	}
}

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

clock_t present = clock();
void complexiti(){
	present = clock() - present;
	cerr << "TIME : " << float(present)/CLOCKS_PER_SEC << '\n';
}

void solver(){
	//~ type your code here
	int n;
	cin >> n;
	vector<double> v(n);
	for(auto &i:v)cin >> i;
	sort(v.begin() , v.end());
	double ans = (v[0] + v[1]) / 2;
	for(int i = 2 ; i < n ; ++i){
		ans = (ans + v[i]) / 2;
	}
	cout << setprecision(10) << ans << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int queries = 1;
	//~ cin >> queries;
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	complexiti();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	for (int i = 0; i < n; i++){
		cin >> v[i];
	}
	for (int i = 0; i < n; i++){
		cin >> c[i];
	}
	for (int i = 0; i < n; i++){
		if (v[i] - c[i] > 0){
			ans += v[i] - c[i];
		}
	}
	cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
all=0
for i in range(N):
  all+=A[i]
  i+=1
count=0
for i in range(N):
  if A[i]>=all*1/(4*M):
    count+=1
if count>=M:
  print('Yes')
else:
  print('No')

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

int main() {
  int nnum;
  cin >> nnum;
  vector<int> in(nnum);
  for(int i = 0; i < nnum; ++i) {
    int num;
    cin >> num;
    in[i] = num;
  }
  multiset<int> nums;
  for(int i = 0; i < nnum; ++i) {
    nums.insert(in[i]);
    vector<int> outs(nnum);
    for(auto j = nums.begin(); j != nums.end(); ++j) {
      outs[distance(nums.begin(), j)] = *j;
    }
    for(int j = i + 1; j < nnum; ++j) {
      outs[j] = in[j];
    }
    cout << outs[0];
    for(auto j = outs.begin() + 1; j != outs.end(); ++j) {
      cout << " " << *j;
    }
    cout << endl;
  }
  return 0;
}

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

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

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

void solve();

int main(void){
    int N, M; cin >> N >> M;
    int ans = 1;
    int lim = M/N + 1;
    if(N == 1) cout << M << endl;
    else if(N % M == 0) cout << M/N << endl;
    else{
        for(int i = 2; i <= lim; i++){
            if(M % i == 0) ans = i; 
        }
        cout << ans << endl;
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 256