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

using namespace std;

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

    string w;

    cin >> w;
    vector<int> cnt(26, 0);
    for (auto c : w)
        ++cnt[(int)(c - 'a')];

    bool beauty = true;
    for (int i = 0; i < 26; ++i)
        if (cnt[i] % 2 != 0)
            beauty = false;

    cout << (beauty ? "Yes\n" : "No\n");

    return 0;
}


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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

int main(void){
	int i,a,m=0,ans;
	for(i=0; i<5; ++i){
		cin >> a;
		ans += (a/10)*10 + ((a%10)?10:0);
		m = max(m,(10-a%10)%10);
	}
	ans -= m;
	cout << ans << endl;
	return 0;
}


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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

    dump(tx-sx);
    REP(_, tx-sx) cout << "R";
    REP(_, ty-sy) cout << "U";
    REP(_, tx-sx) cout << "L";
    REP(_, ty-sy+1) cout << "D";
    REP(_, tx-sx+1) cout << "R";
    REP(_, ty-sy+1) cout << "U";
    cout << "LU";
    REP(_, tx-sx+1) cout << "L";
    REP(_, ty-sy+1) cout << "D";
    cout << "R" << endl;
    
    return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=1; i<=n; i++){
    if(i%2==0) continue;
    int cnt = 0;
    for(int j=1; j<=i; j++){
      if(i%j==0) cnt++;
    }
    if(cnt==8){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int d[100005];
    for(int i = 0; i < n; i++)cin >> d[i];
    sort(d, d+n);
    if(d[n/2] == d[n/2-1])cout << 0 << endl;
    else cout << d[n/2]-d[n/2-1] << endl;
    return 0;
}

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

using namespace std;

const int MAX_N = 1000000;

vector<int> tetra;
vector<int> tetra_odd;

short dp[MAX_N+1];
short dp_odd[MAX_N];

void init() {
	int n = 1;
	while (true){
		int m = n * (n + 1) * (n + 2) / 6;
		if (m >= MAX_N * 10) {
			break;
		}
		tetra.push_back(m);
		if (m % 2 == 1) {
			tetra_odd.push_back(m);
		}
		n++;
	}
}

void solve() {
	dp[0] = dp_odd[0] = 0;
	for (int i = 1; i < MAX_N; i++) {
		short ans = 10;
		short ans_odd = 100;
		for (int j = 0; tetra[j] <= i; j++) {
			//cout << i << " " << tetra[j] << endl;
			ans = min(ans, dp[i-tetra[j]]);
		}
		
		for (int j = 0; tetra_odd[j] <= i; j++) {
			ans_odd = min(ans_odd, dp_odd[i-tetra_odd[j]]);
		}
		dp[i] = ans + 1;
		dp_odd[i] = ans_odd + 1;
		//cout << i << " " << dp[i] << " " << dp_odd[i] << endl;
	}
}

int main() {
	init();
	solve();
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		
		cout << dp[n] << " " << dp_odd[n] << endl;
	}
}

Measured memory_bytes: 5128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char O[51],E[51],s[101];
    cin>>O>>E;
    int i,j,k;
    int m = strlen(O)-strlen(E);

    if(m==0)
    {
        k=0;
        for(i=0,j=0; i<strlen(O); i++,j++)
        {
            s[k] =O[i];
            k++;
            s[k] =E[j];
            k++;
        }
        s[k]='\0';
        cout<<s<<endl;
    }
    else if(m>0)
    {
        k=0;
        for(i=0,j=0; i<strlen(E); i++,j++)
        {
            s[k] =O[i];
            k++;
            s[k] =E[j];
            k++;
        }
        s[k]='\0';
        k=strlen(O)+strlen(E)-m;

        for(i=strlen(E);i<=strlen(O);i++)
        {
            s[k]=O[i];
            k++;
        }
        s[k]='\0';
        cout<<s<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
import collections
import math
import sys
N,K = map(int,input().split())
Ds = list(map(int,input().split()))
for n in range(N,100000):
    check = True
    for d in Ds:
        if str(d) in str(n):
            check = False
            break
    if check ==True:
        print(n)
        break

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

int main(){
	int k;
  	cin>>k;
  	int a, b;
  	cin>>a>>b;
  	int sum=k*(a/k);
  	while(1){
      	if(sum>b){
          	sum-=k;
          	break;
        }
      	sum+=k;
    }
  	
  	if(sum>=a){
    	cout<<"OK"<<endl;
    }else {
    	cout<<"NG"<<endl;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int n;
  cin >> n;
  map<string, int> s;
  rep(i, n) {
    string a;
    cin >> a;
    s[a]++;
  }
  int max = 0;
  for(auto itr = s.begin(); itr != s.end(); ++itr) {
    if(max < itr->second) {
      max = itr->second;
    }
  }

//  cout << endl;

  for(auto itr = s.begin(); itr != s.end(); ++itr) {
    if(max == itr->second) {
      cout << itr->first << endl; 
    }
  }

  return 0;
}

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

const int M = 1e5 + 7;
int a[M];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d",a + i);
    }

    ll s = 0;
    for(int i = 0; i < n; i++){
        s += abs(a[i + 1] - a[i]);
        //cout << s << endl;
    }

    s += abs(a[n]);

    //cout << s << endl;

    for(int i = 2; i <= n; i++){
        ll sub = 0, add = 0;
        sub += abs(a[i - 1] - a[i - 2]);
        sub += abs(a[i] - a[i - 1]);
        add += abs(a[i - 2] - a[i]);
        printf("%lld\n", s - sub + add);
    }
    //cout << " s = "<< s << endl;
    ll sub = 0, add = 0;
    sub += abs(a[n - 1] - a[n]);
    sub += abs(a[n]);
    add += abs(a[n - 1]);

    //cout << sub << ' ' << add << endl;

    printf("%lld\n",s - sub + add);

    return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        double[] ans = new double[N];
        for (int i = 0; i < N; i++)
        {
            x[i] = cin.nextInt();
            y[i] = cin.nextInt();
        }
        const int MAX = 250000;
        for (int i = 0; i < MAX; i++)
        {
            double best = -1e300;
            int p = 0;
            double r = Math.PI * 2 / MAX * i;
            for (int j = 0; j < N; j++)
            {
                double dist = Math.Sin(r) * x[j] + Math.Cos(r) * y[j];
                if(best < dist)
                {
                    p = j;
                    best = dist;
                }
            }
            ans[p] += 1.0 / MAX;
        }

        for (int i = 0; i < N; i++)
        {
            Console.WriteLine("{0:0.00000000000}", ans[i]);
        }

    }


}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc, char *argv[])
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    sum /= n;
    int ans1 = 0, ans2 = 0;
    rep(i, n)
    {
        ans1 += (a[i] - sum) * (a[i] - sum);
        ans2 += (a[i] - sum - 1) * (a[i] - sum - 1);
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  set<char>st;
  r(i,s.length())st.insert(s[i]);
  if(st.size()==s.length())cout << "yes"<<endl;
  else cout << "no"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; ++i) {
    cin >> p[i];
  }
  
  int sum = 0;
  for (int i = 0; i < K; ++i) {
    sum += p[i];
  }

  int mx_sum = sum;
  for (int i = K; i < N; ++i) {
    sum = sum - p[i - K] + p[i];
    mx_sum = max(mx_sum, sum);
  }

  double ans = double(mx_sum + K) / 2;
  cout << setprecision(20) << ans << endl;
  
  return 0;
}


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



int main()
{   
    int a[5];
   
    for(int i=0;i<5;i++){
     cin>>a[i];
    if(a[i]==0){
        cout<<i+1;
        return 0;
    }
    }
   return 0;
   }

Measured memory_bytes: 3620
unittest
{
	assert( [ "10 3", "4 5 6" ].parse.expand.solve == "Yes" );
	assert( [ "20 3", "4 5 6" ].parse.expand.solve == "No" );
	assert( [ "210 5", "31 41 59 26 53" ].parse.expand.solve == "Yes" );
	assert( [ "211 5", "31 41 59 26 53" ].parse.expand.solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hn = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( hn[ 0 ], as );
}

auto solve( long h, long[] as )
{
	return ( h <= as.sum ) ? "Yes" : "No";
}


Measured memory_bytes: 3888
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try {
		    Scanner sc=new Scanner(System.in);
		    int n=sc.nextInt();
		    int ar[]=new int[n];
		    for(int i=0;i<n;i++)
		    {
		        ar[i]=0;
		    }
		    int k=sc.nextInt();
		    for(int i=1;i<=k;i++)
		    {
		        int d=sc.nextInt();
		        for(int j=1;j<=d;j++)
		        {
		            int in=sc.nextInt();
		            ar[in-1]++;
		        }
		    }
		    int s=0;
		    for(int i=0;i<n;i++)
		    {
		        if(ar[i]==0)
		        s++;
		    }
		    System.out.println(s);
		    
		} catch(Exception e) {
		}
	}
}


Measured memory_bytes: 46196
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, k, val, ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> val;
        if (val >= k)
            ans += 1;
    }
    cout << ans << endl;
    return 0;
}




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

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

    int max_v = max({a, b, c});
    int sum = a + b + c;
    if ((max_v + sum) % 2 == 1) max_v++;

    cout << (3 * max_v - sum) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

N,K,L = map(int,input().split())

PQ = [[int(x) for x in input().split()] for _ in range(K)]
RS = [[int(x) for x in input().split()] for _ in range(L)]

P,Q = zip(*PQ)
R,S = zip(*RS)

g1 = csr_matrix(([1]*K,(P,Q)),(N+1,N+1))
g2 = csr_matrix(([1]*L,(R,S)),(N+1,N+1))

_,comp1 = connected_components(g1,directed = False,return_labels = True)
_,comp2 = connected_components(g2,directed = False,return_labels = True)

comp_pair = comp1.astype('int64') * (N+1) + comp2.astype('int64')
c = Counter(comp_pair)

answer = [str(c[comp_pair[i]]) for i in range(1,N+1)]
print(' '.join(answer))

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  ll buf2 = 0;
  ll buf3 = 0;
  bool judge = true;
  //cout<<<<endl;
  string a;
  ll b;
  vector<pair<string,pair<ll,ll>>> t(n);
  
  for(i=0;i<n;i++){
    cin>>a>>b;
    t[i]=MP(a,MP(-b,i+1));
  }
  sort(ALL(t));
  for(i=0;i<n;i++){
    cout<<t[i].second.second<<endl;
  }
  

  return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
N = 10**6  # N!まで求める
fact  = [1, 1]  # 階乗の元テーブル
fact_inv = [1, 1]  # 階乗の逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル 1,2,,...の逆元を求めてる

# 計算 O(1)
def comb(n, r, mod):
    if (r<0 or r>n):
        return 0
    r = min(r, n-r)
    return fact[n] * fact_inv[r] * fact_inv[n-r] % mod

# 順列
def perm(n, r, mod):
    if (r<0 or r>n):
        return 0
    return fact[n] *  fact_inv[n-r] % mod

# 前処理 O(n)
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    fact_inv.append((fact_inv[-1] * inv[-1]) % mod)

#####

s = int(input())

ans = 0
i = 1
while s - i*2 >= i:
    ans += comb(s-i*2-1, i-1, mod)
    ans %= mod
    i += 1

print(ans)

Measured memory_bytes: 212924
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
using namespace std;

int main(){
  int n,m,c; cin>>n>>m>>c;
  int a[n][m];
  int b[m];
  for(int i=0;i<m;i++) cin>>b[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    if(sum+c>0) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, n, i, min, pre, cur;

	scanf("%d", &n);

	scanf("%d", &min);
	scanf("%d", &pre);

	a = pre - min;
	if (min > pre) min = pre;

	for (i = 2; i < n; i++)
	{
		scanf("%d", &cur);
		b = cur - pre;
		c = cur - min;

		if (b > c) { if (a < b) a = b; }
		else if (a < c) a = c;

		if (min > cur) min = cur;

		pre = cur;
	}

	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 1848
using System;

namespace B
{
    class Program
    {
        static public int cnt =0;
        static public int d;
        static public int[,] X;
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);
            d = int.Parse(In[1]);
            X = new int[n, d];
            for(int i = 0; i < n; i++)
            {
                string[] In2 = Console.ReadLine().Split(' ');
                for(int j = 0; j < d; j++)
                {
                    X[i, j] = int.Parse(In2[j]);
                }
            }
            for (int i = 0; i < n-1; i++)
            {
                for (int j = i+1; j < n; j++)
                {
                    Check(i, j);
                }
            }
            Console.WriteLine(cnt);
        }
        static public void Check(int k,int m)
        {
            int sum = 0;
            for(int i = 0; i < d; i++)
            {
                sum += (int)Math.Pow(X[k, i] - X[m, i], 2);
            }
            double dis = Math.Sqrt(sum);
            if (dis % 1 == 0) cnt++;
        }
    }
}


Measured memory_bytes: 27580
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  int64 ret = 1;
  for (int i = 0; i < n; ++i) {
    int64 x;
    scanf("%lld", &x);
    ret = ret / __gcd(ret, x) * x;
  }
  printf("%lld\n", ret);
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  bool ha1=false;
  bool ha2=false;
  if(s[2]==s[3]){
    ha1=true;
  }
  if(s[4]==s[5]){
    ha2=true;
  }
  if(ha1==true && ha2==true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce

K = int(input())
ans = 0

def main(K):
    g=0
    for i in range(1,K+1):
        for j in range(1,K+1):
            for k in range(1,K+1):
                g += math.gcd(math.gcd(i, j), k)
    return (g)
 
print(main(K))

Measured memory_bytes: 9572
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std; 
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(x % y, y);
}
int main() {
	long long int A, B, C, D,CD,g,cc,dd,gg;
	cin >> A >> B >> C >> D;
	CD = C*D;
	g = C*D / gcd(C, D);
	cc = B / C - (A - 1) / C;
	dd = B / D - (A - 1) / D;
	gg = B / g - (A - 1) / g;
	cout << B - A+1 - cc - dd + gg;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	// #ifndef ONLINE_JUDGE   
 //    freopen("input.txt", "r", stdin); 
 //    freopen("output.txt", "w", stdout);    
 //    #endif 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
   	cin>>a[i];
   long long int count =0;
   for(int i=1;i<n;i++){
   	if(a[i-1]>a[i]){
   		count+=a[i-1]-a[i];
   		a[i]=a[i-1];
   	}
   }
   cout<<count;


}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  int max_v = 100000;
  vector<int> va(n), cnt1(max_v + 1, 0), cnt2(max_v + 1, 0);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
    if (i % 2 == 0) {
      cnt1[va[i]]++;
    } else {
      cnt2[va[i]]++;
    }
  }

  auto max2 = [](vector<int> &cnt) {
    int max1 = 0, max2 = 0;
    for (int i = 0; i < cnt.size(); i++) {
      if (cnt[max1] < cnt[i]) {
        max2 = max1;
        max1 = i;
      } else if (cnt[max2] < cnt[i]) {
        max2 = i;
      }
    }

    return array<int, 2>{max1, max2};
  };

  auto max2_even = max2(cnt1), max2_odd = max2(cnt2);
  int ans;
  if (max2_even[0] != max2_odd[0]) {
    ans = n - cnt1[max2_even[0]] - cnt2[max2_odd[0]];
  } else {
    ans = n - max(cnt1[max2_even[0]] + cnt2[max2_odd[1]],
                  cnt1[max2_even[1]] + cnt2[max2_odd[0]]);
  }

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


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

#define LL long long
#define int long long
#define PB push_back
#define N 500001
#define LG 22
#define MXQ 200001
#define M 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define LD double
#define F first
#define S second
#define ll long long
#define inf LLONG_MAX
#define endl "\n"

int32_t main()
{
    LL i,j,lt,d,z,v,c,r,l,q,x,y,m,n,x1,y1,t1,k;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>x>>y;
    k=x+y;
    k=max(k,x+x-1);
    k=max(k,y+y-1);
    cout<<k;
}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define TEST int t = 1; while(t--) solve()

void solve(){
    int n,m; cin>>n>>m;
    vector<int> a(n, 10);
    bool flag = false;
    for(int i=0;i<m;i++){
    	int idx,val; cin>>idx>>val; --idx;
    	if(a[idx] == 10 || a[idx] == val)
    		a[idx] = val;
    	else{
    		cout<<-1<<endl;
    		flag = true;
    	}
    }
    if(flag)
    	return;
    int ans = 0, i = 0;
    if(a[0] == 10 && n != 1)
    	a[0] = 1;
    if(a[0] == 0 && n != 1){
    	cout<<-1<<endl;
    	return;
    }
    for(int i=0;i<n;i++)
    	if(a[i] == 10)
    		a[i] = 0;
    for(;i<n;i++)
    	ans = ans*10 + a[i];
    cout<<ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST; return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Node {
	public int id, degree, depth, height;
	public Node parent, sibling, left, right;
	Node(int id) {
		this.id = id;
		this.degree = 0;
		this.depth = 0;
		this.height = 0;
	}
	void setLeft(Node node) {
		left = node;
		left.parent = this;
		degree++;
	}
	void setRight(Node node) {
		right = node;
		right.parent = this;
		degree++;
	}
	void setSibling() {
		if (left != null && right != null) {
			left.sibling = right;
			right.sibling = left;
		}
	}
	void setDepth(int depth) {
		this.depth = depth;
		if (left != null) left.setDepth(depth + 1);
		if (right != null) right.setDepth(depth + 1);
	}
	void setHeight(int height) {
		if (height >= this.height) {
			this.height = height;
		}
		if (parent != null) parent.setHeight(this.height + 1);
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Node[] tree = new Node[n];
		for (int i = 0; i < n; i++) {
			tree[i] = new Node(i);
		}
		for (int i = 0; i < n; i++) {
			Node node = tree[scanner.nextInt()];
			int left = scanner.nextInt();
			if (left != -1) node.setLeft(tree[left]);
			int right = scanner.nextInt();
			if (right != -1) node.setRight(tree[right]);
			node.setSibling();
		}
		Node root = null;
		for (int i = 0; i < n; i++) {
			if (tree[i].parent == null) {	
				root = tree[i];
				break;
			}
		}
		root.setDepth(0);
		for (int i = 0; i < n; i++) {
			tree[i].setHeight(0);
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append("node ");
			sb.append(tree[i].id);
			sb.append(": parent = ");
			sb.append(tree[i].parent == null ? -1 : tree[i].parent.id);
			sb.append(", sibling = ");
			sb.append(tree[i].sibling == null ? -1 : tree[i].sibling.id);
			sb.append(", degree = ");
			sb.append(tree[i].degree);
			sb.append(", depth = ");
			sb.append(tree[i].depth);
			sb.append(", height = ");
			sb.append(tree[i].height);
			sb.append(", ");
			if (tree[i].parent == null) {
				sb.append("root");
			} else {
				if (tree[i].left == null && tree[i].right == null) {
					sb.append("leaf");
				} else {
					sb.append("internal node");
				}
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 26156
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
using namespace std;

ll k,a,b;
ll bis;
ll ch;

int main(){
        cin >> k >> a >> b;
        bis = 1+k;
        if (b-a > 2){
                ch = (bis-a)/2;
                bis += ch*(b-a-2);
        }
        cout << bis << endl;
       
        return 0;
}


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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> m(n);
    for(int i=0; i<n; i++){
        cin >> m[i];
        x -= m[i];
    }
    cout << n +x/ *min_element(m.begin(), m.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

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

	int d,n;
	cin >> d >> n;

	if(n != 100){
		for(int i=0;i<d;i++){
			n *= 100;
		}
	}
	else{
		n = 101;
		for(int i=0;i<d;i++){
			n *= 100;
		}
	}
	cout << n << "\n";


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define STR_LEN 16
int main(void) {
    char str[STR_LEN];
    int chk[3] = {0};
    int i;
    char *p;
    int five=0,seven=0;

    p = fgets(str, STR_LEN, stdin);
    for(i=0;i<STR_LEN;i++){
        if(str[i] == ' '){
            str[i] = '\0';
            if(chk[0]) {
                chk[1] = atoi(p);
                chk[2] = atoi(&str[i+1]);
                break;
            } else {
                chk[0] = atoi(str);
                p = &str[i+1];
            }
        }
    }

    for(i=0;i<3;i++){
        if(chk[i] == 5)
            five++;
        else if(chk[i] == 7)
            seven++;
    }

    if(five == 2 && seven == 1){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    

    return 0;
}


Measured memory_bytes: 128
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	
	clock_t startTime=clock();

	ll a,b,c;
	cin>>a>>b>>c;
	ll num=a*100 + b*10 +c;
	if(num%4==0)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n = 0;
    long long int sum =0;
    cin >> n;
    for (int i = 0; i <= n; ++i) {
        if(not(i % 3 == 0 || i % 5 == 0)) {
            sum = i+sum;
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3576
s = input()
res = 753

for i in range(len(s)//3+1):
    #print(int(s[i*3:i*3+3]))
    try:
        res = min(res,abs(753-int(s[i*3:i*3+3])))
    except:
        pass
    try:
        res = min(res,abs(753-int(s[i*3+1:i*3+4])))
    except:
        pass
    try:
        res = min(res,abs(753-int(s[i*3+2:i*3+5])))
    except:
        pass
else:
    print(res)

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

#define sqr(A) (A) * (A)
using namespace std;
typedef long long ll;

const string P = "Positive", N = "Negative", Z = "Zero";

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	ll a, b;
	cin >> a >> b;
	if (a > 0 && b > 0)
		return cout << P << endl, 0;
	if (a <= 0 && b >= 0)
		return cout << Z << endl, 0;
	if (a < 0 && b < 0)
		if ((abs(a) - abs(b) + 1) % 2 == 0)
			return cout << P << endl, 0;
		else
			return cout << N << endl, 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<long long>
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = 998244353;
const ll INF = (ll)1e9+1;
const ll N = 1e5;

ll n, a[100001], pos[100001], ans=0;
set<ll> se;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        pos[a[i]] = i;
    }
    se.insert(0); se.insert(n+1);
    for(int i=n; i>0; i--){
        ll j = pos[i];
        auto rb = se.upper_bound(j);
        auto lb = prev(rb);
        if(*rb!=n+1){
            auto rrb = next(rb);
            ans += (*rrb-*rb) * (j-*lb) * i;
        }
        if(*lb!=0){
            auto llb = prev(lb);
            ans += (*lb-*llb) * (*rb-j) * i;
        }
        se.insert(j);
    }
    cout << ans;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
char s[12];
int c[12];
long long ans = 0;
int main(){
	cin >> (s+1);
	int n = strlen(s+1);
	c[0] = 1;
	c[1] = 1;
	for(int i = 2;i<=n;i++)
		c[i] = c[i-1] * 2;
	for(int i = 1;i<=n;i++){
		int res = 1;
		for(int j = 0;j<=n-i;j++){
			//cout << 1ll*res * (s[i]-'0') * c[n-j-1] << endl;
			if(j==n-i)ans += 1ll * res * (s[i]-'0') * c[n-j];
			else ans += 1ll * res * (s[i]-'0') * c[n-j-1];
			res *= 10;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (k, t) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }

    val max = aa.max()!!
    val rest = aa.sum() - max

    if (rest >= max - 1) {
        println(0)
    } else {
        println((max-1)-rest)
    }
}

Measured memory_bytes: 38012
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
#include <stack>
using namespace std;
int main(){
	int N, M; 
	cin >> N >> M; 
	int A[100010] = {}; 
	int I[100010] = {}; 
	vector<int> E[100010] = {}; // 出ていく辺
	vector<int> F[100010] = {}; // 入ってくる辺
	for(int i = 0; i < M; i++){
		int a, b; 
		cin >> a >> b; 
		E[a].push_back(b); 
		F[b].push_back(a); 
		I[b] ++; 
	}
	stack<int> st;
	for(int i = 1; i <= N; i++){
		if(!I[i]) st.push(i); 
	}
	vector<int> S = {}; //トポロジカルソート後
	while(st.size()){
		int i = st.top(); st.pop(); 
		S.push_back(i); 
		for(int j = 0; j < E[i].size(); j++){
			I[E[i].at(j)] --; 
			if(I[E[i].at(j)] == 0) st.push(E[i].at(j)); 
		}
	}
	int dp[100010] = {}; 
	int ans = 0; 
	for(int i = 0; i < N; i++){
		int mx = -1; 
		for(int j = 0; j < F[S[i]].size(); j++){
			mx = max(mx, dp[F[S[i]].at(j)]); 
		}
		dp[S[i]] = mx + 1; 
		ans = max(ans, dp[S[i]]); 
	}
	cout << ans << endl;  
}

Measured memory_bytes: 12540
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,m;
ll f[1000005],w[105],v[105];
int main(){
	in(n);in(m);
    for(int i=1;i<=n;i++)in(w[i]),in(v[i]);
    for(int i=1;i<=n;i++){
        for(int j=m;j>=w[i];j--){
            f[j]=max(f[j],f[j-w[i]]+v[i]);
        }
    }
    printf("%lld\n",f[m]);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

//ゲームは後ろから！

void solve() {
    int H, W, N; cin >> H >> W >> N;
    int sr, sc; cin >> sr >> sc;
    sr --; sc --;
    string S, T; cin >> S >> T;
    int l = 0, r = W, d = 0, u = H;
    //[ , )区間で考えるのが分かりやすい
    per(i, N) {
        if(i != N - 1) {
            if(T[i] == 'L') {
                if(r != W)  r += 1;
            } else if(T[i] == 'R') {
                if(l != 0) l -= 1;
            } else if(T[i] == 'U') {
                if(u != H) u += 1;
            } else if(T[i] == 'D') {
                if(d != 0) d -= 1; 
            }
        }

        if(S[i] == 'L') {
            l += 1;
        } else if(S[i] == 'R') {
            r -= 1;
        } else if(S[i] == 'U') {
            d += 1;
        } else if(S[i] == 'D') {
            u -= 1; 
        }

        if(l >= r || d >= u) {
            cout << "NO" << endl;
            return;
        }
    }
    if(sr >= u || sr < d || sc >= r || sc < l) {
        cout << "NO" << endl;
        return;
    }
    cout << "YES" << endl;
    return;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 920
#include<stdio.h>
char p[10001];
void setp()
{
  int i,j;
  p[0]=p[1]=1;
  for(i=2;i*i<=10000;i++){
    if(!p[i]){
      for(j=i*i;j<=10000;j+=i){
        p[j]=1;
      }
    }
  }
}
int main(void)
{
  setp();
  int n,i;
  for(;;){
    scanf("%d",&n);if(!n)break;
    for(;n;n--){
      if(!p[n-2]&&!p[n]){
        printf("%d %d\n",n-2,n);
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;

namespace AtCoder.ABC
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            var n = nm[0];
            var m = nm[1];

            var a = new bool[n][];
            for(int i = 0; i < n; i++) {
                a[i] = Console.ReadLine().Select(x => x == '.').ToArray();
            }

            var b = new bool[m][];
            for (int i = 0; i < m; i++) {
                b[i] = Console.ReadLine().Select(x => x == '.').ToArray();
            }

            var isOK = true;

            for(int i = 0; i < n - m; i++) {
                for(int j = 0; j < n - m; j++) {
                    isOK = true;
                    for(int k = 0; k < m; k++) {
                        for (int l = 0; l < m; l++) {
                            if(a[i + k][j + l] != b[k][l]) {
                                isOK = false;
                                break;
                            }
                        }

                        if(isOK == false) {
                            break;
                        }

                        if(k == m - 1) {
                            isOK = true;
                        }
                    }

                    if (isOK) {
                        break;
                    }
                }
                if (isOK) {
                    break;
                }
            }

            Console.WriteLine(isOK ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 28320
N = int(input())
alp="abcdefghijk"

s = "a"
def dfs(s,n,alp):
  if len(s) == n:
    print(s)
  else:
    for i in range(max([alp.find(s[i]) for i in range(len(s))])+2):
      s = s + alp[i]
      dfs(s,n,alp)
      s = s[:-1] 
dfs(s,N,alp)      

Measured memory_bytes: 4340
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()

typedef long long int ll;
typedef long double ld;

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

// order_of_key (k) : Number of items strictly smaller than k, basically 0-based index of k
// find_by_order(k) : K-th element in a set (counting from zero)

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int h, w; cin >> h >> w;
	queue <pi> Q;
	string s[h];
	int a[h][w], ans = 0;
	for (int i=0; i<h; ++i)
		cin >> s[i];
	for (int i=0; i<h; ++i)
		for (int j=0; j<w; ++j) {
			if (s[i][j] == '.') {
				Q.push(pi(i, j));
				for (int k=0; k<h; ++k)
					for (int l=0; l<w; ++l)
						a[k][l] = 1e6;
				a[i][j] = 0;
				while (!Q.empty()) {
					pi p = Q.front();
					Q.pop();
					if (p.fi - 1 >= 0 && s[p.fi-1][p.se] == '.' && a[p.fi-1][p.se] > 1 + a[p.fi][p.se]) {
						a[p.fi-1][p.se] = 1 + a[p.fi][p.se];
						Q.push(pi(p.fi-1, p.se));
					}
					if (p.fi + 1 < h && s[p.fi+1][p.se] == '.'&& a[p.fi+1][p.se] > 1 + a[p.fi][p.se]) {
						a[p.fi+1][p.se] = 1 + a[p.fi][p.se];
						Q.push(pi(p.fi+1, p.se));
					}
					if (p.se - 1 >= 0 && s[p.fi][p.se-1] == '.' && a[p.fi][p.se-1] > 1 + a[p.fi][p.se]) {
						a[p.fi][p.se-1] = 1 + a[p.fi][p.se];
						Q.push(pi(p.fi, p.se-1));
					}
					if (p.se + 1 < w && s[p.fi][p.se+1] == '.' && a[p.fi][p.se+1] > 1 + a[p.fi][p.se]) {
						a[p.fi][p.se+1] = 1 + a[p.fi][p.se];
						Q.push(pi(p.fi, p.se+1));
					}
				}
				for (int k=0; k<h; ++k)
					for (int l=0; l<w; ++l)
						if (s[k][l] == '.') ans = max(ans, a[k][l]);
			}
		}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,sum;
  char num[1001];
    
    for(;;) {
    scanf("%s", &num);

    if(num[0] == '0') 
    break;

    sum = 0;
    
    for(i=0;num[i]!='\0';i++)
      sum += num[i] - '0';
    printf("%d\n", sum);
  }
  
  return 0;
}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

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

    ios_base::sync_with_stdio(false);

    int x;
    cin >> x;
    cout << 1000 * (x / 500) + (x % 500) / 5 * 5 << "\n";
}


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

int main() {
  int h, n; cin >> h >> n;
  vector<int> vec(n);
  for (int i=0; i<n; i++) cin >> vec[i];
  
  int x = 0;
  for (int i=0; i<n; i++){
  x += vec[i];
  }
  
  if(x>=h) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct BellmanFord {
private:
    struct Edge { int from, to, cost; };
    vector<Edge> edges;
    int n;
    
public:
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    vector<bool> negative;
    
    BellmanFord() {}
    BellmanFord(int _n) {
        n = _n;
        dist.resize(n);
        negative.resize(n);
    }
    
    void add_edge(int from, int to, int cost) {
        edges.push_back((Edge){from, to, cost});
    }
    
    void get_distance(int from) {
        for (int i = 0; i < n; i++) {
            dist[i] = inf;
            negative[i] = false;
        }
        dist[from] = 0;
        for (int i = 0; i < (n - 1); i++) {
            for (auto e : edges) {
                if ((dist[e.from] != inf) && (dist[e.to] > (dist[e.from] + e.cost))) {
                    dist[e.to] = dist[e.from] + e.cost;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (auto e : edges) {
                if ((dist[e.from] != inf) && (dist[e.to] > (dist[e.from] + e.cost))) {
                    dist[e.to] = dist[e.from] + e.cost;
                    negative[e.from] = negative[e.to] = true;
                }
            }
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    BellmanFord<ll> bf(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        bf.add_edge(a, b, -c);
    }
    bf.get_distance(0);
    if (bf.negative[n - 1]) {
        cout << "inf" << endl;
    }
    else {
        cout << (-bf.dist[n - 1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

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

void sort(int *a, int *b, int *c){
  int tmp;
  if(*a == max(*a, max(*b, *c))){
    if(*b < *c) tmp = *b, *b = *c, *c = tmp;
  }else if(*b == max(*b, *c)){
    tmp = *a, *a = *b, *b = tmp;
    if(*b < *c) tmp = *b, *b = *c, *c = tmp;
  }else{
    tmp = *a, *a = *c, *c = tmp;
    if(*b < *c) tmp = *b, *b = *c, *c = tmp;
  }
}

int judge(int a, int b, int c){ // 1:直角三角形 2:鋭角三角形 3:鈍角三角形
  if(SQ(a) == SQ(b) + SQ(c)) return 1;
  if(SQ(a) < SQ(b) + SQ(c)) return 2;
  if(SQ(a) > SQ(b) + SQ(c)) return 3;
  return 0;
}

int main(){
  int A, B, C;
  ll res[4];
  memset(res, 0, sizeof(res));
  while(cin >> A >> B >> C){
    sort(&A, &B, &C);
    if(A >= B + C) break;
    res[0]++;
    res[judge(A, B, C)]++;
  }

  cout << res[0] << " " << res[1] << " " << res[2] << " " << res[3] << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){

  long n,a,b;
  scanf("%ld %ld %ld", &n, &a, &b);

  long dif = b-a;
  long tohead,totail;
  long round;
  if (dif%2 == 0) {
    round = dif/2;
  } else {
    tohead = a-1;
    totail = n-b;
    round = tohead;
    if (totail < tohead) {
      round = totail;
    }
    round++;
    dif--;
    round += dif/2;
  }

  printf("%ld\n", round);

  return 0;
}

Measured memory_bytes: 128
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N + 1):
        if (N - x - y >= 0) and (10000 * x + 5000 * y + 1000 * (N - x - y) == Y):
            print(x, y, N - x - y)
            break
    else:
        if x == N and y == N:
            print(-1, -1, -1)
        continue
    break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll mod = 1000000007;

ll power(ll a,ll b)
{
	ll r = 1;
	while(b>0)
	{
		if(b%2==1)
		{
			r = (mod+(r*a)%mod)%mod;
		}
		a = ((a*a)%mod+mod)%mod;
		b = b/2;
	}
	return r;
}

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	
	ll arr[n];
	
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	
	ll count = 0;
	ll i = 0;
	ll ans = 0;
	while(1)
	{
		ll k=0;
		ll b = 0;
		if(i<60){
			
			for(ll j=0;j<n;j++)
			{
				if(((arr[j]>>i)&1)==1)
				{
					k++;
				}
				else{
					b++;
				}
			}
		}
		count+=k*b;
		if(count%2==1)
		{
			ans = (mod+(ans+power(2,i))%mod)%mod;
		}
		count = count/2;
		if(count==0 and i>=60)break;
		i++;
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 2560