akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

inline ll uku(ll a){a%=256; if(a<0){a+=256;} return a;}

using Bit=bitset<256>;

void solve(){
  ll M,N;
  cin>>M;
  map<string,pll> A;
  for(int i=0;i<M;i++){
    string s;
    cin>>s;
    ll lf,rg;
    cin>>lf>>rg;
    A[s]={lf,rg};
  }
  cin>>N;
  stack<Bit> S;
  bool ans=true;
  for(int i=0;i<N;i++){
    string str;
    cin>>str;
    //cout<<i<<" "<<str<<endl;
    Bit b;
    b.reset();
    if(str[0]=='+'){
      Bit x=S.top(); S.pop();
      Bit y=S.top(); S.pop();
      for(int i=0;i<256;i++){
        for(int j=0;j<256;j++){
          if(x[i] && y[j]){b[uku(j+i)]=true;}
        }
      }
    }
    else if(str[0]=='-'){
      Bit x=S.top(); S.pop();
      Bit y=S.top(); S.pop();
      for(int i=0;i<256;i++){
        for(int j=0;j<256;j++){
          if(x[i] && y[j]){b[uku(j-i)]=true;}
        }
      }
    }
    else if(str[0]=='*'){
      Bit x=S.top(); S.pop();
      Bit y=S.top(); S.pop();
      for(int i=0;i<256;i++){
        for(int j=0;j<256;j++){
          if(x[i] && y[j]){b[uku(j*i)]=true;}
        }
      }
    }
    else if(str[0]=='/'){
      Bit x=S.top(); S.pop();
      Bit y=S.top(); S.pop();
      for(int i=0;i<256;i++){
        for(int j=0;j<256;j++){
          if(x[i] && y[j]){
            if(i==0){ans=false; continue;;}
            b[uku(j/i)]=true;
          }
        }
      }
    }
    else if(A.count(str)){
      for(int i=A[str].F;i<=A[str].S;i++){b[i]=true;}
    }
    else{
      ll k=0;
      for(auto &I:str){k*=10; k+=I-'0';}
      k%=256;
      b[k]=true;
    }
    //cout<<b<<endl;
    S.push(b);
  }
  cout<<(ans?"correct":"error")<<endl;
}

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

  return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int n;
    cin>>n;
    map<string,int> h;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        h[s]++;
    }
    cout<<"AC x "<<h["AC"]<<endl;
    cout<<"WA x "<<h["WA"]<<endl;
    cout<<"TLE x "<<h["TLE"]<<endl;
    cout<<"RE x "<<h["RE"]<<endl;
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}


Measured memory_bytes: 3680
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
 
 
 
 
 
int main(){
    string a,b,ans;
    cin>>a>>b;
    for(int i=0;i<a.size()+b.size();i++){
        if(i%2==0){ans.push_back(a[i/2]);}
        else{ans.push_back(b[(i-1)/2]);}
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
//ICPC2012C 偏りのあるサイコロ
#include<iostream>
#include<algorithm>

#define FIELD 9
using namespace std;
enum {S,E,N,W};
int top[FIELD][FIELD];//上面の目
int z[FIELD][FIELD];//高さ

int side[3+1][4]={
	{},
	{3,5,4,2},
	{3,1,4,6},
	{1,2,6,5},
};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
void print(int t,int f,int i){
	cout<<t<<' '<<f<<' '<<i<<endl;
	for(int i=0;i<FIELD;i++){
		cout<<" ";
		for(int j=0;j<FIELD;j++){
			cout<<top[i][j];
		}
		cout<<endl;
	}
}
int getIndex(int t,int n){
	if(3<t)t = 7-t;
	for(int i=0;i<4;i++)
		if(side[t][i]==n)return i;
	return -1;
}
void roll(int *t,int *f,int n,int compass){
	if(compass==N){
		*f = 7-*t;
	}
	else if(compass==S){
		*f = *t;
	}
	*t = 7-n;
}
void fall(int y,int x,int t,int f){
	for(int i=6;4<=i;i--){
		int index=getIndex(t,i);
		if(index==-1)
			continue;
		index = (index-getIndex(t,f)+4) %4;
		if(3<t)index = (4-index)%4;
		if(z[y+dy[index]][x+dx[index]] >= z[y][x])
			continue;
		roll(&t,&f,i,index);
		fall(y+dy[index],x+dx[index],t,f);
		return;
	}
	z[y][x]++;
	top[y][x] = t;
}
int main(){
	int n;
	int num[6+1];
	while(cin>>n,n){
		fill_n(num,7,0);
		fill_n((int*)z,FIELD*FIELD,0);
		fill_n((int*)top,FIELD*FIELD,0);
		for(int i=0;i<n;i++){
			int t,f;
			cin>>t>>f;
			fall(FIELD/2,FIELD/2,t,f);
		}
		for(int i=0;i<FIELD;i++)
			for(int j=0;j<FIELD;j++)
				num[top[i][j]]++;
		cout<<num[1];
		for(int i=2;i<=6;i++)cout<<' '<<num[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
//周♂雨扬是最强的！！！
//大佬祝您AK
//沈哲♂贝是最强的！！！
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<fstream>
using namespace std;
//ifstream fin(.in);
//ofstream fout(.out);
const long long mod=1000000007;
int n;
long long tong[10003];
long long ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x=i;
		for(int j=2;j*j<=i;j++){
			while(x%j==0){
				tong[j]++;
				x/=j;
			}
		}
		if(x!=1){
			tong[x]++;
		}
	}
	ans=1;
	for(int i=1;i<=10000;i++){
		ans=ans*(tong[i]+1)%mod;
	}
	cout<<ans<<endl;
	return 0;
}
//沈♂哲贝是最强的！！！
//大佬祝您AK
//周♂雨扬是最强的！！！

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0),cin.tie(0);
int main() {IOS;
    int n,k;
    cin>>n>>k;
    int dp[n];
    vector<int> H;
    memset(dp,0, sizeof(dp));
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        H.push_back(temp);
    }
    for(int i=1;i<n;i++)
    { 
        int m=abs(H[i]-H[i-1])+dp[i-1];
        for(int j=2;i-j>=0&&j<=k;j++)
        {
          m=min(m,abs(H[i]-H[i-j])+dp[i-j]);
        }
        dp[i]=m;
    }
    cout<<dp[n-1];
}

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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

const int N = 2e5 + 10;
int dp[N], nxt[N][26];

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

	string s; cin >> s;
	int n = s.length();
	

	NFOR (i, n-1, 0) {
		if (i == n - 1) {
			FOR (j, 0, 25) nxt[i][j] = n;
		} else {
			FOR (j, 0, 25) nxt[i][j] = nxt[i+1][j];
		}
		nxt[i][s[i]-'a'] = i;
	}

	NFOR (i, n-1, 0) {
		int mx = *max_element(nxt[i], nxt[i] + 26);
		if (mx < n) {
			dp[i] = 1 + dp[mx + 1];
		}
	}

	int len = dp[0] + 1;
	int pos = 0;
	while (1) {
		int x = -100;
		FOR (i, 0, 25) {
			x = nxt[pos][i];
			if (x < n) {
				if (dp[x+1] < len - 1) {
					break;
				}
			} else {
				x = -i-1;
				break;
			}
		}
		assert(x != -100);
		if (len == 1) {
			assert(x < 0);
			cout << (char)('a'-(x+1));
			break;
		}
		assert(x >= 0);
		cout << s[x];
		--len;
		pos = x + 1;
	}

	return 0;
}


Measured memory_bytes: 21652
#include<bits/stdc++.h>
using namespace std;
int a[50];
int main()
{
   int n,m,cnt=0;
   scanf("%d%d",&n,&m);
   for(int i=1;i<=n;i++)
   {
       int val;
       scanf("%d",&val);
       for(int j=1;j<=val;j++)
       {
           int ch;
           scanf("%d",&ch);
           ++a[ch];
       }
   }
   for(int i=1;i<=m;i++)
   {
       if(a[i]==n)++cnt;
   }
   printf("%d\n",cnt);

}


Measured memory_bytes: 256
from collections import deque

n, k = list(map(int,input().split(' ')))
path = []
for i in range(n+1):
    path.append([])
for i in range(n-1):
    a, b = list(map(int,input().split(' ')))
    path[a].append(b)
    path[b].append(a)
val = [0] * (n+1)
for i in range(k):
    v, pt = list(map(int,input().split(' ')))
    val[v] += pt

used = {}
q = deque([1])
used[1] = True
while q:
    v = q.pop()
    for next_v in path[v]:
        if next_v not in used:
            used[next_v] = True
            val[next_v] += val[v]
            q.append(next_v)

print(' '.join([str(pt) for pt in val[1:]]))


Measured memory_bytes: 128112
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a[3],k;
    cin>>a[0]>>a[1]>>a[2];
    cin>>k;
    sort(a,a+3);
    cout<<a[0]+a[1]+a[2]*(1<<k)<<endl;
}

Measured memory_bytes: 256
#別解思考
n = int(input())
res = 0
for i in range(1, n // 2 +1):
    res += (int(n / i) * (i + int(n / i) * i)) // 2
res += (n + n // 2 +1) * (n - n // 2 ) //2
print(res)

Measured memory_bytes: 63652
using System;
using System.Linq;

namespace ATCoderPuzzles
{
    class CVacation
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            int[] bestSol = new int[3] { 0,0,0 };
            while(n-->0)
            {
                int[] currentRow = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
                bestSol = new int[3]
                {
                    currentRow[0] + Math.Max(bestSol[1], bestSol[2]),
                    currentRow[1] + Math.Max(bestSol[0], bestSol[2]),
                    currentRow[2] + Math.Max(bestSol[0], bestSol[1])
                };
                //Console.WriteLine("New best path: " + string.Join(", ",bestSol));
            }
            
            Console.WriteLine(bestSol.Max());
        }
    }
}


Measured memory_bytes: 41388
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		int sum = 700;
		for(char x : input.toCharArray() ) {
			if(x == 'o')
				sum += 100;
		}
		System.out.print(sum);
	}
}

Measured memory_bytes: 21844
n,k=map(int,input().split())
p=list(map(int,input().split()))

b=[0]
for i in range(1,n+1):
 b.append(p[i-1]+b[i-1])

mm=0
inx=-1
for i in range(len(b)-k):
 if b[i+k]-b[i]>=mm:
  inx=i
  mm=b[i+k]-b[i]


ans=0
for j in range(inx,inx+k):
  ans+=((p[j]*(p[j]+1))*0.5)*(1/p[j])

print(ans)

Measured memory_bytes: 24548
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	reverse(a.begin(), a.end());
	for (int i = 0; i < n; i++)
	{
		if (i == n - 1) cout << a[i] << endl;
		else cout << a[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 3100
import sys
input=sys.stdin.readline
n,m = map(int, input().split())
link = [[] for _ in range(n)]
for i in range(m):
    tmp = list(map(int,input().split()))
    link[tmp[0]-1].append(tmp[1]-1)
    link[tmp[1]-1].append(tmp[0]-1)
from collections import deque
Q = deque()
Q.append(0)
visited=[-1]*n
hist=deque()
while Q:
    now = Q.pop()
    if visited[now]!=-1:
        continue
    hist.append(now+1)
    visited[now]=0
    is_nxt=False
    for nxt in link[now]:
        if visited[nxt]==-1:
            is_nxt=True
            Q.append(nxt)
    if not is_nxt:
        break
Q = deque()
Q.append(0)
visited[0]=-1
while Q:
    now = Q.pop()
    if visited[now]!=-1:
        continue
    if now != 0:
        hist.appendleft(now+1)
    visited[now]=0
    is_nxt=False
    for nxt in link[now]:
        if visited[nxt]==-1:
            is_nxt=True
            Q.append(nxt)
    if not is_nxt:
        break
print(len(hist))
print(*hist,sep=" ")

Measured memory_bytes: 62956
import java.io.*;
import java.util.*;

public class Main {
  static private InputReader in;
  static private PrintWriter out;

  public static void main(String[] args) {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Task solver = new Task();
    solver.solve();
    out.close();
  }

  static class Task {
    public void solve() {
      int a = in.nextInt();
      int b = in.nextInt();
      int c = in.nextInt();
      out.println(Math.min(b / a, c));
    }
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }
    
    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}

Measured memory_bytes: 23252
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
a = inp
sum = a.inject(:+)
min = 1e20
now = sum
now2 = 0
a[0..(n-2)].each do |d|
  now2 += d
  now -= d
  drf = (now2 - now).abs
  min = [min, drf].min
end
p min

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	main() {
	string s;
	cin >>s;
	int L=s.size();
	int R=0;
	for (int i=0; i<s.size(); i++) {
		if ('A'==s.at(i))
			L=min(L, i);
		else if ('Z'==s.at(i))
			R=i;
	}
	cout <<R-L+1 <<endl;
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t; cin>>s>>t;
	int cnt,len;
	len=s.size()-1;
	cnt=s.size();
	while(cnt--){
		char e=s[len];
		s.erase(len);
		s=e+s;
		if(s==t){
			cout<<"Yes"<<endl;
			return 0;	
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main(){
  int n, m;
  while(true){
    cin>>n>>m;
    if(n==0&&m==0)break;
    queue<int> q;
    int ans;
    for(int i=0; i<n; i++)q.push(i);
    while(q.size()!=1){
      for(int i=0; i<m-1; i++){q.push(q.front()); q.pop();}
      q.pop();
    }
    cout<<q.front()+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
def solve(L, x):
    if L == 0:
        return 1
    elif x == 1 or x == 0:
        return 0
    elif (2**(L+2)-3)//2 >= x >= 2:
        return solve(L-1, x-1)
    elif x == (2**(L+2)-3)//2 +1:
        return (2**(L+1)-1)//2+1
    elif (2**(L+2)-3)//2+2 <= x <= (2**(L+2)-3):
        return 2**(L+1)-1-solve(L,(2**(L+2)-3)-x)

N, X = map(int, input().split())
print(solve(N, X))

Measured memory_bytes: 3064
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())

if N >= 0:
    e = 2
    n = N
else:
    e = 1
    n = -N
while e <= n:
    if n & e:
        n += e << 1
    e <<= 2
print(bin(n)[2:])


Measured memory_bytes: 3064
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int P[10010];
void init(int N) {
  for (int i=1; i<=N; ++i)
    P[i] = i;
}
int root(int a) {
  if (P[a] == a)
    return a;
  return (P[a] = root(P[a]));
}
bool is_same_set(int a, int b) {
  return root(a) == root(b);
}
void unite(int a, int b) {
  P[root(a)] = root(b);
}

int n;

int main() {
  cin >> n;
  init(n);
  vector<pair<int,int>> NC;
  int src[10010]; int dst[10010];
  int ind = 0;
  int c;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> c;
      if (i < j && c >= 0) {
        ind++;
        NC.push_back(make_pair(c, ind));
        src[ind] = i; dst[ind] = j;
      }
    }
  }
  sort(NC.begin(), NC.end());
  int ans = 0;
  int cst, id, s, d;
  for (int i = 0; i < ind; i++) {
    cst = NC[i].first; id = NC[i].second;
    s = src[id]; d = dst[id];
    if (!(is_same_set(s, d))) {
      ans += cst;
      unite(s, d);
    }
  }
  cout << ans << endl;
}



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

int main() {
  int N;
  cin >> N;
  int d = 0;
  
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 0) continue;

    int dc = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) dc++;
    }
    if (dc == 8) d++;
  }
  
  cout << d << endl;
}


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

		int n = sc.nextInt();
		String s[] = new String[n];
		int data[] = new int [n];
		int count = 0;
		int max = 0;
		String ans[] = new String[n];
		int precount = 0;

		for (int i = 0;i<n ;i++ ) {
			s[i] = sc.next();
			ans[i] = s[i];
		}

		Arrays.sort(s);
		Arrays.sort(ans);

		for (int i = 0;i<n-1 ;i++ ) {
			if (s[i].equals(s[i+1])) {
				data[count]++;
				ans[count] = s[i];
				precount++;
			}else{
				max = Math.max(max,data[count]);
				count++;
			}
		}
		max = Math.max(max,data[count]);
		if (n-1==precount) {
			System.out.println(ans[0]);
			System.exit(0);
		}

		for (int i = 0;i<n ;i++ ) {
			if (max==data[i]) {
				System.out.println(ans[i]);
			}
		}




	}
}


Measured memory_bytes: 81616
#include<iostream>

using namespace std;

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

        int count = 0;

        for(int i=0;i<=a;i++)
        {
                for(int j=0;j<=b;j++)
                {
                        for(int k=0;k<=c;k++)
                        {
                                if(500*i+100*j+50*k==x)
                                        count++;
                        }
                }
        }

        cout << count << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
long long GCD(long long a,long long b){
	return b?GCD(b,a%b):a;
}
long long num[1000005],cnt[1000005]={0},cnt2[1000005]={0};
bool prime[1000005]={0},check=0;
vector<long long> all;
int main(){
	long long i,j,n;
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&num[i]);
		cnt[num[i]]++;
		if(cnt[num[i]]>1&&num[i]!=1)
			check=1;
	}
	long long v=num[0];
	for(i=1;i<n;i++)
		v=GCD(v,num[i]);
	for(i=2;i<=1000000;i++){
		if(!prime[i]){
			all.emplace_back(i);
			for(j=i*i;j<=1000000;j+=i)
				prime[j]=1;
		}
	}
	all.emplace_back(1000000001);
	if(v==1){
		if(check){
			puts("setwise coprime");
			return 0;
		}
		for(i=0;i<n&&!check;i++){
			for(auto x:all){
				if(x*x>num[i])
					break;
				if(num[i]%x==0)
					cnt2[x]++;
				while(num[i]%x==0)
					num[i]/=x;
				if(cnt2[x]>=2)
					check=1;
			}
			long long id=lower_bound(all.begin(),all.end(),num[i])-all.begin();
			if(all[id]==num[i]){
				cnt2[num[i]]++;
				if(cnt2[num[i]]>=2)
					check=1;
			}
		}
		if(check)
			puts("setwise coprime");
		else
			puts("pairwise coprime");
	}
	else
		puts("not coprime");
}


Measured memory_bytes: 20780
function Main(input) {
  input = input.split("\n");
  var A = parseInt(input[0].split(" ")[0]);
  var B = parseInt(input[0].split(" ")[1]);
  var C = parseInt(input[0].split(" ")[2]);
  var ans="No";
  if(A==B&&B==C){
    ans="Yes";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int N, Y, ten=-1, five=-1, one=-1;
	bool flag = false;
    cin >> N >> Y ;
  	for(int i = 0; i <= N; i++){
      for(int j = 0; j <= (N-i); j++){
         if(Y==10000*i+5000*j+1000*(N-i-j)){
          ten=i;
          five=j;
          one=N-i-j;
          break;
        }
      }
    }
   cout << ten << " " << five << " " << one << endl;
}


Measured memory_bytes: 256
const int max = 1000000;

void main(){
	int s = _scan();
	int[int] dic;
	dic[s]++;
	// 初項sでa_1, ... なので2から始まる
	foreach(i; 2..max+1){
		if(s&1) s = 3*s +1;
		else s = s/2;

		dic[s]++;
		if(dic[s]==2){
			i.writeln();
			break;
		}
	}
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

using namespace std;

int main() {

	int n,x;

	while (1) {
		cin >> n >> x;
		if (n == 0 && x == 0) { return 0; }
		int counter = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i+1; j <= n; j++) {
				if (i == j) { continue; }
				for (int k = j+1; k <= n; k++) {
					if (i == k || j == k) { continue; }
					if (i + j + k == x) { counter++; }
				}
			}
		}
		cout << counter << endl;
	}
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
const int N=2e5;
int a[4005],b[4005],c[4005];

int main(){
int n,l=0,m=0,r=0;
ll ans=0;
string s;
cin>>n>>s;
rep(i,n){
if(s[i]=='R')
    a[l++]=i+1;
if(s[i]=='G')
    b[m++]=i+1;
if(s[i]=='B')
    c[r++]=i+1;
}
for(int i=0;i<l;i++)
for(int j=0;j<m;j++){
    int sum=r;
    int a1=min(a[i],b[j]);
    int b1=max(a[i],b[j]);
    if(2*a1-b1-1>=0&&2*a1-b1-1<n&&s[2*a1-b1-1]=='B')
        sum--;
    if(2*b1-a1-1>=0&&2*b1-a1-1<n&&s[2*b1-a1-1]=='B')
        sum--;
    if((a1+b1)%2==0&&s[(a1+b1)/2-1]=='B')
        sum--;
    ans+=sum;
    //cout<<ans<<endl;
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int min(int a, int b) {
  return a < b ? a : b;
}

int max(int a, int b) {
  return a > b ? a : b;
}

int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(max(a, b) % min(a, b), min(a, b));
}

int main(void) {
  int n;
  scanf("%d", &n);

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        int t = gcd(gcd(i, j), k);
        ans += t;
      }
    }
  }

  printf("%d\n", ans);
}


Measured memory_bytes: 1728
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = long long; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(2 2
2 1 2
1 2
0 1)X";
stringstream iss{text};
#endif

class Switches
{
	ll N{0}, M{0}, allS{0}, cnt{0};
	vector<vector<ll>> s;
	vector<ll> p;
	void inp( ) {
		iss >> N >> M;
		s.resize(M);
		rep(m, M) {
			ll K; iss >> K;	s[m].resize(K);
			rep(k, K) { iss >> s[m][k]; }
		}
		p.resize(M); rep(m, M) { iss >> p[m]; }
	}
	inline ll Non(ll m) {//m番目の電球につながっているスイッチでonのものの個数
		ll con{0};
		for (auto &p : s[m]) {// m番目の電球につながっているp番目のスイッチ
			if ((allS >> (p - 1)) & 1) ++con; //スイッチpがonかどうか
		}
		return con;
	}
	inline bool light(ll m) {//m番目の電球がつくか？
		return ((Non(m) % 2) == p[m]);
	}
	inline bool allonQ( ) {//全部の電球がつくか
		rep(m, M) { if (!light(m)) return false; }
		return true;
	}
	void changeSwitch( ) {
		for (ll b = 0; b < ll(1 << N); ++b) {
			allS = b;//スイッチの状態を変える
			if (allonQ( )) ++cnt;
		}
	}
public:
	void procedures( ) {
		inp( );
		changeSwitch( );
		p(cnt);
	}
};

int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class Switches a; a.procedures( );
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int ans = N*(N-1)/2 + M*(M-1)/2;
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
struct Data
{
	ll num;
	Data() :num(INF) {};
	Data(ll n) :num(n) {};
};

struct SegmentTree
{
	int n; vector<Data> data;
	SegmentTree(int N)
	{
		n = 1;
		while (n < N) n *= 2;
		data.resize(2 * n);
	}
private:
	Data sub(int left, int right, int node, int nleft, int nright)
	{
		if (nright <= left || right <= nleft) return Data();
		if (left <= nleft && nright <= right) return data[node];
		Data vl = sub(left, right, node * 2 + 1, nleft, (nleft + nright) / 2);
		Data vr = sub(left, right, node * 2 + 2, (nleft + nright) / 2, nright);
		return min(vl.num, vr.num);
	}

public:
	void update(int pos, Data value)
	{
		pos += n - 1;
		data[pos] = value;
		while (pos > 0)
		{
			pos = (pos - 1) / 2;
			data[pos] = min(data[pos * 2 + 1].num, data[pos * 2 + 2].num);
		}
	}
	Data min_query(int left, int right)
	{
		return sub(left, right, 0, 0, n);
	}
};



int main()
{
	ll n;
	cin >> n;
	SegmentTree seg(n);
	REP(i, n) seg.update(i, 0);
	REP(i, n)
	{
		int a;
		cin >> a;
		ll val = seg.min_query(0, a).num - a;
		seg.update(a-1, val);
	}
	cout << n*(n + 1) / 2 + seg.min_query(0, n).num << endl;
	return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k,a,b;
	cin>>k>>a>>b;
	for(ll i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;
#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  ll S;
  cin >> S;
  ll y2 = INF;
  ll x1;
  if(S % y2 == 0) {
    x1 = S / y2;
  } else {
    x1 = S / y2 + 1;
  }
  ll rest = y2 * x1 - S;
  ll x2 = rest;
  ll y1 = 1;
  dump(x1, y2, x2, y1);
  dump(x1 * y2 - x2 * y1);
  assert(S == abs(x1 * y2 - x2 * y1));
  assert(x1 <= INF && x2 <= INF && y1 <= INF && y2 <= INF);
  cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin, x.end
#define mkp make_pair
#define trav(x, i) for(auto& i : x)
typedef long long ll;
typedef unsigned int uint;

int main(){
  int a, b;
  cin >> a >> b;
  if(a + b == 3) cout << 3;
  else if (a + b == 5) cout << 1;
  else cout << 2; 
  return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;

set<string>s;
vector<ll>ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin>>k;
	queue<string>q;
	for(int i=1;i<=9;i++)
    {
        q.push(to_string(i));
    }
    while(s.size()<=1e6)
    {
        string now=q.front();
        s.insert(now);
        char w=now.back();
        q.pop();
        if(w!='0'&&w!='9')
        {
            q.push(now+w);
            w--;
            q.push(now+w);
            w+=2;
            q.push(now+w);
        }
        else if(w=='0')
        {
            q.push(now+w);
            w++;
            q.push(now+w);
        }
        else
        {
            q.push(now+w);
            w--;
            q.push(now+w);
        }


    }
    for(auto &v:s)
    {
        ans.push_back(stoll(v));
    }
    sort(ans.begin(),ans.end());
    cout<<ans[k-1]<<'\n';









}

Measured memory_bytes: 255160
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char S[9];
    cin>>S;
    int narahatakun=0;
    for(int i=0;i<4;i++){
        if(S[i]=='+')narahatakun++;
        if(S[i]=='-')narahatakun--;
    }
    cout<<narahatakun<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
using namespace std ;

ll x, y ;

int main() {
    scanf("%lld%lld", &x, &y) ;
    int ans = 0 ;
    for ( ; x <= y ; x *= 2) ++ ans ;
    printf("%d\n", ans) ;
    return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		double x1 = scan.nextDouble();
		double y1 = scan.nextDouble();
		double x2 = scan.nextDouble();
		double y2 = scan.nextDouble();
		double x = x1 - x2;
		double y = y1 - y2;
		System.out.println(Math.sqrt((x*x) + (y*y)));
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 28076
import sys
input = sys.stdin.readline
R, C, N = map(int, input().split())
a = []

def conv(i, j):
  res = 0
  if i == 0:
    res = j
  elif j == C:
    res = C + i
  elif i == R:
    res = C + R + (C - j)
  elif j == 0: res = 2 * C + R + (R - i)
  else: res = -1
  return res

for i in range(N):
  x, y, u, v = map(int, input().split())
  d, dd = conv(x, y), conv(u, v)
  if d >= 0 and (dd >= 0):
    a.append((d, i))
    a.append((dd, i))
a.sort()
s = []
for _, i in a:
  if len(s) and s[-1] == i: s.pop()
  else: s.append(i)
if len(s): print("NO")
else: print("YES")

Measured memory_bytes: 94108
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> x(m), next(m);
  rep (i, m) cin >> x[i];
  sort(all(x));
  rep (i, m - 1) next[i] = x[i + 1] - x[i];
  sort(all(next));
  lint sum = accumulate(all(next), 0LL);
  lint dec = accumulate(next.end() - min(n - 1, m), next.end(), 0LL);
  cout << sum - dec << endl;
  return 0;
}

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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;


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

    int cnt=0;
    for(int i=1; i<=N/2; i++){
        if(i != (N-i)) cnt++;
    }

    cout << cnt << endl;



}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = tuple(map(int, input().split()))
X = 0
for i in range(len(bin(K)) - 2, -1, -1):
    if (X + (1 << i)) > K:
        continue
    if sum((a >> i) & 1 for a in A) * 2 < N:
        X += (1 << i)
print(sum(a ^ X for a in A))


Measured memory_bytes: 14620
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int a, p;
	cin >> a >> p;
	p += 3 * a;
	cout << p / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 		Resilience is the greatest of all virtues.
 		Code by rajiv
 */
 #include <iostream>
 #include <cstring>
 #include <vector>
 #include <map>
 #include <set>
 #include <stack>
 #include <queue>
 #include <deque>
 #include <sstream>
 #include <iomanip>
 #include <cassert>
 #include <sys/time.h>
 #include <algorithm>
 #include <bitset>
 #include <cmath>
 #include <functional>
 #include <cmath>
 #include <climits>

 using namespace std ;

 #define xx first
 #define yy second
 #define ll long long
 #define ld long double
 #define el (char)0x0A
 #define sp " "
 #define pb push_back
 #define mp make_pair
 #define all(x) (x).begin(),(x).end()
 #define clr(x) memset((x),0,sizeof(x))
 #define uint unsigned int
 #define abs(x) ((x<=0)?(-x):(x))
 #define CASET  int t;cin>>t;while(t--)
 #define FORN(i,x,y) for(int i=x;i<y;i++)
 #define MAXN 100005
 #define INF 10000000010
 #define MOD 1000000007
 #define last_set_bit(x) log2((x)&(-x))
 #define add(x,y) (x)=((x)+(y))%MOD
 #define PI 3.141592653589793

 typedef pair<int,int> PII ; typedef vector<int> VI ; typedef vector<vector<int> > VVI ; typedef vector<bool> VB ; typedef vector<string> VS ;
 typedef map<int,int> MII ; typedef map<int,VI > MIV ; typedef set<int> SI ; typedef set<PII > SPII ; typedef vector<PII > VPII ; typedef vector<VPII > VVPII ;
 const int N = 100050 ;
 ll gcd(ll a , ll b){
     if (a < b) return gcd(b, a) ;
     if (b == 0) return a ;
     return gcd(b, a%b) ;
 }

 int main(){
     int n ; cin >> n ;
     ll a[n] ;
     for(int i = 0 ; i < n ; i++){
         cin >> a[i] ;
     }
     sort(a, a+n) ;
     ll g = a[0] ;
     for(int i = 1 ; i < n ; i++){
         g = gcd(g, a[i]) ;
     }
     cout << g << el ; 


 }


Measured memory_bytes: 1024
#include <iostream>
#include <map>
using namespace std;
map<long long,int> mp;
int main(){
	long long i,n;
	cin >> n;
	for(i=2;i*i<=n;i++){
		while(n%i==0){
			n /= i;
			mp[i]++;
		}
	}
	if(n!=1) mp[n]++;
	int mn = 0,mx = 1;
	for(auto x: mp){
		mn++;
		mx *= (x.second + 1);
	}
	mx--;
	cout << mn << " " << mx << endl;
}


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

int main(){
  int k,x,i;
  cin >> k >> x;
  for(i=x-k+1; i<x-k+k*2; i++){
    if (i>=-1000000 && i<=1000000){
    	cout << i;
    	cout << " ";
    }
  }
  
  return 0;
}

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

// --- DEBUG begin --- cut here ---
template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

template <class Head>
void dbgLog(Head&& head) {
  cerr << head << endl;
}

template <class Head, class... Tail>
void dbgLog(Head&& head, Tail&&... tail)
{
  cerr << head << " ";
  dbgLog(forward<Tail>(tail)...);
}

#if DEBUG
  #define DLOG(...)        dbgLog(__VA_ARGS__)
  #define DFMT(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFMT(...)
  #define DCALL(func, ...)
#endif

// operator<< definitions for some classes

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 << '[';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  os << ']';

  return os;
}

template <typename T, typename T2, typename T3>
ostream& operator<< (ostream& os, const priority_queue<T, T2, T3>& orig) {
  priority_queue<T, T2, T3> pq(orig);
  bool first = true;
  os << '[';
  while (!pq.empty()) {
    T x = pq.top(); pq.pop();
    if (!first) os << ", ";
    os << x;
    first = false;
  }
  return os << ']';
}
// --- DEBUG end --- cut here ---


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<double> X(N);
  vector<double> Y(N);
  double xMax = 0;
  double xMin = 1000;
  double yMax = 0;
  double yMin = 1000;
  for (ll i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i);
    xMax = max(xMax, X.at(i));
    yMax = max(yMax, Y.at(i));
    xMin = min(xMin, X.at(i));
    yMin = min(yMin, Y.at(i));

  }
  double err = 1e-9;

  auto getR = [&](double x0, double y0) -> double {
    double ret = 0.0;
    for (int i = 0; i < N; i++) {
      double xd = X.at(i) - x0;
      double yd = Y.at(i) - y0;
      ret = max(ret, xd*xd + yd*yd);
    }
    return sqrt(ret);
  };

  double xc = (xMax + xMin) / 2;
  double yc = (yMax + yMin) / 2;
  double s = max(xMax - xMin, yMax - yMin) / 2;
  double rMin = 10000;
  while (true) {
    double rPrev = rMin;
    double xB;
    double yB;
    int div = 64;
    rMin = 10000;
    for (int i = -div; i <= div; i++) {
      for (int j = -div; j <= div; j++) {
	double r = getR(xc + i * s / div, yc + j * s / div);
	if (r < rMin) {
	  xB = xc + i * s / div;
	  yB = yc + j * s / div;
	  rMin = r;
	}
      }
    }
    xc = xB + s/6;
    yc = yB + s/6;
    s /= 2;
    DLOG("xysr", xc, yc, s, rMin);
    if (abs(rMin - rPrev) < err) break;
  }

  cout << rMin << endl;
  return 0;
}



Measured memory_bytes: 256
// ITP1_9_A:   Finding a Word
// 2017.7.27

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

char *gets(char *s);

int strCaseCmp(char *s1, char *s2)
{
//	printf("s1:len %d, %s, s2:len %d, %s\n", strlen(s1), s1, strlen(s2), s2);
	while (*s1 && *s2 && tolower(*s1) == tolower(*s2)) s1++, s2++;
	if (*s1 == 0 && *s2 == 0) return 0;
	return 1;
}

int main()
{
	char W[20], T[1010];
	char *p0, *p1, c;
	int cnt;

	gets(W);
	cnt = 0;
	while (1) {
		gets(T);
		if (!strcmp(T, "END_OF_TEXT")) break;
		p0 = T;
		while (*p0) {
			while (isspace(*p0)) p0++;
			if (*p0) {
				p1 = p0;
				while (*p1 && !isspace(*p1)) p1++;
				c = *p1, *p1 = 0;
				if (!strCaseCmp(W, p0)) cnt++;
				*p1 = c;
				p0 = p1;
			}
		}
	}
	printf("%d\n", cnt);
	return 0;
}

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

int main() {
  int n, b, f, r, v;
  int a[4][3][10] = {0};
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    a[b-1][f-1][r-1] += v;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << ' ' << a[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) cout << "####################" << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=998244353;
const ll ms=2e5+5;
const ll inf=1e17;

int dp[401][401];



int main()
{
    idfc;

    int n,x,y;
    cin>>n>>x>>y;
    int i,j;
    int lim=400;
    for(i=0;i<=lim;i++)
    {
        for(j=0;j<=lim;j++)
        {
            dp[i][j]=modo;
        }
    }
    dp[0][0]=0;
    int a,b,c;

    while(n--)
    {
        cin>>a>>b>>c;

        for(i=lim;i>=0;i--)
        {
            for(j=lim;j>=0;j--)
            {
                if(dp[i][j]<modo)
                {
                    dp[i+a][j+b]=min(dp[i+a][j+b],dp[i][j]+c);
                }
            }
        }
    }

    a=x;
    b=y;
    int ans=modo;
    while(a<=lim&&b<=lim)
    {
        ans=min(dp[a][b],ans);
        a+=x;
        b+=y;
    }
    if(ans==modo)cout<<-1;
    else cout<<ans;


    return 0;
}

Measured memory_bytes: 4260
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll a=0,b=0,ans=0,m=0;
    for(int i=0;i<n;i++) {
        string s;
        cin>>s;
        
        for (int j=1;j<s.size();j++){
            if(s[j-1]=='A' && s[j]=='B') ans++;
        }
        if(s[0]=='B') b++;
        if(s[s.size()-1]=='A') a++;
        if(s[0]=='B' && s[s.size()-1]=='A') m++;
    }
    ll mm=min(a,b);
    if(mm==a && mm==b && mm==m && a!=0) ans+=mm-1;
    else ans += mm;
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	set<int> data;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		data.insert(tmp);
	}

	int ans = data.size() - ((data.size() & 1) ? 0 : 1);

	cout << ans << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 4992