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

int a[] = {1, 10, 9, 12, 3, 4}, mod = 1e9 + 7, pw[100000];
long long dp[100000][13];
string s;

int sol(int p, int md)
{
    if (p == s.size() && md == 5)
        return 1;
    if (p == s.size())
        return 0;
    if (dp[p][md] != -1)
        return dp[p][md];
    long long sum = 0;
    if (s[p] == '?')
        for (int i = 0; i < 10; ++i)
            sum = (sum + sol(p + 1, (md + (1ll * i * pw[p])) % 13)) % mod;
    else
        sum = (sum + sol(p + 1, (md + (1ll * (s[p] - '0') * pw[p])) % 13)) % mod;
    return dp[p][md] = sum;
}

int main()
{
    cin >> s;
    int cnt = -1;
    memset(dp, -1, sizeof dp);
    for (int i = s.size() - 1; i >= 0; --i)
        cnt = ((cnt + 1) % 6), pw[i] = a[cnt];
    cout << sol(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 17280
def main():
    inf = float('inf')

    n = int(input())
    *p, = map(int, input().split())

    ma = inf
    ret = 0
    for x in p:
        if x <= ma:
            ret += 1
            ma = x
    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

using namespace std;

#define int long long
#define MOD 1000000007

#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 (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n;
string s;

signed main()
{
    cin >> n >> s;

    if (n % 2 == 1)
    {
        cout << "No" << endl;
        return 0;
    }

    rep(i, n / 2)
    {
        if (s[i] != s[i + n / 2])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


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

int main(){
    long long a,b,temp,cobai[50],coyaku[50],i=0,clm;

    while (std::cin){
        std::cin >> a >> b;
        clm = a*b;

        if (a<b){
            std::swap(a,b);
        }

        while (b!=0){
            temp = b;
            b = a%b;
            a = temp;
        }
        coyaku[i] = a;
        cobai[i]  = clm/a;
        i++;
    }
    for (int j=0;j<i-1;j++){
        std::cout << coyaku[j] << " " << cobai[j] << std::endl;
    }
}

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <algorithm>

inline long long dig(long long a)
{
  long long r = 0;
  while (a > 0)
  {
    r++;
    a /= 10;
  }
  return r;
}

int main()
{
  long long n;
  scanf("%lld", &n);
  const long long lim = (long long)std::floor(std::sqrt(n));
  long long ans = 1e12;
  for (long long i = 1; i <= lim; ++i)
  {
    if (n % i == 0)
    {
      if (ans > std::max(dig(i), dig(n / i)))
      {
        ans = std::max(dig(i), dig(n / i));
      }
    }
  }
  
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  int n,a,maxi;
  cin >> n;
  cin >> a;
  maxi=a;
  int x[100];
  FOR(i,n){
    cin >> x[i];
    chmax(maxi,x[i]);
  }

  ll dp[51][51][2505]={0};
  dp[0][0][0]=1;
  for(int i=1;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      for(int k=0;k<maxi*n+1;k++){
        if(i>0 && j>0 && k-x[i-1]>=0){
          dp[i][j][k]=dp[i-1][j-1][k-x[i-1]]+dp[i-1][j][k];
        }else if(i>0){
          dp[i][j][k]=dp[i-1][j][k];
        }else{
          dp[i][j][k]=0;
        }

        
      }
    }
  }
  ll ans=0;
    for(int j=1;j<n+1;j++){
      ans+=dp[n][j][j*a];
    }
  
  
  cout << ans << endl;

  
  
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vv vector

#define fi first
#define se second
#define all(A) A.begin(),A.end()

void mxin(ll&a ,ll b){
    if(a<b)
        a = b;
}

using namespace std;

/////////////////////////////////////////////////////


ll N;
ll i, j, k;

ll mk[256];

ll ati(char c){
    return c - 'a';
}

void calc(ll I,ll l,ll r,vv<string> &S,vv<vv<ll>>&smk){
    //printf("%lld,%lld,%lld,%lld\n", l, r, I, mk['c' - 'a']);
    rep(l,l,r+1){
        if(I!=S[l].size())
            break;
    }
    if(l>r)
        return;
    
    ll i, j = l,k, ret = 0;
    rep(i,l,r+2){
        if(i<=r&&I<S[i].size()&&S[j][I]==S[i][I]){
            //printf("b%lld,%lld,%c,%lld\n", i,I, S[i][I], mk[S[i][I] - 'a']);
            
        }else{
            rep(k,j,i){
                if(I+2==S[k].size()){
                    //printf("a%lld,%c\n", I,k, S[k][I + 1]);
                    ++mk[ati(S[k][I + 1])];
                }
            }
            calc(I + 1, j, i - 1, S, smk);
            rep(k,j,i){
                if(I+2==S[k].size()){
                    --mk[ati(S[k][I + 1])];
                }
            }
            j = i;
        }
        if(i<=r&&I<S[i].size())
            mxin(smk[i][ati(S[i][I])], mk[ati(S[i][I])]);
    }
    
}


int main(){
    cin >> N;
    vv<string> S(N);
    rep(i,0,N){
        cin >> S[i];
        //cout << S[i]<<endl;
        reverse(all(S[i]));
    }
    sort(all(S));
    S.push_back("");
    vv<vv<ll>> smk(N + 5, vv<ll>(30));
    rep(i,0,N){
        //cout << S[i] <<S[i].size()<< endl;
        if(S[i].size()==1){
            ++mk[ati(S[i][0])];
        }
    }
    calc(0, 0, N - 1, S, smk);
    ll ans = -N;
    j = 0;
    rep(i, 0, N + 1)
    {
        ll a = 0;
        rep(k,0,27){
            a += smk[i][k];
            //printf("%lld,%lld:%lld\n", i, j, smk[i][j]);
        }
        //printf("%lld,%lld ", i, a);
        ans += a;

        //printf("%lld,%lld\n", i, ans);
        if(S[i]!=S[j]){
            //printf(" %lld ", i - j);
            ans -= (i - j) * (i - j - 1) / 2;
            j = i;
        }
        //printf("%lld,%lld\n", i, ans);
    }
    cout << ans << endl;
    return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

int main(){
    LL n,a,b;
    cin>>n>>a>>b;

    LL ans = a*(n/(a+b));
    if(n%(a+b)<a){
        ans += n%(a+b);
    }else{
        ans += a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define m 1000000007
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	ll suff[n];
	suff[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--){
		suff[i]=((a[i]%m)+(suff[i+1]%m))%m;
	}
	ll ans=0;
	for(int i=0;i<n-1;i++){
		ans+=(a[i]*suff[i+1])%m;
		ans=ans%m;
	}
	cout<<ans;
}


Measured memory_bytes: 6744
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

void solve(long long n, vector<long long> a){
	sort(a.begin(),a.end());
	pll ans=MP(INF,INF);
	ll b=a[n-1];
	for (int i=0;i<n-1;i++) {
		chkmin(ans,MP(abs(b-2*a[i]),a[i]));
	}
	printf("%lld %lld\n",b,ans.snd);
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long n;
	scanf("%lld",&n);
	vector<long long> a(n-1+1);
	for(int i = 0 ; i <= n-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(n, a);
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define endl '\n'
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=3e3+10,mod=998244353;
ll dp[N][N];
ll a[N];
int32_t main(){
    sync;
    ll n,s;
    cin >> n >> s;
    dp[0][0]=1;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    for (int i=1;i<=n;i++){
        for (int j=0;j<N;j++){
            dp[i][j]=dp[i-1][j];
            if (j-a[i]>=0) dp[i][j]+=dp[i-1][j-a[i]];
            if (j==0) dp[i][j]++;
            dp[i][j]%=mod;

        }
    }
    ll ans=0;
    for (int i=1;i<=n;i++) ans+=dp[i][s];
    cout << ans%mod << endl;
}


Measured memory_bytes: 70784
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    int a,b;
    cin>>a>>b;
    int ans = max({a+b,a-b,a*b});
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    string S;
    cin>>S;
    int ans=0;
    REP(i,N-2){
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
            ans+=1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>

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

const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};

using namespace std;

int H, W;
vector<string> field;
vector<vector<int> > dist;
int max_dist;
vector<queue<int> > que(2, queue<int>());

void bfs() {
    
    while(!que[0].empty() && !que[1].empty()) {
        int ch=que[0].front(), cw=que[1].front();
        que[0].pop();
        que[1].pop();
        
        int nh, nw;
        // cout << "ch = " << ch << ", cw = " << cw << endl;
        rep(dir, 4) {
            nh = ch + dh[dir];
            nw = cw + dw[dir];
            
            if(nh<0 || nh>=H || nw<0 || nw>=W) continue;
            if(dist[nh][nw]!=-1) continue;
            
            dist[nh][nw] = dist[ch][cw] + 1;
            
            if(dist[nh][nw]>max_dist) max_dist = dist[nh][nw];

            que[0].push(nh);
            que[1].push(nw);
        }
    }
}

int main() {
    cin >> H >> W;
    field.resize(H);
    dist.assign(H, vector<int>(W, -1));
    
    rep(h, H) {
        cin >> field[h];
        rep(w, W) {
            if(field[h][w]=='#') {
                que[0].push(h);
                que[1].push(w);
                dist[h][w] = 0;
            }
        }
    }

    bfs();
    
    cout << max_dist << endl;

    return 0;
    
}

Measured memory_bytes: 13440
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	static void solve() throws Exception {
		out.print(360 / gcd(360, scanInt()));
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 32748
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), n = rd[0], y = rd[1]/1000;
  foreach (u; 0..n+1)
    foreach (v; 0..n+1) {
      auto w = n-u-v;
      if (w >= 0 && 10*u+5*v+w == y) {
        writeln(u, " ", v, " ", w);
        return;
      }
    }
  writeln("-1 -1 -1");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll N, X;
	cin >> N >> X;

	vector<ll> L(N + 1);
	repn(i, N) cin >> L[i];

	ll ans = 1;

	ll d = 0;

	repn(i, N) {
		d += L[i];
		if (d > X) { break; }
		ans++;
	}

	cout << ans;

	system("PAUSE");
}

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

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] cnt = new long[5];
            Arrays.fill(cnt, 0);
            for (int i = 0; i < n; ++i) {
                String str = in.next();
                if (str.charAt(0) == 'M') {
                    cnt[0]++;
                } else if (str.charAt(0) == 'A') {
                    cnt[1]++;
                } else if (str.charAt(0) == 'R') {
                    cnt[2]++;
                } else if (str.charAt(0) == 'C') {
                    cnt[3]++;
                } else if (str.charAt(0) == 'H') {
                    cnt[4]++;
                }
            }

            long res = cnt[0] * cnt[1] * cnt[2] + cnt[0] * cnt[1] * cnt[3] + cnt[0] * cnt[1] * cnt[4] +
                    cnt[0] * cnt[2] * cnt[3] + cnt[0] * cnt[2] * cnt[4] +
                    cnt[0] * cnt[3] * cnt[4] +
                    cnt[1] * cnt[2] * cnt[3] + cnt[1] * cnt[2] * cnt[4] +
                    cnt[1] * cnt[3] * cnt[4] +
                    cnt[2] * cnt[3] * cnt[4];

            out.println(res);
        }

    }
}



Measured memory_bytes: 46996
from collections import defaultdict, deque
import sys

INF = float('inf')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n = I()
s = S()
ans = 'Yes' if s[:len(s) // 2] == s[len(s) // 2:] else 'No'
print(ans)


Measured memory_bytes: 3444
#include<stdio.h>
#include<iostream>
#include<string>
#include<utility>
using namespace std;

int main(){
int n,q;
int sum = 0;
int ans[100003] = {};
cin >> n >> q;
string s;
cin >> s;
for(int i=1;i<=n;i++){
if(s[i-1] == 'A' && s[i] == 'C'){
sum++;
}
ans[i] += sum;
}
for(int i=0;i<q;i++){
int tempA,tempB;
cin >> tempA >> tempB;
cout << ans[tempB - 1] - ans[tempA -1] << endl;
}
return 0;
}






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

using namespace std;

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int b[m],a[n][m];
    int counter=0;
    rep(i,m)cin>>b[i];
    rep(i,n){
        int ans=c;
        rep(j,m){
            cin>>a[i][j];
            ans+=b[j]*a[i][j];
        }
        counter+=(ans>0 ? 1:0);
    }
    cout<<counter<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long dp[200001];

#define ll long long


struct Tree {
    typedef ll T;
    const T LOW =-1e9;
    T f(T a, T b) { return max(a,b); }// this is the function change it to sum,min,max
    ll n;
    vector<T> s;
    Tree() {}
    Tree(ll m, T def=-1e9) { init(m, def); }//the value of def should be like 1e9 for min and -1e9 for max and 0 for sum
    void init(ll m, T def) {
        n = 1; while (n < m) n *= 2;
        s.assign(n + m, def);
        s.resize(2 * n, LOW);
        for (ll i = n; i --> 1; )
            s[i] = f(s[i * 2], s[i*2 + 1]);
    }
    void update(ll pos, T val) {
        pos += n;
        s[pos] = val;
        for (pos /= 2; pos >= 1; pos /= 2)
            s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
    }
    T query(ll l, ll r) { return que(1, l, r, 0,n); }
    T que(ll pos, ll l, ll r, ll lo, ll hi) {
        if (r <= lo || hi <= l) return LOW;
        if (l <= lo && hi <= r) return s[pos];
        ll m = (lo + hi) / 2;
        return f(que(2 * pos, l, r, lo, m),que(2 * pos + 1, l, r, m, hi));
    }
};


int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    memset(dp, 1, sizeof(dp));
    
    int n;
    cin>>n;
    int h[n];
    int a[n];
    for(int i = 0 ; i < n ; i++){
        cin>>h[i];
    }
    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
    }
  //  int prev[n] = {-1};
    Tree s(200000);
    //cout<<endl;
    long long ans = 0;
    
    //cout<<endl;
    for(int i = 0 ; i < n ; i++){
        ll m = s.query(0,h[i]);

        //cout<<"here"<<endl;
        if(m == -1e9){
            dp[i] = a[i];
            s.update(h[i], dp[i]);
        }
        else{
            dp[i] = a[i] + m;
            s.update(h[i], dp[i]);
        }
       // cout<<dp[i]<<" ";
        if(ans < dp[i]){
                ans = dp[i];
        }
    }
   // cout<<endl;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 13056
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  string s1, s2, s3; cin >> s1 >> s2 >> s3;
  cout << (char)(s1[0] - 'a' + 'A') << (char)(s2[0] - 'a' + 'A') << (char)(s3[0] - 'a' + 'A') << endl;
  return;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで



using namespace std;
lint n;
lint gcd(lint a,lint b){
  if(a<b) swap(a,b);
  if(b==0) return a;
  return gcd(b,a%b);
}


lint lcm(lint a,lint b){
  lint k = gcd(a,b);
  //dump(k);
  lint ans = a/k;
  ans = ans * b;
  return ans;
}

int main(){
  cin >> n;
  lint ans = 1;
  REP(i,n){
    lint t;
    cin >> t;
    ans = lcm(ans,t);
    //dump(ans);
  }
  cout << ans << endl;
  return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}

typedef long long int ll;
typedef pair<ll,ll> P_ll;
struct edge {int to , cost;};
typedef vector<vector<edge>> wgraph; // cost, to

const ll longinf = 1LL<<60 ;
vector<ll> dijkstra(wgraph G,int s){
    priority_queue<P_ll, vector<P_ll>, greater<P_ll>> que;
    vector<ll> dist(G.size(),longinf);

    dist[s]=0;
    que.push({0LL,s});

    while(!que.empty()){
        P_ll p = que.top();que.pop();

        ll v = p.second,d = p.first;
        if(dist[v] < d) continue;
        for(auto e:G[v]){
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                que.push({dist[e.to], e.to});
            }
        }
    }
    return dist;
}


int main(){
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;t--;

    wgraph v1(n),v2(n);  
    REP(i,m){
        int x, y , a, b;
        cin >> x >> y >> a >> b;
        x--;y--;
        v1[x].push_back({y,a});
        v1[y].push_back({x,a});

        v2[x].push_back({y,b});
        v2[y].push_back({x,b});
    }

    vector<ll> dist1 = dijkstra(v1,s);
    vector<ll> dist2 = dijkstra(v2,t);

    vector<ll> ans(n);
    // 都市iで両替する場合の最適解
    REP(i,n) ans[i] = 1e15 - dist1[i] - dist2[i];
    // 最終年は都市iで両替するしかなく、その前はiとi-1というように、後ろから前に最大値を決めていく
    REP(i,n-1) ans[n-i-2] = max(ans[n-i-2], ans[n-i-1]);
    REP(i,n) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 22588
#include<bits/stdc++.h>
using namespace std;
long long num(long long t){
  if(t==1){
    return 0;
  }
  return num(t-1)+t-1;
}
int main(){
  long long n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
  long long ans=0;
  long long cnt=1;
  for(int i=1;i<n;i++){
    if(s[i-1]==s[i]){
      cnt++;
      if(i==n-1){
        ans+=num(cnt);
      }
    }
    if(s[i-1]!=s[i]){
      ans+=num(cnt);
      cnt=1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7296
(n,k),*td=$<.map{|s|s.split.map &:to_i}
td.sort_by!{|t,d|[-d,t]}
tkn=td[0,k]
s=tkn.reduce(0){|m,(t,d)|m+d}
x=tkn.map{|t,d|t}.uniq.size
knd=[]
ds=[]
tkn.map{|t,d|
  ds << [t,d] if knd[t]
  knd[t]=true
}
my=td[k..-1]
s+=x**2
r=s
i=0
loop {
  break if ds.empty?
  while my[i]&&knd[my[i][0]]
    i+=1
  end
  break if !my[i]
  t1,d1=my[i]
  knd[t1]=true
  t2,d2=ds.pop
  x+=1
  s=s+d1-d2+x*2-1
  r=[r,s].max
}
p r


Measured memory_bytes: 17088
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	int h, w;
	std::string s[100];
	std::cin >> h >> w;
	for (int i = 0;i < h;i++) {
		std::cin >> s[i];
	}
	for (int i = 0;i < h;i++) {
		std::cout << s[i] << std::endl;
		std::cout << s[i] << std::endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    string s,t;
    string message = "No";
    cin >> s >> t;
    for(size_t i=0;i<s.size();i++){
        s.insert(s.begin(),*(s.end()-1));
        s.pop_back();
        if(s == t){
            message = "Yes";
            break;
        }
    }
    cout << message << endl;
    return 0;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B, C;
	int maxABC, lack;

	cin >> A >> B >> C;
	
	maxABC = max(A, max(B, C));
	lack = (maxABC - A) + (maxABC - B) + (maxABC - C);

	cout << (lack + 1) / 2 + lack % 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>//
#define ll long long
using namespace std;
int main()
{
    ll i,x,y,turt;
    cin>>x>>y;
    for(i=0; i<=x; i++)
    {
        turt=x-i;
        if(2*i+4*turt==y)
            return cout<<"Yes"<<endl,0;
    }

    cout<<"No"<<endl;
    return 0;
}








Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int a=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        if(a<=0 && 0<=b){ System.out.println("Zero"); }
        else if(0<=a && 0<=b){ System.out.println("Positive"); }
        else { System.out.println((Math.abs(b)-Math.abs(a)+1)%2==0 ? "Positive":"Negative"); }
    }
}

Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"

struct item
{
    int w, v;
};

void solve()
{
    int n, w;
    cin >> n >> w;
    vector<item> arr(n);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i].w >> arr[i].v;
    }
    vector<vector<int>> dp(n + 1, vector<int>(w + 1, 0));
    for (int i = 1; i <= n; i++)
    {
        for (int wt = 0; wt <= w; wt++)
        {
            if ((wt - arr[i-1].w) >= 0)
            {
                dp[i][wt] = max(dp[i][wt], dp[i-1][wt - arr[i-1].w] + arr[i-1].v);
            }
            dp[i][wt] = max(dp[i][wt], dp[i-1][wt]);
        }
    }
    int ans = 0;
    for (int i = 0; i <= w; i++)
    {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 80256
using System;
class Program
{
    static void Main(string[] args)
    {
        int x = int.Parse(Console.ReadLine());
        int min = 400;
        int max = 599;
        for(int rate = 8; rate > 0;rate--)
        {
            if(min <= x && x <= max)
            {
                Console.Write(rate);
                break;
            }
            else
            {
                min += 200;
                max += 200;
            }
        }
    }
}

Measured memory_bytes: 27488
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }

void _main() {
  int N;
  cin >> N;

  int n = N / 111;
  if (N % 111 != 0) n++;

  int ans = n * 111;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int k;
	char s[1010];
	cin>>k;
	cin>>s;
	int n =strlen(s);
	int flag=0;
	for(int i=0;i<n;i++){
		if(i<k){
			cout<<s[i];
		}else{
			flag=1;
			break;
		}
	}
	if(flag){
		cout<<"...";
	}
	cout<<endl;
	
 	return 0;
}

Measured memory_bytes: 3624
use std::io::stdin;

fn main() {
    let result:Vec<i32> = vec![1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692];
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let k = st.trim().parse::<usize>().unwrap();
    println!("{:?}",result[k-1]);
}

Measured memory_bytes: 2096
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 200010;

ll n,m,k,cnt;
ll bas[maxn],a[maxn],b[maxn],arr[maxn],pre[maxn];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	memset(bas,0,sizeof(bas));
	m = 0, cnt = 0;
	n = read(), k=read();
	for(int i=1;i<=n;i++)
	{
		a[i] = read(), b[i] = read(); 
		m = max(m,a[i]);
		bas[a[i]] += b[i];
	}
	
	for(int i=1;i<=m;i++){
		if(bas[i]!=0) arr[++cnt] = i;
	}
	
	for(int i=1;i<=cnt;i++){
		pre[i] = bas[arr[i]];
		pre[i] += pre[i-1];
	}
	
	sort(arr+1,arr+cnt+1);

	for(int i=1;i<=cnt;i++){
		if(pre[i]>=k){
			printf("%d\n",arr[i]);
			break;
		}
	}

//	for(int i=1;i<=cnt;i++){
//		printf("%d ",pre[i]);
//	}printf("\n");
//	for(int i=1;i<=cnt;i++){
//		printf("%d ",bas[arr[i]]);
//	}printf("\n");

	return 0;
}

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

typedef long long ll;

int main(){
    int N; cin >> N;
    ll a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    sort(a,a+N);
    int ans=1;
    ll res=a[0]; 
    for(int i=1;i<N;i++){
        if(2*res>=a[i]){
            ans++;
        }else{
            ans=1;
        }
        res+=a[i];
    }
    cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
    for (int i=0; i<N; i++) cin >> A.at(i);
    for (int i=0; i<N; i++) cin >> B.at(i);
    for (int i=0; i<N-1; i++) cin >> C.at(i);
    int sumB = accumulate(B.begin(), B.end(), 0);
    for (int i=0; i<N-1; i++) {
        if (A.at(i)+1 == A.at(i+1)) sumB += C.at(A.at(i)-1);
    }
    cout << sumB;
}


Measured memory_bytes: 256
n,k=map(int, input().split())
a=list(map(int, input().split()))
cnt=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        if a[i]>a[j]:
            cnt+=1
ans=cnt*k
cnt2=0
aa=sorted(a,reverse=True)
for i in range(len(aa)):
    for j in range(i+1,len(aa)):
        if aa[i]>aa[j]:
            cnt2+=1
ans2=cnt2*((k*(k-1))//2)
print((ans+ans2)%((10**9)+7))

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

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int m = scn.nextInt();
		int[] x = new int[m];
		int[] s = new int[m-1];
		x[0]=scn.nextInt();
		for(int i = 1;i<m;i++) {
			x[i]=scn.nextInt();
		}
		Arrays.sort(x);
		for(int i = 1;i<m;i++) {
			s[i-1] = x[i]-x[i-1];
		}
		Arrays.sort(s);
		int sum = 0;
		for(int i = 0;i<m-n;i++) {
			sum+=s[i];
		}
		System.out.println(sum);
	}
}

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

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

    string a, b, c;
    cin >> a >> b >> c;

    cout << a[0] << b[1] << c[2] << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var dists = Enumerable.Range(0, (int)N)
                .ToDictionary(x => x, y => new List<Path>());
            for (var i = 0; i < N - 1; i++)
            {
                var (a, b, c) = Read3Longs();
                a--; b--; // インデックス変換

                dists[(int)a].Add(new Path { From = a, To = b, Dist = c });
                dists[(int)b].Add(new Path { From = b, To = a, Dist = c });
            }

            var (Q, K) = Read2Longs();
            K--;//インデックス変換
            var distK = new long[N];
            distK[K] = 0;
            var q = new Queue<Path>();
            foreach (var item in dists[(int)K])
            {
                q.Enqueue(item);
            }

            while (q.Count > 0)
            {
                var dq = q.Dequeue();
                distK[dq.To] = distK[dq.From] + dq.Dist;

                // 到達済みのものは除外する
                dists[(int)dq.To].RemoveAll(x => distK[x.To] != 0);

                foreach (var item in dists[(int)dq.To])
                {
                    q.Enqueue(item);
                }
            }

            var sb = new StringBuilder();
            for (var i = 0; i < Q; i++)
            {
                var (x, y) = Read2Longs();
                x--; y--;//インデックス変換
                var d = distK[x] + distK[y];
                sb.AppendLine(d.ToString());
            }

            return sb.ToString().Trim();
        }

        private class Path
        {
            public long From { get; set; }
            public long To { get; set; }
            public long Dist { get; set; }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main(){
  int k, t;  cin >> k >> t;
  vector<int> a(t);
  for(int i=0; i<t; i++)  cin >> a[i];
  sort(a.begin(), a.end());

  int sum = 0, ans = 1e9;
  for(int i=0; i<t; i++){
    sum += a[i];
    ans = min(ans, abs(k-sum-sum));
  }

  cout << max(0, ans - 1) << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main()
{   
  int n, h;
  cin >> n >> h;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
 
  int max_a = *max_element(a.begin(), a.end());
  sort(b.begin(), b.end(), greater<int>());
  ll d = 0;
  int natk = 0;
  rep(i, n) {
    if (d >= h) {
      printf("%d\n", natk);
      return 0;
    }
    if (b[i] <= max_a) break;
    d += b[i];
    ++natk;
  }
  natk += (h - d + max_a - 1) / max_a;
  printf("%d\n", natk);
  return 0;
}

Measured memory_bytes: 4044
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <iomanip>

double euclid(double x1, double y1, double x2, double y2)
{
    double dx = x1 - x2;
    double dy = y1 - y2;
    return sqrt(dx * dx + dy * dy);
}

int main()
{
    double x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    std::cout << std::fixed << std::setprecision(8);
    std::cout << euclid(x1, y1, x2, y2) << std::endl;
    return 0;
}



Measured memory_bytes: 3272
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0200

/* http://www.deqnotes.net/acmicpc/dijkstra/
9 6
1 2 5 0
1 3 4 0
1 4 2 0
2 3 2 0
3 4 3 0
2 6 6 0
3 5 2 0
5 6 4 0
4 5 6 0
1
1 6 0
0 0

*/

#include <cstdio>
#include <climits>
#include <cstring>

#define STATION_MAX 101

//#define dprintf(arg1, ... ) printf( arg1, __VA_ARGS__)
#define dprintf(arg1, ... ) 

/*
typedef struct {
	
} LINE;
*/


int main(void) {

	while(1) {
		int line_cnt, stat_cnt;
		scanf("%d %d\n", &line_cnt, &stat_cnt);
		if ( line_cnt==0 && stat_cnt== 0 ) { break; }
		
		int line_cost[2][STATION_MAX][STATION_MAX];
		memset( line_cost, -1, sizeof(int)*2*STATION_MAX*STATION_MAX );
		
		int a; int b; int fee; int time;
		for( int i=0; i<line_cnt; i++ ) {
			scanf("%d %d %d %d\n", &a, &b, &fee, &time );
			line_cost[0][a][b] = line_cost[0][b][a] = fee;
			line_cost[1][a][b] = line_cost[1][b][a] = time;
		}
		
		int query_cnt;
		scanf("%d\n", &query_cnt );
		
		for( int i=0; i<query_cnt; i++ ) {
			int start, end, type;
			
			scanf("%d %d %d\n", &start, &end, &type );
			
			int stat_cost[STATION_MAX];
			bool stat_flag[STATION_MAX];
			memset( stat_cost, -1, sizeof(int)*STATION_MAX );
			memset( stat_flag, false, sizeof(bool)*STATION_MAX );
			
			stat_cost[start] = 0;
			
			while(1) {
				int minstat = -1;
				int minval=INT_MAX;
				for ( int i=1; i<stat_cnt+1; i++ ) {
					if ( stat_cost[i] == -1 ) { continue; }
					if ( stat_flag[i] == true ) { continue; }
					if ( stat_cost[i] < minval ) { minstat = i; minval = stat_cost[i]; }
				}
				if ( minstat == -1 ) { break; }
				dprintf("minstat: %d stat_cost=%d\n", minstat, stat_cost[minstat]);
				
				stat_flag[minstat] = true;
				
				//check_tonari
				for ( int i=1; i<stat_cnt+1; i++ ) {
				if ( line_cost[type][minstat][i] == -1 ) { continue; }
					if ( stat_cost[i] == -1 ||  stat_cost[i] > stat_cost[minstat] + line_cost[type][minstat][i] ) {
						dprintf( "Refresh stat_cost[%d]:  %d (old: %d)\n", i, stat_cost[minstat] + line_cost[type][minstat][i], stat_cost[i]);
						stat_cost[i] = stat_cost[minstat] + line_cost[type][minstat][i];
					}
				}
			}
			
			printf("%d\n", stat_cost[end]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main(void){
    int n,m;cin>>n>>m;
    combination c(300);
    mint res=c(n+m,2)-n*m;
    cout<<res.x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int INF=1e10;

int main(){
	int n,a,b,ans=0;
	cin >> n;
	rep(i,n){
		cin >> a >> b;
		if(a==b) ans++;
		else{
			if (ans >= 3) break;
			ans = 0;
		}
	}
	if (ans >=3) cout << "Yes"<<endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, a;
  in2(n, k);
  a = n - k;
  vector<vector<ll>> c(2003, vector<ll> (2003, 0));
  rep(i, 2003)
    c[i][0] = c[i][i] = 1;
  rep2(i, 2, 2003){
    rep2(j, 1, i){
      c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
      c[i][j] %= mei;
    }
  }
  rep(i, k){
    out(c[a + 1][i + 1] * c[k - 1][i] % mei);
    memi;
  }
}

Measured memory_bytes: 31744
#include <stdio.h>

int main() 
{
    int m,n,h=0;
    int b,a[105]={0};
    int i,sum=0;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
    {
    	scanf("%d",&a[i]);
    	sum=sum+a[i];
	}
	for(i=0;i<n;i++)
	{
		b=a[i]*m*4;
		if(b>=sum)
		   h++;
	}
	if(h>=m)
	  printf("Yes");
	else
	printf("No");
    return 0;
}














Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)

int main() {
    int n;
    while (cin >> n) {
        map<int, int> cnt;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        vector<int> ans;
        rep(i, n) {
            int l = a[i], r = a[n - i - 1];
            cnt[l]++;
            cnt[r]--;
            if (cnt[l] == 0) cnt.erase(l);
            if (cnt[r] == 0) cnt.erase(r);
            if (cnt.size() == 0) {
                ans.push_back(i);
            }
        }
        rep(i, ans.size()) {
            cout << ans[i] + 1;
            if (i + 1 == ans.size()) {
                cout << endl;
            } else {
                cout << ' ';
            }
        }
    }
}



Measured memory_bytes: 4196
# -*- coding: utf-8 -*-
import math
n = int(input())
T = 1
A = 1
for _ in range(n):
    line = input().split(" ")
    t = int(line[0])
    a = int(line[1])
    c = max((T+t-1)//t, (A+a-1)//a)
    T = c*t
    A = c*a

print(A+T)


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

int main(){
	string S;
	bool exists['z'-'a'+1];
	for(int i='a';i<='z';i++){
		exists[i-'a']=false;
	}

	cin >> S;

	for(const auto& c : S){
		exists[c-'a']=true;
	}
	for(int i='a';i<='z';i++){
		if(!exists[i-'a']){
			cout << ((char)i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}


Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    static final long MOD = 1000000007;
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N = reader.nextInt();
		solver(N);
	}
	
	public static void solver(int N) {
		// write logic
		// DP indexes
		// 0: no0 and no9
		// 1: yes1 and no9
		// 2: no1 and yes9
		// 3: yes1 and yes9
		long[][] dp = new long[N+1][4];
		dp[0][0] = 1;
		for (int i=0; i<N; i++) {
		    dp[i+1][0] = dp[i][0]*8                                        ;
		    dp[i+1][1] = dp[i][0]*1 + dp[i][1]*9                           ;
		    dp[i+1][2] = dp[i][0]*1              + dp[i][2]*9              ;
		    dp[i+1][3] =            + dp[i][1]*1 + dp[i][2]*1 + dp[i][3]*10;
		    for (int j=0; j<4; j++) dp[i+1][j] %= MOD;
		}

		System.out.println(dp[N][3]);
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

Measured memory_bytes: 100364