akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){

    int N,M;
    while(cin>>N>>M,N){
        int p[1200];
        p[0] = 0;
        for(int i = 1;i <= N;i++)cin>>p[i];
        vector<int> V;
        for(int i = 0;i <= N;i++){
            for(int j = 0;j <= N;j++){
                V.push_back(p[i]+p[j]);
            }
        }
        sort(V.begin(),V.end());
        int ans = 0;
        for(int i = 0;i < V.size();i++){
            if(V[i]>M)continue;
            vector<int>::iterator it = lower_bound(V.begin(),V.end(),M-V[i]);
            it--;
            //cout<<V[i]<<" "<<*it<<endl;
            ans = max(ans,V[i] + *it);
        }
        cout<<ans<<endl;
    }

    return 0;
}

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

using namespace std;

const int N = 505;

int a[N][N], r[N][N], n, m;
int cnt[N];
set<pair<int, int> > prio[N];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", a[i]+j);
      a[i][j]--;
      r[i][a[i][j]] = j;
      prio[i].insert(make_pair(j, a[i][j]));
    }
    cnt[a[i][0]]++;
  }
  set<int> st;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    st.insert(i);
    ans = max(ans, cnt[i]);
  }
  for (int i = 0; i < m; i++) {
    memset(cnt, 0, sizeof cnt);
    for (int j = 0; j < n; j++)
      cnt[prio[j].begin()->second]++;
    int cur = 0;
    int del = 0;
    for (int c : st) {
      if (cur < cnt[c]) {
        cur = max(cur, cnt[c]);
        del = c;
      }
    }
    ans = min(ans, cur);
    st.erase(del);
    for (int j = 0; j < n; j++) {
      prio[j].erase(make_pair(r[j][del], del));
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>

int main(void)
{
	int i,tak,nak,hik;
	long long K,Un=10000000000000000000;
	scanf("%d %d %d %d",&tak,&nak,&hik,&K);
	if(tak-nak>=Un&&Un-(tak-nak)<=0){
		if(K%2==0){
			printf("%d\n",tak-nak);
		}else if(K%2==1){
			printf("%d\n",nak-tak);
		}
	}else{
		printf("Unfair\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
vector<int64_t> v;
void gett()
{
  int64_t p,l;
  v.push_back(0);
  p = 0;
  l=26;
  while(p<1000000000000001)
  {
    p+=l;
    v.push_back(p);
    l*=26;
  }
} 
int main()
{
  int64_t n,m,k,l;
  cin>>n;
  int i=0;
  gett();
  while(v[i+1]<n && i<v.size()-1) i++;
  n = n - v[i]-1;
  string ans="";
  //if(!n)
  {
      //for(int j=0;j<i+1;j++) ans+="a";
  }
  while(n>0)
  {
    ans=char(97+n%26)+ans;
    n=n/26;
    i--;
  }
  for(int j=0;j<i+1;j++) ans="a"+ans;
  cout<<ans;
  return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    vl A(n);
    rep(i,n)cin>>A[i];
    ll m=A[0];
    ll res=0;
    rep(i,n-1){
        if(A[i+1]<m){
            res+=m-A[i+1];
        }else if(A[i+1]>m){
            m=A[i+1];
        }
    }
    cout<<res<<endl;
}

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

int main(){
    int e;
    while(cin >> e, e){
        int ans = e;
        for(int z = 0; z*z*z <= e; z++){
            for(int y = 0; z*z*z+y*y <= e; y++){
                ans = min(ans, z+y+(e-z*z*z-y*y));
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
  int K,A,B;
  cin >> K;
  cin >> A >> B;
  if(A % K == 0 || B % K == 0 || (B / K) - (A / K) >= 1){
    cout << "OK" << endl;
    return 0;
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll x,y,z,k;
	cin>>x>>y>>z>>k;
	vector<ll> a(x),b(y),c(z);
	for(int i = 0; i < x; i++){
		cin>>a[i];
	}
	for(int i = 0; i < y; i++){
		cin>>b[i];
	}
	for(int i = 0; i < z; i++){
		cin>>c[i];
	}
	sort(all(a));
	reverse(all(a));
	sort(all(b));
	reverse(all(b));
	sort(all(c));
	reverse(all(c));
	
	vector<ll> sum_bc;
	for(int i = 0; i < y; i++){
		for(int j = 0; j < z; j++){
			sum_bc.push_back(b[i]+c[j]);
		}
	}
	sort(all(sum_bc));
	reverse(all(sum_bc));

	vector<ll> sum_abc;
	for(int i = 0; i < x; i++){
		for(int j = 0; j < min((ll)sum_bc.size(),k); j++){
			sum_abc.push_back(a[i]+sum_bc[j]);
		}
	}
	sort(all(sum_abc));
	reverse(all(sum_abc));
	for(int i = 0; i < k; i++){
		cout<<sum_abc[i]<<endl;
	}

	return 0;
}

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

const int N = 20;

typedef long long LL;

int a[N];

LL dfs(int l, int r, int tl, int tr) {
    if (l > r) return 0;
    LL res = 1e18; 
    for (int i = l; i <= r; i++) 
        res = min(res, dfs(l, i - 1, tl, tl + tr) + dfs(i + 1, r, tl + tr, tr) + (LL)a[i] * (tl + tr));
    return res;
}

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

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>

using namespace std;

int A[100000], ocurrences[100001];


int main()
{
    int N, i, Q, B, C;
    long long sum;

    scanf("%d", &N);
    memset(ocurrences, 0, sizeof ocurrences);
    sum = 0;
    for(i = 0; i < N; ++i){
        scanf("%d", &A[i]);
        ++ocurrences[A[i]];
        sum += A[i];
    }
    scanf("%d", &Q);
    while(Q--){
        scanf("%d%d", &B, &C);
        ocurrences[C] += ocurrences[B];
        sum += ocurrences[B] * 1LL * (C - B);
        ocurrences[B] = 0;
        printf("%lld\n", sum);
    }

    return 0;
}


Measured memory_bytes: 2512
using System;

class Program
{
    static void Main(string[] args)
    {
        string str1 = Console.ReadLine();
        int N = Int32.Parse(str1);

        int X = (int)Math.Ceiling(N / 1.08);
        int NR = (int)Math.Floor(X * 1.08);
        if (N == NR)
        {
            Console.WriteLine(X.ToString());
        }
        else
        {
            Console.WriteLine(":(");
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )

using namespace std;

typedef long long Lint;
typedef long double db;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef pair<db,db> dd;
typedef pair<int,string> is;

const int maxn = 1000020;
const int K = 60;
const int MOd = 998244353;

int ar[maxn], a, bs[maxn];
string s;
int sz;
int x = 1;

int get(int x) {
	int ret = 0;
	while( x ) {
		x /= 2;
		ret += x;
	}
	return ret;
}

void go() {
	int ans = 0;
	for(int i=0;i<sz;i++) {
		int h = get( sz-1 )-get( i )-get( sz-1-i );
		if( h == 0 && ar[i+1] == 1 ) ans ^= 1;
	}
	if( x == 1 ) ans *= 2;
	cout << ans << endl;
}

int solve(  ) {
	scanf("%d",&a);
	cin >> s;
	a = s.size();
	sz = a;
	for(int i=1;i<=a;i++)
		ar[i] = s[i-1]-'1';
	for(int i=1;i<a;i++) {
		for(int j=1;j<=a-i;j++) bs[j] = abs( ar[j]-ar[j+1] );
		for(int j=1;j<=a-i;j++) {
			ar[j] = bs[j];
			//printf("%d",ar[j]);
			if( i == 1 && ar[j] == 1 ) x = 0;
		}
		//printf("\n");
		if( i == 1 && x == 1 )
			for(int j=1;j<=a-i;j++)
				ar[j] /= 2;
		sz--;
		if( i==1 ) go();
		break;
	}
	return 0;
}

int main(  ) {
	int n = 1;
	//scanf("%d",&n);
	for(int i=1;i<=n;i++) solve(  );
	return 0;
}


Measured memory_bytes: 9220
import java.util.*;
 
public class Main {
    public static void main(String[] args)   {
        
    	Scanner sc= new Scanner(System.in);
    	int n=sc.nextInt();
    	sc.nextLine();
        String s = sc.nextLine();
        char[] c=new char[n];
        c=s.toCharArray();
    	char[] test=new char[n];
        
    	if(n%2==1||n!=s.length()) {
    		System.out.println("No");
    	}else{
    		for(int i=0;i<(n/2);i++){
    			test[i]=c[i];
    			test[n/2+i]=c[i];
    		}
    		String test_s=String.valueOf(test);
    		String c_s=String.valueOf(c);
    		if(test_s.equals(c_s)) {
    			System.out.println("Yes");
    		}else {
    			System.out.println("No");
    		}
    	}
    }
}

Measured memory_bytes: 21716
s = list(input())

s1 = int(s[0] + s[1])
s2 = int(s[2] + s[3])

if 1<= s1 <= 12 and 1 <= s2 <= 12:print('AMBIGUOUS')
elif 1 <= s1 <= 12:print('MMYY')
elif 1 <= s2 <= 12:print('YYMM')
else:print('NA')

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int t[N];
int p[N];
int x[N];
void solve(){
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> t[i];
	}
	int m;
	cin >> m;
	for(int i=1;i<=m;i++){
		cin >> p[i] >> x[i];
	}
	for(int i=1;i<=m;i++){
		int tmp = t[p[i]];
		t[p[i]] = x[i];
		int ans = 0;
		for(int j = 1;j<=n;j++) ans += t[j];
		cout<<ans<<endl;
		t[p[i]] = tmp;
	}
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    cout << (n-1+k-2) / (k-1) << endl;
}

Measured memory_bytes: 3712
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		 int A = sc.nextInt();
		 int B = sc.nextInt();
		 
	     int ans = A + B;
	     int b = A - B;
	     if(ans < b) {
	    	 ans = b;
	     }
	     int c = A * B;
	     if(ans < c) {
	    	 ans = c;
	     }
	     
		 System.out.println(ans);
	}
}


Measured memory_bytes: 22608
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        double thetaM = Math.toRadians(6 * M);
        double thetaH = Math.toRadians(30 * H + 0.5 * M);
        double thetaDiff = thetaM - thetaH;

        double ans = Math.sqrt(Math.pow((double)A, 2) + Math.pow((double)B, 2) - 2*A*B*Math.cos(thetaDiff));
        System.out.println(ans);

    }
}

Measured memory_bytes: 36024
n, y = map(int, input().split())
ans = [-1, -1, -1]
for senen in range(n+1):
    for gosenen in range(n-senen+1):
        itimanen = n-senen-gosenen
        if senen*1000 + gosenen*5000 + 10000*itimanen == y:
            ans = [itimanen, gosenen, senen]
            break
    else:
        continue
    break


print(*ans)

Measured memory_bytes: 64856
using namespace std;
#include <iostream>
#include<bits/stdc++.h>
#define pb push_back
#define MAX 300
#define pi 3.1415926536
#define ip pair<int,int>
#define mp make_pair
#define ss second
#define ff first
#define ull unsigned long long
#define ll long long
#define MOD 1000000000
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fn(i,n) for (ll i=0; i<n; i++)
#define endl "\n"
#define Endl endl
#define EN cout<<endl;
#define inp(n) int n; cin>>n;
#define TEST int t; cin>>t; while(t--)
ll power(ll x, ll y, ll p) { int 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 PO(ll a, ll n) { ll val=1; fn(i,n) val*=a; return val;  }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); }
 
signed main ()
{
    inp(a); inp(b);
  	int c = max(a+b, a-b);
  	cout<<max(c,a*b);
  EN
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<climits>
#define inf 1e9+1
#define int long long
using namespace std;
int n, W;
int wt[101];
int val[101];
int maxVal;
int dp[101][100005];


int knapsack2(int n, int W) {


	for(int i=0;i<=n;i++)
		for(int j=0;j<=maxVal;j++)
			dp[i][j]=inf;

        dp[0][0]=0;

	for (int i = 1; i <= n; i++) {
		for (int v = 0; v <= maxVal; v++) {
			
			if (v == 0)
				dp[i][v] = 0;
			else {
				dp[i][v] = dp[i - 1][v];
				
				if (val[i - 1] <= v) {
                   
					dp[i][v] = min(dp[i][v], (dp[i - 1][v - val[i - 1]] + wt[i - 1]));
					
				}
			}
		}
	}


	int ans = 0;

	for (int i = 0; i <= maxVal; i++) {
		if (dp[n][i] <= W)
			ans = max(ans, i);
	}

	return ans;
}





int32_t main() {

	cin >> n >> W;

	maxVal = 0;
	for (int i = 0; i < n; i++) {
		cin >> wt[i] >> val[i];
		maxVal += val[i];
	}

	cout << knapsack2(n, W) << endl;

}

Measured memory_bytes: 82452
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) {
		FastScanner cin = new FastScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(FastScanner cin, PrintWriter cout) {
		assert solve(3, 5) == 0;
		assert solve(4, 5) == 2;
		assert solve(5, 5) == 4;

		assert solve(100000, 100000) == 50000;
		assert solve(100000, 2) == 1;
		long h = cin.nextInt();
		long w = cin.nextInt();
		long ans = solve(h, w);
		cout.println(ans);
	}

	private static long solve(long h, long w) {
		long ans = Long.MAX_VALUE;
		for (long i = Math.max(1, w / 3); i < Math.min(w / 3 + 2, w); i++) {
			for (long j = Math.max(1, h / 2); j < Math.min(h / 2 + 2, h); j++) {
				long sq1 = i * h;
				long sq2 = (w - i) * j;
				long sq3 = (w - i) * (h - j);
				long[] sqs = { sq1, sq2, sq3 };
				Arrays.sort(sqs);
				ans = Math.min(ans, sqs[2] - sqs[0]);
			}
			long ww = w - i;
			for (long j = Math.max(1, ww / 2); j < Math.min(ww / 2 + 2, ww); j++) {
				long sq1 = i * h;
				long sq2 = j * h;
				long sq3 = (ww - j) * h;
				long[] sqs = { sq1, sq2, sq3 };
				Arrays.sort(sqs);
				ans = Math.min(ans, sqs[2] - sqs[0]);
			}
		}
		for (long i = Math.max(1, h / 3); i < Math.min(h / 3 + 2, h); i++) {
			for (long j = Math.max(1, w / 2); j < Math.min(w / 2 + 2, w); j++) {
				long sq1 = i * w;
				long sq2 = (h - i) * j;
				long sq3 = (h - i) * (w - j);
				long[] sqs = { sq1, sq2, sq3 };
				Arrays.sort(sqs);
				ans = Math.min(ans, sqs[2] - sqs[0]);
			}
			long hh = h - i;
			for (long j = Math.max(1, hh / 2); j < Math.min(hh / 2 + 2, hh); j++) {
				long sq1 = i * w;
				long sq2 = j * w;
				long sq3 = (hh - j) * w;
				long[] sqs = { sq1, sq2, sq3 };
				Arrays.sort(sqs);
				ans = Math.min(ans, sqs[2] - sqs[0]);
			}
		}
		return ans;
	}

	/**
	 * How to read input in Java — tutorial <br />
	 * By Flatfoot<br />
	 * http://codeforces.com/blog/entry/7018
	 */
	static class FastScanner {
		private BufferedReader br;
		private StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new IllegalStateException(e);
				}
			return st.nextToken();
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
			return str;
		}

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

}


Measured memory_bytes: 23124
while True:
    i = input()
    H, W = map(int,i.split())
    
    if H == 0 and W == 0:
        break
    
    for h in range(H):
        for w in range(W):
            if (h+w) % 2 == 0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7008
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        a: i64,
        b: i64,
        n: i64,
    }
    let r = min(n, b - 1);
    println!("{}", (a * r) / b);
}


Measured memory_bytes: 2168
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, M;
    std::cin >> N >> M;

    struct Req {
        int64_t a;
        int64_t b;
    };

    std::vector<Req> reqs;
    for (decltype(M) i = 0; i < M; ++i) {
        int64_t a, b;

        std::cin >> a >> b;
        a--;
        b--;
        reqs.push_back({a, b});
    }

    std::sort(std::begin(reqs), std::end(reqs),
              [](const auto& r, const auto& l) {
                  return r.a == l.a ? r.b > l.b : r.a < l.a;
              });
#if 0
    for (auto r: reqs) {
        cerr << r.a << " " << r.b << endl;
    }
    cerr << endl;
#endif

    int64_t ans = 1;
    int64_t rmin = reqs[0].a;
    int64_t rmax = reqs[0].b;
    for (int64_t i = 1; i < M; ++i) {
        if (rmax <= reqs[i].a) {
            // cerr << "!!" << rmin << " " << rmax << endl;
            ans ++;
            rmin = reqs[i].a;
            rmax = reqs[i].b;
        }
        else {
            rmin = std::max(rmin, reqs[i].a);
            rmax = std::min(rmax, reqs[i].b);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2420
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=2e3+9;
int node[N][N],ver[N][N],hor[N][N];
char arr[N][N];
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)	
		for(int j=1;j<=m;j++){
			scanf(" %c",&arr[i][j]);
			node[i][j]=(arr[i][j]-'0')+node[i-1][j]+node[i][j-1]-node[i-1][j-1];
			ver[i][j]=((arr[i][j]-'0')&(arr[i][j-1]-'0'))+ver[i-1][j]+ver[i][j-1]-ver[i-1][j-1];
			hor[i][j]=((arr[i][j]-'0')&(arr[i-1][j]-'0'))+hor[i-1][j]+hor[i][j-1]-hor[i-1][j-1];
		}
	while(q--){
		int x,y,xx,yy;
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		int nodes=node[xx][yy]-node[xx][y-1]-node[x-1][yy]+node[x-1][y-1];
		int edges=ver[xx][yy]-ver[xx][y]-ver[x-1][yy]+ver[x-1][y];
		edges+=hor[xx][yy]-hor[xx][y-1]-hor[x][yy]+hor[x][y-1];
		printf("%d\n",nodes-edges);
	}	
	return 0;
}


Measured memory_bytes: 52992
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

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

    int h,w;
    cin >> h >> w;
    string s[h];
    rep(i,h)cin >> s[i];
    rep(i,w+2)cout << "#";
    cout << endl;
    rep(i,h){
        cout << "#";
        cout << s[i] << "#" << endl;
    }
    rep(i,w+2)cout << "#";
    cout << endl;
}

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

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;
    ArrayList<Integer> primes = new ArrayList<>();
    long MOD = 1000000007;

    public void go() throws IOException
    {
        ntok();
        int n = ipar();
        int k = ipar();
        long sum = 0;
        long[] counts = new long[k+1];
        for (int i = k; i >= 1; i--) {
            long count = modPow(k/i, n);
            for (int e = 2; e*i <= k; e++) {
                count += MOD - counts[i*e];
                count %= MOD;
            }
            counts[i] = count;
            sum += count * i;
            sum %= MOD;
        }
        out.println(sum);

        out.flush();
        in.close();
    }

    public long modPow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 0) {
            return modPow(a*a%MOD, b/2);
        } else {
            return modPow(a*a%MOD, b/2) * a % MOD;
        }
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

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


Measured memory_bytes: 34160
from collections import defaultdict
n,m = map(int, input().split())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in a:
    d[i] += 1
for i in range(m):
    b,c = map(int,input().split())
    d[c] += b
ans = 0
for i in sorted(d.keys(), reverse=True):
    if d[i] >= n:
        ans += i*n
        break
    else:
        ans += d[i]*i
        n -= d[i]
print(ans)

Measured memory_bytes: 32448
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

inf = 10**18
dp = [[inf] * W for _ in range(H)]
if grid[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(H):
    for j in range(W):
        if i != 0:
            tmp = dp[i - 1][j] + int(grid[i][j]=="#" and grid[i - 1][j]==".")
            dp[i][j] = min(dp[i][j], tmp)
        if j != 0:
            tmp = dp[i][j - 1] + int(grid[i][j]=="#" and grid[i][j - 1]==".")
            dp[i][j] = min(dp[i][j], tmp)

ans = dp[H - 1][W - 1]
print(ans)

Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int main(){
    int a; cin >> a;
    int i = 0, ans = 0;
    while(i<2){
        int x; cin >> x;
        ans += min(a,x);
        a = max(a,x);
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int a[10];
    REP(i,10)
        cin >> a[i];
    sort(a,a+10);
    reverse(a,a+10);
    REP(i,3)
        cout << a[i] << '\n';
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, p;
    string s;
    cin >> n >> p;
    cin >> s;
    vector<int> tens(n + 1, 0);
    map<int, int> cnt;
    tens[0] = 1;
    cnt[0] = 1;
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        tens[i] = (tens[i - 1] * 10) % p;
    }
    if (p == 2 || p == 5) {
        for (int i = 0; i < n; i++) {
            if ((s[i] - '0') % p == 0) {
                res += (i + 1);
            }
        }
    } else {
        ll cur = 0;
        for (int i = 0; i < n; i++) {
            cur += (s[i] - '0') * tens[n - i - 1];
            cur %= p;
            res += cnt[cur];
            cnt[cur]++;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1684
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i,0,n) cin >> a[i];
  rep(i,0,n) cin >> b[i];
  vector<int> sa(n), sb(n);
  sa[0] = a[0], sb[n-1] = b[n-1];
  rep(i,1,n) sa[i] = a[i] + sa[i-1];
  rrep(i,n-1,0) sb[i] = b[i] + sb[i+1];
  int ans = 0;
  rep(i,0,n) {
    ans = max(ans, sa[i] + sb[i]);
  }
  cout << ans << endl;
  return 0;
}

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

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;

    if (s == "Sunny") cout << "Cloudy" << endl;
    else if (s == "Cloudy") cout << "Rainy" << endl;
    else if (s == "Rainy") cout << "Sunny" << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1e9;

int main(){
	int n,f[100][10],p[100][11];
	cin>>n;
	rep(i,n) rep(j,10) cin>>f[i][j];
	rep(i,n) rep(j,11) cin>>p[i][j];

	int ans=-INF;
	for(int S=1;S<1024;S++){
		int sum=0;
		rep(i,n){
			int cnt=0;
			rep(j,10) if((S>>j&1) && f[i][j]==1) cnt++;
			sum+=p[i][cnt];
		}
		ans=max(ans,sum);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
// 2_abc128_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

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 SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> v(n);
    rep(i, n){
        string s;
        int p;
        cin >> s;
        cin >> p;
        v[i].first.first = s;
        v[i].first.second = -p;
        v[i].second = i + 1;
    }
    sort(v.begin(), v.end());
    rep(i, n){
        cout << v[i].second << endl;
    }
    return 0;
}


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

int main(void){
    string S;
    cin >> S;
    
    vector<int> cnt(S.size());
    int i = 0;
    while(i < S.size()){
        if(S.at(i) == 'A' || S.at(i) == 'T' || S.at(i) == 'C' || S.at(i) == 'G'){
            int j = i;
            while(j < S.size()){
                if(S.at(j) == 'A' || S.at(j) == 'T' || S.at(j) == 'C' || S.at(j) == 'G'){
                    cnt.at(i)++;
                    j++;
                    continue;
                }
                i++;
                break;
            }
        }
        i++;
    }
    
    int max = 0;
    for(int i = 0 ; i < cnt.size() ; i++){
        if(max < cnt.at(i)){
            max = cnt.at(i);
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
  int x, y, r, c ;
  scanf("%d %d",&x,&y) ;

  if(x < y) {
    c = x ;
    x = y ;
    y = c ;
  }

  r = x % y ;
  while(r != 0) {
    x = y ;
    y = r ;
    r = x % y ;
  }

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

  return 0 ;
}


Measured memory_bytes: 2144
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;
vi g[52];
signed main()
{
    int n,m; 
    cin>>n>>m;
    for (int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    for (int i=1;i<=n;i++){
        cout << sz(g[i]) << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
vector<int> g[30];
vector<int> ans;
bool used[30];
void dfs(int n)
{
	if(!used[n])
	{
		used[n]=true;
		for(int i=0;i<g[n].size();i++)
		{
			dfs(g[n][i]);
		}
		ans.pb(n);
	}
}
int main()
{
	int m,n;
	cin >> m >> n;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin >> a >> b;
		g[a].pb(b);
	}
	for(int i=1;i<=m;i++)
	{
		dfs(i);
	}
	reverse(all(ans));
	for(int i=0;i<ans.size();i++)
	{
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())



Measured memory_bytes: 9716
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        if (a < b) { for (int i = 0; i < b; i++) { Console.Write(a); } }
        else { for (int i = 0; i < a; i++) { Console.Write(b); } }
    }
}


Measured memory_bytes: 13140
n, m, L = map(int, input().split())
   
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
c = [[sum(ak * bk for ak, bk in zip(ai,bj)) for bj in zip(*b)] for ai in a]
   
for ci in c:
    print(*ci)

Measured memory_bytes: 9056
#include <cstdio>
using namespace std;


int main (void)
{
	int n, x, i, j, k, count, sum;

	while (scanf("%d %d", &n, &x)!=EOF && n!=0 || x!=0){
		count = 0;
		for (i=1; i<=n; i++){
			for (j=i+1; j<=n; j++){
				for (k=j+1; k<=n; k++){
					if (i != j && j != k && k != i){
						sum = i + j + k;
						if (sum == x)
							count++;
					}
				}
			}
		}

		printf("%d\n", count);
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	int n, d, ans;
	scanf("%d%d", &n, &d);
	if (n % 2 == 1){
		ans = 127 * (n - 1) + d;
	} else {
		ans = 127 * (n - 1) + 127 - d;
	}
	printf("%d\n", ans);
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum=0;
        int n=sc.nextInt();
        int least=Integer.MAX_VALUE;
        int tmp;
        for(int i=0;i<n;i++){
            tmp=sc.nextInt();
            sum+=tmp;
            if(tmp%10!=0){
                least=Math.min(least, tmp);
            }
        }
        System.out.println(sum%10==0?Math.max(0, sum-least):sum);
    }
}

Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> vi;
struct edge { int v; ll w; };

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

int main() {
	vector<int> a(26, INF);
	int N; cin >> N;
	while (N--) {
		string s; cin >> s;
		vector<int> b(26);
		for (char c: s) b[c - 'a']++;
		rep(k, 26) a[k] = min(a[k], b[k]);
	}
	string s;
	rep(k, 26) rep(t, a[k]) s.pb('a' + k);
	cout << s << endl;
}


Measured memory_bytes: 764
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
long long int lis[300000];
using namespace std;
int main(){
    int N,T;
    cin>>N>>T;
    for(int i=0;i<N;i++)cin>>lis[i];
    long long int ans=0;
    for(int i=0;i<N-1;i++)ans+=min((long long int)T,lis[i+1]-lis[i]);
    ans+=T;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(void){
    ll N;
    cin >> N;
    
    vector<ll> a(N);
    for(ll i = 0; i < N; i++){
        cin >> a.at(i);
    }
    
    sort(a.begin(), a.end());
    
    ll ai = a.at(a.size() - 1);
    
    ll sug = lower_bound(a.begin(), a.end(), ai/2) - a.begin(); //ajはa.at(sug)かa.at(sug-1)
    
    ll aj;
    if(sug == N){
        aj = a.at(sug -1);
    }
    else if(sug >= 1){
        if(a.at(sug) - (ai+1)/2 >= ai/2 - a.at(sug-1)){
            aj = a.at(sug - 1);
        }
        else{
            aj = a.at(sug);
        }
    }
    else{
        aj = a.at(sug);
    }
    
    printf("%lld %lld", ai,aj);
}




Measured memory_bytes: 1024
def main():
	N, K = [int(a) for a in input().split(" ")]
	if N == K:
		for i in range(K):
			if i == 0:
				print(1)
			else:
				print(0)
		return 0

	lim = max([K, N - K]) + K + 1
	p = 1000000007
	f = []
	for i in range(lim):
		if i == 0:
			f.append(1)
		else:
			f.append((f[-1] * i) % p)
	lf = len(f)
	fi = [0] * lf
	fi[-1] = inv(f[-1], p)
	for i in range(lf - 1):
		fi[lf - 1 - i - 1] = (fi[lf - 1 - i] * (lf - 1 - i)) % p

	def comb_p(n, k):
		if k < 0 or n < k:
			return 0
		return (f[n] * ((fi[k] * fi[n - k]) % p)) % p
	for i in range(1, K + 1):
		s = (comb_p(K-1, i-1) * (comb_p(N-K-1, i-2) + 2 * comb_p(N-K-1, i-1) + comb_p(N-K-1,i)) % p) % p
		print(s)

def inv(a, p):
	power_a = [a]
	b_p = format(p - 2, 'b')
	ans = 1
	for i in range(len(b_p)):
		power_a.append((power_a[-1] ** 2) % p)
	for i in range(len(b_p)):
		if b_p[-i-1] == "1":
			ans = (ans * power_a[i]) % p
	return ans

main()

Measured memory_bytes: 9392
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    char c;
    cin >> c;
    if ('A' <= c && c <= 'Z') {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }


    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<>());

    ll ans;
    if(n % 2 == 0){
        ans = 0;
        rep(i, n / 2) ans += a[i] * 2;
        ans -= a[0];
    }else{
        ans = 0;
        rep(i, (n + 1) / 2) ans += a[i] * 2;
        ans -= (a[0] + a[n / 2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4832
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $ans=[];
  for($i=1;$i<1000000;$i++){
    if(isset($ans[$s])) {
      echo $i;
      exit;
    }
    //echo $s." ";
    $ans[$s]=$i;
    if($s % 2 == 0) $s = $s /2;
    else $s=3*$s+1;
  }


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

#define M_PI 3.141592653589793


int main(void) {

	int i = 0, j, k;

	char str[200];
	char serch[100];

	scanf("%s", str);
	scanf("%s", serch);
	int d = strlen(str);

	for (i = d; i < d * 2; i++) {
		str[i] = str[i - d];
	}
	str[d * 2] = '\0';

	if (strstr(str, serch) == NULL) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}



	return 0;

}

Measured memory_bytes: 2688
from collections import deque

n,m = map(int,input().split())
nodes = [[] for _ in range(n)]
edges = []
for _ in range(m):
    a,b = map(lambda x:int(x) -1,input().split())
    nodes[a].append(b)
    nodes[b].append(a)
    edges.append((a,b))
ans = 0
for a,b in edges:
    s = deque()
    gone = [0 for _ in range(n)]
    gone[a] = 1
    s.append(a)
    judge = 1
    while s:
        ai = s.popleft()
        for bi in nodes[ai]:
            if (ai,bi) == (a,b):
                pass
            elif bi ==b:
                judge =0
                break
            else:
                if gone[bi]==0:
                    s.append(bi)
                    gone[bi] =1
    if judge:
        ans +=1
print(ans)

Measured memory_bytes: 3436