akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
using namespace std;

int main(){
    int n, x;
    cin >> n >> x;

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

    sort(m, m + n);

    int cou = n;
    for(int i = 0; i < n; i++){
        x -= m[i];
    }

    if(x != 0){
        while(1){
            if(x == 0){
                break;
            }else if(x < 0){
                cou--;
                break;
            }

            x -= m[0];
            cou++;
        }
    }

    cout << cou << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int i = 0, j = s.length();
    while (s[i++] != 'A');
    while (s[j--] != 'Z');
    cout << j - i + 3 << endl;
}


Measured memory_bytes: 640
#総当たり
def calc(a, b, plus_minus):
  if plus_minus == 0:
    return a + b
  elif plus_minus == 1:
    return a - b

import itertools as it
list_prm = it.product([0, 1], repeat=3)
list_prm = list(list_prm)

list_abcd = [int(num) for num in input()]

def calc4(list_abcd, list_pm):
  ans = calc(list_abcd[0], list_abcd[1], list_pm[0])
  ans = calc(ans, list_abcd[2], list_pm[1])
  ans = calc(ans, list_abcd[3], list_pm[2])
  return ans

def serch_7(list_abcd, list_prm):
  for list_pm in list_prm:
    if calc4(list_abcd, list_pm) == 7:
      return list_pm

    
def convert(num):
  if num == 0:
    return "+"
  else:
    return "-"

sol = serch_7(list_abcd, list_prm)

s = str(list_abcd[0])
s += convert(sol[0])
s += str(list_abcd[1])
s += convert(sol[1])
s += str(list_abcd[2])
s += convert(sol[2])
s += str(list_abcd[3])
s += "=7"

print(s)   

Measured memory_bytes: 38484
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    ll n, k; cin >> n >> k;
    if(k == 0) {
        cout << n * n << endl;
        return 0;
    }
    ll ans = 0;
    repi(a, k, n + 1) {
        ans += n - a;
    }
    
    repi(b, k + 1, n) {
        int res = n / b - 1;
        res *= b - k;
        if(n % b >= k) {
            int t = b * (n / b + 1) - n;
            res += b - (k - 1) - t;
        }
        ans += res;
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int H, W;
  cin >> H >> W;
  ll C[10][10] = {0};
  int A[200][200] = {-1};
  rep(i, 10) {
    rep(j, 10) {
      cin >> C[i][j];
    }
  }
  rep(i, H) {
    rep(j, W) {
      cin >> A[i][j];
    }
  }

  // 同じならコスト0
  rep(i, 10) {
    C[i][i] == 0;
  }

  // ワーシャルフロイドでコストを最小化
  rep(k, 10) {
    rep(i, 10) {
      rep(j, 10) {
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      }
    }
  }

  // デバッグで表示
  // DEBUG("optimized");
  // rep(i, 10) {
  //   rep(j, 10) {
  //     cout << C[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  ll sumCost = 0;
  rep(i, H) {
    rep(j, W) {
      int a = A[i][j];
      if (a != -1 && a != 1) {
        sumCost = sumCost + C[a][1];
      }
    }
  }

  cout << sumCost << endl;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
s = [a[0]]
#和sのリストを作成
for i in range(1, n):
    s.append(s[-1]+a[i])

cnt_a = 0
base = 0
for i in range(n):
    if ((base + s[i] >= 0) and (i % 2 == 1)) or ((base + s[i] <= 0) and (i % 2 == 0)):
        cnt_a += (1 + abs(base + s[i]))
        base += (1 + abs(base + s[i])) * (-1) ** i


cnt_b = 0
base = 0
for i in range(n):
    if ((base + s[i] <= 0) and (i % 2 == 1)) or ((base + s[i] >= 0) and (i % 2 == 0)):
        cnt_b += (1 + abs(base + s[i]))
        base -= (1 + abs(base + s[i])) * (-1) ** i

print(min(cnt_a, cnt_b))

Measured memory_bytes: 14468
// ProblemURL : https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_a
// ---------------------------------------------
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	if len(s) >= 4 && s[:4] == "YAKI" {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
from heapq import heapify, heappop, heappush
N, M = map(int, input().split())
a = [-int(a) for a in input().split()]
heapify(a)
for _ in range(M):
  heappush(a, heappop(a) / 2)
print(-sum(int(x) for x in a))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, m;
	LLi x, y, z, ma=-1, tmp;
	vector<LLi> v1, v2, v3, v4;

	cin>> n >> m;
	v1.resize(n);
	v2.resize(n);
	v3.resize(n);
	v4.resize(n);

	rep(i, n){
		cin >> x >> y >> z;
		v1[i]=x+y+z;
		v2[i]=-x+y+z;
		v3[i]=x-y+z;
		v4[i]=x+y-z;
	}

	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	sort(v3.begin(), v3.end());
	sort(v4.begin(), v4.end());

	tmp=0;
	rep(i, m) tmp+=v1[i];
	ma=max(ma, abs(tmp));
	tmp=0;
	rep(i, m) tmp+=v2[i];
	ma=max(ma, abs(tmp));
	tmp=0;
	rep(i, m) tmp+=v3[i];
	ma=max(ma, abs(tmp));
	tmp=0;
	rep(i, m) tmp+=v4[i];
	ma=max(ma, abs(tmp));

	tmp=0;
	rep(i, m) tmp+=v1[n-1-i];
	ma=max(ma, abs(tmp));
	tmp=0;
	rep(i, m) tmp+=v2[n-1-i];
	ma=max(ma, abs(tmp));
	tmp=0;
	rep(i, m) tmp+=v3[n-1-i];
	ma=max(ma, abs(tmp));
	tmp=0;
	rep(i, m) tmp+=v4[n-1-i];
	ma=max(ma, abs(tmp));
	
	cout<< ma << endl;
 
	return 0;
}

Measured memory_bytes: 3620
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int ans;
vector<int> edge[100];
bool flg[100] ={};
void dfs(int v, int d){
	ans = max(ans, d);
	flg[v] = true;
	for(int i=0; i<edge[v].size(); i++){
		if(!flg[edge[v][i]]) dfs(edge[v][i], d+1);
	}
	flg[v] = false;
}

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0) break;

		for(int i=0; i<100; i++){
			edge[i].clear();
		}
		
		for(int i=0; i<n; i++){
			int a, b;
			cin >> a >> b;
			edge[a-1].PB(b-1);
			edge[b-1].PB(a-1);
		}

		ans = 0;
		for(int i=0; i<100; i++){
			dfs(i, 1);
		}
		cout << ans << endl;
	}
}


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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF					INT_MAX
#define LLINF					LLONG_MAX
#define DEBUG					false

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

int main() {

	int a, b, h;
	cin >> a >> b >> h;
	
	cout << (a+b) * h / 2 <<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int a[]=new int[5];
		for(int i=0;i<5;i++)
			a[i]=sc.nextInt();
		int k=sc.nextInt();
		int c=0;
		for(int i=0;i<4;i++){
			for(int j=i+1;j<5;j++){
				if((a[j]-a[i])>k){
					c++;
					System.out.println(":(");
					break;
				}
				}
			if(c>0)
						break;
		}
		if(c==0)
			System.out.println("Yay!");
	}
}

Measured memory_bytes: 24148
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;


int main(){
    string s;
    cin >> s;
    int q; cin >> q;
    int front = 1;
    vector<char> fr;
    vector<char> bck;
    rep(i,q){
        int t;
        cin >> t;
        if(t==1){
            front = (front+1)%2;
        }
        else{
            int f;
            char c;
            cin >> f; cin >> c;
            if (f == 1){
                if(front==1){
                    fr.pb(c);
                }
                else{
                    bck.pb(c);
                }
            }
            else{
                if(front == 1){
                    bck.pb(c);
                }
                else{
                    fr.pb(c);
                }
            }
        }
    }
    if (front == 1){
        int sf = (int)fr.size();
        int sb = (int)bck.size();
        rep(i,sf){
            cout << fr[sf-1-i];
        }
        cout << s;
        rep(i,sb){
            cout << bck[i];
        }
    }
    else{
        int sf = (int)fr.size();
        int sb = (int)bck.size();
        rep(i,sb){
            cout << bck[sb-1-i];
        }
        rep(j,s.size()){
            cout << s[s.size()-1-j];
        }
        rep(i,sf){
            cout << fr[i];
        }
    }
    
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;


int main() {
    int A, B, m; cin >> A >> B >> m;
    V a(A), b(B);
    rep(i, 0, A) cin >> a[i];
    rep(i, 0, B) cin >> b[i];
    V x(m), y(m), c(m);
    rep(i, 0, m) cin >> x[i] >> y[i] >> c[i];

    ll ans = 1001001001001;
    rep(i, 0, m){
        ll n = a[x[i]-1] + b[y[i]-1] - c[i];
        ans = min(ans, n);
    }

    sort(ALL(a));
    sort(ALL(b));
    if(ans > a[0] + b[0]) ans = a[0] + b[0];

    cout << ans << endl;
    
}

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

int lower_bound(int *A, int N, int key) {
  int left = 0;
  int right = N;

  while (left < right) {
    int mid = (left + right) / 2;
    if (key <= A[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return left;
}

int upper_bound(int *A, int N, int key) {
  int left = 0;
  int right = N;

  while (left < right) {
    int mid = (left + right) / 2;
    if (key < A[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return left;
}

int main() {
  int N;
  cin >> N;

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

  int Q;
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int k;
    cin >> k;
    int ansL = lower_bound(A, N, k);
    int ansU = upper_bound(A, N, k);
    cout << ansL << ' ' << ansU << endl;
  }

  return 0;
}



Measured memory_bytes: 3476
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;


main(){
    int n=in();
    map<int,int> m;
    int cnt=0;
    vec v;
    rep(i,n){
        int a=in();
        v.pb(a);
        if(m[a]==0)cnt++;
        m[a]++;
    }
    if(cnt>3){
        cout<<"No";
    }
    else{
        if(cnt==1){
            if(m[0]==0){
                cout<<"No";
            }
            else{
                cout<<"Yes";
            }
        }
        else if(cnt==2){
            if(n%3){
                cout<<"No";
            }
            else{
                if(m[0]==0){
                    cout<<"No";
                }
                else{
                    int res=m[0];
                    if(res==n/3||res==n*2/3){
                        cout<<"Yes";
                    }
                    else{
                        cout<<"No";
                    }
                }
            }
        }
        else{
            if(n%3){
                cout<<"No";return 0;
            }
            sort(all(v));
            v.erase(unique(all(v)),v.end());
            if((v[0]^v[1])==v[2]){
                if(m[v[0]]==n/3&&m[v[1]]==n/3){
                    cout<<"Yes";
                }
                else{
                    cout<<"No";
                }
            }
            else{
                cout<<"No";
            }
        }
    }
}



Measured memory_bytes: 4216
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    cout << (a + b >= 24 ? a + b - 24 : a + b) << endl;
}


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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL,LL> PLL;
typedef map<int,int> MII;
typedef queue<int> QI;
typedef queue<PII> QPII;
typedef stack<int> SI;
typedef stack<PII> SPII;
typedef deque<int> DI;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define PF push_front
#define POB pop_back()
#define POF pop_front()
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REPR(i,n) RFOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = INT_MAX;
const LL LINF = LLONG_MAX;
const LL MOD = 1e9+7;
const LL MODD = 998244353;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// << fixed << setprecision()

VI dx = {1,0,-1,0,1,1,-1,-1};
VI dy = {0,1,0,-1,1,-1,1,-1};

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(N == 0) {
    return 0;
  }
  
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int H,W,D,E,A,L,R;
  cin >> H >> W >> D;
  VPII xy(H*W);
  VI DP(H*W,0);
  REP(i,H){
    REP(j,W){
      cin >> A;
      xy.at(A-1) = MP(i,j);
    }
  }
  
  FOR(i,D,H*W){
    DP.at(i) = DP.at(i-D) + abs(xy.at(i).FI - xy.at(i-D).FI) + abs(xy.at(i).SE - xy.at(i-D).SE);
  }
  
  int Q;
  cin >> Q;
  
  REP(i,Q){
    cin >> L >> R;
    L--,R--;
    cout << DP.at(R) - DP.at(L) << endl;
  }
                                                                
  return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
    string S;
    cin>>S;
    if(S.size()<4){
       cout<<"No"<<endl;
    }else{
       if(S[0]=='Y'&&S[1]=='A'&&S[2]=='K'&&S[3]=='I'){
          cout<<"Yes"<<endl;
       }else{
          cout<<"No"<<endl;
       }
    }
	return(0);
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath> // sqrt
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

struct line {
    pii p1;
    pii incline;
};


enum type {
    TYPE_NONE,
    TYPE_ORTHOGONAL,
    TYPE_PARALLEL,
};

#define _x first
#define _y second

int inner_prod(pii p1, pii p2) {
    return (p1._x * p2._x) + (p1._y * p2._y);
}

int outer_prod(pii p1, pii p2) {
    return (p1._x * p2._y) - (p1._y * p2._x);
}

int main(void) {
    pii p1;
    pii p2;
    int num;
    cin >> num;
    for(int n = 0; n < num; n++) {
        cin >> p1.first >> p1.second;
        cin >> p2.first >> p2.second;
        pii inc1 = make_pair(p2.first - p1.first,
            p2.second - p1.second
        );
        cin >> p1.first >> p1.second;
        cin >> p2.first >> p2.second;
        pii inc2 = make_pair(
            p2.first - p1.first,
            p2.second - p1.second
        );
        int type = 0;
        if(!inner_prod(inc1, inc2)) {
            type = TYPE_ORTHOGONAL;
        } else if (!outer_prod(inc1, inc2)) {
            type = TYPE_PARALLEL;
        } else {
            type = TYPE_NONE;
        }
        cout << type << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
        string s,t; cin>>s>>t;
        int n1=s.length(),n2=t.length();
        if(n2!=(n1+1)) { cout<<"No"<<endl; return 0;}
        for(int i=0;i<n1;i++) if(s[i]!=t[i]) { cout<<"No"<<endl; return 0;}
        cout<<"Yes"<<endl;
        return 0;
}



Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl p(n);
    rep(i, n) {
        cin >> p[i];
    }

    ll ans = 0;
    exrep(i, 1, n-2) {
        vl v(3);
        v[0] = p[i-1];
        v[1] = p[i];
        v[2] = p[i+1];
        sort(all(v));
        if(v[1] == p[i]) {
            ans++;
        }
    }
    
    out(ans);
    re0;
}

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

using namespace std;

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

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

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


int main()
{
  int N;
  cin >> N;
  string ans = "";

  if(N == 0) {
    cout << 0 << endl;
    return 0;
  }

  while(1) {
    int k, l;
    if(N == 0) break;

    if(N < 0) {
      k = (-N) / 2;
      l = (-N) % 2;
      if(l == 0) {
        ans += '0';
        N = k;
      } else {
        ans += '1';
        N = k + 1;
      }
    } else if(N > 0) {
      k = N / 2;
      l = N % 2;
      if(l == 0) ans += '0';
      else ans += '1';
      N = -k;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    int n=in();
    string s=stin();
    int len=(int)s.length();
    rep(i,len){
        char c=s[i];
        int num=c - 'A';
        num = (num + n)%26;
        char cc='A'+num;
        cout<<cc;
    }
    cout<<endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> b(n-1);
	for (int i = 0; i < n-1; i++)
		cin >> b[i];

	int ans = b[0];
	for (int i = 0; i < n-2; i++)
		ans += min(b[i], b[i+1]);
	ans += b[n-2];

	cout << ans << endl;
}

Measured memory_bytes: 3516
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cmath>
using namespace std;


int main(){
	

	int n;
	int ind=0;
	char arr[100000];
	
	int a,b,c;
	cin>>n>>a>>b>>c;
	string cur;
	cin>>cur;
	for(int i=0;i<n;i++){
		if(cur=="AB"){
			if(a>b){
				arr[ind++]='B';
				if(i<n-1)cin>>cur;
				a--;
				b++;
				continue;
			}
			if(a<b){
				arr[ind++]='A';
				if(i<n-1)cin>>cur;
				a++;
				b--;
				continue;
			}
			if(a==b&&a==0){
				cout<<"No"<<endl;
				return 0;
			}
			if(a==b&&a!=0){
				if(i<n-1)cin>>cur;
				else {arr[ind++]='A';break;}
				if(cur=="AB"){
					arr[ind++]='A';
					arr[ind++]='B';
				  i++;
				  if(i<n-1)cin>>cur;
				  continue;
				}
				if(cur=="AC"){
					arr[ind++]='A';
					a++;
					b--;
				  continue;
				}
				if(cur=="BC"){
					arr[ind++]='B';
					b++;
					a--;
					continue;
				}
				
			}
		}
		if(cur=="BC"){
			if(b>c){
				arr[ind++]='C';
				if(i<n-1)cin>>cur;
				c++;
				b--;
				continue;
			}
			if(c>b){
				arr[ind++]='B';
				if(i<n-1)cin>>cur;
				b++;
				c--;
				continue;
			}
			if(c==b&&c==0){
				cout<<"No"<<endl;
				return 0;
			}
			if(c==b&&c!=0){
				if(i<n-1)cin>>cur;
				else {arr[ind++]='C';break;}
				if(cur=="BC"){
					arr[ind++]='C';
					arr[ind++]='B';
				  i++;
				  if(i<n-1)cin>>cur;
				  continue;
				}
				if(cur=="AC"){
					arr[ind++]='C';
					c++;
					b--;
				  continue;
				}
				if(cur=="AB"){
					arr[ind++]='B';
					b++;
					c--;
					continue;
				}
			}
		}
		if(cur=="AC"){
			if(a>c){
				arr[ind++]='C';
				if(i<n-1)cin>>cur;
				c++;
				a--;
				continue;
			}
			if(c>a){
				arr[ind++]='A';
				if(i<n-1)cin>>cur;
				a++;
				c--;
				continue;
			}
			if(c==a&&c==0){
				cout<<"No"<<endl;
				return 0;
			}
			if(c==a&&c!=0){
				if(i<n-1)cin>>cur;
				else {arr[ind++]='A';break;}
				if(cur=="AC"){
					arr[ind++]='C';
					arr[ind++]='A';
				  i++;
				  if(i<n-1)cin>>cur;
				  continue;
				}
				if(cur=="BC"){
					arr[ind++]='C';
					c++;
					a--;
				  continue;
				}
				if(cur=="AB"){
					arr[ind++]='A';
					a++;
					c--;
					continue;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<ind;i++)cout<<arr[i]<<endl;
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

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

    string ans;
    if (s == "ABC")
    {
        ans = "ARC";
    }
    else
    {
        ans = "ABC";
    }

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

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int N; cin >> N;
    double ans = 0;
    F0R(i, N) {
        double D; cin >> D;
        ans += 1.0/D;
    }
    ans = 1.0/ans;

    cout << setprecision(20) << ans << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343
// license: https://github.com/bqi343/USACO/blob/master/LICENSE

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int n ;

int main() {

  cin >> n ;
  cout << ( n >= 1000 ? "ABD" : "ABC" ) ;


  return 0 ;
}


Measured memory_bytes: 256
n,m,k=gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(' ').map(&:to_i)
b = gets.chomp.split(' ').map(&:to_i)

ans = 0
c = Array.new(n+1){0}
d = Array.new(m+1){0}

n.times do |i|
  c[i+1] = c[i] + a[i]
end
m.times do |l|
  d[l+1] = d[l] + b[l]
end
bm = m
(n+1).times do |i|
  break if c[i] > k
  while d[bm] > k - c[i]
   bm -= 1
  end
  if ans < bm + i 
    ans = bm + i
  end
end
puts ans

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

pair<int,pair<int,int>> dp[3030][3030];
string S,T;
int SS,TT;

int main(){
  rep(i,3030) rep(j,3030) dp[i][j]={-1,{-1,-1}};
  cin>>S>>T;
  SS=S.length(),TT=T.length();
  queue<pair<int,int>> que;
  que.push({0,0});
  pair<int,int> ans={0,0};
  dp[0][0].first=0;
  while(que.size()){
    auto p=que.front(); que.pop();
    int s=p.first, t=p.second;
    if(S[s]==T[t]){
      if(dp[s+1][t+1].first<dp[s][t].first+1){
        dp[s+1][t+1]={dp[s][t].first+1,{s,t}};
        if(dp[ans.first][ans.second].first<dp[s+1][t+1].first){
          ans={s+1,t+1};
        }
      }
      if(s+1>=SS&&t+1>=TT) continue;
      else que.push({s+1,t+1});
    }else{
      if(s+1<SS){
        if(dp[s+1][t].first<dp[s][t].first){
          dp[s+1][t]=dp[s][t];
          que.push({s+1,t});
        }
      }
      if(t+1<TT){
        if(dp[s][t+1].first<dp[s][t].first){
          dp[s][t+1]=dp[s][t];
          que.push({s,t+1});
        }
      }
    }
  }
  string res="";
  int s=ans.first, t=ans.second;
  while(dp[s][t].second.first>=0){
    int tmp=dp[s][t].second.first;
    t=dp[s][t].second.second;
    s=tmp;
    res+=S[s];
  }
  reverse(res.begin(),res.end());
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 107904
//#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
typedef long long  LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("e.in","r",stdin)
#define FOUT freopen("e.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

const LL N=403;
struct NODE{
	db o,r,d;
};
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;
LL ff[N][N],dp[N][N],A[N],B[N];

int main()
{
//	FIN;FOUT;
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0,u,v,cnt;
	cin>>n>>m;
	for(i=0;i<n;i++)cin>>A[i];
	for(i=0;i<n;i++)cin>>B[i];
//	ff[0][0]=1;
	for(i=1;i<N;i++){
		ff[i][0]=1;
		for(j=0;j<N-1;j++){
			ff[i][j+1]=ff[i][j]*i%MOD;
			ff[i][j]=(ff[i][j]+ff[i-1][j])%MOD;
		}
	}
	
	dp[0][0]=1;
	for(i=0;i<n;i++){
		for(j=0;j<=m;j++){
			cnt=(ff[B[i]][j]-ff[A[i]-1][j]+MOD)%MOD;
			for(k=j;k<=m;k++){
				dp[i+1][k]+=dp[i][k-j]*cnt%MOD;
				dp[i+1][k]%=MOD;
			}
		}
	}
	cout<<dp[n][m]<<endl; 
	return 0;
}

Measured memory_bytes: 2816
def compound_interest(n, r, t): 
    for i in range(t):
        n=n+int((n*r)/100)
    return n

x=int(input())
for i in range (1,100000):
    ci=compound_interest(100, 1, i)
    if(ci>=x):
        print(i)
        break
  

Measured memory_bytes: 9168
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=1e5+7;
int a[N];
int main()
{
	int n=ri(),i,last=0,ans=0;
	for(i=1;i<=n;i++)
	{
		a[i]=ri();
		if(a[i]==i)
		{
			if(!last)	last=i;
		}
		else
		{
			if(last)
			{
				ans+=(i-last+1)/2;
				last=0;
			}
		}
	}
	if(last)
	{
		ans+=(n-last+2)/2;
	}
	wi(ans);
	return 0;
}


Measured memory_bytes: 640
while (ln = gets.chomp) != '0 0'
  h, w = ln.split.map(&:to_i)
  h_ = h - 2
  w_ = w - 2
  puts '#'*w

  h_.times do
    puts '#' + '.'*w_ + '#'
  end

  puts '#'*w
  puts
end

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

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

using namespace std;
using lint=long long;

int main(){
	int m; scanf("%d",&m);

	lint ans=m-1,sum=0;
	rep(i,m){
		int d;
		lint c; scanf("%d%lld",&d,&c);
		ans+=c-1;
		sum+=c*d;
	}
	ans+=sum/9;
	if(sum%9==0) ans--;

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

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split(" ")]
B = [int(x) for x in input().split(" ")]

count = 0
for i in range(N):
    n_defeat = min(A[i], B[i])
    A[i] -= n_defeat
    B[i] -= n_defeat
    count += n_defeat
    n_defeat = min(A[i + 1], B[i])
    A[i + 1] -= n_defeat
    B[i] -= n_defeat
    count += n_defeat

print(count)

Measured memory_bytes: 18624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;

int main(){
  int N;
  cin >> N;
  ll sum = 0;
  int a[N];
  rep(i, N){
    cin >> a[i];
    sum += a[i];
  }
  ll ave = sum/N;
  ll ans1=0, ans2=0;
  rep(i, N){
    ans1 += pow((a[i] - ave), 2);
    ans2 += pow((a[i] - ave - 1), 2);
  }
  cout << min(ans1, ans2) << endl;
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

int main(void) {
  ll n; cin >> n; --n;
  ll ans = (n * (n+1))/2;
  pl(ans)
  return 0;
}


Measured memory_bytes: 3620
def main():
    n = int(input())
    v = list(map(int, input().rstrip().split(' ')))
    c = list(map(int, input().rstrip().split(' ')))
    print(sum([vi - ci for vi, ci in zip(v, c) if vi - ci > 0]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQ;
typedef map<int, const char*> MAP;
typedef set<PA> SET;
#define fi first
#define se second
#define pb push_back
#define REP(i,j,n) for(ll i = (ll)(j);i < (ll)(n);i++)
#define INF 1000000001
#define MOD 10000
#define MAXD 201
#define MAXN 100001
#define MAXM 1001

int a,b,c,i;
PQ que;
int l1,l2,l3;

int main()
{
    cin >> a >> b >> c;
    que.push(a);
    que.push(b);
    que.push(c);
    while(1){
        l1 = que.top();que.pop();
        l2 = que.top();que.pop();
        l3 = que.top();que.pop();
        if(l1 == l2 && l2 == l3){
            cout << i << endl;
            break;
        }
        else if(l1 != l2){
            l1 += 2;
            que.push(l1);
            que.push(l2);
            que.push(l3);

        }
        else if(l1 == l2){
            l1++;
            l2++;
            que.push(l1);
            que.push(l2);
            que.push(l3);
        }
        i++;
        //cout << i << " " << l1  << " " << l2  << " " << l3 << endl;
    }

    return 0;
}
/*O(10 ^ 8)　が限界 (2s以内)
    REP(i,a){
        REP(j,b){
4 4
1 2 100
2 3 250
2 4 200
3 4 100

        }
    }
*/



Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

struct edge {
    int from, to;
};

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N;

int d1[MAX_N + 1], d2[MAX_N + 1];
vector<edge> T[MAX_N + 1];

void getCost(int s, int* arr);

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

    cin >> N;

    for (int i = 1; i < N; i++) {
        int s, t;
        cin >> s >> t;
        edge es = { s, t };
        T[s].push_back(es);
        edge et = { t, s };
        T[t].push_back(et);
    }
    getCost(1, d1);
    getCost(N, d2);

    int f = 0;
    int sn = 0;
    for (int i = 1; i <= N; i++) {
        if (d1[i] > d2[i]) {
            sn++;
        } else {
            f++;
        }
    }

    /*
    for (int i = 1; i <= N; i++) {
        cout << "i = " << i << ", d1 = " << d1[i] << "\n";
    }
    for (int i = 1; i <= N; i++) {
        cout << "i = " << i << ", d2 = " << d1[i] << "\n";
    }
    */

    if (f > sn) {
        cout << "Fennec\n";
    } else {
        cout << "Snuke\n";
    }

    return 0;
}

void getCost(int s, int* arr)
{
    memset(arr, -1, sizeof(int) * (N + 1));
    queue<int> que;
    que.push(s);
    arr[s] = 0;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        //cout << "v = " << v << "\n";
        for (int i = 0; i < T[v].size(); i++) {
            edge e = T[v][i];
            if (arr[e.to] == -1) {
                arr[e.to] = arr[v] + 1;
                que.push(e.to);
                //cout << " e.to = " << e.to << "\n";
            }
        }
    }
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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 GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

int main()
{
	int r, d, x;
	cin >> r >> d >> x;

	int tmp = x;

	for (int i = 0; i < 10; i++)
	{
		cout << r * tmp - d << endl;
		tmp = r * tmp - d;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadLong();
            if (N == 1) { Console.WriteLine(0); return; }
            var ans = 0L;
            for (int i = 1; i <= Math.Sqrt(N); i++)
            {
                if (N % i == 0)
                {
                    var chk = N / i - 1;
                    var ama = N % chk;
                    if (i == ama) ans += chk;
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

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

    string s;
    cin >> s;

    map<char, int> mp;
    for (auto x: s)
        mp[x]++;
    int ans = 1;
    for (auto x: mp) {
        ans *= (x.second + 1);
        ans %= MOD;
    }
    cout << (ans - 1 + MOD) % MOD << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 512
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
def s():
 print(*d(list(map(int,input().split()))))
 print(c)
if'__main__'==__name__:c=-int(input());s()


Measured memory_bytes: 61648
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int H,W;
string s[500];
int x[26][2],y[26][2];
int sgn(int x){
	if(x>0) return -1;
	return 1;
}
int main(){
	cin>>H>>W;
	rep(i,H) cin>>s[i];
	rep(i,26) rep(j,2) x[i][j]=y[i][j]=-1;
	rep(i,H) rep(j,W){
		if(s[i][j]!='.'){
			int c=s[i][j]-'A';
			if(x[c][0]<0) x[c][0]=i,y[c][0]=j;
			else x[c][1]=i,y[c][1]=j;
		}
	}
	bool update=true;
	int ans=0;
	bool is[26]={};
	rep(i,26){
		is[i]=(x[i][0]>=0);
	}
	while(update){
		update=false;
		rep(i,26) if(is[i]){
			if(x[i][0]==x[i][1]){
				if(y[i][0]>y[i][1]) swap(y[i][0],y[i][1]);
				if(y[i][0]+1==y[i][1]) continue;
				bool ok=true;
				for(int yi=y[i][0]+1;yi<y[i][1];yi++) if(s[x[i][0]][yi]!='.') ok=false;
				if(ok){
					update=true;
					ans+=2;
					s[x[i][0]][y[i][0]]='.';
					s[x[i][1]][y[i][1]]='.';
					is[i]=0;
				}
			}else if(y[i][0]==y[i][1]){
				if(x[i][0]>x[i][1]) swap(x[i][0],x[i][1]);
				if(x[i][0]+1==x[i][1]) continue;
				bool ok=true;
				for(int xi=x[i][0]+1;xi<x[i][1];xi++) if(s[xi][y[i][0]]!='.') ok=false;
				if(ok){
					update=true;
					ans+=2;
					s[x[i][0]][y[i][0]]='.';
					s[x[i][1]][y[i][1]]='.';
					is[i]=0;
				}
			}else{
				int xi=x[i][0],yi=y[i][1];
				bool ok=true;
				for(;xi!=x[i][1];xi+=sgn(x[i][0]-x[i][1])) if(s[xi][yi]!='.') ok=false;
				xi=x[i][0];
				for(;yi!=y[i][0];yi+=sgn(y[i][1]-y[i][0])) if(s[xi][yi]!='.') ok=false;
				if(ok){
					update=true;
					ans+=2;
					s[x[i][0]][y[i][0]]='.';
					s[x[i][1]][y[i][1]]='.';
					is[i]=0;
					continue;
				}
				swap(x[i][0],x[i][1]);
				swap(y[i][0],y[i][1]);
				xi=x[i][0],yi=y[i][1];
				ok=true;
				for(;xi!=x[i][1];xi+=sgn(x[i][0]-x[i][1])) if(s[xi][yi]!='.') ok=false;
				xi=x[i][0];
				for(;yi!=y[i][0];yi+=sgn(y[i][1]-y[i][0])) if(s[xi][yi]!='.') ok=false;
				if(ok){
					update=true;
					ans+=2;
					s[x[i][0]][y[i][0]]='.';
					s[x[i][1]][y[i][1]]='.';
					is[i]=0;
					continue;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1484