akhauriyash/Code-Regression huggingface dataset:
# include<bits/stdc++.h>
# define mem(x, y) memset(x, y, sizeof(x)))
using namespace std;
const int N = 100010;
const int INF = 9999999;
struct point{
   int x, y;
}a[N];
bool cmp(point w, point v){
    if (w.x == v.x) return w.y > v.y;
   return w.x < v.x;
}
int main(){
   int n, m;
   scanf ("%d%d", &n, &m);
   for (int i = 1; i <= m; ++i) scanf ("%d%d", &a[i].x, &a[i].y);
   sort(a + 1, a + 1 + m, cmp);
   int num = 0, t = a[1].x, p = a[1].y;
   for (int i = 2; i <= m; ++i){
     if (t != a[i].x)  t = a[i].x;
     if (p > a[i].y) p = a[i].y;
     if (t >= p){
        num++;
        t = a[i].x;
        p = a[i].y;
     }
   }
   printf("%d\n", num + 1);
   return 0;
}


Measured memory_bytes: 1152
import heapq
import sys

N = int(input())
A = [-x for x in map(int, input().split())]
heapq.heapify(A)

while len(A) > 3:
    l1 = -heapq.heappop(A)
    l2 = -heapq.heappop(A)
    if l1 == l2:
        while len(A) > 1:
            s1 = -heapq.heappop(A)
            s2 = -heapq.heappop(A)
            # print(s1, s2)
            if s1 == s2:
                print(l1 * s1)
                sys.exit()
            else:
                heapq.heappush(A, -s2)
                # print(A)

    else:
        if A:
            heapq.heappush(A, -l2)
print(0)



Measured memory_bytes: 14212
#include <stdio.h>

int main(void)
{
	int n, i;
	int a[100];
	int s = 0, t = 0;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for(i = 0; i < n; i++) {
		if(a[i] % 2 == 0) {
			s++;
			if(a[i] % 3 == 0 || a[i] % 5 == 0) {
				t++;
			}
		}
	}
	if(s == t) {
		printf("APPROVED\n");
	}
	else {
		printf("DENIED\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
typedef long long ll;
int n,l;
int cnt;
struct node
{
    int u,v,val;
    node () {} node (int u1,int v1,int val1):u(u1),v(v1),val(val1) {}
} pr[70];
int main()
{
    SF("%d",&l);
    l--;
    int sum=1;
    int tot=0;
    for(tot=0; sum-1<=l&&tot<=19; tot++) sum*=2;
    sum/=2;
    for(int i=1; i<tot; i++)
    {
        pr[++cnt]=node(i,i+1,0);
        pr[++cnt]=node(i,i+1,1<<(i-1));
    }
    int pre=0;
    int tot1=tot;
    tot--;
    sum/=2;
    while(pre<l)
    {
        pre+=sum;
        for(; sum+pre+sum-1<=l; pre+=sum)
        {
            pr[++cnt]=node(tot,tot1,sum+pre);
        }
        sum/=2;
        tot--;
    }
    PF("%d %d\n",tot1,cnt);
    for(int i=1; i<=cnt; i++) PF("%d %d %d\n",pr[i].u,pr[i].v,pr[i].val);
}



Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

class Graph{
	private:
	int V;
	vvi List;
	public:
	Graph(int v){
		V=v;
		List=vvi(v);
	}
	void add_edge(int s,int t){
		List[s].push_back(t);
		List[t].push_back(s);
	}
	bool solve(){
		for(int i=0;i<V;i++) if(List[i].size()%2==1) return 0;
		return 1;
	}
};

int n,m;

int main(){
	cin>>n>>m;
	Graph g(n);
	for(int i=0;i<m;i++){
		int s,t;
		cin>>s>>t;
		g.add_edge(s-1,t-1);
	}
	if(g.solve()) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

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

int main(){
  int N;
  cin >> N;
  if((N-3)%10 == 0){
    cout << "bon" << endl;
  }else if(N%10==0 || (N-1)%10==0 || (N-6)%10==0 || (N-8)%10==0){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3608
//@trueno
//The purpose of computation is insight, not numbers...
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll memo[105][100005],V[105],W[105],N;
ll value(int id, ll w)
{
	if(id==N || w==0) return 0;
	if(memo[id][w]!=-1) return memo[id][w];
	if(W[id]>w) return memo[id][w]=value(id+1,w);
	return memo[id][w]=(ll)max(value(id+1,w), V[id]+value(id+1,w-W[id]));
}
int main()
{
	ll weight;
	cin>>N>>weight;
	memset(memo,-1,sizeof(memo));
	for(int i=0;i<N;i++)
	{
		cin>>W[i]>>V[i];
	}
	cout<<value(0,weight);

	return 0;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    int n;
    cin >> n;

    int ans = 0;

    rep(i,n){
        int l,r;
        cin >> l >> r;

        ans += r - l + 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main() {
  while (true) {
    int n, x;
    cin >> n >> x;
    if (n == x && n == 0) {
      return 0;
    }
    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        int l = x - i - j;
        if (j<l&&l <= n) {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3080
def t(s):
    a = s[:int(len(s)/2)]
    b = s[::-1][:int(len(s)/2)]
    c = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            c += 1
    return c


if __name__ == '__main__':
    print(t(input()))


Measured memory_bytes: 2940
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sec = sc.nextInt();
		int hour = sec / 3600;
		int min = (sec % 3600) / 60;
		sec = sec % 60;
		
		System.out.println(hour+":"+min+":"+sec);
    }
}



Measured memory_bytes: 26296
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

	//変数の読み込み
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();

	//SがWよりも多い場合と、SがW以下の場合で分ける
		if(S > W) {
			System.out.print("safe");
		}
		else {
			System.out.print("unsafe");
		}
	}

}

Measured memory_bytes: 27088
#include<bits/stdc++.h>
#define re register
int a[200100],n,m,ans;
bool check(re int l)
{
	re int as=0,as1=0,bo=0;
	for(re int i=1;i<=l;i++)as=std::max(as,(a[i]+a[l*2-i+1])%m);
	for(re int i=1;2*(l+i)<=n;i++)as1=std::max(as1,(a[2*l+i]+a[n+1-i])%m),bo|=(a[2*l+i]+a[n+1-i])<m;
	ans=std::min(ans,std::max(as,as1));
	return bo;
}
int main()
{
	scanf("%d%d",&n,&m);
	n*=2;
	for(re int i=1;i<=n;i++)scanf("%d",&a[i]);
	std::sort(a+1,a+n+1);
	re int l=0,r=n/2,mid;ans=m;
	for(mid=(l+r)/2;l<r;mid=(l+r)/2)
	{
		if(check(mid))l=mid+1;
		else r=mid-1;
	}
	check(l);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

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

	int a[3];
	for (int i = 0; i < n; ++i) {
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
			cout << "YES" << endl;
			continue;
		}
		cout << "NO" << endl;
	}
    return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v <= w) {
        cout << "NO" << endl;
        return 0;
    }
    int d = abs(a - b);
    int vv = v - w;
    int tt = d / vv + (d % vv > 0 ? 1 : 0);
    if (tt > t) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
            
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);
  printf("ABC%d\n",n);
  return 0;
}


Measured memory_bytes: 128
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws Exception{
		FScanner sc=new FScanner();
		int[] num=sc.readIntL();
		int[] ck=new int[2];
		ck[0]=num[0];
		ck[1]=num[1];
		int t=0;
		int d=0;
		
		for(int i=num[2]; i>0; i--){
			if(t==0){
				if(ck[0]%2==1){
					ck[0]-=1;
				}
				d=ck[0]/2;
				ck[0]-=d;
				ck[1]+=d;
			}else{
				if(ck[1]%2==1){
					ck[1]-=1;
				}
				d=ck[1]/2;
				ck[1]-=d;
				ck[0]+=d;
			}
			
			t=(t==0)? 1: 0;
		}
		
		disp(ck);
		//System.out.println("");
	}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(long[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		BufferedReader read=null;
		StringTokenizer tok=null;
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			String buf=sc.nextLine();
			return Integer.parseInt(buf);
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<list>
#include<vector>
#include<queue>
using namespace std;

int visit(int h, int w,vector<vector<list<pair<int,int> > > > adj){
    int i, j;
    vector<int> int_sub;
    for(j = 0; j <= 30; j++){
        int_sub.push_back(0);
    }
    vector<vector<int> > counta;
    for(i = 0; i <= 30; i++){
        counta.push_back(int_sub);
    }
    counta[1][1] = 1;
    queue<pair<int,int> > que;
    que.push(make_pair(1,1));
    pair<int,int> p;
    list<pair<int,int> >::iterator t;
    while(!que.empty()){
        p = que.front();
        que.pop();
        for(t = adj[p.first][p.second].begin(); t != adj[p.first][p.second].end(); ++t){
            if(counta[(*t).first][(*t).second] == 0){
                counta[(*t).first][(*t).second] = counta[p.first][p.second] + 1;
                que.push(make_pair(((*t).first),(*t).second));
            }
        }
    }
    i = counta[h][w];
    return i;
}

int main(){
    int i,j;
    int h, w;
    bool wall;
    vector<bool> bool_sub;
    for(j = 0; j <= 30; j++){
        bool_sub.push_back(0);
    }
    vector<vector<bool> > wall_v, wall_p;
    for(i = 0; i <= 30; i++){
        wall_v.push_back(bool_sub);
        wall_p.push_back(bool_sub);
    }
    list<pair<int,int> > intint_subsub;
    vector<list<pair<int,int> > > intint_sub;
    for(j = 0; j <= 30; j++){
        intint_sub.push_back(intint_subsub);
    }
    vector<vector<list<pair<int,int> > > > adj;
    for(i = 0; i <= 30; i++){
        adj.push_back(intint_sub);
    }
    while(1){
        cin >> w >> h;
        if(h == 0 && w == 0) break;
        for(i = 1; i <= h-1; i++){
            for(j = 1; j <= w-1; j++){
                cin >> wall;
                wall_v[i][j] = wall;
            }
            for(j = 1; j <= w; j++){
                cin >> wall;
                wall_p[i][j] = wall;
            }
        }
        for(j = 1; j <= w-1; j++){
            cin >> wall;
            wall_v[h][j] = wall;
        }
        for(i = 0; i <= 30; i++){
            for(j = 0; j <= 30; j++){
                adj[i][j] = intint_subsub;
            }
        }
        for(i = 1; i <= h; i++){
            for(j = 1; j <= w-1; j++){
                if(!wall_v[i][j]){
                    adj[i][j].push_back(make_pair(i,j+1));
                    adj[i][j+1].push_back(make_pair(i,j));
                }
            }
        }
        for(i = 1; i <= h-1; i++){
            for(j = 1; j <= w; j++){
                if(!wall_p[i][j]){
                    adj[i][j].push_back(make_pair(i+1,j));
                    adj[i+1][j].push_back(make_pair(i,j));
                }
            }
        }
        cout << visit(h,w,adj) << endl;
    }
    return 0;
}


Measured memory_bytes: 3304
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    count = 0
    for a in range(1, n + 1):
        for b in range(a, n + 1):
            if a == b:
                continue
            for c in range(b, n + 1):
                if a == c or b == c:
                    continue
                if a + b + c == x:
                    count += 1
    print(count)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

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

    int contnum=0;
    int flag =0;

    for(int i=0;i<N;++i){
        int D1,D2;
        cin >>D1 >> D2;

        if(D1==D2){
            ++contnum;
            if(contnum >= 3){
                flag =1;
            }
        }
        else{
            contnum =0;
        }
    }

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

}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long dp[55][55][55*55];
int x[55];
int main()
{
	int n,a;
	cin>>n>>a;
	for(int i=1;i<=n;i++)
		cin>>x[i];
	dp[1][1][x[1]]=1;
	for(int i=2;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=a*n;k++)
			{
				dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
				if(j==1)
					dp[i][j][k]+=(x[i]==k);
			}
	long long sum=0;
	for(int i=1;i<=n;i++)
		sum+=dp[n][i][a*i];
	cout<<sum<<endl;
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];

    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if (p[i] != max({p[i-1], p[i], p[i+1]}) && p[i] != min({p[i-1], p[i], p[i+1]})) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,c;
    cin >>a >> b >> c;
    if (a == b && b == c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PAIR;
const int N = 1e3+5;
const int INF = 0x3f3f3f3f;

inline void bfs(int n){
	int cnt = 0;
	priority_queue <ll,vector<ll>,greater<ll> > q;
	for(int i = 1;i <= 9;++i) q.push(i);
	
	while(!q.empty()){
		ll now = q.top();q.pop();
		cnt++;
		if(cnt == n){
			printf("%lld\n",now);
			return ;
		}
		
		ll temp = now%10;
		if(temp-1ll >= 0ll) q.push(now*10ll+temp-1ll);
		if(temp >= 0) q.push(now*10ll+temp);
		if(temp+1ll <= 9ll) q.push(now*10ll+temp+1ll);
	}
	return ;
}

int main(){
	int n;
	scanf("%d",&n);
	bfs(n);
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 1000100100000000
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m;
ll d[2005], a[2005], b[2005], c[2005], negative[2005], ans;
bool negative_loop() {
  rep(i, 0, 2005) d[i] = INF;
  d[0] = 0;
  rep(i, 0, n-1) {
    rep(j, 0, m) {
      if (d[a[j]] != INF && d[b[j]] > d[a[j]] + c[j]) {
        d[b[j]] = d[a[j]] + c[j];
      }
    }
  }
  ans = d[n-1];
  rep(i, 0, n) {
    rep(j, 0, m) {
      if (d[a[j]] != INF) {
        if (d[b[j]] > d[a[j]] + c[j]) {
          d[b[j]] = d[a[j]] + c[j];
          negative[a[j]] = true;
        }
        if (negative[a[j]]) negative[b[j]] = true;
      }
    }
  }
  return negative[n-1];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, 0, m) {
      cin >> a[i] >> b[i] >> c[i];
      a[i]--, b[i]--;
      c[i] = -c[i];
    }
    bool flag = negative_loop();
    if (flag) cout << "inf" << endl;
    else cout << -ans << endl;
    return 0;
}



Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
  // cin>>t;
    while(t--)
    {    
      int h,n;
      cin>>h>>n;
      int sum=0;
      int a[n];
      read(a,n);
      for(int i=0;i<n;i++)
      sum+=a[i];
      if(sum>=h)
      cout<<"Yes";
      else
      cout<<"No";
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 4412
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


a, b =  map(int, sys.stdin.readline().split())

x =int(str(a) + str(b))
r = math.sqrt(x)
if r == int(r):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 65900
#include <stdio.h>

int main(){
  int n,k,x,y;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &x);
  scanf("%d", &y);
  if (n>k){
    printf("%d\n", x*k+y*(n-k));
  }
  else{
    printf("%d\n", x*n);
  }

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>


int main()
{
  int n, i, ans=1, tmp=2;

  scanf("%d", &n);
  for (i=1; i<n+1; i++){
    if (i % tmp == 0){
      ans = i;
      tmp *= 2;
    }
  }
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!

from collections import defaultdict

N = int(input())

d = defaultdict(int)
for _ in range(N):
    a = int(input())
    d[a] += 1

count = 0
for key in d.keys():
    if d[key] % 2 == 1:
        count += 1
        
print(count)

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

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)

using namespace std;

const int inf = (int)1e9 + 7;
const int N = (int)2e5 + 7;

int n,m;

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

      cout << (n * m) - n - m + 1 << endl;
}


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

int main()
{
		int a[20000], b[20000], n, i;
		char op[20000];
		while (1) {
				cin >> a[n] >> op[n] >> b[n];
				if (op[n] == '?') break;
				n++;
		}

		for (i=0; i<n; i++) {
				switch (op[i])
				{
						case '+':
								cout << a[i]+b[i] << "\n";
								break;
						case '-':
								cout << a[i]-b[i] << "\n";
								break;
						case '*':
								cout << a[i]*b[i] << "\n";
								break;
						case '/':
								cout << a[i]/b[i] << "\n";
								break;
						case '?':
								break;
				}
		}
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
constexpr long long INF = 1e18;

template<class T, typename F> struct SparseTable {
private :
    F f;
    T id;
    vector<vector<T>> st;
    vector<int> index;
public :
    SparseTable (const vector<T> &v, const F &f, const T &id) : f(f), id(id) {
        int b = 0;
        while ((1<<b) <= (int)v.size()) b++;
        st.resize(b, vector<T>(1<<b, id));
        for (int i = 0; i < v.size(); i++) st[0][i] = v[i];
        for (int i = 1; i < b; i++) {
            for (int j = 0; j + (1<<i) <= (1<<b); j++) {
                st[i][j] = f(st[i-1][j], st[i-1][j+(1<<(i-1))]);
            }
        }
        index.resize((int)v.size() + 1);
        for (int i = 2; i < (int)index.size(); i++) {
            index[i] = index[i>>1] + 1;
        }
    }

    inline T query (int l, int r) {
        assert(l <= r);
        if (l == r) return id;
        int b = index[r-l];
        return f(st[b][l], st[b][r-(1<<b)]);
    }

};

int main() {
    int n;
    long long x;
    cin >> n >> x;
    vector<long long> a(n);
    for (auto& e : a) cin >> e;
    
    auto f = [](const long long &a, const long long &b) { return min(a, b); };
    SparseTable<long long, decltype(f)> st(a, f, INF);
    
    auto check = [&] (int k) {
        long long res = k * x;
        for (int i = 0; i < n; i++) {
            if (k <= i) res += st.query(i-k, i+1);
            else res += f(st.query(0, i+1), st.query(n-k+i, n));
        }
        return res;
    };
    
    int l = 0, r = n-1;
    while (abs(l - r) > 2) {
        int c1 = (l * 2 + r) / 3;
        int c2 = (l + r * 2) / 3;
        if (check(c1) > check(c2)) l = c1;
        else r = c2;
    }
    
    long long ans = INF;
    for (int i = l; i <= r; i++) chmin(ans, check(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    char pic[500][500], rpic[500][500], bpic[500][500];
    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            cin >> pic[i][j];
        }
    }

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            if((i%2==0 && j<w-1)||j==0)rpic[i][j]='#';
            else rpic[i][j]='.';
        }
    }

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            if((i%2==1 && j>0)||j==w-1)bpic[i][j]='#';
            else bpic[i][j]='.';
        }
    }

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            if(pic[i][j]=='#'){
                rpic[i][j]='#';
                bpic[i][j]='#';
            }
        }
    }

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            cout << rpic[i][j];
        }
        cout << endl;
    }
    cout << endl;

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            cout << bpic[i][j];
        }
        cout << endl;
    }
    cout << endl;
}

Measured memory_bytes: 1408
import os
import sys
from collections import deque

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

# 解説
K = int(sys.stdin.buffer.readline())
que = deque(list(map(str, range(1, 10))))
for _ in range(K - 1):
    # print(que)
    s = que.popleft()
    d = int(s[-1])
    if d > 0:
        que.append(s + str(d - 1))
    que.append(s + str(d))
    if d < 9:
        que.append(s + str(d + 1))
print(int(que[0]))


Measured memory_bytes: 17012
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
// int a[100010],n,j;
int main()
{
  
  string given;
  string needtomake;
  cin >> given >> needtomake;
  int minch=needtomake.length();
  int j=0;
   int first=0,second=needtomake.length()-1;
   int changes=0;
   while(second<given.length())
   {
      for(int i=first;i<=second;i++)
      {
        if(given[i]!=needtomake[j])
          changes++;
         j++;
      }
      j=0;
      minch=min(minch,changes);
      changes=0;
      first++;
      second++;
   }
   cout << minch << endl;
}

Measured memory_bytes: 3552
# ----- BIT -----
class Bit:
    """ used for only int(>=0) 
        1-indexed (ignore 0-index)
    """
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        self.depth = n.bit_length()
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def lower_bound(self, x):
        """ 累積和がx以上になる最小のindexと、その直前までの累積和 """
        sum_ = 0
        pos = 0
        for i in range(self.depth, -1, -1):
            k = pos + (1 << i)
            if k <= self.size and sum_ + self.tree[k] < x:
                sum_ += self.tree[k]
                pos += 1 << i
        return pos + 1, sum_

    def get_less_than_x_cnt(self, x):
        """ 累積和がx未満 の個数 """
        lb_pos, lb_sum = self.lower_bound(x)
        return lb_pos-1

    def get_less_than_and_x_cnt(self, x):
        """ 累積和がx以下 の個数 """
        lb_pos, lb_sum = self.lower_bound(x+1)
        return lb_pos-1
    
    def get_more_than_x_cnt(self, x):
        """ 累積和がxより大きい 個数 """
        return self.size - self.get_less_than_and_x_cnt(x)


def main():
    n = int(input())
    s = list(input())
    q = int(input())
    alps = 'abcdefghijklmnopqrstuvwxyz'

    
    alp_d = {chr(ord('a') + i): Bit(n) for i in range(26)}
    for i,si in enumerate(s):
        alp_d[si].add(i+1,1) 

    ansl = []
    for i in range(q):
        com,a,b = map(str, input().split())
        if com == '1':
            i,c = int(a),b
            si = s[i-1]
            alp_d[si].add(i, -1)
            alp_d[c].add(i, 1)
            s[i-1] = c
        else:
            l,r = int(a),int(b)
            ans = 0
            for alp in alps:
                cnt = alp_d[alp].sum(r) - alp_d[alp].sum(l-1)
                if cnt > 0:
                    ans+=1
            ansl.append(ans)

    for a in ansl:
        print(a)


if __name__ == "__main__":
    main()

Measured memory_bytes: 204208
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main(void)
{
    //freopen("input.txt", "r", stdin);
 
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    
    double pi = 3.141592653589793238;
    double ans2 = (double)m/60;
    double ans1 = ((double)h+ans2)/12;
    
    double ans3 = abs(ans1*2*pi - ans2*2*pi);
    
    double ans4 = (a*a)+(b*b);
    double ans5 = ans4 - 2*a*b*cos(ans3);
    double ans6 = sqrt(ans5);
    
    cout<<setprecision(21)<<fixed;
    cout<<ans6<<"\n";
 
    return 0;
}


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

namespace abc067_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool ret = false;
            if (x[0] % 3 == 0) ret = true;
            if (x[1] % 3 == 0) ret = true;
            if ((x[0] + x[1]) % 3 == 0) ret = true;
            Console.WriteLine(ret ? "Possible" : "Impossible");
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>

using namespace std;

vector< vector<int> > waterPairs;
vector< vector<int> > sugarPairs;

double maxConcentration = -1.0;
int water = -1;
int sugar = -1;

void generateWaterPairs(int a, int b, int f) {
	for(int i = 0; (i * 100 * a) <= f; i++) {
		for(int j = 0; ((i * 100 * a) + (j * 100 * b)) <= f; j++) {
			if((i == 0 && j == 0)) {
				continue;
			}
			vector<int> tmp;
			tmp.push_back((i * 100 * a));
			tmp.push_back((j * 100 * b));
			waterPairs.push_back(tmp);
		}
	}
}

void generateSugarPairs(int c, int d, int f) {
	for(int i = 0; (i * c) <= f; i++) {
		for(int j = 0; ((i * c) + (j * d)) <= f; j++) {
			vector<int> tmp;
			tmp.push_back(i * c);
			tmp.push_back(j * d);
			sugarPairs.push_back(tmp);
		}
	}
}

void solve(int e, int f) {
	for(int i = 0; i < waterPairs.size(); i++) {
		for(int j = 0; j < sugarPairs.size(); j++) {
			int a = (waterPairs[i][0]) + (waterPairs[i][1]);
			int b = (sugarPairs[j][0] + sugarPairs[j][1]);
			double concentration = 100.0 * b / (double) (a + b);
			if((concentration > maxConcentration) && (( 100.0 * (double) b / (double) a) <= e) && ((a + b) <= f)) {
				maxConcentration = concentration;
				sugar = b;
				water = a;
			}
		}
	}
}

int main() {
	int a, b, c, d, e, f;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	cin >> f;

	generateWaterPairs(a, b, f);
	generateSugarPairs(c, d, f);
	solve(e, f);

	if(water == -1) {
		cout << (100 * a) << " " << sugar << endl;
		return 0;
	}
	cout << (water + sugar) << " " << sugar << endl;
	
	return 0;
}

Measured memory_bytes: 13996
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

ll A, B;

bool isOK(vector<ll>& H, ll mid) {
//    printf("--------------------------------------------------\n");
    ll cnt = 0;
    ll D = A - B;
    for (int i = 0; i < H.size(); i++) {
        ll d = H[i] - B * mid;
        if (d <= 0) {
//            printf("Monster (HP: %ld) died by %ld times B\n", H[i], mid);
            continue;
        }
        cnt += (d + (D - 1)) / D;
//        printf("Monster (HP: %ld) was died by A %ld times and B %ld times\n", H[i], (d + (D - 1))/ D, mid);
    }
    return cnt <= mid;
}

int main() {
    ll N; cin >> N >> A >> B;
    vector<ll> H(N);
    rep(i,N) {
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    ll left = -1;
    ll right = (H[N-1] + (B - 1)) / B;
    while (right - left > 1) {
        ll mid = left + (right - left) / 2;
        if (isOK(H, mid)) right = mid;
        else left = mid;
    }

    cout << right << endl;
}


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

using namespace std;
using ll=long long;

int main(){
    int n;
    cin>>n;
    set<int> a;
    for (int i = 0; i < n; ++i) {
        int b;
        cin>>b;
        if(!a.insert(b).second){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int a[N+1], b[N+1] = {};
    rep(i, N) cin >> a[i+1];
    for (int i = N; i > 0; i--) {
        int sum = 0;
        for (int j = i + i; j <= N; j += i) {
            sum ^= b[j];
        }
        b[i] = sum ^ a[i];
    }

    vector<int> ans;
    rep(i, N) {
        if (b[i+1]) ans.push_back(i+1);
    }

    cout << ans.size() << endl;
    if (ans.size()) {
        for (int i: ans) cout << i << " ";
        cout << endl;
    }
}

Measured memory_bytes: 3064
// go:generate go-assets-builder > assets.go

package main

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

type input struct {
	pos     int
	year    int
	sortNum int
}

type inputs []input

func (input inputs) Len() int {
	return len(input)
}
func (input inputs) Swap(i, j int) {
	input[i], input[j] = input[j], input[i]
}
func (input inputs) Less(i, j int) bool {
	return input[i].year < input[j].year
}
func (input inputs) remove(i int) inputs {
	if i >= len(input) {
		return input
	}
	return append(input[:i], input[i+1:]...)
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Split(bufio.ScanLines)
	n := readInt()
	m := readInt()
	numMap := make(map[int][]int)
	yearArr := make([]int, 0, m)
	for i := 0; i < m; i++ {
		cityNum := readInt()
		year := readInt()
		numMap[cityNum] = append(numMap[cityNum], year)
		yearArr = append(yearArr, year)
	}

	yearMap := make(map[int]string)
	for i := 1; i <= n; i++ {
		arr := numMap[i]
		sort.Ints(arr)
		for j, v := range arr {
			yearMap[v] = fmt.Sprintf("%06d%06d", i, j+1)
		}
	}
	for _, year := range yearArr {
		fmt.Println(yearMap[year])
	}
}

//便利関数群
var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, _ := strconv.Atoi(read())
	return i
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func abs(x, y int) int {
	if x-y > 0 {
		return x - y
	}
	return -(x - y)
}

type XY struct {
	x, y int
}

type Points []XY

func (p Points) Len() int {
	return len(p)
}
func (p Points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func (p Points) Less(i, j int) bool {
	return p[i].x < p[j].x
}
func (p Points) remove(i int) Points {
	if i >= len(p) {
		return p
	}
	return append(p[:i], p[i+1:]...)
}


Measured memory_bytes: 21376
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

N abs(N)(N a) {
  return (a < 0 ? -1 : 1) * a;
}

enum MOD = 10L^^9 + 7;

long fact(long n) {
  if (n <= 1) {
    return 1;
  } else {
    return n * fact(n - 1) % MOD;
  }
}

void main() {
  long[] NM = readln.chomp.split.to!(long[]);
  long N = NM[0],
       M = NM[1];

  if (N == M || abs(N - M) == 1) {
    long k = 1;
    if (N == M) {
      k = 2;
    }
    writeln(k * fact(N) * fact(M) % MOD);
  } else {
    writeln(0);
  }
}


Measured memory_bytes: 3452
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
#define int long long
using namespace std;
using point = pair< int,int >;

signed main() {
    int a;
    string s;
    cin >> a >> s;

    OUT((a < 3200 ? "red" : s));
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <stdio.h>

using namespace std;

int main(){
	stack<int> s;
	char c;
	int l, r;
	while((c = getchar()) != EOF && c != '\n'){
		switch(c){
		case ' ':
			continue;
		case '+':
			l = s.top(); s.pop();
			r = s.top(); s.pop();
			s.push(r + l);
			break;
		case '-':
			l = s.top(); s.pop();
			r = s.top(); s.pop();
			s.push(r - l);
			break;
		case '*':
			l = s.top(); s.pop();
			r = s.top(); s.pop();
			s.push(r * l);
			break;
		default:
			ungetc(c, stdin);
			cin >> l;
			s.push(l);
		}
	}

	cout << s.top() << endl;
	return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 100000 + 1;
int a[maxn], b[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int A, B, M;
    cin >> A >> B >> M;
    for(int i = 1; i <= A; i += 1) cin >> a[i];
    for(int i = 1; i <= B; i += 1) cin >> b[i];
    int ans = *min_element(a + 1, a + A + 1) + *min_element(b + 1, b + B + 1);
    for(int i = 1, x, y, c; i <= M; i += 1){
        cin >> x >> y >> c;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  const int V = 1000 * 100;
  int n, W; cin >> n >> W;
  vector<ll> dp(V + 1, 1e18);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    int w, v; cin >> w >> v;
    for (int j = V; j >= v; j--) {
      dp[j] = min(dp[j], w + dp[j - v]);
    }
  }
  for (int v = V; v >= 0; v--) {
    if (dp[v] <= W) {
      cout << v << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
import numpy as np
n,m=map(int,input().split())
a=np.zeros(n)
b=np.zeros(n)
for i in range(n):
    a[i],b[i]=map(int,input().split())
x=np.argsort(a)
ans=0
i=0
while m>0:
    ans+=a[x[i]]*min(b[x[i]],m)
    m-=b[x[i]]
    i+=1
print(int(ans))

Measured memory_bytes: 14812
#include<bits/stdc++.h>
using namespace std;
map<char,int> mp[10010];
int main(){
	int n,i,j;
	cin>>n;
	getchar();
	for(i=1;i<=n;i++){
		string s;
		getline(cin,s);
		for(j=0;j<s.size();j++){
			mp[i][s[j]]++;
		}
	}
	string ans;
	for(char k='a';k<='z';k++){
		int t=0x3f3f3f;
		for(i=1;i<=n;i++){
			t=min(t,mp[i][k]);
		}
		if(t>0){
			for(j=1;j<=t;j++){
				ans+=k;
			}
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
    int A, B; cin >> A >> B;
    vector<int> Num(4);
    Num = {A, B, A - 1, B - 1};
    sort(Num.begin(), Num.end());
    cout << Num.at(3) + Num.at(2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define infll 0x7fffffffffffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=998244353;
const int M=1e6+10;
const int N=2e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
struct node{
	int x,y;
	int nx;
	ll a,b;
}e[300];
struct city{
	ll c,d;
}c[300];
int head[300],ecnt;
int T,n,m,k,s;
ll dis[100][2600];
void add(int x,int y,int a,int b) {
	ecnt++;
	e[ecnt].x=x; e[ecnt].y=y;
	e[ecnt].a=a; e[ecnt].b=b;
	e[ecnt].nx=head[x];
	head[x]=ecnt;
}
void input() {
	n=read(),m=read(),s=read();
	for(int i=1;i<=m;i++) {
		int x=read(),y=read();
		int a=read(),b=read();
		add(x,y,a,b);
		add(y,x,a,b);
	}
	for(int i=1;i<=n;i++) {
		int cc=read(),d=read();
		c[i].c=cc; c[i].d=d;
	}
}
void solve() {
	int i,j;
	queue<pair<ll ,ll > > q;
	
	dis[1][s]=0;
	q.push({1,s});
	while(q.size()) {
		ll x=q.front().first,w=q.front().second;
		q.pop();
		for(i=head[x];i;i=e[i].nx) {
			ll y=e[i].y;
			ll a=e[i].a,b=e[i].b;
			ll wei=w-a;
			if(wei>=0&&dis[y][wei]>dis[x][w]+b) {
				dis[y][wei]=dis[x][w]+b;
				q.push({y,wei});
			} 	
		}	
		ll cc=c[x].c,d=c[x].d;
		ll wei=min(2500ll,cc+w);
		if(dis[x][wei]>dis[x][w]+d) {
			dis[x][wei]=dis[x][w]+d;
			q.push({x,wei});
		}
	}
}
int main()
{
    int i,j;
    input();
    for(i=1;i<=n;i++) {
    	for(j=0;j<=2500;j++) dis[i][j]=infll/100ll;
	}
	s=min(s,2500);
	solve();
    for(i=2;i<=n;i++) {
    	ll ans=infll;
		for(j=0;j<=2500;j++) ans=min(ans,dis[i][j]); 
    	printf("%lld\n",ans);
	}
    return 0;
}


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

int main(){
	double n,k;
	cin >> n >>k;
	vector<double> p(n);
	rep(i,n) cin >> p[i];
	double kitai = 0;
	vector<double> ans(n);
	rep(i,n) ans[i] = (p[i]+1)/2;
	rep(i,k) kitai += ans[i];
	double wa = kitai;
	rep(i,n-k+1){
		wa = wa - ans[i] + ans[i+k];
		kitai = max(kitai,wa);
	}

	cout << fixed << setprecision(15) <<  kitai << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 6468
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    mod = 1000000007
    N = ri()
    A  = ril()
    x = sum(A) ** 2
    y = sum(list(map(lambda i : i * i, A)))
    ans = ((x - y) // 2) % mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31636
'use strict';

const main = (arg) => {
  const input = arg.trim().split('\n');
  const [ab, bc, ca] = input[0].split(' ').map(Number);
  const ans = (ab * bc) / 2;
  console.log(ans);
};

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define reunique(a) (a).resize(unique(all(a)) - (a).begin())
#define ld long double
#define int long long

void SOLVE(){
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(all(a));
    int ans = 1e18;
    for (int i = a[0]; i <= a.back(); i++){
        int cur = 0;
        for (int j = 0; j < n; j++){
            cur += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, cur);
    }
    cout << ans;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int Q = 1;
    //cin >> Q;
    while (Q--){
        SOLVE();
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include<set>
#include <map>
using namespace std;


   
#include <iostream>

using namespace std;
int n,m;

int main()
{
    cin >> n >> m ;
    int A[m-1];
    int sum=0;
    for (int i=0; i<m; i++) {
        cin >> A[i];
        sum += A[i];
        
    }
    if (sum > n) {
        cout << "-1" << endl;
    }else{
        cout << n-sum << endl;
    }
    
   return 0;
}


Measured memory_bytes: 3136
#include "bits/stdc++.h"
#include <iostream>
using namespace std;
#define ll = long long;
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e+9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
	int x, y;
	cin >> x >> y;
	if (x < 10 && y < 10) {
		cout << x * y << endl;
	}
	else {
		cout << -1 << endl;
	}
}
/*


  　　　 _」_
　 　×´　　　  _,,..-──-､,_ｧo､__　　  ｀メ.
　　/　    ,  '"´　 　　　   （-､__oヽ　　　_|__
　 　　　／　　　　　　　　 　 ｀ヽ.ヽﾊ）　 　ﾉ
　　　 ／　　　　　　　　　　　  　 Y⌒ヽ.
　　  /　　 /　　　　　　     ヽ.　 |　　',
　　 ,'　　!　　,　 /!　,| ＿   !.　|　　 !　　
　　　|　  |.__/|_ ,'| / ! __｀./! /|　　 |
　　　|　　|´/ |_/  ﾚ' ｧ'´￣` |／､ﾄ、 　|　　奇跡を起こして計算量をO(N)にします!
　　  '､　 |/ｧ'´￣`  　　　,,　|　|ｿ   　ﾊ　　
　　 　 ＼,ハ ,,　　 '　   　（ ＼|　 / .|
　　　 　 | ﾊ、　i7´￣｀i  ,/ ＼_）,'　 |
　　　　 ,'/｀＞ ､,｀   ,.イ/＼＿_! !　  !　　|
　　 　　/　 /｀     T7´／/ヽ､_＿ﾉ_| 　 |__,メ
　　 　　|  .|r/´`ｰ'-､／　,'./  /::/｀ヽ /
　　　　 八　i/      rﾉ,!￣ヽ､| /:/ 　  i_
　　  　,' X`;くﾄ  ､ノ､　/ﾍ｀ヽ．Y    ／::>
　　　　!　// |::|/.|::|＼/ﾉ 八__ノr:':::／/
　　　　|／　 |::|./|::|/　 ）'ﾉ:/--‐'','
　  　  /　　 八:' _ﾉ::ﾉ　 _,.ｲ／　　　　|
　　 　,'　　　 ＼_ ／,|　 　／　　　 　 !
　　　 |　　　　　　  /|　 ／ 　　　/ 　 |
*/


Measured memory_bytes: 256
N,K=map(int,input().split())
A=0
for a in range(100000000000000):
    if N>K:
        kot=N%K
        if abs(K-kot)>kot:
            print(kot)
            break
        else:
            print(abs(K-kot))
            break
    if N%K==0:
        print(0)
        break
    if N<K:
        if abs(N-K)<N:
            print(abs(N-K))
            break
        else:
            print(N)
            break
    tugi=abs(N-K)
    N=tugi
    A=tugi
    tugi=abs(N-K)
    B=tugi
    N=tugi
    tugi=abs(N-K)
    if A==tugi:
        if B<A:
            print(B)
            break
        else:
       	    print(A)
            break

Measured memory_bytes: 9228
import sys
input = sys.stdin.readline

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	n=int(input())
	vA=linput()
	
	res = 0
	pp = 0
	
	for a in vA:
		if pp==a:
			res += 1
			pp = 0
		else:
			pp = a
	
	#sT = "No Yes".split()
	#print(sT[res])
	print(res)

if __name__ == "__main__":
	main()


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

int main(){
  int A, B;
  cin >> A >> B;
  // A = 2K - B
  // A < K < B
  // K = (A + B) / 2
  if ((A + B) % 2 == 0){
    int K = (A + B) / 2;
    cout << K << endl;
  } else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256