akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    S = input()
    
    ans = 0
    kako = ""
    for i,val in enumerate(S):
        if i == 0:
            ans += 1
            kako = val
            continue
        
        if val != kako:
            ans += 1
            kako = val
    
    print(ans)
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 41328
#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)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<int> dp(n+2,1000000000);
	dp.at(0)=0;
	rep(i,n-1){
		for(int j=1;j<=k && i+j<n;++j){
			dp.at(i+j)=min(dp.at(i+j),dp.at(i)+abs(a.at(i)-a.at(i+j)));
		}
	}
	cout << dp.at(n-1) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,M;
ll dp[1005][9000];
ll a[1005];
ll b[1005];
ll c[1005][15];
ll pw[15];

int main(){

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

cin>>N>>M;
rep(i,M){
    cin>>a[i]>>b[i];
    rep(j,b[i]){
        cin>>c[i][j];
        c[i][j]--;
    }
}
rep(i,15) pw[i]=pow(2,i);
rep(i,1005) rep(j,4100) dp[i][j]=INF;
dp[0][0]=0;
ll sn=0;
rep(k,15){
    rep(i,b[0]){
        if(k==c[0][i]) sn+=pw[k];
    }
}
dp[0][sn]=a[0];
rep1(m,M){
    rep(i,4100){
        ll ii=i;
        string s="000000000000000"; 
        ll st=0;
        while(ii){
            if(ii%2) s[st]='1';
            ii/=2; 
            st++;
        }
        rep(k,b[m]){
            s[c[m][k]]='1';
        }
        ll nm=0;
        rep(k,N){
            if(s[k]=='1') nm+=pw[k];
        }
        dp[m][nm]=min(dp[m][nm],dp[m-1][i]+a[m]);
        dp[m][i]=min(dp[m][i],dp[m-1][i]);
    }
}
ll nmax=0;
rep(i,N) nmax+=pw[i];
cout<<(dp[M-1][nmax]==INF?-1:dp[M-1][nmax])<<endl;



}
    


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

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define M 2000

using namespace std;

bool ab[100000],ac[100000],bc[100000];
bool match(char c1, char c2){
    return (c1 == '?' || c2 == '?' || c1 == c2);
}

int main(void){
    int i,j;
    string a,b,c;
    cin >> a >> b >> c;
    
    int A = a.length();
    int B = b.length();
    int C = c.length();

    REP(i,A) REP(j,B) if(!match(a[i], b[j])) ab[i-j+50000] = true;
    REP(i,A) REP(j,C) if(!match(a[i], c[j])) ac[i-j+50000] = true;
    REP(i,B) REP(j,C) if(!match(b[i], c[j])) bc[i-j+50000] = true;

    int ans = 3 * M;
    for(i=-2*M;i<=2*M;i++) for(j=-2*M;j<=2*M;j++) if(!ab[i+50000] && !ac[j+50000] && !bc[j-i+50000]){
        int L = min(0, min(i, j));
        int R = max(A, max(B + i, C + j));
        ans = min(ans, R - L);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        P[] Ps = new P[M];

        for (int m = 0; m < M; m++) {
            P p = new P();
            p.s = in.nextInt();
            p.c = in.nextInt();
            Ps[m] = p;
        }

        int first = 0;
        if (N > 1) {
            first = (int) Math.pow(10, N - 1);
        }

        for (int i = first; i < Math.pow(10, N); i++) {
            boolean b = true;
            for (P p : Ps) {
                if (get(i, p.s) != p.c) {
                    b = false;
                    break;
                }
            }

            if (b) {
                System.out.println(i);
                return;
            }
        }

        System.out.println(-1);
    }

    private static int get(int a, int s) {
        String as = Integer.toString(a);
        return Integer.parseInt(as.substring(s - 1, s));
    }
}

class P {
    public int s;
    public int c;
}

Measured memory_bytes: 21972
import java.util.*;

public class Main {

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

        int ans = x - t;
        if (ans < 0) ans = 0;

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const int mod=1e9+7;
const int inf=1e9+7;
  
//const int maxn=
  
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
      
    int a,b,c;
    
    cin>>a>>b>>c;
    
    if(a>b)
    	swap(a,b);
    
    if(a>c)
    	swap(a,c);
    
    if(b>c)
    	swap(b,c);
    
    if((a==b&&a!=c)||(b==c&&a!=b))
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
  
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<long long> H(N);
    for (int i=0; i<N; i++) cin >> H.at(i);
    sort(H.begin(), H.end());
    reverse(H.begin(), H.end()); //降順ソートする
    // この最初からK個 H.at(0) ~ H.at(K-1)は必殺技で一撃で倒す
    // すなわち、H.at(K) ~ H.at(N-1) の合計が必要な攻撃回数
    long long ans = 0;
    for (int k=K; k < N; k++){
        ans += H.at(k);
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main(){

    int n;
    double value;
    cin>>n;
    vector<double> v(n);
    rep(i,n) cin>>v[i];
    value = v[0];
    for(int i = 0;i<n-1;i++){
        sort(v.begin()+i,v.end());
        v[i+1] = (v[i] + v[i+1])/2;
    }
    cout << fixed << setprecision(6);
    cout<<v[n-1]<<endl;
    return 0;
}

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

using namespace std;
const int maxn = 100005;
typedef long long ll;

int a[maxn];

void solve()
{
    /*int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);*/
    int a,b,c,x,y;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);

    if(a+b > c*2)
    {
        int cnt = min(x,y);

        int ans = 2*cnt * c;

        if(x>y)
        {
            int cnt2 = x-y;
            ans += min(cnt2*a, cnt2*2*c);
        }
        else
        {
            int cnt2 = y-x;
            ans += min(cnt2*b,cnt2*2*c);
        }
        cout<<ans<<endl;
    }
    else
    {
        cout<<x*a+b*y<<endl;
    }

}
int main()
{
    /*int t;
    scanf("%d",&t);
    while(t--)*/
        solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

int main(){
	vector<P> vec;
	while(1){
		int n,point;
		scanf("%d,%d",&n,&point);
		if(n==0 && point==0)break;
		vec.push_back(make_pair(point,make_pair(n,0)));
	}
	sort(vec.begin(),vec.end(),greater<P>());
	int cnt=2;
	vec[0].second.second=1;
	loop(i,1,vec.size()){
		if(vec[i-1].first==vec[i].first){
			vec[i].second.second=vec[i-1].second.second;
		}else{
			vec[i].second.second=cnt;
			cnt++;
		}
	}
	int num;
	while(cin>>num){
		rep(i,vec.size()){
			if(vec[i].second.first==num){
				cout<<vec[i].second.second<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1248
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#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 <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

#endif


int main(void)
{
	ll n, x;
	cin >> n >> x;

	vector<ll> l(n);
	rep(i, 0, n)
		cin >> l[i];

	ll i = 1;
	ll ans = 0;
	for (const auto& e : l)
	{
		ans += e;

		if (ans <= x)
			i++;
		else
			break;
	}


	cout << i;
	return 0;
}


Measured memory_bytes: 256
import math

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

def countComb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
NN = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, NN + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

#print(cmb(n, r, p))

totalMaxA = 0
totalMinA = 0
for i in range(K-1, N):
  totalMaxA += A[i] * countComb(i, K-1, p)
for i in range(N-K+1):
  totalMinA += A[i] * countComb(N-i-1, K-1, p)

print((totalMaxA - totalMinA) % p)


Measured memory_bytes: 130048
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            String S = reader.readLine();
            int K = Integer.parseInt(reader.readLine());

            long count1 = count(S, K);
            long count2 = count(new StringBuffer(S).reverse().toString(), K);

            System.out.println(Math.min(count1, count2));
        }
    }

    public static long count(String S, int K) {
        long a = 0;
        char[] C = S.toCharArray();
        for (int i = 1; i < C.length; i++) {
            if (C[i] == C[i - 1]) {
                a++;
                C[i] = (char) (C[i] - 32);
            }
        }

        if (K == 1) {
            return a * K;
        } else {
            long b = 0;
            C = (S + S).toCharArray();
            for (int i = 1; i < C.length; i++) {
                if (C[i] == C[i - 1]) {
                    b++;
                    C[i] = (char) (C[i] - 32);
                }
            }

            long ans = b * (K / 2) + a * (K % 2);

            if (C[C.length - 1] == C[0]) {
                ans += K / 2 - 1;
            }

            return ans;
        }
    }

}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
double r;
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> r;
	printf("%.12lf\n",2.0*pi*r);
	return 0;
}
//do smt instead of nothing! never give up!


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

using namespace std;

string KEY="ESTIVAL";
long long dp[9][5001];
long long add[5001];

long long count(string s)
{
    memset(dp, 0, sizeof dp);
    int n=s.length();
    int m=KEY.length();
    for(int i=0; i<n; i++)
        dp[0][i]=1;
    for(int i=0; i<m; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(j>0)
                dp[i+1][j]=dp[i+1][j-1];
            if(KEY[i]==s[j])
                dp[i+1][j]+=dp[i][j];
        }
    }
    return dp[m][n-1];
}

int main()
{
    string s;
    for(int i=1; i<=35; i++)
    {
        string t;
        for(auto c: KEY)
            t+=string(i, c);
        s=t+s;
        add[i]=count(s);
    }
    long long K;
    cin >> K;
    string ans;
    for(int i=35; i>=1; i--)
    {
        if(K>=add[i])
        {
            ans+=string(K/add[i], 'F');
            K%=add[i];
        }
        for(auto c: KEY)
            ans+=string(i, c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
a,b=input().split()
a=int(a)
b=int(b)
x=0.5
count=0
for i in range(1,a+1):
    dcount=0
    while 1:
        if i>=b:
            break
        i=i*2
        dcount+=1
    if dcount==0:
        count+=1/a
    else:
        count+=1/a*x**dcount
print(count)
    


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main(void)
{
    FastIO;
    
    ll x;
    cin>>x;
    if(x==1)
    {
    	cout<<"0";
	}
	else
	{
		cout<<"1";
	}
    
    return 0;
}

Measured memory_bytes: 3648
list=[]
try:
    while True:
        list.append(int(input()))
except EOFError:
    pass
for i in range(len(list)):
    
        
    s=0
    for k in range(0,int(600/list[i])):
    
   
        s=s+(list[i]*k)**2
    print(s*list[i])








Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int mid = 400020;

int nums[600030] = { 0 };

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	vector<int> as(n); for (auto& a : as) cin >> a;

	int64_t ans = 0;
	FOR_LT(i, 0, n) {
		if (as[i] >= 200000) continue;
		ans += nums[mid + as[i] - i];
		nums[mid - as[i] - i]++;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 5584
import java.util.*

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()

    var answer = 0L

    for (h in 1..k) {
        if (h == 1) {
            answer += k*k
        } else {
            for (i in 1..k) {
                val gcdhi = gcd(listOf(h,i))
                if (i == 1) {
                    answer += k
                } else {
                    for (j in 1..k) {
                        if (j == 1) {
                            answer += 1
                        } else if (h == i && h == j && i == j) {
                            answer += h
                        } else {
                            answer += gcd(listOf(gcdhi, j))
                        }
                    }
                }
            }
        }
    }
    println(answer)
}

fun gcd(list: List<Int>): Int {
    val stack = Stack<Int>()
    for (e in list) {
        stack.push(e)
    }
    while (1 < stack.size) {
        val pops = (0 until 2).map {
            stack.pop()
        }

        val minIndex = if (pops[1] < pops[0]) 1
        else 0

        stack.push(pops[minIndex])
        val r = pops[(minIndex + 1) % 2] % pops[minIndex]
        if (0 < r) {
            stack.push(r)
        }
    }
    return stack.pop()
}


Measured memory_bytes: 56640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 10000000000LL

using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
struct edge{
  int to;
  ll cost;
};

int main()
{
	while(1){
      int n;
      scanf("%d", &n);
      if(n==0) return 0;
      vector<edge> v[800];
      int p[802];
      for(int i=1; i<n; i++){
        scanf("%d", &p[i]);
        p[i]--;
      }
      ll sum=0;
      for(int i=1; i<n; i++){
        ll d0;
        scanf("%lld", &d0);
        sum+=d0;
        edge e;
        e.to=p[i];
        e.cost=d0;
        v[i].push_back(e);
        e.to=i;
        v[p[i]].push_back(e);
      }
      ll d[800][800];
      for(int i=0; i<n; i++){
        priority_queue<P, vector<P>, greater<P> > que;
        que.push(P(0, i));
        fill(d[i], d[i]+n, INF);
        d[i][i]=0;
        while(!que.empty()){
          P p=que.top();
          que.pop();
          int x=p.second;
          if(d[i][x]<p.first) continue;
          for(int j=0; j<v[x].size(); j++){
            edge e=v[x][j];
            if(d[i][e.to]>d[i][x]+e.cost){
              d[i][e.to]=d[i][x]+e.cost;
              que.push(P(d[i][e.to], e.to));
            }
          }
        }
      }
      ll sum1=0;
      for(int i=0; i<n; i++){
        if(v[i].size()==1){
          sum1+=v[i][0].cost;
        }
      }
      ll m=0;
      for(int i=0; i<n; i++){
        if(v[i].size()==1) continue;
        for(int j=0; j<n; j++){
          if(v[j].size()==1) continue;
          if(m<d[i][j]) m=d[i][j];
        }
      }
      ll ans=sum1+m*2+(sum-sum1-m)*3;
      printf("%lld\n", ans);
    }
	return 0;
}


Measured memory_bytes: 8368
x = list(input())
y = list(input())

lx = len(x)
ly = len(y)
INF = 10**10
dp = [[INF]*(lx+1) for i in range(ly+1)]
dp[0][0] = 0

for i in range(ly+1): dp[i][0] = i
for i in range(lx+1): dp[0][i] = i

for i in range(ly):
    for j in range(lx):
        if y[i] == x[j]:
            dp[i+1][j+1] = min(dp[i+1][j]+1,dp[i][j+1]+1,dp[i][j])
        else:
            dp[i+1][j+1] = min(dp[i+1][j]+1,dp[i][j+1]+1,dp[i][j]+1)

print(dp[ly][lx])



Measured memory_bytes: 42532
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int a, b, c;
    cin >> a >> b >> c;
    int M = a + b + c;
    if (!M) return 0;
    int P[300];
    for (int i = 1; i <= M; i++)
      P[i] = 2;
    int N;
    cin >> N;
    int L[1000][4];
    for (int x = 0; x < N; x++) {
      for (int j = 0; j < 4; j++)
        cin >> L[x][j];
      if (L[x][3])
        for (int j = 0; j < 3; j++)
          P[L[x][j]] = 1;
    }
    for (int x = 0; x < N; x++)
      if (!L[x][3]) {
        if (P[L[x][0]] == 1 && P[L[x][1]] == 1)
          P[L[x][2]] = 0;
        else if (P[L[x][1]] == 1 && P[L[x][2]] == 1)
          P[L[x][0]] = 0;
        else if (P[L[x][2]] == 1 && P[L[x][0]] == 1)
          P[L[x][1]] = 0;
      }
    for (int i = 1; i <= M; i++)
      cout << P[i] << endl;
  }
}

Measured memory_bytes: 0
Proc.new{ |n, *st| n.first.times { |i| puts st[i..(n.first-1)].inject(0) { |t, (c, s, f)| [((t-s)/f.to_f).ceil,0].max*f+s+c }}}.(STDIN.read.lines.map{ |l| l.split.map(&:to_i)})

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

int main(){
  for (int i=0;true;i++){
    int a,b;
    char op;
    cin >> a  >> op >> b;

    if(op == '?') break;
    else if (op == '+'){
      cout << a+b << endl;
    }
    else if (op == '-'){
      cout << a-b << endl;
    }
    else if (op == '*'){
      cout << a*b << endl;
    }
    else {
      cout << a/b << endl;
    }

  }

  return 0;
}

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

const int N = 305;
using arr = array<array<int, N>, N>;
const int mod = 1e9 + 7;

void add(int& x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int mul(int x,int y) {
	return (long long) x * y % mod;
}

int n;
int type[N + N];

int main() {
	scanf("%d", &n);
	int free = 0; 
	int only = 0;
	for (int i = 1; i <= n; ++i) {
		int u, v;
		scanf("%d %d", &u, &v);
		if (u > v) {
			swap(u, v);
		}
		if (u > 0 && v > 0) {
			type[u] = type[v] = 1;
		} else if (v > 0) {
			type[v] = 2;
			++only;
		} else {
			++free;
		}
	}
	arr f{};
	f[0][0] = 1;
	for (int i = n + n; i > 0; --i) if (type[i] ^ 1) {
		arr nf{};
		if (type[i] == 0) {
			for (int j = 0; j <= n; ++j) {
				for (int k = 0; k <= only; ++k) if (f[j][k]) {
					add(nf[j + 1][k], f[j][k]);
					if (j) {
						add(nf[j - 1][k], f[j][k]);
					}
					if (k) {
						add(nf[j][k - 1], mul(k, f[j][k]));
					}
				}
			}
		} else {
			for (int j = 0; j <= n; ++j) {
				for (int k = 0; k <= only; ++k) if (f[j][k]) {
					add(nf[j][k + 1], f[j][k]);
					if (j) {
						add(nf[j - 1][k], f[j][k]);
					}
				}
			}
		}
		f = nf;
	}
	int ans = f[0][0];
	for (int i = 1; i <= free; ++i) {
		ans = mul(ans, i);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int h,n,m;
int main()
{
	scanf("%d %d %d",&h,&m,&n);
	int ans=max(h,m);
	if(n%ans==0) printf("%d",n/ans);
	else printf("%d",n/ans+1);
	return 0;
}

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

using namespace std;

const int MAX_H = 1000;
const int MAX_W = 1000;

typedef pair<int, int> P;
typedef pair<P, int> PP;

int H, W;
char field[MAX_H][MAX_W];
bool visited[MAX_H][MAX_W];
queue<PP> que;

int solve() {
  int cnt;
  PP pp;
  P p;
  int i, j, ni, nj;

  int di[4] = {-1, 0, 1, 0};
  int dj[4] = {0, 1, 0, -1};

  while (que.size()) {
    pp = que.front();
    que.pop();
    p = pp.first;
    cnt = pp.second;
    i = p.first;
    j = p.second;
    for (int d = 0; d < 4; d++) {
      ni = i + di[d];
      nj = j + dj[d];
      if (ni >= 0 && ni < H && nj >= 0 && nj < W && !visited[ni][nj] &&
          field[ni][nj] == '.') {
        que.push(make_pair(make_pair(ni, nj), cnt + 1));
        visited[ni][nj] = true;
        field[ni][nj] = '#';
      }
    }
  }
  return cnt;
}

int main() {
  cin >> H >> W;
  char cell;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> cell;
      if (cell == '#') {
        visited[i][j] = true;
        que.push(make_pair(make_pair(i, j), 0));
      } else {
        visited[i][j] = false;
      }
      field[i][j] = cell;
    }
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 14080
import java.io.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] rc = line.split(" ");
        int r = Integer.parseInt(rc[0]);
        int c = Integer.parseInt(rc[1]);
        int[][] matrix = new int[r+1][c+1];	//????¨???§?????\??????
        int[] s = new int[c+1];
        for(int i=0; i<r; i++) {
            line = br.readLine();
            String[] inputs = line.split(" ");
            matrix[i][c] = 0;				//????¨?
            for(int j=0; j<c; j++) {
                matrix[i][j] = Integer.parseInt(inputs[j]);
                matrix[i][c] += matrix[i][j];
            }
        }
        for(int i=0; i <= c; i++) {	//????¨????????¨?????¨??????????
			matrix[r][i] = 0;
			for( int j = 0 ; j < r ; j++ ) {
				matrix[r][i] += matrix[j][i];
			}
        }
        for(int i = 0 ; i <= r ; i++ ) {
			for( int j = 0 ; j <= c ; j++ ) {
				System.out.print( matrix[i][j]) ;
				if ( j < c ) {
					System.out.print( " " ) ;
				}
			}
			System.out.println("");
		}
    }
}

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

#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)

int main()
{
    string s, t;
    cin >> s >> t;

    string ans = "UNRESTORABLE";
    REP(i, 0, s.length() - t.length() + 1)
    {
        string tmp = s;
        REP(j, 0, t.length())
        {
            if (s[i + j] != '?' & s[i + j] != t[j])
                break;
            tmp[i + j] = t[j];
            if (j == t.length() - 1)
            {
                REP(k, 0, s.length())
                if (tmp[k] == '?') tmp[k] = 'a'; // ?をaに置き換えている
                ans = tmp;
            }
        }
    }

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

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        long[] asum = new long[n];
        asum[0] = a[0];
        for (int i = 1; i < n; i++)
            asum[i] = asum[i - 1] + a[i];
        long ans = 0;
        ans += asum.Count(s => s == 0);
        Array.Sort(asum);
        int count = 0;
        for (int i = 0; i < n; i++)
        {
            if (i == n - 1 || asum[i] != asum[i + 1])
            {
                count++;
                ans += (long)count * (count - 1) / 2;
                count = 0;
            }
            else
                count++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 36320
#include <bits/stdc++.h>
#define re register
#define int long long
#define SIZE 25
#define MOD 1000000007
using namespace std;
int n;
int a[SIZE][SIZE];
int dp[1<<21],sum[1<<21];
signed main()
{	
    cin>>n;
    for(re int i=1;i<=n;++i)
    	for(re int j=1;j<=n;++j)
    		cin>>a[i][j];
   	for(int S=0;S<(1<<n);S++)
	{
		int t=S;
		while(t!=0)
		{
			if(t&1==1)
				sum[S]++;
			t=t>>1;
		}
	}
    dp[0]=1;
    for(re int i=1;i<=n;++i)	
		for(re int S=0;S<(1<<n);++S)
			for(re int j=1;j<=n;++j)
				if(sum[S]==i && a[i][j]==1 && ((S&(1<<(j-1)))!=0))
				{
					(dp[S]+=dp[S&(~(1<<(j-1)))]%MOD)%MOD;
				} 
    cout<<dp[(1<<n)-1]%MOD<<endl;
    return 0;
}
/*
*/

Measured memory_bytes: 33024
#include<vector>
#include<algorithm>
#include<tuple>
#include<iostream>
#include<queue>
#include<numeric>
#include<deque>
using namespace std;

struct GeneralMatching{
	int N;
	int cur;
	vector<int>t,p,used,base,match;
	queue<int>que;
	vector<vector<int>>G;

	GeneralMatching(int n):N(n),cur(0),t(n),p(n),used(n),base(n),match(n),G(n){}

	void addEdge(int v,int u){
		G[v].push_back(u);
		G[u].push_back(v);
	}

	int get(int v){
		return base[v]==v?v:base[v]=get(base[v]);
	}

	int getLCA(int v,int u){
		v=get(v);u=get(u);
		cur++;
		while(true){
			if(v!=-1){
				if(used[v]==cur)return v;
				used[v]=cur;
				v=match[v]==-1?-1:get(p[match[v]]);
			}
			swap(v,u);
		}
	}

	void blossom(int v,int u,int b){
		while(get(v)!=b){
			p[v]=u;
			u=match[v];
			if(t[u]==1){
				t[u]=0;
				que.push(u);
			}
			base[v]=b;
			base[u]=b;
			v=p[u];
		}
	}

	void augment(int u,int v){
		while(u!=-1){
			int nu=match[p[u]];
			match[u]=p[u];
			match[p[u]]=u;
			u=nu;
		}
	}

	bool bfs(int s){
		fill(p.begin(),p.end(),-1);
		fill(t.begin(),t.end(),-1);
		iota(base.begin(),base.end(),0);
		t[s]=0;
		que=queue<int>();
		que.push(s);
		while(que.size()){
			int v=que.front();que.pop();
			for(auto u:G[v]){
				if(t[u]==-1){
					t[u]=1;
					p[u]=v;
					if(match[u]==-1){
						augment(u,v);
						return true;
					}
					int w=match[u];
					t[w]=0;
					que.push(w);
				}
				else if(t[u]==0&&get(v)!=get(u)){
					int b=getLCA(v,u);
					blossom(v,u,b);
					blossom(u,v,b);
				}
			}
		}
		return false;
	}
	int solve(){
		fill(match.begin(),match.end(),-1);
		int res=0;
		for(int i=0;i<N;i++){
			if(match[i]==-1&&bfs(i))res++;
		}
		return res;
	}
};

int main(){
	int X,Y,E;
	cin>>X>>Y>>E;

	GeneralMatching gm(X+Y);
	for(int i=0;i<E;i++){
		int x,y;
		cin>>x>>y;
		y+=X;
		gm.addEdge(x,y);
	}

	cout<<gm.solve()<<endl;
	return 0;
}


Measured memory_bytes: 3296
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

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

	int n = a.size(), m = b.size();

	if (a[n - 1] == b[0] && b[m - 1] == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

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

Measured memory_bytes: 256
h, w = list(map(int, input().split()))
grid = []
grid.append(list('.'*(w+2)))
for i in range(h):
    grid.append(['.'] + list(input()) + ['.'])
grid.append(list('.'*(w+2)))
bools = []
for i in range(h):
    for j in range(w):
        if grid[i+1][j+1] == '.':
            bools.append(True)
        else:
            if grid[i][j+1] == '#' or grid[i+1][j] == '#' or grid[i+2][j+1] == '#' or grid[i+1][j+2] == '#':
                bools.append(True)
            else:
                bools.append(False)
if all(bools):
    print('Yes')
else:
    print('No')

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

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

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

  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i ; j--) {
      if (a[j] < a[j-1]) {
        swap(a[j], a[j-1]);
        count++;
      }
    }

  }

  for (int i = 0; i < n - 1; i++){
    cout << a[i] << ' ';
  }
  cout << a[n - 1] << endl;
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

int main()
{
	int n,h,w;
	int ans=0;
	cin>>n>>h>>w;
	ans=(n-h+1)*(n-w+1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;



void solve(){

    ll n,r;
    cin >> n >> r;
    if(n>=10) cout << r << endl;
    else cout << r+1000-100*n << endl;

}

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


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
A, B = map(int, input().split())

print(max(A + B, A - B, A * B))

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

int main()
{
	int n, m, a;
	cin>>n>>m;
	for(int i=0; i<m; i++)
	{
		cin>>a;
		n -= a;
	}
	if(n >= 0) cout<<n<<endl;
	else cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll inf=1e12;
const double eps=1e-9;
/*struct Fox
{
    ll x,y,w;
    Fox(ll _x,ll _y,ll _w):x(_x),y(_y),w(_w){}
    bool operator < (const Fox &a)const
    {
        return (abs(a.x-x)<=1 && abs(a.y-y)<=1 );
    }
    
};*/

int main(void)
{
    map<pll,ll> Foxmap;
    int N;
    cin >> N;
    ll ans=0;
    vector<pll> xy(N);
    for(int i=0;i<N;i++)
    {
        ll x,y,w;
        cin >> x >> y>> w;
        Foxmap[pll(x,y)]=w;
        xy[i]=pll(x,y);
    }
    for(int i=0;i<N;i++)
    {
        ll s1=0,s2=0,s3=0,s4=0;
        //各点を中心として,4つの1*1の正方形にして考えると...
        //左上
        s1=Foxmap[pll(xy[i].first,xy[i].second)]+Foxmap[pll(xy[i].first-1LL,xy[i].second)]+Foxmap[pll(xy[i].first-1LL,xy[i].second-1LL)]+Foxmap[pll(xy[i].first,xy[i].second-1LL)];
        //左下
        s2=Foxmap[pll(xy[i].first,xy[i].second)]+Foxmap[pll(xy[i].first-1LL,xy[i].second)]+Foxmap[pll(xy[i].first-1LL,xy[i].second+1LL)]+Foxmap[pll(xy[i].first,xy[i].second+1LL)];
        //右下
        s3=Foxmap[pll(xy[i].first,xy[i].second)]+Foxmap[pll(xy[i].first+1LL,xy[i].second)]+Foxmap[pll(xy[i].first+1LL,xy[i].second+1LL)]+Foxmap[pll(xy[i].first,xy[i].second+1LL)];
        //右上
        s4=Foxmap[pll(xy[i].first,xy[i].second)]+Foxmap[pll(xy[i].first+1LL,xy[i].second)]+Foxmap[pll(xy[i].first+1LL,xy[i].second-1LL)]+Foxmap[pll(xy[i].first,xy[i].second-1LL)];
        //cout << s1 << ' ' << s2 << ' ' << s3 << ' ' << s4 << endl;
        ans=max(ans,s1);
        ans=max(ans,s2);
        ans=max(ans,s3);
        ans=max(ans,s4);
    }
    cout << ans << ' ' << '/' << ' ' << 1 << endl;
}


Measured memory_bytes: 60644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[109],ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if((a[i]&1)&&(i&1))
            ans++;
    }

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


Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(100000000)


def main():
    process()


def process():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if -1 < a < H:
            pass
        else:
            continue
        for b in xrange(j-1, j+2):
            if -1 < b < W:
                pass
            else:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue
            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int mod = 1e9 + 7;

int n, a[100010], cnt;

int main()
{
	gi(n);
	for (int i = 1; i <= n; ++i) gi(a[i]);
	for (int i = 1; i <= n; ++i)
	{
		int j = i, k = i;
		while (j < n && a[j + 1] >= a[j]) ++j;
		while (k < n && a[k + 1] <= a[k]) ++k;
		i = max(j, k);
		++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}

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

int main() {
  int n,x,t;
  cin >> n >> x >> t;
  if(n%x==0){
    cout << (n/x)*t << endl;
  }else{
    cout << (n/x+1)*t << endl;  
  }
}


Measured memory_bytes: 3592
//stringray

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

/*#ifndef __LOCAL__ 
#pragma comment(linker,"/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif*/ 

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ost;

typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<set<int>> vsi;

#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define F first
#define S second
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0)


const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

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;}
template<typename T>
istream& operator >> (istream& is,vector<T>& vec){
  for(T &x:vec)is>>x;
  //for(int i=0;i<vec.size();++i)is>>x[i];
  return is;
}

template<typename T>
ostream& operator << (ostream& os,vector<T>& vec){
  for(int i=0;i<vec.size();++i){
    os<<vec[i]<<(i+1==vec.size()?"":" ");
  }
  return os;
}

ll mpow(ll a, ll b){
  ll ret=1;
  while(b>0){
    if(b&1)ret=(ret*a)%mod;
    (a=a*a)%=mod;
    b>>=1LL;
  }
  return ret;
}

//#define int int64_t
//int a[N+2];
void solve(){
  int l,r;cin>>l>>r;
  if(r-l+1>=2*2019){
    cout<<"0\n";
  }else{
    int ans=2019;
    for(int i=l;i<=r;++i){
      for(int j=i+1;j<=r;++j){
        ans=min(ans,((i%2019)*(j%2019))%2019);
      }
    }
    cout<<ans<<endl;
  }
}
int32_t  main(){
  IOS;
  solve();
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
char s[110];
char t[110];

int main(){
    scanf("%s%s", s, t);
    int len1 = strlen(s);
    int len2 = strlen(t);
    if(len1 != len2){
        printf("No\n");
        return 0;
    }
    else{
        int len = len1;
        if(strcmp(s,t) == 0){
            printf("Yes\n");
            return 0;
        }else{

            for(int i = 1; i < len; ++i){
                char temp[110];
                strcpy(temp, s);
                std::reverse(temp, temp + len - i);
                std::reverse(temp + len - i, temp + len);
                std::reverse(temp, temp + len);
                if(strcmp(temp, t) == 0){
                    printf("Yes\n");
                    return 0;
                }
            }

        }
    }
    printf("No\n");
    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string s;
    cin >> s;

    int i = 0;
    int j = s.size() - 1;

    int ret = 0;
    while(i <= j){
        if(s[i] == 'i' && s[j] != 'i' || s[i] == 'w' && s[j] != 'w' || s[i] == '(' && s[j] != ')' || s[i] == ')' && s[j] != '(')
            ++ ret;
        ++ i;
        -- j;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys


def solve(N: int):
    string = str(N)
    name = int(string[-1])
    if name in [2, 4, 5, 7, 9]:
        print('hon')
    elif name in [0, 1, 6, 8]:
        print('pon')
    else:
        print('bon')
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int a;
int b;
int c;

void input() {
  cin >> a >> b >> c;
}

void solve() {
  set<int> d = {a, b, c};

  string ans = "No";

  if (d.size() == 2) {
    ans = "Yes";
  }

  cout << ans << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    char a, b; cin >> a >> b;
    if(a == 'H'){
        cout << b << endl;
    }else{
        if(b=='H') cout << 'D' << endl;
        else cout << 'H' << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main()
{
	int h,n;
	cin>>h>>n;
	long long a[h+1],sum=0;
	for(int i=0;i<h;i++)cin>>a[i];
	sort(a,a+h);
	for(int i=0;i<h-n;i++)sum+=a[i];
	cout<<sum;
	return 0;
}


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

#define llong long long /*{{{*/
#define ii pair<int, int>
#define xx first
#define yy second
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )

template<typename a> ostream& operator<<(ostream& cout, const vector<a>& b) {
  cout << "[";
  if (len(b)) cout << b[0];
  rep1(i, len(b) - 1) cout << ", " << b[i];
  return cout << "]";
}

template<typename u, typename v> ostream& operator<<(ostream& cout, const pair<u, v> a) {
  return cout << "(" << a.xx <<", " << a.yy << ")";
}/*}}}*/


int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n, t; cin >> n >> t;
  int ans = INT_MAX;
  while (n--) {
    int u, v; cin >> u >> v;
    if (v <= t) ans = min(ans, u);
  }
  if (ans == INT_MAX) cout << "TLE";
  else cout << ans;
  
  return 0;
}


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

namespace ABC163_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] H = Console.ReadLine().Split(' ');
            int N = int.Parse(H[0]);
            int M = int.Parse(H[1]);

            string[] H2 = Console.ReadLine().Split(' ');
            int[] A = new int[M];

            for(int i = 0; i < M; i++)
            {
                A[i] = int.Parse(H2[i]);
            }

            int result = N;

            for (int i = 0; i < M; i++)
            {
                result -= A[i];
                if (result < 0) result = -1;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28348
#include <bits/stdc++.h>
#include <algorithm>
typedef long long int lli;
using namespace std;
 int main(){
    string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;

     return 0;
 }


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		
		System.out.println((m - 1) * (n - 1));
			
		
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21332