akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N, M; cin >> N >> M;

  vector < vector< pair<int, ll> > > graph(N); 

  vector <bool> edge(N);

  for (int i = 0; i < M; i++){
    int L, R; ll D; cin >> L >> R >> D;
    L--; R--;
    graph[L].push_back(make_pair(R, D));
    graph[R].push_back(make_pair(L, -1 * D));
    edge[L] = true; edge[R] = true;
  }

  vector <ll> ans(N);
  vector <bool> visited(N);

  queue <int> que;

  for (int i = 0; i < N; i++){
    if (edge[i] == true){
      que.push(i);
      visited[i] = true;
      break;
    }
  }

  

  
  bool flag = true;
  while (!que.empty()){
    int start = que.front(); que.pop();

    for (int i = 0; i < graph[start].size(); i++){
      int next = graph[start][i].first;
      int dist = graph[start][i].second;

      if (visited[next] == false){
        visited[next] = true;
        que.push(next);
        ans[next] = ans[start] + dist;

      }else{
        if (ans[next] != ans[start] + dist){
          flag = false;
        }
      }
    }


    if (que.empty()){
      for (int i = 0; i < N; i++){
        if (edge[i] == true && visited[i] == false){
          que.push(i);
          visited[i] = true;
          break;
        }
      }
    } 
  }


  

  if (flag == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  


  return 0;
}


Measured memory_bytes: 13952
#include<stdio.h>
#include<string.h>
#define Max(x,y) ((x>y)?x:y)
int c[10005],d[10005];
int func(int s,int t){
	int x=0;
	while(c[s]==c[t] && d[s]+d[t]>=4){
		x+=d[s]+d[t];
		s=s-d[s];
		t=t+d[t];
	}
	//printf(" %d %d\n",s,t);
	return x;
}
int main(){
	int i,j,n,x,y,s,t,ans;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		c[0]=5;c[n+1]=6;
		d[0]=d[n+1]=0;
		scanf("%d",&c[1]);
		x=c[1];y=1;
		for(i=2;i<=n+1;i++){
			if(i<n+1)scanf("%d",&c[i]);
			if(c[i]!=x){
				for(j=1;j<=y;j++)
					d[i-j]=y;
				y=1;
				x=c[i];
			}else y++;
		}
		//for(i=1;i<=n;i++)printf("%d ",d[i]);
		//printf("\n");
		ans=0;
		for(i=1;i<=n;i++){
			if(c[i-1]==c[i+1]){
				if(c[i-1]!=c[i] && d[i-1]+d[i+1]>=3){
					s=(i-1)-d[i-1];
					t=(i+1)+d[i+1];
					ans=Max(ans,d[i-1]+d[i+1]+1+func(s,t));
					//printf("%d:%d\n",i,d[i-1]+d[i+1]+1+func(s,t));
				}
			}else{
				if(c[i-1]!=c[i] && d[i-1]>=3){
					s=(i-1)-d[i-1];
					if(c[i]==c[i+1])t=i,x=0;
					else t=i+1,x=1;
					ans=Max(ans,d[i-1]+x+func(s,t));
					//printf("%d:%d\n",i,d[i-1]+1+func(s,t));
				}
				if(c[i+1]!=c[i] && d[i+1]>=3){
					t=(i+1)+d[i+1];
					if(c[i]==c[i-1])s=i,x=0;
					else s=i-1,x=1;
					ans=Max(ans,d[i+1]+x+func(s,t));
					//printf("%d:%d\n",i,d[i+1]+1+func(s,t));
				}
			}
		}
		printf("%d\n",n-ans);
	}
	return 0;
}

Measured memory_bytes: 0
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m,q = LI()
    a = [[0]*n for i in range(n)]
    for _ in range(m):
        l,r = LI()
        l -= 1
        r -= 1
        a[l][r] += 1
    for i in range(n):
        for j in range(n-1):
            a[i][j+1] += a[i][j]
    for j in range(n):
        for i in range(n-1)[::-1]:
            a[i][j] += a[i+1][j]
    for _ in range(q):
        l,r = LI()
        l -= 1
        r -= 1
        print(a[l][r])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 57052
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm. fill_n(&an[0][0],n*m,0); typedef long long ll;*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
#define print(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}

void solve(){
	string s,t;
	cin >> s >> t;
	int n = (int)s.length();
	bool pr = true;
	FO(i,0,n){
		if(s[i] != t[i]){
			pr = false;
			break;
		}
	}
	if(pr)cout << "Yes" << endl;
	else cout << "No" << endl;
}
/* When you have to multiply many things , do it in different (multiple) lines, not in a single line .*/
int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int nT = 1;
	//cin >> nT;
	FE(i,1,nT)
		solve();
	return 0;
}


Measured memory_bytes: 3648
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool dp[1000000];

const int MAX_N = 1000000;

vector<int> prime;
bool is_prime[MAX_N+1];

// n以下の素数を生成する
void create_prime(int n){
	// 初期化
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<=n;i++){
		is_prime[i] = true;
	}
	
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime.push_back(i);
			for(int j=2*i;j<=n;j+=i){
				is_prime[j] = false;
			}
		}
	}
}

int main(){
	int n,x;
	create_prime(MAX_N);
	while(true){
		cin >> n >> x;
		if(n==0 && x==0) break;
		REP(i,x+1){
			dp[i] = false;
		}
		VI data;
		int buf;
		REP(i, n){
			cin >> buf;
			data.PB(buf);
		}

		dp[0] = true;
		REP(i,x){
			if(dp[i]){
				REP(j, n){
					if(i+data[j] <= x) dp[i+data[j]] = true;
				}
			}
		}

		int ans = 0;
		REP(i, prime.size()){
			if(x < prime[i]) break;
			if(dp[prime[i]]){
				ans = prime[i];
			}
		}

		if(ans != 0){
			cout << ans << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,P[55];
ll i,j,k,ans;
int main(){
    scanf("%lld", &N);
    j = 0;
    fornum(i,0,N){
        scanf("%lld", &P[i]);
        if(P[i]==j+1){
            j = j + 1;
        }
    }
    if(j==N){
        printf("YES");
        return 0;
    }
    
    fornum(i,0,N){
        fornum(j,i+1,N){
            ll a = 0;
            fornum(k,0,N){
                if(k==i){
                    if(a>P[j])
                        break;
                    a = P[j];
                }else if(k==j){
                    if(a>P[i])
                        break;
                    a = P[i];
                }else{
                    if(a>P[k])
                        break;
                    a = P[k];
                }
            }
            if(k==N){
                printf("YES");
                return 0;

            }
        }
    }
    printf("NO");

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char po[1919];
    scanf("%s",po);
    char buri[16][1919]={"KIHBARA","KIHABARA","KIHBRA","KIHABRA","KIHBAR","KIHABAR","KIHBR","KIHABR","AKIHBARA","AKIHABARA","AKIHABRA","AKIHABRA","AKIHBAR","AKIHABAR","AKIHBR","AKIHABR"};
    for(int i=0;i<16;i++)if(strcmp(po,buri[i])==0){printf("YES");return 0;}
    printf("NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  ll x;
  if(b<=n){x=b-1;}else{x=n;}
  ll ans;
  ans=floor(a*x/b);
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[305];
int n;
ll x;
ll sum;
int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%lld",&a[i]);
        if (i >= 2) x ^= a[i];
    }
    sum = a[0] + a[1];
    if (sum < x || ((sum-x)&1ll)){
        printf("-1\n");
        return 0;
    }
    ll N = (sum-x)>>1ll;
    //printf("sum = %lld, xor = %lld, thus and = %lld\n",sum,x,N);
    if (N > a[0]){
        printf("-1\n");
        return 0;
    }
    ll cur = N;
    for (int i = 60; i >= 0; i--){
        ll NEW = cur|(1ll<<i);
        if (NEW <= a[0] && (NEW^(sum-NEW)) == x ){
            //printf("can on %d\n",i);
            cur = NEW;
            //printf("check: %lld vs %lld\n",cur^(sum-cur),x);
        }
    }
    if (cur == 0){
        printf("-1\n");
        return 0;
    }
    ll ans = a[0]-cur;
    if (cur <= a[0] && (cur^(sum-cur)) == x){
        printf("%lld\n",ans);
    }
    else printf("-1\n");
}


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

int main() {
    ll n;
    cin >> n;
    ll P = 100, c = 0;
    while(P < n) {
        P += P / 100;
        c++;
    }

    cout << c << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 100100;

int u[N];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        ++u[a];
    }
    int bad = 0;
    int s = 0;
    for (int i = 1; i < N; ++i) {
        while (u[i] > 2) {
            u[i] -= (u[i] / 3) * 2;
        }
        if (u[i] == 2) {
            ++bad;
        }
        s += u[i];
    }
    bad += bad % 2;
    cout << s - bad;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    long int n;
    cin>>n;
    if(n<5){
        cout<<0;
        return 0;
    }
    int a = n/500;
    int c = n%500;
    int d = c/5;
    int ans = (a*1000) +  (d*5);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,L,R) for(i=L;i<R;i++)
#define REP(i,N) FOR(i,0,N)
int main(){
  ll i,j,H,W,A,B;cin>>H>>W>>A>>B;
  REP(i,H){
    REP(j,W)cout<<(i<B^j<A);
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3544
#include<iostream>
int main()
{
	int N;
	std::cin >> N;
	for (int i = 0; i < N; i++)
	{
		int b_back = 0, c_back = 0;
		bool is_OK = true;
		for (int j = 0; j < 10; j++)
		{
			int num;
			std::cin >> num;
			if (num < b_back && num < c_back)
			{
				is_OK = false;
			}
			else if (num > b_back && num < c_back)
			{
				b_back = num;
			}
			else if (num < b_back && num > c_back)
			{
				c_back = num;
			}
			else
			{
				if (b_back > c_back)
				{
					b_back = num;
				}
				else
				{
					c_back = num;
				}
			}
		}
		std::cout << (is_OK ? "YES" : "NO") << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve(void)
{
  int N,A ,B; cin>>N; cin>>A ;cin>>B;
  cout<<min(A*N,B)<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define DEBUG 0
#define REP(i, n) for (int i = 0; i < (n); i++) 
typedef long long ll;
typedef pair<int,int> pint;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main() { 
    int X,Y;
    cin >> X >> Y;

    int res = 0;
    if(X == 1 && Y == 1)res += 4;
    if(X == 1)res += 3;
    if(X == 2)res += 2;
    if(X == 3)res += 1;
    if(Y == 1)res += 3;
    if(Y == 2)res += 2;
    if(Y == 3)res += 1;

    res *= 100000;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main(){
    int n,m;
    while(cin>>n>>m,n&&m){
        int is,ip,ig,ia,ib,id,it;
        string s,p,g,sa,sb;
        vector<vector<int> > G;
        vector<int>Eki;
        map<string,int>ma;
        Eki.resize(n,-1);
        G.resize(n, Eki);
        
        cin>>s>>p>>g;
        for(int i=0;i<m;i++){
            cin>>sa>>sb>>id>>it;
            
            map<string,int>::iterator ite;

            ite = ma.find(sa);
            if(ite == ma.end()){
                ma.insert(make_pair(sa, ma.size()));
            }
            ite = ma.find(sb);
            if(ite == ma.end()){
                ma.insert(make_pair(sb, ma.size()));
            }
            
            ia = ma.find(sa)->second;
            ib = ma.find(sb)->second;
            G[ia][ib]= id/40+it;
            G[ib][ia]= id/40+it;
        }
        
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    if(G[j][i]!=-1&&G[i][k]!=-1){
                        if(G[j][k]==-1) G[j][k] = G[j][i]+G[i][k];
                        else G[j][k] = min(G[j][k],G[j][i]+G[i][k]);
                    }
                }
            }
        }
        is = ma.find(s)->second;
        ip = ma.find(p)->second;
        ig = ma.find(g)->second;
        cout<<G[is][ip]+G[ip][ig]<<endl;
    }
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

#define MAX (1<<20)
int N;
ll A[MAX];

const bool debug = false;

vector<ll> bf() { // O((2^N)^3)
  vector<ll> ans;
  REP(K,1,(1<<N)) {
    ll maxi = 0;
    rep(i,(1<<N)) {
      REP(j,i+1,(1<<N)) {
	if( ( i | j ) <= K ) {
	  maxi = max(maxi,A[i]+A[j]);
	}
      }
    }
    ans.push_back(maxi);
  }
  return ans;
}

ll memo[MAX];
vector<ll> bf_improve() { // O((2^N)^2)
  memset(memo,0,sizeof memo);
  vector<ll> ans;
  rep(i,(1<<N)) {
    REP(j,i+1,(1<<N)) {
      memo[i|j] = max(memo[i|j],A[i]+A[j]);
    }
  }
  REP(K,1,(1<<N)) {
    if( K > 1 ) memo[K] = max(memo[K],memo[K-1]);
    ans.push_back(memo[K]);
  }
  return ans;
}

class Data {
public:
  ll v[2];
  Data() { v[0]=v[1]=-1; }
  Data(ll a) { v[0]=a;v[1]=-1; }

  void update(Data d) {
    update(d.v[0]);
    update(d.v[1]);
  }
  
  void update(ll x) {
    if( v[0] == -1 ) {
      v[0] = x;
    } else if( v[1] == -1 ) {
      if( v[0] <= x ) {
	swap(v[1],v[0]);
	v[0] = x;
      } else {
	v[1] = x;
      }
    } else if( v[0] <= x ) {
      swap(v[0],v[1]);
      v[0] = x;
    } else if( v[1] <= x ) {
      v[1] = x;
    }
  }
  
};

Data dp[MAX];

void compute() {
  if( debug ) {
    puts("[Brute Force]");
    vector<ll> vec = bf();
    vector<ll> vec2 = bf_improve();
    assert( vec == vec2 );
    rep(i,(int)vec.size()) cout << vec[i] << endl;
  }
  rep(i,(1<<N)) dp[i] = Data(A[i]);
  
  rep(i,N) {
    if( debug ) cout << i << "-th" << endl;
    rep(j,(1<<N)) {
      if( ((j>>i)&1) == 1 ) {
	if( debug ) {
	  bitset<3> BIT;
	  cout << "  Before[" << (BIT=j) << "] = " << dp[j].v[0] << "," << dp[j].v[1] << endl;
	  cout << "    mix up " << dp[j&~(1<<i)].v[0] << " " << dp[j&~(1<<i)].v[1] << endl;
	}
	dp[j].update(dp[j&~(1<<i)]);
	if( debug ) {
	  bitset<3> BIT;
	  cout << "  After [" << (BIT=j) << "] = " << dp[j].v[0] << "," << dp[j].v[1] << endl;
	  puts("");
	}
      }
    }
  }

  if( debug ) {
    puts("Result..");
    REP(i,1,(1<<N)) cout << dp[i].v[0] << " + "<< dp[i].v[1] << endl;
    puts("[My Ans]");
  }
  ll maxi = 0;
  REP(i,1,(1<<N)) {
    maxi = max(maxi,dp[i].v[0]+dp[i].v[1]);
    cout << maxi << endl;
  }
}

int main() {
  cin >> N;
  rep(i,(1<<N)) cin >> A[i];

  if(0) {
    auto f = [](ll a, ll b) { return max(a,b); };
    vector<ll> a(1<<N,0);
    rep(i,(1<<N)) a[i] = A[i];
    rep(i,N) {
      rep(b,(1<<N)) {
	if( 0 == ( b & (1<<i) ) ) {
	  //a[b] += a[b|(1<<i)];
	  a[b] = f(a[b],a[b|(1<<i)]);
	}
      }
    }
    bitset<10> BIT;
    rep(i,(1<<N)) {
      cout << i << " : " << (BIT=i) << " : " << a[i] << endl;
    }
    return 0;
  }
  
  compute();
  return 0;
}


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

using namespace std;

int main() {
	char c[6];

	cin >> c[0] >> c[1] >> c[2] >> c[3] >> c[4] >> c[5];
	if(c[0] == c[5] && c[1] == c[4] && c[2] == c[3]) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


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

int main(){
    int rate;

    cin >> rate;

    if (rate < 1200)
        cout << "ABC" << endl;
    else if(rate < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;
}




Measured memory_bytes: 256
#include <stdio.h>

void sort(int*,int);
int point(int*,int,int);

int main(int argc, char const *argv[]) {
  int length=0,t=0,tt=0; //tは出力判定、ttは10倍数以外があるか判定
  scanf("%d",&length);
  int s[length];
  for (size_t i = 0; i < length; i++) {
    scanf("%d\n",&s[i]);
    if(s[i]%10!=0){
      tt=-1;
    }
  }

  if(tt==0){
    printf("0");
    return 0;
  }

  sort(s,length);
  for (size_t i = 0; i < length; i++) {
    t=point(s,length,i);
    if (t==-1) {
      return 0;
    }
  }
  return 0;
}

void sort(int *s,int length){
  int temp=0;
  for (size_t i = 0; i < length; i++) {
    for (size_t j = length-1; j > i; j--) {
      if (s[j] < s[j-1]) {
        temp=s[j];
        s[j]=s[j-1];
        s[j-1]=temp;
      }
    }
  }
}

int point(int *s,int length,int count){
  int sum=0;
  for (size_t i = count; i < length; i++) {
    sum+=s[i];
  }

  if(count>=2){
    for (size_t i = 0; i < count-1; i++) {
      sum+=s[i];
    }
  }

  if(sum%10!=0){
    printf("%d\n",sum);
    return -1;
  }
  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int k = fs.nextInt();
		
		int now = 1;
		
		for(int i = 0; i < n; i++) {
			if(now < k) {
				now *= 2;
			}else {
				now += k;
			}
		}
		System.out.println(now);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef pair<int, int> pii;

const int N = 200005;
const ll OO = 1e18;

int n, m;
int a[N];
vector<pii> v[N];
ll val[1 << 20], lazy[1 << 20];

void push(int id) {
	val[id] += lazy[id];
	lazy[id * 2 + 1] += lazy[id];
	lazy[id * 2 + 2] += lazy[id];
	lazy[id] = 0;
}

void update(int ql, int qr, ll x, int id = 0, int l = 0, int r = n - 1) {
	push(id);
	if (ql > r || qr < l)
		return;
	if (ql <= l && r <= qr) {
		lazy[id] += x;
		push(id);
		return;
	}
	int mid = (l + r) / 2;
	update(ql, qr, x, id * 2 + 1, l, mid);
	update(ql, qr, x, id * 2 + 2, mid + 1, r);
	val[id] = max(val[id * 2 + 1], val[id * 2 + 2]);
}

ll query(int ql, int qr, int id = 0, int l = 0, int r = n - 1) {
	push(id);
	if (ql > r || qr < l)
		return -OO;
	if (ql <= l && r <= qr)
		return val[id];
	int mid = (l + r) / 2;
	return max(query(ql, qr, id * 2 + 1, l, mid), query(ql, qr, id * 2 + 2, mid + 1, r));
}

int main() {
	std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int l, r, x;
		cin >> l >> r >> x;
		l--, r--;
		v[r].emplace_back(l, x);
	}
	for (int i = 0; i < n; i++) {
		ll cur = 0;
		if (i) {
			cur = max(cur, query(0, i - 1));
		}
		update(i, i, cur);
		for (auto p : v[i]) {
			update(p.first, i, p.second);
		}
	}
	cout << max(0LL, query(0, n - 1)) << endl;
	return 0;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());


    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}

vector<int> factors(int n){
    vector<int> facts;
    int i = 1;
    while(i*i < n){
        if(n % i == 0){
            facts.push_back(i);
            facts.push_back(n/i);
        }
        i++;
    }
    int sq = (int)sqrt(n);
    if(sq * sq == n) facts.push_back(sq);
    sort(all(facts));
    return facts;
}
/* main */

int n;
void in(){
    cin >> n;
}

void solve(){
    vi facts = factors(n);

    int ans = 0;
    rep(i,1,sz(facts)){
        int val = facts[i] - 1;
        if(n / val == n % val) ans += val;
    }
    print(ans);

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int x[5];
  int k;
  REP(i,5){
    cin>>x[i];
  }
  cin>>k;
  for(int i=1;i<5;i++){
    REP(j,i){
      if(x[i]-x[j]>k){
        cout<<":("<<endl;
        return 0;
      }
    }
  }
  
  cout<<"Yay!"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define INF 200000000
#define min(a,b) ((a)<(b)?(a):(b))
#define A 41
#define B 401
int main(){
		int n,ma,mb,i,abc[40][3],j,k;
		scanf("%d%d%d",&n,&ma,&mb);
		for(i=0;i<n;i++)scanf("%d%d%d",&abc[i][0],&abc[i][1],&abc[i][2]);
		int dp[A][B][B];
		for(i=0;i<A;i++){
				for(j=0;j<B;j++){
						for(k=0;k<B;k++){
								dp[i][j][k]=INF;
						}
				}
		}
		dp[0][0][0]=0;
						for(k=1;k<=n;k++){
		for(i=0;i<B;i++){
				for(j=0;j<B;j++){
								dp[k][i][j]=min(dp[k-1][i][j],dp[k][i][j]);
								if(abc[k-1][0]<=i&&abc[k-1][1]<=j)dp[k][i][j]=min(dp[k][i][j],dp[k-1][i-abc[k-1][0]][j-abc[k-1][1]]+abc[k-1][2]);
						}
				}
		}/*
		for(i=0;i<n;i++){
				for(j=0;j<15;j++){
						for(k=0;k<15;k++){
								printf("%d,",dp[i][j][k]);
						}
						puts("");
				}
		}
		puts("OK");*/
		int ans=INF;
		for(i=1;i*ma<=B&&i*mb<=B;i++){
				if(dp[n][i*ma][i*mb]!=0)
				ans=min(ans,dp[n][i*ma][i*mb]);
		}
		if(ans==INF)ans=-1;
		printf("%d\n",ans);
		return 0;
}


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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

const ll inf = numeric_limits<ll>::max();

void solve(){
    ll n, k;
    cin>>n>>k;
    ll h[n];
    vector<ll> dp(n, inf);
    dp[0] = 0ll;
    fr(i, n) cin>>h[i];

    fr(i, n){
        rep(j, i+1, i+k){
            if(j < n)
                dp[j] = min(dp[j], dp[i] + llabs(h[i] - h[j]));
        }
    }
    cout<<dp[n-1];
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<int> vi;

int N;
vector<vpi> G;
vi C;
queue<int> Q;

void input_init(void) {
	cin >> N;
	G.resize(N + 1);
	for (int i = 0; i < N - 1; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		int d = (w % 2 == 0) ? 0 : 1;
		G[u].push_back(make_pair(v, d));
		G[v].push_back(make_pair(u, d));
	}
	C.resize(N + 1, -1);
}

void solve(void) {
	while (!Q.empty()) {
		int cur = Q.front();
		Q.pop();
		vpi::iterator itr;
		for (itr = G[cur].begin(); itr != G[cur].end(); ++itr) {
			int nxt = itr->first;
			int d = itr->second;
			if (C[nxt] != -1)
				continue;
			int col = C[cur] ^ d;
			C[nxt] = col;
			Q.push(nxt);
		}
	}
}

int main(void) {
	input_init();
	C[1] = 0;
	Q.push(1);
	solve();

	for (int i = 1; i <= N; ++i)
		cout << C[i] << '\n';
	return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
        return b ? gcd(b, a%b) : a;
}
int main() {
    
    ll K,sum=0;
    cin >> K;
    vector<vector<ll>> data(K, vector<ll>(K));
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                sum+=gcd(k,gcd(i,j));
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3904
#include <stdio.h>

int main(void) {
	int c1, c5, c10, c50, c100, c500;
	scanf("%d%d%d%d%d%d", &c1, &c5, &c10, &c50, &c100, &c500);
	if( 1*c1 + 5*c5 + 10*c10 + 50*c50 + 100*c100 + 500*c500 >= 1000)
		printf("1\n");
	else
		printf("0\n");
	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

vector<vector<int>> to;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> h(n);
	for(int i=0;i<n;i++)
		cin >> h[i];
	
	to=vector<vector<int>>(n);

	for(int i=0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	int cnt=0;
	for(int i=0;i<n;i++)
	{
		bool flg=true;
		for(int j=0;j<to[i].size();j++)
		{
			int nx=to[i][j];
			if(h[i]<=h[nx])flg=false;
		}
		if(flg)cnt++;
	}
	cout << cnt << endl;


	






}

Measured memory_bytes: 8364
/* last edited at 28.8.2015
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D
*/

#include<iostream>
using namespace std;
int cnt=0;

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

void shellSort(int A[], int N){
	int m=0;
	int G[N];
	for(int k=0; k<N; k++){
		if(k==0)G[0]=1;
		else G[k]=G[k-1]*3+1;
		//else G[k]=G[k-1]+3;
		m++;
		int q=G[k]*3+1;
		if(q>N) break;		
	}
	for(int k=m-1; k>=0; k--){
		insertionSort(A, N, G[k]);
	}
	cout << m << endl;
	for(int k=m-1; k>0; k--){
		cout << G[k] << " ";
	}
	cout << G[0] << endl; 
	cout << cnt << endl;
}

int main(){
	int N;
	cin >> N;
	int A[N];
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
	shellSort(A, N);
	
	for(int i=0; i<N; i++){
		cout << A[i] << endl;
	}	
	
	return 0;
}

Measured memory_bytes: 5072
<?php
 $str = str_replace("\n","",fgets(STDIN));
 $len = strlen($str) - 1;
 for($i = $len - 1;$i >= 0;$i--){
  if($i % 2 == 0){
   if(strcmp(substr($str,0,$i / 2),substr($str,$i / 2,$i / 2)) == 0){
    echo $i;
    return;
   }
  }
 }
?>

Measured memory_bytes: 3700
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct vec{
  double x, y;
  vec operator+(const vec& a) const { return (vec){x + a.x, y + a.y}; }
  vec operator-(const vec& a) const { return (vec){x - a.x, y - a.y}; }
  vec sca(double t){ return (vec){t * x, t * y}; }
  double dot(vec a){ return x * a.x + y * a.y; }
  double cross(vec a){ return x * a.y - y * a.x; }
  double norm(){ return sqrt(x * x + y * y); };
};
struct line{
  vec a, b;
  vec getvec(){ return b - a; }
  vec proj(vec p){
    vec pa = p - a, ba = b - a;
    double t = pa.dot(ba) / ba.dot(ba);
    return a + ba.sca(t);
  }
  vec vref(vec p){ return proj(p).sca(2.0) - p; }
  int ccw(vec p){
    vec q = p - a, ba = b - a;
    if(ba.cross(q) > 0)return 1; //ccw
    if(ba.cross(q) < 0)return -1; //cw
    if(ba.dot(q) < 0)return -2; //back
    if(ba.dot(ba) < q.dot(q))return 2; //front
    return 0; //on
  }
};

signed main(void){
  int i, j, k;
  line l;
  cin >> l.a.x >> l.a.y >> l.b.x >> l.b.y;
  int(q);
  for(;q--;){
    vec p;
    cin >> p.x >> p.y;
    int res = l.ccw(p);
    if(res == 0)puts("ON_SEGMENT");
    else if(res == 2)puts("ONLINE_FRONT");
    else if(res == -2)puts("ONLINE_BACK");
    else if(res == 1)puts("COUNTER_CLOCKWISE");
    else puts("CLOCKWISE");
  }

  return 0;
}

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

int main()
{
	//?????????
	int num1=0,num2=0,num3=0,num4=0,num5=0,num6=0;
	cin>>num1>>num2>>num3>>num4>>num5;
	if(num1<40){
		num1=40;
	}
	if(num2<40){
		num2=40;
	}
	if(num3<40){
		num3=40;
	}
	if(num4<40){
		num4=40;
	}
	if(num5<40){
		num5=40;
	}
	num6=(num1+num2+num3+num4+num5)/5;
	cout<<num6;
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_7 1000003
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n-1){
        cin>>a[i];
    }
    sort(a,a+n);
    ll sum=0;
    if(a[0]>=0){
        rep(i,1,n-1)sum+=a[i];
        sum-=a[0];
        ll k=a[0];
        cout<<sum<<endl;
        rep(i,1,n-2){
            cout<<k<<" "<<a[i]<<endl;
            k=k-a[i];
        }
        cout<<a[n-1]<<" "<<k<<endl;
    }else if(a[n-1]<=0){
        rep(i,0,n-2)sum-=a[i];
        sum+=a[n-1];
        ll k=a[n-1];
        cout<<sum<<endl;
        rep(i,0,n-2){
            cout<<k<<" "<<a[i]<<endl;
            k=k-a[i];
        }
    }else{
        rep(i,0,n-1)sum+=abs(a[i]);
        cout<<sum<<endl;
        
        ll pos=0;
        while(1){
            if(a[pos]>=0)break;
            pos++;
        }
        ll k=a[pos-1];
        rep(i,pos,n-2){
            cout<<k<<" "<<a[i]<<endl;
            k=k-a[i];
        }
        cout<<a[n-1]<<" "<<k<<endl;
        k=a[n-1]-k;
        rep(i,0,pos-2){
            cout<<k<<" "<<a[i]<<endl;
            k=k-a[i];
        }
    }
    
    return 0;
}



Measured memory_bytes: 2688
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        StringBuffer sb = new StringBuffer(n);
        if (n.equals(sb.reverse().toString() )) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#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)

using ll = long long;
#define INF 1e9

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

  if(b - a == c - b){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}


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

int main(){
  int h,w; cin >>h >>w;
  string a[h];
  rep(i,h) cin >>a[i];
  vector<bool> x(h, false);
  vector<bool> y(w, false);
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#'){
        x[i] = true;
        y[j] = true;
      }
    }
  }
  rep(i,h){
    if(x[i]==true){
      rep(j,w){
        if(y[j]==true) cout <<a[i][j];
      }
      cout << endl;
    }
  }
  return 0; 
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

int main() {
    int a,b,m;
    cin >> a >> b >> m;
    vector<int> c(a),d(b);
    for (int i = 0;i < a;++i) scanf("%d",&c[i]);
    for (int i = 0;i < b;++i) scanf("%d",&d[i]);
    int ans = *min_element(c.begin(),c.end())+*min_element(d.begin(),d.end());
    for (int i = 0;i < m;++i) {
        int x,y,e;
        scanf("%d%d%d",&x,&y,&e);x--;y--;
        ans = min(ans,c[x]+d[y]-e);
    }
    cout << ans << endl;
}

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

int main(int argc, char *argv[]) {
  int n;
  cin >> n;

  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }

  int cnt = 0;
  for (int i = 1; i < n-1; ++i) {
    if (p[i-1] > p[i] && p[i+1] < p[i]) {
      cnt++;
    } else if (p[i-1] < p[i] && p[i+1] > p[i]) {
      cnt++;
    }
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

//文字列Sのi文字目以降初めてアルファベットjが出現するindex。O(|S|*文字種)
mat next_index(string &s){
  int len = s.size();
  mat nx(len,vec(26,INF));
  REP(i,len-1) nx[i][s[i+1]-'a'] = i+1;
  RREP(i,len-1) REP(j,26) nx[i][j] = min(nx[i][j],nx[i+1][j]);
  return nx;
}

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

  string s,t;
  cin >> s >> t;

  string u = s+s;

  mat nx = next_index(u);

  int n = s.size();

  int ans = 0, now = n-1;
  REP(i,t.size()){
    int id = nx[now][t[i]-'a'];
    if(id == INF){
      cout << -1 << endl;
      return 0;
    }
    ans += id-now;
    now = id%n;
  }

  cout << ans << endl;

  return 0;
}

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

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


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
  int n;
  cin >> n;
  vector<pair<int,int>> even(110000);
  vector<pair<int,int>> odd(110000);
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    if (i % 2 == 0) even[v].FI++;
    else odd[v].FI++;
  }
  for (int i = 0;i < 110000; i++) {
    even[i].SE = i;
    odd[i].SE = i;
  }
  sort(even.begin(), even.end(), greater<pair<int,int>>());
  sort(odd.begin(), odd.end(), greater<pair<int,int>>());

  /*for(int i = 0; i < 2; i++) {
    cout << odd[i].FI << ' ' << odd[i].SE << endl;
    cout << even[i].FI << ' ' << even[i].SE << endl;
  }*/

  int oddmax[2] = {odd[0].FI, odd[1].FI};
  int oddelem[2] = {odd[0].SE, odd[1].SE};

  int evenmax[2] = {even[0].FI, even[1].FI};
  int evenelem[2] = {even[0].SE, even[1].SE};


  int ans;
  if (evenelem[0] == oddelem[0]) {
    ans = min(n - evenmax[0] - oddmax[1], n - evenmax[1] - oddmax[0]);
  } else {
    ans = n - evenmax[0] - oddmax[0];
  }
  cout << ans << endl;
  
	return 0;
}



Measured memory_bytes: 1920
n=int(input())
ans=0
l1=[]
l2=[]
for i in range(n):
    li = input().split()
    l1.append(li[0])
    l2.append(int(li[1]))
x=input()
for i in range(n):
    if l1[n-i-1]==x:
        break
    else:
        ans+=l2[n-i-1]
print(ans)

Measured memory_bytes: 3316
N, K = map(int, input().split()) 

A = list(map(int, input().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

S_possible = "POSSIBLE"
S_impossible = "IMPOSSIBLE"

if N == 1:
    if K == A[0]:
        print(S_possible)
    else:
        print(S_impossible)
else:
    gcd_max = gcd(A[0], A[1])
    for i in range(N-1):
        gcd_current = gcd(A[i], A[i+1])
        if gcd_current < gcd_max:
            gcd_max = gcd_current
    if K % gcd_max == 0 and K <= max(A):
        print(S_possible)
    else:
        print(S_impossible)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

 int main() {
   ll N;
   cin >> N;
   vector<int> A(N);
   map<int, int> card;
   rep(i, 0, N) {
     cin >> A.at(i);
     card[A.at(i)]++;
   }
   int ans = 0, cnt = 0;
   for (auto p : card) {
     if (p.second == 1) continue;
     else if (p.second % 2 == 1) ans += p.second / 2;
     else {
       ans += (p.second - 2) / 2;
       cnt++;
     }
   }
   ans += (cnt + 1) / 2;
   cout << N - ans * 2 << endl;
 }


Measured memory_bytes: 5376