akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	long m,n=100000;
	cin>>m;
	for(int i=0;i<m;i++){
		n*=21;
		n/=20;
		
		if(n%1000!=0){
			n+=(1000-n%1000);
		}
	}
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;
typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B;
    cin>>A>>B;
    int ans = max(0, A-2*B);
    cout<<ans<<endl;

}

Measured memory_bytes: 256
//file_name:ABC98_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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


    int ans = -9999999;
    maxs(ans,n+m);
    maxs(ans,n-m);
    maxs(ans,n*m);

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int s_siz = s.size();
    vector<int> as(26,0);
    vector<int> at(26,0);
    for(int i = 0;i < s_siz;i++)as[s[i]-'a']++;
    for(int i = 0;i < t.size();i++)at[t[i]-'a']++;
    string S = s+s;
    vector<vector<int>> ch(26,vector<int>());
    for(int i = 0;i < 2*s_siz;i++){
        ch[S[i]-'a'].push_back(i);
        //cout << S[i] << i << endl;
    }
    vector<vector<int>> nextch(s_siz,vector<int>(26));
    for(int i = 0;i < s_siz;i++){
        for(int j = 0;j < 26;j++){
            if(as[j] != 0){
                auto itr = upper_bound(ch[j].begin(),ch[j].end(),i);
                nextch[i][j] = *itr - i;
                char app = 'a'+j;
            }
        }
    }
    long long ans = 0;
    bool judge = true;
    for(int i = 0;i < 26;i++){
        if(as[i] == 0 && at[i] != 0){
            judge = false;
            break;
        }
    }
    if(judge == false)cout << -1 << endl;
    else{
        long long ans = ch[t[0]-'a'][0];
        long long now = ans;
        for(int i = 1;i < t.size();i++){
            //cout << ans << endl;
            ans += nextch[now][t[i]-'a'];
            now = (ans % s_siz);
        }
        cout << ans+1 << endl;
    }
}

Measured memory_bytes: 14848
K, N = map(int, input().split())

house = list(map(int, input().split()))

mx = house[0] + (K - house[-1])

for i in range(N - 1):
	mx_sub = house[i + 1] - house[i]
	if mx_sub > mx:
		mx = mx_sub

print(K - mx)

Measured memory_bytes: 26436
class Telp:
    def __init__(self, to, idx):
        self.to = to
        self.idx = idx
        self.visited = False
        self.step = -1

    def visit(self, step):
        self.visited = True
        self.step = step

    def is_visited(self):
        return self.visited


n, k = map(int, input().split())

a = list(map(int, input().split()))

net = {}

for i in range(n):
    net[i] = Telp(a[i], i)

current = net[0]
count = 0
path = []

while not current.visited:
    # print(current.to)
    path.append(current)
    current.visit(count)
    current = net[current.to - 1]
    count += 1
    if count == k:
        print(path[-1].to)
        exit(0)
    # print("count", count)

offset = current.step
loop = count - offset
fact_idx = (k - offset) % loop

# print("count, offset, loop, fact_idx", count, offset, loop, fact_idx)
# print("ans", path[offset + fact_idx - 1].to)

print(path[offset + fact_idx - 1].to)


Measured memory_bytes: 128108
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin>>n>>m;
	int a[60],b[60],idmax[60],vmin[60];
	rep(i,n){
		cin>>a[i]>>b[i];
		vmin[i]=(int)1e9;
	}
	rep(j,m){
		int c,d;cin>>c>>d;
		rep(i,n){
			int tmp=(abs(a[i]-c)+abs(b[i]-d));
			if(tmp<vmin[i]){
				vmin[i]=tmp;
				idmax[i]=j+1;
			}
		}
	}
	rep(i,n)cout<<idmax[i]<<endl;
				
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=3e5+20;
const double eps=1e-10;
//ÌâÒâ:Á½¸öÈËA,B¶¼ÓÐstring,³¤¶ÈÎªn,´ÓA¿ªÊ¼,Ã¿´ÎÂÖÁ÷´ÓÖÐÈ¡³öÒ»¸ö,AÏëÈÃ×ÖµäÐòÐ¡,BÏëÈÃ×ÖµäÐò¾¡Á¿´ó,ÎÊ×îºó×é³É³¤¶ÈÎªnµÄstring?
//n/2ÂÖ,A¿Ï¶¨´ÓÇ°n/2Ð¡Ñ¡,B¿Ï¶¨´ÓÇ°n/2´óÑ¡
//Çé¿ö1:Èç¹ûa×îÐ¡±Èb×î´ó»¹Ð¡,Ôòb¿Ï¶¨ÏÈÓÃ×îÐ¡µÄÕ¼¸ßÎ»
//Çé¿ö1:Èç¹ûa×îÐ¡±Èb×î´ó»¹´ó,ÔòaÓÃ×î´óµÄÕ¼Áì×îµÍÎ» 
int a,b,c;
int main()
{
	int n,m,sum[200];
	while(cin>>n>>m)
	{
		memset(sum,0,sizeof(sum));
		while(m--)
		{
			int u,v;
			cin>>u>>v;
			sum[u]++;
			sum[v]++;
		}
		for(int i=1;i<=n;i++)
			cout<<sum[i]<<endl;
		
	} 
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
#define vi vector<int>
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      
    x = x % p;  
    while (y > 0) {  
        if (y & 1) 
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;       
    while (y > 0) {    
        if (y & 1) 
            res = (res*x) ;  
        y = y>>1; 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve(){
    ll h;cin>>h;
    ll cnt=0;
    while(h>0){
        cnt++;
        h=h>>1;
    }
    cout<<power(2,cnt)-1<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a = 0;
  int b = 0;
  
  string N;
  cin >> N;
  for(int i = 0;i < N.size();i +=2){
    if(N.at(i) == '0')
    a++;
    else if(N.at(i) == '1')
    b++;
  }
  for(int i = 1;i < N.size();i +=2){  
    if(N.at(i) == '0')
    b++;
    else if(N.at(i) == '1')
    a++;
  }  
  cout << min(a,b) <<endl;
  }

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

int main(void){

  int   n, *a, count, i, flag, j;
  char  tmp[80], *token, *sep = " ";

  scanf("%d\n", &n);
  a = malloc(n * sizeof(*a));
  fgets(tmp, 80, stdin);
  for (size_t i = 0; i < n; i++) {
    token = ( i == 0 )? strtok(tmp, sep) : strtok(NULL, sep);
    a[i] = atoi(token);
  }

  count = 1;
  flag = 1;
  for (size_t i = 1; i < n; i++) {
    for (size_t j = 0; j < i; j++) {
      if (a[i] < a[j]) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) count++;
    flag = 1;
  }

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

  return 0;

}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 26388
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            if (a > b) {
                out.print(0);
                return;
            }
            if (n == 1) {
                if (a == b) {
                    out.print(1);
                } else {
                    out.print(0);
                }
            } else if (n == 2) {
                out.print(1);
            } else {
                long max = (long) a + b + (long) b * (n - 2);
                long min = (long) a + b + (long) a * (n - 2);
                out.print(max - min + 1);
            }
        }

    }
}



Measured memory_bytes: 21972
import re
s=input()
s=s[::-1]
#print(s)

#dream|dreamer|erase|eraser

#maerd|remaerd|esare|resare
t=re.split('maerd|remaerd|esare|resare', s)
#print(len(t))
#print(t.count(''))
if len(t)==t.count(''):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3444
#include <cmath>
#include <cstdlib>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

int main(){
  const int t = getInt();
  const int d = getInt();
  const int ta = getInt();
  const int tb = getInt();
  const int da = getInt();
  const int db = getInt();

  double ans = 1e10;

  for(int i = 0; i * da <= d; i++){
    for(int j = 0; i * da + j * db <= d; j++){
      if(i + j == 0) continue;
      ans = min(ans, fabs(t - (double)(ta * i * da + tb * j * db) / (da * i + db * j)));
    }
  }

  printf("%.9f\n", ans);

  return 0;
}

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

using namespace std;

int main() {
    unsigned int n, m;
    cin >> n >> m;

    vector<int> vtl(m), vtr(m);
    for (int i = 0; i < m; ++i) {
        cin >> vtl[i] >> vtr[i];
    }

    int t = *min_element(vtr.begin(), vtr.end()) -
            *max_element(vtl.begin(), vtl.end());
    if (t >= 0) {
        cout << t + 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin>>x;
    cout<<360/__gcd(x,360)<<endl;
    return 0;
}

Measured memory_bytes: 3608
# input
s = str(input())
t = str(input())

# DP
dp = [[0] * (len(t) + 1) for i in range(len(s) + 1)]

for i in range(len(s)):
  for j in range(len(t)):
    if s[i] == t[j]:
      dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1], dp[i][j] + 1)
    else:
      dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])
      
#lcs = dp[len(s)][len(t)]

ans = ""
i = len(s)
j = len(t)
while i > 0 and j > 0:
  if dp[i][j] == dp[i - 1][j]:
    i -= 1
  if dp[i][j] == dp[i][j - 1]:
    j -= 1

  if dp[i][j] > dp[i - 1][j] and dp[i][j] > dp[i][j - 1]:
    ans += s[i - 1]
    i -= 1
    j -= 1

ans = ''.join(list(reversed(ans)))
print(ans)


Measured memory_bytes: 114012
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 2 == 0) {
			System.out.println(n / 2);
		} else {
			System.out.println((n + 1) / 2);
		}
	}
}


Measured memory_bytes: 25172
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	while (1)
	{
		int n;
		cin >> n;
		if (!(n == 0)) {
			vector<int> s(n);
			double sum = 0;
			for (int i = 0; i < n; ++i) {
				cin >> s[i];
				sum += s[i];
			}
			double m = sum / n;

			double alpha;
			double sum_alpha = 0;
			for (int j = 0; j < n; ++j) {
				sum_alpha += pow((s[j] - m), 2);
			}
			alpha = sqrt(sum_alpha / n);
			printf("%.5f\n", alpha);
		}
		else {
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3120
n = int(input())
s = input()
e = [0]
w = [0]
for i in range(n):
    e.append(e[i] + (s[i] == 'E'))
    w.append(w[i] + (s[i] == 'W'))
e.append(e[-1])
w.append(w[-1])
ans = 10**10

for i in range(1, n+1):
    ans = min(ans, e[-1] - e[i] + w[i - 1])
print(ans)


Measured memory_bytes: 27116
//A
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define red(i,r,l) for(int i=r;i>=l;i--)
#define re(i,n) for(int i=0;i<n;i++)
#define db(x) cout<<#x<<"="<<(x)<<" "
#define el cout<<endl
#define PII pair<int, int>
#define PIII pair<PII, int>
#define c0 first
#define c1 second
using namespace std;
const int MXN = 100010;
int n;
int a[MXN], cnt[MXN] = {};

namespace solve
{
	int f[MXN] = {};
	bool judge()
	{
		if (n % 2 == 0)
		{
			return 0;
		}
		f[0] = 1;
		rep(i, 1, n)
		{
			if (a[i] & 1)
				rep(j, 1, i) if (a[j] & 1)
					if ((i - j) % 2 == 0)
						f[i] |= f[j - 1];
		}
		return f[n];
	}
	void solve()
	{
		if (judge())
		{
			puts("Yes");
		}
		else puts("No");
	}
}

int main()
{
	int ans = 0;
	cin >> n;
	rep(i, 1, n) cin >> a[i], ++cnt[a[i]], ++cnt[a[i] + 1], ++cnt[a[i] + 2];
	rep(i, 0, 100002)
		ans = max(ans, cnt[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

var selected []bool
var result [][]int

func perm(n int, res []int) {
	if len(res) == n {
		tmp := make([]int, n)
		copy(tmp, res)
		result = append(result, tmp)
		return
	}
	for i := 1; i <= n; i++ {
		if selected[i] {
			continue
		}
		res = append(res, i)
		selected[i] = true
		perm(n, res)
		selected[i] = false
		res = res[:len(res)-1]
	}
}

func abs(n int) int {
	if n < 0 {
		return -n
	} else {
		return n
	}
}

func dump(s [][]int) {
	for i := range s {
		fmt.Println(s[i])
	}
}

func main() {
	var N int
	fmt.Scan(&N)
	selected = make([]bool, N+10)
	result = make([][]int, 0, N)
	var P []int = make([]int, N)
	var Q []int = make([]int, N)
	for i := range P {
		fmt.Scan(&P[i])
	}
	for i := range Q {
		fmt.Scan(&Q[i])
	}
	perm(N, make([]int, 0, N))
	//dump(result)
	a := 0
	b := 0
outer:
	for i := range result {
		for j := range result[i] {
			if P[j] != result[i][j] {
				continue outer
			}
		}
		a = i
	}
outer2:
	for i := range result {
		for j := range result[i] {
			if Q[j] != result[i][j] {
				continue outer2
			}
		}
		b = i
	}
	fmt.Println(abs(a - b))
}


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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(){
  int X, Y;
  cin >> X >> Y;
  int ans = 0;
  if(X == 1) ans += 3 * 1e5;
  else if(X == 2) ans += 2 * 1e5;
  else if(X == 3) ans += 1e5; 

  if(Y == 1) ans += 3 * 1e5;
  else if(Y == 2) ans += 2 * 1e5;
  else if(Y == 3) ans += 1e5;

  if(X == 1 && Y == 1) ans += 4 * 1e5;
  print(ans);
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int a,b,c,d,ans=0;
	cin>>a>>b>>c>>d;
	if(a>=b)ans+=b;
	else ans+=a;
	if(c>=d)ans+=d;
	else ans+=c;
	cout<<ans<<endl;
} 

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

int dsum(int n){
  if(n == 0)
    return 0;
  else{
    return n % 10 +dsum(n / 10);
  }

}

int main()
{
  int i,j,A,B,N,MIN=100000;
  scanf("%d",&N);
  for(i=1;i<N;i++){
    j = N-i;
    B = dsum(j);
    A = dsum(i);
    if(A+B < MIN)
      MIN = A+B;
    }
  printf("%d\n",MIN);
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
n,m = map(int,input().split())
G = [[1]*n for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  a -=1;b-=1
  G[a][b] = G[b][a] = 0
colors = [-1 for i in range(n)]
possible = True
ni = []
def dfs(x,y):
  colors[x] = y
  k[y] += 1
  for l in range(n):
    if l == x or G[x][l] == 0:
      continue
    if colors[l] == -1:
      dfs(l,1-y)
    elif colors[l] != 1-y:
      global possible
      possible = False
for i in range(n):
  k = [0,0]
  if colors[i] != -1:
    continue
  dfs(i,0)
  ni.append([k[0],k[1]])
if possible == False:
  print(-1)
  exit()
dp =[0]*701
dp[0] = 1
for i in ni:
  for j in range(700,-1,-1):
    if dp[j]:
      dp[j] = 0
      dp[j+i[0]] = 1
      dp[j+i[1]] = 1
ans = float("inf")
for i in range(0,701):
  if dp[i]:
    tmp = (n-i)*(n-i-1)//2 + i*(i-1)//2
    ans = min(tmp,ans)
print(ans)

Measured memory_bytes: 8820
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}


//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  int a[n];
  int b[n];
  ll sum = 0;
  for(int i = 0; i < n; i++){
    cin>>a[i];
    sum+=a[i];
  }
  sum-=a[0];
  ll sum2 = a[0];
  ll ans = abs(sum-a[0]);
  for(int i = 1; i < n-1; i++){
    sum-=a[i];
    sum2+=a[i];
    ans = min(ans,abs(sum-sum2));
  }
  cout<<ans<<endl;
  return 0;
}
  



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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;



int main() {

    int q; cin >> q;

    vector<bool> p(100010, true);

    p[0] = false;
    p[1] = false;

    for (int i = 2; i < 100010; ++i) {
        if (p[i]) {
            for (int j = i * 2; j < 100010; j += i) {
                p[j] = false;
            }
        }
    }

    vector<bool> n = p;

    for (int i = 2; i < 100010; ++i) {
        if (p[i] && !p[(i+1)/2]) {
            n[i] = false;
        }
    }

    vector<int> s(100010, 0);

    for (int i = 1; i < 100010; ++i) {
        s[i] += s[i-1];
        if (n[i]) {
            s[i] += 1;
        }
    }

    for (int i = 0; i < q; ++i) {
        int l, r; cin >> l >> r;

        cout << s[r] - s[l-1] << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
int main() {
  char c[11][11];
  vector<int> v;
  int dat[7][6]={{1,1,1,1,0,0},{1,0,1,0,1,0},{1,1,0,0,0,0},{1,0,1,0,0,0},{1,1,0,1,0,0},
  {1,0,1,1,0,1},{1,1,1,0,0,0}};
  int i,j,k,x,y,f,g=0;
  while(g==0) {
      f=0;
	  for (i=0;i<8;i++) {
		  gets(c[i]);
		  if (f==0) for (j=0;j<8;j++) if (c[i][j]=='1') { f=1; x=j; y=i; j=9;}
	  }
	  if (gets(c[8])==NULL) g=1; 
	  for (k=0;k<7;k++) {
		  f=0;
		  for (i=0;i<3;i++) for (j=0;j<2;j++) {
			  if (x+j>7 || y+i>7) { if (dat[k][j+i*2]==0) f++;}  else
				  if (c[y+i][x+j]==('0'+dat[k][j+i*2])) f++;
		  }
		  if (f==6) break;
	  }
	  v.push_back(k);
	  }
  for (i=0;i<v.size();i++) cout << (char)('A'+v[i]) << endl;
  return 0;
}

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

namespace _0228
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Max() < 2) Console.WriteLine("NA");
                else
                {
                    int ret = 1;
                    for (int i = 0; i < n; i++)
                    {
                        if (x[i] != 0) ret++;
                    }
                    Console.WriteLine(ret);
                }
            }
        }
    }
}

Measured memory_bytes: 11224
Sn = ["AC", "WA", "TLE", "RE"]
results = Hash.new
Sn.map{|s| results.store(s,0)}
gets.to_i.times.map{
  results[gets.chomp] += 1
  }
Sn.map{|s| puts "#{s} x #{results[s]}" }

Measured memory_bytes: 15384
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt(); 
    if(a == b && b == c && c == a){
      System.out.println("No");
      System.exit(0);
    }
    if(a == b || b == c || c == a){
      System.out.println("Yes");
      System.exit(0);      
    }
      System.out.println("No");    
  }
}

Measured memory_bytes: 20684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Objects;

//import org.junit.Test;

public class Main {
//	@Test
//	public void testName() throws Exception {
//		main(null);
//	}

	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(
				System.in))) {

			new Main().solution(br);
		}
	}

	private void solution(BufferedReader br) throws IOException {
		for (String line = br.readLine(); Objects.nonNull(line); line = br
				.readLine()) {
			String[] strList = line.split(" ", 0);

			int num1 = Integer.parseInt(strList[0]);
			int num2 = Integer.parseInt(strList[2]);
			String operator = strList[1];

			if (operator.equals("?")) {
				break;
			}

			int ans = calc(num1, num2, operator);
			System.out.println(ans);

		}
	}

	private int calc(int a, int b, String operator) {
		int result = 0;
		if (operator.equals("+")) {
			result = a + b;
		} else if (operator.equals("-")) {
			result = a - b;
		} else if (operator.equals("*")) {
			result = a * b;
		} else if (operator.equals("/")) {
			result = a / b;
		}

		return result;
	}

}

Measured memory_bytes: 24260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
ll arr[maxn];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll n, k; cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> arr[i];
    sort(arr, arr + n);
    reverse(arr, arr + n);
    ll sum = 0;
    for (int i = k; i < n; ++i)
        sum += arr[i];
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 1792
#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 pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const int N = 211111;
int n;
ll s[N], a[N];
map<ll, int> m;

int main(){
	read(n);
	rep(i, 1, n) read(a[i]), s[i] = s[i-1] + a[i];
	m[0] = 1;
	ll ans = 0;
	rep(i, 1, n){
		ans += m[s[i]];
		m[s[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
n=int(input())
a_list=[]
for i in range(n):
	k=list(map(int,input().split(" ")))
	L,M,N=sorted(k)
	if L**2+M**2==N**2:
		a_list.append("YES")
	else:
		a_list.append("NO")
for i in a_list:
	print(i)

Measured memory_bytes: 7652
#include<stdio.h>
int main(void)
{
    int n,i,count = 0;
    long long int d,x,y;
    scanf("%d %lld",&n,&d);
    for(i = 0 ; i < n ; i++)
    {
        scanf("%lld %lld",&x,&y);
        if(x*x + y*y <= d*d)
        {
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL
 
typedef struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}*N;
//typedef struct node * N;
 
N root = NIL;

void insert(int);
void inorder(N);
void preorder(N);
 
int main(){
  int m, i, x;
  char str[20];

  scanf("%d", &m);
 
  for(i = 0; i < m; i++){
    scanf("%s", str);
    if(strcmp(str, "insert") == 0){
      scanf("%d", &x);
      insert(x);
    }else if(strcmp(str, "print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}
  
void insert(int k){
  N y = NIL, x = root, z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = z -> right = NIL;
     
  while(x != NIL){
    y = x;
    if(z->key < x->key)   x = x->left;
    else                  x = x->right;
  }

  z->parent = y;

  if(y == NIL)               root = z;
  else if(z->key < y->key)   y->left = z;
  else                       y->right = z;
}
 
void inorder(N u){
  if(u->left != NIL)     inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL)    inorder(u->right);
}

void preorder(N u){
  printf(" %d",u->key);
  if(u->left != NIL)     preorder(u->left);
  if(u->right != NIL)    preorder(u->right);
}

Measured memory_bytes: 24040
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
     cin >> n >> k;
     for (int i = 0; i < n; i++)
          cin >> a[i];

     sort(a, a + n);
     reverse(a, a + n);

     int s = 0;
     for (int i = k; i < n; i++)
          s += a[i];

     cout << s;

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[100002] = {};
    int b[100002] = {};
    int n;
    int k;
    int p1=100001;
    int p2=100001;
    int q1=100001;
    int q2=100001;
    cin >> n ;
    
    for(int i = 0;i<n/2;i++){
        cin >>k;
        a[k]++;
        if(p1!=k){
        if(p2 != k){

        if(a[p2]<a[k]){
            if(a[p1]<a[k]){
                p2 = p1;
                p1 =k;
            }else{
                p2 = k;
            }
            
        }
        }else{
            if(a[p1]<a[k]){
                p2 = p1;
                p1 =k;
            }
        }}
        cin >> k;
        b[k]++;
        if(q1!=k){
        if(q2 != k){

        if(b[q2]<b[k]){
            if(b[q1]<b[k]){
                q2 = q1;
                q1 =k;
            }else{
                q2 = k;
            }
            
        }
        }else{
            if(b[q1]<b[k]){
                q2 = q1;
                q1 =k;
            }
        }
        }
    
    }
    
    if(p1==q1){
        if(a[p2]<b[q2]){
            cout << n - a[p1] - b[q2];
        }else{
            if(p2!=10001){
                cout << n-a[p1]-a[p2];
            }else{
                cout << n/2;
            }
            
        }
    }else{
        cout << n-a[p1]-b[q1];
    }
    return 0;


}

Measured memory_bytes: 1024
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include <numeric>

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(p) cerr<<#p<<'='<<(p.first)<<" "<<p.second<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
const ll MOD = 1e9 + 7;
const int N = 1000000000000001;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char button[4]={'L','R','U','D'};

// Ahhiya thi lakhvanu chalu thasse....


signed main() {
    FAST
    int q = 1;
    //cin>>q;
    while (q--) {
        int n;
        cin>>n;
        n%=1000;
        if(n){
            cout<<1000-n<<endl;
        }
        else{
            cout<<0;
        }
    }
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define ll                      long long int
#define pb                      push_back
#define mp                      make_pair
#define in                      insert
#define all(x)                  (x).begin(),(x).end() 
#define rep(i,a,n)              for(int i=0;i<n;++i)
#define per(i,a,n)              for(int i=n-1;i>=0;--i)
#define mod                     1000000007
using namespace std;

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin>>n;
    int t=n;
    n-=1;
    int a[n];
    rep(i,0,n) cin>>a[i];
    
    int freq[t+1]={0};
    rep(i,0,n) freq[a[i]]++;
    for(int i=1;i<=t;++i){
    	cout<<freq[i]<<'\n';
    }


    
    return 0;
}


Measured memory_bytes: 5228
#include <stdio.h>

int main()
{
    int n;
    int i;
    int a;
    int ans;
    scanf("%d",&n);
    ans =0;
    for (i=0;i<n;i++) {
        scanf("%d", &a);
        ans += a-1;
    }
    printf("%d\n", ans);
    return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
  }

  map<string, ll> m;
  rep(i, n) {
    m[s[i]]++;
  }

  ll max_val = 0;

  FORm(it, m) {
    chmax(max_val, it->second);
  }

  vector<string> ans;

  FORm(it, m) {
    if (it->second == max_val) {
      // ans.push_back(it->first);
      cout << it->first << endl;
    }
  }
  /*
    sort(all(ans));

    FORm(it, ans) {
      cout << *it << endl;
    }
  */
  return 0;
}


Measured memory_bytes: 25472
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
#define INF 2000000000

int main() {
	int s, w;
	cin >> s >> w;
	if (w >= s)cout << "unsafe" << endl;
	else cout << "safe" << endl;
	return 0;
}

Measured memory_bytes: 3636
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = input()
    t = input()
    
    ans = 100000
    for i in range(len(s)-len(t)+1):
        tmp = s[i:i+len(t)]
        cnt = 0
        for j in range(len(t)):
            if t[j] != tmp[j]:
                cnt += 1
        ans = min(ans, cnt)
        
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9068
#include <stdio.h>

int main()
{
	long int n;
	scanf("%ld", &n);
	
	unsigned long int sum=((n*(n+1))/2) - ((((n/3)*(3+(n/3)*3))/2)+(((n/5)*(5+(n/5)*5))/2)-(((n/15)*(15+(n/15)*15))/2));
	
	printf("%lld",sum);
	
return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)

int Count(int N,int& c){
  c++;
  if(ceil(N/3.0)>1) {Count(ceil(N/3.0),c);}
  return c;
}

int main(){
  int N;
  cin>>N;
  int c=0;

  cout<<Count(N,c)<<endl;
  return 0;
}

Measured memory_bytes: 3108
/*
 * ID: 3001
 * Proble: GPA janken, combination
 */

#include <stdio.h>

int main(void)
{
    int a[500000];
    int c[4001] = {};
    int s[4001] = {};

    int n;
    scanf("%d", &n);

    int i;
    for (i = 0; i < n; i++) {
        int d, e, f, g;
        scanf("%1d %*1c %1d %1d %1d", &d, &e, &f, &g);
        a[i] = ((d * 10 + e) * 10 + f) * 10 + g;
    }

    for (i = 0; i < n; i++) 
        c[a[i]]++;

    int k = n - 1;
    for (i = 4000; i >= 0 && k > 0; i--) {
        if (c[i] == 0)
            continue;
        s[i] = k * 3 - (c[i] - 1) * 2;
        k -= c[i];
    }

    for (i = 0; i < n; i++)
        printf("%d\n", s[a[i]]);

    return 0;
}



Measured memory_bytes: 2196
#include<cstdio>
using namespace std;
int N,A[200005],a[200005],l=1,r=200000,mid;
bool check(int n)
{
	int re=-1;
	for(int i=1;i<=N*2-1;i++)
	if(A[i]>=n)
	a[i]=1;
	else
	a[i]=0;
	for(int i=1;i<=N-1;i++)
	{
		if(a[N+i]==a[N+i-1])
		{
			re=a[N+i];
			break;
		}
		if(a[N-i]==a[N-i+1])
		{
			re=a[N-i];
			break;
		}
	}
	if(re!=-1)
	return re;
	else
	return a[1];
}
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N*2-1;i++)
	scanf("%d",&A[i]);
	while(l+1<r)
	{
		mid=(l+r)/2;
		if(check(mid))
		l=mid;
		else
		r=mid;
	}
	printf("%d",l);
	return 0;
}

Measured memory_bytes: 1792
"use strict";

function main(input) {
  input = input.trim().split(" ");
  const D = Number(input[0]);
  const T = Number(input[1]);
  const S = Number(input[2]);

  if (D / S <= T) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


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

int main() {
  int K,X;
  cin >> K >> X;
  
  if(500*K >= X){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
from collections import defaultdict
n = int(input())
s = [list(input()) for _ in range(n)]
s_dict = {}


set_s = set(s[0])
for li in s[1:]:
  set_s = set_s & set(li)


for i in set_s:
  s_dict[i] = 0

for i in s[0]:
  if i in s_dict:
    s_dict[i] += 1

for sub in s[1:]:
  tmp_dict = defaultdict(int)
  for char in sub:
    if char in s_dict:
      tmp_dict[char] += 1
  for k, v in tmp_dict.items():
    if tmp_dict[k] < s_dict[k]:
      s_dict[k] = v

li = []
for k, v in s_dict.items():
  li.append(k*v)

li = sorted(li)
output = ""

for i in li:
  output += i 
print(output)




Measured memory_bytes: 3316
#include <iostream>
#include <vector>
using namespace std;
int N,A,B,C;
vector<int> L;
int INF = 100000;

int dfs(int i, int a, int b, int c){
    if(i==N){
        if(!a || !b || !c)return INF;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }
    int ret;
    ret = dfs(i+1,a,b,c);
    ret = min(ret, dfs(i+1,a+L[i],b,c)+(a?10:0));
    ret = min(ret, dfs(i+1,a,b+L[i],c)+(b?10:0));
    ret = min(ret, dfs(i+1,a,b,c+L[i])+(c?10:0));
    return ret;
}

int main(int argc, char const *argv[])
{
    cin>>N>>A>>B>>C;
    L.resize(N);
    for(int i=0;i<N;++i)cin>>L[i];
    cout << dfs(0,0,0,0) << endl;
    
    return 0;
}


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

using namespace std;

typedef long long int ll;

template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }

typedef pair<int,int> pair;

int main(){
    ll x; cin >> x;
    ll a=0,b=0;

    a+=(x/500)*1000;

    while(x>=500){
        x-=500;
    }
    
    a+=(x/5)*5;

    cout << a << endl;

}


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

int main() {
  long a,b,c;
  string ans="NO";
  cin >> a >> b >> c;
  for(long i=1;i<=1000000;i++) {
    if(a*i%b==c) ans="YES";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int LCS(const char X[], const char Y[]) {
   int LCS[1001][1001];
   int i, j;
   int xl, yl;
   int ans;

   xl = strlen(X);
   yl = strlen(Y);

   for (i = 0; i <= xl; ++i) {
	  for (j = 0; j <= yl; ++j) {
		 if (i == 0 || j == 0)
			LCS[i][j] = 0;
		 else {
			if (X[i - 1] == Y[j - 1])
			   LCS[i][j] = LCS[i - 1][j - 1] + 1;
			else {
			   ans = LCS[i - 1][j];
			   if (ans < LCS[i][j - 1])
				  ans = LCS[i][j - 1];
			   LCS[i][j] = ans;
			}
		 }
	  }
   }
   return LCS[xl][yl];
}

int main() { 
   char X[1000], Y[1000]; 
   int ans[150];
   int n, mal;

   scanf("%d", &n);
   for (mal = 0; mal < n; ++mal) {
	  scanf("%s", X);
	  scanf("%s", Y);
	  ans[mal] = LCS(X, Y);
   }

   for (mal = 0; mal < n; ++mal) {
	  printf("%d\n", ans[mal]);
   }

   return 0;
}

Measured memory_bytes: 5768
#include <iostream>
using namespace std;
signed main(){
    

  int a,b,c,d,e,f,g,h,j,k;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>j>>k;
  cout<<a+b+c+d+e+f+g+h+j+k<<endl;






  return(0);
}



Measured memory_bytes: 3096
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    let a1 = powerMod 10 n
        a2 = powerMod 9 n
        a3 = powerMod 8 n
        ans = a1 `minusMod` a2 `minusMod` a2 `plusMod` a3
    print ans


moduloN :: Int
moduloN = 10 ^ 9 + 7

modN = flip mod moduloN

plusMod x y = modN $ x + y

minusMod x y | x < y = moduloN + x - y
             | otherwise = x - y

mulMod x y = modN $ x * y

powerMod x 0 = 1
powerMod x y
    | even y = mulMod t t
    | otherwise = mulMod x $ mulMod t t
    where
        t = powerMod x $ div y 2


Measured memory_bytes: 3772
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
char s[20][20]={"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
char t[maxn];
void solve()
{
	scanf("%s",t+1);
	rep(i,7){
		if(!strcmp(s[i],t+1)){
			printf("%d\n",7-i);
			return ;
		}
	}
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())

a_ang = 2*(h/12 + m/60/12)*math.pi
b_ang = 2*(m/60)*math.pi

ans = math.sqrt(((a*math.sin(a_ang)-b*math.sin(b_ang))**2)+((a*math.cos(a_ang)-b*math.cos(b_ang))**2))
print(ans)

Measured memory_bytes: 9516
n = int(input())
a = list(map(int, input().split()))

cnt = [0] * (10**5+1)
for v in a:
    cnt[v] += 1

res = 0
even = 0
for c in cnt:
    if c > 0:
        if c % 2 == 0:
            even += 1
        res += 1

if even % 2 == 0:
    print(res)
else:
    print(res - 1)

Measured memory_bytes: 84592
import sys
import math
input = sys.stdin.readline
N = int(input())
#a = [int(i) for i in input().split()] 
#e = [[int(i) for i in input().split()] for i in range(n)] 
price = math.ceil((N/1.08))
#print(price)
#print(math.floor(price*1.08))
if N == (math.floor(price*1.08)):
    print(price)
else:
    print(":(")


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

main(){

  string s;
  cin>>s;

  ll n = s.size();
  vector<ll> a(n);
  a[n-1] = 1;
  for(ll i=n-2;i>=0;--i)a[i]=(a[i+1]*10)%13;

  auto dp = make_vector<ll>(n+1,13);
  dp[0][0]=1;
  rep(i,n){
    if(s[i]=='?'){
      rep(j,10){
        rep(k,13){
          ll num = (j*a[i])%13;
          (dp[i+1][(num+k)%13] += dp[i][k]) %= MOD;
        }
      }
    }else{
      ll num = s[i]-'0';
      num *= a[i];
      num %= 13;
      rep(j,13){
        (dp[i+1][(num+j)%13] += dp[i][j]) %= MOD;
      }
    }
  }

  cout<<dp[n][5]<<endl;


}

Measured memory_bytes: 14464
n, m = map(int,input().split())

li = []
for i in range(n):
    x = map(int,input().split())
    li.append(list(x)[1:])
#    print(li)


sumnum = 0 
for i in range(1, m+1):
    num = 0 
    for j in range(n):
        if i not in li[j]:
            num=0
            break
        num = 1 

    if num == 1:
        sumnum+=1
print(sumnum)

Measured memory_bytes: 3064