akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    bool tle = true;
    int n, t;
    cin >> n >> t;
    int cost = 10000;
    int ans = 0;
    vector<pair<int, int> >data(n);
    for(int i = 0; i < n; i++){
        cin >> data.at(i).first >> data.at(i).second;
    }
    for(int i = 0; i < n; i++){
        if(data.at(i).second <= t){
            tle = false;
            cost = min(cost, data.at(i).first);
        }
    }
    if(tle){
        cout << "TLE" << endl;
    }
    else{
        cout << cost << endl;
    }
    solve();
    return 0;
}



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

int main(){
    int N,K,x,sum;
  sum=0;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >> x;
    if (x<=(K-x)){
      sum += x*2;
    }else{
      sum += (K-x)*2;
    }
  }
  cout << sum;
}


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

const LL Mod = 1000000007;
LL n, A[ 200010 ], B[ 200010 ], F[ 4010 ][ 4010 ];
LL Inv[ 8010 ], Fact[ 8010 ];
LL Ans;

void Exgcd( LL a, LL b, LL &x, LL &y ) {
    if( b == 0 ) {
        x = 1; y = 0; return;
    }
    Exgcd( b, a % b, y, x );
    y -= a / b * x;
    return;
}

LL inv( LL a ) {
    LL b = Mod;
    LL x, y;
    Exgcd( a, b, x, y );
    if( x < 0 ) return x + Mod; else return x;
}

LL C( LL n, LL m ) {
    return Fact[ m ] * Inv[ n ] % Mod * Inv[ m - n ] % Mod;
}

int main() {
    Fact[ 0 ] = 1;
    for( LL i = 1; i <= 8000; ++i ) Fact[ i ] = ( Fact[ i - 1 ] * i ) % Mod;
    Inv[ 8000 ] = inv( Fact[ 8000 ] );
    for( LL i = 7999; i >= 0; --i ) Inv[ i ] = ( Inv[ i + 1 ] * ( i + 1 ) ) % Mod;
    scanf( "%lld", &n );
    for( LL i = 1; i <= n; ++i ) scanf( "%lld%lld", &A[ i ], &B[ i ] );
    for( LL i = 1; i <= n; ++i )
        F[ 2000 - A[ i ] ][ 2000 - B[ i ] ]++;
    for( LL i = 0; i <= 4000; ++i )
        for( LL j = 0; j <= 4000; ++j ) {
            if( i == 0 && j == 0 ) continue;
            if( i == 0 ) F[ i ][ j ] = ( F[ i ][ j ] + F[ i ][ j - 1 ] ) % Mod;
            if( j == 0 ) F[ i ][ j ] = ( F[ i ][ j ] + F[ i - 1 ][ j ] ) % Mod;
            if( i != 0 && j != 0 ) F[ i ][ j ] = ( F[ i - 1 ][ j ] + F[ i ][ j - 1 ] + F[ i ][ j ] ) % Mod;
        }
    for( LL i = 1; i <= n; ++i ) 
        Ans = ( Ans + F[ 2000 + A[ i ] ][ 2000 + B[ i ] ] ) % Mod;
    for( LL i = 1;i <= n; ++i ) 
        Ans = ( ( Ans - C( 2 * A[ i ], 2 * A[ i ] + 2 * B[ i ] ) ) % Mod + Mod ) % Mod;
    Ans = Ans * inv( 2 ) % Mod;
    printf( "%lld\n", Ans );
    return 0;
}



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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0; // to be set

    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) {
        for (int iter = 0; iter < 2; ++iter)
            dat[iter].assign(n + 1, UNITY_SUM);
    }

    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1));
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }

    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) -
               sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
};

int main() {
    int N;
    cin >> N;
    int Q;
    cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        lefts[i]--;
        rights[i];
        ids[i] = i;
    }

    sort(ids.begin(), ids.end(),
         [&](int i, int j) { return rights[i] < rights[j]; });

    BIT<int> bit(N + 5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]] + 2, r + 2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i] + 1, lefts[i] + 2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i)
        cout << res[i] << endl;
}


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

int main(){
  int n,i,j;
  cin>>n;
  string w[n];
  for(i=0;i<n;i++)cin>>w[i];
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(w[i]==w[j]){
        cout<<"No";
        return 0;
      }
    }
  }
  for(i=0;i<n-1;i++){
    if(w[i][w[i].size()-1]!=w[i+1][0]){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << endl;
	return 0;
}


Measured memory_bytes: 256
/**
class cfmaster {
 public:
  struct code {
  	see the details down there !
  };
};
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#define debug debug_out

const long long inf = (long long) 9e18;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
  	cin >> a[i];
	}
	vector<vector<long long>> dp(n, vector<long long>(n, inf));
	vector<long long> psum(n);
	long long s = 0;
	for (long long i = 0; i < n; i++) {
		s += a[i];
		psum[i] = s;
	}
	auto Sum = [&](int L, int R) {
		if (L == 0) {
			return psum[R];
		}
		return psum[R] - psum[L - 1];
	};
	for (int i = 0; i < n; i++) {
		dp[i][0] = 0;
	}
	for (int j = 1; j < n; j++) {
		for (int i = 0; i + j < n; i++) {
			for (int k = 0; k < j; k++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[i + k + 1][j - k - 1] + Sum(i, i + j));
			}
		}
	}
	cout << dp[0][n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1536
n=int(input())
alpha=['z']+[chr(ord('a') + i) for i in range(26)]
list_num=[]
while n>=1:
  num=n%26
  list_num.append(num)
  if num==0:
    n-=1
  n=n//26
list_num.reverse()
list_alpha=[]
for i in list_num:
  s=alpha[i]
  list_alpha.append(s)
  
print(''.join(list_alpha))

Measured memory_bytes: 9164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		
		long[] a=new long[N];
		long[] b=new long[N];
		long count=0;
		
		for(int i=0;i<N;i++){
			a[i]=sc.nextLong();
			b[i]=sc.nextLong();
		}
		for(int i=N-1;i>0;i--){
			count+=baisuu(a[i],b[i]);
			a[i-1]+=count;
		}
		count+=baisuu(a[0],b[0]);
		
		System.out.println(count);
	}
	
	static long baisuu(long a,long b){
		if(a%b==0) return 0;
		else{
			return b-a%b;
		}
	}
}


Measured memory_bytes: 68780
void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);

    int[] b = a.dup;
    b[] -= 1;
    int[] c = a.dup;
    c[] += 1;
    a ~= b ~ c;

    auto g = a.sort!"a < b".group.array;
    g.sort!((x, y) => x[1] > y[1]);

    g[0][1].writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 7856
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[s.length()-1]=='s')
  {
	  s+="e";
	  s+="s";
  }
  else{
	  s+="s";
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.*;

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

        int A = scanner.nextInt();
        int B = scanner.nextInt();

        Map<Integer, Integer> factorA = new HashMap<>();
        Map<Integer, Integer> factorB = new HashMap<>();

        long answer = 1;

        int max = Math.max(A, B);
        boolean[] primes = new boolean[max + 1];
        for (int i = 2 ; i <= max ; i++) {
            primes[i] = true;
        }

        for (int i = 2 ; i * i <= max ; i++) {
            if (primes[i]) {
                int p = i + i;
                while (p <= max) {
                    primes[p] = false;
                    p += i;
                }
            }
        }

        List<Integer> plist = new ArrayList<>();
        for (int i = 2 ; i <= max ; i++) {
            if (primes[i]) plist.add(i);
        }

        for (int p : plist) {
            int countA = 0;
            while (A % p == 0) {
                A = A / p;
                countA++;
                factorA.put(p, factorA.getOrDefault(p, 0) + 1);
            }
            int countB = 0;
            while (B % p == 0) {
                B = B / p;
                countB++;
                factorB.put(p, factorB.getOrDefault(p, 0) + 1);
            }

            if (Math.max(countA, countB) != 0) {
                for (int i = 0 ; i < Math.max(countA, countB) ; i++) {
                    answer *= p;
                }
            }

        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 38324
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin>>n;
	int h[n][3];
	for(int i=0;i<n;i++) cin>>h[i][0]>>h[i][1]>>h[i][2];
	int dp[n][3];
	memset(dp,0,sizeof(dp));
	dp[0][0]=h[0][0];  dp[0][1]=h[0][1]; dp[0][2]=h[0][2];
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(k==j) continue;
				dp[i][j] = max(dp[i][j] ,dp[i-1][k] + h[i][j]);
			}
		}
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
	return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> ckd(1e5 + 1, false);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (!ckd[tmp]) {
      cnt++;
      ckd[tmp] = true;
    }
  }
  if (!(cnt & 1)) cnt--;
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

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

	int i;
	for (i = n - 1; i >= 0; i -= 2) {
		if (i != n - 1)cout << " ";
		cout << a[i];
	}
	i += 2;
	for (i = i^1; i < n; i += 2) {
		cout << " ";
		cout << a[i];
	}
	cout << endl;


    return 0;
}



Measured memory_bytes: 2944
#include <stdio.h>
 
 int main(void){
 int a[3][10][4] = {0};
 int i, j, k;
 int n, p;
 int b, f, r, v; /* b棟f階r番目の部屋にv人 [階][部屋][棟] */
 
scanf("%d", &n);
 for(i=0; i<n; i++){
 scanf("%d%d%d%d", &b, &f, &r, &v);
 
 a[f-1][r-1][b-1] += v;
 }
 
 for(k=0; k<4; k++){
 for(i=0; i<3; i++){
 for(j=0; j<10; j++){
 if(a[i][j][k] == 0){
 printf(" 0");
 }else{
 printf(" %d", a[i][j][k]);
 }
 }
 printf("\n");
 }
 if(k != 3){
 printf("####################\n");
 }
 }
 
 return 0;
 }


Measured memory_bytes: 2728
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
vector <int> a[1111], b[1111];
bool vis[1111], vis1[1111];
vector<int> v;
void dfs(int x){
    if(vis[x])
        return;
    vis[x]=1;
    for(int i=0; i<a[x].size(); ++i){
        dfs(a[x][i]);
    }
}
int tmp2;
int dfs1(int x){
    if(vis[x])
        return 0;
    if(x==tmp2){
        v.push_back(x);
        return 1;
    }
    vis[x]=1;
    int tmp;
    for(int i=0; i<a[x].size(); ++i){
        tmp=dfs1(a[x][i]);
        if(tmp){
            v.push_back(x);
            return 1;
        }
    }
    return 0;
}
int main(){
    int n, m;
    while(cin>>n>>m){
        int x, y;
        for(int i=0; i<m; ++i){
            scanf("%d%d",&x,&y);
            a[x].push_back(y);
            b[y].push_back(x);
        }
        int tmp1=-1;
        for(int i=1; i<=n; ++i){
            for(int j=1; j<=n; ++j)
                vis[j]=0;
            dfs(i);
            for(int j=0; j<b[i].size(); ++j){
                if(vis[b[i][j]]){
                    tmp1=i;
                    tmp2=b[i][j];
                    memset(vis, 0, sizeof vis);
                    dfs1(i);
                    break;
                }
            }
            if(tmp1!=-1)
                break;
        }
        if(tmp1==-1){
            cout<<-1<<endl;
            continue;
        }
        reverse(v.begin(), v.end());
        memset(vis, 0, sizeof vis);
        for(int i=0; i<v.size(); ++i){
            vis[v[i]]=1;
        }
        for(int k=0; k<v.size(); ++k){
            int i=v[k];
            for(int j=0; j<a[i].size(); ++j){
                if(vis[a[i][j]]){
                    while(k+1<v.size()){
                        if(v[k+1]==a[i][j])
                            break;
                        vis[v[k+1]]=0;
                        v.erase(v.begin()+k+1);
                    }
                }
            }
            vis[i]=0;
        }
//        memset(vis, 0, sizeof vis);
        for(int i=0; i<v.size(); ++i){
            vis[v[i]]=1;
        }
        int mx=0;
        for(int k=0; k<v.size(); ++k){
            int i=v[k];
            for(int j=0; j<b[i].size(); ++j){
                if(vis[b[i][j]]){
                    while(v.back()!=b[i][j]){
                        vis[v.back()]=0;
                        v.pop_back();
                    }
                    mx=max(mx, k);
                }
            }
            vis[i]=0;
        }
        cout<<v.size()-mx<<endl;
        for(int i=mx; i<v.size(); ++i){
            cout<<v[i]<<endl;
        }
    }
  return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
ll ketawa(ll n) {
    ll x = 0;
    while (n > 0) {
        x += n % 10;
        n = n / 10;
    }
    return x;
}
int main() {
    cin >> k;
    a = 1;
    b = 1;
    while (k > 0) {
        c = (b / (a * 10)+1) * a * 10 - 1;
        if (b * ketawa(c) <= (c) * ketawa(b)) {
            cout << b << endl;
            k--;
        }
        else if (b!=c) {
            a *= 10;
            b = c - a;
        }
        b += a;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n;cin >> n;
  queue<ll> q;
  rep1(i,9) q.push(i);

  ll res;
  rep(i,n) {
    res = q.front(); q.pop();
    ll x = res % 10;
    if(x != 0) q.push( res*10 + x - 1);
    q.push( res*10 + x );
    if(x != 9) q.push( res*10 + x + 1);      
  }

  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 1792
from itertools import accumulate
import sys
input = sys.stdin.readline

def solve():
    N = int(input())
    Sss = [input().rstrip() for _ in range(N)]

    numL = numR = 0
    Pluss, Evens, Minuss = [], [], []
    for Ss in Sss:
        nums = [0] + [1 if S == '(' else -1 for S in Ss]
        nums = list(accumulate(nums))
        x = min(nums)
        y = nums[-1] - x
        x, y = abs(x), abs(y)
        if x == 0:
            numL += y
        elif y == 0:
            numR += x
        else:
            if x > y:
                Minuss.append((x, y))
            elif x < y:
                Pluss.append((x, y))
            else:
                Evens.append((x, y))

    Pluss.sort(key=lambda x: x[0])
    Minuss.sort(key=lambda x: x[1], reverse=True)

    v = numL
    for x, y in Pluss:
        v -= x
        if v < 0:
            return False
        v += y
    for x, y in Evens:
        v -= x
        if v < 0:
            return False
        v += y
    for x, y in Minuss:
        v -= x
        if v < 0:
            return False
        v += y
    v -= numR
    return v == 0


if solve():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 166556
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef vector <string> vs;
#define N1 5
#define N2 13
int main(void){
	vi card(N2);
	string prize[7]={"null","one pair","two pair","three card","straight","full house","four card"};
	while (true){
		for (int i=0; i<N2; i++)
			card[i]=0;
		int a=0, b=0, d=N2, p=0,tmp;
		for (int i=0;i<N1;i++){
			char c;
			if (i!=0) cin>>c;
			cin>>tmp;
			if (cin.eof()) break;
			tmp--;
			if (tmp<d) d=tmp;
			if (card[tmp]==0) b++;
			card[tmp]++;
			if (card[tmp]>a) a=card[tmp];
		}
		if (b==0) break;
		switch (b){
		case 2: 
			if (a==4) p=6;
			else p=5;
			break;
		case 3:
			if (a==3) p=3;
			else p=2;
			break;
		case 4:
			p=1;
			break;
		case 5:
			bool f=true;
			for (int i=d; i<d+N1; i++)
				if (card[i]!=1){
					f=false;
					break;
				}
			if (!f && card[0]==1){
				f=true;
				for (int i=9; i<N2; i++)
					if (card[i]!=1){
						f=false;
						break;
					}
			}
			if (f) p=4;
			else p=0;
		}
		cout<<prize[p]<<endl;
	}
}

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

int main() {
    const int MOD = 1e9 + 7;
    int n;
    cin >> n;

    ll ans = 1;
    for (ll i = 2; i <= n; i++) ans = (ans * i) % MOD;

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


Measured memory_bytes: 3632
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, m, x;
    cin >> n >> m >> x;
    int cost[n] = {};
    int plus[n][m] = {};

    for(int i=0;i<n;++i)
    {
        cin >> cost[i];
        for(int j=0;j<m;++j)
        {
            cin >> plus[i][j];
        }
    }
    int ret = 1 << 30;
    for(int i = 0; i < (1 << n);++i)
    {
        int tmp_cost = 0;
        int score[m] = {};
        for(int j=0;j<n;++j)
        {
            if((i & (1 << j)) != 0)
            {
                tmp_cost += cost[j];
                for(int k=0;k<m;++k)
                {
                    score[k] += plus[j][k];
                }
            }
        }
        bool ok = true;
        for(int j=0;j<m;++j)
        {
            if(score[j] < x)
            {
                ok = false;
            }
        }
        if(ok){
            ret = min(ret, tmp_cost);
        }
    }
    if(ret == (1<<30))
    {
        cout << -1 << endl;
    }else{
        cout << ret << endl;
    }
}

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

int toGray(int n){
	return n ^ (n >> 1);
}
int toDecimal(int n){
	int mask = n >> 1;
	while(mask != 0){
		n ^= mask;
		mask >>= 1;
	}
	return n;
}

const int N = 1 << 17;

int vis[N+5];

int main() {
	// reset
	for(int i=0; i<N+3; i++) vis[i] = 0;
	// input
	int n,a,b; scanf("%d %d %d", &n, &a, &b);
	int bats = 1 << n;
	//
	if(__builtin_popcount(a) % 2 == __builtin_popcount(b) % 2){
		printf("NO\n");
		return 0;
	}
	//
	a = toDecimal(a);
	b = toDecimal(b);
	//
	printf("YES\n");
	//
	int state = 0; if(a >= (bats>>1)) state = 2;
	for(int noww=a; state<10; ){
		printf("%d ", toGray(noww));
		vis[noww] = 1;
		//
		if(state == 0){
			int next = bats-noww-1;
			if(next == b){
				state = 4;
			} else {
				noww = next;
				state = 1;
			}
		} else if(state == 1){
			int next = noww-1; if(noww == bats>>1) next = bats-1;
			noww = next;
			state = 2;
		} else if(state == 2){
			int next = bats-noww-1;
			if(next == b){
				state = 6;
			} else {
				noww = next;
				state = 3;
			}
		} else if(state == 3){
			int next = noww+1; if(noww+1 == bats>>1) next = 0;
			noww = next;
			state = 0;
		}

		if(state == 4){
			int next = noww+1;
			if(noww+1 == bats>>1) next = 0;
			if(noww+1 == bats) next = bats>>1;
			//
			if(vis[next]){
				next = bats-noww-1;
			}
			if(next == b){
				state = 10;
			}
			noww = next;
		}

		if(state == 6){
			int next = noww-1;
			if(noww == bats>>1) next = bats-1;
			if(noww == 0) next = (bats>>1) - 1;
			//
			if(vis[next]){
				next = bats-noww-1;
			}
			if(next == b){
				state = 10;
			}
			noww = next;
		}
	}
	printf("%d\n", toGray(b));
	return 0;
}


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

using namespace std;
 
#define RIGHT '>'
#define LEFT '<'
#define TOP '^'
#define UNDER 'v'
#define LOOP 'l'
#define END '.'
#define MAX 101
 
void dfs(char mp[MAX][MAX], int i, int j)
{
    if (mp[i][j] == END) {
        printf("%d %d\n", j, i);
        return;
    }
    if (mp[i][j] == LOOP) {
        printf("LOOP\n");
        return;
    }
     
    if (mp[i][j] == RIGHT) {
        mp[i][j] = LOOP;
        dfs(mp, i, j+1);
    } else if (mp[i][j] == LEFT) {
        mp[i][j] = LOOP;
        dfs(mp, i, j-1);
    } else if (mp[i][j] == TOP) {
        mp[i][j] = LOOP;
        dfs(mp, i-1, j);
    } else {
        mp[i][j] = LOOP;
        dfs(mp, i+1, j);
    }
}
 
int main()
{
    char mp[MAX][MAX];
    int n, m;
     
    while (cin >> n >> m, (n | m)) {
        for (int i = 0; i < n; i++) {
            cin >> mp[i];
        }
        dfs(mp, 0, 0);
    }
    return 0;
}

Measured memory_bytes: 3084
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int a;
  cin >> a;

  cout << a + a*a + a*a*a << endl;

  return 0;
}


Measured memory_bytes: 3520
#include <stdio.h>
#define N 1000
int main()
{
  int i,n;
  int mat[N];
  scanf("%d",&n);

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

  for(i=n-1;i>=0;i--)
  {
    if(i==0) printf("%d",mat[0]);
    else printf("%d ",mat[i]);
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 604
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.11 03:01:42
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    string s;cin >> s;
    if (s[0] == s[s.size()-1]) {
        if (s.size() % 2 == 0) {
            puts("First");
        }
        else {
            puts("Second");
        }
    }
    else {
        if (s.size() % 2 == 0) {
            puts("Second");
        }
        else {
            puts("First");
        }
    }
    return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

map<int, int> prime_factors(int n) {
    map<int, int> res;
    if(n == 1) { // n=1 の素因数分解は n^1
        res[n] = 1;
        return res;
    }
    for(int i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++res[i]; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

int main() {
   int N;
   cin >> N;
   map<int, int> log;
   for (int i = 1; i <= N; i++) {
      map<int, int> res = prime_factors(i);
      for(map<int, int>::iterator it = res.begin(), end = res.end(); it != end; ++it) {
         // cout << it->first << "^" << it->second << endl;
         if (it->first == 1) continue;
         log[it->first] += it->second;
      }
   }
   ll ans = 1;
   for (auto alog : log) {
      ans *= 1 + alog.second;
      ans %= MOD;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
D, G = map(int, input().split())
items = []
for i in range(D):
    p, c = map(int, input().split())
    items.append((p, c, i))

ans = float("inf")
for i in range(2 ** D):
    bit = bin(i)[2:].zfill(D)
    sum_num = 0
    cnt = 0
    used = set()
    for j in range(D):
        b = bit[j]
        if b == "1":
            used.add(j)
            cnt += items[j][0]
            sum_num += 100 * (j + 1) * items[j][0] + items[j][1]
    if sum_num >= G:
        ans = min(ans, cnt)
    else:
        for p, c, j in reversed(items):
            if j in used:
                continue
            for a in range(p - 1):
                sum_num += 100 * (j + 1)
                cnt += 1
                if sum_num >= G:
                    break
            if sum_num >= G:
                ans = min(ans, cnt)
                break
print(ans)


Measured memory_bytes: 3064
s=input()
s_l=len(s)

for i in range(s_l-1):
  if s[i]==s[i+1]:
    i+=1
    print(i,i+1)
    exit()
  elif i!=s_l-2 and s[i]==s[i+2]:
    i+=1
    print(i,i+2)
    exit()

print(-1,-1)

Measured memory_bytes: 3188
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
mint dp[100005][5];
int main(){
 string s;
 cin>>s;
 int n=s.size();
 dp[0][0]=1;
 for(int i=0;i<n;i++){
     for(int j=0;j<4;j++){
         dp[i+1][j]+=dp[i][j]*(s[i]=='?'?mint(3):mint(1));
         if(s[i]=='?'||s[i]-'A'==j)dp[i+1][j+1]+=dp[i][j];
     }
 }
 cout<<dp[n][3]<<"\n";
}
 

Measured memory_bytes: 7624
#include<stdio.h>

double count=0;
void margesort(int *,int,int);
void marge(int *,int,int,int);

int S[200000],L[100001],R[100001];

int main(){
  FILE* p;
  int n,i;
  //p=fopen("ALDS1_5_D_in19.txt","r");
  //fscanf(p,"%d",&n);
  scanf("%d",&n);
  for(i=0;i<n;i++) //fscanf(p,"%d",&S[i]); 
     scanf("%d",&S[i]);
  
   margesort(S,0,n);
   printf("%.0f\n",count); 

   //fclose(p);   

   return 0;
}

void margesort(int *S,int left,int right){
  int mid;
  if(left+1 < right){ 
    mid = (left + right)/2;
    margesort(S,left,mid);
    margesort(S,mid,right);
    marge(S,left,mid,right);
  }
}

void marge(int *S,int left,int mid,int right){
  int n1,n2;
  int i,j=0,k;

  n1 = mid - left;
  n2 = right - mid;

  for(i=0;i<n1;i++) L[i] = S[left+i];
  L[n1]=-1;
  for(i=0;i<n2;i++) R[i] = S[mid+i];
  R[n2]=-1;

  i=0;
  for(k=left;k<right;k++){
  if(L[i] > R[j]){  
    S[k] = L[i];
    i++;
    count += n2 - j;
  }
  else{
    S[k] = R[j];
    j++;
  }
  }
}

Measured memory_bytes: 2192
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 N,M;

int main() {
  cin >> N >> M;
  vector<i64> A(N);
  vector<i64> B(N);
  rep(i,0,N - 1) cin >> A[i] >> B[i];
  vector<pair<i64,i64>> vec;
  rep(i,0,N - 1) vec.push_back({A[i], B[i]});
  sort(all(vec));

  int cnt = 0;

  i64 ans = 0;

  for(auto p: vec) {
    i64 a = p.first;
    i64 b = p.second;
    i64 need = min(M - cnt, b);
    cnt += need;
    ans += a * need;
    if(cnt == M) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using ll = long long;
const ll MOD = 1000000007;
#define rep(i,n) for (ll i=0; i < (n); i++)
using namespace std;
int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

  vector<int> a(n+1);
  rep(i,n) scanf("%d", &a[i+1]);

  vector<int> ball(n+1, 0);
  int ans1 = 0;
  vector<int> ans2;
  for (int i = n; i > 0; i--) {
    int sum = 0;
    for (int j = 2 * i; j <= n; j += i) {
      sum += ball[j];
    }
    ball[i] = (sum % 2) == a[i] ? 0 : 1;
    if (ball[i] == 1) {
      ans1++;
      ans2.push_back(i);
    }
  }

  printf("%d\n", ans1);
  rep(i,ans2.size()) printf("%d ", ans2[i]);
  printf("\n");

  return 0;
}


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

int main() {
	int a, b, c, count = 0;
	cin >> a >> b >> c;
	for (int i = a; i < b + 1; i++) {
		if (c % i == 0) count++;
	}
	cout << count << "\n";
	return 0;
}


Measured memory_bytes: 3088
W, H, N = map(int,input().split())
xya = [list(map(int,input().split())) for _ in range(N)]
ls = list(range(1,W*H+1))
for n in range(N):
  if xya[n][2] == 1:
    ls = [K for K in ls if (K-1)%W >= xya[n][0]]
  if xya[n][2] == 2:
    ls = [K for K in ls if (K-1)%W < xya[n][0]]
  if xya[n][2] == 3:
    ls = [K for K in ls if (K-1)/W >= xya[n][1]]
  if xya[n][2] == 4:
    ls = [K for K in ls if (K-1)/W <= xya[n][1]]
print(len(ls))


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

int main() {
  string week[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string day;
  cin >> day;

  for(int i = 0; i < 7; ++i) {
    if(week[i] == day) {
      cout << (7 - i) << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d %d", $n, $m);

  $a = [];
  $b = [];
  for ($i=0; $i<$n; $i++) {
    fscanf(STDIN, "%d %d", $a[], $b[]);
  }

  $ans = [];
  $min = [];
  for ($i=0; $i<$n; $i++) $min[$i] = 9999999999999;


  for ($i=0; $i<$m; $i++) {
    fscanf(STDIN, "%d %d", $c, $d);
    $sum = 0;
    for ($j=0; $j<$n; $j++) {
      $dist = abs($a[$j]-$c) + abs($b[$j]-$d);
      if ($min[$j] > $dist) {
        $min[$j] = $dist;
        $ans[$j] = $i +1;
      }
    }
  }

  for ($i=0; $i<$n; $i++) {
    echo $ans[$i] . "\n";
  }
?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

void solve()
{
	ll n,ans=0,k=0;;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='I')
			ans++;
		else
			ans--;
		k=max(ans,k);
	}
	cout<<k;;	
	return;
}
int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 3592
N = int(input())
X = list(map(int, input().split()))
sorted_X = sorted(X)
median_index = N//2
ans1 = sorted_X[median_index]
ans2 = sorted_X[median_index-1]

for x in X:
  if ans1 > x:
    print(ans1)
  else:
    print(ans2)


Measured memory_bytes: 25228
# word = [w for w in input()]
word = input()
alpha_lists = [-1] * 26
flg = True

for w in word:
  alpha_lists[ord(w) - ord('a')] = 1

for a in range(len(alpha_lists)):
  if(alpha_lists[a] == -1):
    print(chr(ord('a') + a))
    flg = False
    break
    
if(flg):
  print("None")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;

bool myfunc(const ll& a, const ll& b){
	return a>b;
}

int main(){
	int x,y,a,b,c; cin>>x>>y>>a>>b>>c;
	vector<ll> p(a), q(b), r(c);
	
	for(int i=0;i<a;i++) cin>>p[i];
	for(int i=0;i<b;i++) cin>>q[i];
	for(int i=0;i<c;i++) cin>>r[i];
	
	sort(all(p), myfunc);
	sort(all(q), myfunc);
	sort(all(r), myfunc);
	
	
	
	ll sumr[c+5], suma[a+5], sumb[b+5];
	
	int limit=min(x+y, c);
	
	sumr[0]=0;
	suma[0]=0;
	sumb[0]=0;
	
	for(int i=1; i<=x; i++) suma[i]=suma[i-1]+p[i-1];
	for(int i=1; i<=y; i++) sumb[i]=sumb[i-1]+q[i-1];
	for(int i=1; i<=c; i++) sumr[i]=sumr[i-1]+r[i-1];
	
	int inda=x-1, indb=y-1;
	ll ans=sumr[0]+suma[x]+sumb[y];
	
	for(int i=1; i<=limit; i++){
		ll temp = sumr[i];
		if(inda >= 0 && indb >= 0){
			if(p[inda] < q[indb]){
				temp+=sumb[indb+1] + suma[inda];
				inda--;
			}
			else{
				temp+=suma[inda+1] + sumb[indb];
				indb--;
			}
		}
		else if(inda >= 0){
			temp+=suma[inda]+sumb[indb+1];
			inda--;
		}
		else if(indb >= 0){
			temp+=suma[inda+1]+sumb[indb];
			indb--;
		}
		ans=max(ans,temp);
	}
	
	cout<<ans;
	
	return 0;
}


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

using namespace std;

const int md = (int) 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  long long ans1 = 1, ans2 = 2, ans3 = 1;
  for (int i = 0; i < n; i++) {
    (ans1 *= 10) %= md;
    (ans2 *= 9) %= md;
    (ans3 *= 8) %= md;
  }
  (ans1 -= ans2 - ans3 - md) %= md;
  cout << ans1 << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)cout<<1<<endl;
  else if(b==0)cout<<2<<endl;
  else if(c==0)cout <<3<<endl;
  else if(d==0)cout<<4<<endl;
  else if(e==0)cout<<5<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
const int N=1e9+3;
#define int long long
#define double long double

int32_t main()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 IOS;
 
 	
 	int n,w;
 	cin>>n>>w;
 	int wt[n+1];
 	int v[n+1];
 	for (int i = 1; i <= n; ++i)
 	{
 		/* code */cin>>wt[i]>>v[i];
 	}
 	int dp[n+1][w+1];
 	for (int i = 0; i <=n ; ++i)
 	{
 		for (int j = 0; j<= w; ++j)
 		{
 			if(i==0||j==0)
 				dp[i][j]=0;
 			else if(wt[i]<=j)
 			{
 				dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-wt[i]]);
 			}
 			else
 				dp[i][j]=dp[i-1][j];

 		}
 	}
 	cout<<dp[n][w];
 	
 	

 	

 



  
 




  
return 0;
}


Measured memory_bytes: 82372
n = io.read("*n")
rem = 0
t = {}
s = {}
for i = 1, n do
    a = io.read("*n")
    if(n < a) then
        rem = rem + 1
    elseif(s[a] ~= nil) then
        rem = rem + 1
    else
        if(t[a] == nil) then
            t[a] = 1
        else
            t[a] = t[a] + 1
        end
        if(t[a] == a) then
            s[a] = true
            t[a] = 0
        end
    end
end
for k, v in pairs(t) do
    rem = rem + v
end
print(rem)

Measured memory_bytes: 256
N = int(input())

def printCompleteGraph(n):
    edge = [(u, v) for u in range(n)
                   for v in range(u + 1, n)
                   if u != v]
    name = {e: i+1 for i, e in enumerate(edge)}
    for u in range(n):
        e = [name[(min(u, v), max(u, v))] for v in range(n) if u != v]
        print(len(e), ' '.join(map(str, e)))

for n in range(2, max(N, 2) + 1):
    if n * (n - 1) // 2 == N:
        print('Yes')
        print(n)
        printCompleteGraph(n)
        exit()
print('No')


Measured memory_bytes: 24332
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 25005;
const int K = 405;
const int mo = 1e9+7;

LL f[N][K],g[N][K];
int n,m,k;
int a[N];
int vis[K],tim;

LL quickmi(LL x,LL tim){
	LL ret=1;
	for(;tim;tim/=2,x=x*x%mo)
	if (tim&1)ret=ret*x%mo;
	return ret;
}

int main(){
	n=get();k=get();m=get();
	fo(i,1,m)a[i]=get();
	bool ext=0;
	fo(i,k,m){
		tim++;
		int cnt=0;
		fo(j,1,k)if (vis[a[i-j+1]]<tim)cnt++,vis[a[i-j+1]]=tim;
		if (cnt==k){ext=1;break;}
	}
	if (ext){
		LL ans=1;
		fo(i,1,n-m)ans=ans*k%mo;
		ans=ans*(n-m+1)%mo;
		cout<<ans<<endl;
		return 0;
	}
	int pre=m,suf=1;
	tim++;
	fo(i,1,m)
	if (vis[a[i]]<tim)vis[a[i]]=tim;else{pre=i-1;break;}
	tim++;
	fd(i,m,1)
	if (vis[a[i]]<tim)vis[a[i]]=tim;else {suf=i+1;break;}
	if (pre<m){
		suf=m-suf+1;
		f[pre][pre]=1;
		fo(i,pre,n-1){
			f[i][k]=0;
			fd(j,k-1,1)f[i+1][j]=(f[i+1][j+1]+f[i][j])%mo;
			fo(j,1,k-1)f[i+1][j+1]=(f[i+1][j+1]+f[i][j]*(k-j))%mo;
		}
		f[n][k]=0;
		g[suf][suf]=1;
		fo(i,suf,n-1){
			g[i][k]=0;
			fd(j,k-1,1)g[i+1][j]=(g[i+1][j+1]+g[i][j])%mo;
			fo(j,1,k-1)g[i+1][j+1]=(g[i+1][j+1]+g[i][j]*(k-j))%mo;
		}
		LL ans=0;
		fo(l,0,n){
			int r=n+pre+suf-m-l;
			if (!(r>=0&&r<=n))continue;
			LL vl=0,vr=0;
			fo(j,1,k-1)vl=(vl+f[l][j])%mo,vr=(vr+g[r][j])%mo;
			ans=(ans+vl*vr)%mo;
		}
		LL sum=n-m+1;
		fo(i,1,n-m)sum=sum*k%mo;
		ans=(sum+mo-ans)%mo;
		cout<<ans<<endl;
	}
	else{
		f[1][1]=k;
		if (m<=1)g[1][1]=k;
		fo(i,1,n-1){
			f[i][k]=g[i][k]=0;
			fd(j,k-1,1){
				f[i+1][j]=(f[i+1][j+1]+f[i][j])%mo;
				g[i+1][j]=(g[i+1][j+1]+g[i][j])%mo;
			}
			fo(j,1,k-1){
				f[i+1][j+1]=(f[i+1][j+1]+f[i][j]*(k-j))%mo;
				g[i+1][j+1]=(g[i+1][j+1]+g[i][j]*(k-j))%mo;
			}
			fo(j,m,k-1)g[i+1][j]=(g[i+1][j]+f[i+1][j])%mo;
		}
		f[n][k]=g[n][k]=0;
		LL ans=0;
		fo(i,1,k-1)ans=(ans+g[n][i])%mo;
		LL v=1;
		fo(i,1,m)v=v*(k-i+1)%mo;
		ans=ans*quickmi(v,mo-2)%mo;
		LL sum=n-m+1;
		fo(i,1,n-m)sum=sum*k%mo;
		ans=(sum+mo-ans)%mo;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 158464
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    ll res = LONG_LONG_MAX;
    const ll mod = 2019;
    ll l, r; cin >> l >> r;
    for (ll i = l; i <= min(r, l + 2020); i++) {
        for (ll j = i + 1; j <= min(r, i + 2020); j++) {
            res = min(res, (i * j) % mod);
        }
    }
    cout << res << "\n";
}


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

int main(){
	int N,M; scanf("%d%d",&N,&M);
	int s,t,e;
	vector<Q> q;
	while(scanf("%d%d%d",&s,&t,&e),s!=0) q.push_back(Q(s-1,P(t-1,e)));
	int L; scanf("%d",&L);
	int count[10000],b[10000];
	for(int i=0;i<L;i++){
		for(int j=0;j<N;j++) count[j]=0;
		for(int j=0;j<M;j++) scanf("%d",&b[j]);
		for(int j=0;j<q.size();j++){
			Q x=q[j]; P y=x.second;
			count[x.first]+=b[y.first]*y.second;
		}
		for(int j=0;j<N;j++) printf("%d%s",count[j],j==N-1?"\n":" ");
	}
}

Measured memory_bytes: 1984
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;

int main(void)
{
  int n;
  char s[110];
  cin>>n;
  for(int i=0;i<n;i++)
    {
      cin>>s[i];
    }
  int max=0;
  for(int i=0;i<n;i++)
    {
      bool a[27]={false};
	bool b[27]={false};
      int co=0;
      for(int j=0;j<i+1;j++)
	{
	  a[s[j]-'a']=true;
	}
      for(int j=i+1;j<n;j++)
	{
	  b[s[j]-'a']=true;
	}
      for(int j=0;j<26;j++)
	{
	  if(a[j]==true&&b[j]==true)co++;
	}
      if(co>max)max=co;
    }
  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 256