akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
bool check(ll x, ll A, ll B, vector<ll> v){
  ll cnt = 0;
  ll ab = A-B;
  rep(i,v.size()){
    v[i] -= B*x;
    if(v[i] <= 0) continue;
    cnt += (v[i]+ab-1)/ab;
  }
  return cnt <= x;
}
 
 
int main(){
  int N;
  ll A, B;
  cin >> N >> A >> B;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }
 
  ll lb = 0, ub = 10000000000LL;
  while(ub-lb>1){
    ll m = (lb+ub)/2;
    if(!check(m,A,B,v)) lb = m;
    else ub = m;
  } 
  cout << ub << endl;
  return 0;
}


Measured memory_bytes: 1908
N = int(input())
An = [int(i) for i in input().split()]

Bn = sorted([An[i] - (i + 1) for i in range(N)])

if N % 2 ==1:
  median = Bn[N//2]
  error = 0
  for n in range(N):
    error += abs(Bn[n] - median)
  print(error)
else:
  median1 = (Bn[N//2] + Bn[N//2-1])//2
  median2 = (Bn[N//2] + Bn[N//2-1] + 1) //2
  error1 = 0
  error2 = 0
  for n in range(N):
    error1 += abs(Bn[n] - median1)
    error2 += abs(Bn[n] - median2)
  print(min(error1, error2))
    
    
  

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

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	bool pend = false;
	int count = 0;
	while(--k >= 0 && pend == false) {
		vector<ll> b(n+1);
		rep(i,n) {
			int l = max(0ll, i-a[i]);
			int r = min(n, i+a[i]+1);
			b[l]++;
			b[r]--;
		}
		rep(i,n) b[i+1] += b[i];
		b.pop_back();
		if (a==b) break;
		a = b;
	}
	rep(i,n) {
		cout << a[i];
		if (i < n-1)
			cout << " ";
		else
			cout << endl;
	}
	return 0;
}
/* 小手先の時間短縮では収まっていない。やり型そのものに欠陥がある。*/


Measured memory_bytes: 6368
#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 forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=305;
int a[maxn][maxn],n,m;
bool flag[maxn];
int cnt[maxn];
inline void re_count(){
	memset(cnt,0,sizeof(cnt));
	rep(i,1,n){
		rep(j,1,m)if(flag[a[i][j]]){
			cnt[a[i][j]]++;break;
		}
	}
}
int main(){
	read(n);read(m);
	rep(i,1,n)rep(j,1,m)read(a[i][j]);
	int ans=n;rep(i,1,m)flag[i]=1;
	rep(x,1,m){
		re_count();
		int maxi=0;
		rep(i,1,m)maxi=max(maxi,cnt[i]);
		ans=min(ans,maxi);
		rep(i,1,m)if(cnt[i]==maxi){
			flag[i]=0;break;
		}
	}cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
//problem-C
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
#include<string>
#include<queue>
#include<map>

using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;
	
	int putFirst = 0;
	int putLast = 0;
	int nowCount = 0;
	for (int i = 0; i < N; i++)
	{
		if (S[i] == '(') {
			nowCount++;
		}
		else {
			nowCount--;
			if (nowCount == -1) {
				nowCount = 0;
				putFirst++;
			}
		}
	}
	putLast = nowCount;

	for (int i = 0; i < putFirst; i++)
	{
		cout << '(';
	}
	cout << S;
	for (int i = 0; i < putLast; i++)
	{
		cout << ')';
	}
	cout << endl;

	return 0;
}

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

ll gcd(ll a, ll b) {
    if(a<b) {
        ll tmp=a;
        a=b;
        b=tmp;
    }
    ll r=a%b;
    while(r!=0) {
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

ll lcm(ll a, ll b) {
    return a/gcd(a, b) * b;
}


int main() {
    ll n, t, ans=1LL;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;

    return 0;
}



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

using namespace std; 

int N, M, K, X, Y; 
int Maxx, Maxy; 

map <int, int> x, y; 
map <pair <int, int>, bool> Vis; 

bool Check(int xx, int yy){
	return Vis[{xx, yy}]; 

}

vector <int> Ax, Ay; 

int main()
{
	scanf ("%d %d %d",  &N,  &M,  &K); 
	for(int i = 1; i <= K; i++)
	{
		scanf ("%d %d",  &X,  &Y); 
		x[X]++; 
		y[Y]++; 
		Vis[{X, Y}] = 1; 
		if(x[X] > Maxx)
		{
			Ax.clear(); 
			Maxx = x[X]; 
			Ax.push_back(X); 
		} 
		else if(x[X] == Maxx) Ax.push_back(X); 

		if(y[Y] > Maxy) 
		{
			Ay.clear(); 
			Maxy = y[Y]; 
			Ay.push_back(Y); 
		}
		else if(y[Y] == Maxy) Ay.push_back(Y); 
	}
	int ans = 0; 
	for(int i = 0; i < Ax.size(); i++)
	{
		for(int j = 0; j < Ay.size(); j++){
			ans = Maxx + Maxy - Check(Ax[i], Ay[j]); 
			if(ans == Maxy + Maxx) {
				cout << ans << endl; 
				return 0; 
			}
		}
	}
	cout << Maxx + Maxy - 1 << endl; 
	return 0;
}

Measured memory_bytes: 52520
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  int a[n];
  
  for(int i=0; i<n; i++){
    cin >> a[i];
  }

  n = n - k;
  
  int ans = 1;
  for(int i=0; n>0; i++){
    n = n - k + 1;
    ans = ans + 1;
  }
    
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A > B){
  	if(A > C){
    	cout << (10*A)+B+C << endl;
    }else{
    	cout << (10*C)+A+B << endl;
    }	
  }else{
  	if(B > C){
    	cout << (10*B)+A+C << endl;
    }else{
    	cout << (10*C)+A+B << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;




int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[210],ans=0;
    cin>>n;
    rep(i,2*n) cin>>a[i];
    sort(a,a+2*n,greater<ll>());
    rep(i,2*n){
        if(i%2==1) ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

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

  if(a == b && a != c || a == c && a != b || b == c && a != b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    vector<int> tow(1000);
    tow.at(0) = 0;

    for (int i = 1; i < 1000;i++){
        tow.at(i) = tow.at(i-1) + i;
        if(tow.at(i)-tow.at(i-1)==b-a){
            cout << tow.at(i)-b << endl;
        }
        //cout << i<< " "<<tow.at(i) << endl;
    }
}


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

int main() {
  int a;
  int b;
  int c;
  int d;
    cin >> a >> b >> c >> d;
  int L;
  int R;
  	L = a + b;
    R = c + d;
  if (L > R){
    cout << "Left" << endl;
  }
  else if (L < R){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
/*** ????±??°?????????? ***/

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<n; ++i)
int co;

int func(string s){
	vector<int> vv;
	
	if(s[co]!='[' && s[co]!=']'){
		int val=s[co++]-'0';
		
		while(s[co]!=']') val=10*val+(s[co++]-'0');
		vv.push_back(val/2+1);
	}
	
	else{
		while(s[co++]=='['){
			vv.push_back(func(s));
			
			if(s[co+1]!=']') ++co;
		}
	}
	sort(vv.begin(), vv.end());
	
	int sum=0;
	REP(i, vv.size()/2+1){
		sum+=vv[i];
	}
	
	return sum;
}

int main(){
	int n;
	vector<int> v;
	cin>>n;
	
	REP(i, n){
		string s;
		cin >> s;
		co=0;
		v.push_back(func(s));
	}
	
	REP(i, n) cout << v[i] << endl;
	
	return 0;
}

Measured memory_bytes: 3284
while True:
    n, t, L, b = (int(s) for s in input().split())
    if (n, t, L, b) == (0, 0, 0, 0):
        break

    loses = [int(input()) for i in range(L)]
    backs = [int(input()) for i in range(b)]
    dp = [[0.] * n + [1.] for i in range(3)]
    stops = list(range(n + 1)) + list(reversed(range(n - 5, n)))

    for i in reversed(range(t)):
        for j in range(n):
            dp[i % 3][j] = sum(
                dp[(i + 2) % 3][d] if d in loses
                else dp[(i + 1) % 3][0] if d in backs
                else dp[(i + 1) % 3][d]
                for d in stops[j + 1:j + 7]) / 6

    print('{:.6f}'.format(dp[0][0]))

Measured memory_bytes: 6772
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

ll gcd(ll a, ll b)
{
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    while (b != 0) {
        a %= b;
        if (a == 0) return b;
        b %= a;
    }
    return a;
}

ll lcm(ll number1,ll number2){
    return number1 / gcd(number1,number2) * number2;
}

int atcoder(){
    int n;
    cin >> n;
    vector<ll> t;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        t.push_back(tmp);
    }
    ll ans = 1;
    
    REP(i,n){
        ans = lcm(ans,t[i]);
    }
    
    cout << ans << ENT;
    return 0;
}

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


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

int main(){
    int x,y,z,temp;

    cin >> x;
    cin >> y;
    cin >> z;
    
    temp = y;
    y = x;
    x = temp;
    temp = z;
    z = x;
    x = temp;
    
    cout << x << endl << y << endl << z << endl;
    
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=input()
B=input()
C=input()


c=0
for i in range(N):
    if A[i]==B[i] and B[i]==C[i]:
        continue
    if A[i]==B[i] or B[i]==C[i] or C[i]==A[i]:
        c+=1
    else:
        c+=2
print(c) 


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pi (3.141592653589)
#define endl ("\n")
using namespace std;


int main() {
  ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  int t;
  cin>>t;
  (t==0)?cout<<1:cout<<0;
  cout<<endl;

 return 0;
}


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

int main(){
    int X;cin >> X;
    int ans = 0;
    if(X<=599)ans = 8;
    else if(X<=799)ans = 7;
    else if(X<=999)ans = 6;
    else if(X<=1199)ans = 5;
    else if(X<=1399)ans = 4;
    else if(X<=1599)ans = 3;
    else if(X<=1799)ans = 2;
    else if(X<=1999)ans = 1;
    cout << ans << endl;
}






Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;

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;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  long x;
  cin >> x;
  P((x / 500) * 1000 + ((x % 500) / 5) * 5);
  return 0;
}

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

int main ( void ) {

	std::vector< int > data( 3 );

	std::cin >> data[0] >> data[1] >> data[2];

	std::sort( data.begin(), data.end() );

	if ( data[0] == 5 and data[1] == 5 and data[2] == 7 ) {
		std::cout << "YES" << std::endl;
	} else {
		std::cout << "NO" << std::endl;
	}



	return 0;
}

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

int n,m;
vector<vector<int>> v(111111);
vector<int> ans;
bool used[111111];

bool dfs(int p){
    used[p]=true;
    if(p!=0) ans.push_back(p);
    bool end = 1;
    bool ret = 0;
    
    for(auto i:v[p]){
        if(!used[i]){
            end = false;
            ret |= dfs(i);
        }
        if(ret) break;
    }

    return true;
    
}

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

    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    ans.push_back(0);
    dfs(0);
    reverse(ans.begin(),ans.end());
    dfs(0);
    cout << ans.size() << endl;
    for(auto i:ans){
        cout<<i+1<<" ";
    }
    cout<<endl;


    
    
}

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

int main() {
    int n;
    int a[30], b[30], c[30];

    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n-1; i++) cin >> c[i];

    int ans = 0;
    for(int i = 0; i < n - 1; i++) {
        ans += b[a[i]-1];
        if (a[i+1] == a[i] + 1) ans += c[a[i]-1];
    }
    ans += b[a[n-1] - 1];

    cout << ans << endl;
}

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

public class Main {
 static boolean p[];
 public static void main(String[] args) {
	 // TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
	 Scanner sc=new Scanner(System.in);
	 int n,i,count;
	 while(true){
		 n=sc.nextInt();
		 if(n==0) break;
		 count=0;
		 p=new boolean[2*n+1];
		 Arrays.fill(p, true);
		 p[0]=p[1]=false;
		 prime(p,n);
		 for(i=n+1;i<=2*n;i++){
			 if(p[i]) count++;
		 }
		 System.out.println(count);
	 }
 }
	static void prime(boolean p[],int n){
		int i,j;
		for(i=2;i<=2*n;i++){
			if(p[i]){
				for(j=2*i;j<=2*n;j+=i){
					p[j]=false;
				}
			}
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>

using namespace std;

int main(void) {
	int N;

	cin >> N;

	int *ary = new int[N];
	
	int i, x;
	for (i = 0; i < N; i++) {
		cin >> ary[i];
	}
	for (x = 0; x < N - 1; x++) {
		cout << ary[x] << " ";
	}
	cout << ary[N - 1] << endl;


	for (i = 1; i < N; i++) {
		int v = ary[i];
		int j = i - 1;
		while ((j >= 0) && (ary[j] > v)) {
			ary[j + 1] = ary[j];
			j--;
		}
		ary[j + 1] = v;

		for (x = 0; x < N - 1; x++) {
			cout << ary[x] << " ";
		}
		cout << ary[N - 1] << endl;
	}

	delete[] ary;

	int ch;
	cin >> ch;

	return 0;
}

Measured memory_bytes: 3100
n = input()

if len(set(n)) == 1:
    print(n)
else:
    n = [c for c in n]
    if n[0] < n[1] or n[0] < n[2]:
        n = str(int(n[0])+1)
        print(n*3)
    elif n[0] >= n[1] and n[0] >= n[2]:
        print(n[0]*3)




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

#define ll long long

typedef pair< int, int > ii;
typedef vector< ii > vii;

void solve(){
	int a, b; cin>>a>>b;
	int d = a, cnt = 0;
	a = 1;
	while(a < b){
		a--;
		a += d;
		cnt++;
	}
	//cout<<a<<endl;
	cout<<cnt<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//int t; cin>>t;
	cout<<fixed<<setprecision(3);
	//while(cin>>n, n){
		solve();
	//}
	return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}


int main(void) {

	string s;
	cin >> s;

	if (s.size() == 3)
		reverse(s.begin(), s.end());

	COUT(s);

	return 0;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    ll w,h,x,y,k;
    string str[3];
	cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sum=1;
    rep(i,n) sum=lcm(sum,v[i]);
        cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3636
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        //input
        Scanner sc = new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
        int sum=0;

        if (x==3 ) sum+=100000;
        else if (x == 2) sum+=200000;
        else if (x == 1) sum+=300000;

        if (y==3 ) sum+=100000;
        else if (y == 2) sum+=200000;
        else if (y == 1) sum+=300000;

        if (x == 1 && y == 1) sum+=400000;

        System.out.println(sum);
        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

Measured memory_bytes: 23636
#include <cstdio>

int f[25];

int main() {
    int sem = 0;
    char ch = fgetc(stdin);
    while (ch != '\n') {
        f[ch - 'a'] = 1 - f[ch - 'a'];
        ch = fgetc(stdin);
    }
    for (int i = 0; i <= 25; i++)
        if(f[i] == 1)
            sem = 1;
    if (sem == 1) printf("No");
    else printf("Yes");
    return 0;
}


Measured memory_bytes: 128
h, w = gets.split(" ").map{|n| n.to_i }
ans = h.times.map{
  gets.strip.split("")
}.reject{|row|
  row.all?{|d| d == "." }
}.transpose.reject{|col|
  col.all?{|d| d == "." }
}.transpose.each{|line|
  puts line.join
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 1000*1000 + 10;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll n,m,k;
    cin>>n>>m>>k;
    vl a(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
        if(i)a[i] += a[i-1];
    }
    vl b(m);
    for(int i =0;i<m;++i){
        cin>>b[i];
        if(i)b[i] += b[i-1];
    }
    int mx = 0;
    for(int i =0;i<n;++i){
        int x = i + 1;
        ll extra = k - a[i];
        if(extra >= 0){
           int id = lower_bound(all(b),extra) - b.begin();
            if(id < m && b[id] == extra)++id;
            mx = max(mx,x + id);
        }
    }
    ll ex  = k;
    if(ex >= 0){
           int id = lower_bound(all(b),ex) - b.begin();
            if(id < m && b[id] == ex)++id;
            mx = max(mx, id);
        }

    cout << mx;
    

    
    return 0;
}
    

// Химаншу


Measured memory_bytes: 6372
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def pop_count(i):
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    i = (i + (i >> 4)) & 0x0f0f0f0f
    i = i + (i >> 8)
    i = i + (i >> 16)
    return i & 0x3f

N = INT()
cards = [[]] * 2
cards[0] = LIST()
cards[1] = LIST()

# dp[S][i] := 既に使用したカードの集合がSで、最後に使った(現在の右端の)カードがiの時の最小合計転倒数
dp = list2d(1<<N, N, INF)
for i in range(N):
    # 一番左は何が来ても転倒数0
    dp[1<<i][i] = 0
for S in range(1, 1<<N):
    popcnt = pop_count(S)
    # 各位置より元indexが右側にある出現済要素の個数(転倒数)を前計算しておく
    acc = [0] * N
    for i in range(N):
        if S & 1<<i:
            acc[i] = 1
    # 後ろから累積和
    acc = list(accumulate(acc[::-1]))[::-1]
    for i in range(N):
        if dp[S][i] == INF or not S & 1<<i:
            continue
        # 遷移元の右端カードの表裏を確定
        cur = cards[(i%2)^(1-popcnt%2)][i]
        for j in range(N):
            if S & 1<<j:
                continue
            # 遷移先の右端カードの表裏を確定
            nxt = cards[(j%2)^(popcnt%2)][j]
            # 昇順が崩れないなら遷移させてOK
            if cur <= nxt:
                # 転倒数を追加して遷移
                dp[S|1<<j][j] = min(dp[S|1<<j][j], dp[S][i] + acc[j])
ans = INF
for i in range(N):
    ans = min(ans, dp[(1<<N)-1][i])
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 104496
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

string s;
map< string, string > m = { { "Sunny", "Cloudy" }, { "Cloudy", "Rainy" }, { "Rainy", "Sunny" } };

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> s;
	cout << m[ s ] << "\n";	
	return 0;
}

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

int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;

  vector<int> x(N);
  vector<int> y(M);

  for (int i = 0; i < N; i++)
  {
    cin >> x.at(i);
  }
  
  for (int i = 0; i < M; i++)
  {
    cin >> y.at(i);
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  int x_max = x.at(N - 1);
  int y_min = y.at(0);

  

  for (int i = X; i < Y + 1; i++){
    if (i > X && Y >= i && i > x_max && i <= y_min){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}

Measured memory_bytes: 3600
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			int a=0,b=0,c=0;
			int gcd=0;
			ArrayList<Integer>AL=new ArrayList<Integer>();
			ArrayList<Integer>ans=new ArrayList<Integer>();
			if(n==2)
			{
				a=in.nextInt();
				b=in.nextInt();
				AL.add(a);
				AL.add(b);
				gcd=gcd(a,b);
			}
			else
			{
				a=in.nextInt();
				b=in.nextInt();
				c=in.nextInt();
				AL.add(a);
				AL.add(b);
				AL.add(c);
				gcd=gcd(a,gcd(b,c));
			}
			for(int i=1;i<=gcd;i++)
			{
				boolean judge=true;
				for(int j=0;j<AL.size();j++)
				{
					if(AL.get(j)%i!=0)
						judge=false;
				}
				if(judge)
					ans.add(i);
			}
			for(int i=0;i<ans.size();i++)
				System.out.println(ans.get(i));
		}
	}
	static int gcd(int a,int b)
	{
		return b==0 ? a : gcd(b,a%b);
	}
	
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 19728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
int main()
{
	ll x,k,d,ans;
  	cin>>x>>k>>d;
  	x=abs(x);
  	if(x/d>k)
    	ans=x-d*k;
	else
	{
    	ll e=x/d;
    	k-=e;
    	x-=e*d;
    	if(k%2==1)
			x=abs(x-d);
    	ans=x;
  	}
  	cout<<ans<<endl;
  	return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n;
	vector<ll> v1, v2;
	ll ans = 0;

	cin >> n;

	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		v1.push_back(a);
		v2.push_back(b);
	}

	RREP(i, n) {
		ll x = (v1[i] + ans) % v2[i];
		if (x != 0) {
			ans += v2[i] - x;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 2036
N = int(input())
num = [1 for _ in range(N + 1)]
for i in range(2, N + 1):
    cnt = 1
    while cnt * i <= N:
        num[cnt * i] += 1
        cnt += 1
ans = 0
for i in range(1, N + 1):
    ans += num[i] * i
print(ans)


Measured memory_bytes: 224876
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

char str[16];

int main() {
    for (int i = 0; i < 3; i++) {
        cin >> str;
        cout << (char)toupper(str[0]);
    }
    cout << endl;

    return 0;
}


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


int main(){

  int N;
  cin >> N;
  
  vector<int> a(3 * N);
  for(int i = 0; i < 3 * N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  int64_t sum = 0;
  for(int i = N; i < 3 * N; i++){
    if((i - N) % 2 == 0){ 
    sum += a.at(i);
    }
  }
  
  cout << sum << endl;
  
  
}
 
  
 
    

  
  
  
  

Measured memory_bytes: 1408
n = int(input())
edgeList = []
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(i):
        if a[j] != -1:
            edgeList.append([a[j], i, j])
rootList = [-1]*n
sumLength = 0

def getRoot(x):
    r = rootList[x]
    if r < 0:
        rootList[x] = x
    elif r != x:
        rootList[x] = getRoot(r)
    return rootList[x]
        

edgeList.sort(key=lambda x: x[0])
for e in edgeList:
    x = getRoot(e[1])
    y = getRoot(e[2])
    if x != y:
        sumLength += e[0]
        rootList[x] = rootList[y] = min(x, y)
print(sumLength)

Measured memory_bytes: 6120
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

const int MSQ = sqrt(N) + 5;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	ll l,r;

	scanf("%lld %lld",&l,&r);
	int ans = 1e9;
	for(ll i=l;i<min(l+2020,r);i++){
		for(ll j=i+1;j<=min(l+2020,r);j++){
			ans = min((i*j)%2019,(ll)ans);
		}
	}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n;cin>>n;
    int odd=0;
    int even=0;
    if(n&1){
        odd=n/2+1;
        even=n/2;
    }else{
        odd=even=n/2;
    }
    cout<<fixed<<setprecision(10)<<1.0*odd/(even+odd);
}

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

int main(void){
  int n, a, b, i, j, count=0, A[10000];
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &a);
    j = 2;
    b = sqrt(a);
    while(a % j > 0 && j <= b) j++;
    if(j == b + 1){
      A[count] = a;
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1804
#include<map>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

ll const MAX = 200005;
string s;
ll ans_length = 1;
ll section[MAX];
ll str[MAX];
char ans[MAX];
ll alph[30];
ll const a_size = 26;

void alph_init() {
	REP(i, 1, a_size) {
		alph[i] = 0;
	}
}
bool alph_check() {
	REP(i, 1, a_size) {
		if (alph[i] == 0) {
			return false;
		}
	}
	return true;
}

void f(ll t, ll v, ll ans_length) {
	//section[v]からv+1文字目を選ぶ
	alph_init();
	REP(i, t + 1, section[v+1] - 1) {
		alph[str[i]]++;
	}
	REP(i, 1, a_size) {
		if (alph[i] == 0) {
			ans[v + 1] = i;
			break;
		}
	}
	if (v + 1 < ans_length) {
		ll tt = section[v+1];
		while (str[tt] != ans[v + 1]) {
			tt++;
		}
		f(tt, v + 1, ans_length);
	}
}

int main() {
	cin >> s;
	ll n = s.size();
	REP(i, 0, s.size() - 1) {
		str[i + 1] = s[i] - 'a' + 1;
	}
	alph_init();
	for (ll i = n; i >= 1; i--) {
		ll cur = str[i];
		alph[cur]++;
		if (alph_check()) {
			section[ans_length] = i;
			alph_init();
			ans_length++;
		}
	}
	REP(i, 1, a_size) {
		if (alph[i] == 0) {
			ans[1] = i;
			break;
		}
	}
	if (ans_length > 1) {
		reverse(section + 1, section + ans_length);
		section[ans_length] = n + 1;
		alph_init();
		ll tt = section[1];
		while (str[tt] != ans[1]) {
			tt++;
		}
		REP(i, tt + 1, section[2] - 1) {
			alph[str[i]]++;
		}
		REP(i, 1, a_size) {
			if (alph[i] == 0) {
				ans[2] = i;
				break;
			}
		}
		if (ans_length > 2) {
			tt = section[2];
			while (str[tt] != ans[2]) {
				tt++;
			}
			f(tt, 2, ans_length);
		}

	}
	REP(i, 1, ans_length) {
		cout << char((ans[i] - 1) + 'a');
	}
	cout << endl;
}

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

using namespace std;
map<int,int>m;

int main()
{
    int n;
    string s;
    cin>>n;
    cin.ignore();
    getline(cin,s);
    istringstream ss(s);
    do
    {
        string word;
        ss >> word;
        stringstream geek(word);

        int x = 0;
        geek >> x;
        m[x]++;
    }while (ss);
    for(int i=1; i<=n; i++)
    {
        cout<<m[i]<<endl;
    }
    return 0;
}


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

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

  int d = 1;
  if (D == 1)
    d = 100;
  if (D == 2)
    d = 10000;

  int num = N * d;
  if (N == 100)
    num += d;
  cout << num << endl;
}

Measured memory_bytes: 256
n, x = gets.split.map(&:to_i)
xn = gets.split.map(&:to_i).push(x).sort


max = (x - xn[-1]).abs
min = (x - xn[0]).abs
d = max.gcd(min)

n.times do |i|
  d = (xn[i]-xn[i+1]).abs.gcd(d)
end

puts d

Measured memory_bytes: 10096
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
#endif
	crap;

	int A, B, N;
	cin >> A >> B >> N;

	int x = min(B - 1, N);

	cout << (A * x) / B << endl;


	return 0;
}

Measured memory_bytes: 3556
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 area =a*b;
  int length =(a+b)*2;
  System.out.println(area + " " + length);
  }
}

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

int main()
{
    long n;
    long long sum = 0;
    int min, max;

    cin >> n;

    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        sum += a.at(i);
    }
    sort(a.begin(), a.end());
    min = a.at(0);

    reverse(a.begin(), a.end());
    max = a.at(0);

    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3188
K = int(input())

def func_gcd(a, b):
    if b > a:
        a, b = b, a
    
    while b > 0:
        r = a % b
        a = b
        b = r

    return a

ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for l in range(1, K + 1):
            temp = func_gcd(j, l)
            temp2= func_gcd(i, temp)
            ans += temp2

print(ans)


Measured memory_bytes: 69224
#include <cstdio>  
#include <cstring>  
#include <queue>
#include <stack> 
#include <algorithm>  
using namespace std; 
long long N,a[10010],b[10010],c[10010],i,j,s,ax,bx,t;      
int main()  
{ 
	
	scanf("%lld",&N);
	for(i=0;i<N;i++)
		scanf("%lld",&a[i]);
	for(s=ax=bx=i=0;i<N;i++)
	{
		scanf("%lld",&b[i]);
		c[i]=b[i]-a[i];
		if(c[i]>0)
		{
			bx+=c[i];
			if(c[i]%2)
				s++;
		}			
		else
			ax+=c[i];
	}
	if((bx-s)/2>=(-ax)&&(bx>(-ax)||(bx==0&&ax==0)))
		printf("Yes\n");
	else
		printf("No\n");
	return 0; 
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
const int inf=1e9+10;
int n,m,dp[110][110];
char s[110][110];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=m;j++) dp[i][j]=inf;
	for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
	if (s[1][1]=='#') dp[1][1]=1;else dp[1][1]=0;
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=m;j++)
	 {
	 	if (i==1 && j==1) continue;
	 	if (i-1>=1) dp[i][j]=min(dp[i][j],dp[i-1][j]+(s[i-1][j]=='.' && s[i][j]=='#'));
	 	if (j-1>=1) dp[i][j]=min(dp[i][j],dp[i][j-1]+(s[i][j-1]=='.' && s[i][j]=='#'));
	 }
	printf("%d\n",dp[n][m]);
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b;
    int c,d;
    while(1){
    scanf("%d %d",&a,&b);
    if(a==0 && b==0) return 0;
    for(c=1;c<=a;c++)
    {
        if(c==1 || c==a)
        {
            for(d=1;d<=b;d++)
            {
                printf("#");
                if(d==b) printf("\n");
            }
        }else{
        for(d=1;d<=b;d++)
        {
            if(d==1 || d==b)
            {
                printf("#");
            }else{
            printf(".");
            }
            if(d==b) printf("\n");
        }
        }
    }
    printf("\n");
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int n; scanf("%d", &n);
  vector<vector<int>> freqs(n, vector<int>(128, 0));
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    for (int j = 0; j < (int)s.size(); ++j) {
      ++freqs[i][s[j] - 'a'];
    }
  }
  string ans;
  for (int i = 0; i <= 26; ++i) {
    int cnt = 100;
    for (int j = 0; j < n; ++j) {
      cnt = min(cnt, freqs[j][i]);
    }
    ans += string(cnt, 'a' + i);
  }
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#include <climits>
#include <deque>
#include <random>
#include <functional>
#include <unordered_map>
#define rep(i,n) for(int i=0;i < (int)(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    string s;
    cin >> s;
    rep(i,2){
        if(stoi(s.substr(i,3))%111 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout <<"No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
int n,k;
int a[N];
int main()
{
	cin>>k>>n;
	rep(i , 1 , n + 1)
		cin>>a[i];
	int mn = k;
	rep(i , 2 , n + 1){
		int now = (a[i] - a[i-1]); 
		mn = min(mn,k - now);
	}
	mn = min(mn,k - (k - a[n] + a[1]));
	cout<<mn<<"\n";
	return 0;
}



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

int main() {
    ll H, W;
    cin >> H >> W;
    ll a = H * W;
    if(H == 1 || W == 1){
        cout << 1;
        return 0;
    }
    if(a % 2 == 0){
           cout << a / 2;
    }
    else{
        cout << a/2 + 1;
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int T,X;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T>>X;
	_P("%.12lf\n",1.0*T/X);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

public class Main {
    public static InputReader in;
    public static PrintWriter out;
    static int n;
    static int m;
    static char[][] a;
    static int[][] dp;

    public static void main(String[] args) {
        in = new InputReader(System.in);
        out = new PrintWriter(System.out);
        n = in.nextInt();
        m = in.nextInt();
        a = new char[n + 5][m + 5];
        dp = new int[n + 5][m + 5];
        for (int i = 0; i < n; i++) {
            a[i] = in.next().toCharArray();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                dp[i][j] = 100000000;
            }
        }
        dp[0][0] = (a[0][0] == '#') ? 1 : 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (dp[i][j] != 100000000) continue;
                if (a[i][j] == '#') {
                    if (i - 1 >= 0 && a[i - 1][j] == '#') dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]);
                    if (i - 1 >= 0 && a[i - 1][j] == '.') dp[i][j] = Math.min(dp[i][j], dp[i - 1][j] + 1);
                    if (j - 1 >= 0 && a[i][j - 1] == '#') dp[i][j] = Math.min(dp[i][j], dp[i][j - 1]);
                    if (j - 1 >= 0 && a[i][j - 1] == '.') dp[i][j] = Math.min(dp[i][j], dp[i][j - 1] + 1);
                } else {
                    if (i - 1 >= 0 && a[i - 1][j] == '#') dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]);
                    if (i - 1 >= 0 && a[i - 1][j] == '.') dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]);
                    if (j - 1 >= 0 && a[i][j - 1] == '#') dp[i][j] = Math.min(dp[i][j], dp[i][j - 1]);
                    if (j - 1 >= 0 && a[i][j - 1] == '.') dp[i][j] = Math.min(dp[i][j], dp[i][j - 1]);
                }
            }
        }
        out.println(dp[n - 1][m - 1]);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public Long nextLong() {
            return Long.parseLong(next());
        }
        public Double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}



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

string cnt_string( string str )
{
	string kotae = "";
	char prev = 0;
	int cnt = 1;

	for ( int i = 0; i < str.size(); i++ )
	{
		if ( str[i] == prev )
		{
			cnt ++;
		}
		else if ( prev != 0 )
		{
			ostringstream os1;
			os1 << cnt << prev;
			kotae += os1.str();
			cnt = 1;
		}
		prev = str[i];
	}

	ostringstream os2;
	os2 << cnt << prev;
	kotae += os2.str();

	return kotae;
}

int main( void )
{
	int n;
	while ( cin >> n && n != 0 )
	{
		string in;
		cin >> in;

		string str = in;
		for ( int i = 0; i < n; i++ )
		{
			str = cnt_string( str );
		}

		cout << str << endl;

	}

	return 0;
}

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

int main(){
	int h,n,k;
  	cin>>h>>n;
  	while(n--){
      	cin>>k;
    	h=h-k;
      	if(h==0 || h<0) {cout<<"Yes"; return 0;}
    }
  	cout<<"No";
}


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

int main()
{
    int c = 2,t = 4;
    int x,y,soma = 0;
    cin >> x >> y;
    int a[x];
    for (int i = 0;i < x;i++)
    {
        a[i] = c;
        soma += a[i];
    }
    if (soma == y)
    {
        cout << "Yes" << endl;
    }
    else
    {
        for (int i = 0;i < x;i++)
        {
            soma = 0;
            a[i] = t;
            for (int j = 0;j < x;j++)
            {
                soma += a[j];
            }
            if (soma == y)
            {
                cout << "Yes" << endl;
                break;
            }
        }
    }
    if (soma != y)
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define P(p) cout<<(p)<<endl;
using namespace std;
typedef long long ll;
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

unsigned long long sttoi(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

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


void solve() {
	while (true){
		int n, s;
		cin >> n >> s;
		int count = 0;
		if (n == 0 && s == 0){
			break;
		}
		for (int i = 0; i <= 1 << 10; i++){
			int bitcnt = 0;
			int sum = 0;
			for (int j = 0; j < 10; j++){
				if (1 << j & i){
					bitcnt++;
					sum += j;
				}
			}
			if (bitcnt == n && sum == s){
				count++;
			}
		}
		P(count);
	}

}

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

Measured memory_bytes: 1164
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    h, w = map(int, readline().split())
    p, q = map(int, readline().split())

    print(h * w - p * w - q * (h - p))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61652
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#define endl "\n"
#define START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    int n,c1=0,c2=0,c3=0,c4=0;
    cin>>n;
    while(n--)
    {
        string c;
        cin>>c;
        if("AC"==c)
        {
            c1++;
        }
        else if("WA"==c)
        {
            c2++;
        }
        else if("TLE"==c)
        {
            c3++;
        }
        else if("RE"==c)
        {
            c4++;
        }
    }
    cout<<"AC x "<<c1<<"\n";
    cout<<"WA x "<<c2<<"\n";
    cout<<"TLE x "<<c3<<"\n";
    cout<<"RE x "<<c4<<"\n";
    return 0;
}


Measured memory_bytes: 3592