akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

struct Edge{
    int d, e;
};

const int N = 105;
Edge M[N][N];
bool can_use[N][N];
int n, m, l;

void bfs(int n){
    int dis[N]; //?????¢
    queue<int> q; //?¨??????????????????\??????
    rep(i,N) dis[i] = 0;

    dis[0] = l;
    q.push(0);

    int u;
    while(!q.empty()){
        u = q.front(); q.pop();
        rep(v,n){
            if(dis[v] <= dis[u] - M[u][v].d && dis[u] - M[u][v].d >= 0){
                dis[v] = dis[u] - M[u][v].d; //??°???????????±??? 
                can_use[u][v] = true;
                cout << u << ' ' << v << endl;
                q.push(v);
            }
        }
    }
}

int bfs_(int n){
    int dis[N];
    queue<int> q;
    rep(i,N) dis[i] = INF;

    dis[0] = 0;
    q.push(0);

    int u;
    while(not q.empty()){
        u = q.front(); q.pop();
        rep(v,n){
            if(dis[v] > dis[u] + (can_use[u][v] ? 0 : M[u][v].e)){
                dis[v] = dis[u] + (can_use[u][v] ? 0 : M[u][v].e);
                q.push(v);
            }
        }
    }
    return dis[n - 1];
}

const int MAX_V = 105;

void init(int m[MAX_V][MAX_V]){
    rep(i,MAX_V) rep(j,MAX_V) m[i][j] = INF;
    rep(i,MAX_V) m[i][i] = 0;
}

void warshallFloyd(){
    int node[105][MAX_V];
    rep(i,105) rep(j,MAX_V) node[i][j] = INF;
    node[l][0] = 0;

    for(int o = l; o >= 0; o--){
        bool loop = true;
        while(loop){
            loop = false;
            rep(i,n){
                rep(j,n){
                    int tmp = o - M[i][j].d;
                    if(tmp >= 0){
                        if(node[tmp][j] > node[o][i]){
                            node[tmp][j] = node[o][i];
                            loop = true;
                        }
                    }
                    if(node[o][j] > node[o][i] + M[i][j].e){
                        node[o][j] = node[o][i] + M[i][j].e;
                        loop = true;
                    }
                }
            }
        }
        //rep(i,n){ show(node[o][i]) } cout << endl;
    }
    //cout << endl;

    int mini = INF;
    rep(i,l + 1){
        mini = min(mini, node[i][n - 1]);
    }
    cout << mini << endl;
    return;
}

int main(){
    while(cin >> n >> m >> l,n){
        rep(i,N) rep(j,N) M[i][j] = Edge{INF,INF};
        memset(can_use, 0, sizeof(can_use));
        rep(i,m){
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            a--; b--;
            M[a][b] = Edge{d,e};
            M[b][a] = Edge{d,e};
        }
        warshallFloyd();
        //bfs(n);
        //cout << bfs_(n) << endl;
    }


}

Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<pair<int, int>> primeFact(int n) {
  vector<pair<int, int>> res;
  for (int i = 2; i * i <= n; i++) {
    int divcnt = 0;
    if (n % i == 0) {
      do {
        divcnt++;
        n /= i;
      } while (n % i == 0);
      res.emplace_back(i, divcnt);
    }
  }
  if (n != 1)
    res.emplace_back(n, 1);
  return res;
}

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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  sort(ALL(A));
  A.erase(unique(ALL(A)), A.end());
  N = A.size();

  int g = A.back();
  REP(i, N-1){
    g = gcd(A[i], g);
  }

  if(g != 1){
    cout << "not coprime" << "\n";
    return 0;
  }

  int MAX = 1000010;
  vector<bool> cnt(MAX, false);

  REP(i, N){
    auto pri = primeFact(A[i]);
    for(auto p : pri){
      if(cnt[p.first]){
        cout << "setwise coprime" << "\n";
        return 0;
      }
      cnt[p.first] = true;
    }
  }

  cout << "pairwise coprime" << "\n";

  return 0;
}


Measured memory_bytes: 11180
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var n = int.Parse(Console.ReadLine());
            string[] input = test.ReadInput();
            string s = input[0];
            string t = input[1];
            char[] cs = s.ToCharArray();
            char[] ts = t.ToCharArray();
            var sb = new StringBuilder();

            for (var i = 0; i < n; i++)
            {
                sb.Append(cs[i]).Append(ts[i]);
            }

            Console.WriteLine(sb.ToString());
        }


        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }
    }
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int n, m;
  cin >> n >> m;
  vii G(n);
  rep (i, m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
  }

  int s, t;
  cin >> s >> t;
  s--; t--;

  vii dist(n, vi(3, inf));
  dist[s][0] = 0;
  queue<pii> qu;
  qu.push(pii(s, 0));
  while (!qu.empty()) {
    int u = qu.front().first, c = qu.front().second;
    qu.pop();
    rep (i, G[u].size()) {
      int v = G[u][i];
      if (dist[v][(c + 1) % 3] > c + 1) {
        dist[v][(c + 1) % 3] = c + 1;
        qu.push(pii(v, c + 1));
      }
    }
  }

  if (dist[t][0] == inf) {
    cout << -1 << endl;
  }
  else {
    cout << dist[t][0] / 3 << endl;
  }
}


Measured memory_bytes: 11136
#include <stdio.h>

int a[10005];

int main(){

	int N;

	scanf("%d",&N);

	int i;

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

	int cnt=0;
	for(i=0;i<N;i++){
		while(1){
			if(a[i]%2==0){
				cnt++;
				a[i]/=2;
			}
			else{
				break;
			}
		}
	}

	printf("%d\n",cnt);

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

while True:
	n = int(raw_input())
	if n == 0:
		break
	henkan = []
	for i in range(n):
		henkan.append(raw_input().split())

	m = int(raw_input())
	ans = ""
	for i in range(m):
		c = raw_input().split()
		for j in range(len(henkan)):
			if c[0] == henkan[j][0]:
				c[0] = henkan[j][1]
				break
		ans += c[0]
	print ans

Measured memory_bytes: 7732
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int n;
  int k;
  scanf("%d", &n);
  scanf("%d", &k);

  int d = 0;
  while (n > 0) {
    n /= k;
    d++;
  }

  printf("%d\n", d);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    h.push_back(temp);
  }
  sort(h.begin(), h.end(), greater<int>());

  int ans = 1000000000;
  for(int i = 0; i <= n-k; i++){
    int temp;
    temp = h[i] - h[i + k - 1];
    if(ans > temp){
      ans = temp;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main()
{
    // 500円a枚、100円b枚、50円c枚、合計x円
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int patternNum = 0;

    int upper500Num = a;
    if(x/500 < a)
    {
        upper500Num = x/500;
    }

    for(int i = 0; i <= upper500Num; i++)
    {
        int upper100Num = b;
        if((x-500*i)/100 < b)
        {
            upper100Num = (x-500*i)/100;
        }
        for(int j = 0; j <= upper100Num; j++)
        {
            // 残金が50円玉の所持金以下ならOK
            if(x-500*i-100*j <= 50*c)
            {
                patternNum++;
            }
        }
    }

    cout << patternNum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char ch;
    int num[26] = {0};
    int i;
    while ( scanf("%c", &ch) != EOF ){
        //scanf("%c",&ch);
        for(i=0;i<26;i++){
            if(ch==i+65){
                num[i]++;
                break;
            }else if(ch==i+97){
                num[i]++;
                break;
            }
        }
        
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",i+97,num[i]);
    }
    return 0; /*0?????????*/
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(7e5)+10;
int n,a[maxn],b[maxn],c[maxn],d[maxn];
int N,S[maxn];
int sa[maxn],rk[maxn];
int SA[maxn],RK[maxn];
int h[maxn],st[maxn][22];
int cnt[maxn],lg[maxn];
int f[maxn],tot;
void initSA() {
	for (int i=1;i<=N;i++) cnt[S[i]]++;
	for (int i=1;i<=tot;i++) cnt[i]+=cnt[i-1];
	for (int i=1;i<=N;i++) sa[cnt[S[i]]--]=i;
	for (int i=1;i<=N;i++) rk[sa[i]]=rk[sa[i-1]]+(S[sa[i]]!=S[sa[i-1]]);
	for (int j=1;j<=N;j*=2) {
		for (int i=1;i<=N;i++) cnt[rk[sa[i]]]=i;
		for (int i=N;i>=1;i--) if (sa[i]>j) SA[cnt[rk[sa[i]-j]]--]=sa[i]-j;
		for (int i=N;i>=1;i--) if (sa[i]>N-j) SA[cnt[rk[sa[i]]]--]=sa[i];
		for (int i=1;i<=N;i++) RK[SA[i]]=RK[SA[i-1]]+(rk[SA[i]]!=rk[SA[i-1]]||rk[SA[i]+j]!=rk[SA[i-1]+j]);
		swap(sa,SA); swap(rk,RK);
		if (rk[sa[N]]>=N) break;
	}
	//for (int i=1;i<=N;i++) printf("%d ",rk[i]); printf("\n");
	//for (int i=1;i<=N;i++) printf("%d ",sa[i]); printf("\n");
}
void initH() {
	for (int i=1,j,lst=1;i<=N;i++) {
		j=sa[rk[i]-1]; if (lst) lst--;
		while (S[i+lst]==S[j+lst]) lst++;
		h[rk[i]]=lst;
	}
	for (int i=1;i<=N;i++) st[i][0]=h[i];
	//for (int i=1;i<=N;i++) printf("%d ",h[i]); printf("\n");
	for (int j=1;(1<<j)<=N;j++)
	for (int i=(1<<j);i<=N;i++)
		st[i][j]=min(st[i][j-1],st[i-(1<<(j-1))][j-1]);
}
int STQ(int l,int r) {
	if (l>r) swap(l,r);
	int j=lg[r-l];
	return min(st[r][j],st[l+(1<<j)][j]);
}
pair<int,int> ans[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(c[i]); c[0]=c[n];
	for (int i=1;i<=n;i++) a[i]=c[i]^c[i-1];
	for (int i=1;i<=n;i++) read(d[i]); d[0]=d[n];
	for (int i=1;i<=n;i++) b[i]=d[i]^d[i-1];
	//for (int i=1;i<=n;i++) printf("%d ",a[i]); printf("\n");
	//for (int i=1;i<=n;i++) printf("%d ",b[i]); printf("\n");
	for (int i=1;i<=n;i++) f[++tot]=a[i],f[++tot]=b[i];
	sort(f+1,f+tot+1);
	for (int i=1;i<=n;i++) a[i]=lower_bound(f+1,f+tot+1,a[i])-f,b[i]=lower_bound(f+1,f+tot+1,b[i])-f;
	for (int i=1;i<=n;i++) b[i+n]=b[i],S[i]=a[i];
	for (int i=n+1;i<=n*3;i++) S[i]=b[i-n];
	N=n*3;
	for (int j=1;(1<<j)<=N;j++)
	for (int i=(1<<j);i<(1<<(j+1))&&i<=N;i++) lg[i]=j;
	initSA(); initH();
	//for (int i=1;i<=N;i++) printf("%d ",S[i]); printf("\n");
	tot=0;
	for (int i=1;i<=n;i++) {
		if (STQ(rk[1],rk[i+n])>=n) ans[++tot]=make_pair((n-i+1)%n,d[i]^c[1]);
	}
	sort(ans+1,ans+tot+1);
	for (int i=1;i<=tot;i++) printf("%d %d\n",ans[i].first,ans[i].second);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 93056
#include<iostream>

int main(){
	int a, b, c;
	std::cin >> a;
	std::cin >> b;
	std::cin >> c;
	if (a < b){
		if (b < c)
			std::cout << "Yes" << '\n';
		else
			std::cout << "No" << '\n';
	}
	else
		std::cout << "No" << '\n';
}

Measured memory_bytes: 1124
def gcd(a, b):
    r1 = a
    r2 = b
    while True:
        r = r1 % r2
        if r == 0:
            return r2
        else:
            r1 = r2
            r2 = r

a, b = list(map(int, input().split()))
print(gcd(a, b))


Measured memory_bytes: 5600
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<" "<<b<<endl;
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl;
#define debug4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define _for(a,b,c) for(int i=a; i<b; i+=c)
#define __for(a,b,c) for(int j=a; j<b; j+=c)
#define ___for(a,b,c) for(int k=a;k<b; k+=c)
#define Oo ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
typedef long long ll;
int main()
{
      Oo
      string s;
      cin>>s;
      for (int i=0; i<s.size()-1; i++)
      {
            if (s[i]==s[i+1])
            {
                  cout << i+1<< " " << i+2 << endl;
                  return 0;
            }
      }
      for (int i=0; i<s.size()-2; i++)
      {
            if (s[i]==s[i+2])
            {
                  cout << i+1<< " " << i+3 << endl;
                  return 0;
            }
      }
      cout << -1 << " " << -1 << endl;
	return 0;
}



Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long int a,b;
    cin>>a>>b;
    vector<int>v;
    for(int i=b-1;i>b-a;i--)
    {
        v.push_back(i);
    }
    for(int i=b+1;i<b+a;i++)
    {
        v.push_back(i);
    }
    v.push_back(b);
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    cout<<v[i]<<" ";
    
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<iomanip>
using namespace std;
#define rep(i,s,n);for(int i = s;i<n;i++)
#define repe(i,s,n);for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int INF = 1<<29;
const int MOD = 1000000009;
int dy[]={-1,0,1,0,1,-1,-1,1,0};
int dx[]={0,1,0,-1,1,1,-1,-1,0};


int main(){
    ios::sync_with_stdio(0);
	
	ll a, b;
	cin >> a >> b;
	a -= 2;
	b -= 2;
	if (a == -1) {a = 1;}
	if (b == -1) {b = 1;}
	cout << a*b;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int W=sc.nextInt();
        int H=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        int r=sc.nextInt();
        if(x+r<=W && y+r<=H && x-r>=0 && y-r>=0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26176
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;
ll ina, inb;
ll a, b;

bool check(ll k){
  return ina * k >= a && inb * k >= b;
}

int main(){
  cin >> n;
  cin >> ina >> inb;
  a = ina; b = inb;
  rrep(i,n-1){
    cin >> ina >> inb;
    if(ina * b == inb * a) continue;

    ll k1, k2;
    k1 = a/ina; k2 = b/inb;
    if(a%ina != 0) k1++;
    if(b%inb != 0) k2++;
    ll k = max(k1, k2);
    a = ina*k; b = inb*k;
  }
  cout << a + b << endl;
  return 0;
}


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

using namespace std;

int h,w;
int sy,sx,gy,gx;
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
char board[1001][1001];
int dist[1001][1001];
const int INF = 1e9;

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

	cin >> h >> w;
	cin >> sy >> sx;
	cin >> gy >> gx;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin >> board[i][j];
			dist[i][j] = INF;
		}
	}

	priority_queue <pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pque;
	dist[sy][sx] = 0;
	pque.push(make_pair(dist[sy][sx],make_pair(sy,sx)));

	while(!pque.empty())
	{
		int y = pque.top().second.first;
		int x = pque.top().second.second;
		if(dist[y][x] < pque.top().first)
		{
			pque.pop();
			continue;
		}
		pque.pop();

		for(int k=0;k<4;k++)
		{
			int ny = y + dy[k];
			int nx = x + dx[k];
			if(ny<=0 || ny>h || nx<=0 || nx>w)
			{
				continue;
			}
			if(board[ny][nx]=='.')
			{
				if(dist[ny][nx] > dist[y][x])
				{
					dist[ny][nx] = dist[y][x];
					pque.push(make_pair(dist[ny][nx],make_pair(ny,nx)));
				}
			}
		}
		for(int ny=max(1,y-2);ny<=min(h,y+2);ny++)
		{
			for(int nx=max(1,x-2);nx<=min(w,x+2);nx++)
			{
				if(board[ny][nx]=='.')
				{
					if(dist[ny][nx] > dist[y][x] + 1)
					{
						dist[ny][nx] = dist[y][x] + 1;
						pque.push(make_pair(dist[ny][nx],make_pair(ny,nx)));
					}
				}
			}
		}
	}

	if(dist[gy][gx]==1e9)
	{
		cout << -1 << '\n';
	}
	else
	{
		cout << dist[gy][gx] << '\n';
	}
	return 0;
}

Measured memory_bytes: 8664
s = input()

alp = "abcdefghijklmnopqrstuvwxyz"

ans = float("inf")
for al in range(26):

    sc = s

    for j in range(len(s)):

        dic = {}
        for k in sc:
            dic[k] = 1

        if len(dic) == 1:
            #print (sc)
            ans = min(ans,j)
            break

        now = ""
        for k in range(len(s)-j-1):

            if sc[k] == alp[al] or sc[k+1] == alp[al]:
                now += alp[al]
            else:
                now += sc[k]


        for j in now:
            dic[j] = 1

        if len(dic) == 1:
            ans = min(ans,j)

        sc = now

print (ans)


Measured memory_bytes: 43116
x = int(input())

n = 100003
L = [True] * (n+1)
L[0] = False
L[1] = False

for i in range(2, n//2):
    if L[i]:
        mul = 2
        while i * mul <= n:
            L[i * mul] = False
            mul += 1

for i in range(x, n+1):
    if L[i]:
        print(i)
        break

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 1e5 + 5;

vector < int > V[N];
int T[N],t,ok,K;

int f(int x, int p){
    if(ok == 0) return 0;
    vector < int > v;
    if(V[x].size() % 2 == 1) v.pb(0);
    for(int y, i=0; i<V[x].size(); i++)
        if((y = V[x][i]) != p){
            v.pb( f(y,x)+1 );
            if(ok == 0) return 0;
        }
    sort(v.begin() , v.end());
    if(x == 1){
        t = v.size();
        for(int i=0; i<t; i++)
            if(v[i] + v[t-i-1] > K) return ok=0;
        return 0;
    }
    int i,l,m,r;
    l = 0;
    r = v.size();
    for(;l < r;){
        m = l+r >> 1;
        t = 0;
        for(i=0;i<v.size();i++)
            if(i != m)
                T[++t] = v[i];
        
        for(i=1;i<=t/2;i++)
            if(T[i] + T[t-i+1] > K)
                break;
        if(i <= t/2) l = m+1;
        else r = m;
    }
    if(l == v.size()) return ok=0;
    return v[l];
}

int n,i,x,y,a,l,m,r;
int main(){
    cin >> n;
    for(i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        V[x].pb(y); V[y].pb(x);
    }
    
    a = 1;
    for(i=1;i<=n;i++)
        a += (int)V[i].size()-1 >> 1;
        
    l = n/a-1;
    r = n;
    for(; l<r ;){
        m = l+r >> 1;
        ok = 1;
        K = m;
        f(1,-1);
        if(ok) r = m;
        else l = m+1;
    }
    
    cout << a << " " << l << endl;
    return 0;
}


Measured memory_bytes: 14976
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(void){
	int a[100001],junban[100001];
	int n;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		junban[a[i]] =i ;

	}
	for (int j = 1; j <= n; j++) {
		printf("%d ", junban[j]);
	}
	
  return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#include <tuple>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000000; //10^18
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}



int main(void) {

  ll n, k, a[200100];
  cin >> n >> k;
  rep(i, n) cin >> a[i];

  ll l = 0, r = 10000000001;

  while (r - l > 1) {
    ll t = 0;
    ll med = (l+r)/2;
    rep(i, n) {
      ll s = a[i]/med;
      if (a[i] == s*med) s--;
      t += s;
      if (t > k) break;
    }
    //cout << t << endl;
    if (t > k) l = med;
    else r = med;
  }

  cout << r << endl;

}


Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    string s; cin>>s;
    ll res=0;
    rep(i, n-1){
        map<char, ll> m1, m2;
        ll cnt=0;
        for(ll j=0; j<=i; j++){
            if(m1[s[j]]==0){
                m1[s[j]]=1;
            }
        }
        for(ll j=i+1; j<n; j++){
            if(m2[s[j]]==0){
                m2[s[j]]=1;
            }
        }
        for(char c='a'; c<='z'; c++){
            if(m1[c]>0 && m2[c]>0) cnt++;
        }
        chmax(res, cnt);
    }
    cout<<res<<endl;
    return 0;
}


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

int main() {
  int w, a, b;
  cin >> w >> a >> b;

  if ((a + w) < b)
    cout << b - (a + w) << endl;
  else if ((b + w) < a)
    cout << a - (b + w) << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll DP[3002][3002][4],L[3002][3002];

int main(){
  ll R,C,K;
  cin>>R>>C>>K;
  
  for(int i=0; i<=3001; ++i){
    for(int j=0; j<=3001; ++j){
      L[i][j]=-1;
      for(int k=0; k<4; ++k){
        DP[i][j][k]=0;
      }
    }
  }
  
  ll RR[K],CC[K],VV[K];
  REP(i,K){
    cin>>RR[i]>>CC[i]>>VV[i];
    L[RR[i]][CC[i]]=VV[i];
  }
  
  
  for(int i=1; i<=3001; ++i){
    for(int j=1; j<=3001; ++j){
      for(int k=0; k<4; ++k){
        if(L[i][j]!=-1){
          if(k<3) chmax(DP[i][j][k+1],DP[i][j-1][k]+L[i][j]);
          chmax(DP[i][j][1],DP[i-1][j][k]+L[i][j]);
        }
        chmax(DP[i][j][k],DP[i][j-1][k]);
        chmax(DP[i][j][0],DP[i-1][j][k]);
      }
    }
  }
  
  cout<<DP[3001][3001][0]<<endl;
  return 0;
}

Measured memory_bytes: 360324
function main(line) {
	var i=0
	while(line[i]!=0){
		console.log("Case " + (i+1) + ": " + line[i])
		i = i + 1
	}
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});

Measured memory_bytes: 13500
#include <bits/stdc++.h>
using namespace std;
int main() {
    char c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    cout<<c[0][0]<<c[1][1]<<c[2][2];
    return 0;
}

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

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	cout << (x - a) % b << endl;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
ans=""
for i in range(dy):
    ans+="U"
for j in range(dx):
    ans+="R"
for i in range(dy):
    ans+="D"
for j in range(dx):
    ans+="L"
ans+="L"
for i in range(dy+1):
    ans+="U"
for i in range(dx+1):
    ans+="R"
ans+="DR"
for i in range(dy+1):
    ans+="D"
for i in range(dx+1):
    ans+="L"
ans+="U"
print(ans)

Measured memory_bytes: 73208
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int m, f, r;

    while (true) {
      m = scanner.nextInt();
      f = scanner.nextInt();
      r = scanner.nextInt();
      if (m == -1 && f == -1 && r == -1) break;

      if (m == -1 || f == -1) System.out.println("F");
      else if (m + f >= 80) System.out.println("A");
      else if (m + f >= 65) System.out.println("B");
      else if (m + f >= 50 || (m + f >= 30 && r >= 50)) System.out.println("C");
      else if (m + f >= 30) System.out.println("D");
      else System.out.println("F");
    }
  }
}


Measured memory_bytes: 26032
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int p[N];
  for(int i = 0; i < N; ++i) cin >> p[i];
  int A[N], B[N];
  for(int i = 0; i < N; ++i){
    A[i] = (i+1)*N;
    B[i] = (N-i)*N;
  }
  for(int i = 0; i < N; ++i){
    A[p[i]-1] += i;
  }
  for(int i = 0; i < N; ++i){
    cout << A[i];
    if(i < N-1) cout << " ";
    else cout << endl;
  }
  for(int i = 0; i < N; ++i){
    cout << B[i];
    if(i < N-1) cout << " ";
    else cout << endl;
  }
  return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long double distance(int x1, int y1, int x2, int y2)
{
    int dist_x = x1 - x2;
    int dist_y = y1 - y2;

    return std::sqrt(dist_x * dist_x + dist_y * dist_y);
}

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

    std::vector<std::pair<int, int>> lens(n);

    for (int i = 0; i < n; i++) {
        std::cin >> lens[i].first >> lens[i].second;
    }

    std::vector<int> permutation(n);
    for (int i = 0; i < n; i++) {
        permutation[i] = i;
    }

    long double ans = 0;
    int count = 0;
    do {
        for (int i = 0; i < n - 1; i++) {
            ans += distance(lens[permutation[i]].first, lens[permutation[i]].second, lens[permutation[i + 1]].first, lens[permutation[i + 1]].second);
        }
        count++;
    } while (std::next_permutation(permutation.begin(), permutation.end()));

    init_comb();
    std::cout << std::fixed << std::setprecision(10) << ans / fact[n] << std::endl;
}


Measured memory_bytes: 12792
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
const int INF = numeric_limits<int>::max() / 2;

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

	int T;
	while (true)
	{
		cin >> T;
		if (T == 0)
			break;
		vector<int> t(30);
		for (int i = 0; i < T; i++)
			cin >> t[i];
		int n;
		cin >> n;
		vector<int> m(110, 24);
		for (int i = 0; i < n; i++)
		{
			int di, mi;
			cin >> di >> mi;
			m[di] = min(m[di], mi);
		}
		VVI dp(110, vector<int>(T, INF));
		dp[1][0] = 0;
		for (int i = 2; i <= 100; i++)
		{
			for (int j = 0; j < T; j++)
			{
				dp[i][0] = min(dp[i][0], dp[i - 1][j] + 1);
				if (m[i] >= t[j])
					dp[i][j] = min(dp[i][j], dp[i - 1][(j + T - 1) % T]);
			}
		}
		int res = INF;
		for (int i = 0; i < T; i++)
			res = min(res, dp[100][i]);
		cout << res << endl;
	}
}


Measured memory_bytes: 3088
import java.util.*;
import java.awt.geom.*;
public class Main {
	int INF = 1 << 24;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int m = sc.nextInt();
			int [][] pass = new int[n][n];
			for(int i = 0; i < n; i++){
				Arrays.fill(pass[i], INF);
				pass[i][i] = 0;
			}
			for(int i = 0; i < m; i++){
				String [] s = sc.next().split(",");
				int from = Integer.parseInt(s[0]);
				int to = Integer.parseInt(s[1]);
				int cost = Integer.parseInt(s[2]) / 100 - 1;
				pass[from][to] = cost;
				pass[to][from] = cost;
			}
			int res = mst(pass);
			System.out.println(res);
		}
	}

	private int mst(int[][] pass) {
		int INF = 1 << 24;
		int n = pass.length;
		int [] mincost = new int[n];
		boolean [] isused = new boolean[n];
		Arrays.fill(mincost, INF);

		mincost[0] = 0;
		int res = 0;
		while(true){
			int v = -1;
			for(int i = 0; i < n; i++){
				if(! isused[i] &&( v == -1 || mincost[i] < mincost[v])){
					v = i;
				}
			}
			if(v == -1) break;
			isused[v] = true;
			res += mincost[v];
			for(int i = 0; i < n; i++){
				mincost[i] = Math.min(mincost[i], pass[v][i]);
			}
		}
		return res;
	}

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

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    string s;
    ll q;
    cin >> s >> q;
    bool top = true; // trueの時frontが前、falseの時backが前
    deque<char> deq;
    for (char c : s) {
        deq.push_back(c);
    }

    REP(i, q) {
        ll t;
        cin >> t;
        if (t == 1 && deq.size() != 1) {
            top = !top;
        } else {
            ll f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (top) {
                    deq.push_front(c);
                } else {
                    deq.push_back(c);
                }
            } else {
                if (top) {
                    deq.push_back(c);
                } else {
                    deq.push_front(c);
                }
            }
        }
    }

    if (!top) {
        std::reverse(deq.begin(), deq.end());
    }

    for (auto &itr : deq) {
        cout << itr;
    }
    cout << endl;
}

Measured memory_bytes: 896
# coding: utf-8
import itertools
import numpy as np
import sys


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


N = ir()

roots = []
for i in range(N):
    x, y = lr()
    roots.append([x, y])

ans = 0
path_dict = {}
all_path = list(itertools.permutations(range(0, N, 1)))
for pattern in all_path:
    sum_dist = 0
    for n1, n2 in zip(pattern, pattern[1:]):
        path = sorted([n1, n2])
        # if key not in path_dict:
        p1 = roots[path[0]]
        p2 = roots[path[1]]
        dist = np.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)
        # path_dict[key] = dist
        # else:
        #     dist = path_dict[path]

        sum_dist += dist
    ans += sum_dist
ans /= len(all_path)
print(ans)


Measured memory_bytes: 17028
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cerr << #x << ' ' << x << endl;
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int f[5005];
int item[1005], cost[1005];
int main(int argc, char const *argv[])
{
    int n, m;
    scanf("%d %d", &n, &m);
    int a, b;
    rep(i, 1, m) {
        scanf("%d %d", &cost[i], &b);
        rep(j, 1, b) {
            scanf("%d", &a);
            item[i] |= 1 << (a-1);
        }
    }
    memset(f, 0x3f, sizeof f);
    const int stas = (1<<n) - 1;
    f[0] = 0;
    rep(i, 1, m) {
        rep(j, 0, stas) {
            f[j|item[i]] = min(f[j|item[i]], f[j] + cost[i]);
        }
    }
    if(f[stas] == 0x3f3f3f3f)   f[stas] = -1;
    printf("%d\n", f[stas]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[55][30],n,m; char S[66];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		scanf("%s",S); m=strlen(S);
		for (int j=0;j<m;++j) ++a[i][S[j]-'a'];
	}
	for (int i=0;i<27;++i){
		m=100;
		for (int j=1;j<=n;++j) m=min(a[j][i],m);
		while (m--) putchar('a'+i);
	}
	puts("");
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  if(N<1200){
    cout << "ABC" << endl;
  }
  else if(N<2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
}

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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
S=input()
T=input()
ans=len(T)
for i in range(len(S)-len(T)+1):
    x=0
    for j in range(len(T)):
        if S[i:i+len(T)][j]==T[j]:
            x+=1
        ans=min(ans,len(T)-x)
print(ans)


    

                
            





    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 9104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <sys/time.h>
#include <time.h>


using namespace std;



int main(){
  int N,M,times;
  std::cin >> N>>M;
  times=(N-M)*100+M*1900;
  for(int i=0;i<M;i++){
    times*=2;
  }
  std::cout << times << '\n';
}


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

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;

    int ans = 0, diff = 0;
    for(int i = 1; i < n; i++){
        diff += s[i] != s[i-1];
        if(s[i] == s[i-1])  ans++;
    }
    while(k-- > 0 && diff > 0){
        ans += min(2, diff);
        diff-=2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

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


Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        Scanner scan = new Scanner(System.in);
        String a = scan.next();
        String b = scan.next();

        if(a.equals(b)){
            System.out.println("H");

        }
        else{
            System.out.println("D");

        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    vector<int> p(N);
    REP(i, N) cin >> p[i];
    vector<int> ps(N);
    REP(i, N) ps[i] = p[i];
    sort(ps.begin(),ps.end());
    int k = 0;
    REP(i, N) {
        if(ps[i] != p[i]) k++;
    }
    if(k == 0 || k == 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  
  int i;
  vector<vector<int>> h(n, vector<int>(2));
  for(i = 0; i < n; i++){
    cin >> h.at(i).at(0);
    h.at(i).at(0) = 1000 * t - 6 * h.at(i).at(0);
    h.at(i).at(0) = abs(1000 * a - h.at(i).at(0));
    h.at(i).at(1) = i + 1;
  }
  
  sort(h.begin(), h.end());
  
  cout << h.at(0).at(1) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char *a=(char *)calloc(10000+1,sizeof(char));
  scanf("%s",a);
  int d;
  scanf("%d",&d);
  int dp[100*2]={0};
  int now=0;
  int sup=0;
  const int mod=1000000000+7;
  for(int i=0;a[i]!='\0';i++){
    int k=a[i]-'0';
    int next=now^d;
    int j,l;
    for(j=0;j<d;j++) dp[next+j]=0;
    for(j=0;j<d;j++){
      for(l=0;l<10;l++){
	int index=(j+l)%d;
	dp[next+index]=(dp[next+index]+dp[now+j])%mod;
      }
    }
    for(j=0;j<k;j++){
      int index=(sup+j)%d;
      dp[next+index]=(dp[next+index]+1)%mod;
    }
    sup=(sup+k)%d;
    now=next;
  }
  printf("%d\n",(dp[now+0]-1+mod+(sup==0?1:0))%mod);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            if (t >= 30) {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }

    }
}


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

int main()
{
    string s;
    cin >> s;
    int x = 0,ans = 0;

    while(1){
        if(s[x] == 'A') break;
        x++;
    }
    for(int i = x; i < s.length(); i++)
        if(s[i] == 'Z') ans = i - x + 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
x = int(input())
a = 100
cnt = 0
for _ in range(4000):
    cnt += 1
    a = math.floor(a*1.01)
    if a >= x:
        print(cnt)
        exit()


Measured memory_bytes: 68984
N = int(input())
S = input()
op = 0
for c in S:
    if c=='(':
        op += 1
    elif op > 0:
        op -= 1
cl = 0
for c in S[::-1]:
    if c==')':
        cl += 1
    elif cl > 0:
        cl -= 1

print('('*cl + S + ')'*op)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    V<int> ans(n);
    rep(i,n)rep(j,n) {
        int d = min(abs(j-i), 1 + min(abs(x-i) + abs(y-j), abs(y-i) + abs(x-j)));
        // printf("%d,%d : %d\n",i+1,j+1,d);
        ans[d]++;
    }
    Rep(i,n-1) {
        cout << ans[i]/2 << endl;
    }
}

Measured memory_bytes: 3624