akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) ((long long 1) << t)
using namespace std;
typedef long long ll;

int main(){
    ll n,a,b,c,d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--; b--; c--; d--;
    bool pos = 1;
    bool oikoshi = 0;
    REP(i,a+1,max(c,d)){
        if(s[i] == s[i-1] && s[i] == '#'){
            pos = 0;
        }
        if(i >= b + 1 && i <= d + 1 && s[i] == s[i-1] && s[i-1] == s[i-2] && s[i] == '.'){
            oikoshi = 1;
        }
    }
    if(c < d){
        if(pos){
            cout << "Yes" << endl;
        }else{
            cout << "No"<<endl;
        }
    }else{
        if(pos && oikoshi){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  string s;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  rep(i,n){
    if (v[i]%2==0){
      if (v[i]%5 != 0 && v[i]%3 != 0 ){
        cout <<  "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<int,P>;
using PP = pair<P ,P>;
constexpr ll MOD = ll(1e9+7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int n, m;
vector<vector<P> > g;
vector<ull> mask;

bool dfs(int now, int pre, int dst, int id){
    if(now == dst){
        return true;
    }
    for(auto e : g[now]){
        int nxt = e.first;
        if(nxt == pre) continue;
        if(dfs(nxt, now, dst, id)){
            mask[id] |= 1ULL<<e.second;
            return true;
        }
    }
    return false;
}

int main(){
    cin >> n;
    g.resize(n);
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(P(b,i));
        g[b].push_back(P(a,i));
    }
    cin >> m;
    mask.resize(m);
    for(int i=0;i<m;i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        dfs(u, -1, v, i);
    }
    ll r = 0;
    for(int S=1;S<(1<<m);S++){
        int k=0, c=0;
        ull t = 0ULL;
        for(int i=0;i<m;i++){
            if((S>>i)&1){
                k++;
                t |= mask[i];
            }
        }
        for(int i=0;i<n-1;i++){
            if((t>>i)&1ULL) c++;
        }
        r += (1LL<<(n-1-c))*((k&1)?1:-1);
    }
    cout << (1LL<<(n-1))-r << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static int LCS(String i, String j) 
	{
		int subI = i.length();
		int subJ = j.length();
		
		int[][] set = new int[subI + 1][subJ + 1];
		
		for(int n = 0; n <= subI; n++)
		{
			set[n][0] = 0;
		}
		for(int m = 0; m <= subJ; m++)
		{
			set[0][m] = 0;
		}
		
		for(int n = 1; n <= subI; n++)
		{
			for(int m = 1; m <= subJ; m++)
			{
				if(j.charAt(m-1) == i.charAt(n-1))
				{
					set[n][m] = 1 + set[n - 1][m - 1];
					//System.out.println("hi");
				}else
				{
					set[n][m] = Math.max(set[n-1][m], set[n][m-1]);
				}
			}
		}
		
		int max = 0;
		for(int n = 0; n <= subI; n++)
		{
			if(set[n][subJ] > max);
			{
				max = set[n][subJ];
			}
			//System.out.println(set[n][subJ] + " set I");
		}
		
		for(int m = 0; m <= subJ; m++)
		{
			if(set[subI][m] > max)
			{
				max = set[subI][m];
			}
			//System.out.println(set[subI][m] + " set J");
		}
		
		return max;
	}
	public static void main(String[] args) 
	{
		Scanner in = new Scanner(System.in);
		int repetitions = in.nextInt();
		for(int i = 0; i < repetitions; i++)
		{
			System.out.println(LCS(in.next(), in.next()));
		}
	}
}







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

#define ll long long

using namespace std;

int main(){
	ll i,j,l,n,x,z;
	
	while(1){
		cin>>n>>x;
		if(n==0 && x==0) break;
		z=0;
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(l=j+1;l<=n;l++){
					if(i+j+l==x) z++;
				}
			}
		}
		
		cout<<z<<endl;
	}
}


Measured memory_bytes: 3076
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a = cino(True)
    check = True
    # print(a[5:10])
    # print(a[11-6:11][::-1])
    i = len(a)-1
    # print(a[10])
    while i>=0:
        # print(i)
        if a[i-5:i+1][::-1]=="resare":
            # "remaerd"}:
            # print(a[i-5:i+1][::-1])
            i-=6
        elif a[i-6:i+1][::-1]=="remaerd":
            # print(a[i-6:i+1][::-1])
            i-=7
        elif a[i-4:i+1][::-1] in {"esare","maerd"}:
            # print(a[i-4:i+1][::-1])
            i-=5
        else:
            check = False
            break
    if check:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include<cstring>
using namespace std;
int main()
{
	bool flag[1000050];
	int n, m,k;
	while (cin >> n >> m >> k) {
		memset(flag, 0, sizeof(flag));
		for (int i = 0; i <= m; i++)
			for (int j = 0; j <= n; j++)
			{
				int tmp = n*i + m*j - 2*i*j;
				flag[tmp] = true;
				//flag[n*m - tmp] = true;
			}
		if (flag[k])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}


Measured memory_bytes: 1280
import numpy as np

N,Q=map(int,input().split())
y=input()
arr=np.zeros(len(y))
for i in range(len(y)-1):
    if y[i:i+2]=='AC':
        arr[i+1]=arr[i]+1
    else:
        arr[i+1]=arr[i]
              
for q in range(Q):
    l,r=map(int,input().split())
    print(int(arr[r-1]-arr[l-1]))

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

long long x[1009], y[1009], rx[1009], ry[1009];

void rp(long long d, long long r)
{
	if (d == 0 && r == -1) cout << "R";
	else if (d == 0 && r == 1) cout << "L";
	else if (d == 1 && r == -1) cout << "U";
	else cout << "D";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		rx[i] = ry[i] = 1;
		if (x[i] < 0) {
			x[i] *= -1; rx[i] = -1;
		}
		if (y[i] < 0) {
			y[i] *= -1; ry[i] = -1;
		}
	}
	long long t = (x[0] + y[0]) % 2;
	for (int i = 0; i < n; i++) {
		if ((x[i] + y[i]) % 2 != t) {
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << 35 + t << '\n';
	long long mr = (1LL << 32LL);
	cout << mr << " ";
	if (t == 1) cout << 1 << " ";
	for (int i = 0; i <= 32; i++)
		cout << (1LL << (i * 1LL)) << " ";
	cout << (1LL << 33LL) - 1LL << '\n';
	for (int i = 0; i < n; i++) {
		y[i] += mr; rp(1, ry[i]);
		if (t == 1) {
			if (x[i] % 2 == 1) { x[i]--; rp(0, rx[i] * -1); }
			else { y[i]--; rp(1, ry[i] * -1); }
		}
		for (int j = 0; j <= 32; j++) {
			long long ti = (1LL << (j * 1LL));
			bool f = false;
			if ((x[i] & (ti * 2)) != (y[i] & (ti * 2)))
				f = true;
			if ((x[i] & ti) != 0) {
				if (f) {
					x[i] += ti; rp(0, rx[i]);
				}
				else {
					x[i] -= ti; rp(0, rx[i] * -1);
				}
			}
			else {	
				if (f) {
					y[i] -= ti; rp(1, ry[i] * -1);
				}
				else {
					y[i] += ti; rp(1, ry[i]);
				}
			}
		}
		y[i] -= (1LL << 33LL) - 1LL; rp(1, ry[i] * -1);
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

double dp[310][310][310];//dp[i][j][k]...寿司の残りが3個がi組……1個がk組あるときの全部食べ終わる期待値
int a[300];
int c[3];//3,2,1

int main()
{
	double n;
	cin>>n;
	fill(c,c+3,0);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		c[a[i]-1]++;
	}
	fill(dp[0][0],dp[310][0],0.0f);
	//cerr<<"start"<<endl;
	for(int i=0;i<301;i++)
	{
		for(int j=0;j<304;j++)
		{
			for(int k=0;k<309;k++)
			{
				if(i+j+k==0)
					continue;
				double tmp=0.0f;
				double cnt=0.0f;
				if(i>0)
				{
					cnt+=1.0f;
					tmp+=dp[i-1][j+1][k]*(double)i/(double)(i+j+k);
				}
				if(j>0)
				{
					tmp+=dp[i][j-1][k+1]*(double)j/(double)(i+j+k);
					cnt+=1.0f;
				}
				if(k>0)
				{
					tmp+=dp[i][j][k-1]*(double)k/(double)(i+j+k);
					cnt+=1.0f;
				}
				dp[i][j][k]=tmp+n/(double)(i+j+k);
			}
		}
	}
	//cerr<<"end"<<endl;
	cout<<fixed<<setprecision(14)<<dp[c[2]][c[1]][c[0]]<<endl;
	return 0;
}

Measured memory_bytes: 232960
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    cout << W*H/2 << " ";
    if(W/2 == x && H/2 == y) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10;
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
    #define eprintf(...) 42
#endif // LOCAL

int main(){
    int n,k;
    cin >> n >>k;
    int ans = 0;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        ans += (x>=k);
    }
    printf("%d\n",ans);
}
/*
    Good Luck
        -Lucina
*/



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

using namespace std;

using ul = unsigned long long;

const ul p = 1000000007;
ul facto[1000001];

ul power(ul num, ul coefi)
{
    if (coefi == 1)
        return num % p;
    else if (coefi & 1)
        return (power(num, coefi - 1) * num) % p;
    else
        return power(num * num % p, coefi / 2);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    
    int x, y; cin >> x >> y;
    
    if ((x + y) % 3)
    {
        cout << 0;
    }
    else
    {
        int a((x + y) / 3);
        if (x - a < 0 || y - a < 0)
        {
            cout << 0;
        }
        else
        {
            int b(x - a);
               
            facto[0] = facto[1] = 1;
            for (int i = 2; i < a + 1; ++i)
                facto[i] = facto[i - 1] * i % p;
            
            ul A = facto[a];
            ul Binv = power(facto[b], p - 2) * power(facto[a - b], p - 2) % p;
            cout << A * Binv % p;
        }
    }
}

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

using namespace std;

const int maxn=1e6;
int n;
int a[maxn];

int main()
{
    scanf("%d",&n);
    int l=1e9,r=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        l=min(l,a[i]);
        r=max(r,a[i]);
    }
    printf("%d",r-l);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<iomanip>
using namespace std;

int main(){
   string s;
   cin >> s;
   int ans = 0;
   for (int i = 0; i < 4; i++){
      if (s[i] == '+') ans++;
      else ans--;
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,i,x;
    scanf("%d",&n);
    for(i=1;i<n+1;i++){
        if(i%3==0){
            printf(" %d",i);
        }
        else {
            for(x=i;x;x/=10){
                    if(x%10==3){
                        printf(" %d",i);
                        break;
                    }

                 }
        }
    }
    printf("\n");
return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,k;
ll Mod,f[100010],p[100010],q[100010],ans[100010],g[100010];
int cnt,head[100010],to[200010],nxt[200010];
void add(int x,int y)
{
	cnt++;
	to[cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt;
}
void dfs(int x,int fa)
{
	f[x]=1;
	for (int i=head[x];i;i=nxt[i])
	{
		int y=to[i];
		if (y==fa)
		{
			continue;
		}
		dfs(y,x);
		f[x]=f[x]*(f[y]+1)%Mod;
	}
}
void work(int x,int fa)
{
	ans[x]=f[x]*(g[x]+1)%Mod;
	int k=0;
	p[k++]=(g[x]+1)%Mod;
	for (int i=head[x];i;i=nxt[i])
	{
		int y=to[i];
		if (y==fa)
		{
			continue;
		}
		p[k++]=(f[y]+1)%Mod;
	}
	q[k]=1;
	for (int i=k-1;i>=0;i--)
	{
		q[i]=q[i+1]*p[i]%Mod;
	}
	for (int i=1;i<k;i++)
	{
		p[i]=p[i]*p[i-1]%Mod;
	}
	k=0;
	for (int i=head[x];i;i=nxt[i])
	{
		int y=to[i];
		if (y==fa)
		{
			continue;
		}
		k++;
		g[y]=p[k-1]*q[k+1]%Mod;
	}
	for (int i=head[x];i;i=nxt[i])
	{
		int y=to[i];
		if (y==fa)
		{
			continue;
		}
		work(y,x);
	}
}
int main()
{
	scanf("%d%lld",&n,&Mod);
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	dfs(1,0);
	work(1,0);
	for (int i=1;i<=n;i++)
	{
		printf("%lld\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,s[10000],q,t[500],cnt=0,idx=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>s[i];
  sort(s,s+n);

  
  cin>>q;
  for(int i=0;i<q;i++)cin>>t[i];
  sort(t,t+q);

  for(int i=0;i<q;i++)
    for(int j=idx;j<n;j++)
      if(t[i]==s[j]){idx=j;cnt++;break;}


  
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D){
    cout<< "Left" << endl; 
  }else if(A + B == C + D){
    cout<< "Balanced" << endl; 
  }else if(A + B < C + D){
    cout<< "Right" << endl; 
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out){
		int n = sc.nextInt();
		String[] s = new String[n];
		
		for(int i = 0; i < n; i++) s[i] = sc.next();
		
		int m = sc.nextInt();
		String[] t = new String[m];
		
		for(int i = 0; i < m; i++) t[i] = sc.next();
		
		int max = 0;
		
		for(int i = 0; i < n; i++) {
			int res = 1;
			
			for(int j = 0; j < m; j++){
				if(s[i].equals(t[j])) res--;
			}
			
			for(int j = 0; j < n; j++){
				if(i != j && s[i].equals(s[j])) res++;
			}
			
			max = Math.max(max, res);
		}
		
		out.println(max);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22612
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013
 
 
int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		int n;
		cin>>n;
		int a[n];
		vector<int> m(1000006);
		fi(0,n) 
		{
			cin>>a[i];
			m[a[i]]++;
		}
		bool pw=true;
		for(ll i=2;i<=1000000;i++)
		{
			int count=0;
			for(ll j=i;j<=1000000;j+=i)
			{
				count+=m[j];
			}
			if(count>1)
			{
				pw=false;
				break;
			}
		}
		if(pw)
		{
			cout<<"pairwise coprime\n";
			return 0;
		}
		
		int temp=a[0];
		fi(1,n)
		{
			temp=__gcd(temp,a[i]);
		}
		if(temp==1)
		{
			cout<<"setwise coprime\n";
		}
		else
		{
			cout<<"not coprime\n";
		}
		
		
	}
}

Measured memory_bytes: 11120
import java.util.Scanner;

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

    int count = 0;
    int tmp;
    for (int i = 0; i < size; i++) {
      for (int j = size - 1; j > i; j--) {
        if (array[j] < array[j-1]) {
          tmp = array[j-1];
          array[j-1] = array[j];
          array[j] = tmp;
          count++;
        }
      }
    }

    for (int i = 0; i < size - 1; i++) {
      System.out.print(array[i] + " ");
    }
    System.out.println(array[size - 1]);
    System.out.println(count);
  }
}



Measured memory_bytes: 26288
process.stdin.resume();
process.stdin.setEncoding('utf8');

// https://atcoder.jp/contests/caddi2018/tasks/caddi2018_a

const factorization = (n) => {
    let primes= []
    for(let i=2; i*i<=n; i++) {
        let exponent = 0
        while(n%i===0) {
            n /= i
            exponent++
        }
        if(exponent) {
            primes.push({p:i, e:exponent})
        }
    }
    
    if(n!==1) {
        primes.push({p:n, e:1})
    }
    return primes
}

const main = (arg) => {
    const [N,P] = arg.split(" ").map(Number)
    const f = factorization(P)

    gcd = 1;
    for(let i=0; i<f.length; i++){
        let tmp = Math.floor(f[i].e/N)
        gcd *= f[i].p**tmp
    }
    console.log(gcd)
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33516
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

struct SegT {
private:
	int sz; vector<P> node;
	const P init_c = { mod,-mod };
public:
	SegT(int n) {
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
	}
	SegT(vector<P> &v) {
		int n = v.size();
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
		rep(i, n) {
			node[i + sz - 1] = v[i];
		}
		per(i, sz - 1) {
			node[i] = f(node[2 * i + 1], node[2 * i + 2]);
		}
	}
	void update(int k, P a) {
		k += sz - 1;
		node[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = f(node[2 * k + 1], node[2 * k + 2]);
		}
	}
	P f(P a, P b) {
		int le = min(a.first, b.first);
		int ri = max(a.second, b.second);
		return P{ le,ri };
	}
	P query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = sz;
		if (r <= a || b <= l)return init_c;
		else if (a <= l && r <= b)return node[k];
		else {
			P vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			P vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}
};
typedef pair<int, P> speP;
void solve() {
	int n, q; cin >> n >> q;
	vector<speP> v(n);
	rep(i, n) {
		cin >> v[i].second.first >> v[i].second.second >> v[i].first;
	}
	sort(v.begin(), v.end());
	vector<P> u;
	rep(i, n) {
		v[i].second.first -= v[i].first; v[i].second.second -= v[i].first;
		u.push_back(v[i].second);
	}

	vector<speP> z;
	rep(i, n) {
		z.push_back({ v[i].second.first,{1,i} });
		z.push_back({ v[i].second.second,{0,i} });
	}
	sort(z.begin(), z.end());
	int loc = 0;
	SegT st(n);
	rep(i, q) {
		int d; cin >> d;
		while (loc < z.size() && z[loc].first <= d) {
			int id = z[loc].second.second;
			if (z[loc].second.first) {
				st.update(id, u[id]);
			}
			else {
				st.update(id, { mod,-mod });
			}
			loc++;
		}
		int le = 0, ri = n + 1;
		while (ri - le > 1) {
			int mid = (ri + le) / 2;
			P z = st.query(0, mid);
			if (z.first <= d && d < z.second) {
				ri = mid;
			}
			else {
				le = mid;
			}
		}
		if (ri == n+1)ri = -1;
		else ri = v[ri-1].first;
		//cout << "ans is ";
		cout << ri << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


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

using namespace std;

bool isPrime[100010], issPrime[100010];
int csum[100010];

int main(){
    for(int i = 0; i < 100010; ++i) issPrime[i] = isPrime[i] = true;
    issPrime[0] = isPrime[ 0 ] = false; // zero is not prime - it'is not greater than 1
    isPrime[ 1 ] = issPrime[1] =  false; // one is not prime - it'is not greater than 1
    for ( long long int p = 2; p < 100010; ++p ) {
        if ( isPrime[ p ] ) {
            for ( long long int m = 2; m * p < 100010; ++m ) {
                isPrime[ m * p ] = false;
                issPrime[m*p] = false;
            }
        }
    }

    memset(csum, 0, sizeof(csum));

    for(int i = 1; i < 100010; ++i) {
        if(isPrime[i]) {
            if(!isPrime[(i+1)/2]) {
                issPrime[i] = false;
            }
        }
        //if(i < 6)
        //cout<<"hi "<<i<<" "<<issPrime[i]<<endl;
        csum[i] = csum[i-1];
        if(i%2 != 0) csum[i] += (issPrime[i] ? 1 : 0);
    }

    int q;
    cin>>q;
    while(q--) {
        int a, b;
        cin>>a>>b;
        //cout<<"::: "<<csum[b]<<" : "<<csum[a-1]<<endl;
        cout<<(csum[b] - csum[a-1])<<"\n";
    }





    return 0;
}





Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
 
#define WHITE 0
#define GRAY 1
#define BRACK 2
 
int **matrix;
int *color;
int *dist;
 
int n;
int time;
 
int *queue;
int head;
int tail;
 
void enqueue(int);
int dequeue(void);
void bfs(void);
 
 
int main(){
  int i,j,u,k,v;
 
  scanf("%d",&n);
 
  queue = malloc((n+1) * sizeof(int));
  color = malloc((n+1) * sizeof(int));
  dist = malloc((n+1) * sizeof(int));
  
   
  matrix = malloc((n+1) * sizeof(int *));
  for(i=0;i<n+1;i++) matrix[i] = malloc((n+1) * sizeof(int));
 
 
  for(i=1;i<n+1;i++){
    dist[i] = -1;
    color[i] =WHITE;
  }
   
  for(i=1;i<n+1;i++)
    for(j=1;j<n+1;j++)
      matrix[i][j] = 0;
   
   
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      matrix[u][v] = 1;
    }
  }
 
 
  bfs();
  
 
  for(i=1;i<n+1;i++) printf("%d %d\n",i,dist[i]);
 
  for(i=0;i<n+1;i++)
    free(matrix[i]);
  free(matrix);
  free(queue);
  free(dist);
  free(color);
 
  return 0;
}
 
void enqueue(int q){
   
  queue[tail] = q;
  if(++tail == (n+1)) tail = 0;
   
}
 
int dequeue(){
  int v;
   
  v = queue[head];
  if(++head == (n+1)) head=0;
  return v;
 
}

void bfs(){
  int u,i;
 
  head = tail = 0;
  color[1] = GRAY;
  dist[1] = 0;
  enqueue(1);
   
  while(head != tail){
    u = dequeue();
    for(i=1;i<n+1;i++){
      if(matrix[u][i] == 1 && color[i] == WHITE){
	color[i] = GRAY;
	dist[i] = dist[u] + 1;
	enqueue(i);
      }
    }
    color[u] = BRACK;
  }
}

Measured memory_bytes: 636
import sys
input = sys.stdin.readline
 
def main():
     n,m=map(int,input().split())
     field=[[] for i in range(3*n)]
     for i in range(m):
          x,y=map(int,input().split())
          x,y=x-1,y-1
          field[3*x].append(3*y+1)
          field[3*x+1].append(3*y+2)
          field[3*x+2].append(3*y)
     
     s,t=map(int,input().split())
     s,t=s-1,t-1
     s,t=3*s,3*t
     
     d=[float('inf') for i in range(3*n)]
     d[s]=0
     
     que=[s]
     cnt=0
     while que!=[]:
          que2=[]
          cnt+=1
          for i in que:
               for j in field[i]:
                    if j==t:
                         print(cnt//3)
                         return
                    if d[j]>cnt:
                         d[j]=cnt
                         que2.append(j)
                         
          que=que2
     if d[t]==float('inf'):
          print(-1)
     else:
          print(d[t]//3)
     return 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 94604
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>a.at(i).at(j);
    }
  }
  int n;cin>>n;
  int b;
  for(int k=0;k<n;k++){
    cin>>b;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(a.at(i).at(j)==b){
          a.at(i).at(j)=0;
        }
      }
    }
  }
  string s="No";
   for(int i=0;i<3;i++){
     int cnt=1;
    for(int j=0;j<3;j++){
      if(a.at(i).at(j)!=0){
        cnt=0;
      }
    }
     if(cnt==1){
       s="Yes";
     }
   }
    for(int i=0;i<3;i++){
     int cnt=1;
    for(int j=0;j<3;j++){
      if(a.at(j).at(i)!=0){
        cnt=0;
      }
    }
     if(cnt==1){
       s="Yes";
     }
   } 
  if(a.at(0).at(0)==0 &&a.at(1).at(1)==0 && a.at(2).at(2)==0)
    s="Yes";
  if(a.at(0).at(2)==0 && a.at(1).at(1)==0 && a.at(2).at(0)==0)
    s="Yes";
  cout<<s;
  }
    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a1,b,c,a[4][4],ansx;
	cin>>a1>>b>>c;
	ansx=3*c;
	a[1][1]=a1;
	a[1][2]=b;
	a[1][3]=ansx-a1-b;
	a[2][2]=c;
	a[3][1]=ansx-a[1][3]-c;
	a[3][2]=ansx-a[1][2]-c;
	a[3][3]=ansx-a[1][1]-c;
	a[2][1]=ansx-a[1][1]-a[3][1];
	a[2][3]=ansx-a[1][3]-a[3][3];
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    string n;
    cin1(n);
    bool is_kaibun = true;
    REP(i,0,n.length()) {
        if (n[i] != n[n.length()-i-1]) {
            is_kaibun = false;
            break;
        }
    }
    if (is_kaibun)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
/*
   Author : BabaYaga42,
   BITS Pilani, Hyderabad.
   Don't give up ;)
   */
#include <bits/stdc++.h>
#include <stdint.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
#define int long long int
#define push_back pb

int mat[100050][3];
int dp[100050][3];
 
int32_t main(){
    int n,a,b,c,sol=0;
    cin>>n;
    for(int i=0;i<n;i++)
	{
        cin>>a>>b>>c;
        mat[i][0]=a;
        mat[i][1]=b;
        mat[i][2]=c;
    }
    dp[0][0]=mat[0][0];
    dp[0][1]=mat[0][1];
    dp[0][2]=mat[0][2];
    for(int i=1;i<n;i++)
	{
        dp[i][0]=mat[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=mat[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=mat[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<vector<int>> s(30);
    for (int i = 0; i < n; i++){
      int f;
      cin >> f;
      for (int j = 0; j < f; j++){
        int d;
        cin >> d;
        s[d - 1].push_back(i);
      }
    }
    vector<long long> m(n);
    for (int i = 0; i < n; i++){
      m[i] = (long long) 1 << i;
    }
    int ans = -1;
    for (int i = 0; i < 30; i++){
      long long p = 0;
      for (int j : s[i]){
        p |= m[j];
      }
      if (__builtin_popcountll(p) == n){
        ans = i + 1;
        break;
      }
      for (int j : s[i]){
        m[j] = p;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 3e5 + 5;

int main()
{
    fastRead;
    int n , m;
    cin>>n>>m;
    ll tot = 0;
    for(int i =0 ; i < m ; i++ ) {
        ll tmp;
        cin>>tmp;
        tot += tmp;
    }
    if(tot > n) cout<<-1<<'\n';
    else cout<<n-tot<<'\n';
    return 0;
}

Measured memory_bytes: 3652
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)


Measured memory_bytes: 3060
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,h[202020],a[202020],dp[202020],ans;
long long fd(long long nh)
{
	long long rt=0;
	for(;nh;nh-=(nh&-nh))
	{
		rt=max(rt,dp[nh]);
	}
	return rt;
}
long long gx(long long nh,long long nw)
{
	for(;nh<=n;nh+=(nh&-nh))
	{
		dp[nh]=max(dp[nh],nw);
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		long long nw=fd(h[i])+a[i];
		ans=max(ans,nw);
		gx(h[i],nw);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int l = 0;
    int r = n-1;
    string sl, sr, sm;
    cout << l << endl;
    cin >> sl;
    cout << r << endl;
    cin >> sr;
    if(sl == "Vacant" || sr == "Vacant")
        return 0;
    while(l + 1 <= r){
        int m = (l + r) / 2;
        cout << m << endl;
        cin >> sm;
        if(sm == "Vacant")
            return 0;
        else if (sm == sl){
            if((m - l) % 2 == 0){
                l = m;
                sl = sm;
            } else {
                r = m;
                sr = sm;
            }
        } else if(sm == sr){
            if((r - m) % 2 == 0){
                r = m;
                sr = sm;
            } else {
                l = m;
                sl = sm;
            }
        } else {
            if((r - m) % 2 == 0){
                l = m;
                sl = sm;
            } else {
                r = m;
                sr = sm;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3804
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H=0,A[200000001];
string com;
void maxHeapify(int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(1);
    }
}
int main(){
    while(1){
        cin>>com;
        int k;
        if(com=="end") break;
        if(com=="insert"){cin>>k; insert(k);}
        else extract();
    }
    return 0;
}


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

int main(void){
    int a = 0, b = 0, c = 0, d = 0; 

    scanf("%d%d%d%d", &a, &b, &c, &d);


    if(a + b > c + d){
        printf("Left\n");
    }else if(a + b == c + d){
        printf("Balanced\n");
    }else{
        printf("Right\n");
    }
    return 0;

} 


Measured memory_bytes: 256
<?php
$s=str_split(trim(fgets(STDIN)));
$t=str_split(trim(fgets(STDIN)));
$a=str_split('abcdefghijklmnopqrstuvwxyz');
$i=0;
while($i<count($s)){
  $s[$i]=array_search($s[$i],$a);
  ++$i;
}
sort($s);
$j=0;
while($j<count($t)){
  $t[$j]=array_search($t[$j],$a);
  ++$j;
}
rsort($t);
$k=0;
while($k<min($i,$j)){
  if($s[$k]>$t[$k]){
    echo 'No';
    exit;
  }elseif($s[$k]<$t[$k]){
    echo 'Yes';
    exit;
  }
  ++$k;
}
echo $k==$j?'No':'Yes';

Measured memory_bytes: 4728
#include <iostream>

using namespace std;

int bubble_sort(int A[], int N) {
    int  count = 0;
    bool flag = 1;
    for (int i = 0; flag; i++) { 
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--) { 
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j-1]);
                flag = 1;
                count++;
            }
        }
    }
    return count;
}

int main(int argc, char const *argv[])
{
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sw = bubble_sort(A, N);

    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}




Measured memory_bytes: 3068
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iterator>
#include <sstream>

using namespace std;

double dot(double x1,double y1,double x2,double y2)
{
	return x1 * x2 + y1 * y2;
}

int main()
{
	double x1,x2,x3,x4,y1,y2,y3,y4;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){
		double s = dot(x2-x1,y2-y1,x4-x3,y4-y3);
		if(abs(s) <= 1e-10) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 0
import math
tempList = tuple(map(int, input().split()))
a = tempList[0]
b = tempList[1]
hour = tempList[2]
minute = tempList[3]
time = hour * 60 + minute
mypi = math.pi
hourAngle = time/(12*60)
minuteAngle = minute/60
diff = abs(hourAngle - minuteAngle)
if diff > 0.5:
    diff = 1 - diff
angle = diff * mypi * 2
result = a*a + b*b - 2*a*b*math.cos(angle)
print(math.sqrt(result))

Measured memory_bytes: 9420
package main

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

func isqrt(n int) int {
	if n < 0 {
		panic("isqrt argument must be nonnegative")
	}

	if n <= 1 {
		return n
	}

	ok := 0
	ng := 3037000500 // 3037000499 * 3037000499 < math.MaxInt64 < 3037000500 * 3037000500
	if n < ng {
		ng = n
	}
	for ng-ok > 1 {
		m := ok + (ng-ok)/2
		if m*m <= n {
			ok = m
		} else {
			ng = m
		}
	}
	return ok
}

func makeDivisorList(n int) []int {
	result := make([]int, 0)
	for i := 1; i <= isqrt(n); i++ {
		if n%i == 0 {
			result = append(result, i, n/i)
		}
	}
	return result
}

func calcMinOps(r []int, d int) int {
	i, j := 0, len(r)
	for i < j && r[i] == 0 {
		i++
	}
	i--
	a, b := 0, 0
	for j-i != 1 {
		if a <= b {
			i++
			a += r[i]
		} else {
			j--
			b += d - r[j]
		}
	}
	return a
}

func main() {
	defer flush()

	N := readInt()
	K := readInt()

	A := make([]int, N)
	c := 0
	for i := 0; i < N; i++ {
		A[i] = readInt()
		c += A[i]
	}
	r := make([]int, N)

	divisors := makeDivisorList(c)
	sort.Sort(sort.Reverse(sort.IntSlice(divisors)))
	for i := 0; i < len(divisors); i++ {
		d := divisors[i]
		for j := 0; j < N; j++ {
			r[j] = A[j] % d
		}
		sort.Ints(r)
		if calcMinOps(r, d) <= K {
			println(d)
			break
		}
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 2012
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  int N,mn,count,ans;
  cin >> N;
  int A[N];
  int B[N];
  mn=1000000000;
  ans=0;
  for(int i=0; i<N; ++i){
    cin >> A[i];
    mn=min(mn,A[i]);
  }
  for(int i=1; i<N; ++i){
    B[i]=abs(A[i]-A[i-1]);
    if(B[i]==0) B[i]=A[i];
    mn=min(mn,B[i]);
  }
  for(int i=mn; i>=1; --i){
    count=0;
    for(int j=0; j<N; ++j){
      if(A[j]%i != 0) count += 1;
    }
    if(count==0){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int a[33], k;
	a[1]=1;
	a[2]=1;
	a[3] = 1;
	a[4]=2;
	a[5]=1;
	a[6]=2;
	a[7]=1;
	a[8]=5;
	a[9]=2;
	a[10]=2;
	a[11]=1;
	a[12]=5;
	a[13]=1;
	a[14]=2 ;
	a[15]=1 ;
	a[16]=14;
	a[17]=1;
	a[18]=5 ;
	a[19]=1 ;
	a[20]=5 ;
	a[21] = 2 ;
	a[22] =2 ;
	a[23] =1 ;
	a[24] = 15 ;
	a[25] =2 ;
	a[26] = 2 ;
	a[27] = 5 ;
	a[28] = 4 ;
	a[29] =1 ;
	a[30] =4 ;
	a[31] =1 ;
	a[32] =51;

	
	scanf("%d",&k);
	
	printf("%d",a[k]);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
ll n,a[1000005]={1},b[1000005]={1,1},ans;
ll C(ll n,ll m)
{
	if (m<0 || m>n) return 0;
	return a[n]*b[m]%mod*b[n-m]%mod;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) a[i]=a[i-1]*i%mod;
	for (int i=2;i<=n;i++) b[i]=mod-mod/i*b[mod%i]%mod;
	for (int i=2;i<=n;i++) b[i]=b[i]*b[i-1]%mod;
	for (int i=0;i<n;i++) ans=(ans+a[n-1]-C(i-1,n-1-i)*a[i]%mod*a[n-1-i])%mod;
	ans=(ans+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
const int maxn=155;
int n,m,mod;
namespace subtask1
{
	map<pii,int> f[maxn][maxn][maxn];
	inline void solve()
	{
		f[0][0][0][pii(n+1,n+1)]=1;
		for(int i=0;i<n;i++)
			for(int j=0;j<=n;j++)
				for(int k=0;k<=n;k++)
					for(auto it:f[i][j][k])
					{
						int p=it.fi.fi,q=it.fi.se,val=it.se;
						if(!(i&1))
						{
							(f[i+1][0][k][pii(n+1,q)]+=val)%=mod;
							if(p>i+1)
							{
								if(i+2-2*k+m<=i+1 && i+1-2*j+m>i)
									(f[i+1][j+1][k][pii(p,min(q,i+1-2*j+m))]+=val)%=mod;
								else
									(f[i+1][j+1][k][pii(p,q)]+=val)%=mod;
							}
						}
						else
						{
							(f[i+1][j][0][pii(p,n+1)]+=val)%=mod;
							if(q>i+1)
							{
								if(i+2-2*j+m<=i+1 && i+1-2*k+m>i)
									(f[i+1][j][k+1][pii(min(p,i+1-2*k+m),q)]+=val)%=mod;
								else
									(f[i+1][j][k+1][pii(p,q)]+=val)%=mod;
							}
						}
					}
		int res=0;
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n;k++)
				for(auto it:f[n][j][k])
					(res+=it.se)%=mod;
		printf("%d\n",res);
	}
}
namespace subtask2
{
	int f[maxn];
	inline void solve()
	{
		f[0]=1;
		int len=m/2+1;
		for(int i=1;i<=n/2+1;i++)
			f[i]=(2ll*f[i-1]-((i>=len)?f[i-len-(i!=len)]:0)+mod)%mod;
		printf("%lld\n",(ll)f[n>>1]*f[(n+1)>>1]%mod);
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&mod);
	if(m&1) subtask1::solve();
	else subtask2::solve();
	return 0;
}

Measured memory_bytes: 228352
S = input()
T = input()
if len(S) < len(T):
    print("UNRESTORABLE")
    exit(0)

for k in range(len(S)-len(T),-1,-1):
    f = 1
    for i in range(len(T)):
        if S[k+i] != "?":
            if S[k+i] != T[i]:
                f = 0
                break
    if f == 1:
        ans = ""
        for i in range(k):
            if S[i] == "?":
                ans += "a"
            else:
                ans += S[i]
        ans += T
        for i in range(k+len(T),len(S)):
            if S[i] == "?":
                ans += "a"
            else:
                ans += S[i]
        print(ans)
        exit(0)
print("UNRESTORABLE")


Measured memory_bytes: 61968
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    if(n == 2){
        cout << '1';
        return 0;
    }
    long long cnt = 0;
    for(long long i = 2; i <= sqrt(n - 1); i++){
        if((n - 1) % i == 0){
            cnt++;
            if((n - 1)/i != i){
                cnt++;
            }
        }
    }
    for(long long i = 2; i <= sqrt(n); i++){
        if(n % i == 0){
            long long m = n;
            while(m % i == 0){
                m = m/i;
            }
            if(m % i == 1){
                cnt++;
            }
            long long j = n/i;
            if(j == i){
                continue;
            }
            m = n;
            while(m % j == 0){
                m = m/j;
            }
            if(m % j == 1){
                cnt++;
            }
        }
    }
    cnt += 2;
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	long long int A,B;
	string b;
	cin>>A>>b;
	if(b[1]=='.')B=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
	else B=(b[0]-'0')*1000+(b[1]-'0')*100+(b[3]-'0')*10+(b[4]-'0');
	cout<<A*B/100;
	return 0;
}

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

bool solve(vector<string>& W ) {
    int n = W.size();
    for (int i = 0; i < n-1; i++) {
        if (W[i].back() != W[i+1].front()) {
            return false;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            if (W.at(i) == W.at(j)) {
                return false;
            }
        }
    }
    return true;
}
vector<string> input() {
    int n; cin >> n; 
    vector<string> W(n);
    for (int i = 0; i < n; i++) {
        cin >> W.at(i);
    }
    return W;
}
int main() {
    vector<string> W = input();
    if (solve(W)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N) cin >> X[i];
  vector<int> cnt(101);
  rep(i, 101) rep(j, N) cnt[i] += (i - X[j]) * (i - X[j]);
  int mn = inf;
  rep(i, 101) mn = min(cnt[i], mn);
  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
/*交点の座標を求めるプログラム
　点をpとし、p0の座標を(x0,y0)とする
 　Inputは x0 y0 x1 y1 x2 y2 x3 y3
  p0とp1、p2とp3はつながっている*/
double x[100][2];
double y[100][2];
int n;
struct Pos2{
	double x;
	double y;
};

int main() {
	while (cin >> n, n){
		int count = 1;//交点の数を記憶
		for (int i = 0; i < n; i++){
			cin >> x[i][0] >> y[i][0] >> x[i][1] >> y[i][1];
			//cout << x[i][0] << y[i][0] << x[i][1] << y[i][1]<<endl;
		}
		for (int i = 0; i < n ; i++){
			vector<Pos2> p;
			for (int j = i + 1; j < n; j++){
				double d = (x[i][1] - x[i][0])*(y[j][1] - y[j][0]) - (y[i][1] - y[i][0])*(x[j][1] - x[j][0]);//平行チェック
				if (d != 0){
					double a0 = ((y[j][1] - y[j][0])*(x[j][0] - x[i][0]) - (x[j][1] - x[j][0])*(y[j][0] - y[i][0])) / d;//iの直線のどこで交わっているか
					double a2 = ((y[i][1] - y[i][0])*(x[j][0] - x[i][0]) - (x[i][1] - x[i][0])*(y[j][0] - y[i][0])) / d;//jの直線のどこで交わっているか
					if (0.0 < a0&&a0 < 1.0&&0.0 < a2&&a2 < 1.0){//どちらもが線分内で交わっているか判定（辺上で交わるのは除外）
						double ansx = x[i][0] + (x[i][1] - x[i][0])*a0;
						double ansy = y[i][0] + (y[i][1] - y[i][0])*a0;
						bool b = true;
						for (int k = 0; k < p.size(); k++){
							if (abs(p[k].x - ansx) < 1e-10&&abs(p[k].y - ansy) < 1e-10){
								b = false;
								break;
							}
						}
						if (b){
							p.push_back({ ansx, ansy });
						}
					}
				}
			}
			count += p.size() + 1;
		}
		cout << count << endl;//領域を出力
	}
}

Measured memory_bytes: 1268