akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,z,w,ans;cin>>n>>z>>w;
  lvector A(n);
  rep(i,n) cin>>A[i];
  if(n==1) ans=abs(A[n-1]-w);
  else ans=max(abs(A[n-1]-w),abs(A[n-1]-A[n-2]));
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

template<typename T>
vector<T> divisors(T n){
  vector<T> ret;

  for(T i = 1; i * i <= n; i++){
    if(n % i == 0){
      ret.emplace_back(i);
      if(i * i != n) ret.emplace_back(n / i);
    }
  }

  sort(ret.begin(), ret.end());

  return ret;
}

int main() {
  ll n; cin >> n;

  auto div = divisors(n);

  ll ans = 0LL;
  for(ll x: div){
    if(x < n / x - 1){
      ans += n / x - 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<iostream>

#define MAX		300
#define SHUFFLE		1500

using namespace std;


int main()
{
	int n;
	int kard[MAX] = {0};
	int shuffle[SHUFFLE] = {0};
	int k;

	cin >> n >> k;

	for (int i = 0; i < 2 * n; i++)
	{
		kard[i] = i + 1;
	}

	for (int i = 0; i < k; i++)
	{
		cin >> shuffle[i];
	}

	for (int i = 0; i < k; i++)
	{
		if (shuffle[i] == 0)
		{
			int *change = new int[n];
			for (int j = 0; j < n; j++)
			{
				change[j] = kard[j];
			}
			int *change2 = new int[n];
			int cnt = 0;
			for (int j = n; j < n * 2; j++)
			{
				change2[cnt] = kard[j];
				cnt++;
			}

			cnt = 0;
			for (int j = 0; j < n * 2; j += 2)
			{
				kard[j] = change[cnt];
				kard[j + 1] = change2[cnt];
				cnt++;
			}

			delete[]change;
			delete[]change2;
		}
		else
		{
			int kaisu = shuffle[i];

			int *change = new int[kaisu];

			for (int j = 0; j < kaisu; j++)
			{
				change[j] = kard[j];
			}

			int cnt = kaisu;
			for (int j = 0; j < n * 2 - kaisu; j++)
			{
				kard[j] = kard[cnt++];
			}
			cnt -= kaisu;
			for (int j = 0; j < kaisu; j++)
			{
				kard[cnt] = change[j];
				cnt++;
			}

			delete[]change;
		}
	}

	for (int i = 0; i < n * 2; i++)
	{
		cout << kard[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<long long> h(N+1, 0);
    for (int i=0; i<N; ++i) cin >> h[i];
	long long mx = 0;
    stack<int> S, T;
    for (int i=0; i<=N; ++i) {
        while (!S.empty() && h[S.top()]>=h[i]) {
            mx = max(mx, h[S.top()]*(i-T.top()-1));
            S.pop(); T.pop();
        }
		T.push(S.empty() ? -1 : S.top());
		S.push(i); 
    }
    cout << mx << endl;
}


Measured memory_bytes: 4524
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
const ll mo = 1e10 +7;
const int M = 100+50;
const ll mod = 998244353;
int main(){
	string s;
	cin>>s;
	int a=(s[0]-'0')*10+(s[1]-'0');
	int b=(s[2]-'0')*10+(s[3]-'0');
	int mark1=0,mark2=0;
	if(b>0 && b<13)
		mark1=1;
	if(a>0 && a<13)
		mark2=1;
	if(mark1 && mark2)
		cout<<"AMBIGUOUS\n";
	else if(mark1)
		cout<<"YYMM\n";
	else if(mark2)
		cout<<"MMYY\n";
	else 
		cout<<"NA\n";
	return 0;
}

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

typedef long long ll;

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

vector<int> grafo[MAXN];
ll dp[MAXN][2];
int N;

ll solve(int v,int c,int p){

	if(dp[v][c] != -1) return dp[v][c];

	ll tot = 1;
	for(int u : grafo[v]){
		if(u == p) continue;
		if(c == 0) tot = (tot * (solve(u,0,v) + solve(u,1,v))) % MOD;
		else tot = (tot * solve(u,0,v)) % MOD;
	}

	return dp[v][c] = tot;

}

int main(){

	memset(dp,-1,sizeof(dp));

	scanf("%d",&N);
	for(int i = 1;i<N;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
		grafo[v].push_back(u);
	}

	printf("%lld\n", (solve(1,0,-1) + solve(1,1,-1)) % MOD );

	return 0;

}

Measured memory_bytes: 17664
#include <cstdio>
#include <cstring>
using namespace std;

#define L 4194304
bool HA[L];
int T[256] = {0};

inline int get( unsigned char c ) {
    return T[c];
}

int main() {
    int n, sum, t, c;
    T['A'] = 1, T['C'] = 2, T['G'] = 3, T['T'] = 4;
    scanf("%d", &n);
    memset(HA,false,L);
    while ( getchar() != '\n' );
    for ( register int i = 0; i++ < n; ) {
        sum = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            sum += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[sum] = true;
        } else {
            puts( HA[sum] ? "yes" : "no" );
        }
    }
    return 0;
}

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

#define COL 101
#define ROW 11
#define UNK (1<<23)

using namespace std;

struct unknown_val{
	int val;
	pair<int,int> place;
	bool operator<(const unknown_val &t)const{
		if( place.first < t.place.first )
			return true;
		else if( place.first == t.place.first ){
			return place.second < t.place.second;
		}
		return false;
	}
};

int main(){
	bool bFirst=true;

	while(true){
		int p,s;
		int val[COL][ROW] = {{0,},};
		int unknown_cnt = 0;
		vector<unknown_val> vans;
		cin>>p;
		if(p==0)break;
		cin>>s;

		if( !bFirst )
			cout << endl;
		else
			bFirst = false;
		
		cin.ignore();
		for(int i = 0; i < p + 1; ++i){
			for(int j = 0; j < s + 1; ++j){
				//cout << i << " P: " << p << endl;
				int c = cin.peek();
				//cout << c << endl;
				if( c == '?' ){
					//cout << "true"<<endl;
					cin.ignore();cin.ignore();
					val[i][j]=UNK;
					++unknown_cnt;
				}else{
					cin>>val[i][j];
					cin.ignore();
				}
			}
		}

		while( true ){
			bool bDecreased=false;

			for(int i = 0; i < p; ++i){
				int unk_cnt = 0;
				int sum_row = 0;
				int unk_row = -1;
				for(int j = 0; j < s; ++j){
					if( val[i][j] == UNK ){
						++unk_cnt;
						unk_row = j;
					}else
						sum_row += val[i][j];
				}
				if( unk_cnt == 1 ){
					val[i][ unk_row ] = val[i][s] - sum_row;
					unknown_val t;
					t.place = make_pair( i, unk_row );
					t.val = val[i][unk_row];
					vans.push_back( t );
					bDecreased=true;
				}
			}

			for(int i = 0; i < s; ++i){
				int unk_cnt = 0;
				int sum_col = 0;
				int unk_col = -1;
				for(int j = 0; j < p; ++j){
					if( val[j][i] == UNK ){
						++unk_cnt;
						unk_col = j;
					}else
						sum_col += val[j][i];
				}
				if( unk_cnt == 1 ){
					val[ unk_col ][ i ] = val[p][i] - sum_col;
					unknown_val t;
					t.place = make_pair( unk_col, i );
					t.val = val[unk_col][i];
					vans.push_back( t );
					bDecreased=true;
				}
			}

			if( !bDecreased )
				break;
		}

		if( vans.size() == unknown_cnt ){
			sort( vans.begin(), vans.end() );
			for(unsigned int i = 0; i < vans.size(); ++i){
				cout << vans[i].val << endl;
			}
		}else
			cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
  int a[3];
  int b[3];
  int c[3][3];

  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      cin >> c[i][j];

  for (int i1 = 0; i1 < 101; i1++)
  {
    for (int i2 = 0; i2 < 101; i2++)
    {
      for (int i3 = 0; i3 < 101; i3++)
      {
        a[0] = i1;
        a[1] = i2;
        a[2] = i3;

        b[0] = c[0][0] - a[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0];

        int cnt = 0;
        for (int i = 0; i < 3; i++)
          for (int j = 0; j < 3; j++)
          {
            if (c[i][j] == a[i] + b[j]) cnt++;
          }

        if (cnt == 9)
        {
          cout << "Yes\n";
          return 0;
        }

      }
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

string in;
int pos;


main(){
  int n;
  cin>>n;
  cin.ignore();
  while(n--){
    pos=0;
    getline(cin,in);
    int t;
    cin>>t;
    cin.ignore();
    while(t--){
      string com;
      getline(cin,com);
      if(com=="forward char")pos=min(pos+1,(int)in.size());
      else if(com=="backward char")pos=max(0,pos-1);
      else if(com=="forward word"){
	while(pos<in.size() && in[pos]==' ')++pos;
	while(pos<in.size() && in[pos]!=' ')++pos;
      }else if(com=="backward word"){
	while(pos && in[pos-1]==' ')--pos;
	while(pos && in[pos-1]!=' ')--pos;
      }else if(com[0]=='i'){
	in.insert(pos,com.substr(8,com.size()-9));
	pos+=com.size()-9;
      }else if(com=="delete char"){
	if(pos<in.size())in.erase(pos,1);
      }else if(com=="delete word"){
	int sz=0;
	while(pos+sz<in.size() && in[pos+sz]==' ')++sz;
	if(pos+sz==in.size())continue;
	while(pos+sz<in.size() && in[pos+sz]!=' ')++sz;
	in.erase(pos,sz);
      }
    }
    rep(i,in.size()){
      if(i==pos)cout<<'^';
      cout<<in[i];
    }
    if(pos==in.size())cout<<'^';
    cout<<endl;
  }
}

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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

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

    string ans;
    if(R < 1200) {
        ans = "ABC";
    } else if(R < 2800) {
        ans = "ARC";
    } else {
        ans = "AGC";
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3652
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

std::string s;

int main(){
	std::cin >> s;
	long cnt = 0;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'x'){
			cnt++;
		}
	}
	if(cnt >= 8){
		printf("NO\n");
	}else{
		printf("YES\n");
	}
}


Measured memory_bytes: 888
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    
    r = int(input())
    print(3*(r**2))

if __name__ == "__main__":
    main()

Measured memory_bytes: 5324
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

void cnt(ll a, ll p, ll &c, const vvll &e){
    c++;
    for(auto x: e[a]){
        if(x == p){
            continue;
        }
        cnt(x, a, c, e);
    }
}

bool gl(ll a, ll p, ll g, const vvll &e, vll &r){
    if(a == g){
        return true;
    }
    if(sz(e[a]) == 1&&p != INF){
        return false;
    }
    bool b = false;
    for(auto x: e[a]){
        if(x == p){
            continue;
        }
        if(gl(x, a, g, e, r)){
            r.emplace_back(x);
            b = true;
        }
    }
    return b;
}


int main(){
    ll N; cin >> N;
    vvll e(N, vll(0));
    rep(i, 0, N-1){
        ll a, b; cin >> a >> b;
        a--; b--;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    ll s = 0, f = 0;
    vll route(0);
    gl(0, INF, N-1, e, route);
    route.emplace_back(0);
    reverse(all(route));
    ll n = sz(route);
    ll sn, fn;
    if(n%2 == 0){
        fn = route[n/2-1];
        sn = route[n/2];
    }else{
        fn = route[n/2];
        sn = route[n/2+1];
    }
    //prt(fn); prt(" "); prtl(sn);
    cnt(fn, sn, f, e);
    cnt(sn, fn, s, e);
    //prtl(s); prtl(f);
    if(s > f){
        prtl("Snuke");
    }else if(s == f){
        prtl("Snuke");
    }else{
        prtl("Fennec");
    }
}



Measured memory_bytes: 20584
n=int(input())
#n,m=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

dic={}

for i in range(n):
    s=input()
    dic[s]=dic.get(s,0)+1

mx=max(dic.values())
ansl=[]
for k, v in dic.items():
    if v==mx:
        ansl.append(k)

ansl.sort()

for st in ansl:
    print(st)



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

public class Main {

    static int N;
    static int M;
    static Edge[] E;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        E = new Edge[M];
        for (int i = 0; i < M; i++) {
            E[i] = new Edge(sc.nextInt()-1, sc.nextInt()-1);
        }

        System.out.println( solve() ? "YES" : "NO" );
    }

    static class Edge {
        int a;
        int b;

        public Edge(int a, int b) {
            this.a = a;
            this.b = b;
        }
    }

    static boolean solve() {
        int[] T = new int[N];
        for (Edge e : E) {
            T[e.a]++;
            T[e.b]++;
        }

        for (int t : T) {
            if( t % 2 == 1 ) return false;
        }
        return true;
    }

    @SuppressWarnings("unused")
    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 44524
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

N = int(input())
left = list(map(int,input().split()))
middle = list(map(int,input().split()))

ans = []
def dfs(p,end,L,R):
    #print("p: {},end: {},L: {},R: {}".format(p,end,L,R))
    if end == p + 1:
        ans.append(left[p])
        return
    for i in range(L,R):
        if middle[i] == left[p]:
            idx = i
            break
    if idx != L:
        dfs(p + 1,p + idx - L + 1,L,idx)
    if idx != R - 1:
        dfs(p + idx - L + 1,end,idx + 1,R)
    ans.append(left[p])
dfs(0,N,0,N)
print(' '.join(map(str,ans)))


Measured memory_bytes: 5604
/* ~ CoderMehraJ ~ */
#include <bits/stdc++.h>
using namespace std;

#define show(x) cout << #x << " = " << x << '\n';

long long hehe(int a){
    if(a<2) return 0;
    long long b;
    if(a%2) {
        b=((a-1)/2);
        b*=a;
    }
    else {
        b=(a/2);
        b*=(a-1);
    }
    return b;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int ar[n];
    map < int , int > mp;
    map < int , long long > ans;
    unsigned long long anss;
    for(int i=0;i<n;i++) {
        cin>>ar[i];
        mp[ar[i]]++;
    }
    for(auto x: mp) anss+=hehe(x.second);
        
    for(int i=0;i<n;i++){
        cout<<anss-hehe(mp[ar[i]])+hehe(mp[ar[i]]-1)<<"\n";
    }
    return 0;
}
//fixed<<setprecision(1)


Measured memory_bytes: 8320
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
int main(){
	//freopen("in","r",stdin);
	int W=read(),H=read(),x=read(),y=read();
	printf("%.9lf ",1.0*W*H/2);
	if(!(W&1)&&x==W/2&&!(H&1)&&y==H/2)
		puts("1");
	else
		puts("0");
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define db(x) cout<<#x<<"="<<x<<endl;
using namespace std;
struct edge {
	int to,nxt;
} e[N];
struct node {
	int x,p,v;
	bool operator <(const node &b)const {
		return v>b.v;
	}
}now;
priority_queue<node>q;
int n,m,s,t;
int head[N];
int dis[N][3];
void link(int s,int t,int n) {
	e[n]=(edge)<%t,head[s]%>;
	head[s]=n;
}
int main() {
	memset(dis,-1,sizeof(dis));
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; i++) {
		scanf("%d%d",&s,&t);
		link(s,t,i);
	}
	scanf("%d%d",&s,&t);
	q.push((node)<%s,0,0%>),dis[s][0]=0;
	while(!q.empty()) {
		while(!q.empty()&&dis[q.top().x][q.top().p]<q.top().v)q.pop();
		if(q.empty())break;
		now=q.top(),q.pop();
//		printf("x=%d %d\n",now.x,now.p);
		for(int i=head[now.x]; i; i=e[i].nxt) {
			int to=e[i].to;
			if(dis[to][(now.p+1)%3]==-1||dis[to][(now.p+1)%3]>dis[now.x][now.p]+(now.p==2)) {
//				printf("	%d %d %d\n",to,(now.p+1)%3,dis[to][(now.p+1)%3]);
				dis[to][(now.p+1)%3]=dis[now.x][now.p]+(now.p==2);
				q.push((node)<%to,(now.p+1)%3,dis[to][(now.p+1)%3]%>);
			}
		}
	}
	printf("%d\n",dis[t][0]);
	return 0;
}


Measured memory_bytes: 4088
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
  int a,b,c,k;
  int ans;
  cin>>a>>b>>c>>k;
  if(k&1)ans=b-a;
  else ans=a-b;
  if(abs(a-b)>1e18)cout<<"Unfair";
  else cout<<ans<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}

Measured memory_bytes: 256
N = int(input())

dp = [N for i in range(N+1)]

pow6 = [6**i for i in range(1,8)]
pow9 = [9**i for i in range(1,7)]

#print(pow6)
#print(pow9)
dp[0] = 0
for i in range(N+1):
    dp[i] = min(dp[i], dp[i-1]+1)
    for j in pow6:
        if i-j>=0:
            dp[i] = min(dp[i], dp[i-j] + 1)
    for j in pow9:
        if i-j>=0:
            dp[i] = min(dp[i], dp[i-j] + 1)

#print(dp)
print(dp[-1])


Measured memory_bytes: 9676
#include<iostream>
using namespace std;
int main() {

	int A[3];
	cin >> A[0] >> A[1] >> A[2];

	int cnt5=0, cnt7=0;
	for (int i = 0; i < 3; i++) {
		if (A[i] == 5) cnt5++;
		else if (A[i] == 7) cnt7++;
	}

	if (cnt5 == 2 && cnt7 == 1) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 998244353
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 1000000000000000000
#define vll vector<ll>
using namespace std;
const int N=1000005;

void solve()
{
	ll n,k;
	cin>>n>>k;
	cout<<n-k+1;

	
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 256
S= input()
List=list(S)
mid=int(List[0])
opList = ["+"]*3
res="a"
# 010 なら2番目のみ派閥 
for bits in range(2**3): 
  for j in range(3):
    if((bits>>j) & 1):
      opList[j] = "+"
      mid = mid + int(List[j+1])
    else:
      opList[j] = "-"
      mid = mid - int(List[j+1])
  if mid == 7:
    res = List[0]+opList[0]+List[1]+opList[1]+List[2]+opList[2]+List[3]+"=7"
    break
  else:
    mid = int(List[0])
    opList = ["+"]*3
print(res)

Measured memory_bytes: 9200
def solve
    n, m = gets.split.map!(&:to_i)
    a = gets.split.map!(&:to_i)
    ans = 0
    (0..m-1).each do |i|
        ans += a[i]
    end

    if n - ans >= 0
        print n - ans
    else
        print -1
    end
end
solve

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  deque<char> que;
  string s;
  cin >> s;
  rep(i,sz(s)) {
    if(s[i] != 'B') {
      que.push_back(s[i]);
    }
    else {
      if(!que.empty()) {
        que.pop_back();
      }
    }
  }
  while(sz(que)) {
    char ans = que.front(); que.pop_front();
    cout << ans;
  }

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100010, P = 998244353;

int n;
char s[N * 3];
int c1[3], c2[3][3];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  scanf("%d%s", &n, s + 1);
  int ans = 1;
  for (int i = 1; i <= n; ++i) ans = ans * (ll)i % P;
  for (int i = 1; i <= n * 3; ++i) {
    int v = s[i] == 'R' ? 0 : s[i] == 'G' ? 1 : 2, v1 = (v + 1) % 3, v2 = (v + 2) % 3;
    if (v1 > v2) swap(v1, v2);
    if (c2[v1][v2])
      ans = ans * (ll)(c2[v1][v2]--) % P;
    else if (c1[v1]) {
      ans = ans * (ll)(c1[v1]--) % P;
      ++c2[min(v1, v)][max(v1, v)];
    } else if (c1[v2]) {
      ans = ans * (ll)(c1[v2]--) % P;
      ++c2[min(v2, v)][max(v2, v)];
    } else
      ++c1[v];
  }
  printf("%d\n", ans);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long LL;
LL A[100010], B[100010];

int main () {
        ios::sync_with_stdio(false);
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)    cin >> A[i] >> B[i];
        LL ans = 0;
        for (int i = n; i >= 1; i--) {
                if ((A[i] + ans) % B[i] != 0) {
                        ans = ans + B[i] - ((A[i] + ans) % B[i]);
                }
        }
        cout << ans << endl;
        return 0;
}


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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod			1000000007
#define inf			1e18
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int r, c, k;
	cin >> r >> c >> k;

	vector<vector<int>> v(r + 1, vector<int> (c + 1));
	vector<vector<vector<int>>> dp(r + 1, vector<vector<int>> (c + 1, vector<int> (3, 0)));

	for (int i = 0; i < k; i++) {
		int x, y, val;
		cin >> x >> y >> val;
		v[x][y] = val;
	}

	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) {
			dp[i][j][0] = max({dp[i][j - 1][0], dp[i - 1][j][2] + v[i][j]});
			dp[i][j][1] = max({dp[i][j - 1][0] + v[i][j], dp[i][j - 1][1], dp[i - 1][j][2] + v[i][j]});
			dp[i][j][2] = max({dp[i][j - 1][1] + v[i][j], dp[i][j - 1][2], dp[i - 1][j][2] + v[i][j]});
		}
	}

	cout << dp[r][c][2];

	return 0;
}

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

int main(){
  int x,y;
  cin >> x >> y;
  if(x==1 || x==3 || x==5 || x==7 || x==8 || x== 10 ){
    if(y==3 || y==5 || y==7 || y==8 || y==10 || y==12){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else if(x==4 || x==6 || x==9 ){
    if(y==6 || y==9 || y==11){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    ll ans = 0;
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += (int)(lower_bound(a.begin(), a.end(), a[i] + a[j])-a.begin()) - j - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
vector<pi>ans;
pi stk[123];
int main()
{
	int n;scanf("%d",&n);
	int cc=n/2;
	if(n%2==0){
		for(int i=0;i<n/2;i++)stk[i]={i+1,n-i};
	}else{
		for(int i=0;i<n/2;i++)stk[i]={i+1,n-1-i};
		stk[n/2]={n,-1};cc++;
	}
	for(int i=0;i<cc;i++){
		pi g=stk[i],g1=stk[(i+1)%cc];
		if(g.first!=-1){
			if(g1.first!=-1)ans.push_back({g.first,g1.first});
			if(g1.second!=-1)ans.push_back({g.first,g1.second});
		}
		if(g.second!=-1){
			if(g1.first!=-1)ans.push_back({g.second,g1.first});
			if(g1.second!=-1)ans.push_back({g.second,g1.second});
		}
	}int len=ans.size();
	if(cc==2)len/=2;
	cout<<len<<'\n';
	for(int i=0;i<len;i++)cout<<ans[i].first<<' '<<ans[i].second<<'\n';
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  int d,g; cin >> d >> g;
  vi p(d),c(d); rep(i,d) cin >> p[i] >> c[i];

  int ans = inf;
  rep(i,1<<d){ // 埋める難易度
    int ac = 0, score = 0;
    rep(j,d) if(i & (1<<j)){ // 埋める
      ac += p[j];
      score += (j+1)*100*p[j] + c[j];
    }
    dump(ac,score);

    // 足りなければ残りの内1番高い問題をできるだけ解く(埋めてはいけない)
    if(score < g)
      ROF(j,d,0){
	if(not (i & (1<<j))){ // 残りの内1番高い問題
	  int need = (g - score + (j+1)*100 - 1) / ((j+1)*100); // 必要問題数
	  if(need > p[j] - 1) // 無理
	    ac = inf;
	  else{ // 可能
	    ac += need;
	  }
	  break;
 	}
      }
    dump(ac);
    ans = min(ans, ac);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
	int a, b; cin >> a >> b;
	if (b%a == 0)cout << a + b << endl;
	else cout << b - a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll m = 13, d[N][15];
string s;
int main()
{
	int i, j, k, t = 1;
	cin >> s;
	d[s.size()][0] = 1;
	for (i = s.size() - 1; i >= 0; i--, t = t * 10 % m) {
		if (s[i] == '?') {
			for (j = 0; j <= 9; j++) {
				for (k = 0; k < 13; k++) {
					d[i][(k + j * t) % m] = (d[i][(k + j * t) % m] + d[i + 1][k]) % M;
				}
			}
		} else {
			for (j = 0; j < 13; j++)
				d[i][(j + t * (s[i] - '0')) % m] = (d[i][(j + t * (s[i] - '0')) % m] + d[i + 1][j]) % M;
		}
	}
    cout << d[0][5] << endl;
    return 0;
}

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

int main() {
  int n;
  string s;
  cin>>n>>s;
  int ans = 0;
  rep(i,1000) {
    string t;
    int x = i;
    rep(j,3) {
      t += '0'+x%10;
      x /= 10;
    }
    int ti = 0;
    rep(j,n) {
      if (s[j] == t[ti]) {
        ++ti;
        if (ti == 3) {
          break;
        }
      }
    }
    if (ti == 3) {
      ans ++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,a[N],tr[N<<2],ans[N];
vector<int>e[N],v;
void update(int k,int l,int r,int x,int v)
{
	if(l==r)
	{
		tr[k]=v;
		return;
	}
	int mid=l+r>>1;
	if(x<=mid) update(k<<1,l,mid,x,v);
	else update(k<<1|1,mid+1,r,x,v);
	tr[k]=max(tr[k<<1],tr[k<<1|1]);
}
int query(int k,int l,int r,int a,int b)
{
	if(a>b)
		return 0;
	if(l==a&&r==b)
		return tr[k];
	int mid=l+r>>1;
	if(b<=mid) return query(k<<1,l,mid,a,b);
	else if(a>mid) return query(k<<1|1,mid+1,r,a,b);
	else return max(query(k<<1,l,mid,a,mid),query(k<<1|1,mid+1,r,mid+1,b));
}
void dfs(int u,int f)
{
	int x=a[u];
	int zh=query(1,1,n,x,x),k=query(1,1,n,1,x-1);
	update(1,1,n,x,k+1);
	ans[u]=query(1,1,n,1,n);
	for(auto v:e[u])
		if(v!=f)
			dfs(v,u);
	update(1,1,n,x,zh);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		v.push_back(a[i]);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=1;i<=n;i++)
		a[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin()+1;
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 28216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        System.out.println(z + " " + x + " " + y);
    }
}

Measured memory_bytes: 21204
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int w=0,h=0,ww=sc.nextInt(),hh=sc.nextInt(),n=sc.nextInt();
		for(int i=0;i<n;i++) {
			int x=sc.nextInt(),y=sc.nextInt(),a=sc.nextInt();
			if(a==1&&w<x)w=x;
			if(a==2&&x<ww)ww=x;
			if(a==3&&h<y)h=y;
			if(a==4&&y<hh)hh=y;
		}
		System.out.println(w<ww&&h<hh?(ww-w)*(hh-h):0);
		sc.close();
	}
}

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

using namespace std;

int main() {

    string N; cin >> N;
    int first = N.at(0) - '0';
    int second = N.at(1) - '0';
    int third = N.at(2) - '0';

    if(second > first) {
        char a = (char)first+1 + '0';
        string ans = "";
        ans += a;
        ans += a;
        ans += a;
        cout << ans << endl;
        return 0;
    }

    if(second == first && second < third) {
        char a = (char)first+1 + '0';
        string ans = "";
        ans += a;
        ans += a;
        ans += a;
        cout << ans << endl;
        return 0;
    }

    string ans = "";
    ans += N.at(0);
    ans += N.at(0);
    ans += N.at(0);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

constexpr ll mod = 1e9 + 7;

constexpr int kMaxF = 2e5 + 17;

ll powmod(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) {
      res = res * a % mod;
    }
    a = a * a % mod;
    b /= 2;
  }
  return res;
}

ll f[kMaxF];
ll fi[kMaxF];

ll C(int n, int k) {
  if (k > n) {
    return 0LL;
  }
  return f[n] * fi[k] % mod * fi[n - k] % mod;
}

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

  f[0] = fi[0] = 1;
  for (int i = 1; i < kMaxF; ++i) {
    f[i] = f[i - 1] * i % mod;
    fi[i] = fi[i - 1] * powmod(i, mod - 2) % mod;
  }

  int h, w, n;
  cin >> h >> w >> n;

  vector<array<ll, 3>> nodes;
  nodes.reserve(n + 1);
  
  for (int i = 0; i < n; ++i) {
    int r, c;
    cin >> r >> c;
    nodes.push_back({r - 1, c - 1, 0});
  }
  nodes.push_back({h - 1, w - 1, 0});
  sort(nodes.begin(), nodes.end());

  for (int i = 0; i < nodes.size(); ++i) {
    int r = nodes[i][0], c = nodes[i][1];
    nodes[i][2] = C(r + c, r);
    for (int j = 0; j < i; ++j) {
      if (nodes[j][1] <= c) {
        int rr = nodes[j][0], cc = nodes[j][1];
        nodes[i][2] = (nodes[i][2] - nodes[j][2] * C(r + c - rr - cc, r - rr)) % mod;
      }
    }
    nodes[i][2] = (nodes[i][2] + mod) % mod;
  }

  cout << nodes.back()[2] << '\n';

  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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;}
int const INF = 1 << 30;


int main()
{
    int n;
    cin >> n;
    vector<int> t(n),v(n);
    vector<int> st(n+1,0);
    rep(i,n) {
        cin >> t[i]; t[i] *= 2;
        st[i+1] = st[i] + t[i];
    }
    rep(i,n) {
        cin >> v[i]; v[i] *= 2;
    }

    int T = st[n];//終着時刻
    vector<int> lim(T+1,INF);
    lim[0] = 0, lim[T] = 0;
    rep(i,n) {
        for(int j = st[i]; j <= st[i+1]; ++j) {
            chmin(lim[j],v[i]);
        }
    }

    for(int i = T; i > 0; --i) {
        chmin(lim[i-1],lim[i]+1);
    }

    //条件はact[i] <= lim[i]のみ
    vector<int> act(T+1,0);
    for(int i = 0; i < T; ++i) {
        act[i+1] = min(act[i]+1, lim[i+1]);
    }

    ll res = 0;
    for(int i = 1; i < T; ++i) {
        res += 2*act[i];
    }
    cout << fixed << setprecision(10) << (double)res/(4*2) << endl;
    return 0;
}

Measured memory_bytes: 3976
#include <stdio.h>
int main(void) {
	char s[4], t[4];
	int count = 0;

	scanf("%s", s);
	scanf("%s", t);

	if (s[0] == t[0])
		count++;
	if (s[1] == t[1])
		count++;
	if (s[2] == t[2])
		count++;

	printf("%d", count);

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define REP(i,n) for (int i = 0; i < n; ++i)

const int MAX = 1e5+10;

int N, M;
ll K;
ll X[MAX];

vi mult(vi a, vi b) {
    int n = a.size();
    vi res(n);
    REP (i, n) res[i] = b[a[i]];
    return res;
}

vi swap(vi ord, ll k) {
    int n = ord.size();
    vi res(n);
    REP (i, n) res[i] = i;

    while (k) {
        if (k&1) res = mult(res, ord);
        ord = mult(ord, ord);
        k >>= 1;
    }
    return res;
}

int main() {
    cin >> N;
    REP (i, N) cin >> X[i];

    cin >> M >> K;
    vi ord(N-1);
    REP (i, N-1) ord[i] = i;
    REP (_, M) {
        int a;
        cin >> a;
        int k = ord[a-2];
        ord[a-2] = ord[a-1];
        ord[a-1] = k;
    }

    ord = swap(ord, K);
    ll x = X[0];
    REP (i, N-1) {
        cout << x << "\n";
        x += X[ord[i]+1] - X[ord[i]];
    }
    cout << x << endl;
}

Measured memory_bytes: 3424
#!/usr/bin/env python3
import sys
from itertools import chain


def solve(S: str, T: str):
    answer = sum([s != t for s, t in zip(S, T)])
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    answer = solve(S, T)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10968
#nが小さいので全部試せる
n,k = map(int,input().split( ))
d= set(input().split( ))
ans = n

while True:
    tmp = set(str(ans))
    flag = True
    for e in tmp:
        if e in d:
            flag = False
            ans += 1
            break
    if flag:
        break

print(ans)
    
    

Measured memory_bytes: 40684
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
w=input()
#N = 3
#x=[]
#y=[]
#t, x, y = [0]*(N+1), [0]*(N+1), [0]*(N+1)#N+1個の空のリストを作成(原点を入れて##るから一つ増える)
#delta_t=0
#delta_x=0
#delta_y=0
#l=0
#t[0],x[0],y[0]=[0, 0, 0]
#とりあえず入力までは完成した．
#for i in range(N):
# t[i+1], x[i+1], y[i+1] = map(int, input().split())
w_len=len(w)
w_list=list(w)
#print(len(w_list))
#print(w_list)
i=0
j=0
k=0
alphabet="abcdefghijklmnopqrstuvwxyz"
alphabet_list=list(alphabet)
#print(alphabet_list)
for i in range(26):
 k=0
 for j in range(w_len):
    #print(i)
    #print(j)
    if w_list[j]==alphabet_list[i]:
        k=k+1
    else:
        pass
 #print(k)
 if k%2 ==0:
     pass
 else:
     print("No")
     sys.exit()
print("Yes")    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

signed main()
{
   int N; cin >> N;
   V<int> a(N); REP(i, N) cin >> a[i];

   SORT(a);
   int MIN = a[0];

   V<int> b(N);
   int sum = 0;
   REP(i, N) {
      int p = (a[i] - MIN) / (N+1);
      int q = (a[i] - MIN) % (N+1);
      // a = p(N+1) + q + MIN
      sum += p;
      b[i] = q + MIN;
   }

   REP(i, N) {
      b[i] += sum;
   }
   // b: after sum operations

   SORT(b);
   int d = b[0] - N;
   if (d > 0) {
      REP(i, N) {
         b[i] -= d;
      }
      sum += d*N;
   }
   // b: after sum  operations

   while (b[N-1] >= N) {
      b[N-1] -= N;
      REP(i, N-1) {
         b[i] += 1;
      }
      sum += 1;
      SORT(b);
   }
   cout << sum << endl;

   return 0;
}

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

typedef long long ll;
int p[20000];
int r[20000];

void init(int n){
    for(int i=0;i<n;i++){
        p[i] = i;
        r[i] = 0;
    }
}

int find(int i){
    if(p[i]==i)return i;
    return p[i] = find(p[i]);
}
void unite(int a,int b){
    int x = find(a);
    int y = find(b);
    if(x==y)return ;
    if(r[x]<r[y]){
        p[x] = y;
        
    }else{
        p[y] = x;
        if(r[x]==r[y])r[x]++;
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<ll,pair<int,int> > > g;
    for(int i=0;i<m;i++){
        int s,t;
        ll d;
        cin >> s >> t >> d;
        g.push_back(make_pair(d,make_pair(s,t)));
    }
    sort(g.begin(),g.end());
    init(n);
    ll ans = 0;
    for(int i=0;i<m;i++){
        int s,t;
        s = g[i].second.first;
        t = g[i].second.second;
        if(find(s)!=find(t)){
            ans += g[i].first;
            unite(s,t);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4924
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;


int T[110000];

int main(){
    int N,C,s,t,c;
    cin>>N>>C;
    vector<P> V[40],A[40];
    for(int i=0;i<N;i++){
        cin>>s>>t>>c;
        V[c].push_back(P(s,t));
    }
    for(int i=1;i<=C;i++){
        sort(V[i].begin(),V[i].end());
    }
    for(int i=1;i<=C;i++){
        s=0;
        V[i].push_back(P(110000,110000));
        for(int j=0;j<(int)V[i].size();j++){
            if(j==0){
                s=V[i][j].first;
                t=V[i][j].second;
            }else if(t==V[i][j].first) t=V[i][j].second;
            else{
                A[i].push_back(P(s,t));
                s=V[i][j].first;
                t=V[i][j].second;
            }
        }
    }
    for(int i=1;i<=C;i++){
        for(int j=0;j<(int)A[i].size();j++){
            T[A[i][j].first-1]++;
            T[A[i][j].second]--;
            //cout<<i<<" "<<j<<" "<<V[i][j].first-1<<" "<<V[i][j].second<<endl;
        }
    }
    int temp=0,ans=0;
    for(int i=0;i<110000;i++){
        temp+=T[i];
        ans=max(ans,temp);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 2816