akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<functional>
#include<iostream>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<string.h>
#include<unordered_map>
#include<vector>
#include<limits.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define map unordered_map
int inf = LLONG_MAX / 3;

int h, w, a[550][550];
struct stru{ int a, b, c, d; };
queue<stru> q;
signed main() {
	cin >> h >> w;
	int cnt = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
			if (a[i][j] % 2)cnt++;
		}
	}
	bool b = false;
	int cnt2 = 0;
	int sum = 0;
	rep(i, h) {
		if (i % 2) {
			for (int j = w - 1; j >= 1; j--) {
				if (a[i][j] % 2) {
					if (b) {
						b = false;
						cnt2++;
					}
					else if (cnt != cnt2 * 2 + 1)b = true;
				}
				if (b)q.push({ i + 1,j + 1,i + 1,j });
			}
			if (a[i][0] % 2) {
				if (b) {
					b = false;
					cnt2++;
				}
				else if (cnt != cnt2 * 2 + 1)b = true;
			}
			if (b)q.push({ i + 1,1,i + 2,1 });
		}
		else {
			rep(j, w - 1) {
				if (a[i][j] % 2) {
					if (b) {
						b = false;
						cnt2++;
					}
					else if (cnt != cnt2 * 2 + 1)b = true;
				}
				if (b)q.push({ i + 1,j + 1,i + 1,j + 2 });
			}
			if (a[i][w - 1] % 2) {
				if (b) {
					b = false;
					cnt2++;
				}
				else if (cnt != cnt2 * 2 + 1)b = true;
			}
			if (b)q.push({ i + 1,w,i + 2,w });
		}
	}
	cout << q.size() << endl;
	while(!q.empty()) {
		stru str = q.front();
		q.pop();
		cout << str.a << " " << str.b << " " << str.c << " " << str.d << endl;
	}
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int x =1;
  for(int i=0; i<N; i++){
    if(x<K){
      x=x*2;
    }
    else{
      x=x+K;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 256
/**************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

***************************/

#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define MAXI 1000000007
#define mp make_pair
using namespace std;
/*long long int fib(long long int n) 
{ 
  
  long long int f[n+2];   // 1 extra to handle case, n = 0 
  long long int i; 
  f[0] = 0; 
  f[1] = 1; 
  
  for (i = 2; i <= n; i++) 
  { 
      f[i] = f[i-1] + f[i-2]; 
  } 
  
  return f[n]; 
}*/ 
int main()
{   ll v=0,h=0,d,m,n,cnt=0,j=0,l=0,y=0,t,k=0,sum=1,x=0,i,mask,min,r=1,adv,g=0,low,high,yeah=0;
    string s1,s2,s3;
    map<char,long long int>mp;
    vector<long long int> v1;
    vector<long long int> v2;
    set<char> sy;
    char c;
    long long pos=0,pred=0;
    long long MAX=1e9+7;
    i=0;
    cin>>d>>m>>n;
    if(d!=m&&d!=n){
        if(m==n){cout<<2;return 0;}
        else{cout<<3; return 0;}
    }
    else{
        if(m==n){cout<<1;return 0;}
        else{cout<<2;return 0;}
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int main(void)
{
	lli N; cin >> N;
	lli ans = 0;
	rep(i, 1, N + 1) {
		if (i % 3 != 0 && i % 5 != 0)ans += i;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
#define ub(v,n) upper_bound(v.begin(),v.end(),n)-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a);
		}
		b>>=1;
		a=(a*a);
	}
	return ans;
}//prefixsums
void frooty()
{
	l n;
	cin>>n;
	vector<l> v;
	for(l i=0;i<n;i++)
	{
		l a;
		cin>>a;
		v.pb(a);
	}
	l ans=1000;
	for(l i=0;i<n-1;i++)
	{
		if(v[i]<v[i+1])
		{
			ans+=(v[i+1]-v[i])*(ans/v[i]);
		}
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
	//cin>>q;
	while(q--)
	{
		frooty();
	}
}

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


int main()
{
  ll n,k,min;
  cin >> n >> k;

  while(abs(n-k)<n){
     if(n%k==0)
       {cout << 0; return 0;}
    else{
    	ll r = n%k;
      	k=abs(k-r);
      cout << k;
      return 0;
    }
    
     n=abs(n-k);
  }
  cout << n;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> d(N+1);
    for (int i=0; i<N; i++) cin >> d.at(i);
    sort(d.begin(), d.end()-1);
    d.at(N) = 0;
    int res=1;
    for (int i=0; i<N; i++) {
        if (d.at(i)<d.at(i+1)) res++;
    }
    cout << res << "\n";
}

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

int n, y, m, d;

void solve() {
  int sum = 0;

  while(y < 1000) {
    sum++;
    d++;
    if(y%3 && m%2 == 0 && d == 20) {
      d = 1;
      m++;
    }
    else if(d > 20) {
      d = 1;
      m++;
    }
    if(m > 10) {
      m = 1;
      y++;
    }
  }

  cout << sum << endl;
}

int main() {
  while(cin >> n) {
    for(int i = 0; i < n; ++i) {
      cin >> y >> m >> d;
      solve();
    }
  }
}



Measured memory_bytes: 3080
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int p = 0;
    for(int i = 0; i < n; i++) {
      if(s.charAt(i) == 'p') p++;
    }
    System.out.println(n / 2 - p);
  }
}

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

using i64 = int64_t;

int main(){
    i64 n;
    cin >> n;
    i64 mini = LLONG_MAX;
    for(int i=0;i<5;++i){
        i64 tmp;
        cin >> tmp;
        mini = min(mini, tmp);
    }

    cout << (n+mini-1)/mini + 4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}


int main(){


  ll N,ans=0;
  cin >> N;

  FOR(i,1,N+1){
    ll num = N/i;
    ans += ((num+1)*num/2)*i;
  }

  cout << ans << endl;
}




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

const long long MOD = 1000000007;
vector<vector<int>> T;
int N;
const ll MAXN = 100000;
ll dp[MAXN +1][2];

int dfs(int node,int color,int parent){
    // cerr <<"target =" << node << endl;
    if(dp[node][color] >= 0){
        return dp[node][color];
    }
    ll retVal = 1;
    for(int child:T[node]){
        // cerr << "child node = " << child << endl;
        if(child == parent){
            continue;
        }
        if(color == 0){   
            retVal *= ((dfs(child,1,node) + dfs(child,0,node)) % MOD);
            retVal %= MOD;
        }else{
            retVal *= dfs(child,0,node);
            retVal %= MOD;
        }
    }
    // cerr << "target =" << node << "color = " << color << " Val = " << retVal << endl;
    dp[node][color] = retVal;
    return retVal;
}

int main(){
    cin >> N;
    T.resize(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            dp[i][j] = -1;
        }
    }
    // cerr <<"white" << dfs(0,0,-1) << endl;
    // cerr <<"black" <<  dfs(0,1,-1) << endl;
    cout << (dfs(0,0,-1) + dfs(0,1,-1)) %MOD << endl;
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   int n; scanf("%d",&n);
   vector<int> a(n); rep(i,0,n)scanf("%d",&a[i]);
   int res=0;
   rep(i,0,n-1){
      if(a[i]==a[i+1]){
         a[i+1]=-1; res++;
      }
   } cout<<res<<endl;
   return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
if(a==5):
    if(b==7 and c==5):
        print("YES")
    elif(b==5 and c==7):
        print("YES")
    else:
        print("NO")
elif(a==7):
    if(b==5 and c==5):
        print("YES")
    else:
        print("NO")
else:
    print("NO")

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

int main() {

	int n = 0;

	string w, t;


	cin >> w;
	transform(w.begin(), w.end(), w.begin(), ::toupper);


	while(1) {
		cin >> t;
		if (t == "END_OF_TEXT") {
			break;
		}
		transform(t.begin(), t.end(), t.begin(), ::toupper);
		

		if (t == w) {
			n++;
		}
		else {}
	}

	cout << n << endl;

	return 0;
}

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

const int N = 100 * 1000 + 10;

int a[N], b[N];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i]--;
		b[i] = (a[i] == i);
	}
	long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		if(b[i] == 1)
		{
			ans++;
			i++;
		}
	}
	cout << ans << endl;
}

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

int main() {
	int e, x, y, z, min;

	while (cin >> e && e != 0) {
		min = 999999999;
		
		for (z = 0; z*z*z <= e; z++) {
			for (y = 0; y*y <= e - z*z*z; y++) {
					x = e - y*y - z*z*z;
				
				if (min > x + y + z) {
					min = x + y + z;
				}
			}

		}

		cout << min << endl;
	}
}

Measured memory_bytes: 1160
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]
ans = 0
seq = [0] * 10

def dfs(depth, tail):
    global ans, seq
    if depth == n:
        s = 0
        for a, b, c, d in abcd:
            a -= 1
            b -= 1
            if seq[b] - seq[a] == c:
                s += d
        ans = max(ans, s)
        return

    for i in range(tail, m + 1):
        seq[depth] = i
        dfs(depth + 1, i)

dfs(0, 1)
print(ans)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<int> dp(n+5);
    for(int i = n; i > 0; i--)
    {
        int cnt = 0, cur = i;
        while(cur <= n)
        {
            cnt += dp[cur];
            cur += i;
        }
        if(cnt % 2 != a[i-1]) dp[i] = 1;
    }
    //REP(i, n)
    //cout << dp[i+1] << " \n"[i == n-1];
    int ans = 0;
    REP(i, n) if(dp[i+1] == 1) ans++;
    cout << ans << endl;
    REP(i, n) if(dp[i+1] == 1) cout << i+1 << " \n"[i == n-1];
}

Measured memory_bytes: 2560
let inp = readLine()!.split(separator: " ").map { Int($0)! }
 
let n = inp[0]
let k = inp[1]
 
let a = readLine()!.split(separator: " ").map { Int($0)! }
for i in k+1...n {
  print(a[i-1] > a[i - 1 - k] ? "Yes" : "No")
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

void make2(int a,int sz,vector<int>& v){
   vector<int> add(sz,a/sz);
   add.back()+=a%sz;
   rep(i,0,sz)v.push_back(add[i]);
}

int main(){
   int n,k,s; scanf("%d%d%d",&n,&k,&s);
   vector<int> res(n,1e9);
   if(k==0){
      if(s==1000000000){
         rep(i,0,n)res[i]=1;
      }
      rep(i,0,n)printf("%d\n",res[i]);
      return 0;
   }
   if(s<n-k+1){
      rep(i,0,k)res[i]=s;
      rep(i,0,n)printf("%d\n",res[i]);
      return 0;
   }
   vector<int> sub; make2(s,n-k+1,sub);
   rep(i,0,n)res[i]=sub[i%(sub.size())];
   rep(i,0,n)printf("%d\n",res[i]);
   return 0;
}


Measured memory_bytes: 1776
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;



int main(){
    int N, p[10];
    
    cin >> N;
    for (int i=0;i<N;i++) cin >> p[i];
    
    int min = p[0];
    int min_index = 0;
    for (int i=1;i<N;i++) {
        if (p[i]>min) {
            min = p[i];
            min_index = i;
        }
    }
    
    int result = 0;
    for (int i=0;i<N;i++) {
        if (i==min_index)  result += p[i]/2;
        else result += p[i];
    }
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N, K;
    cin >> N >> K;

    int ans = 0;

    int cnt = 0;
    int f, e;
    f = 0;
    e = 0;
    REP(i, K)
    {
        f += cnt;
        e += N - cnt;
        cnt++;
    }

    while (1)
    {
        ans %= MOD;
        if (K > N + 1)
            break;
        ans += e - f + 1;

        f += cnt;
        e += N - cnt;
        cnt++;
        K++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;cin>>s;
	for (int i=0;i<s.size();i++){
		if (s[i]=='L' && i%2==0){
			puts("No");return 0;
		}
		if (s[i]=='R' && i%2==1){
			puts("No");return 0;
		} 
	}
	puts("Yes");
}

Measured memory_bytes: 256
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

// define
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(i,n) FOR(i,0,n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
inline int countChar(string s, char c) {int cnt,i; cnt=0; REP (i,s.size()) {if (s[i]==c) cnt++;} return cnt;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

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

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  int a, b;
  cin >> a >> b;
  // Scan done.

  // Code begin.
  if ((a+b) == 15) {
    cout << "+" << endl;
  }
  else if ((a*b) == 15) {
    cout << "*" << endl;
  }
  else {
    cout << "x" << endl;
  }
  // Code done.

  return 0;
}

//=functions=================================================================//

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

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

    string s_odd;
    int i;
    for(i=0; i<s.size(); i++)
    {
        if((i+1) % 2 == 1)
        {
            s_odd += s.at(i);
        }
    }

    cout << s_odd;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int fun(int n)
{
        if(n>0)
                return n;
        else
                return -n;
}
int main()
{
    int a,b,c,d;
    while(scanf("%d%d%d%d",&a,&b,&c,&d)==4)
    {
            if((fun(c-a)<=d)||(fun(c-b)<=d&&fun(b-a)<=d))
                printf("Yes\n");
            else
                printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,i;string s;
	cin>>n>>s;
	for(i=0;i<s.size();i++) s[i]=(s[i]-65+n)%26+65;
	cout<<s<<endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
	ll h,a;
  cin>>h>>a;
  if(h%a==0) cout << h/a << endl;
  else cout << h/a+1 << endl;
  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  H += (long double)M / 60;
  long double d = max(H / 12, M / 60);
  long double e = min(H / 12, M / 60);
  long double po = min((d - e) * 2 * M_PI, (e + 1 - d) * 2 * M_PI);
  // cout << po / (2 * M_PI) << endl;
  long double ans = (A * A) + (B * B) - (2 * A * B * cos(po));
  cout << fixed << SP(29) << SQRT(ans) << endl;

  return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
ll MOD = ll(1e8) + 9;

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N;
    cin >> N;

    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    // sort(all(X));

    ll m = ll(1e8);
    for (int P = 1; P <= 100; P++) {
        ll tot = 0;
        for (int i = 0; i < N; i++) {
            tot += (X[i] - P) * (X[i] - P);
        }
        m = min(m, tot);
    }
    cout << m << endl;



    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k,q;
    cin>>k>>q;
    vec A(k);
    rep(i,k) cin>>A[i];
    rep(i,q){
        ll n,x,m,sum=0,count=0;
        cin>>n>>x>>m;
        vec B(k);
        rep(i,k) B[i]=A[i]%m,sum+=B[i];
        rep(i,k) if(B[i]==0) count++;
        n--;
        sum=sum*(n/k);
        count=count*(n/k);
        sum+=x%m;
        rep(i,n%k) sum+=B[i];
        rep(i,n%k) if(B[i]==0) count++;
        cout<<n-count-sum/m<<"\n";
    }
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const int N = 4010;
char s[N];
int a[N], dp[N][3];
int main(void){
    IOS;
    int n; cin >> n >> (s+1);
    for (int i = 1; i <= n; ++i){
        if (s[i] == 'R') a[i] = 0;
        else if (s[i] == 'G') a[i] = 1;
        else a[i] = 2;
    }
    for (int i = 1; i <= n; ++i){
        dp[i][0] = dp[i-1][0];
        dp[i][1] = dp[i-1][1];
        dp[i][2] = dp[i-1][2];
        dp[i][a[i]]++;
    }
    //for (int i = 1; i <= n; ++i){
    //    printf("%d %d %d\n", dp[i][0], dp[i][1], dp[i][2]);
    //}
    ll ans = 0;
    for (int i = 3; i <= n; ++i){
        for (int j = 1; j < i; ++j){
            if (a[i] == a[j]) continue;
            ans += dp[j][3-a[i]-a[j]];
            //printf("slc %d dp %d\n", 5-a[i]);
        }
        //debug(ans);
    }
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j+2*i <= n; ++j){
            ans -= (a[j]!=a[j+i] && a[j+i]!=a[j+2*i] && a[j]!=a[j+2*i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define N 200000
int ai[N];
int nx[20][N], q, s, n, L;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> ai[i];
    cin >> L;
    for (int i = 1, j = i; i <= n; ++ i)
    {
        while (j < n && ai[j + 1] - ai[i] <= L) j ++;
        nx[0][i] = j;
    }
    for (s = 1; (1 << s) <= n; ++ s)
        for (int j = 1; j <= n; ++ j)
            nx[s][j] = nx[s - 1][nx[s - 1][j]];
    s --;
    cin >> q;
    for (int i = 1; i <= q; ++ i)
    {
        int l, r, ans = 0;
        cin >> l >> r;
        if (l > r) swap(l, r);
        for (int i = s; ~i; -- i)
            if (nx[i][l] < r)
                l = nx[i][l], ans += 1 << i;
        cout << ans + 1 << "\n";
    }
}


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

const int M=1e9+7;

void dfs(vector<pair<int,int>>&dp,vector<int>*v,int p,vector<int>&vis){
	//cout<<p<<endl;
	if(v[p].size()==1){
		dp[p].first=1;
		dp[p].second=1;
	//	cout<<p<<endl;
	}else{
		long long int pro1=1,pro2=1;
		for(int i=0;i<v[p].size();i++){
			int x=v[p][i];
			if(vis[x])continue;
			vis[x]=1;
			dfs(dp,v,x,vis);
			pro1*=dp[x].first;
			pro2*=(dp[x].first+dp[x].second);
			pro1%=M;
			pro2%=M;
		}
		
		
		
		dp[p].first=pro2;
		dp[p].second=pro1;
	}
	
}

int main() {
	// your code goes here
	int n;cin>>n;
	vector<int>v[n];
	for(int i=0;i<n-1;i++){
		int x,y;cin>>x>>y;
		x--;y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	
	int pos=0;
	for(int i=0;i<n;i++){
		if(v[i].size()!=1){
			pos=i;break;
		}
	}
	vector<pair<int,int>>dp(n);
	vector<int>vis(n,0);
	vis[pos]=1;

	dfs(dp,v,pos,vis);
//	cout<<pos<<endl;
	/*
	for(int i=0;i<n;i++){
		cout<<i<<" "<<dp[i].first<<" "<<dp[i].second<<endl;
	}*/
	
	if(n==2){
		cout<<3<<endl;
	}
	else{
		cout<<(dp[pos].first+dp[pos].second)%M<<endl;
	}
	return 0;
}

Measured memory_bytes: 18152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const ll mod = 998244353;
    int n;
    cin >> n;
    vector<pll> robots_finish;
    vl robots_index;
    rep(i, n) {
        ll x, d;
        cin >> x >> d;
        robots_finish.pb(mp(x + d, x));
        robots_index.pb(x);
    }
    robots_finish.pb(mp(1e18, 1e18 + 1));
    robots_index.pb(1e18);
    n++;
    sort(robots_finish.rbegin(), robots_finish.rend());
    sort(robots_index.begin(), robots_index.end());

    priority_queue<ll> s;
    map<ll, ll> robot_dict;
    ll r = 0;
    vl l(n, -1);
    rep(i, n) {
        robot_dict[robots_index[i]] = i;
    }
    for (int i = n - 1; i >= 0; i--) {
        while (r < n && robots_finish[r].first > robots_index[i]) {
            s.push(robots_finish[r].second);
            r++;
        }
        while (!s.empty() && s.top() >= robots_index[i]) {
            s.pop();
        }
        if (!s.empty()) {
            l[i] = robot_dict[s.top()];
        }
    }

    vl dp(n, 0), dp_sum(n, 0);
    dp[0] = dp_sum[0] = 1;
    for (int i = 1; i < n; i++) {
        dp[i] = dp_sum[i - 1];
        if (l[i] - 1 >= 0) {
            dp[i] -= dp_sum[l[i] - 1];
        }
        if (l[i] == -1) {
            dp[i]++;
        }
        dp[i] %= mod;
        dp_sum[i] = (dp_sum[i - 1] + dp[i]) % mod;
    }
    if (dp[n - 1] < 0) dp[n - 1] += mod;
    cout << dp[n - 1] << endl;
}

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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

int N, m;
vector<Pii> d;
unordered_map<int, int> dp[1001][1001];

int dfs(int pre, int now, int n) {
  if ( n == m ) {
    return (now-pre + (N+1)-pre);
  }
  if ( dp[pre][now][n] > 0 ) return dp[pre][now][n];

  int ret = dfs(min(pre, d[n].sc), d[n].fr, n+1) + (d[n].fr-now);
  ret = min(ret, dfs(d[n].sc, d[n].fr, n+1) + (now-pre + d[n].fr-pre));

  return dp[pre][now][n] = ret;
}

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

  Rep(i, m) {
    int c, b;
    cin >> c >> b;
    d.pb(Pii(b, c));    
  }

  sort(All(d));

  if ( m == 0 ) cout << N+1 << endl;
  else cout << dfs(d[0].sc, d[0].fr, 1) + d[0].fr << endl;
}

Measured memory_bytes: 65748
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	string s, t;
	cin >> n >> s >> t;

	string ans("");
	REP(i, n) {
		ans += s.substr(i, 1) + t.substr(i, 1);
	}
	col(ans);
	return 0;
}


Measured memory_bytes: 3624
/*
AizuOnline A1165
Title
*/
#include <stdio.h>
#define MAXRECTS 200
#define min(x,y) (((x)<(y))?(x):(y))
#define max(x,y) (((x)>(y))?(x):(y))
int n;
int op[MAXRECTS];
int rp[MAXRECTS];
int x[MAXRECTS];
int y[MAXRECTS];
int xmin,ymin,xmax,ymax;
//
main()
{
  int i,j;

  x[0]=y[0]=0;
  while(EOF!=scanf("%d",&n) && n)
    {
      for(i=1;i<n;i++)
	{
	  scanf("%d %d",&op[i],&rp[i]);
	  {
	    if(rp[i]==0)
	      {
		x[i]=x[op[i]]-1;
		y[i]=y[op[i]];
#ifdef DEBUG
		printf("%d %d %d\n",i,x[i],y[i]);
#endif
	      }
	    if(rp[i]==1)
	      {
		x[i]=x[op[i]];
		y[i]=y[op[i]]+1;
#ifdef DEBUG
		printf("%d %d %d\n",i,x[i],y[i]);
#endif

	      }
	    if(rp[i]==2)
	      {
		x[i]=x[op[i]]+1;
		y[i]=y[op[i]];
#ifdef DEBUG
		printf("%d %d %d\n",i,x[i],y[i]);
#endif

	      }
	    if(rp[i]==3)
	      {
		x[i]=x[op[i]];
		y[i]=y[op[i]]-1;

#ifdef DEBUG
		printf("%d %d %d\n",i,x[i],y[i]);
#endif
	      }
	  }
	}
      xmin=0;xmax=0;
      ymin=0;ymax=0;

	for(j=1;j<n;j++)
	  {
#ifdef DEBUG
	    printf("%d %d\n",x[j],y[j]);
#endif
	    xmin=min(xmin,x[j]);xmax=max(xmax,x[j]);
	    ymin=min(ymin,y[j]);ymax=max(ymax,y[j]);
	  }
      printf("%d %d\n" ,xmax-xmin+1,ymax-ymin+1);

    }
return(0);
}

Measured memory_bytes: 600
#include<stdio.h>
int main(){
	int n,i,a[20];
	scanf("%d",&n);
	while(n>-1){
		if(n==0){
			printf("0");
		}
		else{
			for(i=0;n>0;i++){
				a[i]=n%4;
				n=n/4;
			}
			while(i!=0){
				i--;
				printf("%d",a[i]);
			}
		}
		puts("");
		scanf("%d",&n);
	}
}

Measured memory_bytes: 1044
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

int solve(int k)
{
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  return a[k - 1];
}

int main()
{
  int k;
  std::cin >> k;

  std::cout << std::setprecision(20);
  std::cout << solve(k) << std::endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		String b = a.nextLine();
		String[] vals = b.split(" ");
		int comp = Integer.parseInt(vals[0]);
		int c = Integer.parseInt(vals[1]);
		ArrayList<Integer> list= new ArrayList<Integer>();
		for (int i = 0;i<c;i++) {
			String wfeihu = a.nextLine();
			String nums = a.nextLine();
			String[] d = nums.split(" ");
			for (int j=0;j<d.length;j++) {
				int p = Integer.parseInt(d[j]);
				if (!list.contains(p)) {
					list.add(p);
				}
			}
		}
		System.out.println(comp-list.size());
	}
		
}


Measured memory_bytes: 37396
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n = 0; cin >> n;
    if (n%2 == 0) {
        cout << n*(n-1)/2 - n/2 << endl;
        for (int i=1; i<=n; i++) {
            for (int j=i+1; j<=n; j++) {
                if (i + j == n + 1) continue;
                cout << i << " " << j << endl;
            }
        }
    } else {
        cout << n*(n-1)/2 - (n-1)/2 << endl;
        for (int i=1; i<=n; i++) {
            for (int j=i+1; j<=n; j++) {
                if (i + j == n) continue;
                cout << i << " " << j << endl;
            }
        }
    }
    return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    vector<vector<ll>> q(Q);
    vector<string> c(Q);
    for (long long i = 0; i < Q; i++) {
        ll a;
        cin>>a;
        q[i].push_back(a);
        if(a==2){
            ll b;
            cin>>b;
            q[i].push_back(b);
            string C;
            cin>>C;
            c[i]=C;
        }
    }
    // mout(q);
    // vout(c);
    ll cnt=0;
    string res=S;
    for (long long i = 0; i < Q; i++) {
        if(q[i][0]==1){
            cnt++;
        }else{
            if(cnt%2){
                if(q[i][1]==1) res+=c[i];
                if(q[i][1]==2) res.insert(0,c[i]);
            }else{
                if(q[i][1]==1) res.insert(0,c[i]);
                if(q[i][1]==2) res+=c[i];
            }
        }
    }
    if(cnt%2){
        reverse(all(res));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 22972
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -pn;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return pn * tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 9;
	ll tmp[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	ll mae = 1e18;
	int kazu = 0;
	rep(i, N + 1) {
		if (mae != A[i]) {
			mae = A[i];
			kazu = 0;
		}
		kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 4836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[][][] house = new int[3][10][4];
        String count = br.readLine();
        for(int i = 0 ; i < Integer.parseInt(count) ; i++){
            String info = br.readLine();
            String[] ia = info.split(" ");
            house[Integer.parseInt(ia[1])-1][Integer.parseInt(ia[2])-1][Integer.parseInt(ia[0])-1] += Integer.parseInt(ia[3]);
                                                                      
        }
        for(int i = 0 ; i < house[2][0].length ; i++){
            for(int j = 0 ; j < house.length ; j++){
                for(int k = 0 ; k < house[j].length ; k++){
                    System.out.print(" " + house[j][k][i]);
                }
                System.out.println();
            }
            if(i != house[0][0].length-1) System.out.println("####################");
        }
    }
 
}

Measured memory_bytes: 24620
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        while(scn.hasNextInt()) {
            System.out.println(
              (scn.nextInt() + scn.nextInt() + "").length()
            );
        }
    }
}

Measured memory_bytes: 26244
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;

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

	int N;
	cin >> N;

	vector<vector<int>> x(N, vector<int>(N)), y(N, vector<int>(N));
	vector<int> A(N);
	rep(i, N) {
		cin >> A[i];
		rep(j, A[i]) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	bool flg;
	rep(bit, (1 << (N))) {
		flg = false;
		rep(i, N) {
			if (bit & (1 << (i))) {
				//cout << i << ": " << bitset<8>(bit) << endl;
				rep(j, A[i]) {
					if (y[i][j] == 1) {
						if (!(bit & (1 << (x[i][j])))) {
							flg = true;
							break;
						}
					}
					else {
						if ((bit & (1 << (x[i][j])))) {
							flg = true;
							break;
						}
					}
					/*if (j == A[i] - 1) {
						cnt++;
					}*/
				}
				if (flg) {
					cnt = 0;
					break;
				}
				else{
					cnt++;
				}
			}
		}
		ans = max(ans, cnt);
		cnt = 0;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9

int ansA;
int ansB;

int pow5(int n)
{
    return n * n * n * n * n;
}

int solve(int x, int a, int b)
{
    int powA = pow5(a);
    if (x - powA > 0)
    {
        int powi = 0;
        for (int i = 0; powA - powi < x; i--)
        {
            powi = pow5(i);
            if (powA - powi == x)
            {
                ansA = a;
                ansB = i;
                return 0;
            }
        }
    }
    else
    {
        int powi = 0;
        for (int i = 0; powA - powi < x; i++)
        {
            powi = pow5(i);
            if (powA - powi == x)
            {
                ansA = a;
                ansB = i;
                return 0;
            }
        }
    }

    solve(x, a + 1, 0);

    return 0;
}

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

    /*

    solve(x, 0, 0);

    */

    for (int a = 0; a <= 10000000000; a++)
    {
        for (int b = 0; b <= 10000; b++)
        {
            if (pow5(a) - pow5(b) == x)
            {
                cout << a << " " << b << endl;
                return 0;
            }
            if (pow5(-a) - pow5(b) == x)
            {
                cout << -a << " " << b << endl;
                return 0;
            }
            if (pow5(a) - pow5(-b) == x)
            {
                cout << a << " " << -b << endl;
                return 0;
            }
            if (pow5(-a) - pow5(-b) == x)
            {
                cout << -a << " " << -b << endl;
                return 0;
            }
        }
    }

    //cout << ansA << " " << ansB << endl;
}

Measured memory_bytes: 3620