akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

constexpr double EPS = 1e-15;

int K, R, L;
double P, E, T;

VT( double ) ps;
double solve( const int k, const double l, const double r )
{
	const double t = ( l + r ) / 2;

	if ( k == K )
	{
		return abs( t - T ) <= E + EPS;
	}

	if ( T < l - E - EPS || r + E + EPS < T )
	{
		return 0;
	}

	if ( T - EPS <= t )
	{
		return P * solve( k + 1, t, r ) + ( 1 - P ) * solve( k + 1, l, t );
	}
	else
	{
		return P * solve( k + 1, l, t ) + ( 1 - P ) * solve( k + 1, t, r );
	}
}

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

	cin >> K >> R >> L;
	cin >> P >> E >> T;

	cout << setprecision( 9 ) << fixed << solve( 0, R, L ) << endl;

	return 0;
}

Measured memory_bytes: 1304
from collections import deque
import sys
input = sys.stdin.readline
h,w=map(int, input().split(' '))
a = [input() for i in range(h)]
nl = [[] for i in range(h)]
q = deque()
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            nl[i].append(0)
            q.append([i,j,0])
        else:
            nl[i].append(-1)
while q:
    [s,t,cnt] = q.popleft()
    if s>0 and nl[s-1][t] == -1:
        q.append([s-1,t,cnt+1])
        nl[s-1][t] = cnt+1
    if s<h-1 and nl[s+1][t] == -1:
        q.append([s+1,t,cnt+1])
        nl[s+1][t] = cnt+1
    if t>0 and nl[s][t-1] == -1:
        q.append([s,t-1,cnt+1])
        nl[s][t-1] = cnt+1
    if t<w-1 and nl[s][t+1] == -1:
        q.append([s,t+1,cnt+1])
        nl[s][t+1] = cnt+1
ans = 0
for i in range(h):
    ans = max(ans,max(nl[i]))
print(ans)

Measured memory_bytes: 154204
int main(void){
   int N,i;
   int a=0;
   char s[100];
   scanf("%d",&N);
   for(i=0;i<N;i++){
    scanf("%s",&s[i]);
    if(s[i]=='Y'){
      a=1;
    }
  }
  if(a==1){
    printf("Four");
  }else{
    printf("Three");
  }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int b=0,sum=0,n,a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        sum+=a;
        b-=a*a;
    }
    sum*=sum;
    sum+=b;
    cout << sum/2 <<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_10_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
           double[] Num = new double[str.Length];
            for (int i = 0; i < str.Length; i++)
            {
                Num[i] = 0;
                Num[i] = double.Parse(str[i]);
            }
            double Answer = Math.Sqrt((Num[2] - Num[0]) * (Num[2] - Num[0]) + (Num[3] - Num[1]) * (Num[3] - Num[1]));

            Console.WriteLine(Answer);
                    }
    }
}



Measured memory_bytes: 18052
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A, B, C, D = map(int, rl().split())
    cnt0 = -(-C // B)
    cnt1 = -(-A // D)
    if cnt0 > cnt1:
        print('No')
    else:
        print('Yes')
    

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9032
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;


int main()
{
	
	int a, b, c;
	string ans = "Yes";
	cin >> a >> b >> c;
	if (a != b || b != c) {
		ans = "No";
	}
	
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
n,k,s = map(int, input().split())
if s<5:
    xx = 1 + s
else:
    for i in range(2,s):
        if s%i != 0:
            xx = i
            break
ans = [xx]* n
for i in range(k):
    ans[i] = s
print(' '.join(map(str, ans)))

Measured memory_bytes: 12068
#include <vector>
#include <iostream>

using namespace std;


int J, Y;


void bfs(vector<char>& cs, int j, int y)
{
    if(j == J && y == Y){
        for(auto& e: cs) cout << e;
        cout << endl;
        return;
    }

    if((j == 5 && y <= 3) || (y == 5 && j <= 3)
    || (j == 5 && y == 5) || (y == 6 || j == 6))
        return;

    cs.push_back('A');
    bfs(cs, j+1, y);
    cs[j+y] = 'B';
    bfs(cs, j, y+1);
    cs.resize(j+y);
}

int main()
{
    vector<char> cs{};
    cin >> J >> Y;
    bfs(cs, 0, 0);

    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a(n); rep(i, n) cin >> a[i];

	deque<int> deq;
	rep(i, n) {
		int p = lower_bound(deq.begin(), deq.end(), a[i]) - deq.begin();
		if (p == 0) deq.push_front(a[i]);
		else deq[p - 1] = a[i];
	}
	cout << deq.size() << endl;
	return 0;
}


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

int main(){
  int M1,D1,M2,D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if (M1==M2){
    cout <<'0' <<endl;
  }
  else{
    cout <<'1' <<endl;
  }
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++)scanf("%d",&a[i]);
  int ans=4000000, sum;
  for(int i=-100;i<=100;i++){
    sum=0;
    for(int j=0;j<n;j++){
      sum+=(i-a[j])*(i-a[j]);
    }
    if(sum<ans)ans=sum;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc138/tasks/abc138_c

# サンプルから考えるに sort して最初から合成していくのがよいのでは
input()  # Skip
nums = list(map(int, input().split()))  # Numbers

if len(nums) == 1:
    print(nums[0])
    exit()

nums = sorted(nums)
avg = nums[0]
for i in range(len(nums) - 1):
    avg = (avg + nums[i + 1]) / 2

print(avg)
exit()


Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, char *argv[])
{
    char S[32], Ans[32] = {0};
    int i, n = 0;
    fgets(S, 32, stdin);
    for ( i = 0; S[i] != '\n'; i++ ){
        if ( S[i] == 'B' ){
            if ( n > 0 ){
                n--;
            }
        } else {
            Ans[n++] = S[i];
        }
    }
    Ans[n] = '\0';
    printf("%s\n", Ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(ll i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector< ll > vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;

// ll g[200000], ig[200000];



bool ok;

void dfs1(ll u, bool vis[], ll tot[], ll p[],ll h[], vll v[]){
    if(vis[u]==1) return;
    vis[u] = 1;

    ll sum = 0;

    sum += p[u];

    ll sorr = 0;

    for(ll i=1;i<v[u].size();i++){
        // cout<<'a';
        dfs1(v[u][i],vis,tot,p,h,v);
        sum+= tot[v[u][i]];
        sorr = sorr +  tot[v[u][i]] - h[v[u][i]];
    }

    // cout<<sum;

    tot[u] = sum;

    // if(tot[u]-h[u]>sorr){
    //     cout<<tot[u]-h[u]<<' '<<sorr<<'\n';
    //     ok = false;
    //     // cout<<"NOOOOO";
    // }

    return;

}

void dfs2(ll u, bool vis[], ll tot[], ll p[],ll h[], vll v[]){
    if(vis[u]==1) return;
    vis[u] = 1;

    // ll sum = 0;

    // sum += p[u];

    ll sorr = 0;

    for(ll i=1;i<v[u].size();i++){
        // cout<<'a';
        dfs2(v[u][i],vis,tot,p,h,v);
        // sum+= tot[v[u][i]];
        sorr = sorr +  tot[v[u][i]] - h[v[u][i]];
    }

    // cout<<sum;

    // tot[u] = sum;

    // cout<<sorr<<endl;

    if(tot[u]-h[u]>sorr + 2*p[u]){
        // cout<<u<<' '<<tot[u]-h[u]<<' '<<sorr<<'\n';
        ok = false;
        // cout<<"NOOOOO";
    }

    if((tot[u]-h[u])%2==1){
        ok = false;
    }

    if(h[u]>(tot[u]) or h[u]<(-tot[u])){
        ok = false;
    }

    return;

}


int dfs(int u,vector< vector< ll> > &v, bool vis[], vector <ll> &ans, int n){
    if(vis[u]==1)
        return 0;
    vis[u] = 1;

    int num = 0;
    for(int i=0;i<v[u].size();i++){
        int y = dfs(v[u][i],v,vis,ans,n);
        if(y) ans.pb(y);
        num+= y;
    }
    num++;

    return num;
}


void solve()
{	
    ll n,x,t;
    cin>>n>>x>>t;

    ll ans =t*(ceil(n/(x+0.0)));
    cout<<ans;

}

int main() {


    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif


    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
signed main(){
	int n;cin>>n;
	string s;
	rep(i,40){
		if(n>>i&1){
			s+='1';
			if(i%2==0){
				n-=(1<<i);
			}
			else{
				n+=(1<<i);
			}
		}
		else s+='0';
	}
	while(!s.empty()&&s.back()=='0')s.pop_back();
	reverse(s.begin(),s.end());
	if(s.empty())s="0";
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(long long i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main()
{
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a, b) << endl;
  return 0;
}

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

int main()
{
ll n , m ;
cin >> n >> m ;
vector<vector<ll>> g(n);
rep(i, m)
{
  ll a, b;
  cin >> a >> b;
  g[a - 1].push_back(b - 1);
  g[b - 1].push_back(a - 1); //無向辺
}
rep(i,n){
  if(g[i].size()%2!=0){
    cout << "No" << endl;
    return 0;
  }
}
ll f=0;
rep(i,n){
  if(g[i].size()>=6){
    cout << "Yes" << endl;
    return 0;
  }
  if(g[i].size()==4)f++;
}
if(f<2){
  cout << "No" << endl;
  return 0;
}
if(f>2){
  cout << "Yes" << endl;
  return 0;
}
vector<ll> t;
ll v;
rep(i,n){
  if(g[i].size()==4)v=i;
}
vector<ll> see(n);
see[v]=1;
queue<ll> q;
rep(i,4){
  q.push(g[v][i]);
}
while(!q.empty()){
  ll p=q.front();
  q.pop();
  if(g[p].size()==4){
    t.push_back(p);
    continue;
  }
  see[p]=1;
  rep(i,2){
    if(see[g[p][i]]==0)q.push(g[p][i]);
  }
}
if(t.size()==2){
  cout << "Yes" << endl;
  return 0;
}
else{
  cout << "No" << endl;
  return 0;
}
}

Measured memory_bytes: 6528
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

a,b,c,k = mi()

ima = k

if a >= k:
    print(k)
    exit()

ima = k - a

if b >= ima:
    print(a)
    exit()

ima = ima - b

nokori = min(c,ima)
print(a-nokori)


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











int N, A[16][16];
ll dp[1 << 16];
ll cst[1 << 16];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) rep(j, 0, N) cin >> A[i][j];

    rep(msk, 0, 1 << N) {
        rep(i, 0, N) rep(j, i + 1, N) if (msk & (1 << i)) if (msk & (1 << j)) cst[msk] += A[i][j];
    }

    rep(msk, 0, 1 << N) {
        for (int msk2 = msk; msk2 > 0; msk2 = (msk2 - 1)&msk) {
            ll nxt = dp[msk - msk2] + cst[msk2];
            chmax(dp[msk], nxt);
        }
    }

    cout << dp[(1 << N) - 1] << endl;
}


Measured memory_bytes: 1280
n,m=map(int,input().split())
A=[int(input()) for i in range(m)]
mod=10**9+7
flag=1
S=[0]*(n+3)
S[0],S[1],S[2]=[1,1,2]
SET=set(A)
if 1 in SET:
    S[1]=0
if 2 in SET:
    S[2]=0
if 1 in SET and 2 in SET:
    flag=0
for i in range(2,n+1):
    if i in SET:
        if i+1 in SET:
            flag=0
        S[i]=0
    elif i not in SET:
        S[i]=S[i-1]+S[i-2]
print(S[n]%mod if flag==1 else 0)


Measured memory_bytes: 460020
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int v[105],w[105];
long long dp[100005];
const int inf =0x3f3f3f3f;
int main()
{
	int n;
	long long W,V=0;
	cin>>n>>W;
	memset(dp,inf,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i],V+=v[i];
	for(int i=1;i<=n;i++)
		for(int j=V;j>=v[i];j--)
			dp[j]=min(dp[j-v[i]]+w[i],dp[j]);
			//dp[j]=max(dp[j-w[i]]+v[i],dp[j]);
	long long ans;
	for(int i=V;i>=0;i--)
		if(dp[i]<=W)
		 {
		 	ans=i;
		 	break;
		 }
	cout<<ans<<endl;	
	//long long ans=-1;
//	for(int i=0;i<=W;i++)
//		ans=max(ans,dp[i]);		
//	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int cmax = 100/4 + 1;
    int dmax = 100/7 + 1;
    for(int i=0;i<cmax;i++)
    {
        for(int j=0;j<dmax;j++)
        {
            if(i*4+j*7==n)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

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

ans = 0
cnt = 0
for i in range(K, N+1, K):
    cnt += 1
ans += pow(cnt, 3)

if K % 2 == 0:
    cnt = 0
    for i in range(K//2, N+1, K):
        cnt += 1
    ans += pow(cnt, 3)
print(ans)

Measured memory_bytes: 3064
using System;

class Program
{
    static string[] GetVals(string splitChar)
    {
        var src = Console.ReadLine();
        return src.Split(new string[] { splitChar }, StringSplitOptions.None);
    }

    static string[] GetVals(char splitChar)
    {
        var src = Console.ReadLine();
        return src.Split(splitChar);
    }

    static string GetVal()
    {
        return Console.ReadLine();
    }

    static void Write(object o)
    {
        Console.WriteLine(String.Format("{0}", o));
    }

    static int ParseI(string val) { return int.Parse(val); }
    static double ParseD(string val) { return double.Parse(val); }

    static void Main(string[] args)
    {
        var vals = GetVals(' ');
        int a = int.Parse(vals[0]);
        int b = int.Parse(vals[1]);

        if (b <= 1)
            Write(0);
        else
            Write((a - (b - 1)) - 1);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

using lint = long long;
using ldouble = long double;

int main() {
    int N, H, W;
    cin >> N >> H >> W;

    int ans = 0;
    for (int i = 0; i < N; i += 2) {
        int l[2] = {0, W}, r[2] = {W, W * 2};

        int x;
        cin >> x;
        l[0] += x, r[0] += x;

        cin >> x;
        l[1] -= x, r[1] -= x;

        ans += min(l[0], l[1]) + W * 2 - max(r[0], r[1]);
    }

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



Measured memory_bytes: 3116
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << abs(a-c)+abs(b-d)-gcd(abs(a-c),abs(b-d)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
int main(void) {
	int N;
	cin>>N;
	vector<ll> s(N);
	REP(i, N) cin>>s[i];
	ll sum = 0;
	REP(i, N) sum += s[i];
	sort(ALL(s));
 
	if(sum % 10 != 0) cout<<sum<<endl;
	else {
		ll hoge = -INF;
		REP(i, N) {
			if(s[i] % 10 != 0) {
				hoge = s[i];
				break;
			}
		}
		if(hoge != -INF) cout<<sum - hoge<<endl;
		else cout<<0<<endl;
	}
}
 

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

signed main() {
	string s;
	cin >> s;
	int num = count(all(s), 'o');
	int other = 15 - s.size();
	num += other;
	dbg(num)
	puts(num >= 8 ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 256
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
cnt = 0
for i in range(n):
	x -= a[i]
	if x >= 0:
		cnt += 1
	else:
		break
if x > 0:
	cnt -= 1
print(cnt)


Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1]<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

int A, B, C, D, E, X, Y, Z, N, M;
string S, T;
void solve() {
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5])print("Yes");
	else print("No");
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



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

int main() {
    string O, E;
    cin >> O >> E;

    rep(i, E.size()) {
        cout << O.at(i) << E.at(i);
    }
    if (E.size() < O.size()) {
        cout << O.at(O.size() - 1);
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}
string s;
int q,op,type,rev;
char c;
deque <char> start;
deque <char> finish;
int main() 
{   
    fast();
    cin>>s;
    cin>>q;
    while(q--)
    {
        cin>>op;
        if(op==1)
            rev++;
        else
        {
            cin>>type>>c;
            if(type==1)
            {
                if(rev%2==0)
                    start.push_front(c);
                else
                    finish.push_back(c);
            }
            else
            {
                if(rev%2==0)
                    finish.push_back(c);
                else
                    start.push_front(c);
            }
        }
    }
    if(rev%2==0)
    {
        while(!start.empty())
        {
            cout<<start.front();
            start.pop_front();
        }
        cout<<s;
        while(!finish.empty())
        {
            cout<<finish.front();
            finish.pop_front();
        }
    }
    else
    {
        while(!finish.empty())
        {
            cout<<finish.back();
            finish.pop_back();
        }
        reverse(s.begin(),s.end());
        cout<<s;
        while(!start.empty())
        {
            cout<<start.back();
            start.pop_back();
        }
    }
    return 0;
}

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

using ld = long double;
using vi = vector<int>;
#define rep(i, a, b) for(auto i = (a); i < (b); ++i)

int n;
const int MAXN = 300;
ld dp[MAXN + 5][MAXN + 5][MAXN + 5];

ld get(int i, int j, int k) {
  if (dp[i][j][k] != -1) return dp[i][j][k];
  if (i + j + k == 0) return 0;
  ld expected_turns = (ld) n / (i + j + k);
  dp[i][j][k] = expected_turns;
  if (i) dp[i][j][k] += (ld) i / (i + j + k) * get(i - 1, j, k);
  if (j) dp[i][j][k] += (ld) j / (i + j + k) * get(i + 1, j - 1, k);
  if (k) dp[i][j][k] += (ld) k / (i + j + k) * get(i, j + 1, k - 1);
  return dp[i][j][k];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n;
  vi a(4);
  rep(i, 0, n) {
    int v;
    cin >> v;
    a[v]++;
  }
  rep(i, 0, MAXN + 1) rep(j, 0, MAXN + 1) rep(k, 0, MAXN + 1)
    dp[i][j][k] = -1;
  cout << fixed << setprecision(11) << get(a[1], a[2], a[3]) << '\n';
}


Measured memory_bytes: 437888
import java.util.Scanner;
class Main{
    public static void main(String[] av){
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int m=sc.nextInt();
	int[][] a=new int[n][m];
	int[] b=new int[m];
	for(int i=0;i<n;i++){
	    for(int j=0;j<m;j++){
		a[i][j]=sc.nextInt();
	    }
	}
	for(int i=0;i<m;i++){
	    b[i]=sc.nextInt();
	}
	int[] c=new int[n];
	int ans;
	for(int i=0;i<n;i++){
	    for(int j=0;j<m;j++){
		c[i]=0;
		for(int k=0;k<m;k++){
			c[i]+=a[i][k]*b[k];
		}
		
	    }
	}
	for(int i=0;i<n;i++){
	    System.out.println(c[i]);
	}
    }
}



Measured memory_bytes: 40328
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
inline char get() {
	static char buf[10000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 10000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
inline void read(int &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

int n;
vector<int> adj[N];
int dp[N][2];
int deg[N];
bool vis[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read(n);
  if (n == 1) {
    puts("2");
    return 0;
  }
  for (int i = 0; i < n-1; i++) {
    int u, v; read(u); read(v); u--; v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
    deg[u]++;
    deg[v]++;
  }
  stack<int> q;
  for (int i = 0; i < n; i++) {
    if (deg[i] == 1) {
      q.push(i);
    }
  }
  int u = -1;
  while (!q.empty()) {
    u = q.top(); q.pop();
    vis[u] = 1;
    dp[u][0] = dp[u][1] = 1;
    for (int v : adj[u]) {
      if (vis[v]) {
        dp[u][0] = ((ll) dp[u][0]) * (dp[v][0] + dp[v][1]) % MOD;
        dp[u][1] = ((ll) dp[u][1]) * dp[v][0] % MOD;
      } else if (--deg[v] == 1) {
        q.push(v);
      }
    }
    //cerr << u << " -> " << dp[u][0] << " " << dp[u][1] << nl;
  }
  cout << (dp[u][0] + dp[u][1]) % MOD << nl;
  return 0;
}


Measured memory_bytes: 7932
n = int(input())
a = list(map(int,input().split()))
ave = sum(a)/len(a)
dis = []
for i in range(n):
  dis.append(abs(a[i]-ave))
mi = min(dis)
for i in range(n):
  if abs(a[i]-ave) == mi:
    print(i)
    exit()
  

Measured memory_bytes: 9168
#include<iostream>
using namespace std;
#define ll long long int 
int main(){
int n,w;
  cin>>n>>w;
  int val[n],wt[n];
  for(int i=0;i<n;i++){
    cin>>wt[i]>>val[i];
  }
  ll dp[n+1][w+1];
  for(int i=0;i<=n;i++){
    dp[i][0]=0;
  }
  for(int i=1;i<=w;i++){
    dp[0][i]=0;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=w;j++){
      if (j>=wt[i-1]){
        dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]);
      }
      else{
      dp[i][j]=dp[i-1][j];}
    }
  }
cout<<dp[n][w]<<endl;
return 0;
}

Measured memory_bytes: 82452
#include <iostream>
using namespace std;
 
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>

signed main(){
	int finalModu = 7 + 1e9;

	int n,k;
	cin>>n>>k;
	int minSum =0;
	int maxSum=0;
	int ans = 0;

	for(int i=k;i<=n+1;i++){
		minSum = ((i-1)*(i))/2;
		maxSum = (i*(2*n-i+1))/2;
		ans += maxSum - minSum +1;
	}
	cout<<ans%finalModu<<endl;
	return 0;
	
}

Measured memory_bytes: 3136
n = int(input())
h = list(map(int,input().split()))
dp = [0] * (n)
dp[1] = abs(h[0]-h[1])
for i in range(n-2):
    dp[i+2] = min(dp[i]+abs(h[i]-h[i+2]),dp[i+1]+abs(h[i+1]-h[i+2]))
print(dp[n-1])

Measured memory_bytes: 13980
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int m,n,x,y,a[105],b[105];
	cin>>m>>n>>x>>y;
	for(int i=0;i<m;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	sort(a,a+m);
	sort(b,b+n);
	if(a[m-1]<b[0] && b[0]>x && b[0]<=y)
		cout<<"No War"<<endl;
	else cout<<"War"<<endl; 
	return 0;
} 

Measured memory_bytes: 256
using System;

class AOJ
{
    public static void Main()
    {
        double x=0,y=0,temp=0;
        string ss = Console.ReadLine();
        string[] s = ss.Split(',');
        double r = int.Parse(s[0]);
        double th = int.Parse(s[1]);
        bool c = true;

        if (r == 0 && th == 0)
            c = false;

        y = r;
        temp = th;

        while (c)
        {
             ss = Console.ReadLine();
             s = ss.Split(',');
             r = int.Parse(s[0]);
            th = int.Parse(s[1]);

            if (r == 0 && th == 0)
                break;

            x +=  r * Math.Sin(Math.PI / 180 * temp);
            y +=  r * Math.Cos(Math.PI / 180 * temp);

            temp += th;
        }

        Console.WriteLine((int)x);
        Console.WriteLine((int)y);
    }
}

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

using namespace std;

const ll Mod = 1e9 + 7;

ll Rec(int i,bool IsLastBlack,int p);

vector <int> Edges[100100];
ll Dp[1000100][10];

int main()
{
    memset(Dp,-1,sizeof(Dp));

    int n;   cin>>n;

    for(int i=0;i<n-1;i++)
    {
        int x,y;    scanf("%d%d",&x,&y);

        Edges[x].push_back(y);
        Edges[y].push_back(x);
    }

    cout<<Rec(1,false,-1);
}

ll Rec(int i,bool IsLastBlack,int p)
{
    if(Dp[i][IsLastBlack]+1)    return Dp[i][IsLastBlack];

    ll Res1 = !IsLastBlack;
    ll Res2 = 1;

    for(int j=0;j<Edges[i].size();j++)
        if( Edges[i][j] != p )
            Res1 = ( Res1*Rec(Edges[i][j],true,i) )%Mod,
            Res2 = ( Res2*Rec(Edges[i][j],false,i) )%Mod;

    return Dp[i][IsLastBlack] = ( Res1 + Res2 )%Mod;
}

Measured memory_bytes: 90752
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<functional>
#include<iomanip>

#define LLI long long int

using namespace std;

int main(){
	int N,K;cin>>N>>K;
	vector<int>x(N);
	for(int i=0;i<N;i++)cin>>x[i];
	int ans=1000000007;
	for(int l=0;l<=N-K;l++){
		int r=l+K-1;
		if((l>0&&x[l-1]>0)||(r<N-1&&x[r+1]<0))continue;
		int tmp;
		if(x[l]>=0)
			tmp=x[r];
		else if(x[r]<=0)
			tmp=abs(x[l]);
		else if(abs(x[l])<abs(x[r])){
			tmp=2*abs(x[l])+abs(x[r]);
		}else{
			tmp=2*abs(x[r])+abs(x[l]);
		}
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;

	return 0;
}



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

int main() {
	int uriage[4];
	int t, n;
	
	
	for(int i = 1; i <= 4; i++){
		cin >> t >> n;
		switch(t){
		case 1:
			n *= 6000;
			break;
		case 2:
			n *= 4000;
			break;
		case 3:
			n *= 3000;
			break;
		case 4:
			n *= 2000;
			break;
		}
		cout << n << endl;
	}

	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
struct res{
	string s;
	int p;
	int num;

	bool operator<(const res &in) const{
		return s==in.s ? p<in.p : s<in.s;
	};
};

int main(){

	int n, pin;
	vector<res> v;

	cin>> n;
	v.resize(n);

	for(int i=0;i<n;i++){
		cin>> v[i].s >> pin;
		v[i].p=200-pin;
		v[i].num=i+1;
	}

	sort(v.begin(), v.end());//構造体xxxxのvalueをnumでソートする

	for(int i=0;i<v.size();i++) cout<< v[i].num << endl;

}

Measured memory_bytes: 256
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
int pa[200008],a[200008];
int fin(int x)
{
	if(pa[x]==x) return x;return pa[x]=fin(pa[x]);
}
set<int> v1[200008];int v2[200008];
int ans;
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	 int n,m;cin>>n>>m;
	 for(int i=0;i<n;i++) cin>>a[i+1],pa[i+1]=i+1;
	 for(int i=0;i<m;i++)
	 {
	 	int x,y;cin>>x>>y;pa[fin(x)]=fin(y);
	 }
	 for(int i=1;i<=n;i++)
	 {
	 	v1[fin(i)].insert(a[i]),v1[fin(i)].insert(i);v2[i]+=2;
	 }
	 for(int i=1;i<=n;i++)
	 {
		ans+=v2[i]-v1[i].size();
	 }cout<<ans;
	return 0;
}

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

void solve(int n,int m){
    vector<map<int,int>> wmp(n);//idx to w
    vector<int> pos(n);
    iota(pos.begin(),pos.end(),0);
    while(m--){
        char type;
        int a,b;
        cin>>type>>a>>b;
        a--,b--;
        if(type=='?'){
            if(pos[a]==pos[b]){
                cout<<wmp[pos[a]][b]-wmp[pos[b]][a]<<"\n";
            }
            else{
                cout<<"UNKNOWN\n";
            }
        }
        else{
            int w;
            cin>>w;
            if(pos[b]==pos[a]) continue;
            //b-a=w b=a+w
            //merge to a
            if(wmp[pos[a]].size()<wmp[pos[b]].size()){
                w=-w;
                swap(a,b);
            }
            int wa=wmp[pos[a]][a];
            int wb=wmp[pos[b]][b];
            for(auto &e:wmp[pos[b]]){
                int idx=e.first;
                int we=e.second;
                wmp[pos[a]][idx]=(we-wb)+wa+w;
                pos[idx]=pos[a];
            }
        }
    }
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    while(cin>>n>>m,n){
        solve(n,m);
    }
    return 0;
}


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

int main(){
  int N, M;
  vector<pair<int64_t, int64_t>> PY(100010);

  cin >> N >> M;
  for(int i=0; i<M; i++){
    int64_t P, Y;
     cin >> P >> Y;
     PY[i].first = P * 1e10 + Y;
     PY[i].second = i+1;
  }

  sort(PY.begin(), PY.begin()+M);

  vector<pair<int64_t,int64_t>> ans(100010);

  int64_t cnt = 1;
  for(int i=0; i<M; i++){
    int64_t P = PY[i].first / 1e10;
    int64_t num = P*1e6 + cnt;

    ans[i].second = num;
    ans[i].first = PY[i].second;

    int64_t nP = PY[i+1].first / 1e10;
    if(P == nP){
      cnt++;
    } else {
      cnt = 1;
    }
  } 

  sort(ans.begin(), ans.begin()+M);

  for(int i=0; i<M; i++){
    cout << setfill('0') << right << setw(12) << ans[i].second << endl;
  }
}
  
  

Measured memory_bytes: 4608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  ll a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld",&n,&m);
  rep(i,n) scanf("%lld",&a[i]);
  
  result = a[0]-m;
  for(i=1;i<n;i++){
    result = gcd(result,a[i]-m);
  }
  printf("%lld",max(result,-result));
  
  return 0;
}



Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int n, pgf[100001], pgb[100001], ans = 0;

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

	cin >> n;
	for(int i = 1; i<=n; i++){
		cin >> pgf[i]; pgb[i] = pgf[i];
	}

	for(int i = 2; i<=n; i++)
		pgf[i] = __gcd(pgf[i],pgf[i-1]);
	
	for(int i = n-1; i>=1; i--)
		pgb[i] = __gcd(pgb[i], pgb[i+1]);

	ans = max(pgf[n-1], pgb[2]);
	for(int i = 2; i<=n-1; i++)
		ans = max(ans, __gcd(pgf[i-1], pgb[i+1]));
	
	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 1024
def gcd_trio(a, b, c):
  return gcd(gcd(a, b), c)

def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    memo[a][b] = a
    return memo[a][b]

  if memo[a][b] != 0:
    return memo[a][b]
  else:
    memo[a][b] = gcd(b, a%b)
    return memo[a][b]

K = int(input())
memo = [[0 for _ in range(K + 1)] for _ in range(K + 1)]

total_gcd = 0
for i in range(1, K + 1):
  for j in range(1, K + 1):
    for k in range(1, K + 1):
      total_gcd += gcd_trio(i, j, k)

print(total_gcd)


Measured memory_bytes: 69736
#include<stdio.h>
#include<math.h>
#include<limits.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define LARGE 100001

int a[LARGE]={0};
int Add[LARGE]={0};
int b,n;

int main(){

	int q,i,j,com;
	int x,y,z;
	
	scanf("%d %d",&n,&q);
	
	b=sqrt(n);
	
	for(j=0;j<q;j++){
	
		scanf("%d",&com);
		
		if(com==1){/*get*/
			scanf("%d",&x);
			printf("%d\n",a[x]+Add[x/b]);
		}
		
		else {/*update*/
			scanf("%d %d %d",&x,&y,&z);
			if(y/b-x/b<2){
				for(i=x;i<=y;i++)a[i]+=z;
			}
			else {
				for(i=x;i<=MIN(y,(x/b+1)*b-1);i++)a[i]+=z;
			
				for(i=x/b+1;i<y/b;i++)Add[i]+=z;
			
				for(i=MAX(x,y/b*b);i<=y;i++)a[i]+=z;
				
			}
		}
		
	}
	
	return 0;
	
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, t;
  cin >> n >> t;
  ll sum = 0;
  vi time(n);
  rep(i,n) cin >> time[i];
  sum += t;
  REP(i,n){
    if(time[i-1] + t <= time[i]) sum += t;
    else sum += (t - (time[i-1] + t - time[i]));
  }
  cout << sum << endl;
}

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

const int M = 1000000007;

int dfs(int p, vector<vector<int>>& edge, vector<int>& col) {
    int ret = (col[p] ? 1 : -1);
    for (int i : edge[p]) {
        if (col[i] == col[p])
            return M;
        if (col[i] == 1 - col[p])
            continue;

        col[i] = col[p] ^ 1;
        int t = dfs(i, edge, col);
        if (t == M)
            return M;

        ret += t;
    }
    return ret;
}

int main() {
    int v, e;
    cin >> v >> e;
    vector<vector<int>> edge(v);
    for (int i = 0; i < e; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> col(v, -1);
    vector<int> pm;
    int sum = 0, c1 = 0;
    for (int i = 0; i < v; ++i) {
        if (col[i] == -1) {
            col[i] = 0;
            int t = dfs(i, edge, col);
            if (t == M) {
                cout << "-1\n";
                return 0;
            }
            if (t < 0) t = -t;
            if (t == 1) ++c1;
            sum += t;
            if (t > 0) pm.push_back(t);
        }
    }
    if (c1 >= sum / 2) {
        long long a = v / 2;
        long long b = v - a;
        cout << (a * b - e) << "\n";
        return 0;
    }
    vector<int> dp(sum + 1, 0);
    dp[0] = 1;
    for (int i : pm) {
        for (int j = sum; j >= i; --j) {
            dp[j] |= dp[j - i];
        }
    }
    long long ma = 0;
    long long vv = (v - sum) / 2;
    for (int i = 0; i <= sum; ++i) {
        if (dp[i]) {
            ma = max(ma, (vv + i) * (vv + sum - i));
        }
    }
    cout << (ma - e) << "\n";
    return 0;
}

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

using namespace std;

int main()
{
	string a,t;
	cin>>a>>t;
	int l=a.size();
	int flag=0;
	for(int i=0;i<l;i++)
	{
		if(a[i]!=t[i])
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
		cout<<"No\n";
	else
		cout<<"Yes\n";
}


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


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

    int cnt[m+1];
    for (int i=0; i < m+1; i++){
        cnt[i] = 0;
    }

    for (int i=0; i < n; i++){
        for (int j=0; j < m; j++){
            cnt[a[i][j]]++;
        }
    }

    int res = 0;
    for (int i=1; i < m+1; i++){
        if (cnt[i] == n) res++;
    }


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


    

    return 0;
} 



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib> //abs(int)
using namespace std;
int main(void){
  int a;
  cin >> a /*>> c >> d*/;
  if(a % 2 == 0){
    a = a / 2;
    cout << a * a;
  } else {
    a = a / 2;
    cout << a * (a + 1);
  }
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m,a,b = LI()
    if n * m < (a+b) * 2:
        return 'NO'
    r = [['.']*m for _ in range(n)]
    if n % 2 == 1:
        for i in range(min(a,m//2)):
            r[-1][i*2] = '<'
            r[-1][i*2+1] = '>'
            a -= 1

    if m % 2 == 1:
        for i in range(min(b,n//2)):
            r[i*2][-1] = '^'
            r[i*2+1][-1] = 'v'
            b -= 1

    if (a%2) * (b%2) * (n%2) * (m%2) == 1 and n > 2 and m > 2:
        r[-1][-1] = 'v'
        r[-2][-1] = '^'
        r[-3][-1] = '>'
        r[-3][-2] = '<'
        r[-3][-3] = '^'
        r[-2][-3] = 'v'
        a -= 1
        b -= 1

    for i in range(n//2):
        for j in range(m//2):
            if a > 0:
                r[i*2][j*2] = '<'
                r[i*2][j*2+1] = '>'
                if a > 1:
                    r[i*2+1][j*2] = '<'
                    r[i*2+1][j*2+1] = '>'
                a -= 2
            elif b <= 0:
                break
            else:
                r[i*2][j*2] = '^'
                r[i*2+1][j*2] = 'v'
                if b > 1:
                    r[i*2][j*2+1] = '^'
                    r[i*2+1][j*2+1] = 'v'
                b -= 2

    if a > 0 or b > 0:
        return 'NO'

    return 'YES\n' + '\n'.join([''.join(c) for c in r])


print(main())




Measured memory_bytes: 86892
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main() {
    string t1 , t2 , t3 , x = "" ;
    cin >> t1 >> t2 >> t3 ;
    x += t1[0] ;
    x += t2[1] ;
    x += t3[2] ;
    cout << x ;
    return 0 ;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	string s;
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC";
	}
	else{
		cout<<"ABC";
	}
	re 0;
}

Measured memory_bytes: 3624