akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <atcoder/segtree>

namespace ac = atcoder;
constexpr int INF = 1 << 30;

int e() { return -INF; }
int max(int a, int b) { return std::max(a, b); }

void solve() {
    int n, q;
    std::cin >> n >> q;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;

    ac::segtree<int, max, e> seg(xs);

    while (q--) {
        int t;
        std::cin >> t;

        switch (t) {
            case 1: {
                int i, x;
                std::cin >> i >> x;
                seg.set(--i, x);
                break;
            }
            case 2: {
                int l, r;
                std::cin >> l >> r;
                std::cout << seg.prod(--l, r) << "\n";
                break;
            }
            case 3: {
                int l, a;
                std::cin >> l >> a;

                auto lt = [&](int x) { return x < a; };
                int r = seg.max_right(--l, lt);
                std::cout << r + 1 << "\n";
                break;
            }
        }
    }
}

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

    solve();

    return 0;
}


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

"""
input:
5 6
0 1
1 0
1 2
2 4
4 3
3 2
4
0 1
0 3
2 3
3 4

output:
1
0
1
1
"""

import sys
from math import isinf

sys.setrecursionlimit(int(1e5))


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
    return init_adj_table


def Tarjan(current, low, disc, scc_stack, in_scc_stack):
    global timer
    disc[current] = low[current] = timer
    timer += 1

    # visited[current] = True
    in_scc_stack[current] = True
    scc_stack.append(current)

    current_scc_set = set()
    for adj in adj_table[current]:
        if isinf(disc[adj]):
            Tarjan(adj, low, disc, scc_stack, in_scc_stack)
            low[current] = min(low[current], low[adj])

        elif in_scc_stack[adj]:
            low[current] = min(low[current], disc[adj])

    scc_candidate = -1
    if disc[current] == low[current]:
        while scc_candidate != current:
            scc_candidate = scc_stack.pop()
            current_scc_set.add(scc_candidate)
            # visited[scc_candidate] = False
            in_scc_stack[scc_candidate] = False

        init_scc_sets_list.append(current_scc_set)

    return None


def scc():
    disc = [float('inf')] * vertices
    low = [float('inf')] * vertices
    # visited = [False] * vertices
    scc_stack = list()
    in_scc_stack = [False] * vertices

    for v in range(vertices):
        if isinf(disc[v]):
            Tarjan(v, low, disc, scc_stack, in_scc_stack)

    return init_scc_sets_list


def solve():
    for question in q_list:
        flag = False
        ele1, ele2 = map(int, question)
        for each in scc_sets_list:
            if (ele1 in each) and (ele2 in each):
                flag = True
                break
        if flag:
            print('1')
        else:
            print('0')

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:edges + 1])
    q_num = int(_input[edges + 1])
    q_list = map(lambda x: x.split(), _input[edges + 2:])

    init_adj_table = tuple([] for _ in range(vertices))
    adj_table = generate_adj_table(v_info)

    timer = 0
    init_scc_sets_list = []
    scc_sets_list = scc()
    solve()

Measured memory_bytes: 26480
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, F[100][10], P[100][11];
    cin >> N;
    REP(i, N) {
        REP(j, 10) {
            cin >> F[i][j];
        }
    }
    REP(i, N) {
        REP(j, 11) {
            cin >> P[i][j];
        }
    }
    int res = -10e8;
    FOR(i, 1, 1 << 10, 1) {
        int sum = 0;
        REP(j, N) {
            int cnt = 0;
            REP(k, 10) {
                if ((i >> k & 1) && F[j][k] == 1) {
                    cnt++;
                }
            }
            sum += P[j][cnt];
        }
        amax(res, sum);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>                                
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;

int a, b;
                                                                                                                    
int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);                                                                                         
	cout.tie(0);
	srand(time(0)); 
	#ifdef LOCAL
         	freopen("input.txt", "r", stdin);
        	freopen("output.txt", "w", stdout);
        #endif  
        cin >> a >> b;
        cout << ceil((ld)(b - 1) / (a - 1));
        return 0;
}                

Measured memory_bytes: 256
N = int(input())
a = [int(n) for n in input().split(' ')]
n = 1
b = []
for m in a:
    if n == m:
        b.append(m)
        n += 1

if len(b) == 0:
    ans = -1
else:
    ans = len(a) - len(b)

print(ans)


Measured memory_bytes: 84172
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int n,k;
  cin>>n>>k;
  int ans=0;
  V<int> h(n);
  fo(i,n){
    cin>>h[i];
  }

  Sort(h);
  rev(h);
  for(int i=k; i<n; i++){
    ans+=h[i];
  }
  cout<<ans<<endl;
}


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

namespace AtCoder
{
    // http://abc048.contest.atcoder.jp/tasks/abc048_a
    public class Abc048_a
    {
#if !Development
		public static void Main(string[] args)
		{
			Abc048_a.Solve(args);
		}
#endif

        public static void Solve(string[] args)
        {
            var line1 = ReadLineString();
            var one = line1[0].Substring(0, 1);
            var two = line1[1].Substring(0, 1);
            var three = line1[2].Substring(0, 1);

            var result = one + two + three;

            Console.WriteLine(result);
        }

        public static List<string> ReadLineString() { return Console.ReadLine().Split(' ').ToList(); }
        public static List<int> ReadLineInt() { return Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToList(); }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	string s;
	ll k;
	cin >> s;
	cin >> k;

	bool flag=true;
	for(int i=0; i<s.size(); i++){
		if(s[i]!='1'){
			if(100<k){
				cout << s[i] << endl;
				return 0;
			}	else {
				if(i+1<=k){
					cout << s[i] << endl;
					return 0;
				} else {
					cout << 1 << endl;
					return 0;
				}
			}
		}
	}
	if(flag){
		cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
    {
     	 Scanner sc = new Scanner(System.in);
      	
     	String[] sep = sc.nextLine().split(" ");
      	long n = Long.parseLong(sep[0]);
      	long k = Long.parseLong(sep[1]);
      	
      	Long min = n % k;
      	if(min > (k - min))
        {
         	System.out.println(k - min); 
        }else{
         	System.out.println(min); 
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {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;}
// head

const int N=301000;
int n,q,x,l;
int v[N],w[N];
PII ml[5010],mr[5010];

int main() {
	scanf("%d",&n);
	rep(i,1,n+1) scanf("%d%d",w+i,v+i);
	//rep(i,1,n+1) w[i]=rand()%10+1,v[i]=rand()%10+1;
	scanf("%d",&q);
	rep(i,0,q) {
		scanf("%d%d",&x,&l);
		vector<PII> fl,fr;
		int ty=0;
		while (x) {
			if (ty==0) fl.pb({v[x],w[x]});
			else fr.pb({v[x],w[x]});
			x/=2; ty^=1;
		}
		int sl=1,sr=1;

		for (auto x:fl) {
			int s=sl;
			rep(j,0,s) ml[sl++]=mp(ml[j].fi+x.fi,ml[j].se+x.se);
			inplace_merge(ml,ml+s,ml+sl);
		}
		//printf("%d\n",sl);
		for (auto x:fr) {
			int s=sr;
			rep(j,0,s) mr[sr++]=mp(mr[j].fi+x.fi,mr[j].se+x.se);
			inplace_merge(mr,mr+s,mr+sr);
		}
		for (int i=1;i<sr;i++)
			mr[i].se=max(mr[i-1].se,mr[i].se);
		int sz=sr-1;
		int ans=0;
		rep(i,0,sl) {
			auto x=ml[i];
			while (sz>=0&&x.fi+mr[sz].fi>l) --sz;
			if (sz>=0) ans=max(ans,x.se+mr[sz].se);
		}
		printf("%d\n",ans);
	}
}

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

int main()
{
	long long n, min=0, max=0, sum=0;

	cin >> n;

	for(int i=0;i<n;++i){
		int j;
		cin >> j;
		sum += j;

		if(i){
			if(j>max)	max = j;
			if(j<min)	min = j;
		}else{
			max = j;
			min = j;
		}
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 1172
#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.at(i);
  }
  int count=0;
  bool a = 0;
  for(int i=0; ; i++){
    for(int j=0; j<N; j++){
      if(A.at(j)%2 == 1){
        a = 1;
        break;
      }
     A.at(j)/=2;
      //cout << A.at(j) << endl;
      
    }
    if (a){
      break;
    }
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  int r;
  cin >> r;
  if(r<1200) cout << "ABC" << endl;
  if((r>=1200) && (r<2800)) cout << "ARC" << endl;
  if(r>=2800) cout << "AGC" << endl;
}

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

using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MAX_N = 1e5 + 1;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    int x = 0;
    for (int i = 0; i <n ; ++i) {
        cin >> a[i];
        x ^= a[i];
    }
    for (int i = 0; i < n; ++i) {
        int val = a[i] ^ x;
        cout << val << " ";
    }
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 200009;
int n, k, c;
string s;

int lft[N], rgt[N];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k >> c >> s;
    c++;

    for(int i = 0; i < n; ++i) {
        if(s[i] == 'o') {
            if(i-c >= 0) {
                lft[i] = 1+lft[i-c];
            } else {
                lft[i] = 1;
            }
        } else {
            lft[i] = lft[i-1];
        }
    }

    for(int i = n-1; i >= 0; --i) {
        if(s[i] == 'o') {
            if(i+c < n) {
                rgt[i] = 1+rgt[i+c];
            } else {
                rgt[i] = 1;
            }
        } else {
            rgt[i] = rgt[i+1];
        }
    }

    for(int i = 0; i < n; ++i) {
        int sm = 0;
        if(i > 0) {
            sm += lft[i-1];
        }
        if(i < n-1) {
            sm += rgt[i+1];
        }
        if(sm < k) {
            cout << i+1 << '\n';
        }
    }
    
    return 0;
}


Measured memory_bytes: 5012
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int cnt = Integer.parseInt(s.nextLine());
		int result = 0;
		for(int i=0 ; i<cnt ; i++) {
			int number = Integer.parseInt(s.nextLine());
			result += solve(number);
		}
		System.out.println(result);
	}

	public static int solve(int number) {
		if(number == 2) {
			return 1;
		}
		if(number % 2 == 0) {
			return 0;
		}
		for(int i=3 ; i<=Math.sqrt(number) ; i+=2){
			if(number % i == 0) {
				return 0;
			}
		}
		return 1;
	}

}

Measured memory_bytes: 48964
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    k = input_int()
    s = input()

    if len(s) <= k:
        return s

    return s[:k] + "..."


if __name__ == "__main__":
    print(main())


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

using namespace std;
typedef long long ll;

#define MOD 1000'000'007

//DPを行うときは、規定したい状態数＝次元数
//
int dp[101][4][4][4];
int main()
{
    int N;
    cin >> N;
    /* A:0 G:1 C:2 T:3*/
    dp[0][3][3][3] = 1;
    for (int i = 1; i <= N; i++)
    {
        for (int c3 = 0; c3 < 4; c3++) //三つ前の文字
        {
            for (int c2 = 0; c2 < 4; c2++) //二つ前の文字
            {
                for (int c1 = 0; c1 < 4; c1++) //一つ前の文字
                {
                    for (int k = 0; k < 4; k++)
                    {
                        if (c3 == 0 && c1 == 1 && k == 2)
                            continue;
                        if (c3 == 0 && c2 == 1 && k == 2)
                            continue;
                        if (c2 == 0 && c1 == 1 && k == 2)
                            continue;
                        if (c2 == 0 && c1 == 2 && k == 1)
                            continue;
                        if (c2 == 1 && c1 == 0 && k == 2)
                            continue;
                        dp[i][c2][c1][k] += dp[i - 1][c3][c2][c1];
                        dp[i][c2][c1][k] %= MOD;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int c3 = 0; c3 < 4; c3++) //三つ前の文字
    {
        for (int c2 = 0; c2 < 4; c2++) //二つ前の文字
        {
            for (int c1 = 0; c1 < 4; c1++) //一つ前の文字
            {
                ans += dp[N][c3][c2][c1];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}

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

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

    long long min = 0;
    long long max = 0;
    long long sum = 0;

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;

        if(0 == i){
            min = a;
            max = a;
        }

        if(a < min){
            min = a;
        }

        if (a > max){
            max = a;
        }

        sum += a;

        // cout << a << endl;
    }

    cout << min << " " << max << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3100
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
    int N,K;
  	cin >> N >> K;
    vector<int>h(N);
    rep(i,N) cin >> h[i];
  
    sort(h.begin(),h.end());
    int temp = INT_MAX;
    rep(i,N-K+1){
        temp = min(temp,h[i+K-1]-h[i]);
    }
    cout<<temp<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

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

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

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

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VLL t(n), a(n);
  rep(i,n) cin >> t[i] >> a[i];
  ll tt = t[0];
  ll aa = a[0];
  rep(i,n){
    ll ntt1 = tt + ((t[i] - (tt % t[i]) ) % t[i]);
    ll naa1 = a[i]*(ntt1/t[i]);

    ll naa2 = aa + (( a[i] - (aa % a[i]) ) % a[i]);
    ll ntt2 = t[i] * (naa2/a[i]);
    if(naa1 < aa){
      aa = naa2;
      tt = ntt2;
    }else if(ntt2 < tt){
      aa = naa1;
      tt = ntt1;
    }else{
      if((naa1+ntt1) >= (naa2 + ntt2)){
        aa = naa2;
        tt = ntt2;
      }else{
        tt = ntt1;
        aa = naa1;
      }
    }
    // cout << tt << " " << aa << endl;
  }
  cout << tt+aa << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 500010
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[N],b[N],n;
inline int check(int k)
{	memcpy(b,a,sizeof(a));
	for(rint i=1;i<=n;i+=2)
	if(i==n) return (b[i]>=k);
	else if(!(b[i]>=k&&b[i+1]>=b[i])) b[i+2]+=b[i]-b[i+1];
}
int main()
{	int s0=0,s1=0; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]),(i&1)?s0+=a[i]:s1+=a[i];
	if(n%2==0){cout<<max(s0,s1)<<" "<<min(s0,s1)<<endl;return 0;}
	int l=0,r=3e8,ans=-1;
	while(l<=r)
	{	int mid=(l+r)>>1;
		if(check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	cout<<ans+s1<<" "<<s0-ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>

using namespace std;

int main(){

    int a,b,c,tmp;

    cin >> a >> b >> c;

    tmp=a;
    a=b;
    b=tmp;
    tmp=a;
    a=c;
    c=tmp;

    printf("%d %d %d",a,b,c);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;

int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
typedef pair<int,int> p;

int main()
{
	int w,h;
	while(cin>>w>>h,w||h){
		
		//even;LR
		//odd:UD
		vector<vector<int> > even,odd;
		for(int i=0;i<2*h-1;i++){
			if(i%2==0){
				even.push_back(vector<int>(w-1));
				for(int j=0;j<w-1;j++){
					cin>>even[i/2][j];
				}
			}else{
				odd.push_back(vector<int>(w));
				for(int j=0;j<w;j++){
					cin>>odd[i/2][j];
				}
			}
		}
		
		int d[50][50];
		for(int i=0;i<50;i++){
			for(int j=0;j<50;j++){
				d[i][j]=1e7;
			}
		}
		d[0][0]=0;
		queue<p> q;
		
		q.push(p(0,0));
		while(!q.empty()){
			
			p pos=q.front();
			q.pop();
			int y=pos.first,x=pos.second;
			
			//cout<<"y="<<y<<" x="<<x<<" d="<<d[y][x]<<endl;
			
			//left
			int nx=x-1,ny=y;
			if( 0<=nx && nx<w && 0<=ny && ny<h && d[ny][nx]==1e7 && even[y][x-1]==0){
				d[ny][nx]=d[y][x]+1;
				q.push(p(ny,nx));
			}
			
			//right
			nx=x+1,ny=y;
			if( 0<=nx && nx<w && 0<=ny && ny<h && d[ny][nx]==1e7 && even[y][x]==0){
				d[ny][nx]=d[y][x]+1;
				q.push(p(ny,nx));
			}
			
			//up
			nx=x,ny=y-1;
			if( 0<=nx && nx<w && 0<=ny && ny<h && d[ny][nx]==1e7 && odd[y-1][x]==0){
				d[ny][nx]=d[y][x]+1;
				q.push(p(ny,nx));
			}
			
			nx=x,ny=y+1;
			if( 0<=nx && nx<w && 0<=ny && ny<h && d[ny][nx]==1e7 && odd[y][x]==0){
				d[ny][nx]=d[y][x]+1;
				q.push(p(ny,nx));
			}			
			
		}
		
		//cout<<h-1<<" "<<w-1<<endl;
		if(d[h-1][w-1]==1e7) d[h-1][w-1]=-1;
		cout<<d[h-1][w-1]+1<<endl;
		
	}
	
	
	return 0;
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	For(i,1,s.size()){
		if(s[i] == '9'){
		} else {
			cout << s.size() * 9 - 9 + (int)(s[0]-'0' -1) << endl;
			return 0;
		}
	}
	cout << s.size() * 9 - 9 + (int)(s[0] -'0') << endl;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.length();
  int ans = n;
  for (int i = 1; i < n; i++) {
    if( s[i-1] != s[i] ) {
      ans = min( ans, max( i, n-i ) );
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = -1;
        for(int i=0;i<1500;i++){
            if(Math.floor(i * 0.08) == A && Math.floor(i * 0.10) == B){
                ans = i;
                break;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    LL X;
    cin >> X;

    LL happy = X / 500 * 1000;
    X %= 500;
    happy += X / 5 * 5;

    cout << happy << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct Solution {
    int a, b, c;
};


map<P, int> make_p(vector<Solution> &v) {
    map<P, int> ans;
    int n = v.size();
    rep(i, 1 << n) {
        int a = 0, b = 0, c = 0;
        rep(j, n) if ((i >> j) & 1) {
                a += v[j].a;
                b += v[j].b;
                c += v[j].c;
            }
        P p(a, b);
        if (ans.find(p) == ans.end()) {
            ans[p] = c;
        } else {
            cmin(ans[p], c);
        }
    }
    return ans;
}

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<Solution> v(n);
    for (Solution &s:v)cin >> s.a >> s.b >> s.c;

    vector<Solution> sol1, sol2;
    rep(i, n)if (i % 2 == 0) sol1.push_back(v[i]);
        else sol2.push_back(v[i]);

    auto p1 = make_p(sol1);
    auto p2 = make_p(sol2);

    auto calc = [](ll x, ll y) -> ll {
        if (x <= y) return 1;
        return (x + y - 1) / y;
    };
    int ans = INT_MAX;
    for (auto e1:p1) {
        P xp = e1.first;
        ll ar = calc(xp.first, ma);
        ll br = calc(xp.second, mb);
        for (int r = 1; r <= 200; r++) {

            ll ta = ma * r;
            ll tb = mb * r;

            ll ya = ta - xp.first;
            ll yb = tb - xp.second;

            P y(ya, yb);
            if (p2.find(y) == p2.end()) continue;
            int c = p2[y];
            int now = e1.second + c;
            cmin(ans, now);
        }
    }
    cout << (ans == INT_MAX ? -1 : ans) << endl;
}


Measured memory_bytes: 4224
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""
alice = input().split()
alice[0] = int(alice[0])
alice[1] = int(alice[1])
if(alice[0] == alice[1]):
    print("Draw")
elif(alice[0] == 1):
    print("Alice")
elif(alice[1] == 1):
    print("Bob")
elif(alice[0] < alice[1]):
    print("Bob")
elif(alice[0] > alice[1]):
    print("Alice")



Measured memory_bytes: 3064
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N, X, M int
  NextInt(&N, &X, &M)
  F := make([]int, M)
  for i := range F { F[i] = (i * i) % M }
  V := make([]int, M)
  A := make([]int, M + 1)
  A[0] = X
  s, t := 0, 0
  for i, a := range A {
    V[a] = i + 1
    f := F[a]
    if V[f] > 0 { s, t = V[f] - 1, i + 1; break }
    A[i + 1] = f
  }
  S := SumInt(A[:MinInt(t, N)]...)
  if t < N {
    S += SumInt(A[s:t]...) * ((N - t) / (t - s)) + SumInt(A[s:s+(N-t)%(t-s)]...)
  }
  Write(S)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}


Measured memory_bytes: 3844
n,m = map(int, raw_input().split())
v = [map(int, raw_input().split()) for _ in range(n)]

l = [[[[0 for _ in range(n)] for _ in range(2)] for _ in range(2)] for _ in range(2)]
for d in range(n):
    for i,a in enumerate([1, -1]):
        for j,b in enumerate([1, -1]):
            for k,c in enumerate([1, -1]):
                l[i][j][k][d] += a * v[d][0] + b * v[d][1] + c * v[d][2]
mx = -1
for i in range(2):
    for j in range(2):
        for k in range(2):
            l[i][j][k].sort()
            mx = max(mx, abs(sum(l[i][j][k][:m])))
print mx


Measured memory_bytes: 3072
c=[[0]*3001for _ in range(3001)]
dp=[[[0]*3001for _ in range(3001)]for _ in range(4)]
h,w,k=map(int,input().split())
for i in range(k):
    y,x,v=map(int,input().split())
    c[y][x]=v
for i in range(1,h+1):
    for j in range(1,w+1):
        x=max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j])
        for k in range(4):
            if k:dp[k][i][j]=max(dp[k][i][j-1],dp[k-1][i][j-1]+c[i][j])
            else:dp[k][i][j]=max(dp[k][i][j-1],x)
        dp[1][i][j]=max(dp[1][i][j],x+c[i][j])
print(max(dp[0][h][w],dp[1][h][w],dp[2][h][w],dp[3][h][w]))

Measured memory_bytes: 424916
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;

ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a % mod;
	if(b%2 == 1)
		return (power(a,b-1)*a) % mod;
	ll q = power(a,b/2);
	return (q*q) % mod;
}

void solve(){

  ll x=1,c=0,ans=0,y = 1e18;
  ll n,m,k;
  cin>>n >> m;
  for (ll i = 2; i*i <= n; ++i) {
  	c = 0, k = 0;

  	while(n % i == 0) {
  		n = n / i;
  		c++;
  	}
  	//cout << i <<" ";c(c);
  	while((k+1) * (k+2) <= 2 * c)
  		k++;

  	ans += k;

  }

  if(n>1)ans++;

  cout << ans << '\n';
 
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 3688
n, m = map(int, input().split())

broken = [0] * (n+1)
dp = [0] * (n+1)

for _ in range(m):
  broken[int(input())] = 1
  if sum(broken[-2:]) == 2:
    print(0)
    exit()

dp[0] = 1

if broken[1] == 1:
  dp[1] = 0
else:
  dp[1] = 1

if n == 1:
  print(dp[n])
  exit()
else:
  for i in range(2, n+1):
    if broken[i] == 1:
      continue
    else:
      dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[n])

Measured memory_bytes: 7668
#include <stdio.h>
#include <math.h>

double round(double cl)
{
  double re;
  re = cl * pow(10, 3);
  if (cl >= 0)
    {
      re = (double)(int)(re + 0.5);
    }
  else
    {
      re = (double)(int)(re - 0.5);
    }
  return re * pow(10, -3);
}

int main()
{
  double a, b, c, d, e, f;
  double x, y;
  while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)!= EOF)
    {
      y = (c * d - f * a) / ( b * d - e * a );
      x = (c * e - f * b) / ( a * e - d * b );
      y = round(y);
      x = round(x);
      printf("%5.3lf %5.3lf\n", x, y);
    }
  return 0;
}

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

int main()
{
    ll n,i,j;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll res[n];
    res[0] = a[0];
    ll sn = -1;
    for(i=1;i<n;i++)
    {
        res[0] = res[0]+(sn*a[i]);
        sn *= -1;
    }
    for(i=1;i<n;i++)
    {
        res[i] = 2*(a[i-1]-(res[i-1]/2));
    }
    for(i=0;i<n;i++)    cout<<res[i]<<" ";
    return 0;
}


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

void Main()
{
    long n, k;
    cin >> n >> k;
    int a[n+1];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i+1];
    }

    int path[n+2], went[n+1]={0}, order[n+1];
    path[0] = 1; // i回テレポートした時の現在の街の番号
    went[1] = 1; // i番目の街に過去にテレポートしたかどうか
    order[1] = 0; // i番目の街に最短で到達するときのテレポート回数
    int loop_start, loop_end;
    for (int i = 0; i < n; i++)
    {
        path[i+1] = a[path[i]];
        if(went[path[i+1]] == 1){
            loop_start = path[i+1];
            loop_end = path[i];
            break;
        }
        went[path[i+1]] = 1;
        order[path[i+1]] = i+1;
    }
    
    if(k < order[loop_end]){
        cout << path[k] << endl;
        return;
    }
    long n_loop = order[loop_end] - order[loop_start] + 1;
    cout << 
        path[(k - order[loop_start]) % n_loop + order[loop_start]]
        << endl;
    
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 6552
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->right!=NIL)x=x->left;
  return x;
}

Node treeSearch(Node x, int k){
  while (x!=NIL && k!=x->key){
    if(k<x->key)x=x->left;
    else x=x->right;
    return x;
  }

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL){
    return treeMinimum(x->right);
    y=x->parent;
    while (y !=NIL && x==y->right){
      x=y;
      y=y->parent;
    }
    return y;
}

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL){
    y = z;
}
  else y=treeSuccessor(z);

  if(y->left !=NIL)x=y->left;
  else x=y->right;

  if(x != NIL)x->parent=y->parent;
  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent=x;
  else y->parent->right;
  if(y!=z){
    z->key=y->key;
  }
}



void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if (z->key<y->key)y->left=z;
  else y->right=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    
    printf(" %d",u->key); 
    preorder(u->left);
    preorder(u->right);

  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

using namespace std;

int main() {

  string S, T;
  cin >> S >> T;

  int a[26] = {};
  int b[26] = {};
  for (int i = 0; i < S.size(); ++i) {
    char s = S[i];
    char t = T[i];
    int si = s - 'a';
    int ti = t - 'a';
    a[si] += 1;
    b[ti] += 1;
  }

  sort(a, a+26);
  sort(b, b+26);

  bool equal = true;
  for (int i = 0; i < 26; ++i) {
    if (a[i] != b[i]) {
      equal = false;
      break;
    }
  }

  if (equal) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 776
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;



int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    int n = s.length();
    if (n == 2) {
        if (s[0] == s[1]) printf("%d %d\n", 1, 2);
        else printf("-1 -1\n");
        return 0;
    }
    for (int i = 2; i < n; ++i) {
        char c3 = s[i];
        char c2 = s[i-1];
        char c1 = s[i-2];
        if (c3 == c2 || c3 == c1 || c2 == c1) {
            printf("%d %d\n", i-1, i+1);
            return 0;
        }
    }
    printf("-1 -1\n");
    return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <fstream>
#include <stdio.h>

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8

char input[1025];
char g[]=".,!? abcdefghijklmnopqrstuvwxyz";
int h[]={5,3,3,3,3,3,4,3,4};
int k[10];

inline char gc(int b, int r){
	r=(r-1)%h[b];
	return g[k[b]+r];
}

int main(){
	int t;
	cin>>t;
	k[0] = 0;
	REP(i,9)k[i+1]=k[i]+h[i];
	REP(i,t){
		cin>>input;
		int n=strlen(input);
		int r=0;
		REP(j,n){
			if(input[j]!='0')r++;
			else{
				if(r!=0)
					cout << gc(input[j-1]-'0'-1, r);
					r=0;
			
			}
		}
		cout << endl;

	}
}

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

int main(){
  int N; cin>>N;
  vector<pair<ll,ll>> V(N);
  rep(i,N){
    ll A,B; cin>>A>>B;
    V[i]={B,A};
  }
  sort(V.begin(),V.end());
  ll cur=0;
  for(auto& p:V){
    if(cur+p.second>p.first){
      cout<<"No\n";
      return 0;
    }
    cur+=p.second;
  }
  cout<<"Yes\n";
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
int i,o,k,u,s,l,h;
cin>>i>>o>>k>>u>>s>>l;
h=i+(o*5)+(k*10)+(u*50)+(s*100)+(l*500);
if(h>=1000){
cout<<1<<endl;
}
if(h<1000){
cout<<0<<endl;
}

}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed << setprecision(20);
 	ld a, b, h, m;
 	cin >> a >> b >> h >> m;
 	ld theta = pival * 2.0 * ((h / 12.0) + ((m / 60.0) / 12.0) - m / 60.0);
 	ld cosx = cos(theta);
 	ld ans = a * a * 1.0 + b * b * 1.0 - 2 * a * b * cosx * 1.0;
 	ans = sqrt(ans);
 	cout << ans << endl;   
	return 0;
}

Measured memory_bytes: 4176
#include <stdio.h>
#include <stdlib.h>

#define MAX 100001

typedef struct{
  char name[100];
  int time;
} Process;

void initialize(void);
void enqueue(int);
int dequeue(void);
int isEmpty(void);
int isFull(void);

int head,tail;
Process prc[MAX];

int main(){
  int n,q,i,prcIndex,prcTime=0;

  initialize();
  //in
  scanf("%d%d",&n,&q);

  for(i=0;i<n;i++){
    scanf("%s",prc[i].name);
    scanf("%d",&prc[i].time);
  }
  
  tail=n;

  //calculation
  while(head!=tail){
    prcIndex = dequeue();
    if(prc[prcIndex].time>q){
      prcTime += q;
      prc[prcIndex].time -= q;
      enqueue(prcIndex);
    } else {
      prcTime += prc[prcIndex].time;
      printf("%s %d\n",prc[prcIndex].name,prcTime);
    }
  }
  
  return 0;
}

void initialize(void){
  head = tail = 0;
}

void enqueue(int x){
  if(isFull()){
    printf("Overflow!\n");
    exit(1);
  }
  prc[tail]=prc[x];
  if(tail+1== MAX) tail = 0;
  else tail++;
}

int dequeue(void){
  int x;

  if(isEmpty()){
    //printf("Underflow!\n");
    //exit(2);
  }
  x=head;
  if(head+1==MAX) head = 0;
  else head++;
  
  return x;
}

int isEmpty(void){
  if(head == tail) return 1;
  else return 0;
}

int isFull(void){
  if(head == (tail+1) % MAX) return 1;
  else return 0;
}

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

// main
int main(){
    int n; cin >> n;
    vector<int> v(n); rep(i, n)cin >> v[i];

    cout << abs(*min_element(v.begin(), v.end()) - *max_element(v.begin(), v.end())) << "\n";

    return 0;
}

Measured memory_bytes: 256