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


using namespace std;

using ll = long long;


template<long long M>
class modint {
    public:
        long long a;
        modint(const long long x = 0LL) : a((x % M + M) % M) {}
        long long &value() { return a; }
        modint operator+(const modint rhs) const {
            return modint(*this) += rhs;
        }
        modint operator-(const modint rhs) const {
            return modint(*this) -= rhs;
        }
        modint operator*(const modint rhs) const {
            return modint(*this) *= rhs;
        }
        modint operator/(const modint rhs) const {
            return modint(*this) /= rhs;
        }
        modint &operator+=(const modint rhs) {
            a += rhs.a;
            if (a >= M) {
                a -= M;
            }
            return *this;
        }
        modint &operator-=(const modint rhs) {
            if (a < rhs.a) {
                a += M;
            }
            a -= rhs.a;
            return *this;
        }
        modint &operator*=(const modint rhs) {
            a = a * rhs.a % M;
            return *this;
        }
        modint pow(long long n) const {
            modint ret(1);
            modint x = *this;
            while (n) {
                if ((n & 1) == 1) {
                    ret *= x;
                }
                n >>= 1;
                x *= x;
            }
            return ret;
        }
        modint inv() const {
            return pow(M - 2);
        }
        modint &operator/=(const modint rhs) {
            return *this *= rhs.inv();
        }
};

const long long M = 1000000007;

using mint = modint<M>;


int main(void) {
    ll N;
    cin >> N;
    map<pair<ll, ll>, pair<ll, ll>> cnt_slope;
    ll zero = 0;
    for (ll i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) {
            zero++;
            continue;
        }
        ll g = gcd(x, y);
        x /= g;
        y /= g;
        if (y < 0) {
            x = -x;
            y = -y;
        }
        if (y == 0 && x < 0) {
            x = -x;
        }
        bool rot90 = x <= 0;
        if (rot90) {
            ll t = x;
            x = y;
            y = -t;
            cnt_slope[make_pair(x, y)].first++;
        } else {
            cnt_slope[make_pair(x, y)].second++;
        }
    }

    mint ans = 1;
    for (auto p : cnt_slope) {
        mint tmp = 0;
        tmp += mint(2).pow(p.second.first) - 1;
        tmp += mint(2).pow(p.second.second) - 1;
        tmp += 1;
        ans *= tmp;
    }
    ans -= 1;
    ans += zero;
    cout << ans.a << endl;
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,sum=0;
    c_p_c();
  	int a,b,c;
  	cin>>a>>b>>c;
   		int p=0;
  		int temp=a;
  		for (int i = 1; i < 1000; ++i)
  		{
  			/* code */
  			// watch((temp*i)%b);
  			if((temp*i)%b==c){
  				cout<<"YES"<<endl;
  				p=1;
  				break;
  			}
  		}
  		if(!p)
  			cout<<"NO"<<endl;




  	
 	return 0;

   }

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string o, e; std::cin >> o >> e;
  int oi = 0, ei = 0;
  while (oi < o.size() || ei < e.size()) {
    if (oi < o.size()) std::cout << o[oi++];
    if (ei < e.size()) std::cout << e[ei++];
  }
  std::cout << "\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    n, t = map(int, input().split())
    an = list(map(int, input().split()))

    mi = [an[0]]
    se_mi = {0}
    for i in range(1, n):
        if mi[i - 1] > an[i]:
            se_mi = {i}
        elif mi[i - 1] == an[i]:
            se_mi.add(i)
        mi.append(min(mi[i - 1], an[i]))

    ma = 0
    se_ma = set()
    for i in range(1, n):
        be = an[i] - mi[i - 1]
        if be > ma:
            ma = be
            se_ma = {i}
        elif be == ma:
            se_ma.add(i)
    print(len(se_ma))

main()


Measured memory_bytes: 15060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll n; cin >> n;
    vector<int> a(n + 2);
    a[0] = 0;
    a[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    ll original = 0;
    for (int i = 1; i < n + 2; ++i) {
        original += abs(a[i] - a[i - 1]);
    }

    for (int i = 1; i <= n; ++i) {
        ll res = original - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i - 1]);
        cout << res << endl;
    }
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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;
  }

  // for prime mod
  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;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    ll n, k;
    cin >> n >> k;
    VIN(ll, a, n);
    for (ll i = k; i < n; i++) {
        Yes(a[i]>a[i-k]);
    }
}


Measured memory_bytes: 4772
n=int(input())
alist=list(map(int, input().split()))
blist=list(map(int, input().split()))
clist=list(map(int, input().split()))
manzoku=sum(blist)
for i in range(n-1):
    if alist[i+1]==alist[i]+1:
        manzoku+=clist[alist[i]-1]
print(manzoku)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;

inline long long func(long long K) {
    long long res = (K*(K-1))/2;
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> sum(N+1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum[i+1] = sum[i] + A[i];
    }
    sort(sum.begin(), sum.end());
    long long ans = 0, now = sum[0];
    int cnt = 0;
    sum.emplace_back(INF);
    
    for (int i = 0; i < (int)sum.size(); i++) {
        if (sum[i] == now) {
            cnt++;
        } else {
            ans += func(cnt);
            cnt = 1;
            now = sum[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
#define M 1000000007
#define MM 2000000000000000000
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define r2 1.41421356237
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
  int n;
  cin>>n;
  ll c=0;
  for(int i=1;i<n;i++) {
  	for(int j=1;1LL*j*j<=i;j++) {
  		if(i%j==0) { if(j==i/j) { c++; } else { c+=2; } }
  	}
  }
  cout<<c;
  //}
  return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur,a,b,c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

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

using namespace std;

#define ll long long 
#define Fastest ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	ll n;
	
	cin >> n;
	
	ll ans = n*(n-1);
	
	cout << ans/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cerr;
using std::endl;
using std::cout;
using std::cin;

const int N = 233;

std::vector<char> buc;
int len;
std::set<std::pair<int, std::string>> set;

inline int query(std::string str) {
  cout << "? " << str << endl;
  int x; cin >> x; return x;
}

inline std::string merge(std::string A, std::string B) {
  int i = 0, j = 0, sA = A.size(), sB = B.size();
  std::string str = "";
  while (i < sA && j < sB) {
    std::string tmp = str + A[i];
    for (int k = j; k < sB; ++k)
      tmp += B[k];
    int x = query(tmp);
    if (x + tmp.size() == len)
      str += A[i++];
    else
      str += B[j++];
  }
  while (i < sA) str += A[i++];
  while (j < sB) str += B[j++];
  return str;
}

int main() {
  for (int i = 0; i < 10; ++i)
    buc.emplace_back(i + '0');
  for (int i = 0; i < 26; ++i)
    buc.emplace_back(i + 'a');
  for (int i = 0; i < 26; ++i)
    buc.emplace_back(i + 'A');
  /*
  for (char c : "abc")
    buc.emplace_back(c);
  buc.pop_back();
  */

  for (char c : buc) {
    std::string str(128, c);
    int x = 128 - query(str);
    if (x == 0) continue;
    if (!len)
      len = query(std::string(1, c)) + 1;
    std::string now(x, c);
    set.insert({ x, now });
  }

  while (set.size() > 1) {
    std::string A = set.begin()->second;
    set.erase(set.begin());
    std::string B = set.begin()->second;
    set.erase(set.begin());
    std::string str = merge(A, B);
    set.insert({ (int)str.size(), str });
  }

  cout << "! " << set.begin()->second << endl;

  return 0;
}


Measured memory_bytes: 3812
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}


void solve()
{
  ll N;
  std::cin >> N;

  std::vector< std::pair<ll, ll> > vp(N);
  for (ll i = 0; i < N; i++) {
    std::cin >> vp[i].second >> vp[i].first;
  }

  std::sort(vp.begin(), vp.end(), std::greater<>());

  ll ans = vp[N-1].second - vp[0].second + 1;
  ans += vp[0].second - 1;
  ans += vp[N-1].first;

  print(ans);
  return;
}

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

  solve();
  return 0;
}



Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(' ').map { it.toLong() }

    var ans = 0L
    var x = 2L
    var l = b
    while (l > 0) {
        l = l shr 1

        val ac = f(a - 1, x)
        val bc = f(b, x)

        ans += if ((bc - ac) % 2 == 1L) x shr 1 else 0L

        x = x shl 1
    }
    println(ans)
}

private fun f(x: Long, y: Long): Long {
    return (x + 1) / y * (y shr 1) + Math.max(0L, (x + 1) % y - (y shr 1))
}


Measured memory_bytes: 38308
from collections import defaultdict


def solve(pre_is_positive, total, ans, a_list):
    for a in a_list:
        total += a
        if pre_is_positive:
            if total == 0:
                ans += 1
                total = -1
            elif total > 0:
                ans += abs(total) + 1
                total = -1
        elif not pre_is_positive:
            if total == 0:
                ans += 1
                total = 1
            elif total < 0:
                ans += abs(total) + 1
                total = 1

        pre_is_positive = total > 0

    return ans


def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    total = a_list[0]
    if total == 0:
        ans = solve(True, 1, 1, a_list[1:])
        ans = min(ans, solve(False, -1, 1, a_list[1:]))
    elif total > 0:
        ans = solve(True, total, 0, a_list[1:])
        ans = min(ans, solve(False, -1, abs(total) + 1, a_list[1:]))
    else:
        ans = solve(False, total, 0, a_list[1:])
        ans = min(ans, solve(True, 1, abs(total) + 1, a_list[1:]))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14708
#include<iostream>
using namespace std;
string a;
int ans;
int main(){
	cin>>a;
	if(a[0]=='2') ans++;
	if(a[1]=='2') ans++;
	if(a[2]=='2') ans++;
	if(a[3]=='2') ans++;
	cout<<ans;
	return 0;
}

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

int main(){
	string s,t;
	cin >> s;
	cin >> t;
	int ans=0;
	for(int i=0;i<3;i++){
		if(s[i]==t[i]){ans+=1;}
		}
		
	cout << ans << endl;
	
	return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

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

    //??????????????????????????????????????¨?????????
    vector<int> a(n+2,0);
    for(int i=1; i<=n; ++i) scanf(" %d", &a[i]);

    //?????????i??????????????????
    long t[100002]={0};

    queue<int> que;
    //?????????????????????????????????????????¢???
    for(int i=1; i<=n; ++i)
    {
        //???????????????????§???????
        if(a[i-1]<a[i] && a[i]>a[i+1]) que.push(i);
    }

    vector<int> b(a);

    while(!que.empty())
    {
        int idx=que.front();
        que.pop();

        long tmp=L-a[idx];
        if(b[idx-1]==0) tmp=max(tmp,t[idx-1]+(L-a[idx]));
        if(b[idx+1]==0) tmp=max(tmp,t[idx+1]+(L-a[idx]));
        //?????????
        b[idx]=0;
        t[idx]=tmp;
        //printf("idx=%d, tmp=%ld\n", idx,tmp);

        int nx=idx-1;
        if(b[nx-1]<b[nx] && b[nx]>b[nx+1]) que.push(nx);
        nx=idx+1;
        if(b[nx-1]<b[nx] && b[nx]>b[nx+1]) que.push(nx);
    }

    long ans=0;
    for(int i=1; i<=n; ++i) ans=max(ans,t[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4808
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000000;
const long long MOD = 1000000007;

long long f(long long N){
  string s = to_string(N);
  long long ret = 0;
  for (int i = 0; i < s.length();i++){
    ret += s[i] - '0';
  }
  return ret;
}

int main()
{
  long long N;
  cin >> N;
  for (int i = 0; i < N;i++){
    string s;
    cin >> s;
    if(s=="Y"){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

class DisjointSet {
 public:
  DisjointSet(int size) : parent_(size), size_(size, 1) {
    for (int i = 0; i < size; ++i) {
      parent_[i] = i;
    }
  }
  int Find(int x) {
    int& p = parent_[x];
    if (p != x) p = Find(p);
    return p;
  }
  void Union(int x, int y) {
    x = Find(x), y = Find(y);
    if (x == y) return;
    if (Size(x) > Size(y)) std::swap(x, y);
    parent_[x] = parent_[y];
    size_[y] += size_[x];
  }
  int Size(int x) { return size_[Find(x)]; }
  bool Same(int x, int y) { return Find(x) == Find(y); }

 private:
  std::vector<int> parent_, size_;
};

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

  in(int, n, m);
  V<int> p(n);
  rep(i, n) cin >> p[i];
  DisjointSet ds(n);
  rep(i, m) {
    in(int, x, y);
    ds.Union(x - 1, y - 1);
  }
  int ans = 0;
  rep(i, n) if (ds.Same(i, p[i] - 1))++ ans;
  out(ans);
}


Measured memory_bytes: 4440
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

int main()
{
	int N,A,B;
	int P[110]={};
	int ans[3]={};
	
	cin >> N >> A >> B;
	for(int i=0;i<N;i++)
	{
		cin >> P[i];
		if(P[i]<=A)ans[0]++;
		else if(P[i]<=B)ans[1]++;
		else ans[2]++;
	}
		
	cout << min({ans[0],ans[1],ans[2]}) << endl;
	return 0;
}



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

int main() {
	char a[4];
	for (int i = 0; i < 4; i++) {
		cin >> a[i];
	}
	int x = (a[0] - '0') * 10 + (a[1] - '0');
	int y = (a[2] - '0') * 10 + (a[3] - '0');
	if (0 < x && x <= 12) {
		if (0 < y && y <= 12) {
			cout << "AMBIGUOUS";
		}
		else cout << "MMYY";
	}
	else if (0 < y && y <= 12) {
		cout << "YYMM";
	}
	else cout << "NA";
}


Measured memory_bytes: 256
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    q = int(input())

    dq = deque(s)
    head_is_0 = 1
    for _ in range(q):
        query = iter(input().rstrip().split())
        if next(query) == '1':
            head_is_0 ^= 1
        elif (next(query) == '2') ^ head_is_0:
            dq.appendleft(next(query))
        else:
            dq.append(next(query))

    if not head_is_0:
        dq.reverse()

    ret = ''.join(dq)
    print(ret)


if __name__ == '__main__':
    main()


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

int main(){
    long long n;
    cin>>n;
    long long a[n];
    bool win=false;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2) win=true;
    }

    if(win) {
        cout<<"first";
    }
    else cout<<"second";

}

Measured memory_bytes: 1024
var
 a:array[0..100005] of longint;
 n,i,s,ans:longint;
procedure qsort(l,r:longint);
var
 i,j,t,m:longint;
begin
 i:=l;j:=r;m:=a[(l+r) div 2];
 repeat
  while a[i]<m do inc(i);
  while a[j]>m do dec(j);
  if i<=j then
   begin
    t:=a[i]; a[i]:=a[j]; a[j]:=t; 
    inc(i); dec(j);
   end;  
 until i>j;
 if l<j then qsort(l,j);
 if i<r then qsort(i,r);
end; 
begin
 readln(n);
 for i:=1 to n do readln(a[i]);
 qsort(1,n);
 s:=1;
 for i:=2 to n do
  begin
   if a[i]=a[i-1] then s:=(s+1) mod 2
   else begin ans:=ans+s;s:=1;end;
  end;
  if odd(s mod 2) then inc(ans);
  writeln(ans);
end.

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int n,t,ans;
  ans=1001;
  int count=0;
  cin>>n>>t;
  for(int i=0;i<n;i++){
    int c,x;
    cin>>c>>x;
    if(x<=t){ans=min(ans,c); count++;}
  }
  if(count){cout<<ans;}
  else{cout<<"TLE";}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  if(a+b==c){
    cout<<"Yes"<<endl; 
  }
  else if(b+c==a){
    cout<<"Yes"<<endl;
  }
  else if(c+a==b){
    cout<<"Yes"<<endl;
  }
  else {cout<<"No"<<endl;
  }
}

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

int main(){
  int n;
  cin>> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin>>a[i];
  
  int num=1;
  for (int i=0; i<n; i++){
    if (a[i]==num){
      num++;
    }
  }
  if (num==1) cout<<-1<<endl;
  else cout<<n-num+1<<endl;
}

Measured memory_bytes: 1024
N=int(input())
S=input()

w=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

result=""
for i in range(len(S)):
    idx=w.index(S[i])
    new_idx=(idx+N)%len(w)
    result=result+w[new_idx]

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    int n, a = 0;
    cin >> n;
    string k;
    cin >> k;
    int b[n];
    rep(i, n) {
        cin >> b[i];
        b[i]--;
    }
    if (k.size() <= 6) {
        int s = stoi(k);
        int now = a;
        for (int t = 0; t < s; t++) {
            now = b[now];
        }
        cout << now + 1 << endl;
        return 0;
    }
    int now = a;
    int loop;
    int reached[n] = {}, pre[n];
    for (int t = 0;; t++) {
        if (reached[now] > 1) {
            loop = t - pre[now];
            break;
        }
        reached[now]++;
        pre[now] = t;
        now = b[now];
    }
    now = a;
    int tail = 0;
    for (tail = 0;; tail++) {
        if (reached[now] > 1) break;
        now = b[now];
    }
    int s = 0;
    for (int i = 0; i < k.size(); i++) {
        s = 10 * s + (k[i] - '0') % loop;
        s %= loop;
    }
    s -= tail;
    while (s < 0) s += loop;
    for (int t = 0; t < s; t++) {
        now = b[now];
    }
    cout << now + 1 << endl;
    return 0;
}


Measured memory_bytes: 5944
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, A, B = MAP()
S = input()

cnt = 0
cnt_for = 0
for i in range(N):
	if S[i] == "a" and cnt < A+B:
		cnt += 1
		print("Yes")
	elif S[i] == "b" and cnt < A+B and cnt_for < B:
		cnt += 1
		cnt_for += 1
		print("Yes")
	else:
		print("No")

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

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;
 
public:
  u64 a;
 
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

	using mint=modint<MOD>;

    cin>>s;
	vector<vector<mint>> dp(Size(s)+100,vector<mint>(5));
	//dp[i][j]:= (j=1:未満で確定してる) (j=0:いいえ)
	dp[0][0]=1;
	rrep(i,1,Size(s)+1){
		if(s[i-1]=='0'){
			//a+b==0
			dp[i][0]+=dp[i-1][0];
			dp[i][1]+=dp[i-1][1];

			//a+b=1
			dp[i][1]+=dp[i-1][1]*2;
		}
		else{
			//a+b==0
			dp[i][1]+=dp[i-1][1]+dp[i-1][0];

			//a+b=1
			dp[i][0]+=dp[i-1][0]*2;
			dp[i][1]+=dp[i-1][1]*2;
		}
	}
	mint ans=(dp[Size(s)][0]+dp[Size(s)][1]).value();
	Cout(ans.value());
    return 0;
}


Measured memory_bytes: 7376
//abc115_b.cpp
//Sat Dec 15 18:55:15 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	sort(p,p+n);
	ans = ans - p[n-1]/2;

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main(){
    ll c=1000000007;
    ll n,m; cin >> n >> m;
    ll ans=1;
    if(n==m){
        rep2(i,n+1){
            ans*=i;
            ans%=c;
        }
        ans=ans*ans;
        ans%=c;
        ans*=2;
        ans%=c;
        cout << ans << endl;
    }
    else if(n==m+1 || n==m-1){
        n=min(n,m);
        rep2(i,n+1){
            ans*=i;
            ans%=c;
        }
        ans=ans*ans;
        ans%=c;
        ans*=(n+1);
        ans%=c;
        cout << ans << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
//by NeighThorn
using namespace std;
const int maxn=200+5,maxm=10000+5;
int n,m,e,hd[maxn],to[maxm*2],nxt[maxm*2],cnt,pre[maxn],vis[maxn],ans;
inline void add(int x,int y){
	to[cnt]=y;nxt[cnt]=hd[x];hd[x]=cnt++;
}
inline bool dfs(int root){
	for(int i=hd[root];i!=-1;i=nxt[i])
		if(!vis[to[i]]){
			vis[to[i]]=1;
			if(pre[to[i]]==-1||dfs(pre[to[i]])){
				pre[to[i]]=root;
				return true;
			}
		}
	return false;
}
signed main(void){
	cnt=0;ans=0;
	memset(hd,-1,sizeof(hd));
	memset(pre,-1,sizeof(pre));
	scanf("%d%d%d",&n,&m,&e);
	for(int i=1,x,y;i<=e;i++)
		scanf("%d%d",&x,&y),add(x,y+n);
	for(int i=0;i<n;i++)
		memset(vis,0,sizeof(vis)),ans+=dfs(i);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3280
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int h, w;
char a[1005][1005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> h >> w;
  REP(i, h) REP(j, w) cin >> a[i][j];

  ll dp[1005][1005];

  dp[0][0] = 1LL;
  REP(i, h) REP(j, w) if(a[i][j] == '.') {
    if(j + 1 < w && a[i][j + 1] == '.') dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
    if(i + 1 < h && a[i + 1][j] == '.') dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
  }

  cout << dp[h - 1][w - 1] << endl;
}


Measured memory_bytes: 9088
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

# 入力
S = input()
Q = int(input())

Change = " "
counter = 0

for i in range(Q):
    # i+1 回目のinput
    proc = input().split()

    if proc[0] == "1":
        counter += 1
    else:
        # 先頭に文字列を足す場合
        if (counter%2 == 0 and proc[1] == "1") or (counter%2 == 1 and proc[1] == "2"):
            Change = proc[2] + Change
        else:
            Change = Change + proc[2]

if counter%2 == 0:
    print(Change.replace(" ",S))
else:
    print(Change.replace(" ",S)[::-1])



Measured memory_bytes: 4384
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    for(;;){
        int a,b,c; cin >> a >> b >> c;
        if(a==-1 && b==-1 && c==-1) break;
        else if(a==-1||b==-1) cout << 'F' << endl;
        else if(a+b>=80) cout << 'A' << endl;
        else if(a+b>=65) cout << 'B' << endl;
        else if(a+b>=50) cout << 'C' << endl;
        else if(a+b>=30 && c>=50) cout << 'C' << endl;
        else if(a+b>=30) cout << 'D' << endl;
        else cout << 'F' << endl;
    }

    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll dp[2005];
ll s;
int main(){
    cin>>s;
    dp[3]=1;
    dp[0]=1;
    for(int i=4;i<=s;i++){
        for(int j=0;j<=i-3;j++){
            dp[i]=(dp[i]+dp[j])%mod;
        }
    }
    cout<<dp[s];
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const Int MO = 1000000007;
Int dp[302][302][302], pw[303];

// void naive() {
//   int res=0;
//   const int nn=4;
//   for (int a=0;a<nn;++a)for(int b=0;b<nn;++b)for (int c=0;c<nn;++c)for (int d=0;d<nn;++d) for(int e=0;e<nn;++e)
//   for (int f=0;f<nn;++f)for(int g=0;g<nn;++g) {
//     int D[nn][nn];
//     memset(D, 0, sizeof(D));
//     D[0][a] = D[a][b] = D[b][c] = D[c][d] = D[d][e] = D[e][f] = D[f][g]=1;
//     for (int k=0;k<nn;++k)for (int i=0;i<nn; ++i)for(int j=0;j<nn;++j) {
//       D[i][j] |= D[i][k]&&D[k][j];
//     }
//     int ok=1;
//     for (int i=0;i<nn;++i){
//       ok&=D[0][i]&&D[i][0];
//     }
//     if(ok)++res;
//   }
//   printf("NAIVE: %d\n", res);
// }

int main() {
  int N = in();
  int M = in();
  pw[0] = 1;
  for (int i = 1; i <= M; ++i) {
    pw[i] = pw[i - 1] * N % MO;
  }
  dp[0][1][1] = 1;

  Int res = 0;
  for (int i = 0; i < M; ++i) {
    for (int j = 1; j <= i + 1 && j <= N; ++j) {
      for (int k = 1; k <= j; ++k) {
        // 1
        if (j == N) {
          (res += dp[i][j][k] * k % MO * pw[M - i - 1]) %= MO;
          // cerr<<i<<' '<<j<<' '<<k<<' '<<res<<endl;
        } else {
          (dp[i + 1][j][j] += dp[i][j][k] * k) %= MO;
        }

        // already
        (dp[i + 1][j][k] += dp[i][j][k] * (j - k)) %= MO;

        // new
        (dp[i + 1][j + 1][k] += dp[i][j][k] * (N - j)) %= MO;
      }
    }
  }
  // for (int i = 1; i <= M; ++i) {
  //   for (int j = 1; j <= i + 1 && j <= N; ++j) {
  //     printf("%d %d: ", i, j);
  //     for (int k = 1; k <= j; ++k) {
  //       printf("%lld ", dp[i][j][k]);
  //     }
  //     puts("");
  //   }
  // }

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

  return 0;
}


Measured memory_bytes: 108288
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<climits>
#include<queue>
 
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<long long> a(n), b(n);
	for (auto& e : a) cin >> e;
	for (auto& e : b) cin >> e;
	long long ans = 0;
	for (int k = 28; k >= 0; k--) {
		long long x = (1 << k);
		sort(a.begin(), a.end());
		int odd = 0;
		for (const auto& e : b) {
			odd += (a.end() - lower_bound(a.begin(), a.end(), x - e)) % 2;
			odd += (a.end() - lower_bound(a.begin(), a.end(), 2 * x - e)) % 2;
			odd += (a.end() - lower_bound(a.begin(), a.end(), 3 * x - e)) % 2;
		}
		// もし奇数なら
		if (odd%2) ans += x;
		for (auto& e : a) e %= x;
		for (auto& e : b) e %= x;
	}
	cout << ans << endl;

	return 0;
}

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

template<typename T, typename E, typename F, typename G, typename H>
class LazySegmentTree {
  int n, height;
  F f; G g; H h; const T ti; const E ei;
  vector<T> dat; vector<E> laz; vector<int> highest;

  void propagate(int k) {
    if(laz[k] != ei) {
      laz[2*k] = h(laz[2*k],laz[k]); laz[2*k+1] = h(laz[2*k+1],laz[k]);
      dat[k] = g(dat[k],laz[k],n/highest[k]);
      laz[k] = ei;
    }
  }
  inline void recalc(int k) {
    while(k >>= 1) dat[k] = f(g(dat[2*k],laz[2*k],n/highest[2*k]),g(dat[2*k+1],laz[2*k+1],n/highest[2*k+1]));
  }
  inline void thrust(int k) {
    for(int i = height; i > 0; i--) propagate(k >> i);
  }
public:
  LazySegmentTree(int _n, F f, G g, H h, T ti, E ei): f(f), g(g), h(h), ti(ti), ei(ei) {
    n = 1; height = 0;
    while(n < _n) n <<= 1, height++;
    dat.assign(2*n,ti); laz.assign(2*n,ei); highest.assign(2*n,0);
    int c = 1;
    for(int i = 1; i < 2*n; i++) {
      if(c*2 <= i) c <<= 1;
      highest[i] = c;
    }
  }
  void set(int k, T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int a, int b, const E x) {
    thrust(a += n); thrust(b += n-1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l],x), ++l;
      if(r & 1) --r, laz[r] = h(laz[r],x);
    }
    recalc(a); recalc(b);
  }
  T query(int a, int b) {
    thrust(a += n); thrust(b += n-1);
    T l = ti, r = ti; b++;
    while(a < b) {
      if(a & 1) l = f(l,g(dat[a],laz[a],n/highest[a])), a++;
      if(b & 1) b--, r = f(g(dat[b],laz[b],n/highest[b]),r);
      a >>= 1; b >>= 1;
    }
    return f(l,r);
  }
};

int main(){
  int n, q;
  cin >> n >> q;
  auto f = [](ll a, ll b){return min(a,b);};
  auto g = [](ll a, ll b, int l){return b == INF? a : b;};
  auto h = [](ll a, ll b){return b;};
  LazySegmentTree<ll,ll,decltype(f),decltype(g),decltype(h)> lst(n,f,g,h,INF,INF);
  rep(i,n) lst.set(i,((ll)1<<31)-1);
  lst.build();
  vector<ll> ans;
  rep(i,q) {
    int t;
    cin >> t;
    if(t == 0) {
      int l, r; ll x;
      cin >> l >> r >> x;
      lst.update(l,r+1,x);
    } else {
      int l, r;
      cin >> l >> r;
      ans.push_back(lst.query(l,r+1));
    }
  }
  for(auto x : ans) cout << x << endl;
  return 0;
}


Measured memory_bytes: 8912
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;


int main(void){
	ll n, a = 1;
	int b;
	string res = "";
	cin >> n;
	
	while(n != 0){
		a = n / 26;
		b = n % 26;

		if(b == 0){
			res += "z";
			n = a - 1;
		}
		else{
		       res += 'a' + b - 1;
		       n = a;
		}
	}
	
	reverse(res.begin(), res.end());
	cout << res << endl;


	return 0;
}


Measured memory_bytes: 3628
from collections import Counter
from heapq import heappop, heappush

N, M = map(int, input().split())
A = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]

pq = []
ctr = Counter(A)
for val, cnt in ctr.items():
    heappush(pq, (-val, cnt))

for b, c in X:
    heappush(pq, (-c, b))

cnt = 0
ans = 0
while cnt < N:
    val, c = heappop(pq)
    ans += val * min(c, N - cnt)
    cnt += c

print(-ans)


Measured memory_bytes: 115360
var
 i,j,n,l:longint;
 a:array[1..100] of string;
 t:string;
begin
 readln(n,l);
 for i:=1 to n do readln(a[i]);
 for i:=1 to n-1 do 
 for j:=i+1 to n do 
 if a[i]>a[j] then
  begin
   t:=a[i];
   a[i]:=a[j];
   a[j]:=t;
  end;
  for i:=1 to n do write(a[i]);
  end.

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int xs[1000010];
int ys[1000010];
int value[3000][3000];
pair<int, int> memo[1000010];;

vector<bool> is_prime;

std::vector<bool> prime_table(int N){
  std::vector<bool> is_prime(N + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= N; i++){
        if (is_prime[i]){
            for (int j = i * 2; j <= N; j += i) is_prime[j] = false;
        }
    }
    return is_prime;
}

pair<int, int> rec(int x, int y, int m){
  int v = value[x][y];
  if (v > m || v == -1) {
    return make_pair(0, 0);
  }

  if (memo[v].first != -1){
    return memo[v];
  }
  
  memo[v] = rec(x, y + 1, m);
  memo[v] = max(memo[v], rec(x - 1, y + 1, m));
  memo[v] = max(memo[v], rec(x + 1, y + 1, m));

  if (is_prime[v]){
    memo[v].first++;
    if (memo[v].second == 0){
      memo[v].second = v;
    }
  }
  return memo[v];
}

int main(){
  ios::sync_with_stdio(false);

  is_prime = prime_table(1000 * 1000);

  int x   = 1500;
  int y   = 1500;
  int dir = 0;
  int cur = 1;
  int len = 1;
  
  int dx[] = {1, 0, -1, 0};
  int dy[] = {0, -1, 0, 1};
  
  memset(value, -1, sizeof(value));
  REP2(i, 1, 1000 * 1000 + 1){
    value[x][y] = i;
    xs[i] = x;
    ys[i] = y;
    
    x += dx[dir];
    y += dy[dir];
    
    cur -= 2;
    if (cur <= 0){
      cur = ++len;
      dir = (dir + 1) % 4;
    }
  }

  int m, n;
  while (cin >> m >> n && m + n){
    int x = xs[n];
    int y = ys[n];
    memset(memo, -1, sizeof(memo));
    auto p = rec(x, y, m);
    cout << p.first << " " << p.second << endl;
  }

  
  return 0;
}

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

ll n, w, ans;

map<ll, ll, greater<ll>> m;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> w;
    vector<pair<ll, ll>> a(n);
    for (auto& i : a) cin >> i.first >> i.second;

    for (auto i : a) {
        for (auto c : m) {
            int nw = i.first + c.first;
            if (nw <= w) {
                m[nw] = max(m[nw], c.second + i.second);
                ans = max(ans, m[nw]);
            }
        }
        m[i.first] = max(m[i.first], i.second);
        if (i.first <= w) ans = max(ans, m[i.first]);
    }
    
    cout << ans;
}


Measured memory_bytes: 3708
#include <iostream>
#include <cstdio>

using namespace std;

bool isUpper(char c){ return ('A' <= c && c <= 'Z') ? true : false; }
bool isLower(char c){ return ('a' <= c && c <= 'z') ? true : false; }

int main(){
	char line[1200];
	fgets(line, sizeof(line) / sizeof(line[0]), stdin);

	for(int i = 0; i < sizeof(line) / sizeof(line[0]); ++i) {
		char c = line[i];
		if('\0' == c){ break; }

		if(isUpper(c)) {
			c += 'a' - 'A';
		} else if(isLower(c)) {
			c -= 'a' - 'A';
		}
		line[i] = c;
	}
	cout << line;

	return 0;
}



Measured memory_bytes: 3068