akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x[5];
	rep(i, 5) cin >> x[i];
	rep(i, 5) {
		if (x[i] == 0) {
			cout << i + 1 << "\n";
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3568
#pragma GCC optimize ("Ofast", "unroll-loops", "loop-nest-optimize")

#include <bits/stdc++.h>

#define REP(i, n) REPI(i, 0, n)
#define REP1(i, n) REPI(i, 1, n)
#define REPI(i, init, n) for(int i = init; i < n; i++)
#define MS(arr, val) memset(arr, val, sizeof(arr))
#define SZ(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
#define EB emplace_back
#define UB upper_bound
#define LB lower_bound
#define FS first
#define SC second

#ifdef __WIN32__
inline size_t fread_unlocked(void *_buf, int _sz, int _cnt, FILE *_stream)
{
	return fread(_buf, _sz, _cnt, _stream);
}//fread_unlocked
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
//typedef pair<int, int> P;

char buf[100000];

inline char gc()
{
	static char *st = buf, *ed = buf;

	if (st >= ed)
	{
		st = buf;
		ed = st + fread_unlocked(buf, 1, sizeof(buf), stdin);

		if (st == ed) return EOF;
	}//if

	return *(st++);
}//gc

template<class T>
inline bool rit(T &_a)
{
	char _c = gc();
	bool neg = false;
	for (; _c < '0' || _c > '9'; _c = gc())
	{
		if (_c == EOF) return false;
		if (_c == '-') neg = true;
	}//for

	for (_a = 0; _c >= '0' && _c <= '9'; _c = gc())
		_a = _a * 10 + _c - '0';

	if (neg) _a = -_a;

	return true;
}//rit

template<class S, class ...T>
inline bool rit(S &_a, T&... _b)
{
	if (!rit(_a)) return false;
	return rit(_b...);
}//rit

//============================================================================//

const int MAX_N = 0 + 10;
//const int INF8 = 0x3f;
//const int INF32 = 0x3f3f3f3f;
//const int MOD = 1e9 + 7;
//const int MOD = 46337; //maximum prime int for multiplying
//const LL MOD = 2999999929; //maximum prime LL for multiplying
//const LL INF64 = 0x3f3f3f3f3f3f3f3f;
//const DB PI = acos(-1);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int a[3];
	
	rit(a[0], a[1], a[2]);
	sort(a, a + 3);
	
	if (a[0] != a[2] && (a[0] == a[1] || a[1] == a[2])) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}//main


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve(){
	ll n, k;
	cin >> n >> k;
	n %= k;
	cout << min(n, k - n);
}

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

	solve();
    
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

#define H_MAX 2000
#define W_MAX 2000

int main(void){
	int i, j, k;

	int h, w;
	scanf("%d%d", &h, &w);

	char sym;
	int board[H_MAX][W_MAX] = {};
	for(i = 0; i < h; i++){
		for(j = 0; j < w; j++){
			scanf(" %c", &sym);
			if(sym == '#') board[i][j] = 1;
		}
	}

	int board_value[H_MAX][W_MAX] = {}, cnt;
	for(i = 0; i < h; i++){
		cnt = 0;
		for(j = 0; j < w; j++){
			if(board[i][j] == 0){
				board_value[i][j] += cnt++;
			}else{
				cnt = 0;
			}
		}
	}
	for(i = 0; i < h; i++){
		cnt = 0;
		for(j = w-1; j >= 0; j--){
			if(board[i][j] == 0){
				board_value[i][j] += cnt++;
			}else{
				cnt = 0;
			}
		}
	}
	for(i = 0; i < w; i++){
		cnt = 0;
		for(j = 0; j < h; j++){
			if(board[j][i] == 0){
				board_value[j][i] += cnt++;
			}else{
				cnt = 0;
			}
		}
	}
	for(i = 0; i < w; i++){
		cnt = 0;
		for(j = h-1; j >= 0; j--){
			if(board[j][i] == 0){
				board_value[j][i] += cnt++;
			}else{
				cnt = 0;
			}
		}
	}

	int max = 0;
	for(i = 0; i < h; i++){
		for(j = 0; j < w; j++){
			if(board_value[i][j]+1 > max) max = board_value[i][j]+1;
		}
	}

	printf("%d\n", max);

	return 0;
}


Measured memory_bytes: 31360
dic = {'North' : 0, 'East' : 1, 'South' : -2, 'West' : -1}

vv = []
while True:
    n = int( raw_input() )
    if n == 0: break
    cur = 1
    adj = [2, 4, 5, 3]
    ans = 1
    for i in range(n):
        cmd = raw_input()
        if cmd in ['North', 'East', 'South', 'West']:
            cur, adj[ dic[cmd] ], adj[ dic[cmd] + 2 ] = adj[ dic[cmd] ] , 7-cur, cur
        elif cmd == 'Left':
            adj = adj[1:] + adj[:1]
        elif cmd == 'Right':
            adj = adj[-1:] + adj[:-1]
        ans += cur
    vv.append(ans)
for v in vv:
    print v

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    string s;
    int count=0;
    cin>>s;
    REP(i,0,s.size()) if(s[i]=='p') count++;
    cout<<s.size()/2-count<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
int gcd(int a, int b)
{
  while (1) {
    if (b == 0) {
      return a;
    }
    int temp = b;
    b = a % b;
    a = temp;
  }
}

int lcd(int a, int b)
{
  return a / gcd(a, b) * b;
}

int main()
{
  int a, b;
  while (std::cin >> a >> b) {
    std::cout << gcd(a, b) << " " << lcd(a, b) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void) {

  int a,b;
  scanf("%d %d", &a, &b);
  if (a+b == 15) {
    printf("+\n");
  } else if (a*b == 15) {
    printf("*\n");
  } else {
    printf("x\n");
  }

  return 0;
}

Measured memory_bytes: 128
// ITP1_11_A:   Dice I
// 2018.3.9

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

struct DICE{
  int top;
  int south;
  int east;
  int west;
  int north;
  int bottom;
};

void Roll_to_East(struct DICE *p)
{
  int temp[4];
  temp[0] = p->top;
  temp[1] = p->east;
  temp[2] = p->bottom;
  temp[3] = p->west;
  
  p->top = temp[3];
  p->east = temp[0];
  p->bottom = temp[1];
  p->west = temp[2];
}

void Roll_to_West(struct DICE *p)
{
  int temp[4];
  temp[0] = p->top;
  temp[1] = p->east;
  temp[2] = p->bottom;
  temp[3] = p->west;
  
  p->top = temp[1];
  p->east = temp[2];
  p->bottom = temp[3];
  p->west = temp[0];
}

void Roll_to_North(struct DICE *p)
{
  int temp[4];
  temp[1] = p->top;
  temp[0] = p->north;
  temp[2] = p->bottom;
  temp[3] = p->south;
  
  p->top = temp[3];
  p->north = temp[1];
  p->bottom = temp[0];
	p->south = temp[2];
}

void Roll_to_South(struct DICE *p)
{
  int temp[4];
  temp[1] = p->top;
  temp[0] = p->north;
  temp[2] = p->bottom;
  temp[3] = p->south;
  
  p->top = temp[0];
  p->north = temp[2];
  p->bottom = temp[3];
  p->south = temp[1];
}
int
main(void){

  char instruction[100] = {0};
  struct DICE dice;
  
  scanf("%d %d %d %d %d %d\n",
	&dice.top,
	&dice.south,
	&dice.east,
	&dice.west,
	&dice.north,
	&dice.bottom
	);
  
  scanf("%s\n", instruction);

  int i;
  
  for( i = 0; i < strlen(instruction); i++)
    {
      switch(instruction[i])
	{
	case 'E':
	  Roll_to_East(&dice);
	  break;
	case 'W':
	  Roll_to_West(&dice);
	  break;
	case 'N':
	  Roll_to_North(&dice);
	  break;
	case 'S':
	  Roll_to_South(&dice);
	  break;
	}
    }
  printf("%d\n", dice.top);
  return 0;
}



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






int main() {
  int N;cin>>N;
  map<string,int> mp;
  
  rep(i,N){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
    
  }
  ll ans=0;
  
  for(auto& p :mp){
    ll t=p.second;
    ans+=t*(t-1)/2;
  }
  
  cout<<ans<<endl;
}

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

const int mod = 1e9 + 7, maxn = 200000;
int color[maxn],weight[maxn],mini[maxn],fac[maxn+1],inv[maxn+1];
map<int,int> M[maxn];
struct UF{
	int p[maxn],sz[maxn];
	void init(int n){
		for(int i=0;i<n;i++)
			sz[p[i]=i]=1;
	}
	int F(int x){return x==p[x]?x:p[x]=F(p[x]);}
	bool U(int x,int y){
		x=F(x),y=F(y);
		if(x==y)	return false;
		if(sz[x]>sz[y])
			swap(x,y);
		p[x]=y;
		sz[y]+=sz[x];
		return true;
	}
}D;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,x,y;
	cin>>n>>x>>y;
	fac[0]=inv[0]=inv[1]=fac[1]=1;
	for(int i=2;i<=n;i++)
		fac[i]=1LL*fac[i-1]*i%mod,inv[i]=mod-1LL*mod/i*inv[mod%i]%mod;
	for(int i=2;i<=n;i++)
		inv[i]=1LL*inv[i-1]*inv[i]%mod;
	for(int i=0;i<n;i++)
		mini[i]=1e9;
	for(int i=0;i<n;i++){
		cin>>color[i]>>weight[i];
		color[i]--;
		int c=color[i];
		if(mini[c]==1e9||weight[mini[c]]>weight[i])
			mini[c]=i;
	}
	D.init(n);
	for(int i=0;i<n;i++){
		int c=color[i];
		if(weight[mini[c]]+weight[i]<=x)
		D.U(i,mini[c]);
	}
	sort(mini,mini+n,[&](int a,int b){
		if(a==1e9)	return false;
		else if(b==1e9)	return true;
		return weight[a]<weight[b];
	});
	if(mini[1]!=1e9){
		int m0=mini[0],m1=mini[1];
		for(int i=0;i<n;i++){
			if(color[i]!=color[m0]&&weight[i]+weight[m0]<=y)
				D.U(i,m0);
			if(color[i]!=color[m1]&&weight[i]+weight[m1]<=y)
				D.U(i,m1);
		}
	}
	long long int ans=1;
	for(int i=0;i<n;i++)
		M[D.F(i)][color[i]]++;
	for(int i=0;i<n;i++)
		if(i==D.F(i)){
			ans = ans*fac[D.sz[i]]%mod;
			for(auto it:M[i])
				ans = ans*inv[it.second]%mod;
		}
	cout<<ans<<endl;
}



Measured memory_bytes: 24448
#include <iostream>
#include <vector>

using namespace std;

int MOD = 1000000007;

int main(){
  int N, M;
  cin >> N >> M;
  int a[M];
  int i;
  for(i=0; i<M; i++)
    cin >> a[i];

  //i番目の階段を踏んでもいいとき，ok[i]=true
  vector<int> ok(N+1, true);

  for(i=0; i<M; i++)
    ok[ a[i] ] = false;

  //  for(i=0; i<N; i++)
  //cout << ok[i] << endl;
  
  long long int dp[N+1] = {0};
  dp[0] = 1;
  //now : 今いる階段
  //next : 一段上の階段， nenext : 二段上の階段
  int now, next, nenext;
  for(now=0; now<N-1; now++){
    //cout << now << "段目" << endl;
    next = now+1;
    nenext = next+1;
    //nowから一段登れるなら
    if(ok[next] == true){
      //cout << "一段上OK" << endl;
      dp[next] += dp[now];
      dp[next] %= MOD;
    }
    //nowから二段登れるなら
    if(ok[nenext] == true){
      //cout << "二段上OK" << endl;
      dp[nenext] += dp[now];
      dp[nenext] %= MOD;
    }
  }
  //上のループではN-1段目からN段目に上がることは除外している
  dp[N] += dp[N-1];
  dp[N] %= MOD;

  cout << dp[N] << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];

int main()
{
	int q, i, t, f;

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &t, &f);
		for (i = 1; i <= 6; i++) {
			if (assign[i] == t) t = i;
			if (assign[i] == f) f = i;
		}
		printf("%d\n", assign[face[t][f][3]]);
	}
	return 0;
}



Measured memory_bytes: 2108
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

constexpr int mod = 1000000007;

int main()
{
    int N;
    scanf("%d\n", &N);
    int S;
    {
        char temp[5001];
        scanf("%[^\n]\n", temp);
        S = strlen(temp);
    }

    vector<int> row(N + 1);
    vector<int> row_old(N + 1); // table[0]
    row_old[0] = 1;
    for (int n = 1; n < N; ++n){
        for (int s = 0; s <= n; ++s){
            row[s] = row_old[max(0, s - 1)];
            row[s] += (row_old[s + 1] * 2) % mod;
            row[s] %= mod;
        }
        row_old.swap(row);
    }
    printf("%d\n", (row_old[S - 1] + (row_old[S + 1] * 2) % mod) % mod);
}


Measured memory_bytes: 256
class Dice:
	# Label: 1=Up, 2=South, 3=East, 4=West, 5=North, 6=Down
	def __init__(self, nums):
		self.cU = nums[0]
		self.cS = nums[1]
		self.cE = nums[2]
		self.cW = nums[3]
		self.cN = nums[4]
		self.cD = nums[5]
	def goN(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pS,pD,pU,pN
	def goE(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pW,pU,pD,pE
	def goW(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pE,pD,pU,pW
	def goS(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pN,pU,pD,pS
	def toU(self, num):
		if self.cD == num:
			for _ in range(2): self.goN()
		elif self.cN == num: self.goS()
		elif self.cE == num: self.goW()
		elif self.cW == num: self.goE()
		elif self.cS == num: self.goN()
	def right(self, num):
		if self.cN == num: return self.cW
		elif self.cE == num: return self.cN
		elif self.cW == num: return self.cS
		elif self.cS == num: return self.cE
		else: raise # ????????????
nums = [int(i) for i in input().split(' ')]
di = Dice(nums)
q = int(input())
for _ in range(q):
	u,f = map(int, tuple(input().split(' ')))
	di.toU(u)
	print(di.right(f))


Measured memory_bytes: 7772
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
	out << "{" << p.first << "," << p.second << "}";
	return out;
}

static const int MAX = 200000;
static const int INF = INT_MAX;
int n, a[MAX], l[MAX / 2 + 2], r[MAX / 2 + 2];
ll inversion = 0;

void merge(int arr[], int left, int right) {
	int mid = (left + right) / 2;
	int n1 = mid - left, n2 = right - mid;
	rep(i,0,n1)
	{
		l[i] = a[left + i];
	}
	rep(j,0,n2)
	{
		r[j] = a[mid + j];
	}
	l[n1] = r[n2] = INF;
	int i = 0, j = 0;
	rep(k,0,right - left)
	{
		if (l[i] <= r[j]) {
			a[left + k] = l[i++];
		} else {
			a[left + k] = r[j++];
			//Lに残った要素の数
			//==r[j]より大きい数の個数
			//==r[j]より左にあるのに大きい(反転している)数
			//各jで反転数(n1-i)を追加
			inversion += n1 - i;
		}
	}
}

void mergeSort(int arr[], int left, int right) {
	int mid = (left + right) / 2;
	if (left + 1 < right) {
		mergeSort(arr, left, mid);
		mergeSort(arr, mid, right);
		merge(arr, left, right);
	}
}

void solve() {
	scanf("%d", &n);
	rep(i,0,n)
	{
		scanf("%d", &a[i]);
	}
	mergeSort(a, 0, n);
	printf("%lld\n", inversion);
}

void printTestCase() {
	int n = 200000;
	int ins = 0;
	printf("%d\n", n);
	rep(i,0,n)
	{
		if (ins++ > 0) {
			printf(" ");
		}
		printf("%d", n - i);
	}
}

int main() {
	solve();
//	printTestCase();
	return 0;
}



Measured memory_bytes: 4740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        int[] cost = new int[] { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
        string[] line = Console.ReadLine().Split(' ');
        int n = int.Parse(line[0]);
        int m = int.Parse(line[1]);

        int[] values = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[] costs = values.Select(i => cost[i]).ToArray();

        int min = costs.Min();
        int mDig = n / min;

        int[] dp = new int[n + 1];
        dp[0] = 0;

        for (int i = 1; i < dp.Length; i++)
        {
            dp[i] = costs.Select(x => (i >= x) ? (dp[i - x] + 1) : int.MinValue).Max();
        }

        int dig = dp[n];
        string ans = "";
        for (int i = dig - 1; i >= 0; i--)
        {
            int v = values.Where(x => (n - cost[x] >= 0) && dp[n - cost[x]] == i).Max();
            n -= cost[v];
            ans += v;
        }

        Console.WriteLine(ans);
        Console.ReadLine();
    }
}


Measured memory_bytes: 27216
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;
    string f = "";
    string t = "";

    if(s.size() % 2 == 0) {
        for (int i = 0; i < s.size(); i++) {
            if(i < s.size()/2){ 
                f += s[i];
            }
            else {
                t += s[i];
            }
        }
    }
    else {
        // cout << 1 << endl;
        for (int i = 0; i < s.size(); i++) {
            if(s.size()/2 == i){
                continue;
            }
            if(i < s.size()/2){ 
                f += s[i];
            }
            else {
                t += s[i];
            }
        }
    }

    int count = 0;
    for(int i = 0; i < s.size()/2; i++) {
        if(f[i] != t[t.size()-i-1]) {
            count++;
        }
    }

cout << count << endl;
}

Measured memory_bytes: 256
def resolve():
    def main():
        import sys
        n,x=map(int, input().split())
        l=list(map(int, input().split()))
        l.sort()
        cnt=0
        for i in range(n):
            if l[i]<=x:
                x-=l[i]
                cnt+=1
            else:
                return i
        if cnt==n and x>0:
            cnt-=1
        return cnt
    print(main())
resolve()

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()
print(N**3)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pair<int,int>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 1e2+10;

int main(int argc,const char** argv){

	fastio;

	int a,b,c;

	cin >> a >> b >> c;

	cout << c << ' ' << a << ' ' << b << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005

int main(){

    int maxi = 196471;//ミレニアムまでの最大の日数
    int n,y,m,d;
    cin >> n;

    REP(i,n){
        cin >> y >> m >> d;
        int sum = 0;
        //年単位での日数の計算
        for(int i = 1;i < y;i++){
            if(i % 3 == 0){
                sum += 200;
            }else{
                sum += 195;
            }
        }

        

        //月単位での日数の計算
        for(int i = 1;i < m;i++){
            if(y % 3 == 0 || i % 2 == 1){
                sum += 20;
            }else{
                sum += 19;
            }
        }

        //日の追加
        sum += d;
        cout << maxi - sum << endl;
    }


    return 0;
}


Measured memory_bytes: 3064
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
pa,ma=-10**10,-10**10
pi,mi=10**10,10**10
for i in range(N):
    x,y=map(int,input().split())
    s=x+y
    if s>pa:
        pa=s
    if s<pi:
        pi=s
    s=x-y
    if s>ma:
        ma=s
    if s<mi:
        mi=s
print(max(pa-pi,ma-mi))

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[6];
    for(int i=1;i<=5;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=5;i++)
    {
        if(a[i]== 0 ) cout<<i<<endl;
    }

}


Measured memory_bytes: 3636
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
x = int(input())
print(1 - x)

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main()
{
    int a,b,c,d,e,f,g,h,i,j;
    vector<int>v;
    vector<pair<int,int> >v1;
    map<int,int>m;
    map<int,int>::iterator it;
    cin>>a>>b;
    int cnt=0;
    c=0;
    for(i=1; i<=a; i++)
    {
            cin>>d;
        c+=(d+b);
        c-=max(d,cnt);
        cnt=d+b;
    }
    cout<<c<<endl;
    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <malloc.h>
#include <cstdlib>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tr_policy.hpp>
//using namespace __gnu_pbds;

#define ll				long long
#define double			long double
#define pb 				push_back
#define endl 			'\n'
#define F				first
#define S				second
#define mod				(int)1000000007
#define mp              make_pair
#define ios 			ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inf				1e18
#define mem(a,x)		for(int i=0;i<(int)(sizeof(a)/sizeof(a[0]));i++) a[i] = x;
#define trace(a)		cout<<(#a)<<" --> "<<a<<endl
#define trace2(a,b)		{trace(a);trace(b);cout<<"------------------\n";}
#define trace3(a,b,c)	{trace(a);trace(b);trace(c);cout<<"------------------\n";}
#define trace4(a,b,c,d) {trace(a);trace(b);trace(c);trace(d);cout<<"------------------\n";}
#define M_PI           	3.14159265358979323846
#define T				pair<int,int>
//#define ordered_set 	tr<T, null_type,less<T>, rb_tr_tag,tr_order_statistics_node_update>


void run(){
	double r;
	cin>>r;
	cout<<(2*M_PI*r);
}

signed main(){
	ios;
//	int t;
//	cin>>t;
//	for(int i=1;i<=t;i++)
//		cout<<"Case #"<<i<<": ", run();
	run();
	return 0;
}


Measured memory_bytes: 3804
a = [0]* 1000001
m = 0
input()
for x in map(int, input().split()):
  m = max(m, x)
  a[x] += 1
m += 1
for i in range(1, m):
  if a[i]:
    for j in range(i + i, m, i):
      a[j] = 0
print(a[:m].count(1))


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    V<int> x(n), y(n), h(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> h[i];
    }

    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            int H = -1;
            for(int k = 0; k < n; k++){
                if(h[k] > 0){
                    int tmp = h[k] + abs(x[k] - i) + abs(y[k] - j);
                    if(H == -1){
                        H = tmp;
                    }else{
                        if(H != tmp){
                            H = -2;
                            break;
                        }
                    }
                }
            }
            if(H == -2) continue;

            for(int k = 0; k < n; k++){
                if(h[k] == 0){
                    int tmp = abs(x[k] - i) + abs(y[k] - j);
                    if(H > tmp){
                        H = -2;
                        break;
                    }
                }
            }
            if(H == -2) continue;

            cout << i << " " << j << " " << H << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  string t = "CODEFESTIVAL2016";
  ll c = 0;
  re(i, s.size()){
    if(s[i]!=t[i]) c++;
  }
  std::cout << c << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[],int N){ 
 int i;
 for(i=0;i<N;i++){
  if(i>0)printf(" ");
  printf("%d",A[i]);
  }
 printf("\n");
}

void insertionSort(int A[],int N){
 int i,j,v;
 for(i=1;i<N;i++){
  v=A[i];
  j=i-1;
  while(j>=0&&A[j]>v){
   A[j+1]=A[j];
   j--;
  }
 A[j+1]=v;
 trace(A,N);
}
}

int main(){
 int N,i,j;
 int A[100];
 
 scanf("%d",&N);
 for(i=0;i<N;i++)scanf("%d",&A[i]);
 
 trace(A,N);
 insertionSort(A,N);
 
 return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n[3];
    cin >> n[0] >> n[1] >> n[2];
    sort(n,n+3);
    cout<< n[0] << ' ' << n[1]<<' '<<n[2] <<endl;
    return 0;
}

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

int main() {
  int n; cin>>n;
  int res = n;
  for(int i=0; i<=n; i++) {
    int cc=0,t=i;
    while(t>0) {
      cc += t%6;
      t /= 6;
    }
    t = n-i;
    while(t>0) {
      cc += t%9;
      t /= 9;
    }
    if(res>cc) res = cc;
  }
  cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    string A, B;  cin >> A >> B;

    if (A.size() > B.size()) print("GREATER");
    else if (A.size() < B.size()) print("LESS");
    else {
        bool flag = true;
        rep(i, A.size()) {
            if (A[i] > B[i]) {
                print("GREATER");
                flag = false;
                break;
            } else if (A[i] < B[i]) {
                print("LESS");
                flag = false;
                break;
            }
        }
        if (flag) print("EQUAL");
    }
}




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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int h,w,k;
ll dp[100+1][10];

int main() {
    cin>>h>>w>>k;
    memset(dp,0,sizeof(dp));
    dp[0][1]=1;
    map<int,int> d;
    d[-2]=0;
    d[-1]=1;
    d[0]=1;
    d[1]=2;
    d[2]=3;
    d[3]=5;
    d[4]=8;
    d[5]=13;
    d[6]=21;
    if (w==1){
        cout<<1<<endl;
        return 0;
    }
    for (int i=1;i<h+1;i++){
        for (int j=1;j<w+1;j++){
                ll ans1=dp[i-1][j]*d[j-2]*d[w-j-1];
                ll ans2=dp[i-1][j-1]*d[j-3]*d[w-j-1];
                ll ans3=dp[i-1][j+1]*d[j-2]*d[w-j-2];
                dp[i][j]=(ans1+ans2+ans3)%MOD;          
        }
    }
    cout<<dp[h][k]<<endl;
    return 0;
}


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

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

  int m = 0;
  int sum = 0;
  for (int i = 0; i < M; i++){
    cin >> m;
    sum += m;
  }

  cout << (N -sum < 0 ? -1 : N - sum) << endl;
}

Measured memory_bytes: 3632
import sys
from collections import deque
import copy
from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def calc_min_yen(Q, H, S, D, N):
    Q_ = Q * 4
    H_ = H * 2
    min_yen_1l = min([Q_, H_, S])
    if N > 2:
        use_2l = (N/2) * D  + N % 2 * min_yen_1l
    else:
        use_2l =  2**63-1
    return min(use_2l , N * min_yen_1l)


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);

    input_raw = read_func().strip().split()
    [Q, H, S, D] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2]), int(input_raw[3])]
    input_raw = read_func().strip().split()
    [N] =[int(input_raw[0])]

    print calc_min_yen(Q, H, S, D, N)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
#define INF 1000000000000000000
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
signed main()
{
	fast
	int n;
	cin>>n;
	vi dp(n+1),v(n+1);
	f(i,1,n+1)
	{
		int x;
		cin>>x;
		v[i]=x;
		if(i==1) continue;
		if(i==2)
		{
			dp[i]=abs(x-v[i-1]);
			continue;
		}
		dp[i]=min(abs(x-v[i-1])+dp[i-1],abs(x-v[i-2])+dp[i-2]);
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4764
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int A, B, C, D, E, F, swp = -1, sp = -1;

  long double pp = -1e+9;

  std::cin >> A >> B >> C >> D >> E >> F;

  for (int i = 0; ; i ++) {
    int w = i * A * 100;

    if (w > F)
      break;

    for (int j = 0; ; j ++) {
      w = i * A * 100 + j * B * 100;

      if (w > F)
        break;
      
      int S = w * E / 100;

      if (w > F)
        continue;

      for (int k = 0; ; k ++) {
        int s = k * C;

        if (s > S)
          break;
        
        for (int l = 0; ; l ++) {
          s = k * C + l * D;

          if (s > S)
            break;

          int sw = s + w;

          if (sw == 0 || sw > F)
            break;

          long double p = 1.0L * s / sw;

          if (p > pp) {
            pp  = p;
            swp = sw;
            sp  = s;
          }
        }
      }
    }
  }

  std::cout << swp << ' ' << sp << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    string s;
    cin >> s;
    int tmp=0, ans = 0;
    rep(i, s.size()){
        if(s[i]=='R'){
            tmp++;
        }else{
            tmp=0;
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  map<char,int> ans;
  for(int i=0;i<s.size();i++)ans[s.at(i)]++;
  bool ok=true;
  for(auto x:ans){
    if(x.second%2!=0){
      ok=false;
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))

a = [0] * n
a[0] = b[0]
for i in range(1, n):
    a[i] = b[i-1]
    if a[i - 1] > b[i - 1]:
        a[i - 1] = b[i - 1]

print(sum(a))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(void){
	long long s,c,ans=0;
	cin >> s >> c;
	if(s<c/2){
		ans+=s;
		c=c-(s*2);
		if(c>=4)ans+=c/4;
	}
	else if(c/2<=s) ans+=c/2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m,ans=-1;
const ll MOD = 1000000007;
void Main(){
    ll a,b;cin>>n>>a>>b;
    if((a+b)%2==0) cout<<(abs(a-b))/2<<endl;
    else {
        ll ans1=min(max(a-1,n-a),max(b-1,n-b));
        ll ans2=a+(b-a)/2;
        ll ans3=(n-b+1)+(n-(a+n-b+1))/2;
        cout<<min(ans1,min(ans2,ans3))<<endl;
    }
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;

int a[100050],b[100050],c[100050];
int hah(int);

int main() {
	long long  am=-1,bm=-1,i,j,k,s=0,hp,n,sc;
	cin>>n>>hp;
	for(i=1;i<=n;i++) {
	cin>>a[i];
	if(a[i]>am)
	   am=a[i];
    cin>>b[i];
	}
	k=0;
	for(i=1;i<=n;i++) {
       if(b[i]>am) {
         k++;
         c[k]=b[i];
	   }
	}
	sort(c+1,c+1+k);
	for(i=k;i>=1;i--) {
	    s+=c[i];
	    if(s>=hp) {
	    cout<<k-i+1;
		return 0;
		}
	  }
    sc=k;
    if(am==1) sc+=hp-s;
    else if(am==2&&hp>10000) {
			    if((hp-s)&1)//???
			       hp++;
	            sc+=(hp-s)/2;
			}
         else 
            while(s<hp) {
        	    s+=am;
        	    sc++;
            }
    cout<<sc;
    return 0;
}

Measured memory_bytes: 1408
N,M,X = map(int, input().split())
A = list(map(int, input().split()))

Y = X
S1 = []
while Y < N:
    Y += 1
    S1.append(Y)

Z = X
S2 = []
while Z > 0:
    Z -= 1
    S2.append(Z)

risuto = []
risuto.append(len(set(A) & set(S1)))
risuto.append(len(set(A) & set(S2)))
print(min(risuto))


Measured memory_bytes: 3316
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, s[100]; int sum = 0; int cnt = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &s[i]);
    sum += s[i];
    if(s[i] % 10 == 0){
      cnt++;
    }
  }
  
  int m = 101;
  if(cnt == n){
    sum = 0;
  }
  else{
  while(sum > 0){
    if(sum % 10 != 0){
      break;
    }
    else{
      for(int i = 0; i < n; i++){
        if(s[i] % 10 != 0 && m > s[i]){
          m = s[i];
        }
      }
      if(m != 101){
        sum -= m;
      }
    }
  }
  }
  
  printf("%d\n", sum);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD=1e9+7;

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}
template<typename T> T extgcd(T a,T b,T &x,T &y){
    T d=a;
    if (b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    } else x=1,y=0;
    return d;
}
template<typename T> int digit(T n){
    string cnt=to_string(n);
    return cnt.size();
}

template<typename T> bool is_prime(T n){
    for (T i=2;i*i<=n;++i)
        if (n%i==0) return false;
    return 1<n;
}
template<typename T> vector<T> divisor(T n){
    vector<T> res;
    for (T i=1;i*i<=n;++i) if (n%i==0){
        res.emplace_back(i);
        if (i!=n/i) res.emplace_back(n/i);
    }
    return res;
}
template<typename T> map<T,int> prime_factor(T n){
    map<T,int> res;
    for (T i=2;i*i<=n;++i){
        while (n%i==0){
            ++res[i]; n/=i;
        }
    }
    if (n!=1) res[n]=1;
    return res;
}
vector<bool> prime_table(int n){
    vector<bool> prime(n+1,true);
    prime[0]=prime[1]=false;
    for (int i=2;i<=n;++i) if (prime[i]){
        for (int j=i+i;j<=n;j+=i) prime[j]=false;
    }
    return prime;
}
vector<int> primes(int n){
    vector<int> res;
    vector<bool> pt=prime_table(n);
    for (int i=2;i<=n;++i) if (pt[i]){
        res.emplace_back(i);
    }
    return res;
}

long long modpow(long long x,long long n,long long mod){
    long long res=1;
    while (n>0){
        if (n&1LL) res=res*x%mod;
        x=x*x%mod; n>>=1LL;
    }
    return res;
}
long long modinv(long long x,long long p){
    return modpow(x,p-2,p);
}

template<typename T>
T eular_phi(T n){
    T res=n;
    for (T i=2;i*i<=n;++i) if (n%i==0){
        res-=res/i;
        while (n%i==0) n/=i;
    }
    if (n!=1) res-=res/n;
    return res;
}
vector<int> eular_phi_table(int n){
    vector<int> eular(n+1);
    iota(eular.begin(),eular.end(),0);
    for (int i=2;i<=n;++i) if (eular[i]==i){
        for (int j=i;j<=n;j+=i) eular[j]-=eular[j]/i;
    }
    return eular;
};


// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_A

void NTL_1_A(){
    int n; cin >> n;
    map<int,int> ans=prime_factor(n);
    cout << n << ':';
    for (auto p:ans){
        for (int i=0;i<p.second;++i){
            cout << ' ' << p.first;
        }
    }
    cout << '\n';
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_B

void NTL_1_B(){
    ll m,n; cin >> m >> n;
    cout << modpow(m,n,MOD) << '\n';
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_C

void NTL_1_C(){
    int n; cin >> n;
    ll ans=1;
    for (;n--;){
        ll a; cin >> a;
        ans=lcm(ans,a);
    }
    cout << ans << '\n';
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_D

void NTL_1_D(){
    int n; cin >> n;
    cout << eular_phi(n) << '\n';
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_E

void NTL_1_E(){
    int a,b,x,y; cin >> a >> b;
    extgcd(a,b,x,y);
    cout << x << ' ' << y << '\n';
}


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


Measured memory_bytes: 3216
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 55555
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    vector<bool>IsPrime(MAX+1,true);
    vector<int>Prime(MAX+1,0); //Primearray
    int Primecounter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(IsPrime[i]){
            for(int j = 2;i*j<MAX;j++)
                IsPrime[i*j] = false;//素数ならPrimearrayに格納してその倍数を全てfalseに
            Prime[Primecounter] = i;
            Primecounter++;
        }
    }
    int n; cin >> n;
    vector<int>ans;
    rep(i,Primecounter)if(Prime[i]%5 ==1)ans.push_back(Prime[i]);
    rep(i,n){
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 512
// Aizu Vol-10 1027: A Piece of Cake
// 2017.8.17 bal4u@uu

#include <stdio.h>

int main()
{
	int K, c, s, i;
	while (scanf("%d", &K) && K) {
		for (s = 0, i = K*(K-1)/2; i > 0; i--) scanf("%d", &c), s += c;
		printf("%d\n", s / (K - 1));
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main()
{
  int a,b,d,r;
  double f;
  scanf("%d%d",&a,&b);

  d=a/b;
  r=a%b;
  f=(double)a/b;

  printf("%d %d %f\n",d,r,f);

  return 0;

}

Measured memory_bytes: 636
using System;
using System.Collections.Generic;
using System.Linq;
namespace CADDi2018_C{
    class P{
        static void Main(string[] args){
            var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var n = input[0];
            var p = input[1];

            var ans = 1L;
            if(n == 1){
                Console.WriteLine(p);
                return;
            }
            for(var i = 2;i <= (long)Math.Sqrt(p);i++){
                if(p % (long)Math.Pow(i,n) == 0){
                    ans = i;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

ma = max(A + B, A - B)
ma = max(ma , A*B)
print(ma)

Measured memory_bytes: 5148
function Main(input) {
	const [a, b] = input.split(" ").map(n => Number(n));
	let result = 0;
	if (6 <= a && a <= 12) {
		result = b / 2;
	} else if (12 < a) {
		result = b;
	}
	console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int count = 0;
		int result = 0;
		int result_count = 0;
		for(int i = 1; i <= x; i++) {
			count = 0;
			int now = i;
			while(now % 2 == 0) {
				now = now / 2;
				count++;
			}
			if(result_count <= count) {
				result_count = count;
				result = i;
			}
		}



		System.out.println(result);

	}
}


Measured memory_bytes: 23124
_,a,b=open(0)
a=list(map(int,a.split()))
b=list(map(int,b.split()))
c=sum(a)
for i in range(len(b)):
	if a[i]>b[i]:
		a[i]-=b[i]
	else:
		a[i+1]-=(b[i]-a[i])
		a[i+1]=0if a[i+1]<0else a[i+1]
		a[i]=0
print(c-sum(a))

Measured memory_bytes: 19112
n,y=map(int,input().split())
r=range
for i in r(n+1):
  for j in r(n-i+1):
      o=(n-i-j)
      if i*10+j*5+o==y/1000 and i+j<=n:
          print(i,j,o)
          exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]


ans = None
for i in range(1, 1<<10):
    Fk = [[F[j][k] * ((i >> k) & 1) for k in range(10)] for j in range(N)]
    Cs = [sum(Fk[i]) for i in range(N)]
    s = sum([P[i][Cs[i]] for i in range(N)])
    if ans is None or ans < s:
        ans = s
print(ans)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
inline bool check(int year){
    return year%400==0||(year%4==0&&year%100!=0);
}
int cnt(int year){
    int ans=0;
    for(int i=1;i<=year;i++)
        if(check(i))ans++;

    return ans;
}
int main(){
    int d[]={0,31,28,31,30,31,30,31,31,30,31,30};
    for(int i=1;i<12;i++)d[i]+=d[i-1];

    int y1,m1,d1,y2,m2,d2;
    while(cin>>y1>>m1>>d1>>y2>>m2>>d2){
        if(y1==-1||m1==-1||d1==-1)continue;
        if(y2==-1||m2==-1||d2==-1)continue;
        int a1=365*(y1-1)+cnt(m1>2?y1:y1-1)+d[m1-1]+d1;
        int a2=365*(y2-1)+cnt(m2>2?y2:y2-1)+d[m2-1]+d2;
        cout<<a2-a1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(void) {
  string s, t;
  cin >> s >> t;
  s += s;
  bool ans = false;
  rep(i, s.size()) {
    if (s.substr(i, t.size()) != t) continue;
    ans = true;
    break;
  }
  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#define N 100

int main(){
    int n, i, j, f=0, minj, ex, ans=0, A[N];
    scanf("%d",&n);
    
    for(i=0 ; i<n ; i++){
        scanf("%d",&A[i]);
    }
    
    for(i=0 ; i<n ; i++){
        f = 0;
        minj = i;
        
        for(j=i ; j<n ; j++){
            if(A[j] < A[minj]){
                minj = j;
                f = 1;
            } 
        }
        if(f == 1){
            ex = A[i];
            A[i] = A[minj];
            A[minj] = ex;
            ans++;
        }
    }
    for(i=0 ; i<n ; i++){
        if(i != 0) printf(" ");
        printf("%d",A[i]);
    } 
    printf("\n%d\n",ans);
    return 0;
}



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

int gcd(int x, int y) {
    if(y == 0)
        return x;
    else {
        return gcd(y, x % y);
    }
}

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

    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}


Measured memory_bytes: 3136