akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int a,b,c,d;
  cin >> a >> b >> c >> d;

  while(a > 0 || c > 0){
    c -= b;
    if(c <= 0) break;
    a -= d;
  }

  cout << (a <= 0 ? "No" : "Yes") << endl;

  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if(a%2==1 && b%2==1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  bool flg1 = false, flg2 = false, flg3 = false;
  string S;
    cin >> S;
  int L = S.size();

  if (S[0] == 'A') flg1 = true;

  int cnt = 0;
  for (int i = 2; i <= L - 2; ++i) {
    if (isupper(S[i])) {
      cnt++;
      if (S[i] == 'C' && cnt == 1) {
        flg2 = true;
      }
    }
  }

  cnt = 0;
  for (int i = 0; i < L; ++i) {
    if (isupper(S[i])) cnt++;
  }
  if (cnt == 2) flg3 = true;

  cout << (flg1 && flg2 && flg3 ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n;

  while(cin>>n,n){
    pair<int,bool> treasure[25];
    int bridge[25];
    int total=0;
    bool flag=true;

    for(int i=0;i<n;++i){
      cin>>treasure[i].first>>bridge[i];
      treasure[i].second=false;
    }

    for(int i=0;i<n;++i){
      int min=1000000;
      int min_in;
      for(int j=0;j<n;++j){
	if(min>bridge[j] && treasure[j].second==false){
	  min=bridge[j];
	  min_in=j;
	}
      }
      total+=treasure[min_in].first;
      if(total>bridge[min_in]){
	flag=false;
	break;
      }
      treasure[min_in].second=true;
    }
    if(flag==true)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

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

	bool ok = true;
	vector<int> res;
	while (b.size() != 1) {
		pair<int, int> tmp = make_pair(-1, -1);
		for (int i = 1; i < (int)b.size(); i++) {
			if (b[i] == i)
				tmp = make_pair(i, b[i]);
		}
		if (tmp == make_pair(-1, -1)) {
			ok = false;
			break ;
		}
		res.push_back(tmp.second);
		b.erase(b.begin() + tmp.first);
	}
	if (ok) {
		reverse(res.begin(), res.end());
		for (int i = 0; i < (int)res.size(); i++)
			cout << res[i] << '\n';
	} else
		cout << -1 << '\n';
    return 0;
}


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

#define lli long long int

int main()
{
  int k;
  scanf("%d", &k);
  lli sum = 0;
  for (int i = 1; i <= k; i++)
    for (int j = 1; j <= k; j++)
      for (int z = 1; z <= k; z++)
        sum += __gcd(i, __gcd(j, z));
  printf("%lld\n", sum);
  return 0;
}

Measured memory_bytes: 3760
#include <iostream>

int main()
{
    int a, b;
    int n;

    std::cin >> n >> a >> b;

    int counter = 0;
    for (int i = 1; i <= n; i++)
    {
        int man, sen, hyaku, ju, ichi;
        man = i / 10000;
        sen = (i % 10000) / 1000;
        hyaku = (i % 1000) / 100;
        ju = (i % 100) / 10;
        ichi = i % 10;

        int sum = man + sen + hyaku + ju + ichi;
        if (sum >= a && sum <= b)
        {
            counter = counter + i;
        }
    }

    std::cout << counter << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);

//SegmentTree 
template<class T>class SegmentTree{
	vector<T> seg;
	function<T(T, T)> func;
	/*func:ex)
	function<int(int,int)>down=[](int a,int b){return min(a,b);};
	*/
	private:
	T findquary(int left,int right,int index,int atStart,int atStop){
		if ((left <= atStart) and (atStop <= right)){//対象範囲に完全に囲まれる
			return seg[index];
		}if((atStop <= left) or ( right < atStart)){//対象範囲に全く関わらない
			return init;
		}if (index >= size){//範囲外・子がいない
			return seg[index];
		}
		//対象に一部が含まれる
		T aL=findquary(left, right, index * 2, atStart, atStart + (atStop - atStart) / 2);
		T aR= findquary(left, right, index * 2 +1,  atStart +(atStop - atStart) / 2, atStop);
		return func(aL,aR);
	}
	T upquary(int index){ //q1
		return func(seg[index],seg[index+1]);
	}
	public:
	int size; //size of segmenttree
	T init;//unit
	bool found=false;//find query done
	//constructor
	SegmentTree(int _legth, function<T(T, T)> _func, T _init = 0 )
	{
		size=1;
		func = _func;
		init=_init;
		while(size <=_legth){
			size<<=1;
		}
		seg.assign(size<<1,init);
	}
	T get(int index){
		return seg[size+index];
	}
	void show(){
		rep(i,size*2){
			clog<<seg[i]<<" ";
		}
	clog<<endl;
	}
	void clean(){
		found=true;
		for(int i=(size<<1)-2;i>=2;i-=2){
			seg[i/2]=upquary(i);
		}
	}
	//change value 
	void update(int index, T value){
		seg[size+index]+=value;
		if (found==false){return ;}
		int ter=index+size;
		while(ter!=1){
			ter/=2;
			seg[ter]=upquary(ter*2);
		} //show();
	}
	//find value
	T find(int l, int r){ //q2
		if(found==false){
			clean();
		//	show();
		}
		T res = seg[size + l];
		res = findquary(l, r,1,0, size);
		return res;
	}
};
int main(){
	int n,q;
	cin >>n>>q;
	int id;
	ll x,y;
	function<ll(ll,ll)>down=[](ll a,ll b){return (a+b);};
	SegmentTree<ll> seg(n, down, 0LL);
	rep(i,q){
		cin>>id>>x>>y;
		if(id==0){
			seg.update(x,y);
		//	seg.show();
		}else{
			cout<<seg.find(x,y)<<endl;
		}
	}
	
}


Measured memory_bytes: 4916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static int Solve(int N, int M, int[] X)
    {
        var mod = new int[M];
        var dic = new Dictionary<int, int>();
        foreach (int x in X)
        {
            ++mod[x % M];
            if (!dic.ContainsKey(x)) { dic[x] = 0; }
            ++dic[x];
        }
        int cnt = mod[0] / 2;
        mod[0] %= 2;
        for (int i = 1; i * 2 < M; ++i)
        {
            int min = Math.Min(mod[i], mod[M - i]);
            cnt += min;
            mod[i] -= min;
            mod[M - i] -= min;
        }
        if (M % 2 == 0)
        {
            cnt += mod[M / 2] / 2;
            mod[M / 2] %= 2;
        }
        foreach (var pair in dic)
        {
            int m = pair.Key % M;
            int min = Math.Min(mod[m], pair.Value);
            int c = min / 2;
            cnt += c;
            mod[m] -= c * 2;
        }
        return cnt;
    }

    static void Main(string[] args)
    {
        int[] V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] X = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(V[0], V[1], X));
    }
}


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

bool at(ll flags, ll k) { return (flags & (1 << k)) >> k; }

int main() {
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> s(M, vector<ll>(N, 0));
    vector<ll> p(M);
    ll k, tmp;
    rep(i, M) {
        cin >> k;
        rep(j, k) {
            cin >> tmp;
            s[i][tmp - 1] = 1;
        };
    }
    rep(i, M) cin >> p[i];
    ll ans = 0;
    rep(flags, pow(2, N)) {
        rep(i, M) {
            ll sum = 0;
            rep(j, N) {
                if (at(flags, j)) sum += s[i][j];
            }
            if (sum % 2 != p[i]) goto SKIP;
        }
        ans++;
    SKIP:;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	re = N % 1000
	if re == 0:
		print(0)
	else:
		print(1000 - re)




if __name__ == '__main__':
	main()

Measured memory_bytes: 64704
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)

// https://onlinejudge.u-aizu.ac.jp/status/users/fullhouse1987/submissions/1/DSL_2_I/judge/4135652/C++14
template <typename T>
class RQ{
public:
	int n,rn,bn,time=0;
	T inicial;
	vector<T> a,b_get,b_update;
	vector<int> atime,btime;//b_get->buket内全てまとめた値
	T updete(T v,T x){return x;}
	T unite(T x,T y){return x+y;}
	T buket_val(T x){return x*rn;}

	RQ(int n_,T ini){
		n = n_; rn =sqrt(n); bn=(n+rn-1)/rn;
		a.resize(n,ini);
		b_get.resize(bn,ini);
		b_update.resize(bn,ini);
		atime.resize(n,-1);
		btime.resize(bn,-1);
		inicial = ini;
	}
	T get(int s,int t){ //[s,t]
		T res = inicial;
		for(int i=s;i<=t;i++){
			if(i%rn==0 && (i+rn-1)<=t){
				res = unite(res,b_get[i/rn]);
				i += rn-1;
			}else{
				if(atime[i]<btime[i/rn]){
					a[i] = updete(a[i],b_update[i/rn]);
					atime[i] = btime[i/rn];
				}
				res = unite(res,a[i]);
			}
		}
		return res;
	}
	void updete(int s,int t,T x){ //[s,t]
		time++;
		for(int i=s;i<=t;i++){
			if(i%rn==0 && (i+rn-1)<=t){
				b_update[i/rn] = updete(b_update[i/rn],x);
				btime[i/rn] = time;
				b_get[i/rn] = buket_val(x);
				i += rn-1;
			}else{
				a[i] = updete(a[i],x);
				atime[i] = time;
				if((i+1)%rn==0 || i==t){
					int bi = i/rn;
					b_get[bi] = inicial;
					for(int j=bi*rn;j<(bi+1)*rn;j++){
						if(atime[j]<btime[bi]){
							a[j] = updete(a[j],b_update[bi]);
							atime[j] = btime[bi];
						}
						b_get[bi] = unite(b_get[bi],a[j]);
					}
				}
			}
		}
	}
};



int main(){ 
	int n,q,s,t,a;
	ll x;
	cin >> n >> q;
	RQ<ll> sg(n+2,0LL);
	FOR(Q,0,q){
		cin >> a;
		if(a){
			cin >> s >> t;
			cout << sg.get(s,t) << endl;
		}else{
			cin >> s >> t >> x;
			sg.updete(s,t,x);
		}
	}
}


Measured memory_bytes: 3900
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    int a, b, h;
    cin >> a >> b >> h;

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


Measured memory_bytes: 256
# 140 B

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0

for i in range(len(a)):
    sum += b[a[i] - 1]
    try:
        if i != 0 and a[i] == a[i-1] + 1:
           sum += c[a[i-1] - 1]
    except IndexError:
        continue

print(sum)

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] inputs = new int[n];
        for (int i = 0; i < n; i++) {
            inputs[i] = sc.nextInt();
        }

        int max = Integer.MIN_VALUE;
//        for (int i = 0; i < n - 1; i++) {
//            for (int j = i + 1; j < n; j++) {
//                max = (inputs[j] - inputs[i]) > max ? (inputs[j] - inputs[i]) : max;
//            }
//        }
        int min = inputs[0];
        for(int i = 1; i < n; i++) {
            max = (inputs[i] - min) > max ? (inputs[i] - min) : max;
            min = inputs[i] < min ? inputs[i] : min;
        }
        System.out.println(max);
    }

}


Measured memory_bytes: 99492
#include <bits/stdc++.h>
#define P pair<int, int>
#define PP pair<P, P>

using namespace std;

int main(){
  int h, w, a[509][509];
  cin >>h >> w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++)cin >> a[i][j];
  }
  queue<PP> q;
  for(int i=1;i<=h-1;i++){
    for(int j=1;j<=w;j++){
      if(a[i][j]%2==1){
        a[i][j]--;
        a[i+1][j]++;
        q.push(PP(P(i, j), P(i+1, j)));
      }
    }
  }
  for(int j=1;j<w;j++){
    if(a[h][j]%2==1){
      a[h][j]--;
      a[h][j+1]++;
      q.push(PP(P(h, j), P(h, j+1)));
    }
  }
  cout << q.size() << endl;
  while(!q.empty()){
    PP pp = q.front();q.pop();
    cout << pp.first.first << ' ' << pp.first.second << ' ';
    cout << pp.second.first << ' ' << pp.second.second << '\n';
  }
}



Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define M 1000000007
#define endl '\n'
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll initial{0};
	ll moves{0};
	ll distance{0};
	cin>>initial>>moves>>distance;

	initial=abs(initial);

	ll answer{0};
	if(initial==distance){
		if(moves%2==0)
			answer=initial;
		else
			answer=0;
	}
	else if(initial>distance){
		ll temp=initial/distance;
		if(moves>=temp){
			moves=moves-temp;
			if(moves%2==0){
				answer=(initial%distance);
			}
			else{
				answer=(initial%distance);
				answer=answer-distance;
				answer=abs(answer);
			}
		}
		else{
			answer=(initial)-(moves*distance);
			answer=abs(answer);
		}
	}
	else{
		if(moves%2==0)
			answer=initial;
		else
			answer=abs(initial-distance);
	}

	cout<<answer<<endl;

	return 0;
}



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

#define INF 1000000007


int main(){
	int t =1;
	//cin >> t;
	while(t--){
		int n ;
		cin>>n ;
		if(n%1000==0) cout<<0 ;
		else cout<<1000-(n%1000) ;
		cout<<endl ;
	}


	return 0 ;
	}
	






Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    cout << (max({A1, A2, A3}) - min({A1, A2, A3})) << endl;

    return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t x,y,z;
  cin >> x >> y >> z;
  cout << z << " " <<  x  << " " << y << endl;
  
  return 0;
}



Measured memory_bytes: 3588
#include<iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <utility>
#include <math.h>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b;
    for (int i = 0; i < b; ++i) {
        cin >> c;
        a -= c;
    }
    if (a < 0) a = -1;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	cin>>n>>m;
	cout<<(n==m?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int ans = 0;
  bool a = false;
  while (true) {
    for (int j = 0; j < N; j++) {
      if (vec.at(j) % 2 == 1) {
        a = true;
      }
    }
    if (a) {
      break;
     }
    for (int k = 0; k < N; k++) {
      vec.at(k) /= 2;
    }
    ans++;    
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
    int n;
    bool f=false;
    cin>>n;
    int i;
    for(i=9;i>0;--i){
        if(n%i==0){
            n/=i;
            break;
        }
    }
    if(i==0){
        cout<<"No";
        return 0;
    }
    for(i=9;i>0;--i){
        if(n==i){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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


n = int(input())

list_26 = [26]
while list_26[-1] < 1000000000000001:
    list_26.append(list_26[-1]*26)

list_26 = list(itertools.accumulate(list_26))
# print(list_26)

for i in range(len(list_26)):
    if n <= list_26[i]:
        break
digit = i

if i != 0:
    n -= list_26[i-1]
# print(n)

n -= 1


def base_10_to_n(x, n):
    x_dummy = x
    out = []
    while x_dummy > 0:
        out.append(int(x_dummy % n))
        x_dummy = int(x_dummy/n)
    if out == []:
        return [0]
    return out


ans = base_10_to_n(n, 26)

ans += [0]*(i+1-len(ans))
ans.reverse()

for i in ans:
    print(chr(i+97), end="")
print()
# print(ans)


# ans = base_10_to_n(n, 26)
# ans.reverse()

# for i in ans:
#     if
# print(ans)


Measured memory_bytes: 9228
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    for (auto&& aa : a) {
        cin >> aa;
        s += aa;
    }

    int min = numeric_limits<int>::max();
    int min_index = -1;
    for (auto i : irange(0, n)) {
        auto aa = a[i];
        if (abs(aa * n - s) < min) {
            min = abs(aa * n - s);
            min_index = i;
        }
    }

    cout << min_index << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define PI 3.14159265358979323846264338327950L
using namespace std;

typedef long long ll;
typedef long double ld;

long long myGcd(long long a, long long b)
{
	if (a % b == 0)return b;
	return myGcd(b, a % b);
}

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

long long myLcm(long long a, long long b)
{
	return a * b / myGcd(a, b);
}

int myLcm(int a, int b)
{
	return a * b / myGcd(a, b);
}


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

	int A, B, H, M;
	ld rad;
	ld ans;

	cin >> A >> B >> H >> M;

	rad = PI * 2 * ((ld)H / 12.0 + ((ld)M / 60.0) / 12.0 - (ld)M / 60);

	ans = (A * A) + (B * B) - (2 * A * B * cos(rad));
	ans = sqrt(ans);

	cout << fixed << setprecision(20) << ans << endl;

	return 0;
}

Measured memory_bytes: 4180
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int a, b;

	cin >> a >> b;
	if (a*b % 2 != 0) {
		cout << "Odd" << endl;
	}
	else
		cout << "Even" << endl;
	return 0;
}


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

int main(){
  string s,t; cin>>s;
  char a; 
  bool x;
  t="abcdefghijklmnopqrstuvwxyz";
  for(int i=0;i<s.size();i++){
    for(int j=0;j<t.size();j++){
      if(s[i]==t[j]){
        t[j]=' ';}
    }
  }
  bool ans=false;
  for(int i=0;i<t.size();i++){
    if(t[i]!=' '){
      a=t[i];
      ans=true;
      break;
    }
  }
  if(ans){
    cout<<a<<endl;
  }
  else{
    cout<<"None"<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#define ll long long int
#define mod 1000000007


int main(){

    int N, K;
    scanf("%d %d", &N, &K);     //オーバーフロで回答ミス
                                //N,iがintなので、それにか関わる計算にはllキャストが必要。かっこの位置にも注意
    int i;
    ll a, b, answer = 0;
#include <stdio.h>
#define ll long long int
#define mod 1000000007


int main(){

    int N, K;
    scanf("%d %d", &N, &K);     //オーバーフロで回答ミス
                                //N,iがintなので、それにか関わる計算にはllキャストが必要。かっこの位置にも注意
    int i;
    ll a, b, answer = 0;

    for(i = K; i <= N+1; i++){
        a = (ll)i*(i-1)/2;
        b = (ll)N*(N+1)/2-(ll)(N-i)*(N-i+1)/2;

        answer += b-a+1;

    }
    printf("%lld",answer%mod);

   return 0;
}
    for(i = K; i <= N+1; i++){
        a = (ll)i*(i-1)/2;
        b = (ll)N*(N+1)/2-(ll)(N-i)*(N-i+1)/2;

        answer += b-a+1;

    }
    printf("%lld",answer%mod);

   return 0;
}

Measured memory_bytes: 1732
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m1 = sc.nextInt();
        int ignore = sc.nextInt();
        int m2 = sc.nextInt();
        System.out.println(m1 != m2 ? "1" : "0");
    }
}

Measured memory_bytes: 23892
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new int[n + 1];
        var p = new bool[n + 1];
        p[1] = true;
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]);
            var y = int.Parse(line[1]);
            a[x]--;
            a[y]++;
            if (p[x]) p[y] = true;
            if (a[x] == -1 && p[x]) p[x] = false;
        }
        var c = p.Where(x => x == true).Count();
        Console.WriteLine(c);
    }
}


Measured memory_bytes: 15432
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#define M_PI 3.1415926535897932384626433832795


int main() {
	double x,a,b;
	cin >> a>>b>>x;
	double n;
	n = double(x) / double(a);
	double theta;
	
	int k = a * b * 0.5;
	if (k >= n) {
		theta = atan(b * b / n / 2);
		//cout << "a" << endl;
	}
	else {
		theta = atan(2 * b / a - 2 * n / a / a);
		//cout << "b" << endl;
	}
	//cout << theta << endl;
	cout << fixed << setprecision(10) << theta/M_PI*180.0;
	

	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	while (true){
		starter:;
		int n;
		cin >> n;
		if (n == 0) return;
		int dist[27][27] = {};
		vector<string> inputs;
		REP(i, n) {
			string s;
			cin >> s;
			inputs.push_back(s);
		}
		for (int i = 1; i < inputs.size(); ++i) {
			int ok = 0;
			REP(q, min(inputs[i-1].size(),inputs[i].size())) {
				if (inputs[i][q] != inputs[i - 1][q]) {
					dist[inputs[i - 1][q] - 'a'][inputs[i][q] - 'a'] = 1;
					ok = 1;
					break;
				}
			}
			if (ok == 0) {
				if (inputs[i - 1].length() > inputs[i].length()) {
					cout << "no" << endl;
					goto starter;
				}
			}
		}
		REP(t, 3) {
			REP(i, 26) {
				REP(q, 26) {
					REP(j, 26) {
						if(dist[i][j] != 0&&dist[j][q] != 0)
						dist[i][q] = max(dist[i][q], dist[i][j] + dist[j][q]);
					}
				}
			}
		}
		int copy_dist[27][27];
		REP(i, 27) {
			REP(q, 27) {
				copy_dist[i][q] = dist[i][q];
			}
		}
		REP(t, 3) {
			REP(i, 26) {
				REP(q, 26) {
					REP(j, 26) {
						if (dist[i][j] != 0 && dist[j][q] != 0)
							dist[i][q] = max(dist[i][q], dist[i][j] + dist[j][q]);
					}
				}
			}
		}
		int ok = 1;
		REP(i, 26) {
			REP(q, 26) {
				if (dist[i][q] != copy_dist[i][q]) ok = 0;
			}
		}
		string ans[2] = { "no","yes" };
		cout << ans[ok] << endl;
	}
}

#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3052
fun main(args: Array<String>) = println(run {
    val a = readLine()!!
    val b = readLine()!!

    when {
        a.length > b.length -> "GREATER"
        a.length < b.length -> "LESS"
        a > b -> "GREATER"
        a < b -> "LESS"
        else -> "EQUAL"
    }

})


Measured memory_bytes: 31432
import itertools

n, m, x = map(int, input().split())
A = []
ans = []

for i in range(n):
    A.append((list(map(int, input().split()))))

for j in itertools.product([0, 1], repeat=n):
    skill = [0 for s in range(m + 1)]
    k = 0
    for k in range(n):
        if j[k] == 1:
            skill = [a + b for a, b in zip(skill, A[k])]
    if all(x <= e for e in skill[1:]):
        ans.append(skill[0])

if len(ans):
    print(min(ans))
else:
    print(-1)

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

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

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a[5];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3, greater<int>());
  cout << a[1] * a[2] / 2 << "\n";
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input() for _ in range(N))
X = []
for s in S:
    l,r = 0,0
    for c in s:
        if c == ")":
            if r > 0:
                r -= 1
            else:
                l += 1
        else:
            r += 1
    X.append([l,r])
X.sort(key = lambda x:x[0])
Y = []
L = 0
for p,q in X:
    if p > L:
        print("No")
        quit()
    if q >= p:
        L -= p
        L += q
    else:
        Y.append([p,q])
Y.sort(key = lambda x:-x[1])
for a,b in Y:
    if a > L:
        print("No")
        quit()
    L -= a
    L += b
if L:
    print("No")
else:
    print("Yes")     

Measured memory_bytes: 308212
n, y = map(int, input().split())

res = 0
for i in range(n + 1):
    for j in range(n + 1):
        k = n - i - j
        if k >= 0 and 10000 * k == y - 1000 * i - 5000 * j:
            print(k, j, i)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 40940
while s=gets
    x1,y1,x2,y2,x3,y3,xp,yp=s.split(nil).map(&:to_f)
    z1=(x3-x2)*(yp-y2)-(y3-y2)*(xp-x2)
    z2=(x1-x3)*(yp-y3)-(y1-y3)*(xp-x3)
    z3=(x2-x1)*(yp-y1)-(y2-y1)*(xp-x1)
    
    if (z1>0 && z2>0 && z3>0) || (z1<0 && z2<0 && z3<0)
        puts "YES"
        
    else
        puts "NO"
    
    end
end

Measured memory_bytes: 6128
def solve(b):
    if(b=='A'):
        print('T')
    elif(b=='T'):
        print('A')
    elif(b=='C'):
        print('G')
    else:
        print('C')
    
 
 
def main():
    b = input()
    solve(b)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    private Scanner stdin = new Scanner(new BufferedInputStream(System.in));
    private PrintWriter stdout = new PrintWriter(new BufferedOutputStream(System.out));

    private void main() {
        int currentHours = stdin.nextInt();
        int contestBeginFor = stdin.nextInt();

        stdout.println((currentHours + contestBeginFor) % 24);


        stdin.close();
        stdout.close();
    }

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

}

Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {
    
    int a[3];
    int cnt;

    signed call_of_Cthulhu( signed datum ) {

        for ( int i = 0; i < 3; i++ ) {
            read a[i];
        }
        bozo_sort(a, a+3);
        while ( a[0] != a[2] ) {
            if ( a[1] == a[2] ) {
                a[0] += 2;
            }
            else {
                a[0]++;
                a[1]++;
            }
            cnt++;
            bozo_sort(a, a+3);
        }
        echo cnt fin;


        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); echo std::fixed << std::setprecision(8); int main_result = Rlyeh::call_of_Cthulhu(114514); return main_result;}


Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.exception, std.typecons;

  int n, m; rd(n, m);
  auto edges=new Tuple!(int, int)[](m);
  auto g=new int[][](n, 0);
  foreach(i; 0..m){
    int a, b; rd(a, b);
    a--; b--;
    g[a]~=b; g[b]~=a;
    edges[i]=tuple(a, b);
  }

  auto vis=new bool[](n);
  long dfs(int i){
    vis[i]=true;
    long ret=1;
    foreach(j; g[i]){
      if(vis[j]==false) ret+=dfs(j);
    }
    return ret;
  }

  long[] sz;
  foreach(i; 0..n){
    if(vis[i]==false) sz~=dfs(i);
  }
  enforce(sz.length>=2);
  
  long cul(int v){
    long num=sz[v];
    foreach(i; 2..(sz.length)) num+=sz[i];
    auto ret=num*(num-1)/2;
    auto u=v^1;
    ret+=sz[u]*(sz[u]-1)/2;
    ret-=m;
    return ret;
  }

  writeln(max(cul(0), cul(1)));
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}

Measured memory_bytes: 21372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r, x = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    //cout << l << r;
    x += r - l + 1;
  }
  cout << x << endl;
}

Measured memory_bytes: 3640
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Dice d1=new Dice(br.readLine().split(" "));
		Dice d2=new Dice(br.readLine().split(" "));
		int i=0;
		while(!d1.match(d2)&&i<6){
			int j=0;
			while(!d1.match(d2)&&j<4){
				d2.spinR();
				j++;
			}
			if(d1.match(d2)) break;
			if(i%2==0){
				d2.throwN();
			}else{
				d2.throwW();
			}
			i++;
		}
		if(d1.match(d2)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
	
	static class Dice {
		private String top,front,right,left,back,bottom;

		public Dice(String[] lbl){
			top=lbl[0];
			front=lbl[1];
			right=lbl[2];
			left=lbl[3];
			back=lbl[4];
			bottom=lbl[5];
		}
		
		public void throwN(){ String tmp=top; top=front; front=bottom; bottom=back; back=tmp; }
		public void throwS(){ String tmp=top; top=back; back=bottom; bottom=front; front=tmp; }
		public void throwE(){ String tmp=top; top=left; left=bottom; bottom=right; right=tmp; }
		public void throwW(){ String tmp=top; top=right; right=bottom; bottom=left; left=tmp; }
		public void spinR(){ String tmp=front; front=left; left=back; back=right; right=tmp; }

		public String getTop() { return top; }
		public String getFront() { return front; }
		public String getRight() { return right; }
		public String getLeft() { return left; }
		public String getBack() { return back; }
		public String getBottom() { return bottom; }
		
		public boolean match(Dice dice2){
			if(this.getTop().equals(dice2.getTop())&&this.getFront().equals(dice2.getFront())
					&&this.getRight().equals(dice2.getRight())&&this.getLeft().equals(dice2.getLeft())
					&&this.getBack().equals(dice2.getBack())&&this.getBottom().equals(dice2.getBottom())){
				return true;
			}else{
				return false;
			}
		}
	}
}

Measured memory_bytes: 17096
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N,M;
	cin >> N >> M;
	vector<int> ret;
	int ans = 1;
	for (int i = 1; i*i <= M; ++i)
	{
		if (M%i == 0)
		{
			if (M / i >= N) {
				ans = max(ans, i);
			}
			if (i >= N) {
				ans = max(ans, M/i);
			}
		}
	}
	

	
	cout << ans << endl;

	return 0;
}



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

using namespace std;

int main()	{
  int sx, sy, tx, ty;
  int dx, dy;
  cin >> sx >> sy >> tx >> ty;
  dx = tx - sx;
  dy = ty - sy;
  cout << string(dy, 'U') << string(dx, 'R');
  cout << string(dy, 'D') << string(dx, 'L');
  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
  cout << endl;
  return 0;
}

Measured memory_bytes: 3616
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = list(set(readInts()))
print('YES' if n == len(A) else 'NO')


Measured memory_bytes: 33024
import java.util.*;

public class Main {
	static String[] ABC = { "A", "B", "C" };

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if (dfs(S)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	static boolean dfs(String S) {
		if (S.equals("ABC")) {
			return true;
		}
		int cnt = 0;
		boolean f = false;
		boolean[] pos = new boolean[S.length()];
		for (int j = 0; j + 3 <= S.length(); ++j) {
			if (S.substring(j, j + 3).equals("ABC")) {
				pos[j] = true;
				++cnt;
			}
		}
		if (cnt < 1)
			return false;
		out: for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < S.length(); ++j) {
				if (S.charAt(j) == 'A' + i) {
					if (j - i < 0 || !pos[j - i])
						continue out;
				}
			}
			String next = S.replaceAll("ABC", ABC[i]);
			f |= dfs(next.toString());
		}
		return f;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 180492
def mod_10(x):
	x = x % 10
	return x

N = int(input())
s = []
for i in range(N):
	s_i = int(input())
	s.append(s_i)

s.sort()

m_l = list(map(mod_10, s))

ans = sum(s)
if ans % 10 ==0:
	for i in range(N):
		if m_l[i] != 0:
			ans = ans - s[i]
			break
if sum(m_l) == 0:
	ans = 0

print(ans)


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

using namespace std;

typedef long long ll;

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const double EPS = 1e-9;
const ll INF = 1e17;

int n;
string s;
vector<bool> isSheep;

inline bool check(bool a, bool b) {
	isSheep.assign(n, 0);
	isSheep[0] = a;
	isSheep[1] = b;

	for (int i = 1; i < n - 1; i++) {
		if ((isSheep[i] && s[i] == 'o') || (!isSheep[i] && s[i] == 'x')) {
			isSheep[i + 1] = isSheep[i - 1];
		} else {
			isSheep[i + 1] = (isSheep[i - 1] ^ 1);
		}
	}

	bool ta, tb;

	if ((isSheep[n - 1] && s[n - 1] == 'o') || (!isSheep[n - 1] && s[n - 1] == 'x')) {
		ta = isSheep[0] == isSheep[n - 2];
	} else {
		ta = isSheep[0] != isSheep[n - 2];
	}

	if ((isSheep[0] && s[0] == 'o') || (!isSheep[0] && s[0] == 'x')) {
		tb = isSheep[n - 1] == isSheep[1];
	} else {
		tb = isSheep[n - 1] != isSheep[1];
	}

	return ta && tb;
}

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

	cin >> n >> s;

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			if (check(i, j)) {
				for (auto t : isSheep) {
					cout << (t ? 'S' : 'W');
				}
				cout << "\n";
				return 0;
			}
		}
	}

	cout << "-1\n";

	return 0;
}


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

template <class T = long long>
class ST {	//非再帰抽象化セグ木
   private:
	int n;
	vector<T> vec;
	T unit;
	function<T(T, T)> operation;

   public:
	ST(int _n, function<T(T, T)> _operation, T _unit = 0) : n(_n), operation(_operation), unit(_unit) { vec.assign(n * 2, unit); }
	void update(int idx, T x) {
		idx += n;
		vec[idx] = x;
		idx >>= 1;
		while(idx > 0) {
			vec[idx] = operation(vec[(idx << 1)], vec[(idx << 1) | 1]);
			idx >>= 1;
		}
	}
	T get(int lef, int rig) {
		T a = unit, b = unit;
		lef += n;
		rig += n;
		while(lef < rig) {
			if(lef & 1) a = operation(a, vec[lef]);
			if(rig & 1) b = operation(vec[rig - 1], b);
			(lef += 1) >>= 1;
			rig >>= 1;
		}
		return operation(a, b);
	}
};

int main() {
	// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_2_A
	int n, q;
	cin >> n >> q;
	ST<int> st(
		n, [](int a, int b) { return min(a, b); }, (int)((1LL << 31) - 1));
	for(int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if(com) {
			cout << st.get(x, y + 1) << endl;
		} else {
			st.update(x, y);
		}
	}
}


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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int p, q, r;
    cin >> p >> q >> r;

    cout << min({p + q, p + r, q + r}) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int f[1000001],n,a,b,i,j,t,ans;
	while(1){
		scanf("%d %d %d",&n,&a,&b);
		if(n==0&&a==0&&b==0){
			break;
		}
		for(i=1;i<=n;i++){
			f[i]=0;
		}
		f[0]=1;
		ans=0;
		for(i=1;i<=n;i++){
			if(i-a>=0&&f[i-a]==1){
				f[i]=1;
			}
			if(i-b>=0&&f[i-b]==1){
				f[i]=1;
			}
			if(f[i]!=1){
				ans++;
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 4508
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

ll A[N];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m,i,j,x,q;
    int t=1;
    cin>>n;
    ll k;
    cin>>k;
    rep(i,1,n)cin>>A[i];
    ll cnt = 0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(A[i]>A[j])cnt++;
        }
    }
    cnt = (cnt *1ll*k);
    cnt%=mod;
    ll p = (1ll*k*(k-1))/2ll;
    p %= mod;
    for(int i=1;i<=n;i++)
    {
        ll tot = 0;
        for(int j=1;j<=n;j++)if(A[j]>A[i])tot++;
        cnt += (tot*p)%mod;
    }
    cout<<cnt%mod<<"\n";



    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a < b){if(b < c){printf("%d %d %d\n",a,b,c);}
    else if(a < c){printf("%d %d %d\n",a,c,b);}
    else{printf("%d %d %d\n",c,a,b);};}
    else if(a < c){printf("%d %d %d\n",b,a,c);}
    else {if(b < c){printf("%d %d %d\n",b,c,a);}
    else{printf("%d %d %d\n",c,b,a);};};
    return 0;
}



Measured memory_bytes: 2668
S = str(input())
if S == 'SUN':
    print('7')
elif S == 'MON':
    print('6')
elif S == 'TUE':
    print('5')
elif S == 'WED':
    print('4')
elif S == 'THU':
    print('3')
elif S == 'FRI':
    print('2')
else:
    print('1')

Measured memory_bytes: 2940
n=int(input())
a=list(map(int,input().split()))
cnt0=0
cnt2=0
cnt4=0
for i in range(len(a)):
    if a[i]%4==0:
        cnt4+=1
    elif a[i]%2==0:
        cnt2+=1
    else:
        cnt0+=1
if cnt4 >= cnt0 + cnt2%2 -1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 15020
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))fin("Yes");
    else fin("No");
}


Measured memory_bytes: 256