akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

// デバッグを消し忘れるな！！！


int main() {
    ll n; cin >> n;
    Vl a(n);
    ll mx = 0;
    rep(i, 0, n){ cin >> a[i]; chmax(mx, a[i]);};
    set<ll> s, t;
    rep(i, 0, n){
        ll bf = sz(s);
        s.insert(a[i]);
        if(sz(s) == bf) t.insert(a[i]);
    }
    Vl table(mx+1, false);
    for(auto it : s){
        for(int i = 2*it; i <= mx; i += it) table[i] = true;
    }
    ll ans = 0;
    for(auto it : t) table[it] = true;
    rep(i, 0, n) if(!table[a[i]]) ans++;
    co(ans);

    return 0;
}


Measured memory_bytes: 21888
cnt = 0
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

if __name__ == '__main__':
    array = list(get_input())
    for i in range(len(array)):
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if a+b+c+d == int(array[i]):
                            cnt += 1
        print(cnt)
        cnt = 0
        
    

Measured memory_bytes: 7664
#include <iostream>
using namespace std;
int house[5][4][11]={{{0}}};
int main(void){
    int n,b,f,r,v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        house[b][f][r]=house[b][f][r]+v;
    }
     
    for(int i=1;i<=4;i++){
         
        for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                cout << ' ' << house[i][j][k];
            }
            cout << endl;
        }
         
        if(i == 4){
             
        }
        else{
            for(int j=0;j<20;j++){
             cout << "#";   
            }
            cout << endl;
        }
         
    }
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>

using namespace std;
int main(){
    int i;
    string str;
    getline(cin,str);   
    for(i=0; str[i]!=0; i++){ //文字列が終わるまで一つずつ繰り返す
        if('a' <= str[i] && str[i] <= 'z'){
        str[i] = str[i] - 32;
        //strのi番目が'a'と'z'の数字の間であれば-32する
       }else if('A'<= str[i] && str[i] <='Z' ){
        str[i] = str[i] + 32;
        //strのi番目が'A'と'Z'の数字の間であれば+32する。
       }
    }
    cout << str << endl;
}



Measured memory_bytes: 3136
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();

		if (A <= B) {
			for (int i = 1; i <= B; i++) {
				if (A % i == 0) {
					if (B % i == 0) {
						list.add(i);
					}
				}
			}
		} else {
			for (int i = 1; i <= A; i++) {
				if (A % i == 0) {
					if (B % i == 0) {
						list.add(i);
					}

				}
			}
		}

		System.out.println(list.get(list.size() - K));

	}

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  ll a,v; cin >> a >> v;
  ll b,w; cin >> b >> w;
  ll t; cin >> t;
  if(abs(a-b)<=t*(v-w)) cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s; cin >> s;
  int size = (int)s.size();
  for(int i=0;i<size;i++) cout << 'x';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 * 2;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int out = 0;
	rep(i, n - 1){
		if(a[i] == a[i + 1]){
			out++;
			a[i + 1] = -1;
		}
	}
	cout << out << endl;
}


Measured memory_bytes: 3628
import itertools as itr

num = int(input())

a = ['0', '3', '5', '7']
b = ['0', '3', '5', '7']
c = ['0', '3', '5', '7']
d = ['0', '3', '5', '7']
e = ['0', '3', '5', '7']
f = ['0', '3', '5', '7']
g = ['0', '3', '5', '7']
h = ['0', '3', '5', '7']
i = ['0', '3', '5', '7']

cnt = 0
for j,k,l,m,n,o,p,q,r in itr.product(a,b,c,d,e,f,g,h,i):
    num2 = int(j+k+l+m+n+o+p+q+r)
    num2 = str(num2)
    if '0' not in num2:
        if '3' in num2 and '5' in num2 and '7' in num2:
            num2 = int(num2)
            if num >= num2:
                cnt += 1

print(cnt)

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll n;
    string ss;
    cin >> n >> ss;
    vector<ll> lf(n+3, 0), rt(n+3, 0), vl(n+3, 0), vr(n+3, 0);
    for(ll i = 0; i < ss.size(); i++)
    {

        ll idx = i+1;
        if(ss[i] == 'W') vl[idx] = 1;
        else vr[idx] = 1;
    }
    for(ll i = 1; i <= n; i++) lf[i] = lf[i-1]+vl[i];
    for(ll i = 1; i <= n; i++) rt[i] = rt[i-1]+vr[i];
    ll ans = inf;
    for(ll i = 1; i <= n; i++)
    {

        ll xx = lf[i-1]+rt[n]-rt[i];
        ans = min(ans,xx);
    }
    cout << ans;
}


Measured memory_bytes: 9988
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll d;
ll c[29];
ll a[369][29];
ll t[369];
ll b[29];

int main()
{
    scanf("%lld", &d);
    for(ll i = 1; i <= 26; i++)
    {
        scanf("%lld", &c[i]);
    }
    for(ll i = 1; i <= d; i++)
    {
        for(ll j = 1; j <= 26; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= d; i++)
    {
        scanf("%lld", &t[i]);
        for(ll j = 1; j <= 26; j++)
        {
            if(j != t[i]) b[j]++;
            else b[j] = 0;
            ans -= b[j] * c[j];
        }
        ans += a[i][t[i]];
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 3788
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define INF 0x3f3f3f3f
#define MAXN 10
int main(){
	int n=read(),s=0,x,Max=0;
	for(int i=1;i<=n;i++)
		x=read(),s+=x,Max=max(Max,x);
	printf("%d\n",s-Max+Max/2);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sn = new Scanner(System.in);
		int A = Integer.parseInt(sn.next());
		int B = Integer.parseInt(sn.next());
		sn.close();

		double hati;
		double juu;

		hati = A / 0.08;
		juu = B / 0.1;

		double kekka;

		if(hati == juu) {
			if(hati == 0) {
				kekka = -1;
			}else {
				kekka = hati;
			}
		}else if(hati < juu) {
			if((A+1) / 0.08 > juu) {
				kekka = juu;
			}else {
				kekka = -1;
			}
		}else {
			if((B+1) / 0.1 > hati) {
				kekka = hati;
			}else {
				kekka = -1;
			}

		}

		System.out.println((int)Math.round(kekka));

	}

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define   ll long long int

int main(){

string s;
cin>>s;
int ans=0;
for(auto x:s){
    ans+=x-'0';
}
if(ans%9==0)
    cout<<"Yes";
else
    cout<<"No";

}


Measured memory_bytes: 3748
#include <cstdio>

const int N = 100;
const int INF = 10000001;
int cost[N][N];
int minCost[N] = {0};
bool isDecide[N] = {false};

int getMinIndex(int n) {
        int minIndex = -1;
        int cost = INF;
        for (int i = 0; i < n; i++) {
                if (minCost[i] < cost && !isDecide[i]) {
                        cost = minCost[i];
                        minIndex = i;
                }
        }

        return minIndex;
}

int main() {
        for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                        cost[i][j] = -1;
                }
        }
        for (int i = 1; i < N; i++) {
                minCost[i] = INF;
        }
        int n, u, k, v, c;

        scanf("%d", &n);
        for (int i = 0; i < n; i++) {
                scanf("%d %d", &u, &k);
                for (int j = 0; j < k; j++) {
                        scanf("%d %d", &v, &c);
                        cost[u][v] = c;
                }
        }
        while (true) {
                int from = getMinIndex(n);
                if (from < 0) {
                        break;
                }
                isDecide[from] = true;
                for (int to = 0; to < n; to++) {
                        if (cost[from][to] < 0 || isDecide[to]) {
                                continue;
                        }
                        int newCost = minCost[from] + cost[from][to];
                        if (newCost < minCost[to]) {
                                minCost[to] = newCost;
                        }
                }
        }
        for (int i = 0; i < n; i++) {
                printf("%d %d\n", i, minCost[i]);
        }

        return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int a[200010];
bool s[200010];
bool f[200010];
set<pii> st;

bool ok(int x)
{
	st.clear();

	rep(i, N*2-1) {
		s[i] = (a[i] >= x);
	}

	for (int i = 1; i < N*2-2; ++i) {
		f[i] = (s[i] != s[i-1] && s[i] != s[i+1]);
	}

	int l = -1;
	for (int i = 1; i < N*2-2; ++i) {
		if (f[i]) {
			if (l == -1) {
				l = i;
			}
		} else {
			if (l != -1) {
				st.insert(mp(l, i-1));
			}
			l = -1;
		}
	}
	if (l != -1) st.insert(mp(l, N*2-2));


	// for (pii p : st) {
	// 	cout<<p.fi<<" "<<p.se<<endl;
	// }

	for (int i = 1; i < N; ++i) {
		set<pii> nx;
		/*
		for (pii p : st) {
			cout<<p.fi<<" "<<p.se<<endl;
		}*/

		for (auto it = st.begin(); it != st.end(); ++it) {
			int l = it->fi, r = it->se;
			bool sl = s[l] ^ (i & 1);
			bool sr = s[r] ^ (i & 1);
			if (sl == s[l-1]) {
				s[l] = s[l-1];
				++l;
			}
			if (sr == s[r+1]) {
				s[r] = s[r+1];
				--r;
			}

			if (l <= r) {
				if (l == i) {
					s[l] = s[l] ^ (i & 1);
					++l;
				}

				if (l <= r && r == N-1-i) {
					s[r] = s[r] ^ (i & 1);
					--r;
				}

				if (l <= r) nx.insert(mp(l, r));
			}
		}

		st.swap(nx);
/*
		st.clear();
		for (pii p : nx) {
			st.insert(p);
		}*/
	}

	return s[N-1];
}

int main() {
	scanf("%d", &N);
	rep(i, N*2-1) scanf("%d", &a[i]);
	
	int lo = 1, hi = N*2-1;
	
	while (hi - lo > 1) {
		int m = (lo + hi) / 2;
		if (ok(m)) lo = m;
		else hi = m;
	}
	/*
	cout << ok(7) << endl;;

	for (int i = 1; i <= N*2-1; ++i) {
		cout << i << " " << (int)ok(i) << endl;
	}*/

	printf("%d\n", lo);

	return 0;
}

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

int main()
{
    string S;
    size_t w;
    cin >> S;
    cin >> w;
    string solution;
    for(size_t i = 0; i<S.size(); i++){
        if(i%w==0) solution+=S.at(i);
    }
    cout<<solution<<endl;
    return 0;
}

Measured memory_bytes: 256
# ABC 060
# 基本
import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def getIntFromRows(n): return [int(input()) for i in range(n)]
def getIntMat(n):
    mat = []
    for i in range(n): mat.append(getIntList())
    return mat

def zeros(n): return [0 for i in range(n)]
def zeros2(n, m): return [[0 for i in range(m)] for j in range(n)]
N1097 = 10**9 + 7 

debug = True
def db(x): 
    if debug: print(x)
debug = False

a,b,c = getIntList()
rm = a % b
rslt = 'NO'
for i in range(b+1):
    if a%b==c:
        rslt = 'YES'
        break
    a += rm
db(a)
print(rslt)
        

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int x,a,b,c,i,j,k,s=0;
	scanf("%d %d %d %d",&a,&b,&c,&x);
	for(i=0;i<=a;i++)
	{
		if(i*500<=x)
		{
		    for(j=0;j<=b;j++)
		    {
		    	if(i*500+j*100<=x)
                {
			        for(k=0;k<=c;k++)
			        {
			    	    if(i*500+j*100+k*50==x)
			    	    {
			    	    	s++;
						}
			    	}
		        }
	        }
	    } 
	}
	printf("%d",s);
	return 0;
} 

Measured memory_bytes: 128
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
MOD = 1000000007


class FactInv:
    def __init__(self, N, MOD=1000000007):
        fact = [1]*(N+1)
        for i in range(1, N+1):
            fact[i] = fact[i - 1] * i % MOD

        inv = [None]*(N+1)
        inv[N] = pow(fact[N], MOD - 2, MOD)

        for i in range(N)[::-1]:
            inv[i] = inv[i + 1] * (i + 1) % MOD

        self.N = N
        self.MOD = MOD
        self.fact = fact
        self.inv = inv

    def perm(self, a, b):
        if a > self.N or b > self.N:
            raise ValueError(
                "\nPermutaion arguments are bigger than N\n N = {}, a = {}, b = {}".format(self.N, a, b))
        return self.fact[a] * self.inv[a-b] % self.MOD

    def comb(self, a, b):
        if a > self.N or b > self.N:
            raise ValueError(
                "\nCombination arguments are bigger than N\n N = {}, a = {}, b = {}".format(self.N, a, b))
        return self.fact[a] * self.inv[b] * self.inv[a-b] % self.MOD


def main():
    K = I()
    l = len(S())

    fi = FactInv(K + l + 1)

    ans = 0

    for x in range(K+1):
        ans += fi.comb(l + K - x - 1, l - 1) * \
            pow(25, K - x, MOD) * pow(26, x, MOD) % MOD
        ans %= MOD

    print(ans)


main()


Measured memory_bytes: 185240
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/










int H, W; string S[404];
//---------------------------------------------------------------------------------------------------
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
int vis[404][404];
pair<ll, ll> dfs(int x, int y) {
    vis[y][x] = 1;

    ll a = 1, b = 0;
    rep(i, 0, 4) {
        int xx = x + dx[i];
        int yy = y + dy[i];
        if (xx < 0 or W <= xx or yy < 0 or H <= yy) continue;
        if (vis[yy][xx]) continue;
        if (S[y][x] != S[yy][xx]) {
            auto p = dfs(xx, yy);
            a += p.second;
            b += p.first;
        }
    }

    return { a, b };
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W;
    rep(y, 0, H) cin >> S[y];

    ll ans = 0;
    rep(y, 0, H) rep(x, 0, W) if (!vis[y][x]) {
        auto p = dfs(x, y);
        ans += p.first * p.second;
    }
    cout << ans << endl;
}

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

int main(){
  string s,t;
  //char t[12];
  cin >> s >> t;
  
  string x = t.erase(t.size() - 1);
  
  if (s==x) cout << "Yes" << endl;
  else  cout << "No" << endl;
}


Measured memory_bytes: 3600
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    a = LS()
    f = True
    for i in range(1,3):
        if a[i][0] != a[i-1][-1]:
            f = False
            break

    if f:
        return 'YES'

    return 'NO'


print(main())


Measured memory_bytes: 6732
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
t = STR()
ans = list(deepcopy(s))
i = len(s) - len(t)
while i >= 0:
    flag = True
    for j in range(len(t)):
        if s[i + j] != '?' and s[i + j] != t[j]:
            flag = False
    if flag:
        ans[i:i + len(t)] = list(t)
        break
    i -= 1
if ''.join(ans) == s and '?' in s:
    print('UNRESTORABLE')
    exit()
for i in range(len(ans)):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))

Measured memory_bytes: 5196
x_1,y_1,x_2,y_2 =map(int, input().split())
X = x_2-x_1
Y = y_2-y_1

x_4 = -Y + x_1
y_4 = X + y_1

x_3 = x_4 - x_1 +  x_2
y_3 = y_4 - y_1  + y_2

print(x_3,y_3,x_4,y_4)

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,t;
    cin >> n >> t;
    vector<int> a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    vector<int> dp(t,0),dq(t,0);
    rep(i,n){
        per(j,t-1){
            dq[j]=max(dq[j],dp[j]+b[i]);
          	if(j>=a[i]){
            	dp[j]=max(dp[j],dp[j-a[i]]+b[i]);
                dq[j]=max(dq[j],dq[j-a[i]]+b[i]);
            }
        }
    }
    cout << max(dp[t-1],dq[t-1]) << endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 105;

int n, W;

int main() {
	
	FAST;
	
	cin >> n >> W;
	vector <int> v(n + 1), w(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> w[i] >> v[i];
	}
	vector <intt> dp(W + 1, 0);
	dp[0] = 0;
	for (int k = 1; k <= n; k ++) {
		for (int x = W; x >= 0; x --) {
			if (x - w[k] >= 0) {
				dp[x] = max(dp[x], v[k] + dp[x - w[k]]);
			}
		}
	}
	cout << dp[W] << '\n';
	return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


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

	int N, M;
	cin >> N >> M;
	vector<int> C(N), D(M);
	FOR(i, 0, N) {
	    cin >> C[i];
	}
	FOR(i, 0, M) {
	    cin >> D[i];
	}

	VV<LL> dp(M + 10, V<LL>(N + 10, INF));
	dp[0][0] = 0;

	FOR(i, 0, M) {
	    FOR(j, 0, N) {
	        if (dp[i][j] == INF) {
                continue;
	        }
	        // stop
	        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);

	        // go
	        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + C[j] * D[i]);
	    }
	}

	LL ans = INF;
	FOR(i, 0, M + 1) {
	    ans = min(ans, dp[i][N]);
	}
	print(ans);

	return 0;
}


Measured memory_bytes: 9452
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i,N) for(int i=0;i<((int)N);i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int main(void){
  long N; cin>>N;
  long a[N];
  for(int i=0;i<N;i++){
      cin>>a[i];
  }
  long sum=0; long ansa=0;
  for(int i=0;i<N;i++){
    sum+=a[i];
    if(i%2==0){
        if(sum<=0){ansa+=1-sum; sum=1;}
    }
    else{
        if(sum>=0){ansa+=sum+1; sum=-1;}
    }
  }
  sum=0; long ansb=0;
  for(int i=0;i<N;i++){
      sum+=a[i];
      if(i%2==1){
          if(sum<=0){ansb+=1-sum; sum=1;}
      }
      else{
          if(sum>=0){ansb+=sum+1; sum=-1;}
      }
  }
  if(ansa>ansb) cout<<ansb;
  else cout<<ansa;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
#define P(a,b) make_pair(a,b);
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

string K;

ll d(string S){
  ll res = 0;
  rep(i,S.size()) res += ll(S[i] - '0');
  return res;
}

ll dp[1000010][2];

int main(){
  cin >> K;
  reverse(ALL(K));
  K += '0';
  ll N = K.size();
  rep(i,N+1) rep(j,2) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i,N){
    ll n = K[i] - '0';
    rep(j,2){
      n += j;
      if(n < 10) dp[i+1][0] = min(dp[i+1][0],dp[i][j]+n);
      if(n > 0) dp[i+1][1] = min(dp[i+1][1],dp[i][j]+(10 - n));
    }
  }
  cout << dp[N][0] << endl;
}


Measured memory_bytes: 17028
import math


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    M = max(A) + 1
    C = [0 for i in range(M)]
    for a in A:
        C[a] += 1

    pairwise = True
    for i in range(2, M):
        cnt = 0
        for j in range(i, M, i):
            cnt += C[j]

        if cnt > 1:
            pairwise = False

    if pairwise:
        print("pairwise coprime")
        return

    g = 0
    for i in range(n):
        g = math.gcd(g, A[i])

    if g == 1:
        print("setwise coprime")
        return

    print("not coprime")

resolve()

Measured memory_bytes: 126756
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        string S=Console.ReadLine();
        Console.WriteLine(F(S));
    }
    static int IsYYMM(string s)
    {
        int b, e;
        b = (s[0] - '0') * 10 + (s[1] - '0');
        e = (s[2] - '0') * 10 + (s[3] - '0');

        if (1 <= e && e <= 12)
            return 1;
        else
            return 0;

    }
    static int IsMMYY(string s)
    {
        int b, e;
        b = (s[0] - '0') * 10 + (s[1] - '0');
        e = (s[2] - '0') * 10 + (s[3] - '0');

        if (1 <= b && b <= 12)
            return 2;
        else
            return 0;

    }
    static string F(string s)
    {
        switch (IsMMYY(s) + IsYYMM(s))
        {
            case 0:
                return "NA";
            case 1:
                return "YYMM";
            case 2:
                return "MMYY";
            case 3:
                return "AMBIGUOUS";
        }
        return "";
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
int main(){
    int X;
    cin >> X;

    if(X==3 || X==5 || X==7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define    ll   long long int
#define    sz   200010
#define    md   1000000007
using namespace std;


ll ara[sz];


int main()
{

    ll a,b,n,x,y,p,d,k,i,j,m,mx=0,c=0;

    cin>>a>>b;

    x=__gcd(a,b);

    if(x%2==0)
    {
        c++;
        while(x%2==0)
        {
            x/=2;
        }
    }

    for(i=3; i<=sqrt(x); i+=2)
    {
        if(x%i==0)
        {
            c++;
            while(x%i==0)
            {
                x/=i;
            }
        }
    }

    if(x!=1)c++;

    cout<<c+1<<endl;



    return 0;
}


Measured memory_bytes: 256
N, a, b=(int(i) for i in input().split())
import math
p = 10 ** 9 + 7
def binary(n):
    return bin(n)[2:]

# バイナリ法
def pow_by_binary_exponentiation(k, x, n): # a^x mod n
    x = [int(l) for l in binary(x)]
    y = k
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * k) % n
    return y

ans=(pow_by_binary_exponentiation(2,N,p)-1)
combA=1
combB=1
for i in range(a):
    combA*=(N-i)
    combA%=p
for i in range(b):
    combB*=(N-i)
    combB%=p

print((ans - combA*pow_by_binary_exponentiation(math.factorial(a), p-2, p) - combB*pow_by_binary_exponentiation(math.factorial(b), p-2,p))%p)

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


//int dp[101][4][4][4];
vector<vector<vector<vector<int>>>> dp(101, vector<vector<vector<int>>>(4, vector<vector<int>>(4, vector<int>(4))));

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

	dp[0][3][3][3] = 1;
	int mod = 1e9 + 7;

	//文字列の文字数
	for (int len = 0; len < N; len++)
	{
		//最後から1文字目の文字
		for (int c1 = 0; c1 < 4; c1++)
		{
			//最後から2文字目の文字
			for (int c2 = 0; c2 < 4; c2++)
			{
				//最後から3文字目の文字
				for (int c3 = 0; c3 < 4; c3++)
				{
					//条件に当てはまるものがない場合はcontinue;
					if (dp[len][c1][c2][c3] == 0) continue;

					//新しく追加する文字
					for (int a = 0; a < 4; a++)
					{
						//ダメな5つの条件をカットする
						if (a == 2 && c1 == 1 && c2 == 0) continue;
						if (a == 2 && c1 == 0 && c2 == 1) continue;
						if (a == 1 && c1 == 2 && c2 == 0) continue;
						if (a == 2 && c1 == 1 && c3 == 0) continue;
						if (a == 2 && c2 == 1 && c3 == 0) continue;

						//ダメな条件を抜けたら、aを足した文字列が作れる

						// S = ...... c3 c2 c1
						// nextS = ...... c2 c1 a

						dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
						dp[len + 1][a][c1][c2] %= mod;
					}
				}
			}
		}
	}

	int ans = 0;

	//長さNの全部の答えを纏める
	//最後から1文字目の文字
	for (int c1 = 0; c1 < 4; c1++)
	{
		//最後から2文字目の文字
		for (int c2 = 0; c2 < 4; c2++)
		{
			//最後から3文字目の文字
			for (int c3 = 0; c3 < 4; c3++)
			{
				ans += dp[N][c1][c2][c3];
				ans %= mod;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int p,q,r; cin>>p>>q>>r;
    cout<<min(p+q,min(q+r,r+p))<<endl;

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

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

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

int n, m, ax, ay, bx, by;
vector<string> b;

bool chk(int x, int y){
    return x >= 0 && y >= 0 && x < n && y < m;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> ax >> ay >> bx >> by;
    ax--, ay--, bx--, by--;
    for(int i = 0; i < n; ++i){
        string s; cin >> s;
        b.pb(s);
    }
    queue<pair<int, int>> q1, q2;
    vector<vector<int>> vis(n, vector<int>(m, -1));
    q1.push({ax, ay}), vis[ax][ay] = 0;
    while(!q1.empty() || !q2.empty()){
        while(!q1.empty()){
            auto [x, y] = q1.front(); q2.push(q1.front()); q1.pop();
            for(int i = 0; i < 4; ++i){
                int nx = x + dx[i], ny = y + dy[i];
                if(chk(nx, ny) && vis[nx][ny] == -1 && b[nx][ny] != '#'){
                    vis[nx][ny] = vis[x][y];
                    q1.push({nx, ny});
                }
            }
        }
        while(!q2.empty()){
            auto [x, y] = q2.front(); q2.pop();            
            for(int i = -2; i <= 2; ++i){
                for(int j = -2; j <= 2; ++j){
                    if(chk(x + i, y + j) && vis[x + i][y + j] == -1 && b[x + i][y + j] != '#'){
                        vis[x + i][y + j] = vis[x][y] + 1;
                        q1.push({x + i, y + j});
                    }
                }
            }
        }
    }
    cout << vis[bx][by];
    return 0;
}

Measured memory_bytes: 8668
#include <iostream>

using namespace std;

int main()
{
    int A,B;
    char op;
    
    cin >> A >> op >> B;
    
    switch (op){
        case '+':
        cout << A+B << endl;
        break;
        case '-':
        cout << A-B << endl;
        break;
    }


    return 0;
}


Measured memory_bytes: 636
#include<stdio.h>
#define S 100000
#define T 50000
int main(){
  int s[S],t[T],n,q,i,j=0,count=0,k,r,l,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
   scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }
  for(i=0;i<q;i++){
    k=t[i];
    l=0;
    r=n;
    while(1){
      m=(l+r)/2;
      if(s[m]==k){
	count++;
	break;
      }
      else if(s[m]<k){
	l=m+1;
      }
      else if(s[m]>k){
	r=m-1;
      }
      if(r<l){
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
s = input()[::-1]
i = 0

while i < len(s):
    if s[i:i+5] == 'maerd' or s[i:i+5] == 'esare':
        i += 5
    elif s[i:i+6] == 'resare':
        i += 6
    elif s[i:i+7] == 'remaerd':
        i += 7
    else:
        break

print('YES' if i == len(s) else 'NO')

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int main()
{
    char a, b;
    cin >> a >> b;
    if (a == 'H')
    {
        cout << b << endl;
    }
    else if (b == 'H')
    {
        cout << 'D' << endl;
    }
    else
    {
        cout << 'H' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))

const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);


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

    cout<<x+y/2<<"\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007



int main(){
  ll a,b;
  ll buc[4]={0};
  rep(i,3){
    cin >> a >> b;
    buc[a-1]++;
    buc[b-1]++;
  }
  ll res=1;
  bool hantei=true;
  rep(i,4){
    if(buc[i]>=3){
      cout << "NO" << endl;
      hantei=false;
      break;
    }
    res*=buc[i];
  }
  if(res==0){
    cout << "NO" << endl;
    hantei=false;
  }
  if(hantei)cout << "YES" <<endl;
}


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

int main(){
  string N;
  cin>>N;
  int c1=N.at(0)-'0';
  int c2=N.at(1)-'0';
  int c3=N.at(2)-'0';
  int c=c1*100+c2*10+c3;
  int d1=c1*100+c1*10+c1;
  int d2=(c1+1)*100+(c1+1)*10+(c1+1);
  if(d1-c<0||d1-c>d2-c)cout<<d2<<endl;
  else cout<<d1<<endl;
}


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

struct P {
    int time;
    int id;
    
    bool operator <(const P &another) {return time < another.time;}
};

bool is_ok(int s, const vector<P> &p) {
    int len = (int)p.size();
    {
        vector<bool> done(len / 2);
        done.at(p.at(0).id) = true;
        int before = p.at(0).time;
        for (int i = 1; i < len; i++) {
            if (done.at(p.at(i).id)) continue;

            if (p.at(i).time - before >= s) {
                done.at(p.at(i).id) = true;
                before = p.at(i).time;
            }
        }

        bool ok = true;
        for (int i = 0; i < len / 2; i++) {
            if (!done.at(i)) {
                ok = false;
                break;
            }
        }
        if (ok) return true;
    }

    {
        vector<bool> done(len / 2);
        done.at(len / 2 - 1) = true;
        int before = len / 2 - 1;
        for (int i = len / 2 - 2; i >= 0; i--) {
            if (done.at(p.at(i).id)) continue;

            if (before - p.at(i).time >= s) {
                done.at(p.at(i).id) = true;
                before = p.at(i).time;
            }
        }

        bool ok = true;
        for (int i = 0; i < len / 2; i++) {
            if (!done.at(i)) {
                ok = false;
                break;
            }
        }
        if (ok) return true;
    }

    return false;
}

int main() {
    int n;
    cin >> n;
    vector<P> p;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        p.push_back(P{d, i});
        p.push_back(P{24 - d, i});
    }
    sort(p.begin(), p.end());

    for (int s = p.at(0).time; s >= 0; s--) {
        if (is_ok(s, p)) {
            cout << s << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string S, T;
  cin >> S >> T;
  
  int answer = 0;

  for (int i = 0; i < 3; i++) {
    if (S[i] == T[i]) {
      answer++;
    }
  }
  
  cout << answer << endl;

}

Measured memory_bytes: 256
from sys import stdin


def main():
    h, w = map(int, input().split())
    a = [next_str() for _ in range(h)]
    ans = [a[i - 1] if 0 < i <= h else "#" * w for i in range(h + 2)]
    print("\n".join(map(lambda x: "#{}#".format(x), ans)))


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        double[] A = new double[N];
        for (int i = 0; i < N; i++) {
            A[i] = Double.parseDouble(sc.next());
        }

        double d = 0;
        for (int i = 0; i < N; i++) {
            d += 1d / A[i];
        }
        System.out.println(1d / d);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
// 对于 x + y = 2^i 来说，如果 x < y 且 2^i-1 < y < 2^i
// 那么 x 唯一
// 转换成树结构：根节点是 y 它的父亲 x 唯一
// 即求整个森林中最多的无公共端点的边的数量
using namespace std;
const int maxn = 200005, inf = 1e9;
int n, a;
map<int, int> mp; // map 自动排序 使得能够从叶子结点往上找边
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		mp[a]++;
	}
	int res = 0;
	while (!mp.empty()) {
		map<int, int>::iterator it = mp.end();
		it--;
		int y = it->first;
		mp[y]--;
		if (mp[y] == 0) mp.erase(y);
		int i = 1;
		while (i <= y) i *= 2;
		// 求出最小的那个大于 y 的二次幂数
		int x = i - y;
		if (mp.find(x) != mp.end()) {
			res++;
			mp[x]--;
			if (mp[x] == 0) mp.erase(x);
		}
	}
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 13172
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// dp[i][j] := A の物質量が i、B の物質量が j の時のコスト最小
int dp[410][410];
int N, Ma, Mb, a, b, c;

signed main() {
    rep(i,0,410) rep(j,0,410) dp[i][j] = INF;
    dp[0][0] = 0;

    cin >> N >> Ma >> Mb;
    int ans = INF;
    rep(i,0,N) {
        cin >> a >> b >> c;
        repr(j,400,0) repr(k,400,0) {
            if(j-a < 0 || k-b < 0) continue;
            chmin(dp[j][k], dp[j-a][k-b] + c);
            if(j != 0 && k != 0 && j*Mb == k*Ma) chmin(ans, dp[j][k]);
        }
    }
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}

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

int main() {
  int A, B, C, D, E, X;
  cin >> A >> B >> C >> D >> E >> X;
  
  
  if ((E - A) <= X){
    cout << "Yay!" << endl;
  }
  else {
    cout << ":( " << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=0;
deque<int> d;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		d.push_back(x);
	}
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(i+j>k)
				continue;
			int u=k-i-j;
			vector<int> hand;
			deque<int> tmp=d;
			for(int l=0;l<i&&tmp.size();l++)
			{
				hand.push_back(tmp[0]);
				tmp.pop_front();
			}
			for(int l=0;l<j&&tmp.size();l++)
			{
				hand.push_back(tmp[tmp.size()-1]);
				tmp.pop_back();
			}
			int sum=0;
			for(int l=0;l<hand.size();l++)
				sum+=hand[l];
			sort(hand.begin(),hand.end());
			for(int l=0;l<u;l++) 
			{
				if(l>=hand.size())
					break;
				if(hand[l]>=0)
					break;
				sum-=hand[l];
			}
			ans=max(ans,sum);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
	string s,sf,sb,tp;
	cin>>s;
	int q,t,f;bool rev=false;
	cin>>q;char c;
	deque <char> dq(s.begin(),s.end());
	while(q--)
	{
		cin>>t;
		if(t==1)rev=!rev;
		else
		{
			cin>>f>>c;
			if((f==1&&!rev)||(f==2&&rev))
			{
				dq.push_front(c);
			}
			else
			{
				dq.push_back(c);
			}
		}
	}
	if(rev)
	for(auto it=dq.rbegin();it!=dq.rend();it++)cout<<*it;
	else
	for(auto it=dq.begin();it!=dq.end();it++)cout<<*it;
}

Measured memory_bytes: 896
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint cani[1000010];
mint canj[1000010];
mint scan[1000010];

int main(){
  itn n,m; cin >> n >> m;
  rep(i,n){
    itn a; cin >> a; a--;
    cani[a]+=1;
    if(cani[a].x>1){
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i,m){
    itn b; cin >> b; b--;
    canj[b]+=1;
    if(canj[b].x>1){
      cout << 0 << endl;
      return 0;
    }
  }
  vector<mint> scani(n*m);
  scani[n*m-1]=cani[n*m-1];
  for(int i=n*m-1;i>0;i--) scani[i-1]=scani[i]+cani[i-1];
  vector<mint> scanj(n*m);
  scanj[n*m-1]=canj[n*m-1];
  for(int i=n*m-1;i>0;i--) scanj[i-1]=scanj[i]+canj[i-1];
  mint ans=1;
  rrep(i,n*m){
    if(cani[i].x>0&&canj[i].x>0) scan[i]=cani[i]*canj[i];
    else if(cani[i].x>0) scan[i]=cani[i]*scanj[i];
    else if(canj[i].x>0) scan[i]=scani[i]*canj[i];
    else scan[i]=scani[i]*scanj[i]-(n*m-1-i);
  }
  rrep(i,n*m) ans=ans*scan[i];
  cout << ans << endl;
}

Measured memory_bytes: 42308
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  int ans = 1e3;
  REP(i,s.size()-2){
    int x = stoi(s.substr(i,3));
    ans = min(ans, abs(753-x));
  }
  cout << ans << endl; 

}


Measured memory_bytes: 256