akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

string comp(int x, int y)
{
	stringstream ss;

	ss << x << " " << y;

	return ss.str();
}

string rec(vector<string>& field, pint pos)
{
	int buf = field[pos.first][pos.second];
	field[pos.first][pos.second] = 0;
	
	switch(buf)
	{
	case '.' :
		return comp(pos.second, pos.first);
		
	case '>' :
		return rec(field, mp(pos.first, pos.second + 1));

	case '<' :
		return rec(field, mp(pos.first, pos.second - 1));

	case '^' :
		return rec(field, mp(pos.first - 1, pos.second));

	case 'v' :
		return rec(field, mp(pos.first + 1, pos.second));

	default :
		return "LOOP";
	}
}

int main()
{
	int w, h;
	while(cin >> h >> w && w)
	{
		vector<string> field(h);

		rep(i, h)
			cin >> field[i];

		cout << rec(field, mp(0, 0)) << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	char s[3];
	scanf("%s",s);
	int i=0,count=0;
	for(i;i<=2;i++)
		{
		if(s[i]=='1')
		{count++;}
		}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int dp[401][401];
int A[401];
int sm(int l,int r)
{
	int q=0;
	for(int i=l;i<=r;i++)
		q=q+A[i];
	return q;
}
signed main() {
	int n,k;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	for(int l=n-1;l>=0;l--)
	{
		for(int r=l;r<n;r++)
		{
			if(l==r)dp[l][r]=0;
			else{
				dp[l][r]=LLONG_MAX;
				for(int i=l;i<=r;i++)
				{
					dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+sm(l,r));
				}
			}
		}
	}
	cout<<dp[0][n-1];
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
int main(void){
  int x,temp;
  int sum;
  if( scanf("%d", &x) == 1);
  temp=x/500;
  sum=temp*1000;
  x %= 500;
  temp=x/5;
  sum+=temp*5;
  printf("%d",sum);
  
  return 0;
 
 
}

Measured memory_bytes: 128
import itertools
N = int(input())
a = [i for i in range(1,N+1)]
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]

kaijo = 1
for i in range(N):
  kaijo *= (N - i)
A = list(itertools.permutations(a, N))
ansP = 0
for i in range(kaijo):
  if(list(A[i]) == P):
    ansP = i
ansQ = 0
for i in range(kaijo):
  if(list(A[i]) == Q):
    ansQ = i
print(abs(ansQ-ansP))


Measured memory_bytes: 13680
in_string = raw_input()
in_arr = in_string.split()
N = int(in_arr[0])
A = int(in_arr[1])
B = int(in_arr[2])

if ((B-A) % 2) == 0:
    print(int((B-A)/2))
else:
    if (N-B) > A-1:
        print(int(A+(B-A-1)/2))
    else:
        print(int(N-B+1+((N-(A+N-B+1))/2)))


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<s.size();j++){
      string tmp=s;
      tmp.erase(i,j);
      if(tmp=="keyence"){
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int s=sc.nextInt();
        int h=s/3600;
        int m=s%3600/60;
        s=s%60;
        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26160
#include <iostream>
#include<vector>
using namespace std;
int main() {
    int n;cin>>n;
    vector<int>a(n+1);for(int i=1;i<=n;i++)cin>>a[i];
    long long dp[100];
    for(int i=1;i<=n;i++)dp[i]=0LL;
    dp[1]=1000;
    for(int i=2;i<=n;i++){
        for(int j=1;j<i;j++){
            dp[i]=max(dp[i],dp[j]%a[j]+dp[j]/a[j]*a[i]);
            dp[i]=max(dp[i],dp[j]);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 3632
K, N = map(int, input().split())
A = list(map(int, input().split()))
D = K
for i in range(N):
    j = (i-1) % N
    if A[j] < A[i]:
        D = min(D, A[j] - A[i] + K)
    else:
        D = min(D, A[j] - A[i])
print(D)


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, a, b, c;
int l[10];
int sum[4], cnt[4];
int ans;
void dfs(int i) {
    if (i == n) {
        if (!cnt[1] || !cnt[2] || !cnt[3]) return;
        ans = min(ans, (cnt[1] + cnt[2] + cnt[3] - 3) * 10 + abs(a - sum[1]) + abs(b - sum[2]) + abs(c - sum[3]));
        return;
    }
    for (int j = 0; j < 4; ++j) {
        sum[j] += l[i];
        ++cnt[j];
        dfs(i + 1);
        --cnt[j];
        sum[j] -= l[i];
    }
}
int main() {
    ans = 1e9;
    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
bool isp[1<<20];
main()
{
    for(int i=2;i<1<<20;i++)isp[i]=1;
    for(int i=2;i<1<<20;i++)
    {
        if(!isp[i])continue;
        for(int j=i+i;j<1<<20;j+=i)isp[j]=0;
    }
    int n;
    while(cin>>n,n)
    {
        int cnt=0;
        for(int i=2;i*2<=n;i++)
        {
            cnt+=isp[i]&&isp[n-i];
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 4000
#include<iostream>
#include<tuple>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;

#define INF ((int)(1e9))
#define MAX 110000

int n, k, a, q, query, x;
string key, y;
multimap<string,int> se;

int main(){
	cin>>q;
	
	for(int i = 0; i < q; i++){
		cin>>query>>key;
		if(!query){
			cin>>x;
			se.insert(make_pair(key,x));
		} else if(query == 1){
			decltype(se)::iterator it = se.lower_bound(key), it2 = se.upper_bound(key);
			for(int i = 0; it != it2; i++,it++) if((*it).second)cout<<(*it).second<<endl;
		} else if(query == 2){
			se.erase(key);
		} else if(query == 3){
			cin>>y;
			decltype(se)::iterator it = se.lower_bound(key), it2 = se.upper_bound(y);
			for(int i = 0; it != it2; i++,it++) if((*it).second)cout<<(*it).first<<" "<<(*it).second<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 24840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		int d = ni();
		long g = nl() / 100;
		int[][] a = nia(d, 2);
		long[] dp = new long[1001];
		for (int i = 0; i < d; i++) {
			long[] dp2 = dp.clone();
			for (int j = 1; j <= a[i][0]; j++) {
				int inc = (j < a[i][0] ? 0 : a[i][1] / 100) + (i + 1) * j;
				for (int k = 1000; k >= j; k--) {
					dp2[k] = Math.max(dp2[k], dp[k - j] + inc);
				}
			}
			dp = dp2;
//			Helper.tr(dp);
		}
//		Helper.tr(dp);
		for (int i = 1; i <= 1000; i++)
			if (dp[i] >= g) {
				out.println(i);
				break;
			}
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	int[][] nia(int n, int m) throws IOException {
		int[][] res = new int[n][];
		for (int i = 0; i < n; i++) {
			res[i] = nia(m);
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vector<int> r(a), g(b), l(c);
	rep(i,0,a)cin >> r[i];
	rep(i,0,b)cin >> g[i];
	rep(i,0,c)cin >> l[i];
	sort(r.rbegin(), r.rend());
	sort(g.rbegin(), g.rend());
	sort(l.rbegin(), l.rend());
	int rp = x-1;
	int gp = y-1;
	int cp = 0;
	while(cp < l.size()){
		int dr = (rp >= 0?l[cp] - r[rp]:-1);
		int dg = (gp >= 0?l[cp] - g[gp]:-1);
		if(max(dr,dg) > 0){
			++cp;	
			if(dr > dg)--rp;
			else --gp;
		}
		else{
			break;	
		}
	}
	ll ans = 0;
	rep(i,0,rp+1)ans+=r[i];
	rep(i,0,gp+1)ans+=g[i];
	rep(i,0,cp)ans+=l[i];
	cout << ans << '\n';
}


Measured memory_bytes: 1408
N, L = map(int, input().split())
a = list(map(int, input().split()))

for i in range(N-1):
    if a[i]+a[i+1]>=L:
        print('Possible')
        
        ans = []
        
        for j in range(1, i+1):
            ans.append(j)
        
        for j in range(N-1, i+1, -1):
            ans.append(j)
        
        ans.append(i+1)
        
        for ans_i in ans:
            print(ans_i)
        
        break
else:
    print('Impossible')

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

int main() {
	string s;
	cin >> s;
	char a[105];
	for (int i = 0; i <= s.size(); i++) {
		a[i] = 'z';
	}
	
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			a[i] = '0';
		}
		if (s[i] == '1') {
			a[i] = '1';
		}
		if ((i!=0&&s[i] == 'B')) {
			for (int j = i; j >= 0; j--) {
				if (a[j] != 'z') {
					a[j] = 'z';
					break;
				}
			}
			
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (a[i] != 'z') {
			cout << a[i];
		}
	}
	cout << endl;
	return 0;
}

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

int main() {
//	freopen("data.in", "r", stdin);
//	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	long long n, c, k;
	cin >> n >> c >> k;
	long long a[n];
	for (long long i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n);
	int cnt = 0;
	for (long long i = 0; i < n; ++i) {
		long long it = i + 1;
		long long items = 1;
		while (abs(a[i] - a[it]) <= k && items++ < c && it < n) {
			it++;
		}
		i = it-1;
		cnt++;
	}

	cout << cnt  << endl;

}

/*
 * 2
 * 6
 * 6
 * 8
 * 10
 */


Measured memory_bytes: 1024
T = int(input())
for i in range(T):
    N,A,B,C,D = map(int,input().split())
    memo = {0:0,1:D}
    def f(n):
        if n in memo:
            return memo[n]
        else:
            res = D*n
            r2 = n%2
            r3 = n%3
            r5 = n%5
            res = min(res,f(n//2)+A+r2*D,f(n//3)+B+r3*D,f(n//5)+C+r5*D)
            res = min(res,f((n+1)//2)+A+(2-r2)*D,f((n+2)//3)+B+(3-r3)*D,f((n+4)//5)+C+(5-r5)*D)
            memo[n] = res
            return res
    print(f(N))

Measured memory_bytes: 11136
import java.util.*;
import java.util.regex.*;

public class Main {
    private static final String[] TERM = {"JOI", "IOI"};

    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            while(scn.hasNext()) {
                String str = scn.next();
                for(int i = 0; i < TERM.length; i++) {
                    Pattern p = Pattern.compile(TERM[i]);
                    Matcher m = p.matcher(str);
                    int sum = 0;
                    for(int idx = 0; m.find(idx); idx = -~m.start()) {
                        sum++;
                    }
                    System.out.println(sum);
                }
            }
        }
    }
}

Measured memory_bytes: 27744
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Classes = Tuple!(long, "number", long, "person");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto a = aryread();
    auto school = new Classes[](n);
    foreach(i, e; a)
    {
        school[i] = Classes(e, i + 1);
    }
    school.sort();
    foreach(i, e; school)
    {
        e.person.writeln();
    }
}


Measured memory_bytes: 7612
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    var r = 0L
    var g = 0L
    var b = 0L
    for (x in 0 until n) {
        when (s[x]) {
            'R' -> r++
            'G' -> g++
            'B' -> b++
        }
    }
    var res = r*g*b
    for (i in 0 until n-2) {
        for (j in i+1 until n-1) {
            val k = 2*j-i
            if (k >= n) break
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) res--
        }
    }
    println(res)
}

Measured memory_bytes: 35936
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(void){
    int x; cin >> x;
    for(int i=-200;i<200;i++){
	for(int j=-200;j<200;j++){
	    long long  t = pow(i,5)-pow(j,5);
	    if(t==x){
		cout << i << " " << j << endl;
		return 0;
	    }
	}
    }
    return 0;
}


Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	cout << n-k+1 << endl;
}


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

map<int,int>mp;

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=1;i<=n;i++)
    {
        int h;
        cin>>h;
       arr[i]=i-h;
       mp[i+h]++;
    }
    long long counter=0;
    for(int i=1;i<=n;i++)
    {
        counter+=mp[arr[i]];
    }
    cout<<counter<<endl;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
VL dx={1,0,-1,0};
VL dy={0,1,0,-1};
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    ll ct=0;
    bool fg=false;
    fr(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        if(x==y)
        {
            ct++;
        }
        else
        {
            ct=0;
        }
        if(ct>=3)
        {
            fg|=true;
        }
    }
    if(fg)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return;
}
int main()
{
    IOS;
    ll t=1,pp;
    //cin>>t;
    pp=t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<": ";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

int main() {
    ll N;
    cin >> N;
    ll ans = 1;
    ll mod = 1e9 + 7;
    for (ll i = 1; i <= N; i++) {
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int H = in.nextInt();
            int W = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();

            boolean[] canUseH = new boolean[H];
            Arrays.fill(canUseH, true);
            for (int i = 0; i < A; i++) {
                canUseH[H - 1 - i] = false;
            }
            boolean[] canUseW = new boolean[W];
            Arrays.fill(canUseW, true);
            for (int i = 0; i < B; i++) {
                canUseW[i] = false;
            }

            long mod = (long) (1e9 + 7);

            long[] w2 = new long[W];
            for (int w = B; w < W; w++) {
                int r = H - A - 1 - (w - B);
                int c = B + (w - B);
                w2[w] = modComb(r + c, r, mod);
            }
            long res = 0;
            for (int w = B; w < W; w++) {
                int r = A + (w - B);
                int c = W - w - 1;
                res += (w2[w] * modComb(r + c, r, mod)) % mod;
                res %= mod;
            }
            System.out.println(res);

        }
    }

    public static final long modComb(long n, long k, long p) {
        if (n < 0 || k < 0 || n < k) {
            return 0;
        }
        long[] e1 = new long[1];
        long[] e2 = new long[1];
        long[] e3 = new long[1];
        long a1 = modFact(n, p, e1);
        long a2 = modFact(k, p, e2);
        long a3 = modFact(n - k, p, e3);
        if (e1[0] > e2[0] + e3[0]) {
            return 0;
        }
        return (a1 * modInverseByFermatsLittleTheorem((a2 * a3) % p, p)) % p;
    }

    private static final int MAX_P = (int) 1e6;
    private static final long[] fact = new long[MAX_P];
    private static final boolean[] first = new boolean[] { true, };

    private static final long modFact(long n, long p, long[] e) {
        if (first[0]) {
            first[0] = false;
            fact[0] = 1;
            for (int i = 1; i < fact.length; i++) {
                fact[i] = (int) ((i * fact[i - 1]) % p);
            }
        }

        e[0] = 0;
        if (n == 0) {
            return 1;
        }

        long res = modFact(n / p, p, e);
        e[0] += n / p;

        if ((n / p) % 2 != 0) {
            return res * (p - fact[(int) (n % p)]) % p;
        }

        return res * fact[(int) (n % p)] % p;
    }

    private static final long modPow(long x, long n, long modulo) {
        long res = 1L;
        while (n > 0) {
            if ((n & 1L) != 0) {
                res = res * x % modulo;
            }
            x = x * x % modulo;
            n >>= 1;
        }
        return res;
    }

    private static long modInverseByFermatsLittleTheorem(long x, long modulo) {
        return modPow(x, modulo - 2, modulo);
    }

}


Measured memory_bytes: 56156
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long 
#define mod 1000000007 
using namespace std ;

int32_t main(){

	 ios::sync_with_stdio(false) ; cin.tie(NULL) ; 
	 string s,t;
	 cin>>s>>t;
	 int c=0;
	 for(int i=0;i<s.size();i++)
	 {
	 	if(s[i]!=t[i])
	 	{
	 	c++;
	 	break;
	 	}
	 	
	 }
	 if(c==0)
	 cout<<"Yes";
	 else
	 cout<<"No";



}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main(){
	cin>>n>>m;
	int w=0,b=0,r=0;
	int wl[n],bl[n],rl[n];
	char flag;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>flag;
			if(flag=='W'){
				b++;
				r++;
			}else if(flag=='B'){
				w++;
				r++;
			}else if(flag=='R'){
				b++;
				w++;
			}
		}
		wl[i]=w;
		bl[i]=b;
		rl[i]=r;
	}
	//for(int i=0;i<n;i++){
	//	cout<<"w"<<" "<<wl[i]<<endl;
	//	cout<<"b"<<" "<<bl[i]<<endl;
	//	cout<<"r"<<" "<<rl[i]<<endl;
	//}
	int k=0;
	int ans=2147483647;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			k+=wl[i];
			//cout<<k<<endl;
			k+=bl[j]-bl[i];
			//cout<<k<<endl;
			k+=rl[n-1]-rl[j];
			//cout<<k<<" "<<i<<" "<<j<<endl;
			ans=min(ans,k);
			k=0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3084
#include <stdio.h>
int main(void){
    char c;
    scanf("%c", &c);

    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        printf("%s\n", "vowel");
    }
    else {
        printf("%s\n", "consonant");
    }

    return 0;
}


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

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

using namespace std;
using lint=long long;

int main(){
	int n; cin>>n;
	lint a[50];
	rep(i,n) cin>>a[i];

	lint ans=0;
	while(1){
		bool end=true;
		rep(i,n) if(a[i]>=n) {
			ans+=a[i]/n;
			rep(j,n) if(j!=i) a[j]+=a[i]/n;
			a[i]%=n;
			end=false;
		}
		if(end) break;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int i,l,j,n,k,v[100010],q;
int main()
{
    cin>>n>>k>>q;
    for(i=1;i<=q;i++)
        cin>>j , v[j]++;
    for(i=1;i<=n;i++)
    {
        if(q-v[i]<k)
            cout<<"Yes"<<'\n';
        else cout<<"No"<<'\n';
    }
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
int res[3];
int main() {
    int a, b;
    while (scanf("%d%d",&a,&b)) {
        if (!a&&!b) break;
        int r=b-a;
        res[2]=r/1000;
        r%=1000;
        res[1]=r/500;
        r%=500;
        res[0]=r/100;
        for (int i=0; i<3; i++) printf("%d%c",res[i],i==2?'\n':' ');
    }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;

int l[2100][2100], r[2100][2100], u[2100][2100], d[2100][2100];

int main() {
    int h, w; cin >> h >> w;
    V<string> board(h);
    for(int i = 0; i < h; i++) cin >> board[i];

    for(int i = 0; i < h; i++){
        int c = 0;
        for(int j = 0; j < w; j++){
            if(board[i][j] == '#') c = 0;
            else c++;
            l[i][j] = c;
        }
    }
    for(int i = 0; i < h; i++){
        int c = 0;
        for(int j = w - 1; j >= 0; j--){
            if(board[i][j] == '#') c = 0;
            else c++;
            r[i][j] = c;
        }
    }
    for(int i = 0; i < w; i++){
        int c = 0;
        for(int j = 0; j < h; j++){
            if(board[j][i] == '#') c = 0;
            else c++;
            u[j][i] = c;
        }
    }
    for(int i = 0; i < w; i++){
        int c = 0;
        for(int j = h - 1; j >= 0; j--){
            if(board[j][i] == '#') c = 0;
            else c++;
            d[j][i] = c;
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            ans = max(ans, (l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3));
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 72448
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,k;
	cin >> n >> k;
	cout << (bool)(n % k) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int gcd(int m, int n) {
  //  cout << "Gcd: " << m << " " << n << "=";                                           
  if(m < n) swap(m,n);
  while(n != 0) {
    int r = m % n;
    m = n;
    n = r;
  }
  //  cout << m << endl;                                                                 
  return m;
}

int main() {
  int N; cin>>N;
  vector<int> A(N);
  REP(i,N) cin>>A[i];
  vector<int> rec(N,0);
  for(int i = 0; i < N-1; i++) {
    rec[i+1] = gcd(rec[i], A[i]);
  }
  int ans = 0;
  int rev = 0;
  for(int i = N-1; i >= 0; i--) {
    int work = gcd(rec[i], rev);
    ans = max(ans, work);
    //    cout << i << " " << rec[i] << " " << rev << " " << ans << endl;                
    rev = gcd(rev, A[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || b + c == a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

typedef long long ll;
const int N = 540;

int n;
int pn = 0, c[7930], p[1054];
ll a[N][N];

void sieve(int n) {
	int i, j, v;
	memset(c, -1, sizeof c);
	for (i = 2; i <= n; ++i) {
		if (!~c[i]) p[pn] = i, c[i] = pn++;
		for (j = 0; (v = i * p[j]) <= n && j <= c[i]; ++j) c[v] = j;
	}
}

int main() {
	int i, j, *q;
	scanf("%d", &n), sieve(7929);
	q = p + (n - 1);
	for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) if ((i ^ j) & 1)
		a[i][j] = p[(i + j - 1) / 2] * q[(j - i + n - 1) / 2];
	for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) if (!((i ^ j) & 1)) {
		ll &s = a[i][j]; s = 1;
		if (i          || j         ) s *= p[(i + j - 2) / 2];
		if (i != n - 1 || j != n - 1) s *= p[(i + j) / 2];
		if (i          || j != n - 1) s *= q[(j - i + n) / 2];
		if (i != n - 1 || j         ) s *= q[(j - i + n - 2) / 2];
		++s;
	}
	if (n == 2) a[1][1] = a[1][1] * 2 - 1;
	for (i = 0; i < n; ++i) for (j = 0; j < n; ++j)
		printf("%lld%c", a[i][j], j == n - 1 ? 10 : 32);
	return 0;
}

Measured memory_bytes: 5248
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<long long> a(n); REP(i, n) cin >> a[i];
  vector<long long> sum(n+1, 0); FOR(i, 1, n+1) sum[i] = sum[i-1] + a[i-1];
  vector<vector<long long> > dp(n, vector<long long>(n, LINF));
  REP(i, n) dp[i][i] = 0;
  FOR(width, 1, n) {
    for (int i = 0; i + width < n; ++i) {
      int j = i + width;
      FOR(k, i, j) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + sum[j+1] - sum[i]);
    }
  }
  cout << dp[0][n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
int main(){
  int c,b,b1=0,b2=0,i,j,k;
  scanf("%d",&c);
  for(i=0;i<c;i++){
    b1=0;
    b2=0;
    k=0;
    for(j=0;j<10;j++){
      scanf("%d",&b);
      if(b1<b)	   b1=b;
      else if(b2<b)b2=b;
      else   	   k=1;
    }
    if(k==0)printf("YES\n");
    else    printf("NO\n");
  }
  return 0;
}

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

using ll = long long;

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    int d = A[0] + K - A[N - 1];
    rep(i, N - 1) {
        d = max(d, A[i + 1] - A[i]);
    }
    cout << K - d << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  int k; cin >> k;
  string s; cin >> s;
  if(s.size() <= k) cout << s << endl;
  else{
    rep(i,k){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;


#define FORA(i, a, n) for (int i = (a); i < (n); ++i)


typedef int64_t i64;


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


i64 f(i64 b, i64 n) {
  if (n < b) return n;
  return n % b + f(b, n / b);
}

void solve(istream& in, ostream& out) {
  auto n = next<i64>(in);
  auto s = next<i64>(in);
  FORA(b, 2, 1000001) {
    if (f(b, n) == s) {
      out << b << "\n";
      return;
    }
  }
  if (n < s) {
    out << -1 << "\n";
    return;
  }

  auto x = n - s;
  i64 res = (i64)1e18;
    if (s == n) {
    res = s + 1;
  }
  for (i64 d = 1; d * d <= x; ++d) {
    if (x % d == 0) {

      auto b = x / d + 1;
      if (f(b, n) == s) {
        res = min(res, b);
      }

      b = d + 1;
      if (f(b, n) == s) {
        res = min(res, b);
      }
    }
  }
  if (res >= 1e18) {
    out << -1 << "\n";
  } else {
    out << res << "\n";
  }
  // n = pb + q
  // p + q = s
  // n - s = p(b - 1)
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



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

const int MAX_N = 10000;
const int INF = (1 << 21);

int N;
vector<pair<int, int> > A[MAX_N];

void dj() {
  int d[MAX_N], c[MAX_N];

  // (first: distance*-1, second: adjacent)
  priority_queue<pair<int, int> > PQ; 

  for (int i = 0; i < N; i++) {
    d[i] = INF;
    c[i] = -1;
  }

  d[0] = c[0] = 0;
  PQ.push(make_pair(0, 0));

  while (!PQ.empty()) {
    pair<int, int> t = PQ.top(); PQ.pop();
    int cur_n = t.second;
    c[cur_n] = 1;

    if (d[cur_n] < t.first * -1) continue;

    for (int i = 0; i < A[cur_n].size(); i++) {
      int adj_n = A[cur_n][i].first;

      if (c[adj_n] == 1) continue;

      if (d[cur_n] + A[cur_n][i].second < d[adj_n]) {
        d[adj_n] = d[cur_n] + A[cur_n][i].second;
        PQ.push(make_pair(d[adj_n] * -1, adj_n));
        c[adj_n] = 0;
      }
    }
  }

  for (int i = 0; i < N; i++)
    cout << i << ' ' << d[i] << endl;
}

int main() {
  cin >> N;

  for (int i = 0; i < N; i++) {
    int cur_n, k; cin >> cur_n >> k;

    for (int j = 0; j < k; j++) {
      int u, v; cin >> u >> v;
      A[cur_n].push_back(make_pair(u, v));
    }
  }

  dj();

  return 0;
}

Measured memory_bytes: 6304
#include<bits/stdc++.h>
#define   ll      long long int
#define   sz      200010
using namespace std;



int main()
{


    double w,h,x,y,a,b,p,q;
    ll o;


    cin>>w>>h>>x>>y;

    a=w*h;
    a/=2.0;
    w/=2.0;
    h/=2.0;
    if(x==w && y==h)o=1;
    else
        o=0;


       printf("%0.10lf %ld\n",a,o);




    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>
#include<queue>

using lli = long long int;
using namespace std;
int inf = 1000000007;

int N;
string L;

int main() {
	cin >> N >> L;
	//左から右に括弧の完結カウント
	int st = 0;
	int make = 0;
	for (int i = 0; i < N; i++)
		if (L[i] == '(')st++;
		else {
			if (st == 0)make++;
			else st--;
		}
	for (int i = 0; i < make; i++)L = "(" + L;
	N += make;
	st = 0;
	make = 0;
	for (int i = N - 1; i >= 0; i--)
		if (L[i] == ')')st++;
		else {
			if (st == 0)make++;
			else st--;
		}
	for (int i = 0; i < make; i++)L = L + ")";
	cout << L << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if((x==0)&&(y==0))
            break;
        else if(x<=y)
            printf("%d %d\n",x,y);
        else
            printf("%d %d\n",y,x);
    }
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var kx = Console.ReadLine().Split();
        var k = int.Parse(kx[0]);
        var x = int.Parse(kx[1]);

        var min = Math.Max(-1000000, x - (k - 1));
        var max = Math.Min(1000000, x + (k - 1));

        for (int i = min; i <= max; i++)
        {
            Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
namespace SOLVE {
	VI w;
	VI dp;

	void main() {
		int n;
		cin >> n;
		w.resize(n + 5);
		dp.resize(n + 5);
		fill(dp.begin(), dp.end(), 1000000000);

		REP(i, 1, n + 1) {
			cin >> w[i];
		}
		dp[1] = 0;
		REP(i, 1, n + 1) {
			dp[i + 1] = min(dp[i + 1], dp[i] + abs(w[i] - w[i + 1]));
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(w[i] - w[i + 2]));
		}
		cout << dp[n];
	}
}


signed main() {

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}


Measured memory_bytes: 1024
a=int(input())
if a==1:
    print(4)
elif a==2:
    print(4)
elif a==4:
    print(4)
else:
    for i in range(1000000):
        if a%2==0:
            a=a//2
        else:
            a=3*a+1
        if a==4:
            print(i+5)
            break

Measured memory_bytes: 3060
n = int(input())

nums = [list(map(int, input().split())) for _ in range(n)]
current_time = 0
ans = "Yes"

"""
n = [[作業にかかる時間, 作業が終了していないといけない時間]]の2次元配列で複数渡ってくる
すべての作業を、作業が完了していないといけない時間までに終えることができるか？

n = [
[3, 12], [2, 6], [1, 2]
]

作業の締切が優先されるので締め切り順に整頓する
[1,2],[2,6],[3,12]

作業には作業時間掛かるので、現在時刻に作業時間を加算する。すべての加算された時間が最後まで締め切り時間以内(締切時間に終了しても大丈夫)であればok
1個め=現在時刻1, 2個め=現在時刻3 3個め=現在時刻6 締切は2, 6, 12なのでok
"""

nums = sorted(nums, key=lambda x: x[1])


for i in nums:
    current_time = current_time + i[0]
    if current_time > i[1]:
        ans = "No"

print(ans)

Measured memory_bytes: 55264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int w,h,n,x,y,a;
  cin>>w>>h>>n;
  int xl=0,xr=w,yl=0,yr=h;
  for(int i=0;i<n;i++){
    cin>>x>>y>>a;
    if(a==1) xl=max(x,xl);
    else if(a==2) xr=min(x,xr);
    else if(a==3) yl=max(y,yl);
    else  yr=min(y,yr);
  }
  if(xl<xr&&yl<yr) cout<<(xr-xl)*(yr-yl)<<endl;
  else cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    string s; cin >> s;
    int n = (int)s.size();
    for(int r = n - 1; r >= 0; r--){
        if(r % 2 == 1) continue;
        bool ok = true;
        for(int i = 0; i < r / 2; i++){
            if(s[i] != s[i + r / 2]) ok = false;
        }

        if(ok){
            cout << r << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<cstdio>
#include<cstring>
#include<iostream>
#define Mod 1000000007
#define RG register
#define IL inline
using namespace std;
const int N = 1000009;
typedef long long LL;
int n, k;
LL g[N], ans;
LL cnt;
int d[N];
bool f[N];
IL void disolve(int x)
{
	for(int i = 2; i * i <= x; i++)
	{
		int sum = 0;
		while(x % i == 0)
			x /= i, sum++;
		d[i] = max(d[i], sum);
	}
	if(x != 1) d[x] = max(d[x], 1);
}
IL LL ksm(LL a, int b)
{
	LL sum = 1;
	while(b)
	{
		if(b&1)
			sum = (sum * a) % Mod;
		b >>= 1;
		a = (a * a) % Mod;
	}
	return sum;
}
IL int read()
{
	char c; int num = 0; bool flag = 0;
	while((c = getchar()) == ' ' || c == '\r' || c == 'n');
	if(c == '-') flag = 1; else num = c - '0';
	while(isdigit(c = getchar()))
		num = num * 10 + c - '0';
	return flag?-num:num;
}
int main()
{
	n = read();
	cnt = 1;
	for(RG int i = 1; i <= n; i++)
	{
		g[i] = read();
		disolve(g[i]);
	}
	for(RG int i = 1; i < N; i++)
		if(d[i])
			cnt = (cnt * ksm(1LL*i, d[i])) % Mod;
	for(RG int i = 1; i <= n; i++)
		ans = (ans + cnt * ksm(g[i], Mod-2)) % Mod;
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 5376
#include<stdio.h>

int main(){
    int m[10];
    int i,j,k;

    for(i = 0; i < 10; i++){
        scanf("%d",&m[i]);
    }

    for(j = 0; j < 9; j++){
        for(k = 0; k < 9-j; k++){
            if(m[k] < m[k+1]){
                int num = m[k+1];
                m[k+1] = m[k];
                m[k] = num;
            }
        }
    }

    for(i = 0; i < 3; i++){
        printf("%d\n",m[i]);
    }

    return 0;
}

Measured memory_bytes: 600
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    
    s = S()

    ex = s.replace("x", "")

    for i in range(len(ex)//2):
        if ex[i] != ex[len(ex)-1-i]:
            print(-1)
            exit(0)

    
    l = -1
    r = len(s)
    ans = 0

    while True:
        l += 1
        r -= 1
        lcnt = 0
        rcnt = 0

        while l < len(s):
            if s[l] == "x":
                lcnt += 1
                l += 1
            else:
                break

        while r > -1:
            if s[r] == "x":
                rcnt += 1
                r -= 1
            else:
                break

        if l > r:
            break
        ans += abs(lcnt-rcnt)

    print(ans)
    
main()


Measured memory_bytes: 10128
n = int(input())
ans = 0

for _ in range(n):
    v = int(input())
    if v == 2:
        ans += 1
    elif v % 2 > 0:
        i = 3
        p = False
        while (i*i) <= v:
            if v % i == 0:
                p = True
                break
            i += 2
        if not p:
            ans += 1
print(ans)



Measured memory_bytes: 5608
#include <iostream>
#include <stdio.h>
using namespace std;


int main(){
    int a, b, c, x, y, z;
    cin >> a >> b >> c;
    x = min(min(a, b), c);
    z = max(max(a, b), c);
    y = a+b+c-x-z;
    printf("%d %d %d\n",x,y,z);
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
 int i,n;
 cin >> n;
 int a[n],b[n];
 for(i=0;i<n;i++)
 cin >> a[i];
 b[0]=0;
 b[1]=abs(a[0]-a[1]);
 for(i=2;i<n;i++)
 b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
 cout << b[n-1];
 return 0;
}

Measured memory_bytes: 1024
/// Radoslaw Mysliwiec 2019
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB emplace_back
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using pll = pair<ll,ll>;

int n;

int suf[500500], suf2[500500];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int cases;
    string s;
    cin >> s;
    ll res = 0;

    for (int i=s.length()-1; i>=0; --i){
        if (s[i] == '>') suf[i] = suf[i+1] + 1;
    }
    int tmp = 0;
    res = suf[0];
    if (s[0] == '<') suf2[0] = 1;
    for (int i=1; i<=s.length(); ++i){
        if (i!=s.length() && s[i] == '<') suf2[i] = suf2[i-1] + 1;
        res += max(suf[i], suf2[i-1]);
    }

    cout << res << endl;


}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if( a == 5) {
    if(b == 5) {
      if(c == 7){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  if( a == 5) {
    if(b == 7) {
      if(c == 5){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  if( a == 7) {
    if(b == 5) {
      if(c == 5){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
import math
import itertools

n=int(input())

d={}
for i in range(n):
    d[i] = tuple(map(int,input().split()))

def calc(a,b):

    x,y = d[a] 
    xx,yy = d[b]

    return math.sqrt((x-xx)**2 + (y-yy)**2)

res=0
for i in itertools.permutations(range(n)):


    for  j in range(n-1):
        res+= calc(i[j],i[j+1])


print(res/math.factorial(n))

Measured memory_bytes: 40684
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

string S;

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

  int zero_cnt = 0;
  int one_cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '0') {
      zero_cnt++;
    } else {
      one_cnt++;
    }
  }

  if (zero_cnt == 0 || one_cnt == 0) {
    cout << 0 << endl;
  } else {
    if (zero_cnt < one_cnt) {
      cout << zero_cnt * 2 << endl;
    } else {
      cout << one_cnt * 2 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 512
N=gets.to_i
ans = 0
1.upto(Math.sqrt(N)) do |i|
  next if N%i != 0
  if i>1 && N % (i-1) == N / (i-1)
    ans += i-1
  end
  j = N/i
  if j > 1 && N % (j-1) == N / (j-1)
    ans += j-1
  end
end
puts ans

Measured memory_bytes: 1788