akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>r;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		r.push_back(x);
	}
	sort(r.begin(), r.end());
	reverse(r.begin(), r.end());
	vector<int>a;
	for (int i = 0; i < n-1; i++) {
		if (r[i] == r[i + 1]) {
			a.push_back(r[i]); i++;
		}
	}
	
	if (a.size() > 1)cout << (long long int)a[0] * (long long int)a[1] << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll A,B,C,D;
    cin >> A>>B>>C>>D;
    
    while(A>0){
        C=C-B;
        A=A-D;
    }
    if(C>0)
    cout<<"No";
    else
    cout<<"Yes";
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m;
	cin >> m;
	ll sum = 0, ans = -1;
	rep(i,m){
		ll a, b;
		cin >> a >> b;
		ans += b;
		sum += a * b;
	}
	ans += (sum - 1LL) / 9LL;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

public static void main(String[] args) {

Scanner inp = new Scanner(System.in);

int a = inp.nextInt();
int b = inp.nextInt();

System.out.print((a/b)+" "+(a%b));
System.out.printf(" %.5f", (double) a/b);

}
}


Measured memory_bytes: 26564
N = int(input())
Alphabet = str('abcdefghijklmnopqrstuvwxyz')
import bisect

List = [0, 26, 702, 18278, 475254, 12356630, 321272406, 8353082582, 217180147158, 5646683826134, 146813779479510, 3817158266467286, 99246114928149462, 2580398988131886038, 67090373691429037014, 1744349715977154962390, 45353092615406029022166, 1179180408000556754576342, 30658690608014475618984918]
V = []

if List.count(N) == 1:
	for i in range (0, List.index(N)):
		V.append('z')
	print(*V, sep = '')
	exit()

k = 26
A = [0]
for i in range (2, 20):
	A.append(k)
	k = k+26**i
    
S = []

B = bisect.bisect_right(A, N)

N = N-A[B-1]-1
for i in range (0, B):
	S.append(Alphabet[N%26])
	N = N//26
    
S = reversed(S)
print(*S, sep = '')

Measured memory_bytes: 9156
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

int array_min_max(int* p, int n,bool f)  //f: true→min false→max
{
	int tmp;

	if (f)
		tmp = INF;
	else
		tmp = 0;

	for (int i = 0; i < n; i++)
	{
		if (f)
		{
			if (p[i] < tmp)
				tmp = p[i];
		}
		else
		{
			if (p[i] > tmp)
				tmp = p[i];
		}
	}
	return tmp;
}

void swap(int *a, int *b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void bubble_sort(int *p, int n)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[j], &p[j + 1]);
		}
	}
}

int main()
{
	int N;
	int A, B;
	char S[101];
	char T[101];


	scanf("%d%d", &A, &B);

	for (int i = 1; i <= 3; i++)
	{
		if (A != i && B != i)
			printf("%d\n", i);
	}
}

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

int main() {
    string w; cin >> w;
    map<char, int> ch;
    for (int i = 0; i < (int)w.size(); i++) ch[w[i]]++;

    for (int i = 0; i < (int)w.size(); i++) {
        if (ch[w[i]] % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {

	

	
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
	    int mod=(int)(Math.pow(10, 9)+7);   
		int n=sc.nextInt();
	        int m=sc.nextInt();
	        char arr[][]=new char[n][m];
	        
	        for(int i=0;i<n;i++)
	        {
	        	String s=sc.next();
	        	arr[i]=s.toCharArray();
	        }
	        long dp[][]=new long[n][m];
	        for(int i=0;i<n;i++)
	        {
	        	if(arr[i][0]=='#')
	        	{
	        		break;
	        	}
	        	dp[i][0]=1;
	        }
	        for(int i=0;i<m;i++)
	        {
	        	if(arr[0][i]=='#')
	        	{
	        		break;
	        	}
	        	dp[0][i]=1;
	        }
	        ///
	        for(int i=1;i<n;i++)
	        {
	        	for(int j=1;j<m;j++)
	        	{
	        		if(arr[i][j]=='.')
	        		{
	        			dp[i][j]=dp[i-1][j]+dp[i][j-1];
	        			dp[i][j]%=mod;
	        		}
	        	}
	        }
	        System.out.println(dp[n-1][m-1]);
			
	    		
	}
	
	
}


Measured memory_bytes: 63464
import java.util.*;
import java.io.*;


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

        String C = sc.next();
        char c = C.charAt(0);
        int code = (int)c + 1;
        char[] result = Character.toChars(code);
        
        out.println(result);

        out.flush();
    }

        
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22100
n = int(input())
h = list(map(int, input().split()))
can = 0
max_h = h[0]
max_c = 0
for i in range(n-1):
    l = h[i]
    r = h[i+1]
    if l >= r:
        can += 1
    else:
        can = 0
        max_h = r
    if can > max_c:
        max_c = can
print(max_c)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s,t;
  cin >> s >> t;

  t+=s;
  for(ll i=0;i<t.size();i++)cout << t[i];

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define endl '\n'
#define int ll
// #define gcd __gcd
#define popcount(x) __builtin_popcountll(x)
#define fill(x, y) memset(x, y, sizeof(x))
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)
// default binary search returns a bool
 
// int dx[]={1,0,-1,0}; 
// int dy[]={0,1,0,-1}; //4 Direction 
 
// int dx[]={1,1,0,-1,-1,-1,0,1}; 
// int dy[]={0,1,1,1,0,-1,-1,-1};  // 8D

void solve(){

    string a;
    cin >> a;
    int n = a.size() , sum = 0;
    for (int i = 0 ; i< n ; i++){
        sum += a[i]-'0';
    }
    if (sum%9){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

}

 
int32_t main(){

    #ifndef ONLINE_JUDGE 
  
    freopen("input.txt", "r", stdin); 
  
    // freopen("output.txt", "w", stdout); 
  
    #endif 
 
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 
 
    int t = 1;
    // cin >> t;
    for (int tt = 0 ; tt < t ; tt++){
        
        // cout << "Case " << (tt+1) <<": " << endl;
        solve();
    }
    
}

Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define MOD (1e9+7)

int main(void){
	int n,i;
	ll a[12345],b[12345],debt=0;
	bool flag = true;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	for(i=0; i<n; i++){
		cin >> b[i];
	}
	for(i=0; i<n; i++){
		if(a[i]>b[i]){
			debt += (a[i]-b[i])*2;
			b[i] = a[i];
		}
	}
	for(i=0; i<n; i++){
		debt -= ((b[i]-a[i])/2)*2;
	}
	cout << ((debt<=0)?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x-r>=0)&&(x+r<=W)){
		if((y-r>=0)&&(y+r<=H)){
			printf("Yes\n");
		}else{
		printf("No\n");
	}
	}else{
		printf("No\n");
	}
		
	return 0;
}


Measured memory_bytes: 2132
import numpy as np
H, W=map(int, input().split())
F=[]
for i in range(H):
  F.append(list(input()))
count=0
for i in range(H):
  count+=F[i].count("#")
INF=100000000  
F=np.array(F)
def bfs():
    #dx, dy 四方向に対応したベクトルのリスト
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    #P: (x, y)のキュー
    P=[]
    #d: スタートから各点までの最小距離の配列
    d=np.ones((H, W))*INF
    #スタート地点をキューに入れ、その点の距離を0にする
    sx,sy=0,0
    gx,gy=H-1,W-1
    P.append([sx, sy])
    d[sx,sy]=0
    
    #キューがからになるまでループ
    while len(P)>0:
        #キューの先頭を取り出す
        p=P.pop(0)
        #取り出してきた状態がゴールなら探索をやめる
        if (p[0]==gx and p[1]==gy):
            break
        
        #移動四方向をループ
        for i in range(4):
            #移動した後の点をnx, nyとする
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]
            
            #移動が可能かどうかの判定とすでに訪れたことがあるかどうかの判定（d[nx, ny]!=INFならおtpずれたことがある）
            if 0<=nx and nx<H and 0<=ny and ny<W and F[nx, ny]!="#" and d[nx, ny]==INF:
                #移動できるならキューに入れ、その点の距離をpからの距離＋１で確定する
                P.append([nx, ny])
                d[nx, ny]=d[p[0], p[1]]+1
    #print(d)
    return d[gx, gy]
ans=bfs()
if ans==INF:
  print(-1)
else:
  print(int((H*W-count)-ans-1))



Measured memory_bytes: 12504
#pragma GCC optimize("O3")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
const ll MOD=1e9+7;
vector<ll> facts;

ll add(ll first,ll second)
{
    first%=MOD;
    second%=MOD;
    ll res=(first+second)%MOD;
    return res;
}

ll sub(ll first,ll second)
{
    first%=MOD;
    second%=MOD;
    ll res=(first-second+MOD)%MOD;
    return res;
}

ll mul(ll first,ll second)
{
    first%=MOD;
    second%=MOD;
    return (first*second)%MOD;
}

void computeFacts(ll n)
{
    F0R(i,n+1)
    {
        if(i==0)
            facts.pb(1);
        else
            facts.pb(mul(facts[i-1],i));
    }
}

ll fact(ll first)
{
    return facts[first];
}

ll modPow(ll first,ll second)
{
    first%=MOD;
    if(second==0)
        return 1;
    if(second==1)
        return first;
    ll res=modPow(first,second/2);
    if(second%2==0)
        return mul(res,res);
    else
        return mul(mul(res,res),first);
}

ll choose(ll first,ll second)
{
    if(second>first)
        return 0;
    ll num=fact(first);
    ll den=mul(fact(second),fact(first-second));
    ll res=mul(num,modPow(den,MOD-2));
    return res;
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll tot=0;
    int n,k;
    cin >> n >> k;
    computeFacts(n);
    vector<int> arr(n);
    F0R(i,n)
        cin >> arr[i];
    sort(arr.begin(),arr.end());
    F0R(i,sz(arr))
    {
        tot=add(tot,mul(arr[i],choose(i,k-1)));
        tot=sub(tot,mul(arr[i],choose(sz(arr)-(i+1),k-1)));
    }
    cout << tot;

    return 0;
}


Measured memory_bytes: 1400
using System;
public class Example {
    public static void Main() {
        int debt = 100;
        int month = int.Parse(Console.ReadLine());
        for (int i = 0; i < month; i++) {
            debt = (int)Math.Ceiling(debt*1.05);
        }
        Console.WriteLine(debt*1000);
    }
}

Measured memory_bytes: 8952
#include <iostream>
#include <set>

int main()
{
    std::ios_base::sync_with_stdio(0);
    int n,m;
    std::cin >> n >> m;
    std::multiset<int, std::greater<int>> S;
    for (int i=0;i<n;++i)
    {
        int a;
        std::cin >> a;
        S.insert(a);
    }
    for (int i=0;i<m;++i)
    {
        auto it = S.begin();
        int v = *it;
        S.erase(it);
        S.insert(v/2);
    }
    int64_t sum = 0;
    for (int v : S) sum += v;
    std::cout << sum;
    return 0;
}

Measured memory_bytes: 4992
#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 <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int n; cin>>n;
    vector<bool> a(n, false), b(n, false), c(n, false);
    int x; cin>>x;
    for(int i=0; i<x; i++){
        int d; cin>>d;
        a[--d] = true;
    }
    int y; cin>>y;
    for(int i=0; i<y; i++){
        int d; cin>>d;
        b[--d] = true;
    }
    int z; cin>>z;
    for(int i=0; i<z; i++){
        int d; cin>>d;
        c[--d] = true;
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        if((!a[i] && c[i]) || (b[i] && c[i])){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3096
n,m=map(int,input().split())
l=[tuple(map(int,input().split())) for i in range(m)]
p=[]
q=[]
for i in l:
    if i[0]==1:
        p.append(i[1])
    if i[1]==n:
        q.append(i[0])
if len(set(p)&set(q))!=0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 39260
from collections import defaultdict
from bisect import bisect_right
S = input()
T = input()
NS = len(S)

# 構成不可
if set(list(T)) - set(list(S)):
    print(-1)
    exit()


# 各文字の出現場所を記録
D = defaultdict(list)
for i, s in enumerate(S):
    D[s].append(i)


ans = 0
marker = -1
for t in T:
    target_char_appeared_indexes = D[t]
    bi = bisect_right(target_char_appeared_indexes, marker)
    # もう一周してこないと見つけられない
    if bi == len(target_char_appeared_indexes):
        ans += NS
        marker = target_char_appeared_indexes[0]
    else:
        marker = target_char_appeared_indexes[bi]


# 0-indexedのため+1
print(ans + marker + 1)


Measured memory_bytes: 8164
package main

import (
	"fmt"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	if a[0] == b[2] && a[1] == b[1] && a[2] == b[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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


int main() { 
    string s;
    cin >> s;
    int n=3;
    vector<char> ans(3);
    for (int bit=0;bit<(1<<n);bit++) {
        int sum=s[0]-'0';
        for (int i=0;i<n;i++) {
            if (bit & (1<<i)) {
                sum+=s[i+1]-'0';
                ans[i]='+';
            } else {
                sum-=s[i+1]-'0';
                ans[i]='-';
            }
        }
        if (sum==7) break;
    }
    for (int i=0;i<n;i++) {
        cout << s[i] << ans[i];
    }
    cout << s[3] << "=7" << endl;
}

Measured memory_bytes: 256
import bisect

def main():
    s = input()
    t = input()
    n = len(s)
    m = len(t)

    l = [[] for _ in range(26)]
    for i in range(n):
        l[ord(s[i]) - ord('a')].append(i)
    for i in range(n):
        l[ord(s[i]) - ord('a')].append(i+n)

    ans = 0
    p = 0
    for i in range(m):
        c = ord(t[i]) - ord('a')
        if len(l[c]) == 0:
            print(-1)
            return
        p = l[c][bisect.bisect_left(l[c], p)] + 1
        if p >= n:
            p -= n
            ans += n
    ans += p
    print(ans)
    return

main()


Measured memory_bytes: 11768
#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        mut m: i64,
        ab: [(i64, i64); n],
    }
    let mut btmap = BTreeMap::new();
    let mut ans = 0;
    for (a, b) in ab { *btmap.entry(a).or_insert(0) += b; }
    for (price, stock) in btmap {
        let to_buy = min(m, stock);
        m -= to_buy;
        ans += price * to_buy;
    }
    println!("{}", ans);
}


Measured memory_bytes: 7956
//
//  ALDS1_3_A_Stack.cpp
//  test
//
//  Created by Sajor on 2019/3/23.
//  Copyright © 2019年 Sajor. All rights reserved.
//

#include<iostream>
#include<stack>
#include<cstdlib>

using namespace std;

int main()
{
    int a, b;
    stack<int> s;
    char str[10];
    while(cin >> str){
        if(str[0] == '-'){
            a = s.top();
            s.pop();
            b = s.top();
            s.pop();
            s.push(b-a);
        } else if(str[0] == '+'){
            a = s.top();
            s.pop();
            b = s.top();
            s.pop();
            s.push(b+a);
        } else if(str[0] == '*'){
            a = s.top();
            s.pop();
            b = s.top();
            s.pop();
            s.push(b*a);
        }else {
            s.push(atoi(str));
        }
    }
    cout << s.top() << endl;
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
bool ask(int x){
    cout<<"? "<<x<<endl;
    char c;cin>>c;
    return c=='Y';
}
void kek(int x){
    cout<<"! "<<x<<endl;
    exit(0);
}
int32_t main(){
    int len=-1,q=1;
    for(int i=1;i<=10;++i){
        if(!ask(q)){
            len=i-1;
            break;
        }
        q*=10;
    }
    if(len==-1){//10..00
        q=10;
        for(int i=1;i<=10;++i){
            if(ask(q-1))kek(q/10);
            q*=10;
        }    
        assert(0);
    }else{
        q=0;
        dbg(len);
        forn(i,len-1){
            int l=(i==0),r=10;
            while(r-l>1){
                int m=(l+r)/2;
                if(ask(q+m))l=m;
                else r=m;
            }
            (q+=l)*=10;
        }
        int l=-1,r=9;
        while(r-l>1){
            int m=(l+r)/2;
            if(ask((q+m)*10))r=m;
            else l=m;
        }
        kek(q+r);
    }
    return 0;
}

Measured memory_bytes: 3732
def bmi(s,w,h):
    if w/h**2 >= 25:
        print(s)

while(1):
    try:
        s,w,h = [i for i in input().split(",")]
        s = int(s)
        w = float(w)
        h = float(h)
        bmi(s,w,h)
    except EOFError:
        break


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    char e = 'a';
    int i;
    int h;
    for(i=0;i<26;i++){
        e='a'+i;
        h=s.find_first_of(e);
        if(h==std::string::npos){
            cout << e << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
 
 
public class Main {

	static long MOD = 1_000_000_007;
	static int[][] map;
	static long[][] dp;
	static int[] dx = {1,-1,0,0};
	static int[] dy = {0,0,1,-1};
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		//int N = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		//char[] c = sc.next().toCharArray();
		int INF = Integer.MAX_VALUE;
		int ans = 0;
		
		Scanner sc = new Scanner(System.in);
		int W = Integer.parseInt(sc.next());
		int H = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		double area = (double)W * (double)H /2.0;
		
		int flag = 0;
		
		if(W%2 == 1 || H%2 == 1){
			flag = 0;
		}else if (x == W/2 && y== H/2){
			flag = 1;
		}else{
			flag = 0;
		}
		
		
		System.out.print(area+" "+flag);
		
	}
}



Measured memory_bytes: 21972
//while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

const int nax=200*1007;
using ll=long long;

int n;
vector < pair<int,ll> > graf[nax];

ll tab[nax];

ll wyn;


int bylcen[nax];

vector <int> spo;
int roz[nax];
int maxroz[nax];

vector < pair <int,ll> > ter;

vector < pair <ll , pair <int,int> > > kra;

int oj[nax];

int fin(int v)
{
	if (v!=oj[v])
		oj[v]=fin(oj[v]);
	return oj[v];
}

bool mniej(pair <int,ll> a, pair <int,ll> b)
{
	return a.second<b.second;
}

void dfs1(int v, int oj)
{
	roz[v]=1;
	maxroz[v]=0;
	spo.push_back(v);
	for (auto i : graf[v])
	{
		if(i.first==oj || bylcen[i.first])
			continue;
		dfs1(i.first, v);
		roz[v]+=roz[i.first];
		maxroz[v]=max(maxroz[v], roz[i.first]);
	}
}

void dfs2(int v, int oj, ll odl)
{
	ter.push_back({v, odl+tab[v]});
	for (auto i : graf[v])
	{
		if(i.first==oj || bylcen[i.first])
			continue;
		dfs2(i.first, v, odl+i.second);
	}
}

void szuk(int v)
{
	if (bylcen[v])
		return;
	spo.clear();
	dfs1(v, 0);
	
	int c=-1;
	int ss=spo.size();
	for (int i : spo)
		if (2*maxroz[i]<=ss && 2*(ss-roz[i])<=ss)
			c=i;
	
	bylcen[c]=1;
	
	ter.clear();
	dfs2(c, 0, 0LL);
	
	sort(ter.begin(), ter.end(), mniej);
	
	for (auto i : ter)
		kra.push_back({i.second+ter[0].second, {i.first, ter[0].first}});
	
	for (auto i : graf[c])
		szuk(i.first);
}

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
		scanf("%lld", &tab[i]);
	for (int i=1; i<n; i++)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		//a=i;
		//b=i+1;
		//c=1;
		
		graf[a].push_back({b, c});
		graf[b].push_back({a, c});
	}
	szuk(1);
	
	for (int i=1; i<=n; i++)
		oj[i]=i;
	
	sort(kra.begin(), kra.end());
	
	for (auto i : kra)
	{
		int x=fin(i.second.first);
		int y=fin(i.second.second);
		if (x!=y)
		{
			oj[x]=y;
			wyn+=i.first;
		}
	}
	
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 104160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
map<pii,int>m;

vector<int>adjb[200005],adjr[200005];


#define MOD 1000000007
int main()
{


    ll n,m,i,ANS=0,ans=0,ans2=0;
    cin>>n>>m;
    ll ara[n],arb[m];
    for(i=0;i<n;i++) cin>>ara[i];
    for(i=0;i<m;i++) cin>>arb[i];
    ll mul=-n+1;
    for(i=0;i<n;i++) {
    ara[i]=(ara[i]*mul)%MOD;
    mul+=2;
    }

    mul=-m+1;
    for(i=0;i<m;i++) {
    arb[i]=(arb[i]*mul)%MOD;
    mul+=2;
    }
    for(i=0;i<n;i++) ans=(ans+ara[i])%MOD;
    for(i=0;i<m;i++) ANS=(ANS+(arb[i]*ans)%MOD)%MOD;
    cout<<ANS;





}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
using namespace std;
const int maxn = 1e5+10;
vector<int> v[maxn];
bool vis[maxn];
int a[maxn], num;
void d(int x){
	for(int i = 0; i < v[x].size(); ++i){
		int xx = v[x][i];
		if(vis[xx]) continue;
		vis[xx] = true, a[++num] = xx;
		d(xx); return ;
	}
}
int main(){
	int n, m, x, y, num2;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; ++i){
		scanf("%d%d", &x, &y);
		v[x].push_back(y), v[y].push_back(x);
	}
	vis[1] = true;
	a[num = 1] =  1;
	d(1),  num2 = num, d(1);
	printf("%d\n", num);
	for(int i = num2; i >= 1; --i){
		if(i == num2) printf("%d", a[i]);
		else printf(" %d", a[i]);
	}
	for(int i = num2+1; i <= num; ++i){
		printf(" %d", a[i]);
	}
	printf("\n");
	return 0;
}

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

typedef long long ll;

class Memo {
private:
	vector<ll> p;
	vector<ll> b;
	vector<ll> s;
public:
	Memo(ll N): p(N + 1), b(N + 1), s(N + 1) {
		p[0] = 1;
		b[0] = 0;
		s[0] = 1;

		for(int i = 1; i <= N; i++) {
			p[i] = p[i - 1] * 2 + 1;
			b[i] = b[i - 1] * 2 + 2;
			s[i] = p[i] + b[i];
		}
	}

	ll num(ll N, ll X) {
		if(N == 0) {
			return 1LL;
		}
		if(X == 0) {
			return 0LL;
		}
		if(X < s[N] / 2LL) {
			return num(N - 1LL, X - 1LL);
		}
		if(X == s[N] / 2LL) {
			return p[N - 1] + 1LL;
		}
		if(X < s[N] - 1LL) {
			return p[N - 1] + num(N - 1LL, X - s[N - 1] - 2LL) + 1LL;
		}

		return 2LL * p[N - 1] + 1LL;
	}
};

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

	ll N, X;
	cin >> N >> X;
	
	Memo memo(N);

	cout << memo.num(N, X - 1LL) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  int c[2][3],r,r_;
  double d;
  cin>>c[0][0]>>c[0][1]>>c[0][2];
  cin>>c[1][0]>>c[1][1]>>c[1][2];
  d = pow(pow((c[0][0]-c[1][0]),2) + pow(c[0][1]-c[1][1],2),0.5);
  r = c[0][2]+c[1][2];
  r_ = abs(c[0][2]-c[1][2]);
  //cout <<d<<" "<<r<<" "<<r_<<endl;
  if(d>r) cout<<"4"<<endl;
  else if (d == r) cout<<"3"<<endl;
  else if (r_ == d) cout<<"1"<<endl;
  else if (r_ < d && d < r) cout<<"2"<<endl;
  else if (r_ > d) cout<<"0"<<endl;
  //cout <<d<<" "<<r<<" "<<r_<<endl;
  return 0;
}



Measured memory_bytes: 3284
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];

  bool flag = true;
  map<int,int> mp;
  for(int i = 0;i < n;i++){
    int now= a[i];
    int cnt = 0;
    while(now % 2 == 0){
      now/=2;
      cnt++;
    }
    mp[cnt]++;
  }

  if(mp.size() != 1){
    cout << 0 << endl;
    return 0;
  }

  if(n == 1){
    ll ans = m/(a[0]/2) - m/a[0];
    cout << ans << endl;
  }
  else{
    ll g = gcd(a[0]/2,a[1]/2);
    ll lcm = (a[0]/2)*(a[1]/2)/g;
    for(int i = 0;i < n;i++){
      g = gcd(lcm,a[i]/2);
      lcm = lcm*(a[i]/2)/g;
    }
    ll ans = (m+lcm)/(2*lcm);
    cout << ans << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	int h, w;
	scanf("%lld%lld", &h, &w);
	int cnt = 0;
	rep(i,h){
		string str;
		cin >> str;
		rep(j,w)if(str[j] == '#')cnt++;
	}
	printf("%s\n", cnt == h+w-1 ? "Possible" : "Impossible");
	return 0;
}






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

ans=0
for i in range(m) :
    ans = ans+a[i]

day=n-ans

#if day>=0 :
#    print(day)
#else :
#    print(-1)

print(day if day >= 0 else "-1")

Measured memory_bytes: 9956
s=str(input())
arr=[0]
sumx=0
i=0
while(i<len(s)):
	if(s[i]=='<'):
		arr.append(arr[-1]+1)
		i+=1
	else:
		countx=0
		j=i
		while(j<len(s) and s[j]=='>'):
			countx+=1
			j+=1
		if(arr[-1]<countx):
			arr[-1]=countx
		while(i<j):
			arr.append(countx-1)
			countx-=1
			i+=1

print(sum(arr))



Measured memory_bytes: 24092
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S.at(i);
  }
  int result = INT_INF;
  for(int bit = 0; bit < (1<<(H-1)); bit++){
    int res = __builtin_popcount(bit);
    vi g(H);
    int gnum = 0;
    for(int i = 0; i < H; i++){
      g.at(i) = gnum;
      if((bit >> i)&1) gnum++;
    }
    vi count(H, 0);
    
    for(int i = 0; i < W; i++){
      vi nowcount(H, 0);
      for(int j = 0; j < H; j++){
        nowcount.at(g.at(j)) += S.at(j).at(i)-'0';
      }
      for(int j = 0; j < H; j++){
        count.at(j) += nowcount.at(j);
        if(count.at(j) > K){
          res++;
          for(int k = 0; k < H; k++){
            count.at(k) = nowcount.at(k);
            if(count.at(k) > K) res = INT_INF;
          }
          break;
        }
      }
    }
    chmin(result, res);
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;

int M;
int a[7];
int s, g;
int N[301];

bool isChecked[301];
vector<int> milestone[301];  //そのマスで出せばゴールにたどり着ける目を格納する

int iabs(int x){ return x >= 0 ? x : -x; }

bool search(int now){
	if (isChecked[now]) return false;
	else if (now == g)  return true;

	isChecked[now] = true;
	for (int dice = 1; dice <= 6; dice++){
		if (now + a[dice] <= M && search(now + a[dice] + N[now + a[dice]])){
			milestone[now].push_back(a[dice]);
		}
		if (now - a[dice] >= 1 && search(now - a[dice] + N[now - a[dice]])){
			milestone[now].push_back(-a[dice]);
		}
	}

	return milestone[now].size() > 0 ? true : false;
}

int main(){
	srand((unsigned int)time(NULL));
	cin >> M;
	for (int i = 1; i <= 6; i++){
		cin >> a[i];
	}
	cin >> s >> g;
	for (int i = 1; i <= M; i++){
		cin >> N[i];
	}
	bool canGoal = search(s);

	int now = s; //自分が今いるマスの番号
	for (;;){
		int dice;
		cin >> dice;

		bool found = false;
		for (vector<int>::iterator it = milestone[now].begin(); it != milestone[now].end(); it++){
			if (iabs(*it) == a[dice]){
				if (*it > 0){
					now = now + a[dice] + N[now + a[dice]];
					cout << 1 << endl;
				}
				else{
					now = now - a[dice] + N[now - a[dice]];
					cout << -1 << endl;
				}
				found = true;
				break;
			}
		}
		if(!found) cout << 0 << endl;
		cout.flush();

		if (now == g) return 0;
	}
	
	return 0;
}

Measured memory_bytes: 1308
n,m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
rem = {}
rem[0]=1
sum=0
ans=0
for i in a:
    sum+=i
    if (sum%m in rem): rem[sum%m] += 1
    else: rem[sum%m] = 1
    ans += rem[sum%m]-1
print(ans)


Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        int mx=max(max(a,b),c);
        int mn=min(min(a,b),c);
        printf("%d\n",mx-mn);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    ll a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if ((b - a) % 2 == 0) cout << a + (b - a) / 2 << endl;
    else cout << "IMPOSSIBLE " << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  long long d,min,max,sum=0;
  scanf("%d%lld",&n,&d);
  sum = min = max = d;
  while(--n > 0){
    scanf("%lld",&d);
    if (d > max)max = d;
    if (d < min)min = d;
    sum += d;
  }
  printf("%lld %lld %lld\n",min,max,sum);

  return 0;
}


Measured memory_bytes: 2096
while True:
    n = list(input())
    if n == list("-"):
        break
    m = int(input())
    for i in range(m):
        h = int(input())
        t = n[:h]
        del n[:h]
        n.append(t)
        n = [n for x in n for n in x]
    n = "".join(n)
    print(n)

Measured memory_bytes: 7636
m,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
res=0
for i in range(0,m):
    cnt += a[i]
    if cnt > x:
        res=i
        break
    elif cnt==x:
        res=i+1
        break
    if i == m-1 and cnt<x:
        res=m-1
if a[0] > x:
    res=0
print(res)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    int R;
    cin >> R;
    if (R < 1200)
    {
        cout << "ABC" << endl;
    }
    else if (R < 2800)
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  string s; cin >> s;
  int n = s.size();

  int ans = 1e9;

  rep(i, 26) {
    char c = alphabet[i];
    bool contain = 0;
    int maxStreak = 0;
    int streak = 0;
    rep(i, n) {
      if(s[i] == c) {
        contain = 1;
        streak = 0;
      } else {
        ++streak;
        chmax(maxStreak, streak);
      }
    }

    if(contain) {
      chmin(ans, maxStreak);
    }
  }

  cout << ans << endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<int>a(3); for(auto&i:a)cin>>i;
	sort(a.begin(),a.end());
	int ans=a.back()*2-a.at(1)-a.at(0);
	while(ans%2!=0)ans+=3;
	cout<<ans/2<<"\n"s;
}

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

#define repu(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a)    for(int i=0;i<a;i++)
#define ll long long
#define vi vector<int>
#define vll vector<ll>

using namespace std;

void calc(int x, vll &mx, vll &c, vi &p, int n, ll k)
{
    vi vis(n+1,0);
    vll val(n+1,0);
    int y=x;
    ll z=0;
    ll turn=1;
    while(vis[y]==0 && turn<=k)
    {
        vis[y]=turn;
        val[y]=z;
        z+=c[y];
        mx[x]=max(mx[x],z);
        y=p[y];
        turn++;
    }
    if(turn>k)
        return;
    ll nodes=turn-vis[y], left=k-turn+1, zz=left/nodes;
    if(zz>0)
        zz--;
    z+=zz*(z-val[y]);
    left=left-zz*nodes;
    mx[x]=max(mx[x],z);
    while(left)
    {
        z+=c[y];
        y=p[y];
        mx[x]=max(mx[x],z);
        left--;
    }
    return;
}

int main() {
    int n;
    cin>>n;
    ll k;
    cin>>k;
    vi p(n+1);
    vector<ll> c(n+1), mx(n+1,0);
    repu(i,1,n)
        cin>>p[i];
    repu(i,1,n)
    {
        cin>>c[i];
        mx[i]=c[i];
    }
    ll ans=mx[1];
    repu(i,1,n)
    {
        calc(i,mx,c,p,n,k);
        ans=max(mx[i],ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3768
#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;
#define N 50
int a[N+1], b[N+1], c[N+1], d[N+1];
int dis(int i, int j) {
    return abs(a[i] - c[j]) + abs(b[i] - d[j]);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    for(int i = 1; i <= m; i++) {
        cin >> c[i] >> d[i];
    }
    for(int i = 1; i <= n; i++) {
        int best = 1;
        for(int j = 1; j <= m; j++) {
            if(dis(i, best) > dis(i, j)) {
                best = j;
            }
        }
        cout << best << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

int getMinCost(vector<int> A, int k){
    if(A.size() < 2) return 0;

    vector<int> dp(A.size(), INT_MAX);

    dp[0] = 0;

    for(int i=1;i<A.size();i++){
        for(int j=i-1;(i-j) <= k && j>=0;j--){
            dp[i] = min(dp[i], dp[j] + abs(A[i]-A[j]));
        }
    }

    return dp[A.size()-1];

}

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

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

    cout<<getMinCost(A, k);
}


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

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

    int dig3, dig1;
    dig1 = n % 10;
    dig3 = n / 100;

    if (dig3 == dig1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

long long gcd(long long a, long long b) {
	return b ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}

signed main() {
	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;
	bool ok = true;
	long l = lcm(n, m);
	long N = l / n;
	long M = l / m;
	for (int i = 0; i <= n; i++) {
		if ((N * i) % M == 0) {
			if (s[i] != t[(N * i) / M]) {
				ok = false;
			}
		}
	}
	if (ok) cout << l << endl;
	else cout << -1 << endl;
	return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {


	int n;
	cin >> n;
	
	VVLL v(n, VLL(2));

	REP(i, n) {
		cin >> v[i][1] >> v[i][0];
	}

	sort(ALL(v));

	ll cur = 0;
	REP(i, n) {
		cur += v[i][1];
		if (cur > v[i][0]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	



}


Measured memory_bytes: 11136
N = int(input())
A = list(map(int, input().split()))

if N == 2:
  print(max(A[0], A[1]))
  exit()

DP = [[- 10 ** 10] * 3 for _ in range(N)]

DP[0][0] = A[0]
DP[1][0] = A[1]
DP[2][0] = A[0] + A[2]
DP[2][1] = A[2]

for i in range(3, N):
  DP[i][0] = DP[i - 2][0] + A[i]
  DP[i][1] = DP[i - 2][1] + A[i]
  DP[i][2] = DP[i - 2][2] + A[i]
  if i - 3 >= 0:
    DP[i][1] = max(DP[i][1], DP[i - 3][0] + A[i])
    DP[i][2] = max(DP[i][2], DP[i - 3][1] + A[i])
  if i - 4 >= 0:
    DP[i][2] = max(DP[i][2], DP[i - 4][0] + A[i])

ans = 0

if N % 2 == 0:
  ans = max(DP[-1][0], DP[-1][1])
  ans = max(ans, DP[-2][0])
else:
  ans = max(DP[-1][1], DP[-1][2])
  ans = max(ans, DP[-2][0])
  ans = max(ans, DP[-2][1])
  ans = max(ans, DP[-3][0])

print(ans)


Measured memory_bytes: 128324
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

#define size_t int

using namespace std;

int main(int argc, char const *argv[]) {
  int N, M;
  scanf("%d %d", &N, &M);
  int a = M / N;
  for (size_t i = a; i > 0; i--) {
    if (!(M % i) && M / i >= N) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}


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

class segtree{
public:
  int Node;
  vector<int> table;
  segtree(int);
  int ope(const int,const int);
  void update(int index,const int value){ // index is 0-indexed.
    index += Node; // query function
    table[index] += value;
    while(index > 0){
      index /= 2;
      table[index] += value;
    }
  }
  int find(int l, int r);
};
int segtree::find(int l,int r){ // l,r is 0-indexed.
    if(l == r) return table[r+Node];
    l += Node; r += Node;
    int ans = 0;
    for(; l <= r;l >>=1, r >>=1){
      if(r == l){ans+=table[l]; return ans;}
      if(r%2 == 0) ans+=table[r],--r;
      if(l%2) ans+=table[l],++l;
    }
    return ans;
}
segtree::segtree(int Max_Node){  // initialize
  Node = 2;
  while(Node < Max_Node)
    Node *= 2;
  table.resize(2*Node);
  for(int i = Node;i < Node*2; i++)
    table[i] = 0; // initialize
  for(int i= Node-1; i > 0; i--)
    table[i] = ope(table[i*2],table[i*2+1]);
}

int segtree::ope(const int a,const int b){
  return min(a,b);
}

int main () {
  int n,q;cin>>n>>q;
  segtree st(n);
  for(int i=0;i<q;++i){
    int c,x,y;cin>>c>>x>>y;
    if(c==0)
      st.update(x,y);
    else
      cout<<st.find(x,y)<<endl;
  }
}

Measured memory_bytes: 3864
import numpy as np
n=int(input())
if n==1:
  print(0)
else:
  def factorization(n):
      arr = []
      temp = n
      for i in range(2, int(-(-n**0.5//1))+1):
          if temp%i==0:
              cnt=0
              while temp%i==0:
                  cnt+=1
                  temp //= i
              arr.append([i, cnt])

      if temp!=1:
          arr.append([temp, 1])

      if arr==[]:
          arr.append([n, 1])

      return arr

  y=factorization(n)
  def judge(y):
    i=1
    while np.arange(i+2).sum()<=y:
      i+=1
    return i
  ans=0
  for i in range(len(y)):
    ans+=judge(y[i][1])
  print(ans)


Measured memory_bytes: 27144
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let al: usize = itr.next().unwrap().parse().unwrap();
    let bl: usize = itr.next().unwrap().parse().unwrap();

    let ar = al + w;
    let br = bl + w;
    if ar < bl {
        println!("{}", bl - ar);
    } else if br < al {
        println!("{}", al - br);
    } else {
        println!("{}", 0);
    }
}


Measured memory_bytes: 2104
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
char s[10];
int main()
{
    scanf("%s",s);
    int ans = 0;
    for(int i=0;i<4;i++){
        if(s[i]=='-') ans --;
        else ans ++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256