akhauriyash/Code-Regression huggingface dataset:
import sys

h, w = map(int, input().split())

array = ["".join(list(input())) for x in range(h)]

flag = True
for h_i in range(1, len(array)-2):
    for w_i in range(1, len(array[h_i]) - 2):
        if array[h_i][w_i] == "#" and array[h_i+1][w_i] == "." and array[h_i][w_i+1] == "." and \
                array[h_i - 1][w_i] == "." and "." == array[h_i][w_i - 1]:
            print("No")
            sys.exit()

print("Yes" if flag else "No")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <thread>
#include <chrono>
#include <queue>
#include <set>

using namespace std;

int main(void){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int counter = 0;
	for(int p=0;p<=a;p++){
		for(int q=0;q<=b;q++){
			for(int r=0;r<=c;r++){
				int tmp = 500*p + 100*q + 50*r;
				if(tmp==x){
					counter++;
				}
			}
		}
	}
	cout << counter << endl;
	return 0;
}

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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

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



template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

vector<long long> items= {100,101,102,103,104,105};

long long dp[10][100005];

int x;

bool possible(int pos,long long it)
{
    if(it==x){
        return true;
    }
    if(it>x){
        return false;
    }

    if(items.size()==pos){
        return false;
    }

    if(dp[pos][it]!=-1){
        return dp[pos][it];
    }
    bool taking=possible(pos,it+items[pos]);

    bool nottaking =possible(pos+1,it);

    return dp[pos][it]=taking|nottaking;
}

void solve()
{


    SET(dp);
    cin>>x;

    cout<<possible(0,0ll)<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);


    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 8064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	int N, ans;

	cin >> N;

	if(N / 100 == 1){
		ans = 900;
	} else {
		ans = 100;
	}

	N = N % 100;
	if(N / 10 == 1){
		ans += 90;
	} else {
		ans += 10;
	}

	N = N % 10;
	if(N / 1 == 1){
		ans += 9;
	} else {
		ans += 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	string s,t;cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<int>());
	cout<<(s<t?"Yes":"No")<<endl;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t h, w;
    cin >> h >> w;

    int64_t ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;

    vector maze(h + 2, vector(w + 2, false));
    for (auto i : irange(0L, h)) {
        string s;
        cin >> s;
        for (auto j : irange(0L, w)) {
            if (s[j] == '.') {
                maze[i + 1][j + 1] = true;
            }
        }
    }

    vector costs(h + 2, vector(w + 2, numeric_limits<int64_t>::max()));
    list<pair<int64_t, int64_t>> q;
    costs[ch][cw] = 0;
    q.emplace_back(ch, cw);
    while (!q.empty()) {
        auto [eh, ew] = q.front();
        q.pop_front();

        if (eh == dh && ew == dw) {
            cout << costs[dh][dw] << endl;
            return 0;
        }

        // cerr << eh << "," << ew << " " << costs[eh][ew] << endl;

        for (auto dy : irange(-2L, 3L)) {
            for (auto dx : irange(-2L, 3L)) {
                auto nh = eh + dy;
                auto nw = ew + dx;
                if (nh <= 0 || nh > h || nw <= 0 || nw > w) {
                    continue;
                }
                if (!maze[nh][nw]) {
                    continue;
                }

                auto edge_cost = (abs(dy) + abs(dx) == 1 ? 0 : 1);
                auto cost = costs[eh][ew] + edge_cost;
                if (cost < costs[nh][nw]) {
                    costs[nh][nw] = cost;
                    if (edge_cost == 0) {
                        q.emplace_front(nh, nw);
                    } else {
                        q.emplace_back(nh, nw);
                    }
                }
            }
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 12168
#include<bits/stdc++.h>
using namespace std;
struct Rest{
	int score;
	string s;
	int index;
};
bool comp(Rest a, Rest b){
	if(a.s<b.s){
		return true;
	}
	else if(a.s == b.s){
		if(a.score>b.score)return true;
		else return false;
	}
	else return false;
}
int main(){
	int n;
	cin>>n;
	Rest a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i].s>>a[i].score;
    	a[i].index=i+1;
	}
	sort(a, a+n, comp);
	for(int i=0;i<n;i++){
		cout<<a[i].index<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define int long long
    
signed main(){
    int n;cin >> n;
   // while(cin >> n){
        int q; cin >> q;
        vector<int> a(n,0);
        for(int i = 0; i < n; ++i) cin >> a[i];
        int x;
        for(int i = 0; i < q; ++i) {cin >> x;
int ans{};
            //syaku
            int left = 0;
            int right = 0;
            int sum = 0;
//            for(int right = left; i < n; ++i){
            for(left = 0; left < n; ++left){
       
                for(; right < n && sum + a[right] <= x; ++right)
                        sum += a[right];
    
                ans += (right-left);
    
                if(right == left) ++right;
                else sum -=a[left];
            }
    
cout << ans << endl;
    
    
        }
 //  }
    
    
    
    return 0;
}


Measured memory_bytes: 3592
package main

import (
	"fmt"
	"sort"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
	var n int; fmt.Scan(&n)
	l := make([]int, n)
	for i := 0; i < n; i++ {fmt.Scan(&l[i])}
	sort.Ints(l)

	cnt := 0
	for i := 0; i < n - 2; i++ {
		for j := i + 1; j < n - 1; j++ {
			k := sort.SearchInts(l, l[i] + l[j]) - 1
			cnt += maxInt(0, k - j)
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 640
import itertools
t = []
for _ in range(5):
    t.append(int(input()))

most_fast = 10**5

for i in itertools.permutations(t,5):
    time = 0
    for j in range(4):
        time += i[j]
        if time % 10 != 0:
            time += 10 - (time % 10)
    time += i[4]
    if time <= most_fast:
        most_fast = time

print(most_fast)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
char a[103];
long long len,k,ans,ans1,flag,flag2,fla=1e9;
long long check(long long x,long long y)
{
    return x/2+y/2;
}
int main()
{
    scanf("%s",a);
    cin>>k;
    len=strlen(a);
    for(int i=1;i<len;i++)
	if(a[i]!=a[i-1])
	    flag=1;
    if(flag==0&&len%2==1)
    {
	cout<<len*k/2;
	return 0;
    }    
    for(long long i=1;i<len;i++)
	if(a[i-1]!=a[i])
	{
	    flag2=i-1;
	    break;
	}
    for(long long i=len-1;i>=flag2+1;i--)
	if(a[i-1]!=a[i])
	{
	   fla=i;
	   break;
	}
	if(fla!=1e9&&a[flag2]==a[fla])
	{
	   ans1=(flag2+1+len-fla)/2;
	   for(long long i=flag2+1;i<=fla-1;i++)
	       if(a[i]==a[i-1])
		   a[i]='*',ans++;
	   cout<<ans*k+ans1*(k-1)+check(flag2+1,len-fla);
	}
	else
	{
	   for(long long i=1;i<len;i++)
	       if(a[i]==a[i-1])
		   a[i]='*',ans++;
	   cout<<ans*k;
	}
    return 0;
}


Measured memory_bytes: 256
n = int(input())
T = [int(input()) for _ in range(n)]

def gcd(a, b):
  if a > b:
    a, b = b, a
  while a % b != 0:
    a, b = b, a % b
  return b

def lcm(a, b):
  return a * b // gcd(a, b)

l = T.pop()
for t in T:
  l = lcm(l, t)
print(l)

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

int N,K;
double ans;

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

    cin>>N>>K;
    FOR( i,1,N )
    {
        double p = 1/(double)N;
        int n = i;
        while( n<K )
        {
            p/=2;
            n*=2;
        }
        ans+=p;
    }
    cout<<fixed<<setprecision(10)<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    llint N, A, B;
    cin >> N >> A >> B;
    if(N+1 < A+B) puts("-1");
    else if(A*B < N) puts("-1");
    else{
        vector<llint> P;
        llint now=A*B, ct=N-(A+B-1);
        REP(b, B){
            for(int a=A-1; a>=0; a--){
                if(a == A-1 || b == 0) P.pb(now-a);
                else if(ct > 0){
                    P.pb(now-a);
                    ct--;
                }else{
                    break;
                }
            }
            now -= A;
        }
        vector<llint> Pst = P;
        sort(All(Pst));

        REP(i, N){
            cout << (lower_bound(All(Pst), P[i])-Pst.begin())+1 << (i == N-1 ? "\n" : " ");
        }
    }
    
    return 0;
}

Measured memory_bytes: 8044
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int X;
    cin >> X;
    rep(A, -1000, 1000){
        rep(B, -1000, 1000){
            if (pow(A, 5) - pow(B, 5) == X){
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;

int  main()
{
	int k, x; cin >> k >> x;
	int s;
	int end = x + (k - 1);
	for (s = x - (k - 1); s <= end; s++)
	{
		if (s >= (-1000000) && s <= 10000000)
			cout << s << " ";
	}
	cout << endl;
	return (0);
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/ 
#include <iostream> 
#include <algorithm> 
#include <stdio.h> 
#include <cmath> 
#include <vector> 
#include <set> 
#include <map> 
#include <cstring> 
#include <unordered_map> 
#include <queue> 
#define   mod  998244353 
#define   int  long long  
#define   ld   long double 
#define   pb   push_back 
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   sz(x)  (int)x.size() 
#define   all(a) (a.begin(),a.end()) 
#define   ff   first 
#define   ss   second 
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 
 
inline void solve(){ 
    int p,n; cin>>p>>n; 
    vector <int> v; 
    if (p>=n) printf("1"); 
    else{ 
        map <int,int> cnt; 
        cnt.clear();
        for (int i=2;i*i<=n;i++){ 
            if (n%i==0) { 
                while (n%i==0) {
                    cnt[i]++;
                    n = n/i; 
                }
            } 
        } 
        cnt[n]++; 
        int ans=1;
        for (auto &it: cnt){
            if (it.ss>=p){
                ans *= pow(it.ff,(it.ss/p));
            }
        }
        cout << ans << endl;
    } 
} 
 
signed main() 
{ 
    int n=1; // cin>>n; 
    while (n--) solve(); 
    return 0; 
} 



/// 2 103 206 206 206 




Measured memory_bytes: 3904
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n, cnt1, cnt2, cnt3, a[MAXN];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif
	
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0) cnt1++;
		else {
			if (a[i] % 2 == 0) cnt2++;
			else cnt3++;
		}
	}
	
	if (cnt2 == 0) {
		if (cnt1 + 1 >= cnt3) cout << "Yes";
		else cout << "No";
	}
	else {
		if (cnt1 >= cnt3) cout << "Yes";
		else cout << "No";
	}


}


Measured memory_bytes: 768
from fractions import gcd
from functools import lru_cache

@lru_cache(maxsize=None)
def lcm(a, b):
    return a*b//gcd(a, b)

n = int(input())
t = 1
for _ in range(n):
    tt = int(input())
    t = lcm(t, tt)

print(t)


Measured memory_bytes: 5076
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut map = HashMap::new();
    for _ in 0..n {
        *map.entry(read::<usize>()).or_insert(0) += 1;
    }
    let m:usize = read();
    for _ in 0..m {
        *map.entry(read::<usize>()).or_insert(0) -= 1;
    }
    println!(
        "{}",
        if map.values().any(|&x| x < 0) {"NO"} else {"YES"}
    );
}


Measured memory_bytes: 8660
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    map<int, int> map;
    for(int i = 1; i <= N - 1; i++) {
        for(int j = i + 1; j <= N; j++) {
            int d = abs(X - i) + 1 + abs(j - Y);
            d = min(j - i, d);
            if(map.find(d) != map.end()) {
                map[d] += 1;
            } else {
                map[d] = 1;
            }
        }
    }
    for(int i = 1; i <= N - 1; i++) {
        if(map.find(i) != map.end()) {
            cout << map[i] << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
import numpy as np
import math
import itertools

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
  
n, d = (int(i) for i in input().split()) 
x = []
count = 0

for k in range(n):
  x.append([int(i) for i in input().split()])
  
for px, py in itertools.combinations(range(n), 2):
  vec_a = np.array(x[px])
  vec_b = np.array(x[py])
  if is_integer_num(np.linalg.norm(vec_a - vec_b)):
    count += 1
    
print(count)
  
    
 
    

Measured memory_bytes: 12436
#include<iostream>
#include<string.h>
using namespace std;

const int INF=50000000;

int data[51][12];

int main(){
	int M,T,P,R;
	while(cin>>M>>T>>P>>R && M){
		fill((int*)data,(int*)(data+51),0);
		for(int i=0;i<R;i++){
			int m,t,p,j;
			cin>>m>>t>>p>>j;
			if(j==0){
				data[t][0]++;
				data[t][11]+=m+data[t][p]*20;
			}
			else data[t][p]++;
		}
		int prev[2]={INF,0};
		for(int i=0;i<T;i++){
			int ans=0;
			int now[2]={0,INF};
			for(int j=T;j>=0;j--){
				if(data[j][0]>now[0]){
					now[0]=data[j][0];
					now[1]=data[j][11];
					ans=j;
				}
				else if(data[j][0]==now[0] && data[j][11]<now[1]){
					now[1]=data[j][11];
					ans=j;
				}
			}
			if(i){
				if(memcmp(now,prev,sizeof(now))==0)cout<<"=";
				else cout<<",";
			}
			cout<<ans;
			memcpy(prev,now,sizeof(now));
			data[ans][0]=-1;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1164
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;



int main() {
	ll n, k, x, y; cin >> n >> k >> x >> y;
	ll ans = x * min(k, n) + y * max(n - k, 0LL);
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		sc.close();

		int a = BigInteger.valueOf(n).gcd(BigInteger.valueOf(m)).intValue();
		int n2 = n / a;
		int m2 = m / a;
		for (int i = 0; i < a; i++) {
			if (s.charAt(n2 * i) != t.charAt(m2 * i)) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println((long) n2 * m2 * a);
	}
}


Measured memory_bytes: 28956
#include <stdio.h>
#include <math.h>
#define N 1000000000

int main(void){
    unsigned long long int s,t;
    unsigned long long int res[6] = {};
    int i,j;
    
    scanf("%llu", &s);
    i = (unsigned long long int)sqrtl(s);
    t = i+1;
    
    for(; i * t > s; i--){
        ;
    }
    
    
    res[2] = i+1;
    res[5] = t;
    if(res[2] * res[5] != s){
        t = res[2] * res[5] - s;
        j = (unsigned long long int)sqrtl(t) + 1;
           while(j > 1){
                if(t % j == 0){
                    break;
                }
                j--;
            } 
        
        
        res[3] = t / j;
        res[4] = j;
    }
    
    while(res[3] > N || res[5] > N || (res[2] * res[5] - res[3] * res[4]) != s){
        if(res[2] * res[5] == s){
            res[3] = 0;
            res[4] = 0;
            break;
        }else if(res[2] * res[5] > s){
            res[5]--;
            t = res[2] * res[5] - s;
            j = (unsigned long long int)sqrtl(t) + 1;
               while(j > 1){
                    if(t % j == 0){
                        break;
                    }
                    j--;
                } 
            
            
            res[3] = t / j;
            res[4] = j;
        }else{
            if(res[5] < N){
                res[5]++;
            }
            if(res[2] < N){
                res[2]++;
            }
        }
    }
    
    
    for(i = 0; i < 6; i++){
        printf("%llu ", res[i]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 128
/*
    oj d https://atcoder.jp/contests/abc166/tasks/abc166_b
    g++ B.cpp
    oj t
    oj s https://atcoder.jp/contests/abc166/tasks/abc166_b B.cpp
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N, K;
    cin >> N >> K;
    int s[N] = {};
    for(int i=0;i<K;i++){
        int d;
        cin >> d;
        for(int j=0;j<d;j++){
            int A;
            cin >> A;
            s[A-1] = 1;
        }
    }
        
    int ans = 0;
    for(int i=0;i<N;i++){
        if(s[i] == 0)
            ans++;
    }
        
    cout << ans << endl;

}

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

int main(){
  int N, M, x, y;
  cin >> N;
  M = N ;
  while (N != 0){
    x = x + N % 10;
    N = N / 10;
   }
  
  y = M % x;
 if (y == 0){ 
  cout << "Yes" << endl;
 }
  else{
   cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())						# 5
a = [int(i) for i in input().split()]	# 1 2 3 4 5 ...


a.sort(reverse=True)

s=0
t=0
x=0
y=0
for _ in range(N):
	i = a[_]
	if t==0:
		if(s==i):
			t = i
		else:
			s = i
	else:
		if(x==i):
			y = i
			break
		else:
			x = i


print(s * x)



Measured memory_bytes: 14244
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint H, W, K;
char mp[6][6];
int main() {
	cin >> H >> W >> K;
	REP(i, H) {
		REP(j, W) {
			cin >> mp[i][j];
		}
	}
	lint ans = 0;
	REP(i, 1 << H) {
		REP(j, 1 << W) {
			lint cnt = 0;
			REP(_i, H) {
				REP(_j, W) {
					if ((i >> _i) % 2 == 0 && (j >> _j) % 2 == 0 && mp[_i][_j] == '#') {
						cnt++;
					}
				}
			}
			if (cnt == K) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
def main():
    import collections
    n,x,y = map(int,input().split(" "))
    dp = [[0]*n for i in range(n)]

    for i in range(0,n):
        for j in range(i+1,n):
            if i < x-1:
                if j < x:
                    dp[i][j] =dp[i][j-1] +1
                if j >= x and j < y:
                    dp[i][j] = dp[i][x-1]+min(j-x+1,y-j)
                if j >=y:
                    dp[i][j] = dp[i][y-1]+j-y+1
            
            if i >= x-1 and i < y-1:
                if j < y:
                    dp[i][j] = dp[i][x-1]+min(j-i,y-x+1-(j-i))
                if j >=y:
                    dp[i][j] = dp[i][y-1]+j-y+1
            
            if i >= y-1:
                dp[i][j] = dp[i][j-1] + 1
    
    dp_fl = dp[0]
    for i in range(1,n):
        dp_fl += dp[i]

    cnts = collections.Counter(dp_fl)

    for i in range(1,n):
        print(cnts.get(i,0))
main()

Measured memory_bytes: 116008
S = gets.strip.to_s
N = S.size
a = S.slice(0..((N-3)/2))
b = S.slice(((N+1)/2)..N-1)
if a == a.reverse then
  if a == b then
    puts "Yes"
  else
    puts "No"
  end
else
  puts "No"
end

Measured memory_bytes: 14300
import sys
INF = 10 ** 10
MOD = 10 ** 9 + 7
from functools import lru_cache
sys.setrecursionlimit(100000000)

def main():
    a,b,c = map(int,input().split())
    print(a * b //2)
if __name__ =='__main__':
    main()   

Measured memory_bytes: 3572
def solve(current, x, y, z):
    if current == n:
        if min(x, y, z) > 0:
            return abs(a - x) + abs(b - y) + abs(c - z) - 30
        else:
            return 10 ** 9 + 7
    use_for_a = solve(current + 1, x + l[current], y, z) + 10
    use_for_b = solve(current + 1, x, y + l[current], z) + 10
    use_for_c = solve(current + 1, x, y, z + l[current]) + 10
    not_use = solve(current + 1, x, y, z)

    return min(use_for_a, use_for_b, use_for_c, not_use)

n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]
print(solve(0, 0, 0, 0))

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x;
string s,t;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	while(n > 0) {
		n-=1000;
	}
	cout<<-n;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int X, Y; cin >> X >> Y;
	int a, b;
	if (Y % 2 != 0) {
		cout << "No";
		return 0;
	}
	if (Y < 2 * X) {
		cout << "No";
		return 0;
	}
	if (X < (Y / 2 - X)) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

struct data{
  string name;
  int score;
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b;
  while(cin >> n ){
    if(n == 0){
      break;
    }
    vector<data> vs(n);
    vector<int> d[n];
    vector<int> m(n),u(n,0);
    vector<int> c(30,0);
    rep(_,n){
      cin >> vs[_].name;
      vs[_].score = 0;
      cin >> m[_];
      rep(i,m[_]){
        cin >> b ;
        d[_].pb(b);
        c[b]++;
      }
    }
    rep(i,n){
      rep(j,m[i]){
        vs[i].score += n - c[d[i][j]]+1;
      }
    }
    sort(all(vs),[](const data& a,const data& b){return a.score != b.score? a.score < b.score:a.name < b.name;});
//     rep(i,n){
//       cout << vs[i].first+" " << vs[i].second << ":" <<u[vs[i].second] <<endl;
//     }
    cout << vs[0].score << " "+vs[0].name <<endl;
  }
  return 0;
}

Measured memory_bytes: 3184
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    ans = A[-1]
    ans_cnt = 0
    for i in range(N-1)[::-1]:
        if ans_cnt == N-2:
            break
        ans += A[i]
        ans_cnt += 1
        if ans_cnt == N-2:
            break
        ans += A[i]
        ans_cnt += 1
        if ans_cnt == N-2:
            break
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 91992
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int main() {
    int n; cin >> n;
    rep(i,n/4 + 1){
        rep(j,n/7 + 1){
            if (4*i + 7*j == n) {
                cout << "Yes" << endl;
                return 0;
            } 
        }
    }
    print("No");
}

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

int main(){
    double W, H, x, y;
    int i = 0;
    cin >> W >> H >> x >> y;
    if(W/2.0 == x && H/2.0 == y) i = 1;
    cout << W*H/2.0 << " " << i <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	ArrayList<String> list = new ArrayList<String>();

	public static void main(String[] args) throws Exception {
		ArrayList<String> list = new ArrayList<String>();
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			String in = scan.nextLine();
			list.add(in);
		}
		scan.close();

		for (String str : list) {
			String[] strs = str.split(" ");
			long a = Long.valueOf(strs[0]);
			long b = Long.valueOf(strs[1]);

			long na = a;
			long nb = b;

			ArrayList<Long> listA = new ArrayList<Long>();
			ArrayList<Long> listB = new ArrayList<Long>();

			//最大公約数用の変数と最小公倍数用の変数を用意
			long s = 1;
			long t = 1;

			//入力値の2つを素因数分解
			for (long i = 2; na > 1 || nb > 1; i += 2) {
				while (na % i == 0 && nb % i == 0) {
					//aとbの両方で割り切れる場合
					//最大公約数用の変数にiをかける
					s *= i;
					//aとbの作業用変数を両方ともiで割る
					na /= i;
					nb /= i;
				}

				//片方の数だけ割り切れる数を保存
				while (na % i == 0) {
					//割り切れた場合は、割った数を保存
					listA.add(i);
					//現在値を割った後の値で更新
					na /= i;
				}
				//こちらも同様
				while (nb % i == 0) {
					listB.add(i);
					nb /= i;
				}

				if (i == 2) {
					//初期値は2だが、以降偶数で割り切れることはないため、
					//ここで1引いて、以後は2刻みの奇数でのみ確認
					i -= 1;
				}
			}

			t = s;
			for (long l : listA) {
				t *= l;
			}
			for (long l : listB) {
				t *= l;
			}

			System.out.println(s + " " + t);
		}
	}
}



Measured memory_bytes: 26076
#include <cstdio>
#include <vector>
#include <algorithm>

const int INF=1100000000;

int main()
{
  int n;
  scanf("%d",&n);
  std::vector<std::pair<int,int > > P(n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&P[i].first,&P[i].second);
  }
  std::sort(P.begin(),P.end());
  std::vector<int> AL(n+1),AR(n+1),BL(n+1),BR(n+1);
  AL[0]=0;
  AR[0]=INF;
  for(int i=0;i<n;i++){
    AL[i+1]=std::max(AL[i],P[i].first);
    AR[i+1]=std::min(AR[i],P[i].second);
  }
  BL[n]=0;
  BR[n]=INF;
  for(int i=n-1;i>=0;i--){
    BL[i]=std::max(BL[i+1],P[i].first);
    BR[i]=std::min(BR[i+1],P[i].second);
  }
  int ans=0;
  for(int i=1;i<n;i++){
    ans=std::max(ans,std::max(0,AR[i]-AL[i]+1)+std::max(0,BR[i]-BL[i]+1));
  }
  for(int i=0;i<n;i++){
    ans=std::max(ans,std::max(0,std::min(AR[i],BR[i+1])-std::max(AL[i],BL[i+1])+1)+(P[i].second-P[i].first+1));
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2688
import itertools
n,m,q = map(int,input().split())
a = [0 for _ in range(q)]
b = [0 for _ in range(q)]
c = [0 for _ in range(q)]
d = [0 for _ in range(q)]
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
e = list(map(list,itertools.combinations_with_replacement([i+1 for i in range(m)],n)))
ans = 0
for i in range(len(e)):
    current = 0
    for j in range(q):
        if e[i][b[j]-1] - e[i][a[j]-1] == c[j]:
            current += d[j]
    ans = max(ans,current)
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<char> S(N);
  bool ans = false;
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
    if (S.at(i) == 'Y') {
      ans = true;
    }
  }
  if (ans) {
    cout << "Four" << endl;
  }else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

long long dp[410][410];
vector<long long> a, sum;
const long long MAX = (long long)1e18;

long long calc(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(l == r) return 0;
    long long res = MAX;
    for(int k = l; k < r; k++){
        res = min(res, calc(l, k) + calc(k + 1, r) + sum[r] - sum[l - 1]);
    }
    return dp[l][r] = res;
}

int main(){
    int n;
    cin >> n;
    a = vector<long long>(n + 1);
    sum = vector<long long>(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    for(auto&& i : dp){
        for(auto&& j : i){
            j = -1;
        }
    }
    long long ans = calc(1, n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1536
#include<string.h>
#include<stdio.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x;
  x = Q[head];
  head=(head+1)%LEN;
   return x;


}
int min(int a,int b){
  return a<b? a:b;
}
int main(){
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;tail=n+1;   
  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}

Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back

int n;
int cnt[100010];

priority_queue<pp> pq;

int main()
{
    read(n);
    for(int i=1; i<=n; ++i){
		int x; read(x);
		++cnt[x];
    }
    for(int i=1; i<=int(1e5); ++i) pq.push(pp{cnt[i], i});
    int ans=n;
    while(pq.size()){
		int c, i; tie(c, i) = pq.top(); pq.pop();
		if(cnt[i] <= 1) break;
		
		if(pq.empty() || pq.top().first == 0){
			cnt[i] -= 2;
			ans -= 2;
			pq.push(pp{cnt[i], i});
			continue;
		}
		
		int j=pq.top().second; pq.pop();
		--cnt[i]; --cnt[j];
		ans -= 2;
		pq.push(pp{cnt[i], i});
		pq.push(pp{cnt[j], j});
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 1912
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

  vvi dp(n+1,vi(3,-INF));
  rep(i,3) dp[0][i] = 0;
  rep(i,n) {
    int a, b, c;
    cin >> a >> b >> c;
    vi x = {a,b,c};
    rep(j,3) {
      rep(k,3) {
        if (j == k) continue;
        chmax(dp[i+1][k], dp[i][j]+x[k]);
      }
    }
  }

  int ans = -INF;
  rep(i,3) chmax(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<algorithm>

using namespace std;

const int maxn = 1e5 + 5;
int dp[maxn][5],a[maxn][4];
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=3;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=1;i<=3;i++)
		dp[1][i]=a[1][i];
	for(i=2;i<=n;i++)
	{
		dp[i][1]=max(dp[i-1][2]+a[i][1],dp[i-1][3]+a[i][1]);
		dp[i][2]=max(dp[i-1][1]+a[i][2],dp[i-1][3]+a[i][2]);
		dp[i][3]=max(dp[i-1][2]+a[i][3],dp[i-1][1]+a[i][3]);
	}
	int ans=0;
	for(i=1;i<=3;i++)
		ans=max(dp[n][i],ans);
		printf("%d\n",ans);
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	string s;
 	cin>>s;
 	int i,n,f=0,g=0;
 	n=s.length();
 	for(i=0;i<n;i++)
 		{
 			if(s[i]!=s[n-i-1])
 				f=1;
		 }
	for(i=0;i<(n-1)/2;i++)
		{
			if(s[i]!=s[(n-1)/2-i-1])
				g=1;
		}
	if(f==0&&g==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
 	return 0;
 }

Measured memory_bytes: 3604
package main

import (
	"fmt"
	"math"
)

func main() {
	var x, a, b float64
	fmt.Scan(&x, &a, &b)
	if math.Abs(x-a) < math.Abs(x-b) {
		fmt.Println("A")
		return
	}
	fmt.Println("B")
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    int a;
    for (int i = 0; i < N; ++i) {
        cin >> a;
        A[a-1] = i+1;
    }
    for (int j = 0; j < N; ++j) {
        cout << A[j] << " ";
    }

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
#define pi acos(-1)
#define eps 0.000001
using namespace std;

int n;

struct node
{
    int n, id;
}nd[100005];

bool cmp(const struct node & a, const struct node & b)
{
    return a.n > b.n;
}

int main()
{
    int ans = 0;
    scanf("%d", &n);
    for(int i = 1;i <= 100000;i++)
        nd[i].n = 0, nd[i].id = i;
    for(int i = 1, a;i <= n;i++)
    {
        scanf("%d", &a);
        nd[a].n++;
    }
    sort(nd + 1, nd + 1 + 100000, cmp);
    int res = 0;
    for(int i = 1;i <= 100000;i++)
    {
        if(nd[i].n)
        {
            ans++;
            if(nd[i].n > 1)
                res += nd[i].n - 1;
        }
        else
            break;
    }
    if(res % 2)
        ans--;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector




signed solve()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }



    return 0;

}

//       g++ -g c.cpp ; ./a.exe

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

int ans = 0;

void dfs(long long now,long long end) {
	bool check3 = false, check5 = false, check7 = false;
	//cout << "今見る数字は" << now << endl;
	int num = now;
	if (now > end) {
		//cout << end << "以上だね。ここで再帰終了" << endl;
		return;
	}
	while (num) {//numの桁を一桁ずつ検査
		
		if (num % 10 == 3) {
			//cout << num << "から3を検知" << endl;
			check3 = true;
		}
		if (num % 10 == 5) {
			//cout << num << "から5を検知" << endl;
			check5 = true;
		}
		if (num % 10 == 7) {
			//cout << num << "から7を検知" << endl;
			check7 = true;
		}
		num = num / 10;
		if (check3 == true && check5 == true && check7 == true) {
			//cout << "七五三数だね" << endl;
			++ans;
			break;
		}
	}
	dfs((10 * now) + 3, end);
	dfs((10 * now) + 5, end);
	dfs((10 * now) + 7, end);
	return;
}

int main()
{
	long long N;
	ans = 0;
	cin >> N;

	dfs(0, N);

	cout << ans << endl;

}

Measured memory_bytes: 256
N, Y = map(int, input().split())

for man in range(Y // 10000 + 1):
    for go in range(Y // 5000 + 1):
        X = Y - man * 10000 - go * 5000
        if X < 0:
            continue
        sen = X // 1000
        if man + go + sen == N:
            print(man, go, sen)
            exit()

print('-1 -1 -1')

Measured memory_bytes: 40556
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <numeric>
#include <limits>

using namespace std;

typedef long long ll;

int main()
{
    int n,t;
    scanf("%d%d",&n,&t);
    int a[200010];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    ll res=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i+1]-a[i]>t)
            res+=t;
        else res+=(a[i+1]-a[i]);
    }
    res+=t;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K, x) binary_search(K.begin(), K.end(), x)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout << x << endl
#define put(x) out(x)
#define in(x) cin >> x
#define maxx(a, b, c) max(a, max(b, c))
#define minn(a, b, c) min(a, min(b, c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main()
{
    int x, y;
    in(x >> y);
    out(x + y / 2);
}


Measured memory_bytes: 256
import collections

def inverse_lookup(d, x):
    for k,v in d.items():
        if x == v:
            return k

n = int(input())
v_list = list(map(int, input().split()))
v_0_list = v_list[::2]
v_1_list = v_list[1::2]

v_0_count_dict = collections.Counter(v_0_list)
v_0_count_list = list(v_0_count_dict.values())
v_0_count_list.sort()
v_0_max_count = v_0_count_list[-1]
v_0_max = inverse_lookup(v_0_count_dict, v_0_max_count)

v_1_count_dict = collections.Counter(v_1_list)
v_1_count_list = list(v_1_count_dict.values())
v_1_count_list.sort()
v_1_max_count = v_1_count_list[-1]
v_1_max = inverse_lookup(v_1_count_dict, v_1_max_count)

ans = 0
if v_0_max == v_1_max:
    if len(v_0_count_list) == 1:
        if len(v_1_count_list) == 1:
            v_0_max_count = 0
            v_1_max_count = len(v_1_list)
        else:
            v_1_max_count = v_1_count_list[-2]
    else:
        if len(v_1_count_list) == 1:
            v_0_max_count = v_0_count_list[-2]
        else:
            if v_0_count_list[-1] - v_0_count_list[-2] < v_1_count_list[-1] - v_1_count_list[-2]:
                v_0_max_count = v_0_count_list[-2]
            elif v_0_count_list[-1] - v_0_count_list[-2] >= v_1_count_list[-1] - v_1_count_list[-2]:
                v_1_max_count = v_1_count_list[-2]
    ans += len(v_0_list) - v_0_max_count
    ans += len(v_1_list) - v_1_max_count
else:
    ans += len(v_0_list) - v_0_max_count
    ans += len(v_1_list) - v_1_max_count

print(ans)


Measured memory_bytes: 19552
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
Scanner s = new Scanner(System.in);
		int N = Integer.valueOf(s.next());
		int[] A = new int[N];
		
		long ret = 0;
		int cur = s.nextInt();
		int before = 0;
		for(int i = 1 ; i < N ; i++) {
			before = cur;
			cur = s.nextInt();
			if(before > cur) {
				ret += before - cur;
				cur  = before;
			}
		}
		System.out.println(ret);
	}
}

Measured memory_bytes: 59636
#include <vector>
#include <string>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cassert>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	long long arr[n];
	for (int i = 0; i != n; ++i)
		cin >> arr[i];
	
	long long sum = 0;
	for (int i = 0; i != n; ++i)
		sum += arr[i];
	
	long long ans = sum;
	long long curr = 0;
	for (int i = 0; i != n; ++i)
	{
		curr += arr[i];
		ans = min(ans, abs(sum - 2 * curr));
	}
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7;
int n,cnt,hd[N],v[N],nxt[N],w[N];
long long d[N];
void adde(int x,int y,int z){v[++cnt]=y,nxt[cnt]=hd[x],w[cnt]=z,hd[x]=cnt;}
void dfs(int u,int fa)
{
	for(int i=hd[u];i;i=nxt[i])
	if(v[i]!=fa)
	{
		d[v[i]]=d[u]+w[i];
		dfs(v[i],u);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1,x,y,z;i<n;i++)scanf("%d%d%d",&x,&y,&z),adde(x,y,z),adde(y,x,z);
	dfs(1,0);
	for(int i=1;i<=n;i++)
	{
		int op=d[i]&1;
		printf("%d\n",op);
	}
}

Measured memory_bytes: 6144