akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;


int main() {
    int x,y,z;
    string S;

    cin >> x >> y >> z;
    
    cout << z << "  "<< x << "  " << y;
    //printf("%.15lf", ans);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  vi t(1001), v(1001);
  while (getline(cin, s), s.size()) {
    int c, d;
    char gomi;
    istringstream(s) >> c >> gomi >> d;
    t[c]++;
    v[c] = 1;
  }
  while (getline(cin, s)) {
    int c, d;
    char gomi;
    istringstream(s) >> c >> gomi >> d;
    t[c]++;
    if (v[c] == 1) v[c] = 2;
  }
  rep(i, v.size()) if (v[i] == 2) {
    cout << i << ' ' << t[i] << endl;
  }
}

Measured memory_bytes: 3104
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

map<ll,ll> pfmp; //各素因数の冪指数の最大値を格納
vector<ll> pfv(0); //異なる素因数を昇順に格納

void pf(ll N){
  ll n=N;
  if(n<=0) return;
  ll exp;
  if(n%2==0){
    if(pfmp[2]==0) pfv.push_back(2);
    exp=0;
    while(n%2==0){
      n/=2;
      exp++;
    }
    if(exp>pfmp[2]) pfmp[2]=exp;
  }
  if(n==1) return;
  for(ll i=3;i<=sqrt(N);i+=2){
    if(n%i==0){
      if(pfmp[i]==0) pfv.push_back(i);
      exp=0;
      while(n%i==0){
        n/=i;
        exp++;
      }
      if(exp>pfmp[i]) pfmp[i]=exp;
    }
  }
  if(n!=1){
    if(pfmp[n]==0){
      pfv.push_back(n);
      pfmp[n]=1;
    }
  }
  //sort(all(pfv));
}

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%mod;
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

ll modinv(ll a,ll m){
  ll b=m,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=m;
  if(u<0) u+=m;
  return u;
}

int main(){
  int N; cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  rep(i,N){
    pf(a[i]);
  }
  sort(all(pfv));
  ll lcm=1;
  rep(i,pfv.size()){
    lcm*=rui(pfv[i],pfmp[pfv[i]]);
    lcm%=mod;
  }
  ll ans=0;
  rep(i,N){
    ans+=lcm*modinv(a[i],mod);
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
  public static void main(String[]args){
    int pos=-1;
    Scanner sc=new Scanner(System.in);
    int[] a=new int[5];
    for(int i=0;i<5;i++){
      a[i]=sc.nextInt();
      if(a[i]==0)
        pos=i;
    }
    System.out.println(pos+1);
  }
}


Measured memory_bytes: 27084
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long x; cin >> x;
    long long sum = 100;
    for (int i = 1; i < INT_MAX; i++) {
        sum += sum / 100;
        if (sum >= x) {
            cout << i << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int ans = 0;

		for (int i=1; i<=n; i+=2){
			int divisor = 0;
			for (int j=1; j<=i; j++){
				if (i % j == 0){
					divisor++;
				}
			}
			if (divisor == 8){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
int main()
{
	ll N;
	vector<ll>V(4,0);
	cin>>N;
	rep(i,N){
		string s;
		cin>>s;
		if(s=="AC")V[0]++;
		if(s=="WA")V[1]++;
		if(s=="TLE")V[2]++;
		if(s=="RE")V[3]++;
	}
	cout<<"AC x "<<V[0]<<endl;
	cout<<"WA x "<<V[1]<<endl;
	cout<<"TLE x "<<V[2]<<endl;
	cout<<"RE x "<<V[3]<<endl;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 2e5 + 1;

vi tree[MAXN];
int par[MAXN];
int firstMax[MAXN], secondMax[MAXN];
int firstReach[MAXN], secondReach[MAXN];
bool beatSecondMax[MAXN];
int afterFirstMax[MAXN];

void dfs1(int loc) {
    if (loc == 0 || loc > firstMax[par[loc]]) {
        firstMax[loc] = loc;
        secondMax[loc] = loc ? firstMax[par[loc]] : -1;
        beatSecondMax[loc] = false;
        afterFirstMax[loc] = -1;
    } else {
        firstMax[loc] = firstMax[par[loc]];
        secondMax[loc] = secondMax[par[loc]];
        beatSecondMax[loc] = beatSecondMax[par[loc]] | loc > secondMax[loc];

        afterFirstMax[loc] = afterFirstMax[par[loc]];
        if (afterFirstMax[loc] == -1) {
            afterFirstMax[loc] = loc;
        }
    }

    firstReach[loc] = loc <= firstMax[loc];
    secondReach[loc] = !beatSecondMax[loc] && (loc <= secondMax[loc]);

    for (int nbr : tree[loc]) if (nbr != par[loc]) {
        par[nbr] = loc;
        dfs1(nbr);

        if (firstMax[nbr] == firstMax[loc]) {
            firstReach[loc] += firstReach[nbr];
        }
        if (secondMax[nbr] == secondMax[loc]) {
            secondReach[loc] += secondReach[nbr];
        }
    }
}

int ans[MAXN];

void dfs2(int loc) {
    if (firstMax[loc] == loc) {
        ans[loc] = 1 + secondReach[loc];
        if (loc != 0) ans[loc] += ans[par[loc]];
    } else {
        ans[loc] = ans[firstMax[loc]]
                 + firstReach[afterFirstMax[loc]]
                 - secondReach[afterFirstMax[loc]];
    }

    for (int nbr : tree[loc]) if (nbr != par[loc]) {
        dfs2(nbr);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

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

    dfs1(0);
    dfs2(0);

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

    return 0;
}



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

using namespace std;

bool Check(int num)
{
  if(num < 2){ 
    return false;
  }
  else if(num == 2){ 
    return true;
  }
  else if(num % 2 == 0){ 
    return false;
  }

  double sq = sqrt(num);
  for(int i = 3;i <= sq;i += 2){
    if (num % i == 0){
      return false;
    }
  }

  return true;
}

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

    if(N == 0){
      break;
    }

    int t = 1;
    int ans = 2;
    
    if(N != 1){
      for(int i = 3;;i = i + 2){
        bool ch = Check(i);
        if(ch == true){
          ans += i;
          ++t;
        }

        if(t == N){
          break;
        }
      }
    }

    cout<<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 3000
# 初期入力
from itertools import combinations
from itertools import product
import numpy as np 
import sys
input   = sys.stdin.readline
N,M,X   = (int(x) for x in input().split())
C       = [list(map(int, input().split())) for i in range(N)]
all_book= [i for i in range(N)]          #買う本

price_list  =[]
flag        =False
C_np        =np.array(C,dtype=int)
price       =C_np[:,0]
understand  =np.delete(C_np,0,1)

for num in range(1,N+1): #1冊からN冊まで
    for t in combinations(all_book,num): #参考書を買う組合せ、全列挙
        book_buy         =np.array(t,dtype=int)      #今回買った本
        understand_now   =understand[book_buy]       #買ったうちの各本の知識
        understand_sum   =np.sum(understand_now,axis=0) #知識の合計

        if np.all(X <= understand_sum ): #アルゴリズム理解度が全て目標値X以上か
            price_now =price[book_buy]
            price_list.append(np.sum(price_now))
            flag =True
if flag ==True:
    print(min(price_list))
else:
    print(-1)

Measured memory_bytes: 27100
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappush, heappop

Q = int(readline())
query = (tuple(map(int,line.split())) for line in readlines())

# 適当に番兵を入れておく
INF = 10**12
L = [INF] # -1倍していれる
R = [INF]
sumL = 0; sumR = 0 # 和
lenL = 0; lenR = 0 # 長さ

add = 0 # 全体に共通に加わってるもの

answer = []
for q in query:
    if len(q) == 1:
        # 値を求める
        x = -L[0]
        f = sumR - sumL + x * (lenL - lenR)
        answer.append('{} {}'.format(x,f+add))
        continue
    # 更新
    a,b = q[1:]
    add += b
    
    b = -heappop(L); sumL -= b
    c = heappop(R); sumR -= c
    a,b,c = sorted([a,b,c])
    heappush(L,-a); sumL += a
    heappush(R,c); sumR += c
    if lenL > lenR:
        heappush(R,b); sumR += b; lenR += 1
    else:
        heappush(L,-b); sumL += b; lenL += 1

print('\n'.join(answer))

Measured memory_bytes: 28020
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

const int MAXN = 2e4 + 10;
int n, p[MAXN], a[MAXN], b[MAXN];


int main(){

mal

cin >> n;

for(int i = 1; i <= n; ++i) {
    cin >> p[i];
    a[i] = i * n;
    b[n - i + 1] = i * n;
}

int cnt = n - 1;

for(int i = 1; i <= n; ++i) {
    b[p[i]] -= cnt;
    cnt--;
}

cnt = n - 1;

for(int i = n; i >= 1; --i) {
    a[p[i]] += cnt;
    cnt--;
}

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

cout << '\n';

for(int i = 1; i <= n; ++i) {
    cout << b[i] << ' ';
}

return 0;
}



Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int R = scan.nextInt();
		scan.close();
		if(R < 1200) {
			System.out.println("ABC");
		}else if(R < 2800) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}
	}
}

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

int main(){
    ll n,k;
    cin>>n>>k;
    ll tmp=n/k;
    ll tmp1=tmp*tmp*tmp;
    if(k%2!=0){
        cout<<tmp1<<endl;
    }else{
        ll tmp2=(n+k/2)/k;
        tmp1+=tmp2*tmp2*tmp2;
        cout<<tmp1<<endl;
    }
}

Measured memory_bytes: 3604
include Math

x1, y1, x2, y2 = gets.split.map(&:to_i)

vx = x2 - x1
vy = y2 - y1

x3 = - vy + x2
y3 = vx + y2

x4 = -1 * vx + x3
y4 = -1 * vy + y3

print "#{x3} #{y3} #{x4} #{y4}\n"



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

int main() {
  int n;
  cin >> n;
  vector<string> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  vector<string> name(n);
  vector<int> num(n);
  
  int mx=1,count=1;
  name.push_back (a.at(0));
  for(int i=0; i<n-1; i++){
    if(a.at(i)==a.at(i+1)){
      count++;
      mx=max(count,mx);
    }
    else{
      num.push_back (count);
      name.push_back (a.at(i+1));
      count=1;
    }
  }
  num.push_back(count);
  
  vector<string> ans;
  
  for(int i=0;i<num.size();i++){
    if(num.at(i)==mx){
      cout << name.at(i)<<endl;
    }
  }
                  
                  
  
  
  
  
  
}

Measured memory_bytes: 18900
n = int(input())
a = list(map(int, input().split()))

ans = []
base = 0
for i in range(n):
    if i % 2 == 0:
        base += a[i]
    else:
        base -= a[i]
base //= 2

for i in range(n)[::-1]:
    base = a[i] - base
    ans.append(base)
ans = list(map(lambda x: str(x*2), ans))
ans = ans[::-1]
print(" ".join(ans))


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

using namespace std;

bool isPower(unsigned int n)
{
	// Base case
	if (n <= 1) return true;

	// Try all numbers from 2 to sqrt(n) as base
	for (int x=2; x<=sqrt(n); x++)
	{
		unsigned p = x;

		// Keep multiplying p with x while is smaller
		// than or equal to x
		while (p <= n)
		{
			p *= x;
			if (p == n)
				return true;
		}
	}
	return false;
}


int main()
{
    ios::sync_with_stdio(false);
     cin.tie(NULL);
     unsigned int n;
     bool dp[1001];
     memset(dp,false,sizeof(dp));
     for(unsigned int i=1;i<=1000;i++)
     {
         if(isPower(i))
            dp[i]=true;
     }
     cin>>n;
     for(unsigned int j=n;;j--)
     {
         if(dp[j])
         {
             cout<<j<<endl;
             break;
         }
     }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        while(a % 2 == 0) {
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math

n=int(input())
xy=[]
l=[]
for i in range(n):
    x,y=map(int, input().split())
    xy.append((x, y))

for i in range(n):
    ix,iy=xy[i]
    tmp=[]
    for j in range(n):
        jx,jy=xy[j]
        tmp.append(math.sqrt((ix-jx)**2+(iy-jy)**2))
    l.append(tmp)

pat=1
for i in range(1,n+1):
    pat*=i
sa=1
for i in range(1, n-1):
    sa*=i
wei=pat/(n-1)-sa

sum=0
for i in range(n):
    for j in range(i+1, n):
        sum+=(wei*l[i][j])*2

print(sum/pat)





Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n,m;
int a[100];
int b[100];
int c[100];
int d[100];
int k;
int ans;
int main()
{
	cin>>n>>m;
	rep(i,n)cin>>a[i]>>b[i];
	rep(i,m)cin>>c[i]>>d[i];
	rep(i,n)
	{
		k=abs(c[0]-a[i])+abs(d[0]-b[i]);
		ans=0;
		rep(j,m)
		{
			if(k>abs(c[j]-a[i])+abs(d[j]-b[i]))
			{
				k=abs(c[j]-a[i])+abs(d[j]-b[i]);
				ans=j;
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "string"
#include <stack>
#include <queue>
#include <sstream>
using namespace std;
void A()
{
	stack<int> stack;
	string str;
	while (cin >> str)
	{
		if (str == "+" || str == "-" || str == "*")
		{
			int b = stack.top();
			stack.pop();
			int a = stack.top();
			stack.pop();
			int c;
			if (str == "+")
			{
				c = a + b;
			}
			else if (str == "-")
			{
				c = a - b;
			}
			else
			{
				c = a * b;
			}

			stack.push(c);
		}
		else
		{
			int num = stoi(str);
			stack.push(num);
		}
	}

	cout << stack.top() << endl;
}

void B()
{
	queue<string> name;
	queue<int> time;
	int spendTime = 0;
	int N;
	int Q;
	cin >> N;
	cin >> Q;

	cin.ignore();
	string line;
	string s;
	for (int i = 0; i < N;i++)
	{
		getline(cin, line);
		stringstream ss(line);
		ss >> s;
		name.push(s);
		ss >> s;
		time.push(stoi(s));
	}

	while (!time.empty())
	{
		int left = time.front();
		time.pop();
		string n = name.front();
		name.pop();

		if (Q >= left)
		{
			spendTime += left;
			cout << n << " " << spendTime<<endl;
		}
		else
		{
			spendTime += Q;
			time.push(left - Q);
			name.push(n);
		}
	}

	/*while (!name.empty())
	{
		cout << name.front() << endl;
		name.pop();
		cout << time.front() << endl;
		time.pop();
	}*/
}

void C()
{

}

void D()
{

}
int main()
{
	//A();
	B();
	return 0;
}

Measured memory_bytes: 4172
{-# OPTIONS_GHC -O2 #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Data.Array.Unboxed
import Data.Array.ST
import Data.STRef 
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Monad.ST
import Data.List
import Data.Char
import qualified Data.Map.Strict as M

convert :: Int -> Int -> VU.Vector (Int,Int) -> V.Vector [Int]
convert n e graph = V.create $ do
    v <- VM.replicate n []
    forM_ [0..e-1] $ \i -> do
        let (x,y) = graph VU.! i
        VM.modify v (y-1:) (x-1)
        VM.modify v (x-1:) (y-1)
    return v

bipartite :: Int -> V.Vector [Int] -> Maybe (VU.Vector Int)
bipartite n graph = runST $ do
    vec <- VUM.replicate n (-1)
    VUM.write vec 0 0
    go [0] vec
    where go :: [Int] -> VUM.MVector s Int -> ST s (Maybe (VU.Vector Int))
          go [] vec = do
              vv <- VU.freeze vec
              return $ Just vv
          go (n:ns) vec = do
              now <- VUM.read vec n
              ls <- newSTRef []
              flag <- newSTRef False
              forM_ (graph V.! n) $ \i -> do
                  b <- VUM.read vec i
                  when (b == -1) $ VUM.write vec i (1-now) >> modifySTRef ls (i:)
                  when (b == now) $ writeSTRef flag True
              ll <- readSTRef ls
              ff <- readSTRef flag
              if ff then return Nothing else go (ll++ns) vec


main :: IO ()
main = do
    [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    graph <- convert n m <$> (VU.replicateM m $ (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine)
    print $ case bipartite n graph of
        Nothing -> (n*(n-1))`div`2-m
        Just vec -> let len = VU.length $ VU.filter (==1) vec in len*(n-len) - m

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

#ifdef DEBUG
#define debug(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }


int main() {
    int t,x; cin >> t >> x;
    double a=(double)t/x;
    printf("%.10f\n", a);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
sum2=0
if(n==1):
    sum2=1
if(n==2):
    sum2=3
if(n>=3):
    sum2=3
    for i in range(3,n+1):
        if(i%3!=0 and i%5!=0):
            sum2=sum2+i
print(sum2)
    

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

using namespace std;

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

int main(){
	
	typedef pair<int,int> pii;
	
	vector<pii> dat;
	int a,b;
	int cnt = 0;
	while(scanf("%d,%d",&a,&b)!=EOF){
		if(a==0 && b==0)break;
		dat.push_back(pii(b,a));
		cnt++;
	}
	
	sort(dat.begin(),dat.end());
	reverse(dat.begin(),dat.end());
	
	int rank[11111]={0};
	int r = 1;
	rank[0]=1;
	reps(i,1,dat.size()){
		if(dat[i].first==dat[i-1].first)rank[i]=r;
		else{
			r++;
			rank[i]=r;
		}
	}
	
	
	int c;
	while(cin>>c){
		rep(i,dat.size()){
			if(dat[i].second==c)printf("%d\n",rank[i]);
		}
	}
	
}

Measured memory_bytes: 1264
#include <iostream>
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s; cin >> s;
  cout << s.substr(0, 3) << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line;
            int[][] map = new int[10][10];
            
            while((line=br.readLine())!=null){
                if(line.equals(""))break;
                String[] splited = line.split(",");
                int x = Integer.parseInt(splited[0]);
                int y = Integer.parseInt(splited[1]);
                int size = Integer.parseInt(splited[2]);
                map[x][y]++;
                if(x!=0)map[x-1][y]++;if(x!=9)map[x+1][y]++;
                if(y!=0)map[x][y-1]++;if(y!=9)map[x][y+1]++;
                if(size>1){
                    if(x!=0&&y!=0)map[x-1][y-1]++;if(x!=9&&y!=0)map[x+1][y-1]++;
                    if(x!=9&&y!=9)map[x+1][y+1]++;if(x!=0&&y!=9)map[x-1][y+1]++;
                }
                if(size==3){
                    if(x>=2)map[x-2][y]++;if(x<=7)map[x+2][y]++;
                    if(y>=2)map[x][y-2]++;if(y<=7)map[x][y+2]++;
                }
            }
            int max=0, tile=0;
            for(int i=0; i<100;i++){
                int den = map[i%10][i/10];
                if(den>max)max=den; if(den>0)tile++;
            }
            System.out.println(100-tile);
            System.out.println(max);
        }catch(Exception e){e.printStackTrace();}
    }
}

Measured memory_bytes: 15080
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int main() {
  int N, M; cin >> N >> M;
  Pi Input[N];
  for (int i = 0; i < N; i++) {
    int a, b; cin >> a >> b;
    Input[i] = Pi(a, b);
  }

  auto comparator = [](const Pi & l, const Pi & r) {
                      return l.first < r.first;
                    };

  sort(Input, Input + N, comparator);

  // for (int i = 0; i < N; i++) {
  //   cout << Input[i].first << " " << Input[i].second << endl;
  // }


  auto comparator2 = [](const Pi & l, const Pi & r) {
                       return l.second < r.second;
                     };
  
  priority_queue<Pi, vector<Pi>, decltype(comparator2)> PQ(comparator2);


  int ans = 0;
  for (int i = 1; i <= M; i++) {
    int x = lower_bound(Input, Input + N, Pi(i, 0), comparator) - Input;
    int y = upper_bound(Input, Input + N, Pi(i, 0), comparator) - Input;
    // cout << i << " " << x << " " << y << endl;
    for (int j = x; j < y; j++) {
      PQ.push(Input[j]);
    }
    if (PQ.empty()) {
      continue;
    } else {
      ans += PQ.top().second;
      PQ.pop();
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 2168
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         string[] s = ReadLine().Split(' ').ToArray();
         decimal A = decimal.Parse(s[0]);
         decimal B = decimal.Parse(s[1]);
         WriteLine(Math.Truncate(A * B));
      }
   }
}

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

int N, D, X;

int main() {
	cin >> N >> D >> X;
	for (int i = 0; i < N; i++) {
		int A; cin >> A;
		int day = 1;
		while (1 <= day && day <= D) {
			X++;
			day += A;
		}
	}
	cout << X << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

vector<int> invG[100000];

int main()
{
    int n,k;
    cin >>n >>k;
    vector<int> a(n);
    rep(i,n)
    {
        scanf(" %d", &a[i]);
        --a[i];
    }

    for(int i=1; i<n; ++i) invG[a[i]].pb(i);

    vector<int> d(n,0);
    queue<int> que;
    que.push(0);
    while(!que.empty())
    {
        int v=que.front();
        que.pop();
        rep(i,invG[v].size())
        {
            int nx=invG[v][i];
            d[nx]=d[v]+1;
            que.push(nx);
        }
    }

    vector<pi> p(n);
    rep(i,n) p[i]=pi(d[i],i);
    sort(all(p), greater<pi>());

    int ans=0;
    if(a[0]!=0)
    {
        ++ans;
        a[0]=0;
    }

    vector<bool> vis(n,false);
    rep(i,n)
    {
        int v=p[i].se;
        if(p[i].fi<=k) break;
        if(vis[v]) continue;

        int r=v;
        rep(j,k-1) r=a[r];

        //おわり
        if(r==0) break;

        ++ans;
        que.push(r);
        vis[r]=true;
        while(!que.empty())
        {
            int now=que.front();
            que.pop();
            rep(j,invG[now].size())
            {
                int nx=invG[now][j];
                if(!vis[nx])
                {
                    vis[nx]=true;
                    que.push(nx);
                }
            }
        }
    }

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


Measured memory_bytes: 7296
//https://atcoder.jp/contests/abc145/tasks/abc145_b
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	vector<char> lis;
	vector<char> alis;
	vector<char> blis;
	ll i;
	for(i=0;i<n;i++)
	{
		lis.push_back(s[i]);
	}
	if(n==1)
	{
		cout<<"No"<<"\n";
	}
	else if(n%2!=0)
	{
		cout<<"No"<<"\n";
	}
	else
	{
		ll cnt=0;
		for(i=0;i<n/2;i++)
		{
			alis.push_back(lis[i]);
		}
		for(i=n/2;i<n;i++)
		{
			blis.push_back(lis[i]);
		}
		for(i=0;i<n/2;i++)
		{
			if(alis[i]==blis[i])
			{
				cnt=cnt+1;
			}
			else
			{
				cnt=cnt;
			}
		}
		if(cnt==n/2)
		{
			cout<<"Yes"<<"\n";
		}
		else
		{
			cout<<"No"<<"\n";
		}	
	}
	return 0;
}

Measured memory_bytes: 3548
from collections import deque

S = deque(input())
n= int(input())
condition=True

for i in range(n):
  Q = [i for i in input().split()]
  if Q[0] =='1':
    if condition ==True:
      condition=False
    else:
      condition=True
  else:
    if Q[1]=='1':
      if condition ==True:
        S.appendleft(Q[2])
      else:
        S.append(Q[2])
    else:
      if condition==True:
        S.append(Q[2])
      else:
        S.appendleft(Q[2])
    #print(S)

if condition ==False:
  S.reverse()

for i in S:
  print(i, end='')

Measured memory_bytes: 7536
import sys

N = int(input())
s = list()
for i in range(N):
	s.append(int(input()))

s.sort(reverse=True)

point = sum(s)
l = len(s)
i = 0

while i < l:
	if point % 10 != 0:
		print(point)
		sys.exit()
	if not s == []:
		for x in reversed(list(s)):
			if not x % 10 == 0:
				point -= s.pop(s.index(x))
				break
	i += 1

print("0")

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

using namespace std;

int str_to_int(string s, int l, int r) {
    int ret=0;
    for(int i=l; i<=r; i++) {
        ret *= 10;
        ret += (int)(s[i]-'0');
    }
    
    return ret;
}

int main() {
    string str;
    cin >> str;
    
    int ans=1e5;
    for(int i=0; i+2<str.size(); i++) {
        ans = min(ans, abs(str_to_int(str, i, i+2)-753));
    }
    
    cout << ans << endl;

    return 0;
    
}

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

#define ll long long int

int main()
{
	string ss;
	cin >> ss;
	if (ss[2] >= 'a' && ss[2] <= 'z' && ss[3] >= 'a' && ss[3] <= 'z' && ss[4] >= 'a' && ss[4] <= 'z' && ss[5] >= 'a' && ss[5] <= 'z'  && ss.size()==6)
	{
		(ss[2] == ss[3] && ss[4] == ss[5]) ? cout << "Yes": cout << "No";
	}
	else cout<<"No";
}

Measured memory_bytes: 256
a = list(input())
a,b,c,d = int(a[0]), int(a[1]), int(a[2]), int(a[3])
if a+b+c+d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c-d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c+d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b+c+d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c-d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        string s1,s2;
        cin>>s1>>s2;
        int l1 = s1.size(),l2=s2.size();
        int dp[l1+1][l2+1];
        for(int i=0;i<=l1;i++) dp[i][0]=0;
        for(int i=0;i<=l2;i++) dp[0][i]=0;
        for(int i=1;i<=l1;i++){
            for(int j=1;j<=l2;j++){
                 if(s1[i-1]==s2[j-1]){
                    dp[i][j] = dp[i-1][j-1]+1;   
                 }
                 else {
                    dp[i][j] = max(dp[i-1][j],dp[i][j-1]);  
                 }
             }
        }  
      /*   for(int i=1;i<=l1;i++){
            for(int j=1;j<=l2;j++){
                 cout<<dp[i][j]<<" ";
             }
             cout<<endl;
        } */
        string ans;
        int pt1 = l1,pt2=l2;
        while(pt1>0&&pt2>0){
            if(dp[pt1][pt2]==dp[pt1-1][pt2-1]+1&&dp[pt1][pt2]!=dp[pt1-1][pt2]&&dp[pt1][pt2]!=dp[pt1][pt2-1]){
                ans+=s1[pt1-1];
                pt1--;pt2--;
            }
            else if(dp[pt1][pt2]==dp[pt1][pt2-1]){
                 pt2--;
            }
            else if(dp[pt1][pt2]==dp[pt1-1][pt2]){
                 pt1--;        
            }
        }
        reverse(ans.begin(),ans.end());
        cout<<ans;
        return 0;
    } 

Measured memory_bytes: 35456
n = gets.to_i
b = gets.split.map(&:to_i)
a = Array.new(n, -1)
ids = Array.new(n-1)
for i in 0..(n-2)
  ids[i] = i
end

ids.sort!{|x, y| b[x] <=> b[y]}

for i in 0..(n-2)
  a[ids[i]] = b[ids[i]] if a[ids[i]] == -1
  a[ids[i]+1] = b[ids[i]] if a[ids[i]+1] == -1
end
sum = 0
a.each do |an|
  sum += an
end
puts sum

Measured memory_bytes: 1788
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }

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

int n, m;
vector<int> G[maxn];
int dp[maxn], ind[maxn];

void dfs(int u){
	for(int v : G[u]){
		if(!dp[v]){
			dfs(v);
			dp[u] = qmax(dp[u], dp[v] + 1);
		} else {
			dp[u] = qmax(dp[u], dp[v] + 1);
		}
	}
}

int main()
{
	n = read(), m = read();
	rep(i, 1, m) {
		int u = read(), v = read();
		G[u].pb(v);
		ind[v]++;
	}
	rep(i, 1, n){
		if(!ind[i]){
			dfs(i);
		}
	}
	printf("%d\n", *max_element(dp, dp + n + 1));
	return 0;
}

Measured memory_bytes: 11136
def solve():
    H,W = map(int,input().split())
    
    ans = float('inf')
    a = 0
    b = 0
    c = 0

    for h in range(H+1):
        if W % 2 == 0:
            a = h * W // 2
            b = h * W // 2
        else:
            a = h * (W-1) // 2
            b = h * (W+1) // 2
        c = W * (H-h)

        s_max = max(a,b,c)
        s_min = min(a,b,c)
        ans = min(ans, s_max-s_min)

        a = h * W
        if (H-h) % 2 == 0:
            b = (H-h) // 2 * W
            c = (H-h) // 2 * W
        else:
            b = (H-h-1) // 2 * W
            c = (H-h+1) // 2 * W
        
        s_max = max(a,b,c)
        s_min = min(a,b,c)
        ans = min(ans, s_max-s_min)

    for w in range(W+1):
        if H % 2 == 0:
            a = w * H // 2
            b = w * H // 2
        else:
            a = w * (H-1) // 2
            b = w * (H+1) // 2
        c = H * (W-w)

        s_max = max(a,b,c)
        s_min = min(a,b,c)
        ans = min(ans, s_max-s_min)

        a = w * H
        if (W-w) % 2 == 0:
            b = (W-w) // 2 * H
            c = (W-w) // 2 * H
        else:
            b = (W-w-1) // 2 * H
            c = (W-w+1) // 2 * H
        
        s_max = max(a,b,c)
        s_min = min(a,b,c)
        ans = min(ans, s_max-s_min)
    
    print(ans)

if __name__ == '__main__':
    solve()

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

int main() {
	long long n,x,cur=0;
	cin >> x; n=x;
	while(n>0){
		cur+=n%10;
		n/=10;
	}
	if(x%cur==0){
		cout << "Yes";
	}else{
		cout << "No";
	}
}


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

using namespace std;

int main(void){
  int N,M;
  int sum=0;
  cin >> N >> M;
  vector<int> A(N);
  bool ok=true;
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
  }
  sort(A.rbegin(),A.rend());

  for(int i=0;i<M;i++){
    if(A[i]<(double)sum/(double)(4*M)){
      ok = false;
      break;
    }
  }
  if(ok){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n, m;
  scanf("%d %d\n", &n, &m);
  int a[n][m], b[m], c = 0;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < m; i++)
    scanf("%d", &b[i]);

  for (int i = 0; i < n; i++)
  {
    c = 0;
    for (int j = 0; j < m; j++)
    {
      c += a[i][j] * b[j];
    }
    printf("%d\n", c);
  }
}


Measured memory_bytes: 2104
#include<cstdio>
#include<vector>

using namespace std;

typedef long long ll;

const int MOD = 1000000007;

ll fac[100100], finv[100100], inv[100100];

void comb_init(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i < 100100; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll comb(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	comb_init();
	int n, m; scanf("%d %d", &n, &m);
	vector<int> v;
	for(int i = 2; i * i <= m; i++){
		int e = 0;
		while(m % i == 0){ e++; m /= i; }
		if(e > 0) v.push_back(e);
	}
	if(m > 1) v.push_back(1);
	ll res = 1;
	for(int i = 0; i < v.size(); i++) res = (res * comb(n + v[i] - 1, v[i])) % MOD;
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 2560
import sys
def f():
 w=m=0;n,q=map(int,input().split());s=[0]*-~n
 for e in sys.stdin:
  a,v=map(int,e.split());s[a]+=v
  if v<0 and a==w:m=max(s);w=s.index(m)
  elif s[a]>m:w,m=a,s[a]
  elif s[a]==m:w=min(w,a)
  print(w,m)
if'__main__'==__name__:f()


Measured memory_bytes: 13712
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int M;
  cin >> M;
  cout << 48 - M << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int m = saori.saori_hayami();
		int[] aa = new int[a];
		int[] bb = new int[b];
		int[] x = new int[m];
		int[] y = new int[m];
		int[] c = new int[m];
		for(int i = 0;i < a;i++){
			aa[i] = saori.saori_hayami();
		}
		for(int i = 0;i < b;i++){
			bb[i] = saori.saori_hayami();
		}
		for(int i = 0;i < m;i++){
			x[i] = saori.saori_hayami();
			y[i] = saori.saori_hayami();
			c[i] = saori.saori_hayami();
		}
		int min = MAX;
		for(int i = 0;i < m;i++){
			min = Math.min(min, aa[x[i]-1] + bb[y[i]-1] - c[i]);
		}
		Arrays.sort(aa);
		Arrays.sort(bb);
		min = Math.min(min, aa[0] + bb[0]);
		System.out.println(min);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32144
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        //int n = sc.nextInt();
        int []k = new int[32];
        k[0]=1;
        k[1]=1;
        k[2]=1;
        k[3]=2;
        k[4]=1;
        k[5]=2;
        k[6]=1;
        k[7]=5;
        k[8]=2;
        k[9]=2;
        k[10]=1;
        k[11]=5;
        k[12]=1;
        k[13]=2;
        k[14]=1;
        k[15]=14;
        k[16]=1;
        k[17]=5;
        k[18]=1;
        k[19]=5;
        k[20]=2;
        k[21]=2;
        k[22]=1;
        k[23]=15;
        k[24]=2;
        k[25]=2;
        k[26]=5;
        k[27]=4;
        k[28]=1;
        k[29]=4;
        k[30]=1;
        k[31]=51;
        int a = sc.nextInt();
        System.out.println(k[a-1]);
        sc.close();
    }
}

Measured memory_bytes: 21844
import collections

n = int(input())
blue = [0] * n
for i in range(n):
    blue[i] = input()
m = int(input())
red = [0] * m
for i in range(m):
    red[i] = input()

ans = 0
word = []
wordCnt = []

for i in range(n):
    if not blue[i] in word:
        word.append(blue[i])
        wordCnt.append(1)
    else:
        for j in enumerate(word):
            if blue[i] == j[1]:
                wordCnt[j[0]] += 1

for i in range(m):
    if not red[i] in word:
        word.append(red[i])
        wordCnt.append(-1)
    else:
        for j in enumerate(word):
            if red[i] == j[1]:
                wordCnt[j[0]] -= 1

ans = max(wordCnt)
if ans < 0:
    ans = 0
print(ans)

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

typedef long long ll;
#define MOD 1000000007
ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

ll H, W, K;
vector<vector<llm> > dp;
int main(){
  vector<llm> fib = {1, 1, 2, 3, 5, 8, 13, 21, 34};
  cin >> H >> W >> K;
  dp = vector<vector<llm> >(H+1, vector<llm>(W+1));
  dp[0][1] = 1;
  for(ll i=0;i<H;i++){
    for(ll j=1;j<=W;j++){
      if (j>1) dp[i+1][j-1] = dp[i+1][j-1] + dp[i][j] * fib[j-2] * fib[W-j];
      dp[i+1][j] = dp[i+1][j] + dp[i][j] * fib[j-1] * fib[W-j];
      if (j<W) dp[i+1][j+1] = dp[i+1][j+1] + dp[i][j] * fib[j-1] * fib[W-j-1];
    }
  }
  cout << dp[H][K] << endl;
}
  
  
  
  

Measured memory_bytes: 256