akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int I = 0;
	int cnt = 0;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		I = i;
		while (I != 0) {
			cnt += I % 10;
			I /= 10;
		}
		if (A <= cnt && cnt <= B) {
			ans += i;
		}
		cnt = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool chk(string s,int st,int n)
{
  int i;
  int f=0;
  for(i=st;i<n;i++)
  {
    if(s[i]!=s[n-i-1])
    { f=1; break;}
  }
  if(f)
    return false;
  return true;
}

int main()
{	
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin>>s;
  int n=s.length();
  int k=(n-1)/2;
  int tr=((n+3)/2)-1;
  if(chk(s,0,n) and chk(s,0,k) and chk(s,tr,n))
    	cout<<"Yes\n";
  else
  cout<<"No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  ll L, R; cin >> L >> R;

  R = min(R,L+4038);
  ll ans = inf;
  for(ll i=L; i<=R-1; i++) {
    for(ll j=i+1; j<=R; j++) {
      ans = min(ans, (i*j)%2019);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, D, A = gets.split.map(&:to_i)
pairs = Array.new(N)
N.times do |i|
  pairs[i] = gets.split.map(&:to_i)
end
pairs = pairs.sort_by{|x| x[0] }

result = 0
damage_list = []
damage = 0
AF = A.to_f
while(pair =  pairs.shift) do
  x = pair[0]
  while damage_list.size > 0
    break if damage_list[0][0] >= x
    damage -= damage_list[0][1]
    damage_list.shift
  end
  next if damage > pair[1]
  num = ((pair[1] - damage) / AF).ceil
  result += num
  dd = num * A
  damage = damage + dd
  to = x + ( 2 * D )
  damage_list.push([to, dd])
end

puts result

Measured memory_bytes: 22520
#include <stdio.h>

int main(void){
  int n, i;
  int count, min;
  scanf("%d", &n);
  
  int arr[n];
  
  for(i=0; i<n; i++){
    scanf("%d", &arr[i]);
  }
  
  min=n;
  count=0;
  for(i=0; i<n; i++){
      if(arr[i] <= min){
          min = arr[i];
          count++;
      }
  }
  
  printf("%d", count);
  
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    string a,b;
    cin>>a>>b;
    if(a>b){
        cout<<">"<<endl;
    }else if(a==b){
        cout<<"="<<endl;
    }else{
        cout<<"<"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
import sys
import re
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = arr_data[0][0]
b = arr_data[0][1]
s = arr_data[1][0]

#pattern="^[0-9]{3}-[0-9]{4}$"

pattern="^[0-9]{" + a + "}-[0-9]{" + b + "}$"

#print(pattern)

if(re.search(pattern,s)):
    
    print("Yes")

else:
    
    print("No")


Measured memory_bytes: 3188
//https://atcoder.jp/contests/agc018/tasks/agc018_b
#include<bits/stdc++.h>
using namespace std;
int n,m,ans,mark[305],cnt[305],g[305][305];
//贪心，每次选择人数最多的项目去掉，记录最大值
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++)
          scanf("%d",&g[i][j]);
    }
    ans=n+1;
    for(int i=1; i<=m; i++){
        memset(cnt,0,sizeof(cnt));
        for(int j=1; j<=n; j++){
            int k=1; //选择未标记的最大爱好项目
            while(mark[g[j][k]]==1) k++;
            cnt[g[j][k]]++;
        }
        int mx=0;
        for(int j=1; j<=m; j++)
          if(cnt[j]>cnt[mx]) mx=j;
        ans=min(ans,cnt[mx]);
        mark[mx]=1;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin>>N;
    
    int A[N],B[N];
    long long sum_A=0,sum_B=0;
    int i;
    
    for(i=0;i<N;i++){
        cin>>A[i];
        sum_A+=A[i];
    }
    for(i=0;i<N;i++){
        cin>>B[i];
        sum_B+=B[i];
    }
    
    if(sum_B>sum_A){
        cout<<"-1"<<endl;
        return 0;
    }

    vector<int> gap(N);
    for(i=0;i<N;i++){
        gap[i]=A[i]-B[i];
    }
    
    sort(gap.begin(),gap.end());
    
    int count=0;
    long long sum=0;
    for(i=0;i<N;i++){
        if(gap[i]<0){
            sum+=gap[i];
            count++;
        }
    }
    
    if(sum==0){
        cout<<"0"<<endl;
        return 0;
    }
    
    for(i=N-1;i>=0;i--){
        sum+=gap[i];
        count++;
        if(sum>=0)break;
    }
    
    
    cout<<count<<endl;

}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline

X, Y = map(int, input().split())

ans = 0
if X == 1:
    ans += 300000
if X == 2:
    ans += 200000
if X == 3:
    ans += 100000
if Y == 1:
    ans += 300000
if Y == 2:
    ans += 200000
if Y == 3:
    ans += 100000
if X == 1 and Y == 1:
    ans += 400000
print(ans)

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int A, P;
    cin >> A >> P;
    cout << (3*A+P)/2 << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long

signed main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int count = 0;
  int count2 = 0;
  for (int i = 1; i <= n; i++) {
    if (i % k == 0) count++;
    else if (k % 2 == 0 && i % k == k / 2) count2++;
  }
  ans = count * count * count + count2 * count2 * count2;
  cout << ans << endl;
  return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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 ll;

const long long INF = 1LL << 60;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int diff_y = y1 - y2;
    int diff_x = x1 - x2;
    printf("%d %d %d %d\n", x2 + diff_y, y2 - diff_x, x1 + diff_y, y1 - diff_x);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		map<int,int> data;
		for(int i=0,num;i<n;++i){
			int sum=0;
			cin>>num;
			for(int j=0,m,s;j<4;++j){
				cin>>m>>s;
				sum+=m*60+s;
			}
			data.insert(map<int,int>::value_type(sum,num));
		}
		map<int,int>::iterator it = data.begin();
		cout<<(*it).second<<"\n";
		++it;
		cout<<(*it).second<<"\n";
		map<int,int>::reverse_iterator rit = data.rbegin();
		++rit;
		cout<<(*rit).second<<"\n";
	}
	return 0;
}

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

using namespace std;

const int Nmax = 1e5 + 5;
int a[Nmax],dp[Nmax];
int N;

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin >> a[i];

    dp[2] = abs(a[2] - a[1]);

    for(int i = 3; i <= N; ++i)
        dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]),dp[i - 2] + abs(a[i - 2] - a[i]));

    cout << dp[N];
    return 0;
}


Measured memory_bytes: 1024
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll n;
vector<vector<ll>> g;
ll memo[100100][2];
ll rec(ll now, ll state, ll pa){
    if(memo[now][state] != -1) return memo[now][state];
    ll res = 1;
    rep(i, g[now].size()){
        ll next = g[now][i];
        if(next == pa) continue;
        ll tmp = 0;
        if(state == 0) tmp += rec(next, 1, now);
        tmp %= MOD;
        tmp += rec(next, 0, now);
        tmp %= MOD;
        res *= tmp;
        res %= MOD;
    }
    return memo[now][state] = res;
}
int main(void){
    cin >> n;
    g.resize(n);
    rep(i, n - 1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    rep(i, 100100){
        rep(j, 2){
            memo[i][j] = -1;
        }
    }

    cout << (rec(0, 0, -1) + rec(0, 1, -1)) % MOD << endl;


}


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

int pay(int n)
{
	int k=n*1.08;
	return k;
}
int n,flag=0;

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		if (pay(i)==n)
		{
			cout<<i<<endl;
			flag=1;
			break;
		}
	}
	if (flag==0)  cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();

        Console.WriteLine(s.Length == t.Length - 1 && t.StartsWith(s) ? "Yes" : "No");
    }
}


Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    string s; cin >> s;
    ll r = 0; rep(i,n)if(s[i] == 'R')r++;
    ll ans = 0;
    rep(i,r)if(s[i] == 'W')ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3772
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys
ceil=math.ceil
n,a,b = ma()
H = []
for i in range(n):
    H.append(ni())
H.sort()
def isok(x):
    bs = b*x
    d=a-b
    cnt=0
    for h in H:
        if h>bs:
            cnt+=math.ceil((h-bs)/d)
    return cnt<=x

def bisect():
    ok = 10**9
    ng = 0
    x = (ok+ng)//2
    while ok-ng>1:
        if isok(x):
            ok=x
        else:
            ng=x
        x=(ok+ng)//2
    return ok
print(bisect())


Measured memory_bytes: 13752
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// # pragma GCC optimize "-O3"
# define int long long
using namespace std;
  
const int N = 1e2 + 7;
const int mod = 1e9 + 7;

int ans = 1e9, c[N], a[N][N];

int32_t main() {
    speed;
    int n, m, x;
    cin >> n >> m >> x;
    for ( int i = 0; i < n; i++ ) {
    	cin >> c[i];
    	for ( int j = 0; j < m; j++ ) {
    		cin >> a[i][j];
    	}
    }
    for ( int i = 0; i <= (1 << n); i++ ) {
    	vector < int > vc(m);
    	int cnt = 0;
    	for ( int j = 0; j < n; j++ ) {
    		if ( (( i >> j ) & 1) ) {
    			cnt += c[j];
    			for ( int k = 0; k < m; k++ ) {
    				vc[k] += a[j][k];
    			}
    		}
    	}
    	int ok = 1;
    	for ( int j = 0; j < m; j++ ) {
    		if ( vc[j] < x ) {
    			ok = 0;
    			break;
    		}
    	}
    	if ( ok ) {
    		ans = min( ans, cnt );
    	}
    }
    if ( ans == 1e9 ) {
    	ans = -1;
    }
    cout << ans;
}


Measured memory_bytes: 3668
import math

D, G = map(int, input().split())
p = [0] * D
c = [0] * D
ans = float('inf')
for i in range(D):
  p[i], c[i] = map(int, input().split())
for i in range(2 ** D):
  s = 0
  n = 0
  ma = -1
  for j in range(D):
    if ((i >> j) & 1) == 1:
      s += 100 * (j + 1) * p[j] + c[j]
      n += p[j]
    else:
      ma = j
  if s < G:
    m = math.ceil((G - s) / (100 * (ma + 1)))
    if m > p[ma]:
      continue
    else:
      n += m
  ans = min(ans, n)
print(ans)

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

using namespace std;

// int jumps(int n, int N, int a[],int dp[]) {
//     int x,y;
//     x = y = INT_MAX;
//     if(n == N) return 0;
//     else if(dp[n] != 0) return dp[n];
//     else {
//         if(n+1 <= N) x = jumps(n+1,N,a,dp) + abs(a[n] - a[n+1]);
//         if(n+2 <= N) y = jumps(n+2,N,a,dp) + abs(a[n] - a[n+2]);
//         dp[n] = min(x,y);
//         return dp[n];
//     }
// }

int jumps(int N, int a[][4]) {
    int x,y;
    int dp[N+1][4] = {0};
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];
    dp[1][3] = a[1][3]; 
    if(N == 1) return max(max(dp[1][1],dp[1][2]),dp[1][3]);
    for(int i=2; i<=N; i++) {
        dp[i][1] = max(dp[i-1][2],dp[i-1][3]) + a[i][1];
        dp[i][2] = max(dp[i-1][1],dp[i-1][3]) + a[i][2];
        dp[i][3] = max(dp[i-1][2],dp[i-1][1]) + a[i][3];   
    }
    return max(max(dp[N][1],dp[N][2]),dp[N][3]);
}

int main() {
    int N;
    cin>>N;
    int a[N+1][4]; 
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=3; j++) cin>>a[i][j];  
    }
    cout<<jumps(N,a);
    return 0;
}

Measured memory_bytes: 6672
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	string S;
	cin >> S;
	int cnt[3] = {};
	map<char, int> mm;
	mm['a'] = 0; mm['b'] = 1; mm['c'] = 2;
	
	REP(i, S.size()) cnt[mm[S[i]]]++;
	
	sort(cnt, cnt + 3);
	
	if (cnt[2] - cnt[0] <= 1) puts("YES");
	else puts("NO");
	
	return 0;
}


Measured memory_bytes: 512
import sys

val = input()
input_str = input()
 
if 0 > int(val) or int(val) > 100:
    sys.exit()
if 0 > len(input_str) or len(input_str) > 100:
    sys.exit()


if int(val) >= len(input_str):
    print(input_str)
else:
    new_str = input_str[0:int(val)]
    print(new_str + '...')
    

Measured memory_bytes: 9180
import sys

strn = []
for s in sys.stdin:
    strn.append(s)

strng = ''.join(strn).lower()

a = 'abcdefghijklmnopqrstuvwxyz'

strng_lower = strng.lower()

for i in range(26):
    print("{} : {}".format(a[i], strng_lower.count(a[i])))




Measured memory_bytes: 5572
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AEntranceExamination {
public:
	void solve(istream& in, ostream& out) {
        double a,b; in >> a >> b;
        out << fixed << setprecision(10) << a / b << endl;
	}
};

int main() {
	AEntranceExamination solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
use std::fmt::Debug;
use std::io::stdin;
use std::str::FromStr;

fn read<T>() -> Vec<T>
where
  T: FromStr,
  <T as FromStr>::Err: Debug,
{
  let mut s = String::new();
  stdin().read_line(&mut s).unwrap();
  s.trim()
    .split_whitespace()
    .map(|c| T::from_str(c).unwrap())
    .collect()
}

fn main() {
  let x: Vec<u32> = read();
  println!(
    "{}",
    match x[1] {
      100 => (x[1] + 1) * 100u32.pow(x[0]),
      _ => x[1] * 100u32.pow(x[0]),
    }
  );
}


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

int main() {

    int n;
    cin >> n;
    vector<pair<double, double>> v;
    rep(i, n){
        double x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }

    vector<int> d(n);
    iota(all(d), 0);
    double ans = 0;
    do{
        rep(i, n-1){
            ans += sqrt(pow(v[d[i]].first - v[d[i+1]].first, 2) + pow(v[d[i]].second - v[d[i+1]].second, 2));
        }
    }while(next_permutation(all(d)));


    int fact = n;
    while(--n){
        fact *= n;
    }

    cout << fixed << setprecision(10) <<  ans / (double) fact << endl;

    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int c[] = {10000, 5000, 1000};
	int n, y;
	cin >> n >> y;
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= n; j++) {
			int k = n - i - j;
			if(k < 0) {
				continue;
			}                
			int tmp = 10000 * i + 5000 * j  + k * 1000;
			if(tmp == y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;	
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
ans=a[0]
for i in range(1,n):
    ans=gcd(ans,a[i])
if k%ans==0:
    if k<=max(a):
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
//long long a[200005];
int main ()
{
  long long int a,b,c,d,t,n,i,j;
  string s;
  cin >> s;
  if (s=="ABC")
  {
      cout<< "ARC"<<"\n";
  }
  else
  {
      cout << "ABC"<<"\n";
  }
}




Measured memory_bytes: 3556
N=int(input())
d1=[0]*N
d2=[0]*N
for i in range(N):
    d1[i],d2[i]=list(map(int,input().split()))
counter=0
for i in range(N-2):
    if d1[i]==d2[i] and d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2]:
        counter=1
if counter==1:
    print('Yes')
else:
    print('No')


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

using namespace std;

pair<int, int> A[100010];

int main(){

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

	int n, input;
	cin >> n;
	for(int i=0;i<n;++i){
		cin >> input;
		A[i] = make_pair(input, i);
	}
	sort(A, A+n);

	int counter = 0;
	for(int i=0;i<n;++i)
		if((A[i].second-i)&1) 
			counter++;
	
	cout << counter/2 << '\n';
	
	return 0;
} // br1


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int c[55],v[55];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	for(int i=0;i<n;i++){
		cin>>c[i];
	}
	int maxn=0;
	for(int i=0;i<n;i++){
		if(v[i]-c[i]>=0){
			maxn+=v[i]-c[i];
		}
	}
	printf("%d",maxn);
	return 0;
	
}

Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1009LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef pair<ii, ii> i4;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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


int n;
ll arr[300005], ans;


void solve(int l, int r){
    if(l > r)   return;
    ans += arr[r-1];
    r -= 2;
    l += 1;
    solve(l, r);
}
 
 
int main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n;
    for(int i=1;i<=3*n;i++)
        cin>>arr[i];
    sort(arr+1, arr+3*n+1);

    ans = 0;
    solve(1, 3*n);
    cout<<ans;
    return 0;
}





Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

map< long long, long long > prime_factor(long long n) {
  map< long long, long long > ret;
  for(long long i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main() {
    long long a, b;
	cin >> a >> b;
	cout << a*b << endl;
}

Measured memory_bytes: 3628
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [n, r] <- readIntList
  print $ if n < 10 then r + 100 * (10 - n) else r


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

int main(){
  int A, B;
  cin >> A >> B;
  
  if( (A+B)%2 == 0){
    cout << (A+B)/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>

const ll mod = 1000000007 ;
const ll N=5e5+5;

ld dp[1005][1005];
int main()
{
    FAST
    ll tc,i,j;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
      ll n,k;
      cin>>n>>k;
      ll ans=0;
      ll a[n];
      for(i=0; i<n; i++)
        cin>>a[i];
      sort(a,a+n);
      for(i=0; i<k; i++)
        ans+=a[i];
      cout<<ans<<"\n";
    }
    return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> as(N);
    for(int i=0; i<N; i++) cin >> as.at(i);
    vector<bool> bs(1000005, false);
    for(int i=0; i<N; i++) bs[as[i]] = true;

    sort(as.begin(), as.end());
    // asのなかから被りをのぞいた配列をnasに入れる。
    vector<int> nas;
    for(int i=0, prea=-1; i<N; i++)
    {
        if(prea == as[i]) continue;
        if(i+1 < N && as[i] == as[i+1])
        {
            prea = as[i];
            continue;
        }
        prea = as[i];
        nas.push_back(as[i]);
    }

    int prea = -1;
    int ans = 0;
    for(auto a : nas)
    {
        if(prea == a) continue;
        bool flag = true;
        if(a != 1 && bs[1]) flag = false;
        for(int i=2; i*i<=a; i++)
        {
            if(a%i==0 && (bs[i] || bs[a/i]))
            {
                flag = false;
                break;
            }
        }
        if(flag) ans++;
        prea = a;
    }
    cout << ans << '\n';


    return 0;
}


Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	if(k==0){
		cout << (ll)n*n << endl;
		return 0;
	}
	ll ans=0;
	for(int b=k+1;b<=n;++b){
		int i=k,j=b-1;
		while(i<=n || j<=n){
			if(j>n) ans+=n-i+1;
			else ans+=j-i+1;
			i+=b;
			j+=b;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("unroll-loops")
     
    #include <algorithm>
    #include <bitset>
    #include <cassert>
    #include <chrono>
    #include <cmath>
    #include <complex>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>
    #include <deque>
    #include <functional>
    #include <iomanip>
    #include <iostream>
    #include <iterator>
    #include <limits>
    #include <climits>
    #include <list>
    #include <map>
    #include <numeric>
    #include <queue>
    #include <random>
    #include <ratio>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <string>
    #include <unordered_map>
    #include <unordered_set>
    #include <utility>
    #include <vector>
    using namespace std;
     
    typedef long long ll;
    typedef long double LD;
    #define int ll
    #define double LD
    #define pb push_back
    #define mp make_pair
    #define REP(i,n) for (int i = 0; i < n; i++)
    #define loop(i,n) for (int i = 0; i < n; i++)
    #define FOR(i,a,b) for (int i = a; i < b; i++)
    #define REPD(i,n) for (int i = n-1; i >= 0; i--)
    #define FORD(i,a,b) for (int i = a; i >= b; i--)
    #define remax(a,b) a = max(a,b)
    #define remin(a,b) a = min(a,b)
    #define mem(a, b) memset(a, b, sizeof a)
    #define append push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define print(x) cout << (x) << endl
    #define PRECISION(x) cout << fixed << setprecision(x)
    #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
     
    const double PI=acos(-1);
    const int MOD = 1000000007;
    const int FMOD = 998244353;
    const double eps = 1e-9;
     
    mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
 	
 
    signed main()
    {
    	int n;
    	cin>>n;
    	int a[n];
    	loop(i,n)
    	cin>>a[i];
    	sort(a,a+n);
    	int ans=INT_MAX;
    	for(int j=1;j<=100;j++)
    	{
    		int d=0;
    		for(int i=0;i<n;i++)
    		{
    			d+=pow(a[i]-j,2);
			}
			ans=min(ans,d);
		}
		cout<<ans;
	}

Measured memory_bytes: 256
import java.util.Scanner;

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

		if (X == 7 || X == 5 || X ==3) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
vl fact,finv;
ll modpw(ll x,ll k){
	ll res=1;
	while(k!=0){
		if(k&1)res=res*x%MOD;
		x=x*x%MOD;
		k=k>>1;
	}
	return res;
}

ll comb(ll n,ll k) {
	if(n==0&&k==0)return 1;
	if(n<k||n<0)return 0;
	return fact[n]*finv[n-k]%MOD*finv[k]%MOD;
}

struct ferm{
	ferm(ll n){
		fact.resize(n);
		finv.resize(n);
		fact[0]=1;
		finv[0]=1;
		rep(i,n-1){
			fact[i+1]=(fact[i]*(i+1))%MOD;
			finv[i+1]=modpw(fact[i+1],MOD-2);
		}
	}
};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,ans=0;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	ferm(n+1);
	ll cur=0;
	ll tab=fact[n-1];
	rep(i,n-1){
		ll tmp=v[i+1]-v[i];
		//tab*=finv[i+1];
		//tab%=MOD;
		cur+=tab*modpw(i+1,MOD-2);
		cur%=MOD;
		tmp*=cur;
		tmp%=MOD;
		ans+=tmp;
		ans%=MOD;
		//puta(tmp,tab,(tab*finv[i+1])%MOD,cur%MOD);
	}
	puta(ans);
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(A);
        var A_ = A.Reverse().ToList();

        var len = new List<int>();

        for (int i = 0; i < N - 1; i++) {
            if (A_[i + 1] == A_[i]) {
                len.Add(A_[i]);
                i++;
            }

            if (len.Count() == 2) {
                break;
            }
        }
        if (len.Count() != 2) {
            Console.WriteLine(0);
        } else {
            Console.WriteLine((long)len[0] * len[1]);
        }
    }
}

Measured memory_bytes: 21216
from sys import stdin
# import sys

# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
# N = [int(x) for x in stdin.readline().rstrip().split()]
N = int(input())
# U = input().split()
# A, B = [str(x) for x in stdin.readline().rstrip().split()]

d = {}
for i in range(N):
    s = input()
    d[s] = d.get(s, 0)+1
print(len(d))


Measured memory_bytes: 35272
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
 
int32_t main()
{
	fastio();
	int n;
    cin>>n;
    map<int,int> mp;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        mp[x]++;
    }
    int ans=0;
    for(auto x: mp)
    {
    	if(x.second<x.first)
    	{
    		ans+=x.second;
    	}
    	else
    	{
    		ans+=x.second-x.first;
    	}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll a;
    cin(a);

    ll b = a % 10;
    if (b == 2 || b == 4 || b == 5 || b == 7 || b == 9) {
        print("hon");
    } else if (b == 0 || b == 1 || b == 6 || b == 8) {
        print("pon");
    } else {
        print("bon");
    }

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
  int N, s ;
  int i, j ;
  scanf("%d",&N) ;

  int d[100] ;

  /*N個のおいしさ度をスキャンし、配列に入力*/
  for( i = 0 ; i < N ; i++ ){
    scanf("%d",&d[i]) ;
  }

  s = 0 ;
  for( i=0 ; i<N ; i++ ){
    for( j=0 ; j<N ; j++){
      s += d[i]*d[j] ;
    }
  }

  for( i=0 ; i<N ; i++ ){
    s -= d[i]*d[i] ;
  }

  s /= 2 ;
  printf("%d\n",s) ;

  return 0 ;
}

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

int main(){
    string s;
    cin >> s;
    int ans; 
    if(s == "SUN") ans = 7;
    if(s == "MON") ans = 6; 
    if(s == "TUE") ans = 5; 
    if(s == "WED") ans = 4; 
    if(s == "THU") ans = 3; 
    if(s == "FRI") ans = 2; 
    if(s == "SAT") ans = 1; 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int n;
int a[100]={};

ll total(int x){
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=(x-a[i])*(x-a[i]);
  }
  return ans;
}

int main(){
  cin  >> n;
  ll sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  int avg=sum/n;
  cout << min(total(avg), total(avg+1)) << endl;
  return 0;
}

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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    string s; cin >> s;
    int ans=0;
    for(int i=0;i<N;i++){
        if(s[i]==s[i+1]) continue;
        else ans++;
    }
    cout << ans << endl;
}


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

const int N=105;
const int inf=1000000000;

int n,m,s,t,sx,sy,tx,ty,cnt,last[N*2],dis[N*2],cur[N*2];
struct edge{int to,next,c;}e[N*N*N*2];
queue<int> que;
char str[N];

void addedge(int u,int v,int c)
{
    e[++cnt].to=v;e[cnt].c=c;e[cnt].next=last[u];last[u]=cnt;
    e[++cnt].to=u;e[cnt].c=0;e[cnt].next=last[v];last[v]=cnt;
}

bool bfs()
{
    for (int i=s;i<=t;i++) dis[i]=0;
    while (!que.empty()) que.pop();
    dis[s]=1;que.push(s);
    while (!que.empty())
    {
        int u=que.front();que.pop();
        for (int i=last[u];i;i=e[i].next)
            if (e[i].c&&!dis[e[i].to])
            {
                dis[e[i].to]=dis[u]+1;
                if (e[i].to==t) return 1;
                que.push(e[i].to);
            }
    }
    return 0;
}

int dfs(int x,int maxf)
{
    if (x==t||!maxf) return maxf;
    int ret=0;
    for (int &i=cur[x];i;i=e[i].next)
        if (e[i].c&&dis[e[i].to]==dis[x]+1)
        {
            int f=dfs(e[i].to,min(e[i].c,maxf-ret));
            e[i].c-=f;
            e[i^1].c+=f;
            ret+=f;
            if (maxf==ret) break;
        }
    return ret;
}

int dinic()
{
    int ans=0;
    while (bfs())
    {
        for (int i=s;i<=t;i++) cur[i]=last[i];
        ans+=dfs(s,inf);
    }
    return ans;
}

int main()
{
    scanf("%d%d",&n,&m);
    s=0;t=n+m+1;cnt=1;
    for (int i=1;i<=n;i++)
    {
        scanf("%s",str+1);
        for (int j=1;j<=m;j++)
            if (str[j]=='S') sx=i,sy=j;
            else if (str[j]=='T') tx=i,ty=j;
            else if (str[j]=='o')addedge(i,j+n,1),addedge(j+n,i,1);
    }
    if (sx==tx||sy==ty) {puts("-1");return 0;}
    addedge(s,sx,inf);addedge(s,sy+n,inf);
    addedge(tx,t,inf);addedge(ty+n,t,inf);
    printf("%d",dinic());
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

// const ll mod = static_cast<int>(1e9 + 7);


vector<Vi> node;
Vi ans;
Vi cnts;


void dfs(int idx, int cnt) {
	cnt += cnts[idx];
	ans[idx] = cnt;
	for (const auto& chd : node[idx]) {
		if (ans[chd] != -1) continue;
		dfs(chd, cnt);
	}
}


int main() {
	int N, Q;
	cin >> N >> Q;

	node.resize(N);
	ans.resize(N, -1);
	cnts.resize(N);


	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		node[a].push_back(b);
		node[b].push_back(a);
	}


	for (int i = 0; i < Q; ++i) {
		int p, x;
		cin >> p >> x;
		--p;
		cnts[p] += x;
	}

	dfs(0, 0);
	for (int i = 0; i < N - 1; ++i) {
		cout << ans[i] << " ";
	}
	cout << ans[N - 1] << endl;
}


Measured memory_bytes: 21120
money = 0
x, y = map(int, input().split())

def func(grade):
    global money
    if grade == 1:
        money += 300000
    elif grade == 2:
        money += 200000
    elif grade == 3:
        money += 100000

func(x)
func(y)

if x == 1 and y == 1:
    money += 400000

print(money)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int draw ( int width, int height,std::vector<std::vector<int>> map){
	for(int i =0; i < height; i ++){
		for(int j = 0; j < width; j ++){
			cout << map[j][i] << " ";
		}
		cout << endl;

	}
	return 0;
}
//未探索陸地か
bool judge (int width,int height,std::vector<std::vector<int>> map, int x, int y){
	if( x >=0 && x  < width && y >= 0 && y < height && map[x][y] == 1){
		return true;
	}
	return false;
}
//周辺を探査して塗りつぶす
std::vector<std::vector<int>> Conqure (int width,int height,std::vector<std::vector<int>> map, int x, int y, int color) {
	map[x][y] = color;
	for(int dx = -1; dx <= 1; dx++){
		for(int dy = -1; dy <= 1; dy++){
			if(judge(width,height,map,x+dx,y+dy)){
				map[x+dx][y+dy] = color;
				if(!(dx == 0 && dy == 0)){
					map = Conqure(width,height,map,x+dx,y+dy,color);
				}
				
			}
		}
	}
	return map;
}
int main () {
	while(true){
			int w,h;
	cin >> w >> h;
	if(w == 0 && h == 0){
		break;
	}
	std::vector<std::vector<int>> map;
		map.resize(w);		// ()内の数字が要素数になる
	for( int i=0; i<w; i++ ){
		map[i].resize(h);
	}
	int landCount = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> map[j][i];
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(judge(w,h,map,j,i)){
				landCount += 1;
				map = Conqure(w,h,map,j,i,landCount + 1);
				//draw(w,h,map);
			}
		}
	}
	cout <<  landCount << endl;
	}

}


Measured memory_bytes: 29512
#include <iostream>
#include <sstream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
    while (1){
        int i, j ;
        cin >> i >> j ;
        if (i == 0 && j == 0){
            break;
        } else if ( i <= j) {
            cout << i << " " << j << endl;
        } else{
            cout << j << " " << i << endl;
        }

    }
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  int a[100];
  int i,n;
  int before = 0;

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

  for(i = 0; i < n; i++){
    if(i > 0){
      printf(" ");
    }
    printf("%d", a[i]);
  }
  printf("\n");

  for(int j = 1; j < n; j++){
    for(i = j; i > 0; i--){
      if(a[i-1] > a[i]){
        before = a[i-1];
        a[i-1] = a[i];
        a[i] = before;
      }
    }
    for(i = 0; i < n; i++){
      if(i > 0) printf(" ");
      printf("%d", a[i]);
    }
    printf("\n");
  }
  
	return 0;
}

Measured memory_bytes: 3192
#coding: UTF-8

x = int(input())
a = 0
s = 0
h = 0
c = 0
d = 0
lists = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
listh = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
listc = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
listd = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

while a < x:
	l = raw_input().split()
	a += 1
	m = l[0]
	n = int(l[1])
	
	if m == "S":
		s += 1
		lists.remove(n)
	if m == "H":
		h += 1
		listh.remove(n)
	if m == "C":
		c += 1
		listc.remove(n)
	if m == "D":
		d += 1
		listd.remove(n)

for ss in lists:
	print "S %d"%ss
for hh in listh:
	print "H %d"%hh
for cc in listc:
	print "C %d"%cc
for dd in listd:
	print "D %d"%dd

Measured memory_bytes: 6412
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, d[110], ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", d + i);
  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j < n; j++)
      ans += d[i] * d[j];
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int N, K;
  cin >> N;
  cin >> K;
  long long int ans;
  long long int H[N];
  ans = 0;
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  sort(H, H+N);
  for (int i = N-1; i >= 0; --i) {
    if (K > 0) {
      --K;
    } else {
      ans += H[i];
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1792
import math
def kock(n,p1,p2):
    a=math.radians(60)
    if n==0:
        return 0
    s=[(2*p1[0]+p2[0])/3,(2*p1[1]+p2[1])/3]
    t=[(p1[0]+2*p2[0])/3,(p1[1]+2*p2[1])/3]
    u=[((t[0]-s[0])*math.cos(a)-(t[1]-s[1])*math.sin(a))+s[0],(t[0]-s[0])*math.sin(a)+(t[1]-s[1])*math.cos(a)+s[1]]
    kock(n-1,p1,s)
    print(" ".join(map(str,s)))
    kock(n-1,s,u)
    print(" ".join(map(str,u)))
    kock(n-1,u,t)
    print(" ".join(map(str,t)))
    kock(n-1,t,p2)
n=int(input())
start=[float(0),float(0)]
end=[float(100),float(0)]
print(" ".join(map(str,start)))
kock(n,start,end)
print(" ".join(map(str,end)))


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

#define ll long long

int main(void){
    int a,b;
    cin >> a >> b;
    if((a+b)%2==0){
        cout << (a+b)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
#define P pair<int, int>
using namespace std;

const int M = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> cnt(M);
  for(int x : a){
    if(cnt[x] != 0){
      cnt[x] = 2;
      continue;
    }
    for(int i = x; i < M; i+= x) cnt[i]++;
  }
  int ans = 0;
  for(int x : a){
    if(cnt[x] == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7956