akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int cost[10][10];
int a[210][210];

int main()
{
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < 10; ++i)
  {
    for (int j = 0; j < 10; ++j)
    {
      cin >> cost[i][j];
    }
  }
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      cin >> a[i][j];
    }
  }

  for (int l = 0; l < 10; ++l)
    for (int k = 0; k < 10; ++k)
    {
      for (int i = 0; i < 10; ++i)
      {
        for (int j = 0; j < 10; ++j)
        {
          cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        }
      }
    }
  ll sum = 0;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      if (a[i][j] >= 0)
        sum += cost[a[i][j]][1];
    }
  }
  cout << sum << endl;

  return 0;
}


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

using namespace std;

#define ll long long

ll ans[3000][3000][4];
ll a[3000][3000];

int main(){
	ll r,c,k;
	cin>>r>>c>>k;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++)
			a[i][j]=0;
	}
	while(k--){
		ll a1,a2,v;
		cin>>a1>>a2>>v;
		a[a1-1][a2-1]=v;
	}
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			if(i==0&&j==0){
				ans[i][j][0]=0;
				ans[i][j][1]=a[i][j];
				ans[i][j][2]=0;
				ans[i][j][3]=0;
				continue;
			}
			if(i==0){
				ans[i][j][0]=ans[i][j-1][0];
				ans[i][j][1]=max(ans[i][j-1][0]+a[i][j],ans[i][j-1][1]);
				ans[i][j][2]=max(ans[i][j-1][1]+a[i][j],ans[i][j-1][2]);
				ans[i][j][3]=max(ans[i][j-1][2]+a[i][j],ans[i][j-1][3]);
				continue;
			}
			if(j==0){
				ll val = max(max(ans[i-1][j][0],ans[i-1][j][1]),max(ans[i-1][j][2],ans[i-1][j][3]));
				ans[i][j][0]=val;
				ans[i][j][1]=val+a[i][j];
				ans[i][j][2]=val+a[i][j];
				ans[i][j][3]=val+a[i][j];
				continue;
			}
			ll val = max(max(ans[i-1][j][0],ans[i-1][j][1]),max(ans[i-1][j][2],ans[i-1][j][3]));
			ans[i][j][0]=ans[i][j-1][0];
			ans[i][j][1]=max(ans[i][j-1][0]+a[i][j],ans[i][j-1][1]);
			ans[i][j][2]=max(ans[i][j-1][1]+a[i][j],ans[i][j-1][2]);
			ans[i][j][3]=max(ans[i][j-1][2]+a[i][j],ans[i][j-1][3]);
			ans[i][j][0]=max(ans[i][j][0],val);
			ans[i][j][1]=max(ans[i][j][1],val+a[i][j]);
			ans[i][j][2]=max(ans[i][j][2],val+a[i][j]);
			ans[i][j][3]=max(ans[i][j][3],val+a[i][j]);
		}
	}
	int i=r,j=c;
	ll answer= max(max(ans[i-1][j-1][0],ans[i-1][j-1][1]),max(ans[i-1][j-1][2],ans[i-1][j-1][3]));
	cout<<answer;
	// for(int k=0;k<4;k++){
	// 	for(int i=0;i<r;i++){
	// 		for(int j=0;j<c;j++)
	// 			cout<<ans[i][j][k]<<" ";
	// 		cout<<endl;
	// 	}
	// 	cout<<endl;
	// }
	return 0;
}


Measured memory_bytes: 355024
# 解説コード
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
  for c in '753':
    ret += dfs(s + c)
  return ret

print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

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

typedef long long ll;

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define gcd(a, b) __gcd(a, b)
#define min3(a, b, c) min(c, min(a, b))
#define max3(a, b, c) max(c, max(a, b))

#define        MX        100005

ll w[MX], v[MX], dp[105][MX];
ll n, W;

ll solve(ll i, ll wr)
{
    if(i == n) return 0;
    if(dp[i][wr] != -1) return dp[i][wr];

    if(wr-w[i] >= 0) dp[i][wr] = max(dp[i][wr], solve(i+1, wr-w[i]) + v[i]);
    dp[i][wr] = max(dp[i][wr], solve(i+1, wr));

    return dp[i][wr];
}

int main()
{
    optimize
    cin>>n>>W;
    
    for(int i = 0; i  < n; i++){
        cin>>w[i]>>v[i];
    }
    
    RESET(dp, -1);
    cout<<solve(0, W)<<endl;

}


Measured memory_bytes: 85680
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll dp[55][55][5000];

signed main(){
	//cout << fixed << setprecision(10);
	int n; cin>>n;
	string s; cin>>s;
	 ll ans=0;
	rep(i,0,1000){
		string t=to_string(i);
		if(t.size()==1)t.insert(t.begin()+0,'0');
		if(t.size()==2)t.insert(t.begin()+0,'0');
		//cout<<t<<endl;
		ll cnt=0;
		rep(j,0,n){
			if(cnt==3)break;
			if(s[j]==t[cnt])cnt++;
		}
		if(cnt==3)ans++;
	}
	cout<<ans<<endl;
	 
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;

int main(){
  int s;
  string ans;
  cin >> s;
  int s1=0,s2=0;
  s1 = s%100;s/=100;
  s2 = s;
  if(s2>0&&s2 <= 12){
    if(s1<=12 && s1 > 0) ans = "AMBIGUOUS";
    else ans = "MMYY";
  }else if(s1 > 0 && s1 <= 12){
    if(s2 > 0 && s2 <= 12) ans = "AMBIGUOUS";
    else ans = "YYMM";
  }else{
    ans = "NA";
  }
  
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        llin(k);
        vllin(v,n);
        ll t=0;
        ll u=0;
        ll p=0;
        t=min(n,k);
        vvvll l(t+1,vvll (t+1,vll (0,0)));
        FOR(i,1,t){
                FOR(j,0,i){
                        p=0;
                        FOR(g,0,j-1){
                                l[i][j].pb(v[g]);
                        }
                        FOR(g,0,i-1-j){
                                l[i][j].pb(v[n-1-g]);
                        }
                        SORT(l[i][j]);
                        FOR(g,0,i-1){
                                p+=l[i][j][g];
                        }
                        FOR(g,0,k-1-i){
                                if(g<i&&l[i][j][g]<0) p-=l[i][j][g];
                        }
                        u=max(p,u);
                }
        }
        sal(u)
}


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

vector<int> dp;

int fib(int n){
    if(dp[n]!=-1){
        return dp[n];
    }else{
        dp[n]=fib(n-1)+fib(n-2);
        return dp[n];
    }
}

int main(){
    int n; cin >> n;
    dp.assign(n+1,-1);
    dp[0]=1;
    dp[1]=1;
    cout << fib(n) << endl;
}
//g++ -o proa.exe proa.cpp

//VSCなら./test
//Atomならtest.exe



Measured memory_bytes: 3108
def modpow(a,n,mod):
    res=1
    a=a%mod
    while(n>0):
        if(n&1):
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res

def com(n,k,mod):
    res=1
    tmp=1
    for i in range(1,k+1):
        res=res*(n-i+1)%mod
        tmp=tmp*i%mod
    a=modpow(tmp,1000000005,mod)
    return res*a%mod

MOD=1000000007
n,a,b=map(int,input().split())
ans=modpow(2,n,MOD)-1
t=com(n,a,MOD)
m=com(n,b,MOD)
ans=ans-t
if(ans<0):
    ans+=MOD
ans=ans-m
if(ans<0):
    ans+=MOD
print(ans)

Measured memory_bytes: 3064
import itertools
#1~Mと仕切りN枚を適宜並べ、「左にあるかずの個数」を考える。
#1~N+Mの中からN個選ぶ
N,M,Q = [int(hoge) for hoge in input().split()]
L = list(itertools.combinations(range(1,M+N),N))
abcd = [[int(hoge) for hoge in input().split()] for q in range(Q)]

curmax = 0
for l in L:
    suretu = []
    score = 0
    for n,k in enumerate(l):#数列を実際に生成
        #(1,2,5,6,7,9)とか出てくるので…
        suretu.append(k-n)
    for a,b,c,d in abcd:
        if suretu[b-1] - suretu[a-1] == c:
            score += d
    curmax = max(curmax,score)
print(curmax)

Measured memory_bytes: 84584
#include<bits/stdc++.h>
using namespace std;
int main(){
  double L[4] = {0.25, 0.5, 1, 2};
  vector<pair<double,pair<int,double>>> V(4);
  for(int i = 0; i < 4; ++i){
    int x; cin >> x;
    V[i] = {x/L[i],{x, L[i]}};
  }
  sort(V.begin(), V.end());  
  double N; cin >> N;
  int idx = 0;
  long long ans = 0;
  while(N > 0){
    if(V[idx].second.second <= N){
      long long x = N / V[idx].second.second;
      N -= x * V[idx].second.second;
      ans += x * V[idx].second.first;
    }
    idx++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
string s;
long long cnt,s_len;
int main(){
    cin>>s;
    s_len=s.size();
    int k=s_len-1;
    for(int i=s_len-1;i>=0;i--){
        if(s[i]=='B'){
            cnt+=(k-i);
            k--;
        }
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 640
s = input()
ans = True

for i in range(len(s)):
    c = s[i]
    if i % 2 != 0:
        if c != 'L' and c != 'U' and c != 'D':
            ans = False
    else:
        if c != 'R' and c != 'U' and c != 'D':
            ans = False

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

Measured memory_bytes: 38480
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
typedef long long ll;
int n, m, k;

char ch[maxn];
int main()
{
    scanf("%s", ch);
    n = strlen(ch);
    if(n % 2 == 1){
        printf("No\n");
    }
    else{
        for(int i=0;i<n;i++){
            if(i % 2 == 0 && ch[i] == 'h');
            else if(i % 2 == 1 && ch[i] == 'i');
            else{
                printf("No\n");
                return 0;
            }
        }
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdlib>
#define ll long long int
using namespace std;
int main()
{
    ll n,c=0,c1=0,c2=0,c3=0,i;
    cin>>n;
    while(n--)
    {
    	string s;
    	cin>>s;
    		if(s[0]=='A')
    			c++;
    		else if(s[0]=='W')
    			c1++;
    		else if(s[0]=='T')
    			c2++;
    		else
    			c3++;
	}
	cout<<"AC"<<" "<<"x"<<" "<<c<<endl;
	cout<<"WA"<<" "<<"x"<<" "<<c1<<endl;
	cout<<"TLE"<<" "<<"x"<<" "<<c2<<endl;
	cout<<"RE"<<" "<<"x"<<" "<<c3<<endl;
}

Measured memory_bytes: 3620
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N, M;
    cin >> N >> M;
    ll S[5], C[5];
    rep(i, M)cin >> S[i] >> C[i];
    rep(i, 1000){
        V v;
        for(int j = i; j; j /= 10)v.push_back(j % 10);
        if(v.size() == 0)v.push_back(0);
        if(v.size() != N)continue;
        reverse(v.begin(), v.end());
        int f = 1;
        rep(j, M)if(v[S[j] - 1] != C[j])f = 0;
        if(f){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] ar){
    Scanner sc=new Scanner(System.in);
    int A=sc.nextInt();
    int B=sc.nextInt();
    int C=sc.nextInt();
    
    int p=(int)B/A;
    int ans;
    
    if(p>=C){
      ans=C;
    }else{
      ans=p;
    }
    System.out.println(ans);
  }
}

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    vector<ll> s;
    vector<ll> p;

    void input() {
        s.resize(60);
        p.resize(60);
        s[0] = 1ll;
        p[0] = 1ll;
        for (int i = 1; i <= 50; ++i) {
            s[i] = 3 + 2 * s[i - 1];
            p[i] = 1 + 2 * p[i - 1];
        }
    }

    ll f(ll X, int L) {
        if (L == 0) return 1;
        if (X == 1) return 0;
        if (2 * X < s[L] + 1) return f(X - 1, L - 1);
        if (2 * X == s[L] + 1) return p[L - 1] + 1;
        if (X < s[L]) return p[L - 1] + 1 + f(X - (2 + s[L - 1]), L - 1);
        if (X == s[L]) return p[L];
    }

    void solve() {
        input();
        int N;
        ll X;
        cin >> N >> X;

        ll ans = f(X, N);
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
import math, numpy
a, b, h, m = map(int,input().split())
x1 = a * math.sin(math.radians((h * 360 / 12) + (m / 2)))
y1 = a * math.cos(math.radians((h * 360 / 12) + (m / 2)))
x2 = b * math.sin(math.radians(m * 6))
y2 = b * math.cos(math.radians(m * 6))
hh = numpy.array([x1, y1])
mm = numpy.array([x2, y2])
u = mm - hh
print(numpy.linalg.norm(u))

Measured memory_bytes: 27268
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	char ar[100001];
	cin>>ar;
	ll i,j,k,l,n=strlen(ar);

	ll s1=0,s2=0;
	k=0;
	for(i=0;i<n;i++){
		if(ar[i]-'0'!=k){
			s1++;
		}
		if(k==1) k=0;
		else k=1;
	}

	k=1;
	for(i=0;i<n;i++){
		if(ar[i]-'0'!=k){
			s2++;
		}
		if(k==1) k=0;
		else k=1;
	}
	ll mn=min(s1,s2);
	cout<<mn;
	return 0;
}


Measured memory_bytes: 384
from collections import deque
import numpy as np


def bfs(y, x, H, W, S):
    dirs = [(-1, 0), (0, -1), (1, 0), (0, 1)]
    depth = np.full((H+2, W+2), -1, dtype=np.int)
    q = deque()
    q.append((y, x))
    depth[y][x] = 0
    max_depth = 0
    while q:
        y, x = q.popleft()
        max_depth = max(max_depth, depth[y][x])
        for dy, dx in dirs:
            ny, nx = y + dy, x + dx
            if depth[ny][nx] == -1 and S[ny][nx] == '.':
                depth[ny][nx] = depth[y][x] + 1
                q.append((ny, nx))
    return max_depth


def solve():
    H, W = map(int, input().split())
    S = list()
    S.append(['#'] * (W+2))
    for _ in range(H):
        buf = input()
        S.append(list('#' + buf + '#'))
    S.append(['#'] * (W+2))

    dist_max = 0
    for y in range(H):
        for x in range(W):
            if S[y+1][x+1] == '.':
                d = bfs(y+1, x+1, H, W, S)
                dist_max = max(d, dist_max)
    print(dist_max)


if __name__ == '__main__':
    solve()


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

int main(){
    string S;
    cin >> S;
    int res1=0; int res2=0;
    for (int i=0; i < S.length(); i++){
        if(i%2 == 0){
            if(S[i] == '1') res1++;
            else res2++;
        }
        else{
            if(S[i] == '0')res1++;
            else res2++;
        }
    }
    int res = min(res1,res2);
    cout << res << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	ll x;
	cin >> x;
	n = x / 100;
	rep(i, n + 1) {
		if (100 * i <= x && x <= 105 * i) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
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; }

int main(){
    ll n,a,b; cin >> n >> a >> b;
    ll q = n / (a+b);
    ll r = n % (a+b);
    cout << q*a + min(a,r) << endl;
}


Measured memory_bytes: 256
# D - Flipping Signs

N = int(input())
A = list(map(int, input().split()))

n_minus = len([x for x in A if x < 0])

if n_minus % 2 == 0:
    print(sum([abs(x) for x in A]))
else:
    print(sum([abs(x) for x in A]) - 2*abs(min(A, key=abs)))

Measured memory_bytes: 14284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    int x[100], y[100], h[100], num, flag = 0, max_h = -1, min_x = 101, min_y = 101;
    for(int i=0;i<N;i++)
        cin >> x[i] >> y[i] >> h[i];
    
    for(int i=0;i<N;i++){
        if(h[i] > max_h)
            max_h = h[i];
        if(x[i] < min_x)
            min_x = x[i];
        if(y[i] < min_y)
            min_y = y[i];
    }
    
    for(int H = max_h;;H++){
        for(int Cy=0;Cy<=100;Cy++){
            for(int Cx = min_x;Cx<=100;Cx++){
                flag = 0;
                for(int i=0;i<N;i++){
                    num = H - abs(x[i] - Cx) - abs(y[i] - Cy);
                    if(max(num, 0) != h[i])
                        flag = 1;
                }
                if(flag == 0){
                    cout << Cx << ' ' << Cy << ' ' << H << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <string.h>

int main()
{
	int N;
	scanf("%d",&N);
	char s[101];
	scanf("%s",&s);
	getchar();
	int length=strlen(s);
	s[N]='\0';
	if(N>=length){
		printf("%s\n",s);
	}else{
		printf("%s...\n",s);
	}
}

Measured memory_bytes: 1728
import sys

l = []
for input in sys.stdin:
    l.append(int(input))

l = sorted(l)
d = {}
for i in range(0,len(l)):
    d[l[i]] = l.count(l[i])
max = 0
for key,value in d.items():
    if(value > max):
        max = value
for key,value in d.items():
    if(value == max):
        print key


Measured memory_bytes: 4652
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    ll n, a,b;
    cin >> n >> a >> b;

    ll mx = min(a,b);
    ll mi = (n < a + b) ? a + b - n : 0;

    cout << mx << " " << mi << endl;


    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

long long Combi::nPk_modp(long long n, long long k, long long p)
{
  ll ans = 1;
  for(long long i = k; i <= n; i++)
  {
    ans = (ans * i) % p;
  }

  return ans;
};


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

N = int(input())
paths = {}
for i in range(N-1):
    u, v, w = map(int,input().split())
    paths.setdefault(u, {})
    paths[u][v] = w
    paths.setdefault(v, {})
    paths[v][u] = w

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in zip(paths[now].keys(), paths[now].values()):
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1])


Measured memory_bytes: 107476
#include <bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 200007
#define MOD 1000000007
#define MODL 1000000007LL
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

// Trace dinâmico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

// Debugador de recursão
int recNum = 0;
void prTabs() { for (int ii = 0; ii < recNum; ++ii) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}

int MD(int x) {
	if(x < 0) return x+MOD;
	if(x >= MOD) return x-MOD;
	return x;
}

ll MDL(ll x) {
	return (x%MODL+MODL)%MODL;
}

ll modpow(ll a, ll b, ll m) {
	if (!b) return 1LL;
	if (b&1LL) return a*modpow(a, b-1, m)%m;
	ll r = modpow(a, b>>1, m);
	return r*r%m;
}

//m prime
ll invmod(ll a , ll m) {
	return modpow(a, m-2, m);
}

ll li[MAX];
ll n, t, k, a, b, c;
int main(){
	sc("%lld %lld", &n, &k);
	for(int i = 0; i < n; i++) {
		sc("%lld", li+i);
	}
	ll l = 1, r = 1000000000LL;
	ll re = r;
	while(l <= r) {
		ll m = (l+r)/2LL;
		ll cnt = 0LL;
		for(int i = 0; i < n; i++) {
			ll p = (li[i]/m) + ((li[i]%m) ? 0LL : -1LL);
			cnt += p;
		}
		if (cnt <= k) {
			re = m;
			r = m-1LL;
		} else {
			l = m+1LL;
		}
	}
	pr("%lld\n", re);
 	return 0;
}


Measured memory_bytes: 5148
s=input()
a=0
find_a=0
z=len(s)-1
find_z=0
while find_a==0 or find_z==0:
    if find_a==0:
        if s[a]=="A":
            find_a=1
        else:
            a+=1
    if find_z==0:
        if s[z]=="Z":
            find_z=1
        else:
            z-=1
print(z-a+1)

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int x,t;
    cin>>x>>t;
    if(x-t<0)cout<<0<<endl;
    else cout<<x-t<<endl;

    return 0;
}


Measured memory_bytes: 3616
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pii;
typedef tuple<ll,ll,ll> t3;

using namespace std;


int main() {
    map<ll,ll> nn;
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        ll v;
        cin >> v;
        nn[v]++;
    }
    int m;
    cin >> m;
    map<ll, ll> mm;
    for(int i = 0;i < m;i++)
    {
        ll v;
        cin >> v;
        mm[v]++;
    }
    for(auto e : mm)
    {
        auto ee = nn[e.first];
        if(ee < e.second)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 25216
N = gets.to_i
array = gets.split.map(&:to_i)
Q = gets.to_i
array_m = gets.split.map(&:to_i)

def array.can_make_number?(target_number, i = 0)
  return true if target_number == 0
  return false if i >= N
  result = self.can_make_number?(target_number, i + 1) || self.can_make_number?(target_number - self[i], i + 1)
  return result
end

array_m.each do |target_number|
  if array.can_make_number?(target_number)
    puts 'yes'
  else
    puts 'no'
  end
end



Measured memory_bytes: 6876
#include<stdio.h>

main()
{
    int input1[3000] = {};
    int input2[3000] = {};
    int i = 0;

    while(1)
    {
        scanf("%d %d", &input1[i], &input2[i]);
        if(input1[i] == 0 && input2[i] == 0) break;
        i++;
    }

    i = 0;
    while(1)
    {
        if(input1[i] == 0 && input2[i] == 0) break;

        if(input1[i] < input2[i])
        {
            printf("%d %d\n", input1[i], input2[i]);
        }
        else
        {
            printf("%d %d\n", input2[i], input1[i]);
        }
        
        i++;
    }
}


Measured memory_bytes: 2060
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      return search(x+1)
    elif x < i**2:
      break
    
  return x

main()

Measured memory_bytes: 92148
//
// Created by user on 3/9/2020.
//
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

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

    for (int i = 1; i <= 10000; ++i) {
        //cerr << i << " " << (int)(i * 0.08) << " " << (int)(i * 0.1) << endl;
        if ( (int)(i * 0.08) == a and (int)(i * 0.1) == b) {
            cout << i;
            return 0;
        }
    }
    cout << -1;

}

Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  char x, y;
  cin >> x >> y;

  if (x < y) {
    cout << "<" << endl;
  } else if (x == y) {
    cout << "=" << endl;
  } else {
    cout << ">" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
 

int main(){
    int x; cin >> x;
    int fivh=0; int fiv=0; 
    while(x>=500){
        fivh++;
        x-=500;
    }
    while(x>=5){
        fiv++;
        x-=5;
    }
    ll ans;
    ans=(fivh*1000)+fiv*5;
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int x,y;
	cin >> x >> y; 
	if (x < y)
		cout << "a < b" << endl;
	else if (x > y)
		cout << "a > b" << endl;
	else if (x == y)
	    cout << "a == b" << endl;
	return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>

constexpr int max(int a, int b) {
  return (a>b)?a:b;
}

int main(int argc, char** argv) {
  int H, W, N;
  std::cin >> H >> W >> N;
  int max_HW = max(H, W);
  if (N % max_HW) std::cout << (N/max_HW + 1) << '\n';
  else std::cout << (N/max_HW) << '\n';
}


Measured memory_bytes: 888
import java.util.Scanner;

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

        String S = sc.next();
        sc.close();

        String firstString = S.substring(0, 2);
        String lastString = S.substring(2, 4);

        String result = "NA";
        int count = 0;
        if (isYY(firstString)) {
            if (isMM(lastString)) {
                result = "YYMM";
                count++;
            }
        }
        if (isMM(firstString)) {
            if (isYY(lastString)) {
                result = "MMYY";
                count++;
            }
        }
        if (count == 2) {
            result = "AMBIGUOUS";
        }
        System.out.println(result);
    }
    public static boolean isYY(String string) {

        boolean flag = false;
        if (string.matches("[0-9]{2}")) {
            flag = true;
        }
        return flag;
    }
    public static boolean isMM(String string) {

        boolean flag = false;
        if (string.matches("0[1-9]{1}") || string.matches("1[0-2]{1}")) {
            flag = true;
        }
        return flag;
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  if((N / 100 % 10 == N / 10 % 10) && ((N / 100 % 10  == N / 1000) || (N / 100 % 10 == N % 10))) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main()
{
    ll N; cin >> N;
    double tmp = sqrt(N);
    int l = (int)tmp;
    cout << l * l << endl;

}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 2e4 + 10;

struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(20);
  }
}IO;

int32_t main(){
 int a[3][3];
 bool visited[3][3];
 memset(visited, false, sizeof visited);
 for (int i = 0; i < 3; i++)
  for (int j = 0; j < 3; j++)
    cin >> a[i][j];
 int n; cin >> n;
 while (n--){
  int b; cin >> b;
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      if (a[i][j] == b)
        visited[i][j] = 1;
    }
  }
 }
 for (int i = 0; i < 3; i++){
  if (visited[0][i] && visited[1][i] && visited[2][i]){
    cout << "Yes" << endl;
    return 0;
  }
  if (visited[i][0] && visited[i][1] && visited[i][2]){
    cout << "Yes" << endl;
    return 0;
  }
 }
 if (visited[1][1] && visited[2][2] && visited[0][0]){
  cout << "Yes" << endl;
  return 0;
 }
 if (visited[0][2] && visited[1][1] && visited[2][0]){
  cout << "Yes" << endl;
  return 0;
 }
 cout << "No" << endl;

}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int count = 0;
  int pos, ans;
  for(int i = 0; i < N; ++i) {
    if(S[i] == '.') count++;
  }
  pos = count;
  ans = pos;
  for(int i = 0; i < N; ++i) {
    if(S[i] == '.') pos--;
    else pos++;
    ans = min(ans, pos);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import sys
import numpy as np

N=int(input())

X=np.array(list(map(int,input().split())))
temp=X
temp=np.sort(temp,kind="quicksort")
med=temp[int(N/2)]
for i in range(N):
	if X[i]<med:
		print(med)
	else:
		print(temp[int(N/2)-1])


Measured memory_bytes: 34136
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using  namespace std;
#define ll long long
#define sc second
#define fr first
#define mp make_pair
const int N = 2e5 + 10, OO = 1e9 + 5000,MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	int from = 1;
	int turn = 1;
	int ans = 0;
	while (true) {
		int to = from * 10 - 1;
		if (turn % 2 == 1) {
			ans += min(to, n) - from + 1;
		}
		++turn;
		if (to >= n) break;
		from = to + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#define SORT(v) sort(v.begin(), v.end())
#include "iostream"
#include "map"
#include "vector"
#include <stack>
#include "cstdlib"
#include <algorithm>
#include <cstdarg>
// #include "ane.cpp"
 
#define INF (int)1e9
#define NMAX 200
#define MMAX 200
#define MOD 100000
using namespace std;
 
// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> P;
 
int N,M,dp[NMAX][MMAX] = {};
string s;
 
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};
 
int ans = 0;
 
void solve(){
    // 解答アルゴリズム
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == ',')
        {
            s[i] = ' ';
        }
    }
}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    cout << s << endl;
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    ios::sync_with_stdio(false);
 
    Fill(dp, -1);
 
    cin >> s;
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();
 
    return 0;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;

	ll power = 1;
	REP(i, n){
		power *= (i + 1);
		power %= 1000000007;
	}

	cout << power << endl;
}


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

using namespace std;
using ll = long long;
constexpr int NMAX = 3010;
constexpr ll MOD = 998244353;

int mgaParaan[NMAX][NMAX];
ll pow2[NMAX];

int main() {
	pow2[0] = 1;
	for (int i = 1; i < NMAX; ++i) pow2[i] = (pow2[i-1] * 2) % MOD;
	int n, s; scanf("%d %d", &n, &s);
	vector<int> arr(n);
	for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
	mgaParaan[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int sum = 0; sum <= s; ++sum) {
			mgaParaan[i][sum] = (2LL * mgaParaan[i-1][sum] % MOD + (sum >= arr[i-1] ? mgaParaan[i-1][sum - arr[i-1]] : 0)) % MOD;
//			printf("%d %d = %d\n", i, sum, mgaParaan[i][sum]);
		}
	}
	ll ans = 0;
	for (int sz = 1; sz <= n; ++sz) {
//		printf("%lld arrays of size %d\n", mgaParaan[sz][s], sz);
		ans = (ans + mgaParaan[sz][s] * pow2[n - sz] % MOD) % MOD;
	}
	printf("%d\n", mgaParaan[n][s]);
	return 0;
}


Measured memory_bytes: 39104
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  if(A+K-1<B-K+1){
    for(int i = 0; i < K; i++){
      printf("%d\n",A+i);
    }
    for(int i = B-K+1; i <= B ; i++){
      printf("%d\n",i);
    }
  }else{
    for(int i = A; i <= B; i++){
      printf("%d\n",i);
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, W; cin >> N >> W;
	int wmax = 0;
	int wmin = 0;
	long long int w[105], v[105];
	for(int i=0;i<N;i++){
		cin >> w[i] >> v[i];
	}
	long long int dp[102][100002];
	for(int i=0;i<N;i++){
		for(int j=1;j<=W;j++){
			if(j<w[i]){
				dp[i+1][j] = dp[i][j];
			}else{
				dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
			}
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 79104
N = int(input())
Bs = [0] * 120

for i in range(N):
  b, f, r, v = map(int, input().split())
  if b == 1:
    Bs[0 + 10 * (f-1) + (r-1)] += v
  elif b == 2:
    Bs[30 + 10 * (f-1) + (r-1)] += v
  elif b == 3:
    Bs[60 + 10 * (f-1) + (r-1)] += v
  elif b == 4:
    Bs[90 + 10 * (f-1) + (r-1)] += v

for i in range(12):
  for j in range(10):
    print(' {}'.format(Bs[i * 10 + j]), end = '')
    if (j+1) % 10 == 0:
      print()
  if (i+1) % 3 == 0 and (i+1) != 12:
    print('#' * 20)


Measured memory_bytes: 5620
// AOJ ALDS1_2_B Selection Sort
// 2018.4.27 bal4u
 
#include <stdio.h>
 
int selection_sort(int n, int *a)
{
    int i, j, minj, x;
int ans = 0;
 
    for (i = 0; i < n; i++) {
        minj = i;
        for (j = i; j < n; j++) {
            if (a[j] < a[minj]) minj = j;
        }
        if (i != minj) {
            x = a[i], a[i] = a[minj], a[minj] = x;
ans++;
        }
    }
return ans;
}
 
//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0, c = getchar_unlocked();
    do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
    return n;
}
 
int a[102];
 
int main()
{
    int N, i, k;
 
    N = in();
    for (i = 0; i < N; i++) a[i] = in();
    k = selection_sort(N, a);
    printf("%d", a[0]);
    for (i = 1; i < N; i++) printf(" %d", a[i]);
    putchar('\n');
    printf("%d\n", k);
    return 0;
}


Measured memory_bytes: 2040
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<iterator>
#include<queue>
#include<set>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

class Graph{
    public:
    typedef struct Edge{
        ll from, to, cost;
        Edge(ll f, ll t, ll c): from(f),to(t),cost(c){}
    } Edge;

    bool isDirected;
    ll INF = 1LL << 62;
    ll v; // 頂点数
    std::vector<Edge> edges;  // 辺のリスト
    std::vector<std::vector<std::pair<ll,ll>>> list;  // 隣接リスト
    //std::vector<std::vector<ll>> matrix; // 隣接行列

    Graph() : isDirected(false){ init(0); }
    Graph(ll n, bool isDirected=false) : isDirected(isDirected) { init(n); }
    void init(ll n){
        v=n;
        edges.clear();
        list.assign(n, std::vector<std::pair<ll,ll>>());
        //matrix.assign(n, std::vector<ll>(n, INF));
    }
    void connect(ll from, ll to){
        con(from, to, 1);
        if(!isDirected) con(to, from, 1);
    }
    void connect(ll from, ll to, ll cost){
        con(from, to, cost);
        if(!isDirected) con(to, from, cost);
    }
    void con(ll from, ll to, ll cost){
        edges.push_back(Edge(from,to,cost));
        list[from].push_back(std::make_pair(to, cost));
        //matrix[from][to] = cost;
    }
};

struct Diameter{
    //public:
    ll ans = 0;
    Graph G;
    ll rec(ll v, ll parent){
        std::vector<ll> children;
        for(auto e : G.list[v]){
            if(e.first == parent) continue;
            children.push_back(rec(e.first, v) + e.second);
        }
        sort(children.begin(), children.end(), std::greater<ll>());
        if(children.size()==0)return 0;
        else if(children.size()==1){ if(ans < children[0]) ans = children[0]; }
        else { if(ans < children[0]+children[1]) ans = children[0]+children[1]; }
        return children[0];
    }
    ll operator()(Graph G){ this->G=G; rec(0, -1); return ans; }
} Diameter;

int main(){
    ll n,s,t,w;
    cin >> n;
    Graph G(n, false);
    REP(i,n-1){
        cin >> s >> t >> w;
        G.connect(s,t,w);
    }
    cout << Diameter(G) << endl;
}


Measured memory_bytes: 45436
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    System.out.println(calcLCM(a, b));
  }

  private static long calcLCM(int a, int b) {
    long maxValue = Math.max(a, b);
    long minValue = Math.min(a, b);

    long val = maxValue * minValue;
    if (minValue == 0) {
      return (int) maxValue;
    }

    long c;
    while( (c = maxValue % minValue) != 0 ) {
      maxValue = minValue;
      minValue = c;
    }

    return (val / minValue);
  }
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main(){

  //変数の準備
  int r, g, b;
  
  //入力
  cin >> r >> g >> b;
  
  //４の倍数かの処理
  if( (r*100 + g*10 + b)%4 == 0 ) cout << "YES" << endl;
  else  cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n=0;
    string s,t="CODEFESTIVAL2016";
    cin>>s;
for(int i=0;i<t.size();i++){
    if(s[i]!=t[i]) n+=1;
}
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    long long a,b,k;
    cin>> a >> b >> k;
    if(k<= a){
        a -= k;
    }
	else{
        b= b-(k-a);
        b = max(0ll,b);
        a = 0;
    }
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> L(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
           ans += lower_bound(L.begin(), L.end(), L[i]+L[j]) - L.begin()-j-1; 
        }
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
n, w = map(int, input().split())

weights = [0]*n
values = [0]*n

for i in range(n):
    weights[i], values[i] = map(int, input().split())

dp = [[0 for _ in range(w+1)] for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(1, w+1):
        if j < weights[i-1]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], values[i-1]+dp[i-1][j-weights[i-1]])

print(dp[-1][-1])


Measured memory_bytes: 172448