akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,i;
    cin>>n>>i;
    cout<<n-i+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)2e5 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
                           

int f[maxn], inv[maxn];
int binpow(int a, int b){
  if(b == 0) return 1;
  if(b % 2 == 0){
    int d = binpow(a, b / 2);
    return d * 1ll * d % mod;
  }
  else{
    int d = binpow(a, b - 1);
    return d * 1ll * a % mod;
  }
}                  
int C(int n, int k){
  if(n < 0 || k < 0 || n < k) return 0;
  return (f[n] % mod * 1ll * inv[k] % mod) % mod * 1ll * inv[n - k] % mod % mod;
}

int step(int i1, int j1, int i2, int j2){
  return C(i2 - i1 + j2 - j1, i2 - i1);
}
int dp[maxn], h, w, n, q;
pii a[maxn];
void calc(){               
  cin >> h >> w >> n;
  forn(i, 1, n) cin >> a[i].f >> a[i].s;
  a[++n] = mp(h, w);
  sort(a + 1, a + n + 1);
  forn(i, 1, n){
    dp[i] = step(1, 1, a[i].f, a[i].s);
    forn(j, 1, i - 1)
      dp[i] = (dp[i] - dp[j] * step(a[j].f, a[j].s, a[i].f, a[i].s) % mod + mod) % mod;
  }
  cout << dp[n] << endl;
}
main () {   
  f[0] = 1;
  inv[0] = 1;             
  forn(i, 1, maxn - 1){
    f[i] = f[i - 1] * 1ll * i % mod;
    inv[i] = binpow(f[i], mod - 2);
  }
  calc();
}         



Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    for(int i=0;i<max(a,b);i++){
        cout << min(a,b);
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	string s;
	cin >> s;
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int k,n,af,i,a,aa,maxd=0;
  
  scanf("%d%d%d",&k,&n,&af);
  aa=af;
  for(i=1; i<n; i++) {
     scanf("%d",&a);
     if(maxd < a-aa) maxd=a-aa;
     aa=a;
  }
  if(maxd < k-a+af) maxd=k-a+af;
  
  printf("%d\n",k-maxd);
  
  return 0;
}

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

ll C(ll a,ll b){
		if(b<0) return 0;
		if(b>a) return 0;
		if(b==0) return 1;
		if(b==1) return a;
		if(b==2) return a*(a-1)/2;
		return 0;
}		
	
ll power (ll a,ll b){
		if(b<0)
			return 0;
		return pow(a,b);	
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	int k;
	cin>>s>>k;
	
	ll l = s.length();
	ll ans = 0;
	for(ll i=k;i<=l-1;i++){
		ll p = power(9,k);
		ll cc = C(i-1,k-1);
		ans += (p*cc);
		//ctrl + /cout<<i<<" "<<p<<" "<<cc<<" "<<ans<<"\n";
	}
	ans += (s[0] - '0' - 1) * C(l-1,k-1) * power(9,k-1);
	if(k==1) { 
		ans++;
		cout<<ans;
		return 0;
	}
	int i=1;
	for(;i<l;i++){
		if(s[i] != '0')
			break;
	}
	if(i<l){
		ans += C(l-i-1,k-1) * power(9,k-1);
		ans += (s[i] -'0' -1) * C(l-i-1,k-2) * power(9,k-2);
		if(k==2) {
			ans++;
			cout<<ans;
			return 0;
		}
	}
	i++;
	if(i<l){
		for(;i<l;i++)
			if(s[i] != '0')
				break;
	}
	if(i<l){
		ans += C(l-i-1,k-2) * power(9,k-2);
		ans += (s[i] - '0' - 1) * C(l-i-1,k-3) * power(9,k-3);
		if(k==3) ans++;
	}
	cout<<ans;
	return 0;
}
	
	
	
	
	
	
	
	
	
	
	

























Measured memory_bytes: 384
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            if(s[i+1]=='C') {
                cout<<"Yes"<<endl;
            return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,m; 
    cin >> n >> m;
    vector<pll> v;
    for(int i = 0;i<n;i++){
        ll a; cin >> a;
        v.push_back({a,1});
    }
    while(m--){
        ll b,c;
        cin >> b >> c;
        v.push_back({c,b});
    }
    sort(all(v),greater<pll>());
    ll ans = 0;
    ll num = 0;
    for(auto p : v){
        if(num + p.second <= n){
            ans += p.first*p.second;
            num += p.second;
        }else{
            ans += p.first*(n-num);
            num = n;
            break;
        }
    }
    cout << ans << endl;
}

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

const int MAX_N = 10000;
const int MAX_Q = 500;

int main() {
    int n, q;
    int S[MAX_N], T[MAX_Q];

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

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

    int ans = 0;
    for(int i = 0; i < q; i++) {
        for(int j = 0; j < n; j++) {
            if(S[j] == T[i]) {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,k; cin>>n>>k;
	vi vec(n);
	rep(i,0,n) cin>>vec[i];
	ll ans=0;
	rep(i,0,n){
		ans+=min(vec[i]*2,(k-vec[i])*2);
	}
	cout<<ans;
	
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

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

   for (int i = s.size()-1; i >= 0; i--) {
      string p = s.substr(i, t.size());
      if (p.size() != t.size()) continue;
      bool f = true;
      rep (j, p.size()) {
         if (p[j] == '?') continue;
         if (p[j] != t[j]) f = false;
      }

      if (f) {
         int cnt = 0;
         for (int j = i; j < i+t.size(); j++) {
            s[j] = t[cnt];
            cnt++;
         }
         rep (i, s.size()) {
            if (s[i] == '?') {
               cout << 'a';
            } else {
               cout << s[i];
            }
         }
         cout << endl;
         return 0;
      }
   }

   puts("UNRESTORABLE");

   return 0;
}

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

#define vi vector<int>
#define pb push_back

bool start[200010] = {}, goal[200010] = {};
int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

const int mod = 998244353;
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint f(int n){ 
  if(n == 0)return 1;
  mint x = f(n / 2); 
  x *= x; 
  if(n % 2 == 1)x *= 2;
  return x;
}

mint choose(int n, int a){
  mint x = 1, y = 1;
  for(int i = 0; i < a; ++i){
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

mint fact[200101];
mint fact_inv[200101];
void init(){
	fact[0] = 1;
	for(int i = 1; i <= 200100; ++i){
		fact[i] = fact[i - 1] * i;
	}
	fact_inv[200100] = fact[200100].inv();
	for(int i = 200100; i >= 1; --i){
		fact_inv[i - 1] = fact_inv[i] * i;
	}
}

mint comb(int n, int k){
	return fact[n] * fact_inv[n - k] * fact_inv[k];
}

int main(){
  init();
  int n, m, k;
  cin >> n >> m >> k;

  mint ans = 0;
  mint color = m;
  for(int i = n - 1; i >= 0; --i){
  	mint divide = comb(n - 1, i);
  	if(i <= k)ans += color * divide;
  	color *= m - 1;
  }

  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 6764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

struct Tree{
  struct Node{
    int p;
    vector<pair<int,int> > sib;
  };

  vector<Node> node;
  int n,ans;

  Tree(int v){
    n=v;
    node.clear();
    node.resize(n);
  }

  void input(int a,int b,int w){
    node[a].sib.push_back({b,w});
    node[b].sib.push_back({a,w});
  }

  int dfs(int v=0,int prev=-1){
    //DFS

    int i,next,tmp,first=0,second=0;
    node[v].p=prev;
    for(i=0;i<node[v].sib.size();i++){
      next=node[v].sib[i].first;
      if(next==prev)continue;

      tmp=dfs(next,v)+node[v].sib[i].second;
      if(first<tmp){
        second=first;
        first=tmp;
      }
      else if(second<tmp){
        second=tmp;
      }
    }
    tmp=first+second;
    if(ans<tmp)ans=tmp;

    return first;
  }
};

int main(void){
  int n,s,t,w,i;
  cin>>n;

  Tree tree(n);

  for(i=0;i<n-1;i++){
    cin>>s>>t>>w;
    tree.input(s,t,w);
  }

  tree.dfs();

  cout<<tree.ans<<endl;

  return 0;
}


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

	//B
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while ((a > 0) && (c > 0)) {
		c = c - b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a = a - d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;

	//A
	/*int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	return 0;*/
}

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

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		char a = sc.next().charAt(0);
		char b = sc.next().charAt(0);
		char c = sc.next().charAt(0);
		System.out.println("" + Character.toUpperCase(a) + Character.toUpperCase(b) + Character.toUpperCase(c));
	}

    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


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

vector<vector<int>> graph;
vector<int> depth;
void DFS(int v, int parent_v = -1){
    if(parent_v != -1 && depth[v] != -1) return ;
    if(parent_v != -1 && depth[v] == -1) depth[v] = depth[parent_v] + 1;

    for(int child_v : graph[v]){
        if(child_v == parent_v) continue;

        DFS(child_v, v);
    }
}

int main(){
    int n;
    cin >> n;
    graph.resize(n);
    depth.assign(n, -1);
    depth[0] = 0;

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

    DFS(0);
    int even = 0, odd = 0;
    for(int i=0; i<n; i++){
        //cout << depth[i] << " ";
        if(depth[i] % 2 == 0) even += 1;
        if(depth[i] % 2 == 1) odd  += 1;
    }

    set<int> num;
    for(int i=1; i<=n; i++) num.insert(i);

    vector<int> ans(n);
    if(even <= n/3){
        for(int i=0; i<n; i++){
            if(depth[i] % 2 == 0){
                ans[i] = 3 * even;
                num.erase(3 * even);
                even -= 1;
            }
        }
        for(int i=0; i<n; i++){
            if(ans[i] == 0){
                ans[i] = *num.begin();
                num.erase(num.begin());
            }
        }
    }
    else if(odd <= n/3){
        for(int i=0; i<n; i++){
            if(depth[i] % 2 == 1){
                ans[i] = 3 * odd;
                num.erase(3 * odd);
                odd -= 1;
            }
        }
        for(int i=0; i<n; i++){
            if(ans[i] == 0){
                ans[i] = *num.begin();
                num.erase(num.begin());
            }
        }
    }
    else{
        int count1 = 0, count2 = 0, count3 = 0;
        for(int i=0; i<n; i++){
            if(depth[i] % 2 == 0 && 3 * count1 + 1 <= n){
                    ans[i] = 3 * count1 + 1;
                    count1 += 1;
            }
            else if(depth[i] % 2 == 1 && 3 * count2 + 2 <= n){
                ans[i] = 3 * count2 + 2;
                count2 += 1;
            }
            else{
                ans[i] = 3 * count3 + 3;
                count3 += 1;
            }
        }
    }

    for(int i=0; i<n; i++){
        cout << ans[i];
        if(i == n-1) break;
        cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 27184
n = gets.to_i
ps = gets.split.map &:to_i

ps = ps.map.with_index{ |x, i|
	[x, i]
}.sort{ |a,b| a[0] <=> b[0] }

count = 0
memo = n

ps.each{ |p|
	if p[1] < memo then
		count += 1
		memo = p[1]
	end
}

puts count


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

signed main(){
    int h,w,x,y,r;cin>>w>>h>>x>>y>>r;
    if(x-r<0||x+r>w||y-r<0||y+r>h)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
    using namespace std;
    
    //                                 (POLICY BASED DS)
    // #include <ext/pb_ds/assoc_container.hpp>
    // #include <ext/pb_ds/tree_policy.hpp>
    // using namespace __gnu_pbds;
    // template<typename T>
    // using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
    // template<typename T>
    // using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
    //                      ( find_by_order( )  ,  order_of_key( ) )
    
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef pair<ll,ll> pll;
     
    const ll mod = 1e9 + 7;
    const ld PI = 3.1415926535897932384626;
    const ld eps = 1e-9;                            
     
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define sidha(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
    #define ulta(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);--i)
    #define stl(container,itr) \
        for(auto itr = container.begin(); itr != container.end(); itr++)
    #define sab(v) v.begin(), v.end()
    #define rall(v) v.rbegin(), v.rend()            
    #define test ll t;cin>>t;while(t--)
    #define sz size()
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define LOG2(X) (63ll - __builtin_clzll(X))
    #define endl '\n'
    #define modinv(x) power(x, mod-2)
    #define ncr(n,r) ( n >= r ? ((((fact[n]*modinv(fact[r]))%mod)*modinv(fact[n-r]))%mod) : (ll)0)
    #define MAX 100005
     
    ll power(ll x, ll y) { 
        ll ans=1;
        x=x%mod;
        while(y>0) { 
            if (y&1) 
                ans=(ans*x)%mod; 
            y=y>>1;
            x=(x*x)%mod; 
        } 
        return (ans%mod); 
    }
    
    // vector<ll> adj[MAX];
    // ll visit[MAX];
    // void dfs(ll node){
    //     visit[node]=1;
    //     for(auto i : adj[node]){
    //         if(!visit[i]) dfs(i);
    //     }
    // }
    
    // ll spf[MAX];
    // void sieve(){
    //     sidha(i,1,MAX)  spf[i]=i;
    //     for(ll i=4;i<MAX;i+=2)  spf[i]=2;
    //     for(ll i=3;i*i<=MAX;i++){
    //         if(spf[i]==i){
    //             for(ll j=i*i;j<MAX;j+=i){
    //                 if(spf[j]==j)   spf[j]=i;
    //             }
    //         }
    //     }
    // }

    int main()
    {
        boost;
        ll fact[1000005],power8[1000005],power9[1000005],n,ans,tmp,tmp1;
        fact[0]=1;
        power8[0]=power9[0]=1;
        sidha(i,1,1000005){
            fact[i]=((fact[i-1]*i)%mod);
            power8[i]=((power8[i-1]*8)%mod);
            power9[i]=((power9[i-1]*9)%mod);
        }
        cin>>n;
        ans=power(10,n);
        tmp=power(8,n);
        ans=((ans-tmp+mod)%mod);
        tmp=0;
        for(ll i=1; ;i++){
            if(i>n) break;
            tmp1=((power8[i-1]*power9[n-i])%mod);
            tmp=((tmp+tmp1)%mod);
        }
        tmp=((tmp*2)%mod);
        ans=((ans-tmp+mod)%mod);
        cout<<ans;
        return 0;
    }
    

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    char str;
    cin>>str;
    
    if((int)str > 90)
    cout<<'a'<<endl;
    else
    cout<<'A'<<endl;
    return 0;
}


Measured memory_bytes: 3624
N = int(input())
S = [list(input()) for _ in range(N)]

for i in range(N):
	S[i].sort()

for i in range(N):
	S[i] = "".join(S[i])

S.sort()
S.append(None)

pt,count,C = 1,0,[]
while pt <= N:
	if S[pt-1] == S[pt]:
		count += 1
	else:
		if count > 0:
			C.append(count+1)
			count = 0
	pt += 1

ans = 0
for i in range(len(C)):
	ans += C[i]*(C[i]-1) // 2

print(ans)


Measured memory_bytes: 24208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int a, b, c, d;

signed main() {
	cin >> a >> b >> c >> d;
	if (d <= b)cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
void main() {
	auto Q = ri;
	auto arr = generate_prime_list(100000);
	bool[] arr2 = new bool[](100001);
	foreach(i; 1..100001) {
		if(arr[i] && arr[(i+1)/2]) arr2[i] = true;
	}
	
	ulong[] vl = new ulong[](100001);
	foreach(v; 1..100001) {
		if(arr2[v]) vl[v] = vl[v-1] + 1;
		else vl[v] = vl[v-1];
	}
	
	//debug writefln("%(%d %)", vl);
	foreach(i; 0..Q) {
		auto ip = readAs!(int[]), l = ip[0], r = ip[1];
		writeln(vl[r] - vl[l-1]);
	}
	//debug foreach(i, v; arr) writefln("%d: %s", i, v);
}

bool[] generate_prime_list(T)(T N) if(isIntegral!T) {
	bool[] prime_list = new bool[](N+1);
	prime_list[] = true;
	prime_list[0] = prime_list[1] = false;
	foreach(i; 2..N+1) {
		if(prime_list[i]) {
			foreach(j; iota(i*2, N+1, i)) {
				prime_list[j] = false;
			}
		}
	}
	return prime_list;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int hight = 0;
    ll ans = 0;
    rep(i,n){
        hight = max(hight, a[i]);
        ans += hight - a[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int n,k;cin>>n>>k;
	
	long long release=0;
	for(int i=1;i<n;i++){
		release += (release + k - 1 - release%(k-1)) / (k-1);
	}
	
	cout<<release<<endl;
	
	return 0;
}

Measured memory_bytes: 3068
n = gets.to_i
a = gets.split.map(&:to_i)
aa = a.map.with_index(1) {|e, i| e - i}.sort

b = n.odd? ? aa[n/2] : (aa[n/2 - 1] + aa[n/2] + 1) / 2
puts a.each.with_index(1).inject(0) {|r, (v, i)| r + (v - b - i).abs}

Measured memory_bytes: 23024
/* 
ABC 162 D問題
RGB Triplets
*/

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

int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(3, vector<int>(4)); //二次元配列
    long long N, R_cnt = 0, G_cnt = 0, B_cnt = 0, remove_cnt = 0;
    string S;
    cin >> N >> S;

    for (char s : S) {
        if (s == 'R') {
            R_cnt++;
        } else if (s == 'G') {
            G_cnt++;
        } else {
            B_cnt++;
        }
    }

    for(int i = 0; i < N - 2; i++) {
        for(int j = i + 1; j < N - 1; j++) {
            int k = j + j - i;
            if (k > N - 1) {
                break;
            } else {
                set<char> RGB_set;
                RGB_set.insert(S.at(i));
                RGB_set.insert(S.at(j));
                RGB_set.insert(S.at(k));
                if (RGB_set.size() == 3) {
                    remove_cnt++;
                }
            }
        }
    }
    cout << R_cnt * G_cnt * B_cnt - remove_cnt << endl;

    return 0;
}



Measured memory_bytes: 3640
program signboard
  implicit none
  character(16) :: s, t
  integer :: i, m
  read(*,*) s
  t = "CODEFESTIVAL2016"
  m = 0
  do i = 1, 16
    if (s(i:i).ne.t(i:i)) m = m + 1
  end do
  write(*,'(i0)') m
  stop
end program signboard

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main ()
{
 int S;
 cin >> S;
 int h = S / 60 / 60;
 int m = (S - h * 60 * 60) / 60;
 int s = S - h * 60 * 60 - m * 60;
 cout << h << ":" << m << ":" << s << endl;
 return 0;
}

Measured memory_bytes: 3088
n=int(input())
v=list(map(int, input().split()))
import collections
v1=v[0::2]
v11=collections.Counter(v1)
v2=v[1::2]
v22=collections.Counter(v2)
o=v11.most_common()+([(0,0)])
e=v22.most_common()+([(0,0)])
if o[0][0]!=e[0][0]:
    print(n-o[0][1]-e[0][1])
else:
    print(min(n-o[0][1]-e[1][1],n-o[1][1]-e[0][1]))

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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

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

    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    long long cnt = 0;
    bool b = false;
    rep(i, n) {
        if (a[i] == 0) {
            b = true;
            break;
        }
        if (a[i] < 0) {
            cnt++;
        }
    }

    b = cnt % 2 == 0;
    long long sum = 0;
    if (b) {
        rep(i, n) sum += abs(a[i]);
    } else {
        long long t = abs(a[0]);
        rep(i, n) {
            sum += abs(a[i]);
            t = min(t, abs(a[i]));
        }

        sum -= 2 * t;
    }

    cout << sum << endl;

}

Measured memory_bytes: 1024
n = int(input())
x = input().split()
s = x[0]
t = x[1]
a = []
s_i = 0
t_i = 0
for i in range(0,n*2):
  if(i%2 == 0):
    a.append(s[s_i])
    s_i = s_i + 1
  else:
    a.append(t[t_i])
    t_i = t_i + 1
      
b = ''.join(a)
print(b)

Measured memory_bytes: 38256
X=[int(x) for x in input().split()]
count=0
if ((X[0]%2-1)*(X[1]%2-1)*(X[2]%2-1)!=0 and X[0]==X[1] and X[1]==X[2]):
  count=-1
else:
  while((X[0]%2-1)*(X[1]%2-1)*(X[2]%2-1)!=0):
    Y=[0,0,0]
    Y[0]=(X[1]+X[2])/2
    Y[1]=(X[0]+X[2])/2
    Y[2]=(X[1]+X[0])/2
    X=Y
    count =count+1
print(count) 

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int n;
  cin>>n;
  n%=10;
  if(n==3) out("bon");
  else if(n==0||n==1||n==6||n==8) out("pon");
  else out("hon");
}

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


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

int main(){
    int n;
    cin >> n;
    double y = n;
    double a[n];
    double sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    for(int i=0;i<n;i++){
        sum += a[i];
    }

    sum = sum/y;

    int ans = 0;
    double x = abs(sum-a[0]);

    for(int i=1;i<n;i++){
        if(x>abs(sum-a[i])){
            ans = i;
            x = abs(sum-a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//BY: YASH JAIN, CF: yashjain0333
#include <bits/stdc++.h>
using namespace std;
#define May_the_fork_be_with_you ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e18
#define ll long long
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define int long long
#define N 502

// vector<vector<pair<int,int>>> adj(N);
// // vector<int> res(N,0);
// // vector<bool> vis(N,false);
// int n,m,q;

// vector<int> dijkstra(int v, vector<int>& d){
// 	d[v] = 0;
// 	vector<bool> mark(N,false);
// 	priority_queue<pair<int,int>,vector<pair<int,int>>, less<pair<int,int>>> pq;
// 	pq.push({d[v], v});
// 	while(!pq.empty()){
// 		int u = pq.top().second;  pq.pop();
// 		if(mark[u]) continue;
// 		mark[u] = true;
// 		for(auto p : adj[u]){
// 			if(d[p.first] > d[u] + p.second){
// 				d[p.first] = d[u] + p.second;
// 				pq.push({d[p.first], p.first});
// 			}
//         }
// 	}
//     return d;
// }

void solve(){
    int d,t,s; cin>>d>>t>>s;
    if(d%s==0){
        if(d/s<=t){
            cout<<"Yes";
            return;
        }
    }
    else{
        if(d/s+1<=t){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}

int32_t main(){
    May_the_fork_be_with_you
    int t = 1; 
    // cin>>t;
    while (t--) {
        solve();
	}
}

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

int main(){
    int n, a[100], sum=0,m;
    cin >> n;
    for(int i=0; i<n; i++)cin >> a[i];
    for(int i=n-1; i>=0; i--){
        for(int j=0; j<=i-1; j++){
            if(a[j] > a[j+1]){
                swap(a[j], a[j+1]);
            }            
        }
    }
    m = (n-1)%2;
    for(int i=n-1; i>=0; i--){
        if(i%2==m)sum+=a[i];
        else sum-=a[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a,b,c;
    char op;
    
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        
        if(op == '?') break;
        
        if(op == '+'){
            c = a + b;
            
        }else if(op == '-'){
            c = a -b;
            
        }else if(op == '*'){
            c = a * b;
            
        }else if(op == '/'){
            c = a / b;
            
        }else{
            
        }
        
        printf("%d\n", c);
    }
	return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}

#define REP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

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

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000+7)

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    
    int maxima = 0;
    REP(i, 0, N) {
        cin >> H[i];
        maxima = max(maxima, H[i]);
        if (i > 0 && maxima > H[i]+1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin >> n >> k;
  VLL h(n);
  rep(i, n) cin >> h[i];
  VLL dp(n + 10, 1e9);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  FOR(i, 2, n) {
    for(int j = 1; i - j >= 0 && j <= k ; j++){
      chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 4736
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)

for i in reversed(range(1, n + 1)):
    k = i
    cnt = 0
    while k <= n:
        cnt += b[k]
        k += i

    if cnt % 2 != a[i]:
        b[i] = 1

print(sum(b))
for i in range(1, n + 1):
    if b[i] == 1:
        print(i)

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

int main() {
  int N;
  int a = 0;
  int b;
  cin >> N;
  b = N;
  while(true) {
    a += b % 10;
    if (b /10 > 0) {
      b /= 10;
    }else {
      break;
    }
  }
  if (N % a == 0) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 380
package main

import "fmt"

func main() {
	var a [3][3]int
	var c [3][3]bool
	for i := range a {
		for j := range a[i] {
			fmt.Scan(&a[i][j])
		}
	}
	var n, b int
	fmt.Scan(&n)
	for k := 0; k < n; k++ {
		fmt.Scan(&b)
		for i := range a {
			for j := range a[i] {
				if a[i][j] == b {
					c[i][j] = true
				}
			}
		}
	}

	for i := 0; i < 3; i++ {
		if c[i][0] && c[i][1] && c[i][2] || c[0][i] && c[1][i] && c[2][i] {
			fmt.Println("Yes")
			return
		}
	}
	if c[0][0] && c[1][1] && c[2][2] || c[0][2] && c[1][1] && c[2][0] {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


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

struct Pos {
	int x, y;
};


int N;
int t[100010];
Pos pos[100010];


bool judge() {

	int turn;

	for (int i = 1; i <= N; i++) {
		// 時間数
		turn = t[i] - t[i - 1];


		// 絶対値を引く
		turn -= abs(pos[i].x - pos[i - 1].x);
		turn -= abs(pos[i].y - pos[i - 1].y);

		if (turn < 0 || turn % 2 != 0) return false;
	}

	return true;
}

int main() {
	cin >> N;

	t[0] = 0;
	pos[0] = { 0, 0 };
	for (int i = 1; i <= N; i++) {
		cin >> t[i] >> pos[i].x >> pos[i].y;
	}


	if (judge()) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1408
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}

int ans[1024][1024], n, m;
int sq[12][1024][1024];
//flip flopはいいぞ！ (素振り！)
bool flip;

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	if(n > m) {
    	swap(n, m); flip = true;
    }
	
	sq[1][1][1] = 1;
	for(int i=1;i<=9;i++){
		int L = (1<<i);
		rep(a, L) rep(b, L) sq[i+1][a][b] = sq[i+1][a+L][b] = sq[i+1][a][b+L] = sq[i][a][b];
		rep(a, L) rep(b, L) sq[i+1][a+L][b+L] = sq[i][a][b]^1;
	}
	rep(R, 1<<(m-n)){
		rep(a, (1<<n)) rep(b, (1<<n)) ans[a][b+R*(1<<n)] = sq[n][a][b];
	}
	if(flip) swap(n, m);
	for(int i=1;i<(1<<n);i++){
		for(int j=1;j<(1<<m);j++){
			int x = (flip?j:i), y = (flip?i:j);
			int cur = ans[x][y] ^ ans[x-1][y] ^ ans[x][y-1] ^ ans[x-1][y-1];
			cout << cur;
		}
		cout << '\n'; 
	}
	return 0;
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

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

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

int main() {
  int N, K;
  cin >> N >> K;
  int H[100010];
  for (int i = 0; i < N; i++)
    cin >> H[i];
  
  int ans = 0;
  for (int i = 0; i < N; i++)
    if (H[i] >= K) ans++;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
const int MAXN=110000;
const int INF=1E7;
vector<int> g[MAXN];
int w[MAXN], l[MAXN], r[MAXN];
bool c[MAXN];
bool dfs1(int u, int f, bool t)
{
	c[u]=t;
	if (~w[u]&&w[u]%2!=t) return 0;
	for (int i=0; i<g[u].size(); i++)
	{
		int v=g[u][i];
		if (v!=f&&!dfs1(v, u, t^1)) return 0;
	}
	return 1;
}
int dfs2(int u, int f)
{
	if (~w[u]) l[u]=r[u]=w[u];
	for (int i=0; i<g[u].size(); i++)
	{
		int v=g[u][i];
		if (v==f) continue;
		if (!dfs2(v, u)) return 0;
		l[u]=max(l[u], l[v]-1);
		r[u]=min(r[u], r[v]+1);
	}
	return l[u]<=r[u];
}
void dfs3(int u, int f, int k)
{
	w[u]=k;
	for (int i=0; i<g[u].size(); i++)
	{
		int v=g[u][i];
		if (v==f) continue;
		if (l[v]<=k-1&&k-1<=r[v]) dfs3(v, u, k-1);
		else dfs3(v, u, k+1);
	}
}
int main()
{
//	freopen("E.in", "r", stdin);
//	freopen("E.out", "w", stdout);
	int n, k;
	scanf("%d", &n);
	for (int i=1; i<n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	scanf("%d", &k);
	memset(w, -1, sizeof w);
	for (int i=1; i<=k; i++)
	{
		int v, p;
		scanf("%d%d", &v, &p);
		w[v]=p;
	}
	for (int i=1; i<=n; i++)
		if (~w[i])
		{
			if (!dfs1(i, 0, w[i]%2))
			{ puts("No"); return 0; }
			break;
		}
	for (int i=1; i<=n; i++) l[i]=-INF, r[i]=INF;
	if (!dfs2(1, 0)) { puts("No"); return 0; }
	puts("Yes");
	dfs3(1, 0, l[1]);
	for (int i=1; i<=n; i++) printf("%d\n", w[i]);
	return 0;
}

Measured memory_bytes: 15744
array_str = '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'

array = array_str.split(', ')

k = int(input())
print(array[k - 1])

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

int main()
{
  int N,A[1000],k,v,j;

  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  for(int k=0;k<N-1;k++)cout<<A[k]<<" ";
  cout<<A[N-1]<<endl;  
  for(int i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(int k=0;k<N-1;k++)cout<<A[k]<<" ";
    cout<<A[N-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
def solve():
    n = int(input())
    X, Y, H = [], [], []
    for i in range(n):
        x, y, h = map(int, input().split())
        X.append(x), Y.append(y), H.append(h)

    for cx in range(101):
        for cy in range(101):
            res = []
            for x, y, h in zip(X, Y, H):
                if h == 0:
                    continue
                hh = h + abs(x - cx) + abs(y - cy)
                res.append(hh)
            if len(set(res)) == 1:
                flg = True
                for x, y, h in zip(X, Y, H):
                    if h != max(res[0] - abs(x - cx) - abs(y - cy), 0):
                        flg = False
                if flg:
                    print(cx, cy, res[0])

solve()

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

int main(){
    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    vector<pair<double, int>> temp(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
        temp[i].first = abs(a - (t - h[i]*0.006));
        temp[i].second = i + 1;
    }
    sort(temp.begin(), temp.end());
    cout << temp[0].second << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	vector <vector<char> > v(m,vector <char> (n) );
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>v[j][i];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			bool b=false;
			if(v[j][i]=='#'){
				if(i!=0){
					if(v[j][i-1]=='#'){
						b=true;
					}
				}
				if(i!=n-1){
					if(v[j][i+1]=='#'){
						b=true;
					}
				}
				if(j!=0){
					if(v[j-1][i]=='#'){
						b=true;
					}
				}
				if(j!=m-1){
					if(v[j+1][i]=='#'){
						b=true;
					}
				}
				if(b==false){
					cout<<"No"<<endl;
					return 0;
				}
			}
			
		}
	}
	cout<<"Yes"<<endl;
	return 0;
	
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n=int(input())
	A=list(map(int,input().split()))
	
	ans=[0]*(n)
	ans[0]=sum(A)-2*sum(A[1::2])
	for i in range(1,n):
		ans[i]=2*A[i-1]-ans[i-1]
	print(*ans)
	
	
	





if __name__ == '__main__':
	main()


Measured memory_bytes: 13656