akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	string S;
	cin >> S;
	bool exists[26] = { false };
	if (S.length() < 26) {
		for (char c : S) exists[c - 'a'] = true;
		cout << S;
		for (int i = 0; i < 26; i++) {
			if (!exists[i]) {
				cout << (char)('a' + i) << endl;
				break;
			}
		}
	}
	else {
		if (S == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
			return 0;
		}
		string origin = S;
		next_permutation(S.begin(), S.end());
		for (int i = 0; i < S.length(); i++) {
			cout << S[i];
			if (origin[i] != S[i]) break;
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES": "NO") << endl;}
void R_YesNo(bool p) { cout << (p ? "Yes": "No") << endl;}
// ベルマンフォード法
// O(VE)
// s から t への最短距離を計算
template<typename Edge, typename T>
bool BellmanFord(const vector<Edge> &edge, int V, int s, int t, T& ans, T inf = 1e15) {
	vector<T> dist(V, inf);
	dist[s] = 0;
	for(int i = 0; i < 2 * V; i++) {
		for(auto &e : edge) {
			if(dist[e.to] > dist[e.from] + e.cost) {
				dist[e.to] = dist[e.from] + e.cost;
				if(i > V && e.to == V - 1) {
					return false;
				}
			}
		}
	}
	ans = dist[t];
	return true;
}

struct Edge {
    int from, to;
    i64 cost;
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<Edge> edge(M);
    for(auto &e : edge) {
        int a, b;
        i64 c;
        cin >> a >> b >> c;
        e = {--a, --b, -c};
    }
    i64 ans = 0;
    if(!BellmanFord(edge, N, 0, N - 1, ans)) {
        cout << "inf" << endl;
    } else {
        cout << -ans << endl;
    }
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(5e2 + 5);

int n;
ll k;
ll a[MAX_N];

ll whole = 0LL;

ll ans;

bool check(ll cand) {
  vector<ll> tmp;

  for (int i = 0; i < n; ++i) {
    tmp.push_back(a[i] % cand);
  }

  sort(tmp.begin(), tmp.end());

  vector<ll> plus;
  vector<ll> minus;

  for (auto &e : tmp) {
    if (e == 0) continue;
    plus.push_back(cand - e);
    minus.push_back(e);
  }

  // printf("cand: %lld: ", cand);
  // printf("\n");

  // printf("tmp: ");
  // for (auto &e : tmp) {
  //   printf("%lld ", e);
  // }
  // printf("\n");

  // printf("plus: ");
  // for (auto &e : plus) {
  //   printf("%lld ", e);
  // }
  // printf("\n");

  // printf("minus: ");
  // for (auto &e : minus) {
  //   printf("%lld ", e);
  // }
  // printf("\n");

  int size = plus.size();

  for (int i = 1; i < size; ++i) {
    plus[i] += plus[i - 1];
    minus[i] += minus[i - 1];
  }

  // printf("plus: ");
  // for (auto &e : plus) {
  //   printf("%lld ", e);
  // }
  // printf("\n");

  // printf("minus: ");
  // for (auto &e : minus) {
  //   printf("%lld ", e);
  // }
  // printf("\n");

  // printf("\n");

  for (int i = 0; i < size; ++i) {
    if (minus[i] == (plus[size - 1] - plus[i])) {
      if (minus[i] <= k) {
        return true;
      }
    }
  }

  return false;
}

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &k);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
    whole += a[i];
  }

  ans = 1LL;

  for (ll i = 1LL; i * i <= whole; ++i) {
    if (whole % i != 0) continue;  // not candidate

    ll other = whole / i;

    // printf("- %lld %d\n", i, check(i));
    // printf("- %lld %d\n", other, check(other));

    if (check(i)) {
      ans = max(ans, i);
    }

    if (check(other)) {
      ans = max(ans, other);
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
count = int(input())
nums = list(map(int, input().split()))

minAbs = 0
isFirst = True

for i in range(count):
    leftSum = 0
    rightSum = 0
    for leftIndex in range(i + 1):
        leftSum += nums[leftIndex]

    for rightIndex in range(i + 1, count):
        rightSum += nums[rightIndex]

    if isFirst:
        minAbs = abs(leftSum - rightSum)
        isFirst = False
    else:
        minAbs = min(abs(leftSum - rightSum),minAbs)
        

print(minAbs)


Measured memory_bytes: 3060
# coding: utf-8
# hello worldと表示する
a,b=map(int,input().split())
ans=True
for i in range(a+1):
    for j in range(a+1-i):
        if ans==True:
            s=10000*i+5000*j+1000*(a-i-j)
            if s == b:
                print(str(i)+" "+str(j)+" "+str(a-i-j))
                ans = False
        else:
            break
if ans==True:
    print("-1 -1 -1")

Measured memory_bytes: 3188
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let c: String = read();
    let v = vec!["a","e","i","o","u"];
    let ans = if v.contains(&c.as_str()){
        "vowel"
    } else {
        "consonant"
    };
    println!("{}",ans );
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  	string s;
  	cin >> s;
  	set<char> st;
  	st.insert(s.begin(), s.end());
  	if(st.size() != 2) cout << "No\n";
  	else {
      	map<char, int> mp;
     	for(auto x: s)  mp[x]++;
      	int flag = 1;
      	for(auto x: mp) {
         	if(x.second != 2) {
             	flag = 0;
              	break;
            }
        }
      	if(!flag) cout << "No\n";
      	else cout << "Yes\n";
    }
  
  
  
 	return 0; 
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    private List<long[]> prime_factorize(long N) {
        List<long[]> res = new ArrayList<long[]>();
        for (long a = 2; a * a <= N; a++) {
            if (N % a != 0) continue;
            long ex = 0;

            while (N % a == 0) {
                ++ex;
                N /= a;
            }   

            res.add(new long[]{a, ex});
        }   

        if (N != 1) res.add(new long[]{N, 1});
        return res;
    } 

    public void run() {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        List<long[]> list = prime_factorize(N);

        long ans = 0;
        for (long[] p : list) {
            long num = p[0];
            long cnt = p[1];
            //System.out.println(String.format("%d %d", num, cnt));

            long i = 1;
            while (cnt - i >= 0) {
                ans++;
                //System.out.println(String.format("\t%d %d", cnt, i));
                cnt -= i;
                i++;
            }
        }

        System.out.println(ans);
        return;
    }

}

Measured memory_bytes: 35844
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, q;
string s;
char t[202020], d[202020];

int main(){
	cin >> n >> q;
	cin >> s;
	for(int i = 0; i < q; i++){
		cin >> t[i] >> d[i];
	}
	
	int l = 0, r = n-1;
	int ansl = 0, ansr = 0;
	while(l <= r){
		int c = (l+r)/2, cc = (l+r)/2;
		for(int i = 0; i < q; i++){
			if(t[i] == s[c]){
				if(d[i] == 'L') c--;
				else c++;
			}
			if(c < 0){
				l = cc+1;
				ansl = cc+1;
				break;
			}
		}
		if(l != cc+1) r = cc-1;
	}
	
	l = ansl; r = n-1;
	while(l <= r){
		int c = (l+r)/2, cc = (l+r)/2;
		for(int i = 0; i < q; i++){
			if(t[i] == s[c]){
				if(d[i] == 'L') c--;
				else c++;
			}
			if(c >= n){
				r = cc-1;
				ansr = n-cc;
				break;
			}
		}
		if(r != cc-1) l = cc+1;
	}
	
	cout << n-(ansl + ansr) << endl;
	
	return 0;
}

Measured memory_bytes: 1028
N,L = map(int,input().split())
inf = float('inf')
eat = inf
ans = 0
for i in range(N):
    eat = min(eat, abs(L+i))
if L > 0:
    s = eat - L + 1
else:
    s = abs(eat + L -1)

for i in range(1,N+1):
    if s == i:
        continue
    ans += L + i -1
print(ans)


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

using namespace std;

typedef pair<int,int> pii;

#define F first
#define S second

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

	int n;
	while(cin >> n)
	{
		vector<pii> v(n);
		for(int i=0; i<n; i++)
		{
			cin >> v[i].F;
			v[i].S = i;
		}
		int cnt = 0;
		sort(v.begin(),v.end());
		for(int i=0; i<n; i++)
		{
			int diff = abs(i-v[i].S);
			if(diff&1)
				cnt++;
		}
		assert(cnt%2 == 0);
		cout << cnt/2 << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

template<class T>
class d_heap_for_Dijkstra{
	static const int N_MAX=100;
	int n,d,key[N_MAX],pos[N_MAX];
	T val[N_MAX];

	void sift_up(int i,const T &x){
		val[i]=x;
		while(i!=0 && val[(i-1)/d]>val[i]){
			int p=(i-1)/d;
			swap(pos[key[p]],pos[key[i]]);
			swap(key[p],key[i]);
			swap(val[p],val[i]);
			i=p;
		}
	}
	void sift_down(int i,const T &x){
		val[i]=x;
		for(int j,k,c;;i=j){
			j=i;
			for(c=0,k=d*i+1;c<d;c++,k++) if(k<n && val[j]>val[k]) j=k;
			if(j==i) break;
			swap(pos[key[j]],pos[key[i]]);
			swap(key[j],key[i]);
			swap(val[j],val[i]);
		}
	}
public:
	d_heap_for_Dijkstra(int d):n(0),d(d){}
	int find_min()const{ return key[0]; }
	void insert(int u,const T &x){
		int i=n++;
		key[i]=u;
		pos[u]=i;
		sift_up(i,x);
	}
	void delete_min(){
		n--;
		pos[key[n]]=pos[key[0]];
		key[0]=key[n];
		sift_down(0,val[n]);
	}
	void decrease_key(int u,const T &x){
		sift_up(pos[u],x);
	}
	bool empty()const{ return n==0; }
	int size()const{ return n; }
};

const int INF=1<<29;

struct edge{ int v,cost1,cost2; };

int main(){
	for(int m,n;scanf("%d%d",&m,&n),n;){
		vector<edge> G[100];
		rep(i,m){
			int u,v,cost1,cost2; scanf("%d%d%d%d",&u,&v,&cost1,&cost2); u--; v--;
			G[u].push_back((edge){v,cost1,cost2});
			G[v].push_back((edge){u,cost1,cost2});
		}

		int q; scanf("%d",&q);
		while(q--){
			int s,t,type; scanf("%d%d%d",&s,&t,&type); s--; t--;

			int d[100];
			rep(u,n) d[u]=(u==s?0:INF);
			d_heap_for_Dijkstra<int> H(5);
			H.insert(s,0);
			while(!H.empty()){
				int u=H.find_min();
				H.delete_min();

				rep(i,G[u].size()){
					const edge &e=G[u][i];
					int d2=d[u]+(type==0?e.cost1:e.cost2);
					if(d[e.v]>d2){
						if(d[e.v]==INF) H.insert(e.v,d2);
						else            H.decrease_key(e.v,d2);
						d[e.v]=d2;
					}
				}
			}

			printf("%d\n",d[t]);
		}
	}

	return 0;
}

Measured memory_bytes: 1148
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 999999999
R = 10**9 + 7
import math

def ddprint(x):
  if DBG:
    print(x)

def prime_division2(x):
    q = int(math.sqrt(x))
    h = {}
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            h[i] = ex
    if x>q:
        h[x] = 1
    return h

n = inn()
facc = {}
for i in range(1,n+1):
    f = prime_division2(i)
    ddprint("prdiv i {} f:".format(i))
    ddprint(f)
    for p in f:
        if p in facc:
            facc[p] += f[p]
        else:
            facc[p] = f[p]

ddprint(facc)
n74plus = len([x for x in facc if facc[x]>=74])
n24plus = len([x for x in facc if facc[x]>=24])
n14plus = len([x for x in facc if facc[x]>=14])
n4plus = len([x for x in facc if facc[x]>=4])
n2plus = len([x for x in facc if facc[x]>=2])
sm = n74plus
sm += n24plus*(n2plus-1)
sm += n14plus*(n4plus-1)
sm += n4plus*(n4plus-1)*(n2plus-2)//2
print(sm)


Measured memory_bytes: 38384
#include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 200010
#define MAX 1000000000000000000
#define MOD 1000000007

#include <stdio.h>


int main(void)
{
    int x;

    scanf("%d", &x);

    if (x == 1) {
        puts("0");
    } else {
        puts("1");
    }

    return 0;
}



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

const int maxn = 1e5+5;
int dp[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int x; cin >> x;
    dp[0] = 1;
    for (int i = 0; i <= x; i++) {
        if (dp[i] == 1) {
            dp[i+100] = 1;
            dp[i+101] = 1;
            dp[i+102] = 1;
            dp[i+103] = 1;
            dp[i+104] = 1;
            dp[i+105] = 1;
        }
    }
    cout << dp[x] << '\n';
}



Measured memory_bytes: 640
from operator import itemgetter

N = int(input())

lst_1 = []

for i in range(N):

    lst_2 = []
    lst_2.extend(input().split())
    lst_2.append(str(i + 1))
    lst_1.append(lst_2)

for i in range(N):

    lst_1[i][1] = int(lst_1[i][1])

lst_1.sort(key=itemgetter(1))

lst_1.reverse()

lst_1.sort(key=itemgetter(0))

for i in range(N):

    print(int(lst_1[i][2]))

Measured memory_bytes: 3064
#include <iostream>
#include <array>

using ll = long long;
using namespace std;

int main() {
    array<int, 1001> A{};
    fill(A.begin(), A.end(), 10000);
    A[0] = 0;
    int a[6] = {500, 100, 50, 10, 5, 1};
    for (int i = 0; i < 1001; ++i) {
        for (auto &&v : a) {
            if (v <= i) {
                A[i] = min(A[i-v]+1, A[i]);
                break;
            }
        }
    }
    int n;
    while(cin>>n, n) {
        cout << A[1000 - n] << "\n";
    }
    return 0;
}



Measured memory_bytes: 3096
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}
// data structure {{{

// Union-Find
// verified AOJ DSL_1_A
struct UF {
    vector<int> p;  // parent
    vector<int> r;  // rank

    UF(int n) {
        p.resize(n);
        r.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
            r[i] = 1;
        }
    }

    int find(int x) {
        if(x == p[x]){
            return x;
        }else{
            return p[x] = find(p[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(r[x] < r[y]){
            p[x] = y;
        }else{
            p[y] = x;
            if(r[x] == r[y]){
                r[x]++;
            }
        }
    }
};
//}}}

int main() {
    int n, k, l;cin >> n >> k >> l;
    UF ufp(n), ufr(n);
    for(int i=0;i<k;i++){
        int a, b;cin >> a >> b;a--;b--;
        ufp.unite(a, b);
    }
    for(int i=0;i<l;i++){
        int a, b;cin >> a >> b;a--;b--;
        ufr.unite(a, b);
    }

    map<pair<int, int>, int> m;

    for(int i=0;i<n;i++){
        pair<int, int> p = {ufp.find(i), ufr.find(i)};
        // if(m.find(p) == m.end()){
        //     m[p] = 0;
        // }
        m[p]++;
    }

    bool flag = true;
    for(int i=0;i<n;i++){
        if(!flag){
            cout << " ";
        }
        flag = false;
        pair<int, int> p = {ufp.find(i), ufr.find(i)};
        cout << m[p];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n, m, q;
    int a[60], b[60], c[60], d[60];
    cin >> n >> m >> q;
    fori(q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    int s[10] = { 1,1,1,1,1,1,1,1,1,1 };
    int h = 0;
    for (int l = 1; l <= m; ++l) {
        fori(n) {
            s[i] = l;
        }
        while (1) {
            bool ok = true;
            for (int i = 0; i < n - 1; ++i) {
                if (s[i] > s[i + 1]) {
                    ok = false;
                }
            }
            if (ok) {
                int score = 0;
                fori(q) {
                    if (s[b[i] - 1] - s[a[i] - 1] == c[i]) {
                        score += d[i];
                    }
                }
                if (score > h) {
                    h = score;
                }
                /*fori(n){
                    cout<<s[i];
                }
                cout<<"\t"<<score<<endl;*/
            }
            bool end = true;
            fori(n) {
                if (s[i] != m) {
                    end = false;
                    break;
                }
            }
            if (end) {
                break;
            }

            /*for (int i = n - 1; i >= 0; --i) {
                if (s[i] < m) {
                    if (s[i] == 1 && i != n - 1) {
                        s[i + 1] = 1;
                    }
                    ++s[i];
                    break;
                }
            }*/
            ++s[n - 1];
            for(int i = n - 1; i > 0; --i) {
                if (s[i] > m) {
                    ++s[i - 1];
                    for (int j = i; j < n; ++j) {
                        s[j] = s[i - 1];
                    }
                }
            }
        }
    }
    cout << h;
}

Measured memory_bytes: 3624
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut dp: Vec<usize> = vec![1 << 30; 100010];
    dp[0] = 0;
    for i in 0..n {
        for j in (a[i].1..100005).rev() {
            dp[j] = min(dp[j], dp[j - a[i].1] + a[i].0);
        }
    }
    let mut ans = 0;
    for i in 0..100005 {
        if dp[i] <= w {
            ans = i;
        }
    }
    println!("{}", ans);
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%lld",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5 + 5;
ll v[N];
int n;

ll f(ll x) {
	loop(i,n)
	{
		x = x / v[i] * v[i];
	}
	return x;
}

ll bs(ll s, ll e) {
	while (s < e) {
		ll mid = s + (e - s + 1) / 2;
		if (f(mid) == 2) {
			s = mid;
		} else {
			e = mid - 1;
		}
	}
	return s;
}

int main() {

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#endif

	sfi1(n);
	loop(i,n)
	{
		sfll1(v[i]);
	}

	if (v[n - 1] != 2) {
		cout << -1 << endl;
		return 0;
	}

	ll lowest = 2, largest = 3;
	rloop(i,n-2)
	{
		ll tmp = lowest;
		if (v[i] > lowest) {
			lowest = v[i];
		} else {
			lowest = (lowest + v[i] - 1) / v[i] * v[i];
		}
	}

	if (f(lowest) != 2) {
		puts("-1");
	} else {
		cout << lowest << " " << bs(lowest, 1e18) << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <algorithm>
#include <cmath>
#define ll long long
#define mod 1000000007
using namespace std;

ll n, arr[10004];
map<ll, ll>mp;

ll fp(ll base, ll power)
{
    if (power == 0) return 1;
    ll ans = fp(base, power / 2);
    ans = (ans * ans) % mod;
    if (power % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void get_max(ll key, ll val)
{
    map<ll, ll>::iterator it = mp.find(key);
    if (it == mp.end())
        mp.insert({ key,val });
    else
        it->second = max(it->second, val);
}

void get_factors(ll x)
{
    ll xx = x;
    bool prime = 1;
    for (ll i = 2; i * i <= x; i++)
    {
        if (xx % i == 0)
        {
            prime = 0;
            ll power = 0;
            while (xx % i == 0)
            {
                power++;
                xx /= i;
            }
            get_max(i, power);
        }
    }
    if (xx > 1)
        get_max(xx, 1);
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        get_factors(arr[i]);
    }
    ll lcm = 1, ans = 0;
    for (auto i : mp)
        lcm = ((lcm % mod) * fp(i.first, i.second)) % mod;
    for (int i = 0; i < n; i++)
        ans = (ans + ((lcm * fp(arr[i], mod - 2)) % mod)) % mod;
    cout << ans % mod << '\n';
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589
#define endl "\n"
#define int long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define fr(i,a,b) for (int i = (a); i < (b); ++i)

void solve(){
    int n, m;
    cin >> n >> m;
    char a[n][m];
    fr(i, 0, n) fr(j, 0, m) cin >> a[i][j];
    int dp[n + 1][m + 1];
    int M = 1e9 + 7;
    fr(i, 0, n + 1) dp[i][0] = 0;
    fr(j, 0, m + 1) dp[0][j] = 0;
    dp[1][1] = 1;
    fr(i, 1, n + 1) fr(j, 1, m + 1){
        if(i * j == 1) continue;
        if(a[i - 1][j - 1] == '#') dp[i][j] = 0;
        else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % M;
    }
    cout << dp[n][m];
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int t;
    t = 1;
    //cin >> t;
    while(t--) {solve();}
    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
const int INF = 1001001001;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    
    sort(a.begin(), a.end(), greater<int>());
    
    cout << a[0] << " ";
    
    int temp = INF;
    int now = 1;
    for(int i = 1; i < n; ++i){
        if(a[0] - a[i] == 0)    continue;
        
        int t = abs(a[0] / 2 - a[i]);
        if(t < temp){
            temp = t;
            now = i;
        }
    }
    
    cout << a[now] << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int a,b,c,d,e,x;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&x);
	if((b-a)<=x&&(c-a)<=x&&(d-a)<=x&&(e-a)<=x)
		{if((c-b)<=x&&(d-b)<=x&&(e-b)<=x)
			if((d-c)<=x&&(e-c)<=x)
				if((e-d)<=x)
					printf("Yay!\n");}
				else
					printf(":(\n");
	return 0;
}

Measured memory_bytes: 128
import std;

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		long n, a, b, c, d;
		readf !(" %s %s %s %s %s") (n, a, b, c, d);
		long [long] costs;
		costs[2] = a;
		costs[3] = b;
		costs[5] = c;

		long [long] fSaved;
		fSaved[1] = d;

		long f (long v)
		{
			if (v !in fSaved)
			{
				long ans = long.max;
				if (d * v / v == d)
				{
					ans = d * v;
				}
				foreach (cur, cost; costs)
				{
					if (cur <= v)
					{
						auto rem = v % cur;
						ans = min (ans, cost +
						    d * rem + f (v / cur));
						if (rem > 0)
						{
							ans = min (ans, cost +
							    d * (cur - rem) +
							    f (v / cur + 1));
		                        	}
					}
				}
				fSaved[v] = ans;
			}
	                return fSaved[v];
		}

		writeln (f (n));
	}
}


Measured memory_bytes: 8376
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
using namespace std;
const int N = 1e5+5;
void fast(){std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
int n,k,R,P,S,ans=0;
bool use[N];
string s;
inline int change(char c)
{
	if(c=='r')return P;
	if(c=='p')return S;
	return R;
}
int main()
{
	fast();
	cin>>n>>k>>R>>S>>P>>s;
	for(int i=0;i<n;i++)
	{
		if(i>=k)
		{
			if(s[i]!=s[i-k]||!use[i-k])ans+=change(s[i]),use[i]=true;
		}
		else
			ans+=change(s[i]),use[i]=true;
//		cout<<ans<<' ';
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(sc.next());

		int ans = 0;
		boolean flag = true;
		
		while(flag) {
			for (int i = 0; i < n; i++) {
				if (a[i] % 2 == 0) {
					a[i] /= 2;
				} else {
					flag = false;
					break;
				}
			}
			if (flag) ans++;
		}
		
		System.out.println(ans);
		sc.close();
	}
}

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

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var query = Enumerable.Range(0, n)
			.Select(i => Console.ReadLine().Split())
			.Select((x, i) => new { Id = i + 1, City = x[0], Point = int.Parse(x[1]) })
			.OrderByDescending(r => r.Point)
			.OrderBy(r => r.City)
			.Select(r => r.Id);
		Console.WriteLine(string.Join("\n", query));
	}
}


Measured memory_bytes: 13664
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
import math


def main():
    K, S = map(int, input().split())
    cnt = 0
    for x in range(S+1):
        if x > K:
            continue
        res = S - x
        for y in range(res + 1):
            if y > K:
                continue
            z = res - y
            if z > K:
                continue
            else:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40412
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
using namespace std;

typedef double D;
typedef pair<D,int> pdi;
typedef complex<D> P;

vector<P> cs;
vector<D> rs;
vector<vector<pdi> > G;
vector<vector<P> > plgs;


bool contains(const vector<P> &plg, P pt){
	int cnt = 0;
	double y = imag(pt);
	int n = plg.size();

	for(int i = 0; i < n; ++i){
		int j = (i + 1 == n ? 0: i + 1);

		D dyi = imag(plg[i]) - y;
		D dyj = y - imag(plg[j]);
		D tx = (dyi * real(plg[j]) + dyj * real(plg[i])) / (dyi + dyj);

		if(imag(plg[i]) >= y && imag(plg[j]) < y){
			if( tx < real(pt) ) ++cnt;
		}
		else if(imag(plg[i]) < y && imag(plg[j]) >= y){
			if( tx < real(pt) ) ++cnt;
		}
	}
	
	return (cnt % 2 != 0);
}


bool solve(){
	D x1, x2, y1, y2;
	scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
	P p1(x1, y1), p2(x2, y2);
	
	bool c = 0;
	for(size_t i = 0; i < rs.size(); ++i){
		bool f1 = abs(cs[i] - p1) < rs[i];
		bool f2 = abs(cs[i] - p2) < rs[i];
		if(f1 != f2){
			return false;
		}
		c |= f1;
	}
	if(!c){
		for(size_t i = 0; i < plgs.size(); ++i){
			if(contains(plgs[i], p1) != contains(plgs[i], p2)){
				return false;
			}
		}
	}
	return true;
}


int main(){
	int n, m;
	D x, y;
	while(scanf("%d%d", &n, &m), n){
		cs.resize(n);
		rs.resize(n);
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf", &x, &y, &rs[i]);
			cs[i] = P(x, y);
		}

		plgs.clear();
		G.clear();
		G.resize(n);
		for(int i = 0; i < n; ++i)
		for(int j = i + 1; j < n; ++j){
			if(abs(cs[i] - cs[j]) < rs[i] + rs[j]){
				G[i].push_back(pdi(arg(cs[j] - cs[i]), j));
				G[j].push_back(pdi(arg(cs[i] - cs[j]), i));
			}
		}

		vector<vector<char> > asd(n);
		for(int i = 0; i < n; ++i){
			sort(G[i].begin(), G[i].end());
			asd[i].assign(G[i].size(), 0);
		}

		for(int i = 0; i < n; ++i)
		for(size_t j = 0; j < G[i].size(); ++j)
		if(!asd[i][j]){
			int s = i;
			int t = j;
			vector<P> pl;
			
			while(!asd[s][t]){
				asd[s][t] = 1;
				pl.push_back(cs[s]);
				int u = G[s][t].second;
				for(t = 0; G[u][t].second != s; ++t);
				t = (t + G[u].size() - 1) % G[u].size();
				s = u;
			}
			
			plgs.push_back(pl);
		}

		for(int i = 1; i <= m; ++i){
			printf("%s%c", solve() ? "YES" : "NO", i == m ? '\n' : ' ');
		}
	}
}

Measured memory_bytes: 1208
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
int n;set<int> st;
signed main(){
  cin>>n;
  rep(i,n){
    int a;cin>>a;
    if(st.count(a) > 0)st.erase(a);
    else st.insert(a);
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define put putchar
#define ll long long
using namespace std;
const int N=1e6+5,mo=998244353;
int n,a,m,c[N],p[N],ps,mu[N],f[N],iv[N];
int ans;
bool b[N];
int main(){
	cin>>n;
	fo(i,1,n)scanf("%d",&a),m=max(m,a),++c[a],ans=(ans+a)%mo;
	mu[1]=1;
	fo(i,2,m){
		if(!b[i])p[++ps]=i,mu[i]=-1;
		for(int j=1,u;(u=i*p[j])<=m;++j){
			b[u]=1;
			if(i%p[j]==0)break;
			mu[u]=-mu[i];
		}
	}
	iv[1]=1;
	fo(i,2,m)iv[i]=mo-(ll)iv[mo%i]*(mo/i)%mo;
	fo(i,1,m)if(mu[i])
		fo(j,1,m/i)f[i*j]=(mu[i]*iv[j]+f[i*j])%mo;
	ans=-ans;
	fo(i,1,m){
		int su=0;
		for(int j=i;j<=m;j+=i)su=((ll)c[j]*j+su)%mo;
		ans=((ll)su*su%mo*f[i]+ans)%mo;
	}
	cout<<(ll)(ans+mo)*(mo+1>>1)%mo;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

bool mt[704][704], fj = 0, dp[1500][1500];
vector<int> G[704];
short arr[704];

void dfs(int c, short a) {
	for (int i : G[c]) {
		if (arr[i] == a) {
			fj = 1;
			return;
		}
		if (arr[i] == 3 - a)
			continue;
		arr[i] = 3 - a;
		dfs(i, 3 - a);
		if (fj)return;
	}
}

int main() {
	for (int i = 0;i < 704;i++) {
		for (int j = 0;j < 704;j++)
			mt[i][j] = 0;
		for (int j = 0;j < 1500;j++)
			dp[i][j] = 0;
		arr[i] = 0;
	}
	int N, M, a, b;
	cin >> N >> M;
	for (int i = 0;i < M;i++) {
		cin >> a >> b;
		a--;b--;
		mt[a][b] = 1;
		mt[b][a] = 1;
	}
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < N;j++) {
			if (i == j)continue;
			if (mt[i][j])continue;
			G[i].push_back(j);
		}
	}

	int x, y;
	vector<pair<int, int>> A;
	for (int i = 0;i < N;i++) {
		if (arr[i] == 5)continue;
		arr[i] = 1;
		x = y = 0;
		dfs(i, 1);
		if (fj) {
			cout << -1 << endl;
			return 0;
		}
		for (int j = i;j < N;j++) {
			if (arr[j] == 1)
				x++;
			if (arr[j] == 2)
				y++;
			if (arr[j] > 0)
				arr[j] = 5;
		}
		A.push_back({ x,y });
	}

	dp[0][0] = 1;
	int ss = A.size();
	for (int i = 0;i < ss;i++) {
		for (int j = 0;j < N;j++) {
			if (dp[i][j]) {
				dp[i + 1][j + A[i].first] = 1;
				dp[i + 1][j + A[i].second] = 1;
			}
		}
	}

	a = N / 2;
	b = N - a;

	while (1) {
		if (dp[ss][a] || dp[ss][b]) {
			cout << a * (a - 1) / 2 + b * (b - 1) / 2 << endl;
			return 0;
		}
		a--;b++;
	}
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,m;
    cin>>n;
    vector<string> s(n);
    REP(i,n)cin>>s.at(i);
    cin>>m;
    vector<string> t(m);
    REP(i,m)cin>>t.at(i);
    int ans=0;
    REP(i,n){
        int cnt=1;
        for(int j=i+1;j<n;j++)if(s.at(i)==s.at(j))cnt++;
        REP(j,m)if(s.at(i)==t.at(j))cnt--;
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;

int main()
{
  int N, M, P;
  while(1){
    cin >> N >> M >> P;
    if(N == 0 && M == 0 && P == 0){
      break;
    }else{
      int x, y, sum;
      sum = 0, y = 0;
      REP(i, N){
        cin >> x;
        sum += x;
        if(i + 1 == M)
          y = x;
      }
      if(y)
        cout << sum * (100 - P) / y << endl;
      else
        cout << "0" << endl;
    }
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
using P = pair<ll, ll>;
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
struct inputoutputfaster{
    inputoutputfaster(){
        ios::sync_with_stdio(false);\
        cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
}inputoutputfaster_;
template <class T> V<T> press(V<T> &x){ 
    V<T> res = x;
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    REP(i, SZ(x)){
        x[i] = lower_bound(all(res), x[i]) - res.begin();
    }
    return res;
}
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T divup(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    INT(k);
    print(k / 2 * (k / 2 + k % 2));
}

Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    ll a, b, c; cin >> a >> b >> c;

    ll ans = 1e18;
    ll ab = a*b;
    ll bc = b*c;
    ll ca = c*a;

    if(a%2 == 0 || b%2 == 0 || c%2 == 0){
        ans = 0;
    }
    else{
        ans = min(ab, min(bc, ca));
    }

    cout << ans;

    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int w,r;
  rep(i,0,n){
    if(s[i] == 'W') w++;
    else r++;
  }
  int ans = 0;
  rep(i,0,r) if(s[i] == 'W') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+1;
const int MX=1e15+123456789;
int n;
int a[N][4];
int dp[N][4];
int solve(int i,int j){
    if(i==1)return a[i][j];
    if(dp[i][j]+1){
        return dp[i][j];
    }
    int path,mx=0;
    for(int u=1;u<=3;u++){
        if(u==j)continue;
        path=solve(i-1,u)+a[i][j];
        mx=max(mx,path);
    }
    return dp[i][j]=mx;
}
main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=3;j++){
            scanf("%lld",&a[i][j]);
        }
    }memset(dp,-1,sizeof(dp));
    int ans=0;
    int mx=0;
    for(int i=1;i<=3;i++){
        mx=max(solve(n,i),mx);
    }
    cout<<mx;
}


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	ll k,a,b;
	cin >> k >> a >> b;
	ll ans = 1;
	ll rem = k;
	if (a+2 >= b) {cout << 1+k << endl;return 0;}
	else {
		if (a-1 <= k) {ans = a;rem-=(a-1);}
		else {cout << 1+k << endl;return 0;}
		if (rem%2==0) {ans += (b-a)*rem/2;}
		else {ans += (b-a)*(rem-1)/2 + 1;}
	}
	cout << ans << endl;
} 

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    string s,t;
    cin >> s >>t;
    t=t.substr(0,s.size());
    if(s==t){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
const int VMAX = 106, EMAX = 10000;
const long long int INF = 100000000000;

long long int dist[VMAX][VMAX];

void init(int V) {
  REP(j, V) REP(i, V) {
    dist[i][j] = (i == j ? 0 : INF);
  }
}

void wf(int V) {
  REP(k, V) REP(i, V) REP(j, V) {
    if (dist[i][k] != INF and dist[k][j] != INF) {
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
  }
}

bool has_negcycle(int V) {
  REP(i, V) {
    if (dist[i][i] < 0) return true;
  }
  return false;
}

int main() {
  int V, E;
  cin >> V >> E;
  
  init(V);
  REP(i, E) {
    int s, t, d;
    cin >> s >> t >> d;
    dist[s][t] = d;
  }
  wf(V);
  
  if (has_negcycle(V)) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    REP(i, V) {
      REP(j, V) {
        if (dist[i][j] == INF) {
          cout << "INF";
        } else if (dist[i][j] == 0) {
          cout << 0;
        } else {
          cout << dist[i][j];
        }
        if (j < V - 1) cout << " ";
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 1248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        long[] A = new long[N];
        String[] input = Console.ReadLine().Split();
        for(int i = 0; i < N; i++)
        {
            A[i] = long.Parse(input[i]);
        }
        long ans = 0;
        long[] mark = new long[N];
        for(int i = 0; i < A.Length; i++)
        {
            if(0 <= i - A[i]) { ans += mark[i - A[i]]; }
            if (i + A[i] < N) { mark[i + A[i]]++; }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 45192
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode('c${rg!EWj>5WFMt4=bvtLJ2Wdd#F&;Uw9X8eF!=B1}q%gwH=^;|JF%>RK=GhGvnFa**t($AvRIzuma7^uHic@#C$#;J%IR*duwj^R^t(M@iOG_96jF(TRWw3%l$4Ci@y~QF^LA=$_U*^+)Cv`@yYhKMkcI@7$P^3<=P6anN}rpt@BI%#)68ta9kXyc3`Hd-8bFw$a=F3n01lyD6B-k2vKjwBO$R$U7<Hnd0WHey%(?w%}I$v^oSo5FucY<?g*1!Fj<X9K&Q13&I!#!fd1AtUHe>bdQCb*W~xjCGrN&Tt0ZtKTf$|qhVy`3Lul%j(ix<OCvrS$8>SFM9->qhgsPqO5q22Gp8E`(Cvi0pI+q_&MC-5G?z0a<8LbR<6_Cs6Y&c><%M1h*u<YQ|p0)_jgBeRA`|8sfEa3I+#;J<vcUZ2VB=f_KNR9%Y;CTsiC_CI^Y-lCo+8D(}vaYKPz6S3qOM#uUl+9(3A6wAY>^AUJsz|pCp6;;Iw2O*jQB(>%{lQ2Ob*f_CZYAr>{g!=QLZbP8gqDuJ_Ibnn9jsf_^zo0D|IB07)=eu<Bh7jp>VN}lcgN;@2fK`rG9vgt%e@>0')))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 14000
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M;
    cin >> N >> M;
    int ans = 1;
    for (int i = 1; i * i <= M; ++i)
    {
        if (M % i == 0)
        {
            if (M / i >= N) chmax(ans, i);
            if (M / (M / i) >= N) chmax(ans, M / i);
        }
    }
    cout << ans << endl;
}


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

int main(){
  int a,b,hour,seconds,minutes;
  cin>>a;
  hour=a/3600;
  b=a%3600;
  minutes=b/60;
  seconds=b%60;
    cout<<hour<<":"<<minutes<<":"<<seconds<<endl;

}



Measured memory_bytes: 3104
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a>b)System.out.printf("a > b\n");
		else if(a<b)System.out.printf("a < b\n");
		else if(a==b)System.out.printf("a == b\n");
	}
}


Measured memory_bytes: 26396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			char before = ' ';
			int result = 0;
			for(char c : s.toCharArray()) {
				if (before == 'A') {
					result++;
					before = ' ';
				} else if (c == before) {
					before = 'A';
				} else {
					before = c;
					result++;
				}
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 26508
#!/usr/bin/env python3
import sys

def solve(N: int, S: str):
    def nx(S):
        res = [[N+1] * 10 for _ in range(N+1)]
        for i in range(N-1, -1, -1):
            for j in range(10):
                res[i][j] = res[i+1][j]
            res[i][int(S[i])] = i
        return res
    dp = [[0] * 3 for _ in range(N+1)]
    dp[1] = [1, 0, 0]
    res = nx(S)
    for i in range(0, N+1):
        for j in range(10):
            if res[i][j] >= N: continue
            if res[0][j] == res[i][j]:
                dp[res[i][j]+1][0] = 1
            dp[res[i][j]+1][1] += dp[i][0]
            dp[res[i][j]+1][2] += dp[i][1]
    res = 0
    for i in range(N+1):
        res += dp[i][2]
    print(res)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: int
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12020
def main():
    #import sys
    #input = sys.stdin.readline
    S = input()
    S_list = list(S)
    dig = len(S) - 1
    insert_plus = format(0,"0"+str(dig)+"b")
    insert_plus_max = "1"*len(insert_plus)
    s = 0
    if len(S) == 1:
        print(int(S))
        exit()

    for i in range(int(insert_plus_max,2)+1):
        before = 0
        num_list = []
        now = format(i,"0"+str(dig)+"b")
        for j in range(len(now)):
            if now[j] == "1":
                num_list.append("".join(S_list[before:int(j)+1]))
                before = j+1
            if j == len(now)-1:
                num_list.append("".join(S_list[before:]))
        for num in num_list:
            s += int(num)
    print(s)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] a){

		String str;
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		try {
			while(null != ( str = bf.readLine() )){
				int n = Integer.parseInt(str);

				int[] arr = createArray(n);

				for(int i = 2; i <= n; i++){
					for(int j = 2; n >= i * j; j++){
						arr[i*j] = -1;
					}
				}

				System.out.println(countArray(arr));
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				bf.close();
			} catch (IOException e) {
			}
		}
	}

	private static int[] createArray(int number){
		int[] arr = new int[number + 1];
		arr[0] = arr[1] = -1;
		for(int i = 2; i <= number; i++){
			arr[i] = i;
		}
		return arr;
	}

	private static int countArray(int[] arr){
		int count = 0;
		for(int n : arr)if(n != -1)count++;
		return count;
	}

}

Measured memory_bytes: 13000
#include <iostream>
using namespace std;
//B - Time Limit Exceeded
int main(void){
    int N,T;
    std::cin >> N >> T;
    int minCost=1001;
    for (int i = 0; i < N; i++) {
        int c,t;
        std::cin >> c >> t;
        if(t<=T){
            if(c<minCost){
                minCost=c;
            }
        }
        
    }
    if(minCost==1001){
        std::cout << "TLE" << std::endl;
    }else{
        std::cout << minCost << std::endl;
    }
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    while(true) {
      int x = scan.nextInt();
      int y = scan.nextInt();
      if ((x == 0) && (y == 0)) {
        break;
      }
      System.out.println(Math.min(x, y) + " " + Math.max(x, y));
    }

  }
}


Measured memory_bytes: 35280
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans;
    char a,b;
    cin >>a;
    if (a=='A')b='T';
    else if (a=='C')b='G';
    else if (a=='G')b='C';
    else if (a=='T')b='A';

    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<b<<endl;

    return 0;

}

Measured memory_bytes: 256