akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

string numstring(int i);

int main(){
  int m,n;

  while(1){
    cin >> m >> n;
    if(m == 0 && n == 0) break;


    vector<int> v;
    for(int i = 1;i <= m;i++) v.push_back(i);
    int pn = 0;

    string str[10000];
    for(int i = 0;i < n;i++){
      cin >> str[i];
    }

    for(int i = 1;i <= n;i++){
      string s;
      s = str[i-1];
      string ans;
      if(i % 3 == 0 && i % 5 == 0){
        ans = "FizzBuzz";
      }else if(i % 3 == 0){
        ans = "Fizz";
      }else if(i % 5 == 0){
        ans = "Buzz";
      }else{
        ans = numstring(i);
      }

      if(s == ans){
        pn = (pn + 1) % v.size();
      }else{
        v.erase(v.begin() + pn);
        if(pn == v.size()) pn = 0;
      }
      if(v.size() == 1) break;
    }

    for(int i = 0;i < v.size();i++){
      cout << v[i];
      if(i != v.size()-1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}


char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };

string numstring(int i){
  string ans;
  while(i > 0){
    ans.insert(ans.begin(),nums[i%10]);
    i = i/10;
  }

  return ans;
}




Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll n,ans=0;
  cin>>n;
  ll a[n];
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n-1){
    if(a[i]%2==1 && a[i+1]!=0){
      a[i]-=1;
      a[i+1]-=1;
      ans++;
    }
  }
  rep(i,n){
    ans+=a[i]/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
import std;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
  int n = scan!int;
  long k = scan!long;
  long[] as = scan!long(n);
  long[] bs = as.map!(x => (x - 1) % k).array;
  long[] sums = [0];
  foreach(b; bs) sums ~= (sums[$ - 1] + b) % k;
  log("as:", as);
  log("bs:", bs);
  log("sums:", sums);
  
  long ans = 0;
  long[long] cnt;
  foreach(i; 0 .. n + 1){
    if(i >= k) cnt[sums[i - k]] -= 1;
    long s = sums[i];
    if(s !in cnt) cnt[s] = 0;
    ans += cnt[s];
    cnt[s] += 1;
    log("i:", i, "s:", s, "cnt:", cnt, "ans:", ans);
  }
  
  ans.writeln;
}

Measured memory_bytes: 30052
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m;
vi adj[N];
int h[N];

void input()
{
	cin >> n >> m;
	FOR (i, 1, n) cin >> h[i];
	FOR (i, 1, m)
	{
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	input();
	int ans = 0;
	
	FOR (i, 1, n)
	{
	    int cnt = 0;
	    for (int j: adj[i])
	        if (h[i] > h[j]) cnt++;
	    
	    if (cnt == sz(adj[i])) ans++;
	}
	print(ans);
}





















Measured memory_bytes: 12604
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
if sum(A) <= K:
  print(0)
  exit()
A.sort()
F.sort(reverse=True)

l,r = -1,10**12+1

while r-l > 1:
  m = (l+r)//2

  k = 0
  for i in range(N):
    a,f = A[i], F[i]
    k += max(0,a-(m//f))

  if k <= K:
    r = m
  else:
    l = m

print(r)

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 110000, maxm = 210000;
const int inf = 1000000000;
vector<pii> e[maxn]; // e[v] = list of (neighbour, id)
int w[maxm]; // initially inf
int col[maxn]; // -1 = uncolored, 0 = black, 1 = white
int d[maxn];

void dfs(int v, int c) {
    col[v] = c;
    for (pii edge: e[v]) {
        int u = edge.first;
        if (d[v] != d[u]) continue;
        if (col[u] != -1) continue;
        w[edge.second] = d[v];
        dfs(u, c ^ 1);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, m;
    cin >> n >> m;
    forn(i, n) cin >> d[i];
    forn(i, m) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        e[u].push_back({v, i});
        e[v].push_back({u, i});
    }

    forn(i, m) w[i] = inf;
    forn(i, n) col[i] = -1;

    vi ord(n);
    iota(all(ord), 0);
    sort(all(ord), [&](int v, int u){return d[v] < d[u];});

    bool ok = true;
    for (int v: ord) {
        bool isNeigh = false;
        for (pii edge: e[v]) {
            int u = edge.first;
            if (d[u] == d[v]) isNeigh = true;
        }
        if (isNeigh) {
            if (col[v] != -1) continue;
            dfs(v, 0);
        } else {
            pii smallerEdge = {-1, -1};
            for (pii edge: e[v]) {
                int u = edge.first;
                if (d[u] < d[v]) smallerEdge = edge;
            }
            if (smallerEdge.first == -1) {
                ok = false;
                break;
            }
            int u = smallerEdge.first;
            col[v] = col[u];
            w[smallerEdge.second] = d[v] - d[u];
        }
    }

    if (!ok) cout << -1 << '\n';
    else {
        forn(i, n) cout << "BW"[col[i]];
        cout << '\n';

        forn(i, m) cout << w[i] << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 13056
def main():
    import sys
    n, k, *a = map(int, sys.stdin.read().split())
    a = [0] + a
    check = [0] * (n + 1)
    check[1] = 1

    i = 0
    nw = 1
    path = [1]
    while 1:
        nx = a[nw]
        i += 1
        if i == k:
            print(nx)
            break
        if check[nx]:
            j = path.index(nx)
            d = j + (k - i) % (i - j)
            print(path[d])
            break
        path.append(nx)
        check[nx] = 1
        nw = nx


if __name__ == '__main__':
    main()


Measured memory_bytes: 32516
#include<iostream>
using namespace std;
int box[]={0,1,2,3,5,7,8,9};
void oct(int x){
	int a=x%8;
	if(x/8!=0)
	oct(x/8);
	cout<<box[a];
}
int main(){
	int n;
	while(cin>>n,n){
		oct(n);
		cout<<endl;
	}
	return 0;
}

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

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int k = sc.nextInt();

		if(a < b){
			int temp = a;
			a = b;
			b = temp;
		}

		if(a < c){
			int temp = a;
			a = c;
			c = temp;	
		}

		int maxSum = a;
		for(int i=1; i<=k; i++){
			maxSum = maxSum * 2;
		}

		maxSum += b;
		maxSum += c;

		System.out.println(maxSum);
		
	}
}


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

A = []
for i in range(20):
    if 6**i<=N:
        A.append(6**i)
for i in range(1,20):
    if 9**i<=N:
        A.append(9**i)
AA = sorted(A,reverse=True)
#print(AA)
        
INF = float("inf")
dp=[INF]*(N+1)
dp[0]=0

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

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

int main() {
  vector<int> vec{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout  << vec.at(K-1) <<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      int n = Integer.parseInt(in.readLine());
      String[] lns = in.readLine().split(" ");
      int t = Integer.parseInt(lns[0]);
      int a = Integer.parseInt(lns[1]);
      int[] h = new int[n];

      String line = in.readLine();
      char regex = ' ';
      boolean isContinue = true;
      for(int i=0, offset=0,next=0; isContinue; offset = ++next) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        h[i++] = Integer.parseInt(line.substring(offset,next));
      }

      int ans=0;
      long tmp = 0;
      long min = Long.MAX_VALUE;
      for(int i=0; i<n; i++) {
        tmp = Math.abs( a*1000 - (t*1000 - (h[i] * 6)) );
        if(tmp < min ) {
          ans = i+1;
          min = tmp;
        }
      }
      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
vector<vector<int>> tree;
vector<bool> used;
vector<vector<int>> dp;
void treeDP(int i){
    used[i]=true;
    dp[i][0]=1;dp[i][1]=1;
    for(auto e:tree[i]){
        if(used[e]) continue;
        treeDP(e);
        dp[i][0] *= dp[e][0] + dp[e][1];
        dp[i][1] *= dp[e][0];
        dp[i][0] %= mod;
        dp[i][1] %= mod;
    }
    used[i]=false;
    return ;
}
signed main(){
    int N;cin>>N;
    tree.resize(N);
    used.resize(N,false);
    dp.resize(N,vector<int>(2,0));
    REP(i,N-1){
        int a,b; cin>>a>>b;
        a--;b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    treeDP(0);
    cout<<(dp[0][0]+dp[0][1])%mod<<endl;
}


Measured memory_bytes: 18176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();

		long a = n % k;
		long ans = Math.min(a, k -a);

		System.out.println(ans);

	}

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int count=0;
  for(int i=0;i<s.length();++i)
    if(s[i]!=t[i])
      count++;
  cout<<count;
  return 0;
}
  


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

void Print(const vector<int> & A)
{
    cout << A[0];
    for (int i = 1; i < A.size(); ++i) {
        cout << ' ' << A[i];
    }
    cout << endl;
}

void InsertionSort(vector<int> & A)
{
    int n = A.size();
    int count = 0;
    for (int i = 0; i < n; ++i) {
        int min_j = i;
        for (int j = i+1; j < n; ++j) {
            if (A[min_j] > A[j]) {
                min_j = j;
            }
        }
        if (i != min_j) {
            swap(A[i], A[min_j]);
            count ++;
        }
    }
    Print(A);
    cout << count << endl;
}

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    // Print(A);
    InsertionSort(A);
    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  string S;
  cin >> S;

  if(S.size() == 2) cout << S << endl;
  else cout << S.at(2) << S.at(1) << S.at(0) << endl;
  
}



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

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

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

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

using namespace std;

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

using ll=long long;
using R=long double;
const R PI = acos(-1.0);

int a, b, x;

R check(R mid){
	const R degree = mid / 180.0 * PI;
	const R thr = atan2(b, a);
	if(degree <= thr) {
		const R volume = 1.0 * (2.0 * b - a * tan(degree)) * a * a / 2.0;
		return volume;
	} else {
		const R volume = 1.0 * b * (1.0 * b / tan(degree)) * a / 2.0;
		return volume;
	}
	assert(false);
}

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

	R low = 0.0, high = 90.0;

	rep(loop, 200){
		const R mid = (low + high) / 2.0;
		if(check(mid) >= x)
			low = mid;
		else
			high = mid;
	}

	cout.precision(20);
	cout << fixed << low << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int INF = 1e9+7;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a;
	for(int i=0;i<n;++i){
		ll val;
		cin>>val;
		a.push_back(val);
	}
	int ans = 0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			for(int k=j+1;k<n;++k){
				if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] && (a[i]+a[j])>a[k] && (a[j]+a[k])>a[i] && (a[i]+a[k])>a[j]){
					++ans;
					//cout<<i+1<<' '<<j+1<<' '<<k+1<<'\n';
				}
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<algorithm>
#define INF 1<<21
using namespace std;
int main(){
    int n,sum=0;
    scanf("%d",&n);
    int s[n];
    for(int i=0;i<n;i++) s[i] = INF;
    for(int i=0;i<n-1;i++){
        scanf("%d",&s[i]);
    }
    sum += s[0];
    for(int i=1;i<n;i++){
        sum += min(s[i-1],s[i]);
    }
    printf("%d\n",sum);
}

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

int main() {
    string S;cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a, b;
    cin >> a >> b;
    cout << a * b - (a + b) + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

int main(void){
		int H, W;
		scanf("%d %d", &H, &W);
		while(H != 0 || W != 0){
				for(int i = 0; i < H; i++){
						for(int j = 0; j < W; j++){
								printf("#");
						}
						printf("\n");
				}
				printf("\n");
				scanf("%d %d", &H, &W);
		}

		return 0;
}



Measured memory_bytes: 2568
import Data.Ord (comparing)
import Data.List (sortBy)
import Data.Maybe (fromJust)
import Control.Monad (replicateM)
import qualified Data.ByteString.Char8 as BS


toInt = fst . fromJust . BS.readInt

toIntPair =
    let
        toTuple = \(a : b : _) -> (a, b)
    in
        toTuple . map toInt . BS.words

sortByTime = sortBy $ comparing snd

works =
    let
        work acc t = (fst t + fst acc, snd t)
    in
        tail . scanl work (0, 0)

main = do
    n <- toInt <$> BS.getLine
    pairs <- map toIntPair <$> replicateM n BS.getLine

    let accepts = \t -> fst t <= snd t
    let check = takeWhile accepts . works . sortByTime

    let count = length $ check pairs

    putStrLn (if n == count then "Yes" else "No")


Measured memory_bytes: 96636
def geti; gets.to_i end
def getis; gets.split.map &:to_i end
def getin n;  n.times.map{geti}  end
def getisn n; n.times.map{getis} end
YES = "YES"; NO = "NO"; Yes = "Yes"; No = "No";


a,b=getis
puts a*b%2==0? "Even" : "Odd"


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

using namespace std;

int main()
{
  string o[] = {"maerd", "remaerd", "esare", "resare"};
  string S; cin >> S;
  reverse(S.begin(), S.end());
  bool flag = true;
  for(int i = 0; i < S.size(); i++) {
    bool hoge = false;
    for(int j = 0; j < 4; j++) {
      if(i+o[j].size() <= S.size() && S.substr(i, o[j].size()) == o[j]) {
	hoge = true;
	i += o[j].size()-1;
	break;
      }
    }
    if(!hoge) flag = false;
    if(!flag) break;
  }
  cout << (flag ? "YES":"NO") << endl;
  return 0;
}


Measured memory_bytes: 512
o=input()
e=input()
ans=""

for i in range(len(o)):
  if len(o)>len(e):
    if i==len(o)-1:
      ans+=o[i]
      break
    else:
      ans+=o[i]
      ans+=e[i]
  else:
    ans+=o[i]
    ans+=e[i]
  
print(ans)

Measured memory_bytes: 3060
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
c = [0]+gets.chomp.split.map(&:to_i)

point = 0
prev = 0

for x in a
  point += b[x - 1]
  if x - prev == 1
    point += c[x-1]
  end
  prev = x
end

puts point


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int A[100100];

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

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    int g = A[0];
    for(int i=1;i<N;++i){
        g = gcd(g, A[i]);
    }

    std::cout << g << std::endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}

ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b, a%b);
}
int main(){
    fast_io

    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans;
    if(k%2==0) ans=a-b;
    else ans=b-a;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
using namespace std;
typedef long long ll;
const ll inf = 1e18 + 1;
const int maxn = 2011;
int DP[maxn][maxn];
ll num[maxn][maxn];
bool ok[maxn][maxn];
char S[maxn];
int n;

int GetDP(int l, int r){
    if (ok[l][r]) return DP[l][r];
    ok[l][r] = 1;
    if (l == r){
        DP[l][r] = 0;
        num[l][r] = 1;
        return 0;
    }
    if (l == r - 1 && S[l] == S[r]){
        DP[l][r] = 0;
        num[l][r] = 1;
        return 0;
    }
    if (S[l] == S[r]){
        DP[l][r] = GetDP(l+1, r-1);
        num[l][r] = num[l+1][r-1];
        return DP[l][r];
    }
    else{
        int ll = GetDP(l+1, r) + 1, rr = GetDP(l, r-1) + 1;
        DP[l][r] = min(ll, rr);
        if (ll < rr)
            num[l][r] = num[l+1][r];
        else if (rr < ll)
            num[l][r] = num[l][r-1];
        else
            num[l][r] = num[l+1][r] + num[l][r-1];

        num[l][r] = min(inf, num[l][r]);
        return DP[l][r];
    }
}
char ans[maxn*2];
int tot = 0;
void print1(){
    rep(i, 1, tot)
        printf("%c",ans[i]);
}
void print2(){
    for (int i = tot; i >= 1; i--)
        printf("%c",ans[i]);
    printf("\n");
}
void Getans(int l, int r, ll k){
    if (num[l][r] < k){
        printf("NONE\n");
        return;
    }
    if (l == r){
        print1();
        printf("%c",S[l]);
        print2();
        return;
    }
    if (S[l] == S[r] && l == r - 1){
        ans[++tot] = S[l];
        print1();
        print2();
        return;
    }
    if (S[l] == S[r]){
        ans[++tot] = S[l];
        Getans(l + 1, r - 1, k);
    }
    else{
        if (DP[l+1][r] < DP[l][r-1]){
            ans[++tot] = S[l];
            Getans(l+1, r, k);
        }
        else if (DP[l][r-1] < DP[l+1][r]){
            ans[++tot] = S[r];
            Getans(l, r-1, k);
        }
        else{
            if (S[l] < S[r]){
                if (num[l+1][r] >= k){
                    ans[++tot] = S[l];
                    Getans(l+1,r,k);
                }
                else{
                    k -= num[l+1][r];
                    ans[++tot] = S[r];
                    Getans(l,r-1,k);
                }
            }
            else{
                if (num[l][r-1] >= k){
                    ans[++tot] = S[r];
                    Getans(l,r-1,k);
                }
                else{
                    k -= num[l][r-1];
                    ans[++tot] = S[l];
                    Getans(l+1,r,k);
                }
            }
        }
    }
}
int main(){
    scanf("%s", S + 1);
    n = strlen(S + 1);
    ll k;
    cin>>k;
    GetDP(1, n);
    Getans(1, n, k);
    return 0;
}

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

int abs(int x){
  if (x>=0) return x;
  else return -x;
}

int main(void){
  int n,i,h[100000],dp[100000],a,b;
  cin >> n;
  for (i=0;i<n;i++) cin >> h[i];
  dp[0]=0;  dp[1]=abs(h[0]-h[1]);
  for (i=2;i<n;i++){
    a=dp[i-2]+abs(h[i]-h[i-2]);
    b=dp[i-1]+abs(h[i]-h[i-1]);
    dp[i]=(a<b)? a:b;
  }
  cout << dp[n-1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
words = [input() for _ in range(N)]
s = set()
for i, word in enumerate(words):
    if word in s:
        print('No')
        exit()
    if i != 0:
        if words[i-1][-1] == word[0]:
            s.add(word)
        else:
            print('No')
            exit()
    else:
        s.add(word)
print('Yes')


Measured memory_bytes: 3060
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while ( A[i] != key ) i++;
  return i != n;
}

int main(void){
  int i, n, A[10000 + 1], q, key, sum = 0;
  
  scanf("%d", &n);
  for( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  
  scanf("%d", &q);
  for( i = 0; i < q; i++ ){
    scanf("%d", &key);
    if ( search(A, n, key) ) sum++;
  }
  printf("%d\n", sum);
  
  return (0);
}



Measured memory_bytes: 2104
def main():
  from collections import defaultdict
  N = int(input())
  A = list(map(int,input().split()))
  MOD = 1000000007
  c = defaultdict(int)
  c[0] = 3
  ans = 1
  for i in range(N):
    if not c[A[i]]:
      print(0)
      exit()
    ans *= c[A[i]]
    ans %= MOD
    c[A[i]] -= 1
    c[A[i]+1] += 1
  print(ans)
main()  
           

Measured memory_bytes: 20952
//
//  main.cpp
//  cell distance
//
//  Created by Dong Truong on 5/28/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <stdio.h>

using namespace std;
#define cmod 1000000007
#define maxn 1000001

int64_t n,m,k,sl;
int64_t pow(int64_t a,int64_t n)
{
    if (n==0) return 1;
    int64_t t=pow(a,n/2);
    t=(t*t)%cmod;
    if (n%2==1) return (t*a)%cmod;
    return t;
}
void pre()
{
    int64_t o=1;
    for (int i=1;i<=n*m-2;++i)
        o=(o*i) %cmod;
    int64_t u=1;
    for (int i=1;i<=k-2;++i)
        u=(u*i) %cmod;
    int64_t v=1;
    for (int i=1;i<=n*m-k;++i)
        v=(v*i) %cmod;
    u=(u*v)%cmod;
    if (k-2<=0 || n*m-k<=0) sl=1;
    else
        sl=(o*pow(u,cmod-2)) % cmod;
}
void sol()
{
    int64_t kq=0;
    for (int i=1;i<=n-1;++i)
    {
        int64_t o=( (i*sl) % cmod * (m*m) % cmod ) %cmod;
        kq=( kq+( (n-i) * o ) % cmod ) % cmod;
        //kq=(kq+o)%cmod;
    }
    for (int i=1;i<=m-1;++i)
    {
        int64_t o=( (i*sl) % cmod * (n*n) %cmod ) % cmod;
        kq=(kq+((m-i)*o)%cmod)%cmod;
        //kq=(kq+o)%cmod;
    }
    cout<<kq;
}
int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
    //freopen("a.inp","r",stdin);
    cin>>n>>m>>k;
    pre();
    sol();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
string s, t;
int dp[4005][4005], ans;
signed main() {
	while (cin >> s >> t) {
		for (int i = 0; i <= 4000; i++)for (int j = 0; j <= 4000; j++)dp[i][j] = 0;
		ans = 0;
		for (int i = 1; i <= s.size(); i++) {
			for (int j = 1; j <= t.size(); j++) {
				if (s[i - 1] == t[j - 1]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
					ans = max(dp[i][j], ans);
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 128340
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

template <typename T>
struct ST{
    using F = function<T(T,T)>;
    F f;
    vector<T> dat;
    int n;
    T ti;
    ST(F f, int n_, T init = INF) : f(f), ti(init) {
        n = 1;
        while(n < n_) n <<= 1;
        dat.assign(n << 1, init);
    }
    ST(int n_, T init = INF){ //RMQ
        ST([](ll a, ll b){return (ll)min(a, b);}, n_, init);
    }
    void update(int k, T a){
        k += n -1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    // [a, b)
    // 外部からはquery(a,b,0,0,st.n)で呼び出す(インスタンス変数がst)
    T query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return ti;
        if(a <= l && r <= b) return dat[k];
        else{
            T vl = query(a,b,k * 2 + 1, l, (l + r) / 2);
            T vr = query(a,b,k * 2 + 2, (l + r) / 2, r);
            return f(vl, vr);
        }
    }
};

int main(void)
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    ST<ll> st([](ll a, ll b){return (ll)(a|b);}, N, 0LL);
    REP(i, N){
        int n = S[i]-'a';
        st.update(i, (1LL<<n));
    }
    int Q;
    cin >> Q;

    vector<int> aaa;
    REP(i, Q){
        int q;
        cin >> q;
        if(q == 1){
            int iq;
            char cq;
            cin >> iq >> cq;
            int n = cq-'a';
            st.update(iq-1, (1LL<<n));
        }else{
            int f,s;
            cin >> f >> s;
            auto tmp = st.query(f-1, s, 0, 0, st.n);
            int ans = 0;
            REP(j, 26){
                if((tmp>>j)&1) ans++;
            }
            aaa.pb(ans);
        }
    }

    for(auto&& ai : aaa) pr(ai);
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //



void solve(){
	int n;
	cin >> n;
	string check[] = {"AC", "WA", "TLE", "RE"};
	int res[4] = {0};
	
	loop(j, n){
		string s;
		cin >> s;
		loop(i, 4){
			res[i] += s[0] == check[i][0];
		}
	}
	
	loop(i, 4){
		cout << check[i] <<  " x " << res[i] << endl;
	}
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



Measured memory_bytes: 3648
import sys
input = sys.stdin.readline

#入力と違って０オリジンとなっているので注意
n = int(input())
li = [[0] * n for _ in range(n)] #隣接行列、０オリジン li[i][j]:iからjへの有向グラフがある
for i in range(n):
    x, y, *v = [int(x)-1 for x in input().split()]
    for j in v:
        li[i][j] = 1 #有向グラフがあるところは１、ないところは０となる

from collections import deque
Q = deque([0]) #初期条件
finish = [0] #訪問済みの頂点をしまう
len_ = [-1]*n #頂点jの頂点０からの距離、できなかったらー１と返す
len_[0] = 0 #初期条件
while Q: #Qがからでない限り以下の操作を繰り返す
    i = Q.popleft()
    for j in range(n):
        if li[i][j] == 1: #iからjへの道が存在する場合
            if not j in finish: #まだjが探索済みじゃなかったら以下の操作を行う
                finish.append(j)
                Q.append(j)
                len_[j] = len_[i] + 1
        else:
            continue
for i in range(n):
    print(str(i+1) + ' ' + str(len_[i]))


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

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> ab(n);
    vector<pair<int,int>> cd(m);
    for(int i = 0; i < n; i++){
        cin >> ab[i].first >> ab[i].second;
    }
    for(int i = 0; i < m; i++){
        cin >> cd[i].first >> cd[i].second;
    }


    for(int i = 0; i < n; i++){
        int value = 1e9;
        int ans;
        for(int j = 0; j < m; j++){
            int tmp = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
            if(value > tmp){
                value = tmp;
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 380
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll nums[100009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>nums[i];
    sort(nums,nums+N);
    
    int now=N,X=0;
    rep(i,N){
        if(i){
            if(nums[i]%2){
                X=nums[i];
            }
        }else{
            ll n=nums[i]-nums[i-1];
            if(n%2){
                X=(X^now);
            }
        }
        now--;
    }
    if(X){
        cout1("first")
    }else{
        cout1("second")
    }
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<int> p(n);
    REP(i, n) cin >> p[i];
    int ans = 0;
    FOR(i, 1, n - 1) { 
        if ((p[i - 1] < p[i] && p[i + 1] > p[i]) || (p[i - 1] > p[i] && p[i + 1] < p[i])) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,d;cin>>a>>b>>c>>d;
//    if(b>0&&d>0) cout<<b*d;
//    else if(b*d<0){
//        cout<<max(a*d,b*c);
//    }else cout<<max(a*c,ll(0));
cout<<max({a*c,a*d,b*c,b*d});
    return 0;
}


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

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int n , k ; 
	cin >> n >>k ;
	vector<int> p(n +1) ;
	vector<int> c(n +1) ;
	for(int i = 1 ; i<=n ; ++i)
		cin >> p[i] ;
	for(int i = 1 ; i <= n ; ++i)
	{
		cin >> c[i] ;
	}   
	int ans =  -1e18 ;
	for(int i = 1 ; i <= n ; ++i)
	{
		int st = p[i]; 
		int cur = p[st] ;
		int  mx = c[st] ; 
		int cnt = 1  ; 
		vector<int> score ;
		score.push_back(mx) ;
		ans = max(ans, mx) ;  

		while(cnt < k && cur != p[i] )
		{
			mx += c[cur] ; 
			ans = max(ans ,mx) ; 
			cur = p[cur] ; 
			score.push_back(mx) ;
			cnt++ ;  
		}
		
		if(cnt < k && st == p[i])
		{
			int q = k/cnt  ; 
			int r = k%cnt ; 
			if(r ==0 )
			{
				--q ; 
				r = cnt  ; 

			}
			int temp = -1e18  ;
			for(int t = 0  ; t < r ; ++t)
			{
				temp = max(temp , score[t]) ; 
			}
			ans = max(ans , q*mx + temp) ; 
	   		
		}
	//	cout << "ans " << ans   << endl ;
	}
	cout << ans ; 


}    


















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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//繰り返し2乗法
ll power(ll x, ll y){//繰り返し2乗法
  if(y < 0){
    return 0;
  }else if(y == 0){
    return 1LL;
  }else if(y%2 == 0){//偶数
    return power(x,y/2)*power(x,y/2);
  }else{//奇数
    return power(x,y-1)*x;
  }
}

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N; cin >> N;
  
  //main
  string ans = "No";
  for(int i=0; i<3; i++){
    if(N%10==7){
      ans = "Yes"; break;
    }
    N = (N-(N%10))/10;
  }
  
  // output
  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)

int main() {
    int N,x,y,h,tx,ty,th;
    cin >> N;
    vector<vector<int>> py(101, vector<int>(101,-1));

    rep(i,N) {
        cin >> x >> y >> h;
        py.at(x).at(y) = h;
        if(h > 0)
            tx=x, ty=y, th=h;
    }

    rep(i,101)
        rep(j,101) {
            int ph=th+abs(i-tx)+abs(j-ty);
            bool r=1;
            rep(k,101)
                rep(l,101) {
                    if(py.at(k).at(l) == -1)
                        continue;
                    if(py.at(k).at(l) != max(ph-abs(k-i)-abs(l-j), 0))
                        r=0;
                }
            
            if(r) {
                cout << i << " " << j << " " << ph << endl;
                return 0;
            }
        }
}

Measured memory_bytes: 256
#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>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n;
std::string s;
long in[100005];
long out[100005];//0:sheep, 1:wolves

int main(){
    scanf("%ld", &n);
    std::cin >> s;
    for(int i = 0; i < n; i++){
        if(s[i] == 'o'){
            in[i] = 0;
        }else{
            in[i] = 1;
        }
    }
    for(int a = 0; a < 4; a++){
        out[0] = a / 2;
        out[1] = a % 2;
        for(int i = 1; i < n-1; i++){
            out[i+1] = (in[i] + out[i] + out[i-1]) % 2;
        }
        if((out[n-1] == (in[0] + out[0] + out[1]) % 2) && (out[0] == (in[n-1] + out[n-1] + out[n-2]) % 2)){
            for(int i = 0; i < n; i++){
                if(out[i] == 0){
                    printf("S");
                }else{
                    printf("W");
                }
            }
            printf("\n");
            return 0;
        }
    }
    printf("-1\n");
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;

int main() {
	string ans;
	int a, b, c, d, e, f, g, h;
	cin >> a >> b >> c >> d >> e >> f >> g >> h;
	int hh = a * e + b * f + a / 10 * g + b / 20 * h, k = c * e + d * f + c / 10 * g + d / 20 * h;
	if (hh > k) { ans = "hiroshi"; }
	else if (hh != k) { ans = "kenjiro"; }
	else { ans = "even"; }
	cout << ans << endl;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}
ll noofdigits(ll n)
{
    ll cnt=0;
    while(n!=0)
    {
        n/=10;
        cnt++;
    }
    return cnt;
}
int main()
{
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
   // cin>>test;
    while(test--)
    {

            ll n,ans=INT_MAX;
            cin>>n;
            for(ll i=1;i*i<=n;i++)
            {
                if(n%i==0)
                {
                    ll x=max(noofdigits(i),noofdigits(n/i));
                    if(x<ans)
                        ans=x;
                }

            }
            cout<<ans<<endl;
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not






Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int a[200001];
int n,k;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    long long sum=0;
    for(int i=1;i<=n-k;i++)sum+=a[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1024
def solve():
    from itertools import product
    from sys import stdin
    f_i = stdin
    
    # idices of faces
    indices = ((0, 1, 2, 3, 4, 5), (0, 2, 4, 1, 3, 5),
               (0, 4, 3, 2, 1, 5), (0, 3, 1, 4, 2, 5),
               (1, 0, 3, 2, 5, 4), (1, 3, 5, 0, 2, 4),
               (1, 5, 2, 3, 0, 4), (1, 2, 0, 5, 3, 4),
               (2, 0, 1, 4, 5, 3), (2, 1, 5, 0, 4, 3),
               (2, 5, 4, 1, 0, 3), (2, 4, 0, 5, 1, 3),
               (3, 0, 4, 1, 5, 2), (3, 4, 5, 0, 1, 2),
               (3, 5, 1, 4, 0, 2), (3, 1, 0, 5, 4, 2),
               (4, 0, 2, 3, 5, 1), (4, 2, 5, 0, 3, 1),
               (4, 5, 3, 2, 0, 1), (4, 3, 0, 5, 2, 1),
               (5, 1, 3, 2, 4, 0), (5, 3, 4, 1, 2, 0),
               (5, 4, 2, 3, 1, 0), (5, 2, 1, 4, 3, 0))
    
    while True:
        n = int(f_i.readline())
        if n == 0:
            break
        
        cubes = tuple(tuple(f_i.readline().split()) for i in range(n))
        
        if n == 1:
            print(0)
            continue
        
        cube1 = cubes[0]
        cubes = cubes[1:]
        
        cnt = 6 * (n - 1)
        for tpl in product(indices, repeat=n-1):
            tmp = 0
            for idx, color1 in zip(zip(*tpl), cube1):
                d = {color1: 1}
                for c, i in zip(cubes, idx):
                    color = c[i]
                    if color in d:
                        d[color] += 1
                    else:
                        d[color] = 1
                tmp += n - max(d.values())
                if tmp >= cnt:
                    break
            else:
                cnt = tmp
        
        print(cnt)

solve()


Measured memory_bytes: 5696
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long
map<int, int>mo;
const int maxn = 1e5 + 5;
int a[maxn], b[maxn];
int main()
{
	int n, m;
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
		b[a[i]]++;
	}
	 
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x>> y;
		int t = (y - x);
		if (b[x])
		{
			sum +=(b[x] * t);b[y] += b[x];
			b[x] = 0;
			
		}cout << sum << endl;

	}
}

Measured memory_bytes: 4312