akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	f(i,0,n-1) cin>>ara[i];

	sort(ara,ara+n);

	int sum=0;

	f(i,0,n-1)
	{
	    sum+=ara[i];
	}
	if(sum%10!=0) cout<<sum<<endl;
	else{

        f(i,0,n-1){
            f(j,0,n-1)
            {
                if((sum-ara[j])%10!=0) {
                    cout<<sum-ara[j]<<endl,exit(0);
                }
            }
            sum-=ara[i];
        }
        cout<<sum<<endl;
	}

}


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

inline long long gcd(const long long &a, const long long &b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

inline long long lcm(const long long &a, const long long &b) {
	return a*b / gcd(a, b);
}

int main() {
	cin.tie(0);
	ios::ios_base::sync_with_stdio(false);
	int n;  cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; ++i) {
		a[i + 1] = lcm(a[i], a[i + 1]);
	}
	cout << a[n - 1] << endl;
}

Measured memory_bytes: 1200
#include <iostream>

using namespace std;
int main()
{
	int a,b,c,x;
	cin >> a >> b >>c >>x;

	int res = 0;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				int total = 500 * i + 100 * j + 50 * k; // 合計金額
				if (total == x) {
					++res; // 合計金額が X に一致したら答えをインクリメント
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if (A < B) :
    end_A = A + V * T
    end_B = B + W * T
    if (end_B <= end_A) :
        print("YES")
    else :
        print("NO")
else :
    end_A = A - V * T
    end_B = B - W * T
    if(end_A <= end_B) :
        print("YES")
    else :
        print("NO")


Measured memory_bytes: 9192
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()

    val As = readInputLine().split(" ").mapIndexed{i, r -> r.toInt() - i - 1}.sorted()

    val differ = As[N / 2]
    
    println(As.fold(0L, {R, T -> R + Math.abs(T - differ)}))
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 81004
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String n = in.readLine();
    System.out.println(n.substring(0,1).equals("9") || n.substring(1,2).equals("9")?
                       "Yes":"No");
  }
}

Measured memory_bytes: 32608
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int A[100050];

int main() {
  int N = in();
  for (int i = 0; i < N; ++i) {
    A[i] = in();
  }

  int p = 1;
  Int res = 0;

  for (int i = 0; i < N; ++i) {
    if (A[i] < p) {
      continue;
    } else if (A[i] == p) {
      ++p;
    } else {
      res += (A[i] - 1) / p;
      if (p == 1) {
        ++p;
      }
    }
  }

  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>v, v2, vis(n, 0);
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v2.push_back(x);
    }
    reverse(v2.begin(), v2.end());
    int j = 0;
    vector<int>cur;
    for(int i = 0; i < n; i++){
        while(j < n && v2[j] == v[i]){
            j++;
        }
        if(j < n){
            cur.push_back(v2[j]);
            vis[j] = 1;
            j++;
        }
    }
    for(int i = 0; i < n; i++){
        if(vis[i] == 0){
            cur.push_back(v2[i]);
        }
    }
    int y = 1;
    for(int i = 0; i < n; i++){
        if(v[i] == cur[i]){
            y = 0;
        }
    }
    if(y == 1){
        cout << "Yes\n";
        for(int i = 0; i < n; i++){
            cout << cur[i] << ' ';
        }
        return 0;
    }
    reverse(v2.begin(), v2.end());
    multiset<int>st;
    for(int i = 0; i < n; i++){
        st.insert(v2[i]);
    }
    int k = 1;
    vector<int>ans;
    for(int i = 0; i < n; i++){
        multiset<int>::iterator it = st.upper_bound(v[i]);
        if(it == st.end()){
            it = st.begin();
        }
        ans.push_back(*it);
        st.erase(it);
    }
    for(int i = 0; i < n; i++){
        if(ans[i] == v[i]){
            k = 0;
        }
    }
    if(k == 0){
        cout << "No";
    }
    else{
        cout << "Yes\n";
        for(int i = 0; i < n; i++){
            cout << ans[i] << ' ';
        }
    }
    return 0;
}

Measured memory_bytes: 15876
#include <stdio.h>

void sort(int a[], int n)
{
    for (int i = 0; i < n - 1; i++) {
        int max = a[i], max_index = i, tmp;
        for (int j = i + 1; j < n; j++) {
            if (a[j] > max) {
                max = a[j];
                max_index = j;
            }
        }
        tmp = max;
        a[max_index] = a[i];
        a[i] = tmp;
    }
}

int main(void)
{
    int n, a[100], result = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, n);

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            result += a[i];
        } else {
            result -= a[i];
        }
    }

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

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string n;
	cin>>n;
	for(int i=0;i<n.size();i++){
		if(n[i]=='1'){
			n[i]='9';
		}
		else{
			n[i]='1';
		}
	}
	cout<<n;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Travel by Car
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();
            int L = sc.nextInt();

            long[][] D = initWF(N);
            for (int i = 0; i < M; i++) {
                int A = sc.nextInt() - 1;
                int B = sc.nextInt() - 1;
                int C = sc.nextInt();

                D[A][B] = C;
                D[B][A] = C;
            }

            execWF(N, D);

            long[][] E = initWF(N);
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    if (D[i][j] <= L) {
                        E[i][j] = 1;
                        E[j][i] = 1;
                    }
                }
            }

            execWF(N, E);

            StringBuilder sb = new StringBuilder();

            int Q = sc.nextInt();
            for (int i = 0; i < Q; i++) {
                int s = sc.nextInt() - 1;
                int t = sc.nextInt() - 1;

                long z = (E[s][t] != Long.MAX_VALUE) ? E[s][t] - 1 : -1;

                sb.append(z).append("\n");
            }

            System.out.println(sb.toString());
        }
    }

    public static long[][] initWF(int N) {
        long[][] D = new long[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (i != j) {
                    D[i][j] = Long.MAX_VALUE;
                }
            }
        }
        return D;
    }

    public static void execWF(int N, long[][] D) {
        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    if (D[i][k] != Long.MAX_VALUE && D[k][j] != Long.MAX_VALUE) {
                        D[i][j] = Math.min(D[i][j], D[i][k] + D[k][j]);
                    }
                }
            }
        }
    }

}


Measured memory_bytes: 91576
#include<bits/stdc++.h>
using namespace std;
int main(){

  string S,T;
  

  cin>>S>>T;

  int cnt[26]={ };
  int cnt1[26]={ };
  
  for(int i=0;i<S.length();i++){

    cnt[S[i]-'a']++;
    cnt1[T[i]-'a']++;

  }

  sort(cnt,cnt+26);
  sort(cnt1,cnt1+26);

  for(int i=0;i<26;i++){
    if(cnt[i]!=cnt1[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
    
  return 0;

}

  
  


Measured memory_bytes: 776
N, M, X = map(int, input().split())
C = [0] * N
A = [[0] * M] * N

for i in range(N):
    S = list(map(int, input().split()))
    C[i] = S[0]
    A[i] = S[1:]

smallest = None
for i in range(2 ** N):
    sum = 0
    string = ""
    Algo = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            sum += C[j]
            for m in range(M):
                Algo[m] += A[j][m]
            string += "1"
        else:
            string += "0"
    # print(Algo)
    # print(string)
    # print(sum)
    if all(e >= X for e in Algo):
        if smallest == None:
            smallest = sum
        elif sum < smallest:
            # print("更新！")
            smallest = sum

if smallest == None:
    print(-1)
else:
    print(smallest)


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    bool flag = true;
    while(flag){
        flag = false;
        for(int i = 0; i < n; i++){
            if(a[i] % 2 == 0){
                a[i] /= 2;
                ans++;
                flag = true;
                break;
            }
        }
    }
    cout << ans << endl;
}


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

int main(void){

  int N,i,j,k,l;
  scanf("%d",&N);

  int x[N+1],y[N+1];
  int a,b,p,q;
  int cost,min = N;
  int cos[N];

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

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(i != j){
        p = x[j] - x[i];
        q = y[j] - y[i];
        cost = N;
          for(k=0;k<N;k++){
            for(l=0;l<N;l++){
              if((x[k] - p) == x[l] && (y[k] - q) == y[l]){
                cost = cost - 1;
              }
            }
          }
        }
        if(cost < min)
          min = cost;
      }
    }

  printf("%d",min);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
#define ll long long
ll arr[51] = {0};
int main(){
    ll int n;
    int i;
    while(scanf("%lld",&n)!=EOF){
        for(i = 0;i < 50;i++){
            arr[i] = 49+n/50;
        }
        //cout<<"*****"<<endl;
        ll m = n%50;
        for(i = 0;i < 50;i++){
            arr[i] = arr[i]-m;
        }

        for(i = 0;i < m;i++){
            arr[i] = arr[i]+50;
        }
         printf("50\n");
        for(int i=0;i<50;i++)printf("%lld ",arr[i]);
        printf("\n");
    }
}


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

using namespace std;

int tencount(int a){
    int count = 0;
    if(a % 10 != 0)
        count++;
    
    return count;
}


int main(){
    int n; cin >> n;
    int sum = 0;
    int ans;
    int b[n];
    
    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
        sum += a[i];
    }
    
    sort(a.begin(),a.end());
    
    int count = 0;
    for(int i = 0 ; i < n ; i++){
        count+=tencount(a[i]);
    }
    
    if(sum % 10 != 0)
        cout << sum << endl;
    
    else if(count == 0)
        cout << "0" << endl;
    
    else{
        for(int k = 0 ; k < n ; k++){
            b[k] = sum - a[k];
            if(b[k] % 10 != 0){
                ans = b[k];
                break;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    string s;
    cin>>s;
    int len = s.length();
    int ans = 10000000;
    for(int i=0;i<len-1;i++){
        if(s[i]!=s[i+1]) ans = min(ans,max(i+1,len-i-1));
    }
    if(ans == 10000000)ans = len;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int[] time = new int[5];
		int sum = 0;
		int frac = 10;
		for (int i = 0; i < 5; i++) {
			time[i] = sc.nextInt();
			sum += ((time[i] - 1) / 10 + 1) * 10;

			if (time[i] % 10 != 0) {
				frac = Math.min(frac, (time[i] % 10));
			}
		}
		System.out.println(sum - (10 - frac));
	}
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w);
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ans(n, pair<int, int>(make_pair(INT_MAX / 2, -1)));
    vector<vector<int>> path(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        path.at(a - 1).push_back(b - 1);
        path.at(b - 1).push_back(a - 1);
    }
    ans.at(0) = make_pair(0, 0);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push(ans.at(0));
    while(pq.size()) {
        pair<int, int> p = pq.top();
        pq.pop();
        rep(i, path.at(p.second).size()) {
            if(ans.at(path.at(p.second).at(i)).first > p.first + 1) {
                ans.at(path.at(p.second).at(i)) = make_pair(p.first + 1, p.second);
                pq.push(make_pair(p.first + 1, path.at(p.second).at(i)));
            }
        }
    }
    bool flag = true;
    rep(i, n) if(ans.at(i).first >= INT_MAX / 2) flag = false;
    if(flag){
        cout << "Yes" << endl;
        rep(i, n - 1) cout << ans.at(i + 1).second + 1 << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 11188
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define EPS         1e-9
#define INF         1e18
#define PI          3.14159265358979323846
#define MAXI        1000000
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define N 100005

signed main()
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int a[n][3];
		int i,j,k;
		for(i=0;i<=n-1;i++)
		{
			for(j=0;j<=2;j++)
			{
				cin>>a[i][j];
			}
		}
		int dp[n+1][3];
		dp[1][0]=a[0][0];
		dp[1][1]=a[0][1];
		dp[1][2]=a[0][2];
		for(i=2;i<=n;i++)
		{
			for(j=0;j<=2;j++)
			{
				dp[i][j]=max(dp[i-1][(j+1)%3]+a[i-1][j],dp[i-1][(j+2)%3]+a[i-1][j]);
			}
		}
		cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	}
}

Measured memory_bytes: 8328
n = input().split(" ")

a = n[0]
b = n[1]
c = n[2]

"aとbの入れ替え"
n[0] = b
n[1] = a
"aとcの入れ替え"
n[0] = c
n[2] = b

print(n[0]+" "+n[1]+" "+n[2]+" ")



Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned int ui;
#define infin (ll)(pow(10,9)+7)
using namespace std;
int main()
{
    ll n,x,y;
    ll diff_min=1000000000,diff_max=-1*pow(10,10),sum_min=10000000000,sum_max=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        if (x+y>sum_max)
           sum_max=x+y;
        if(x+y<sum_min)
          sum_min=x+y;
        if (x-y<diff_min)
           diff_min=x-y;
        if (x-y>diff_max)
           diff_max=x-y;
    }
    cout<<max(diff_max-diff_min,sum_max-sum_min);
}

Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <string>
#define MAX 1000001
using namespace std;

int main(){
  int i,j,a,d,n;
  bool A[MAX];
  A[1] = A[0] = false;
  for(i=2;i<MAX;i++) A[i] = true;
  for(i=2;i<MAX;i++){
    if(A[i]){
      for(j=i*2;j<MAX;j+=i) A[j] = false;
    }
  }

  while(1){
    cin >> a >> d >> n;
    if(a == 0 && d == 0 && n == 0) break;
    int c = 0,ans;
    for(i=a;i<MAX;i+=d){
      if(A[i]) c++;
      if(c == n){
	ans = i;
	break;
      }
    }
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  out(min(b/a,c));
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%s\n",((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)?"YES":"NO"));
    return 0;
}



Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
int order[8001]={0},n=0;
int orderx[8001]={0},ordery[8001]={0},nx=0,ny=0;
int x,y;
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    char c; int tmpx=0,tmpy=0;
    while((c=getchar())=='T'||c=='F')
    {
        if(c=='T')
            n++;
        else
            order[n]++;
    }
    for(int i=1;i<=n;i++)
        if(i%2==0)
            orderx[nx++]=order[i];
        else
            ordery[ny++]=order[i];
    scanf("%d %d",&x,&y);
    sort(orderx, orderx+nx,cmp);   sort(ordery, ordery+ny,cmp);
    tmpx=order[0];
    for(int i=0;i<nx;i++)
    {
        if(tmpx>=x)
            tmpx-=orderx[i];
        else
            tmpx+=orderx[i];
    }
    for(int i=0;i<ny;i++)
    {
        if(tmpy>=y)
            tmpy-=ordery[i];
        else
            tmpy+=ordery[i];
    }
    if(x==tmpx&&y==tmpy)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int sum=0;
  cin>>N;
  int l[N];
  int r[N];
  for(int i=0;i<N;i++){
   cin>>l[i]>>r[i];
  }
  for(int j=0;j<N;j++){
   sum=sum+r[j]-l[j]+1;
  }
  cout<<sum<<endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	if (b - (a + w)>0)
    cout<< b - (a + w);
	else if ((b + w) >= a) cout << "0";
	else cout <<a - (b + w);
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
string dp[70][70],m[70];
int h,w;
string dfs(int y,int x){
  if(dp[y][x].size())return dp[y][x];
  string p1,p2;
  if(y+1<h&&isdigit(m[y+1][x]))p1=dfs(y+1,x);
  p1=m[y][x]+p1;
  if(x+1<w&&isdigit(m[y][x+1]))p2=dfs(y,x+1);
  p2=m[y][x]+p2;
  if(p1.size()>p2.size())return dp[y][x]=p1;
  else if(p1.size()==p2.size()&&p1>p2)return dp[y][x]=p1;
  else return dp[y][x]=p2;
}
main(){
  while(cin>>w>>h,w){
    r(i,h)r(j,w)dp[i][j]="";
    string p="";
    r(i,h)cin>>m[i];
    r(i,h)r(j,w)if('1'<=m[i][j]&&m[i][j]<='9'){
      string t=dfs(i,j);
      if(t.size()>p.size())p=t;
      else if(t.size()==p.size())p=max(t,p);
    }
    cout<<p<<endl;
  }
}

Measured memory_bytes: 3364
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 21 18:51:07 2019

@author: Yamazaki Kenichi
"""

N = int(input())
A = [int(input()) for i in range(N)]
mod = 998244353
def mof(x):
    return x % mod
total = sum(A)
dp1 = [[0 for i in range(300*N+1)] for i in range(N+1)]
dp2 = [[0 for i in range(300*N+1)] for i in range(N+1)]
dp1[0][0], dp2[0][0] = 1,1
for i in range(N):
    for j in range(N*300+1):
        dp1[i+1][j] = mof(dp1[i][j]*2 + (dp1[i][j-A[i]] if j >= A[i] else 0))
        dp2[i+1][j] = mof(dp2[i][j] + (dp2[i][j-A[i]] if j >= A[i] else 0))
        
ex = mof(sum(dp1[N][(total+1)//2:]))
a = dp2[N][total//2] if total % 2 == 0 else 0

ans = mof(3**N - 3*ex + 3*a)
print(ans)


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
ll f[N];
ll inv[N];

ll bpow (ll a, ll b) {
	ll res = 1;
	while(b > 0) {
		if (b & 1) res = (res * a) % mod;
		a = (a * a) % mod;
		b /= 2;
	}
	return res;
}

ll cnk (ll n, ll k) {
	return (f[n] * inv[k] % mod) * inv[n - k] % mod;
}

int main () {
	SpeedForce;
	cin >> n >> k;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	if (k == 1) {
		cout << 0 << '\n';
		exit(0);
	}

	if (k == 2) {
	    ll ans = 0;
	    ll sum = 0;
	    ll cnt = 0;
		for (int i = 2, j = 1; i <= n; i ++, j++) {
			sum += a[j];
			cnt++;
			ans += (cnt * a[i] - sum) % mod;
			ans %= mod;
	
		}
		cout << ans << '\n';
		exit(0);
	}

	f[0] = inv[0] = 1;
	for (int i = 1; i <= n; i ++) {
		f[i] = f[i-1] * i % mod;
		inv[i] = bpow(f[i], mod - 2);
	}

	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i ++) if (a[i] < 0) {
		a[i] += mod;
	}
	
	ll ans = 0, res = 0;
	for (int i = k, j = 1; i <= n; i ++, j++) {

		/*cout << ": " << i << '\n';
		for (int p = 1; p <= j; p++) {
			ans += (a[i] - a[p]) * cnk(i - p - 1, k - 2);
			ans %= mod;
			cout << cnk(i - p - 1, k - 2) << '\n';
		}   */
		ans += a[i] * cnk(i-1, k-1);
		ans %= mod;

		res += a[j] * cnk(n-j, k-1);
		res %= mod;
	//	cout << n - i << ' ' << k - 1 << '\n';
	
		
		/*pref += a[j];
		sum += pref;
		cnt += j;

		ans += (cnt * a[i] - sum) % mod;
		ans %= mod;*/
	}
	ans -= res;
	if (ans < 0) ans += mod;
	cout << ans % mod << '\n';

   	return Accepted;
}

// B...a

Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var sa = Input();
		var a = new long[n];
		var ac = new long[n];
		for(int i = 0; i < n; i++)
		{
			a[i] = sa[i].ToLong();
			ac[i] = sa[i].ToLong();
		}
		Array.Sort(a);
		long kijun = a[n / 2];
		for(int i = 0; i < n; i++)
		{
			if(kijun > ac[i])
			{
				Console.WriteLine("{0}", kijun);
			}
			else
			{
				Console.WriteLine("{0}", a[n/2-1]);
			}
		}
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 36400
n = int(input())
a_li = list(map(int,input().split()))

import collections
c = collections.Counter(a_li)

mc = c.most_common()
# [('a', 4), ('c', 2), ('b', 1)]

if len(mc) == 1 and mc[0][1]<=3:
    print(0)
    exit()
all_li = []
seihou_li = []
for m in mc:
    if m[1]>=2:
        all_li.append(m[0])
    if m[1]>3:
        seihou_li.append(m[0])
if len(all_li) <= 1:
    print(0)
    exit()
all_li.sort(reverse=True)
#print(all_li)
ans_li = [all_li[0]*all_li[1]]
for s in seihou_li:
    ans_li.append(s**2)
print(max(ans_li))

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

using namespace std;

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

  int n;
  cin >> n;

  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  bool ok = true;
  int cnt = 0;
  while (ok) {
    ok = false;
    for (int i = 0; i < n; ++i) {
      if (a[i] % 2 == 0) {
        a[i] /= 2;
        ok = true;
        ++cnt;
        break;
      }
    }
  }

  cout << cnt << '\n';

  return 0;
}


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

vector<pair<int, int>> cut(pair<int, int> cake, int s)
{
  vector<pair<int, int>> ans(2);//ans.at(0) bigger ans.at(1) smaller
  int w = cake.first;
  int h = cake.second;
  s = s % (w + h);
  if (s > w)
  {
    s -= w;

    ans.at(0).first = w;
    ans.at(1).first = w;
    ans.at(0).second = max(s, h - s);
    ans.at(1).second = min(s, h - s);
  }
  else
  {
    ans.at(0).first = max(s, w - s);
    ans.at(1).first = min(s, w - s);
    ans.at(0).second = h;
    ans.at(1).second = h;
  }
  return ans;
}

int main()
{
  bool first_time = true;
  while (true)
  {
    int n, w, d;
    cin >> n >> w >> d;
    if (n + w + d == 0)
    {
      cout << endl;
      return 0;
    }
    vector<pair<int, int>> cake(0);
    cake.push_back({w, d});
    int p, s;
    for (int i = 0; i < n; ++i)
    {
      cin >> p >> s;
      vector<pair<int,int>> cut_cake = cut(cake.at(p - 1), s);
      cake.erase(cake.begin() + p - 1);
      cake.push_back(cut_cake.at(1));
      cake.push_back(cut_cake.at(0));
    }
    vector<int> ans(n + 1);
    for (int i = 0; i < n + 1; ++i)
    {
      ans.at(i) = cake.at(i).first * cake.at(i).second;
    }
    sort(ans.begin(), ans.end());
    if (!first_time)
    {
      cout << endl;
    }
    first_time = false;
    for (int i = 0; i < n + 1; ++i)
    {
      cout << ans.at(i);
      if (i != n)
      {
        cout <<  ' ';
      }
    }
  }
}



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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)                                                             \
  sort(x.begin(), x.end());                                                    \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y)                                                           \
  cerr << "(" << #x << ", " << #y << ") = "                                    \
       << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;

  ll qa = q * 8;
  ll ha = h * 4;
  ll sa = s * 2;

  vector<ll> v = {qa, ha, sa, d};

  sort(all(v));

  ll sum = 0;

  for (int i : v) {
    debug(i);

    double ama = 0;
    if (i == qa) {
      int a = n / 0.25;
      sum += a * q;
      ama = fmod(n, 0.25);
    } else if (i == ha) {
      int a = n / 0.5;
      sum += a * h;
      ama = fmod(n, 0.5);
    } else if (i == sa) {
      int a = n / 1;
      sum += a * s;
      ama = n % 1;
    } else if (i == d) {
      int a = n / 2;
      debug(a);
      sum += a * d;
      ama = n % 2;
    }

    if (ama == 0) { break; }

    n = ama;
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long
//vector<int> g1;
//g1.push_back(i);

using namespace std;

int main()
{
	int n;
	cin >> n;
	string a,b;
	cin >> a >> b;
	for(int i=0;i<n;i++)
	{
		cout << a[i] << b[i];
	}
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <functional>
#include <queue>
#include <tuple>
#include <map>

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using ll = long long;
using vll = vector<ll>;
using pii = pair<int, int>;
using vb = vector<char>;
using vvb = vector<vb>;

#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define RREP(i, a, b) for (int i = (int)(b) - 1; i >= a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define mp(a, b) make_pair(a,b)

#define fi first
#define sn second
#define decpii(p) p.fi--,p.sn--;


#ifdef LOCAL
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define dumpn(c) cerr << "> " << #c << " = " << (c) << ", ";
#else
#define dump(c) ;
#define dumpn(c) ;
#endif


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, (int) a.size())os << (i ? " " : "") << a[i];
    return os << ']';
}

const int INF = 1 << 29;

int dxf[] = {1, 0, -1, 0};
int dyf[] = {0, -1, 0, 1};

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

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

inline vi uni(vi &vec) {
    sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct ____ {
    ____() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} ________;


auto solve() {
    int N;
    cin >> N;
    vector<pii> red(N), blue(N);
    rep(i, N) cin >> red[i].fi >> red[i].sn;
    rep(i, N) cin >> blue[i].fi >> blue[i].sn;
    sort(all(blue));

    vb used(N, false);
    tr(it, blue) {
        int use = -1;
        int y = -1;

        rep(i, N) {
            if (used[i]) continue;
            auto ait = red[i];
            if (ait.fi < it->first && ait.sn < it->second) {
                if(chmax(y, ait.sn))
                    use = i;
            }
        }

        dump(use);
        if(use != -1)
            used[use] = true;
    }

    return accumulate(all(used), 0);
}

int main() {
//    cout << (solve() ? "yes" : "no") << endl;
    cout << solve() << endl;
//    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//map
int main()
{
    int iMin = 1000001;
    int iMax = -1000001;
    ll iSum = 0;

    int N, a;
    cin >> N;

    REP(i,N)
    {
        cin >> a;
        iMin = min(iMin,a);
        iMax = max(iMax,a);
        iSum += a;
    }

    cout << iMin << " " << iMax << " " << iSum << endl;

    return 0;
}


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

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

using namespace std;

int main () {
	int sx, sy, tx, ty, w, h;
	cin >> sx >> sy >> tx >> ty;
	w = tx - sx;
	h = ty - sy;
	rep(i, h) cout << 'U';
	rep(i, w) cout << 'R';
	rep(i, h) cout << 'D';
	rep(i, w) cout << 'L';
	cout << 'L';
	rep(i, h + 1) cout << 'U';
	rep(i, w + 1) cout << 'R';
	cout << 'D';
	cout << 'R';
	rep(i, h + 1) cout << 'D';
	rep(i, w + 1) cout << 'L';
	cout << 'U';
	cout << endl;
}


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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 
#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   int N,K;
   cin>>N>>K;

   int a=max(N/2,(N+1)/2);
   if(a>=K)cout<<"YES"<<endl;
   else cout<<"NO"<<endl;

   /*
   int K,A,B;
   cin>>K>>A>>B;
   if(B<=2){
      cout<<(ll)(K+1)/2*A<<endl;
      return 0;
   }
   else{
      cout<<1+((K-1)+1)/2;
   }
   */
   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

string S;

int main(){
    cin>>S;

    int a=0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            if(S[i]==S[j]) a++;
        }
    }

    if(a==2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int N,temp,lmax,lsum=0,i;
	vector<int> L;
	cin>>N;
	for(i=0;i<N;i++){
		cin >>temp;
		L.push_back(temp);
	}
	sort(L.begin(),L.end());
	for(i=0;i<N-1;i++){
		lsum+=L.at(i);
	}
	lmax=L.at(i);
	if(lsum>lmax){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}


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

if s[0]=='R':
  if s[1]=='R':
    if s[2]=='R':
      print(3)
      exit()
    else:
      print(2)
      exit()
  else:
    print(1)
    exit()
else:
  if s[1]=='R':
    if s[2]=='R':
      print(2)
      exit()
    else:
      print(1)
      exit()
  else:
    if s[2]=='R':
      print(1)
      exit()
    else:
      print(0)

Measured memory_bytes: 9064
n = int(input())
restaurants = [ input().split() for i in range(n) ]
names = [ restaurants[j][0] for j in range(n)]
names = set(names)
names = sorted(list(names))
for name in names:
    scores = list(map(int, [restaurants[l][1] for l in range(n) if restaurants[l][0] == name]))
    scores.sort(reverse = True)
    for m in scores:
        print(restaurants.index([name,str(m)]) +1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inc(l,i,r) for (int i=l;i<=r;i++)
#define dec(r,i,l) for (int i=r;i>=l;i--)
#define SIZE(V) ((int) V.size())
#define forE(p,u) for (edge *p=head[u];p;p=p->nxt)
#define forV(i,V) for (int i=0;i<SIZE(V);i++)
#define pb push_back
#define In inline
#define fi first
#define se second
#define mp make_pair
#define It iterator
#define ___ putchar(10);
#define cnt(x) __builtin_popcount(x)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N = 100100, P = 998244353;

char S[1010];
int n, m, k, a[310], dp1[310][310], dp2[310][310], ans;

int main() {
	scanf("%s%d",S+1,&k);

	{
		int len = strlen(S+1), cnt = 0;
		inc(1,i,len) {
			if (S[i] == '0') a[++n] = cnt, cnt = 0;
			else ++cnt;
		}
		if (cnt) a[++n] = cnt, cnt = 0;
	}
	inc(1,i,n) m += a[i];
	// inc(1,i,n) printf("%d ",a[i]);  puts("");

	//dp[tot][now]
	dp1[0][0] = 1;
	dec(n,i,1) {
		inc(0,x,m) dec(x,y,0) dp2[x][y] = (dp1[x][y] + dp2[x][y+1]) % P;
		inc(1,j,a[i]) {
			inc(0,x,m) inc(0,y,x) if (x-j >= 0 && y-j >= 0) dp2[x][y] = (dp2[x][y] + dp1[x-j][y-j]) % P;
		}

		inc(0,x,m) inc(0,y,x) dp1[x][y] = dp2[x][y], dp2[x][y] = 0;
		// printf("i=%d\n",i);
		// inc(0,x,m) {
		// 	inc(0,y,m) printf("%d ",dp1[x][y]);
		// 	puts("");
		// }
	}

	inc(0,x,min(m,k)) ans = (ans + dp1[x][0]) % P;
	printf("%d\n",ans);
}

Measured memory_bytes: 4552
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


 
int main() {
	string s;
	cin >> s;
	long long n = s.size();
	string s1 = s, s2 = s.substr(0, (n - 1) / 2), s4 = s.substr((n + 3) / 2 - 1, n - (n + 3) / 2 + 1);
	string s3 = s2, s5 = s4;
	reverse(s1.begin(), s1.end());
	reverse(s2.begin(), s2.end());
	reverse(s4.begin(), s4.end());
	if(s1 != s){
		cout << "No";
		return 0;
	}
	if(s2 != s3){
		cout << "No";
		return 0;
	}
	if(s4 != s5){
		cout << "No";
		return 0;
	}
	cout << "Yes";
}


Measured memory_bytes: 760
package main

import "fmt"

func main() {
	var s, t string

	fmt.Scan(&s)
	fmt.Scan(&t)

	fmt.Println(solve(s, t))
}

func solve(s, t string) int {
	c := 0
	for i := 0; i < 3; i++ {
		if s[i] == t[i] {
			c++
		}
	}

	return c
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b,h;cin>>a>>b>>h;
  int ans=(a+b)*h/2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = n
for i in  range(n+1):
  cnt=0
  t=i
  while t>0:
    cnt += t%6
    t //= 6
  j=n-i
  while j>0:
    cnt+=j%9
    j//=9
  ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 9040
#include <stdio.h>

int main(void)
{
   int n, S[1000000], q, T[1000000], i, j;
   int wa = 0;

   scanf("%d", &n);
   for ( i = 0; i < n; i++ ) {
      scanf("%d", &S[ i ]);
   }
   scanf("%d", &q);
   for ( i = 0; i < q; i++ ) {
      scanf("%d", &T[ i ]);
   }

   for ( i = 0; i < q; i++ ) {
      for ( j = 0; j < n; j++ )
         if ( T[ i ] == S[ j ] ) {
            wa = wa + 1;
            break;
         }
   }

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

   return 0;
}

Measured memory_bytes: 1856
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
using namespace std;

const int maxn=500005;
int a[maxn],last[maxn],dp[maxn];
int main(){
    int n;
    scanf("%d",&n);
    getchar();
    int p=0;
    for(int i=1;i<=n;i++){
        char c;
        c=getchar();
        a[i]=c-'0';
        last[i]=p;
        if(a[i]==0)
            p=i;
    }

    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1];
        if(a[i]==0)
            continue;
        if(last[i]==0)
            continue;
        if(a[last[i]-1]==0)
            continue;
        if(last[i]-2>=0){
            dp[i]=max(dp[i],dp[last[i]-2]+i-last[i]);
        }
        if(last[i]==i-1){
            for(int j=last[last[i]];j<last[i]-1;j++)
                dp[i]=max(dp[i],dp[j]+last[i]-j-1);
        }
    }
    printf("%d\n",dp[n]);
}


Measured memory_bytes: 6144
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr, sort)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  xs <- U.fromListN n . sort . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let (ys,zs) = U.splitAt (n `quot` 2) xs
      y = U.last ys
      z = U.head zs
  print $ z - y


Measured memory_bytes: 18428
#include <iostream>
#include <list>
#include <string>

using namespace std;

int main() {

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

	list<int> L;

	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;

		if (s == "insert") {
			int v;
			scanf("%d",&v);
			L.push_front(v);
		} else if (s == "delete") {
			int v;
			scanf("%d",&v);
			for (auto itr = L.begin(); itr != L.end(); ++itr) {
				if (*itr == v) {
					L.erase(itr);
					break;
				}
			}
		} else if (s == "deleteFirst") {
			L.pop_front();
		} else {
			L.pop_back();
		}
	}

	for (auto itr = L.begin(); itr != L.end(); ++itr) {
		if (itr != L.begin()) {
			cout << " " << *itr;
		} else {
			cout << *itr;
		}
	}
	cout << endl;

	return 0;
}

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

int main() {
    string O, E;

    cin >> O >> E;
    int flag = 0, i;
    if (O.size() - E.size() > 0) flag = 1;

    for (i = 0; i < E.size(); i++)
    {
        cout << O[i] << E[i];
    }
    if (flag) cout << O[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
def hex_num(str)
  return str.to_i(16)
end
input_array = gets.chomp.split(' ')
result_ar = []
input_array.each do |ar|
  result_ar << hex_num(ar)
end

puts  result_ar[0] == result_ar[1] ? '=' :
      result_ar[0] > result_ar[1] ? '>' :
      '<'

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>

int gcd(int a, int b){
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}


using namespace std;

int main(void){
    int n, I, x;
    int d = 1;

    cin >> n >> I;

    for (int i = 0; i < n; i++){
        cin >> x;

        if (i == 0){
            d = abs(x - I);
        }
        else {
            d = gcd(d, abs(x - I));
        }
    }
    cout << d << endl;
}


Measured memory_bytes: 256
def LCS():
    X = raw_input()
    Y = raw_input()
 
    a, b = len(X), len(Y)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = X[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == Y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i in range(n):
    print LCS()

Measured memory_bytes: 6540