akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
#include<tuple>
#define all(c) c.begin(),c.end()
#define tr(x,n) for(int i=x;x<n?i<n:i>=n;x<n?i++:i--)
#define ll long long int
#define pb push_back
#define em emplace_back
#define mp make_pair
#define mt make_tuple
#define debug(c) cout<<c<<endl;
#define isro ios_base::sync_with_stdio(false);
#define find(v,x) find(all(v),x)!=v.end()


using namespace std;
typedef vector<ll>vi;
typedef vector<vi>vii;
typedef pair<ll,ll>pi;
typedef tuple<ll,ll,ll>ti;

int main(){
    isro;
    ll n,x;
    cin>>n>>x;

    vi d(n+2,0);
    vi l(n+2,0);
    for(int i=1;i<=n;i++){
        cin>>l[i];
    }
 
    ll count=0;
    for(ll i=2;i<=n+1;i++){
        d[i]=d[i-1]+l[i-1];
//        cout<<d[i]<<" ";
        if(d[i]<=x)
            count++;
    }

    if (d[1]<=x)
         count++;
    
    cout<<count<<endl;
          

}

/*
    ll X,A;
    cin>>X>>A;
    if(X<A){
        cout<<0<<endl;
    }
    else{
        cout<<10<<endl;
    }

*/

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
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; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int n,m;cin>>n>>m;
    vint x(m);vin(x);
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    sort(all(x));
    vint d;
    rep(i,m-1){
        d.push_back(abs(x[i]-x[i+1]));
    }
    sort(all(d));
    int ans=0;
    rep(i,m-n) ans+=d[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


signed main(){
    FAST;
    double a, b, h, m;
    while(cin>>a>>b>>h>>m){
        //a2=b2+c2-2bc*cos(theta)
        double h_=h*2*acos(-1)/12==0 ? 2*acos(-1) : 2*h*acos(-1)/12;
        double extrah_= 2*acos(-1)/(12*60)*m;
        double m_=m*2*acos(-1)/60==0 ? 2*acos(-1) : 2*m*acos(-1)/60 ;
        double theta = abs(h_+extrah_-m_);
        cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*b*a*cos(theta))<<endl;
    }

}


Measured memory_bytes: 4168
/*
 * Author : Sadi
 * Thu 02/07/2020
 * 18:18:56.64
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    string str;
    cin >> str;
    for(int i = 0; i < (int) str.size(); ++i) {
        if(str[i] == '1') {
            str[i] = '9';
        }
        else {
            str[i] = '1';
        }
    }
    cout << str << endl;
    return 0;
}


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

int main(int argc, const char * argv[]) {
    
    
    int tmp,n,four=0,two=0,rest=0;
    
    scanf("%d",&n);
    
    
    for(int i=0;i<n;i++){
        
        scanf("%d",&tmp);
        
        if(tmp%4==0){
            four++;
        }else if(tmp%2==0){
            two++;
        }else{
            rest++;
        }
    }
    
    if(four+1 == rest){
   
        if(two%2==0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else if(four >= rest){
        printf("Yes\n");
        
    }else {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int N=sc.nextInt(),a[]=new int[3*N];
        for(int i=0;i<3*N;i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        long res=0;
        for(int i=1;i<=N;i++){
            res+=a[3*N-2*i];
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 61872
#include <stdio.h>
	
int main()
{
	int i, N, A[21], B[21], C[21], ans = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	for (i = 1; i <= N; i++) {
		scanf("%d", &(B[i]));
		ans += B[i];
	}
	for (i = 1; i < N; i++) scanf("%d", &(C[i]));
	for (i = 1; i < N; i++) if (A[i] == A[i+1] - 1) ans += C[A[i]];
	printf("%d", ans);
	fflush(stdout);
	return 0;
}

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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int first = 0,second = 0;
    for(int i=0;i<s.size();i++){
    	if(s[i]=='A'){
    		first = i;
			break;
		}
	}
	for(int i=s.size()-1;i>=0;i--){
    	if(s[i]=='Z'){
    		second = i;
			break;
		}
	}
	cout << second-first+1 << "\n";
    
	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std ;
class Cube {
  public:
  int f[6] ;
  Cube(){}
  void roll_z(){ roll(1,2,4,3); }
  void roll_y(){ roll(0,2,5,3); }
  void roll_x(){ roll(0,1,5,4); }
  void roll(int i , int j , int k , int l ){
    int t = f[i] ; f[i] = f[j] ;f[j] = f[k] ;f[k]= f[l];f[l]= t;
  }
} ;
bool eq(Cube c1 , Cube c2 ){
  for(int i = 0 ; i < 6 ; i++ )
    if(c1.f[i] != c2.f[i]) return false ;
  return true ;
}
bool equal (Cube c1 , Cube c2 ){
  for(int i = 0 ; i < 6 ; i++ ){
    for(int j = 0 ; j < 4 ; j++ ){
      if(eq(c1 ,c2 )) return true ;
      c1.roll_z() ;
    }
    if ( i % 2 == 0 )c1.roll_y();
    else c1.roll_x();
  }
  return false  ;
}
/*int getRight(Cube c1 , int f1 ,int f2){
  for(int i = 0 ; i < 6 ; i++ ){
    for(int j = 0 ; j < 4 ; j++ ){
      if(c1.f[0] == f1 && c1.f[1]==f2) return c1.f[2] ;
      c1.roll_z() ;
    }
    if ( i % 2 == 0 )c1.roll_y();
    else c1.roll_x();
  }
  return -1 ;
}
*/
Cube C[100] ; int n ;
bool check () {
  for(int i = 0 ; i < n-1 ; i++)
    for(int j = i + 1 ; j < n ; j++) if(equal(C[i] ,C[j] )) return false ;
  return true ;
}
int main () {
  cin >> n ;
  
  for(int i = 0 ; i < n ; i++ )
    for(int j = 0 ; j < 6 ; j++ ) cin >> C[i].f[j] ;
  
  if(check())cout << "Yes" << endl ;
  else cout << "No" << endl ;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

struct factorial
{
    vector<ll> fac, finv, inv;

    factorial(int n) : fac(2, 1), finv(2, 1), inv(2, 1)
    {
        int i;

        rep(i, 2, n + 1)
        {
            fac.push_back(fac[i - 1] * i % MOD);
            inv.push_back(MOD - inv[MOD % i] * (MOD / i) % MOD);
            finv.push_back(finv[i - 1] * inv[i] % MOD);
        }
    }

    ll comb(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    ll perm(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * finv[n - k] % MOD;
    }
};

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % MOD;
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ans;
}

int main(void)
{
    ll n, a, b;
    ll i;
    ll ans = 0;
    ll comba = 1, combb = 1;

    cin >> n >> a >> b;

    factorial f(max(a, b));

    rep(i, 0, a)
    {
        comba *= n - i;
        comba %= MOD;
        comba *= f.inv[i + 1];
        comba %= MOD;
    }

    rep(i, 0, b)
    {
        combb *= n - i;
        combb %= MOD;
        combb *= f.inv[i + 1];
        combb %= MOD;
    }

    ans = power(2, n);

    ans = (ans - comba - combb - 1 + MOD * 3) % MOD;

    cout << ans << endl;
}

Measured memory_bytes: 5716
def main():
    s = int(input())
    # a, b, c = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()

    amount = [s]
    i = 1
    while True:
        if s % 2 == 0:
            s = s // 2
        else:
            s = 3*s + 1
        i += 1
        if s in amount:
            print(i)
            break
        amount.append(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61836
#include <bits/stdc++.h>
#define MOD 1000000007
 
using namespace std;

string S;

int A,B;

int main(){

cin>>S; 

int len=S.size();
char c=S[len-1];

while(len){
    len--;
    if(S[len]!=c){
        c=S[len];
        A++;
    }
}

cout<<A<<endl;

return 0;
 
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int N;
    float P;
    scanf("%d",&N);
    if(N%2==0){
        P=0.5;
        printf("%.10f\n",P);
    }
    else{
        P=((N+1)/2)/(float)N;
        printf("%.10f\n",P);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n,x;
    cin>>n>>x;
    vector<int> l(n);
    rep(i,n)cin>>l[i];
    vector<int> d(n+1);
    d[0]=0;
    for(int i=1;i<n+1;++i){
        d[i]=d[i-1]+l[i-1];
    }
    int cnt=0;
    rep(i,n+1){
        if(d[i]<=x)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3544
import numpy as np
N, M, X = map(int, input().split())
*A,     = map(int, input().split())



sum_right = 0
sum_left  = 0

I         = np.zeros((1, N+1))
I[0][0]   = 0
I[0][N]   = 0
I[0][X]   = 0

for i in A:
    I[0][i] = 1

print(int(min(np.sum(I[0][0:X]), np.sum(I[0][X:N+1]))))


Measured memory_bytes: 13100
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    s = input()
    ans = 0
    w = 0
    for i in range(len(s)):
        if s[i] == "W":
            ans += i-w
            w += 1
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 42992
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int k, a, b;    cin >> k >> a >> b;
    if (b/k - (a-1)/k > 0)
        cout << "OK" << endl;
    else 
        cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
fun solve(N: Long, K: Long, S: String){
    println(S.mapIndexed{ index, value -> if (index == K.toInt() - 1) value.toLowerCase() else value }.joinToString(separator=""))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val K = sc.next().toLong()
    val S = sc.next()
    solve(N, K, S)
}



Measured memory_bytes: 31488
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
import itertools
li=[i for i in range(1,n+1)]
cnt=0
a=-1
for x in itertools.permutations(li):
    x=list(x)
    if x==p or x==q:
        if a>=0:
            print(abs(cnt-a))
            exit()
        else:
            a=cnt    
    cnt+=1                
print(0)   

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

const int N = 1e5 + 50;

int a, b, c;

int main() {
  cin >> a >> b >> c;
  if (c > a + b) printf("%d\n", b + (a + b + 1));
  else printf("%d\n", b + c);
  return 0;
}

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

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

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

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

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

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

    int N;
    cin >> N;

    ll tot = 0;

    vi loc(N + 2);
    for (int i = 1; i <= N; i++) {
        cin >> loc[i];
        tot += abs(loc[i] - loc[i-1]);
    }
    tot += abs(loc[N]);

    for (int i = 1; i <= N; i++) {
        cout << tot - abs(loc[i] - loc[i-1]) - abs(loc[i+1] - loc[i])
            + abs(loc[i+1] - loc[i-1]) << "\n";
    }

    return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> pii;

int n, m;
map<LL, LL, greater<LL> > mp;
int main(){
	cin >> n >> m;
	vector<LL> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	for (int i = 0, b, c; i < m; i++){
		cin >> c >> b;
		mp[b] += 1LL * c;
	}
	LL tot = 0;
	for (int i = 0; i < n ;i++){
		if (mp.size() && mp.begin()->fi > a[i]){
			a[i] = mp.begin()->fi;
			mp.begin()->se--;
			if (mp.begin()->se == 0)
				mp.erase(mp.begin());
		}
		tot += a[i];
	}
	cout << tot << '\n';
	return 0;
}


Measured memory_bytes: 7296
n = int(input())

cnt = 0
x = 0
for i in range(n) :
  a, b = map(int, input().split())
  if a == b :
    cnt += 1
  else :
    cnt = 0
  
  if cnt == 3 :
    x += 1

if x >= 1 :
  print("Yes")
else :
  print("No")

Measured memory_bytes: 9172
########10進法からn進法への変換関数部分##############
def Format(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
############################

n=int(input())
# 6進表現と9進表現を全探索
ans=n
for i in range(n+1):
  j=n-i
  i,j=Format(i,6),Format(j,9)
  t=0
  for s in i:
    t+=int(s)
  for s in j:
    t+=int(s)
  ans=min(ans,t)
print(ans)

Measured memory_bytes: 9152
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll n, m;
	
	cin >> n >> m;

	ll sum_x = 0;
	ll sum_y = 0;

	rep(i, n)
	{
		ll x;
		cin >> x;
		sum_x = (sum_x + i * x -(n -i - 1)*x) % MOD;
	}

	rep(i, m)
	{
		ll y;
		cin >> y;
		sum_y = (sum_y + i * y -(m -i - 1)*y) % MOD;
	}

	cout << (sum_y * sum_x) % MOD << endl;
 


	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N,i,j,tmp;
    int a[200000];
    string O;
    O = "dummy";
    cin >> N ;
    
    
    for (i=0;i<N;i++){
        cin >> a[i];
    }
    
    sort(a,a+N);
    
    for (i=0;i<N-1;i++){
        tmp = a[i] - a[i+1];
        if(tmp == 0) {
            O = "NO";
            cout << O;
            break;
        }
    }

    if(O != "NO") {
        O = "YES";
        cout<<O;
    }
}


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

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

	if(a%k==0)
	{
		cout<<"OK"<<endl;
	}
	else
	{
		int r=a/k;
		if((r+1)*k<=b)
			cout<<"OK"<<endl;
		else
			cout<<"NG"<<endl;
	}

	return 0;
}


Measured memory_bytes: 3644
n = int(input())
a = [int(x) for x in input().split()]

gray = 0
brown = 0
green = 0
light_blue = 0
blue = 0
yellow = 0
orange = 0
red = 0
ex = 0

for i in range(n):
    if a[i] <= 399:
        gray = 1
    elif a[i] <= 799:
        brown = 1
    elif a[i] <= 1199:
        green = 1
    elif a[i] <= 1599:
        light_blue = 1
    elif a[i] <= 1999:
        blue = 1
    elif a[i] <= 2399:
        yellow = 1
    elif a[i] <= 2799:
        orange = 1
    elif a[i] <= 3199:
        red = 1
    else:
        ex += 1

if ex == n:
    min_color = 1
    max_color = ex
else:
    min_color = gray + brown + green + light_blue + blue + yellow + orange + red
    max_color = min_color + ex

print('{}'.format(min_color) +' {}'.format(max_color))

Measured memory_bytes: 3064
using System;

class Program
{
    static void Main()
    {
        string a = Console.ReadLine();
        int count = 0;
        int max = 0;
        for(int i = 0; i < a.Length; i++)
        {
            if ("ATGC".IndexOf(a[i])>-1)
            {
                count++;
            }
            else
            {
                count = 0;
            }
            if (max<count)
            {
                max = count;
            }
        }
        Console.WriteLine(max);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct edge {
  int to, cost;
  edge() {}
  edge(int to, int cost): to(to), cost(cost) {}
};

const ll INF = 1LL << 50;
int n, m, s, t;
int u[100010], v[100010], a[100010], b[100010];
vector<edge> G[2][100010];
ll dis[2][100010];

void dijkstra(int idx, int s) {
  fill_n((ll*)dis[idx], 100010, INF);
  dis[idx][s] = 0;
  using P = pair<ll, int>;
  priority_queue<P, vector<P>, greater<P>> que;
  que.emplace(0, s);
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int cur = p.second;
    if (dis[idx][cur] < p.first) continue;
    for (edge &e : G[idx][cur]) {
      if (dis[idx][e.to] > dis[idx][cur] + e.cost) {
        dis[idx][e.to] = dis[idx][cur] + e.cost;
        que.emplace(dis[idx][e.to], e.to);
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n >> m >> s >> t;
  s--; t--;
  for (int i = 0; i < m; i++) {
    cin >> u[i] >> v[i] >> a[i] >> b[i];
    u[i]--; v[i]--;
    G[0][u[i]].emplace_back(v[i], a[i]);
    G[0][v[i]].emplace_back(u[i], a[i]);
    G[1][u[i]].emplace_back(v[i], b[i]);
    G[1][v[i]].emplace_back(u[i], b[i]);
  }
  dijkstra(0, s);
  dijkstra(1, t);
  vector<ll> ans;
  ll tmp = INF;
  for (int i = n - 1; i >= 0; i--) {
    tmp = min(tmp, dis[0][i] + dis[1][i]);
    ans.emplace_back(tmp);
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < n; i++) {
    cout << (ll)1e15 - ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 18812
n=int(input());a=list(map(int,input().split()));b=[0]
for i in a:b.append(b[-1]+i)
b=b[1:];s=b[-1];mi=abs(b[0]-(b[-1]-b[0]))
for i in range(n-1):mi=min(abs(b[i]-(b[-1]-b[i])),mi)
print(mi)

Measured memory_bytes: 24832
def main():
    args = input().rstrip().split(' ')
    A, B, C, D = int(args[0]),int(args[1]),int(args[2]), \
                 int(args[3])
    chance = A / D
    if(chance.is_integer() == False):
        chance = int(chance) + 1
    
    if(C <= B*chance):
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];

  sort(v.begin(), v.end());
  for (string s : v) cout << s;
  cout << endl;
}


Measured memory_bytes: 768
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n; cin >> n;
    int c[500], s[500], f[500];
    REP(i, n-1) {
        cin >> c[i] >> s[i] >> f[i];
    }
    REP(i, n) {
        int res = 0;
        FOR(j, i, n-2) {
            if (res < s[j]) {
                res = s[j];
            } else if (res % f[j] != 0) {
                res = res + f[j] - res % f[j];
            }
            res += c[j];
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
main = do
    n <- read <$> getLine
    print $ solver n

solver n = head
    [ n `div` x + x - 2
    | x <- enumFromThenTo (sqrtInt n) (pred . sqrtInt $ n) 1
    , n `mod` x == 0
    ]

sqrtInt = floor . sqrt . fromIntegral

Measured memory_bytes: 1020
// =====================================================================================
//
//       Filename:  at.cpp
//
//    Description:  
//
//        Version:  1.0
//        Created:  19/04/20 05:21:38 PM IST
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Kiran Bhanushali (), kiranbhanushali143.kb143@gmail.com
//   Organization:  
//
// =====================================================================================

#include<bits/stdc++.h>


using namespace std;

#define int long long 
#define pb push_back
//#define _SHOW_TIME

void solve(){
    //your code here;
    int n,m ;
    cin>>n>>m;
    int sum = 0 ;
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        sum+= x;
    }

    if(sum<=n) cout<<n-sum<<endl;
    else cout<<"-1"<<endl;
    
}
int32_t main(){
 /////////////////////////////////////
    #ifdef _SHOW_TIME
	int tt = (int) clock();
    #endif
    /////////////////////////////////////
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /////////////////////////////////////
    solve();
    /////////////////////////////////////
    #ifdef _SHOW_TIME
        cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
    #endif
    /////////////////////////////////////
    return 0;

}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
vector<int>a[100005];
int d[100005]={0},n,m,x,y;
void dfs(int no){
    for(int i=0;i<a[no].size();i++){
        if(!d[a[no][i]]) dfs(a[no][i]);
        d[no]=max(d[no],1+d[a[no][i]]);
    }
    return ;
}
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        a[x].push_back(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!d[i]) dfs(i);
    }
    for(int i=1;i<=n;i++) ans=max(ans,d[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,mn=1000000000,mx=1;
    cin >> n;
    long long int a[n];
    for(i=0;i<n;i++)
    {
        cin >> a[i];
        if(a[i] > mx)
            mx = a[i];
        if(a[i] < mn)
            mn = a[i];
    }
    long long int ans = mx-mn;
    cout  << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr int C = 200000;

vecint xpy(400001, -1e8);
vecint xmy(400001, -1e8);

int solve(vector<tuple<int,int,char>>& vt, bool need_sort) {
  for (auto&&e:xpy) e = -1e8;
  for (auto&&e:xmy) e = -1e8;

  if (need_sort) {
    sort(ALL(vt), [] (auto&& lhs, auto&& rhs) {
        auto&&[xl,yl,ul] = lhs;
        auto&&[xr,yr,ur] = rhs;
        return tie(xl, yl) < tie(xr, yr);
    });
  } else {
    reverse(ALL(vt));
  }
  int mn = 1e8;
  int last_u_x = -1;
  int last_u = -1e8;
  for (auto&&[x,y,u] : vt) {
    switch (u) {
      case 'R':
        xpy[x+y] = max(xpy[x+y], x);
        xmy[x-y+C] = max(xmy[x-y+C], x);
        break;
      case 'U':
        mn = min(mn, (x - xpy[x+y]) * 10);
        last_u_x = x;
        last_u = y;
        break;
      case 'D':
        mn = min(mn, (x - xmy[x-y+C]) * 10);
        if (x == last_u_x) {
          mn = min(mn, (y - last_u) * 5);
        }
        break;
    }
  }
  return mn;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  scanf("%d", &n);
  char nl = getchar();
  vector<tuple<int,int,char>> vt;
  vt.reserve(n);
  REP(i,n) {
    unsigned int x=0,y=0;
    while (true) {
      int c = getchar();
      if (c < '0') break;
      x *= 10;
      x += c - '0';
    }
    while (true) {
      int c = getchar();
      if (c < '0') break;
      y *= 10;
      y += c - '0';
    }
    char c = getchar();
    char ign = getchar();
    vt.emplace_back(x,y,c);
  }
  int mn = 1e8;
  REP(i,2) {
    mn = min(mn, solve(vt, true));
    for (auto&&[x,y,u] : vt) {
      x = C - x;
      y = C - y;
      switch (u) {
        case 'L': u = 'R'; break;
        case 'R': u = 'L'; break;
        case 'U': u = 'D'; break;
        case 'D': u = 'U'; break;
      }
    }
    mn = min(mn, solve(vt, false));
    if (i == 1) break;
    for (auto&&[x,y,u] : vt) {
      int tmp = x;
      x = y;
      y = tmp;
      switch (u) {
        case 'L': u = 'D'; break;
        case 'R': u = 'U'; break;
        case 'U': u = 'R'; break;
        case 'D': u = 'L'; break;
      }
    }
  }
  if (mn >= 1e8) {
    cout<<"SAFE\n";
  } else {
    cout<<mn<<"\n";
  }
  return 0;
}


Measured memory_bytes: 8812
#include <stdio.h>
#include <math.h>

int main()
{
    double a, b, C;
    scanf("%lf %lf %lf", &a, &b, &C);

    double C_rad, S;
    C_rad = ((2 * M_PI) / 360) * C;
    S = (a * b * sin(C_rad)) / 2;
    printf("%lf\n", S);

    double c;
    c = sqrt(pow(a, 2) + pow (b, 2) - 2 * a * b * cos(C_rad));
    printf("%lf\n", a + b + c);

    double h;
    h = (S * 2) / a;
    printf("%lf\n", h);

    return 0;
}



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

int main(){
  int x1,x2,y1,y2;
  int xDl,yDl;
  int x3,x4,y3,y4;
  
  cin >> x1 >> y1 >> x2 >> y2;
  
  xDl = x2 - x1;
  yDl = y2 - y1;
  
  x3 = x2 + (-1)*yDl;
  y3 = y2 + xDl;
  x4 = x3 + (-1)*xDl;
  y4 = y3 + (-1)*yDl;

  cout << x3 << " ";
  cout << y3 << " ";
  cout << x4 << " ";
  cout << y4 << " ";
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        char[][] c = new char[h][w];
        int cnt = 0;
        for(int i=0;i<h;i++){
            String s = sc.next();
            for(int j=0;j<w;j++){
                if(s.charAt(j) == '#'){
                    cnt++;
                }
                c[i][j] = s.charAt(j);
            }
        }
        int ans = 0;
        for(int i=0;i< (1<<h);i++){
            for(int j =0; j<(1<<w);j++){
                int tempCnt = 0;
                for(int l=0; l<h;l++){
                    if((i >> l&1)==1){
                        continue;
                    }
                    for(int m =0; m<w;m++){
                        if((j>>m&1)==1){
                            continue;
                        }
                        if(c[l][m] == '#'){
                            tempCnt++;
                        }
                    }
                }
                if(tempCnt == k){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}



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

int main(){
    int n; cin >> n;
    pair<int, int>  p[n];
    for(int i = 0; i < n; i++){
        int a,b; cin >> a >> b;
        p[i] = make_pair(a,b);
    }
    sort(p, p+n);
    cout << (p[n-1].first) + (p[n-1].second) << endl;
    return 0;
}

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

struct pos{
    int x;
    int y;
    int dis;
};

int main(){
    int w, h;
    while(cin >> w >> h, w != 0 && h != 0){
        int field[65][65];
        for(int i = 0; i < 65; i++){
            for(int j = 0; j < 65; j++){
                field[j][i] = 1;
            }
        }

        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                field[i*2-1][j*2-1] = 0;
            }
        }

        int l = 1;
        for(int i = 1; i <= h*2-1; i++){
            if(i % 2 == 1){
                for(int j = 1; j <= w-1; j++){
                    int input;
                    cin >> input;
                    field[l*2-1][j*2] = input;
                }
            }else{
                for(int j = 1; j <= w; j++){
                    int input;
                    cin >> input;
                    field[l*2][j*2-1] = input;
                }
                l++;
            }
        }

        queue<pos> q;
        field[1][1] = 1;
        pos p;
        p.x = 1;
        p.y = 1;
        p.dis = 1;
        q.push(p);
        int x1[] = {-1, 0, 1, 0}, y1[] = {0, -1, 0, 1};
        while(!q.empty()){
            p = q.front();
            q.pop();
            for(int i = 0; i < 4; i++){
                pos p1 = p;
                p1.x += x1[i]; p1.y += y1[i];
                if(!field[p1.x][p1.y]){
                    p1.dis++;
                    field[p1.x][p1.y] = p1.dis;
                    q.push(p1);
                }
            }
        }

        int ans = (field[h*2-1][w*2-1] + 1) /2;

        cout << ans << endl;

    }
}

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

ends = 0
middle = 0

now = S[0]
if now == 'L':
  ends += 1

_S = S[1:]
for i, s in enumerate(_S):
  if now == 'R' and s == 'L':
    middle += 2
  
  now = s

if now == 'R':
  ends += 1

ans = N - max(middle+ends-2*K, 1)
print(ans)

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

int main(){
  int N;
  int w[100];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> w[i];
  }
  int Dm = 2147483647;
  for(int i = 0; i < N - 1; i++){
    int S1 = 0, S2 = 0;
    for(int j = 0; j <= i; j++){
      S1 += w[j];
    }
    for(int j = i + 1; j <= N - 1; j++){
      S2 += w[j];
    }
    int D;
    if(S1 > S2){
      D = S1 - S2;
    }
    else
      D = S2 - S1;
    if(Dm > D)
      Dm = D;
  }
  cout << Dm << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long n;
  long long a,b;
  cin>>n>>a>>b;
  long long cnt=n/(a+b);
  long long ans=cnt*a;
  long long left=min(a,n-cnt*(a+b));
  cout<<ans+left<<endl;
  return(0);
}

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

using namespace std;

int main(){
  double t1, t2;
  cin >> t1 >> t2;
  if(t1 > t2) swap(t1, t2);

  double s1 = (t2 - t1) / 2.;
  double s2 = (360 - t2 + t1) / 2.;

  double ans;
  if(s1 < s2)
	ans = t1 + s1;
  else
	ans = (t1 - s2 + 360);
  if(ans > 360)
	ans -= 360;
  cout << fixed << setprecision(9) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3264
import sys

n = int(input())
A = [int(_) for _ in input().split()]

# dp = [[0 for i in range((n//2)+1)] for j in range(n)]

if n == 1 or n == 2 or n == 3:
    print(max(A))
    sys.exit()

dp = [[0, 0] for j in range(n)]
M = - float('inf')
for i in range(4):
    M = max(M, A[i])
    dp[i][0] = M
dp[2][1] = dp[0][0] + A[2]
dp[3][1] = max(dp[1][0] + A[3], dp[2][1])


# for i in range(len(dp)):
#     print(dp[i])

# for i in range(4, n):
#     for j in range(max(0, i // 2 - 1), (i + 2) // 2):
#         # print(i, j)
#         if i % 2 == 0 and j == (i + 2) // 2 - 1 :
#             dp[i][j] = dp[i-2][j-1] + A[i]
#         else:
            # dp[i][j] = max(dp[i-2][j-1] + A[i], dp[i-1][j])

for i in range(4, n):
    for j in range(2):
        # print(i, j)
        if i % 2 == 0 and j == 1:
            dp[i][j] = dp[i-2][1] + A[i]
        elif i % 2 == 0 and j == 0:
            dp[i][j] = max(dp[i-2][0] + A[i], dp[i-1][1])
        elif i % 2 == 1 and j == 1:
            dp[i][j] = max(dp[i-2][1] + A[i], dp[i-1][1])
        else:
            dp[i][j] = max(dp[i-2][0] + A[i], dp[i-1][0])

# for i in range(len(dp)):
#     print(dp[i])

print(dp[n-1][(n+1)%2])

Measured memory_bytes: 112288
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> vec(N+1);
  vector<int> div(N+1);

  for (int i = 1; i <= N; i++){
    vec.at(i) = i;
    int num = 0;

    while(1){
      if(vec.at(i)%2 != 0){
        div.at(i) = num;
        break;
      }
      vec.at(i) = vec.at(i)/2;
      num++;
    }
  }

  std::vector<int>::iterator maxIt = std::max_element(div.begin(), div.end());
  size_t maxIndex = std::distance(div.begin(), maxIt);
  if(maxIndex == 0) maxIndex = 1;
  cout << maxIndex << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,0,n){
        if(i!=n-1&&s[i]=='x'&&s[i+1]=='x'){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<n<<endl;


    return 0;
}



Measured memory_bytes: 3336
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class Program
{
    static void Main(string[] Args) {
        string S = ReadLine();
        if(S.Length <= 2) {
            WriteLine(Math.Abs(753 - Int32.Parse(S)));
            return;
        }

        List<int> Deffs = new List<int>();
        for(int i = 0;i < S.Length - 2; i++) {
            Deffs.Add(Math.Abs(753 - Int32.Parse(S.Substring(i, 3))));
        }

        WriteLine(Deffs.Min());
    }
}

Measured memory_bytes: 13268
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long a[] = new long[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}

		long[] sum = new long[N + 1];
		Arrays.fill(sum, 0);
		for (int i = 1; i < sum.length; i++) {
			sum[i] = a[i - 1] + sum[i - 1];
		}

		HashMap<Long, Long> map = new HashMap<Long, Long>();
		for (int i = 0; i < sum.length; i++) map.put(sum[i], 0L);
		for (int i = 0; i < sum.length; i++) {
			map.put(sum[i], map.get(sum[i])+1);
		}

		long res = 0;
		for (Map.Entry<Long, Long> entry : map.entrySet()) {
			long num = entry.getValue();
			res += num * (num - 1) / 2;
		}

		System.out.println(res);
	}

}

Measured memory_bytes: 92684
#include <stdio.h>

int main(void){
  int n, t;
  scanf("%d %d", &n, &t);
  int mincost = 1001;
  int i;
  
  for(i = 0; i < n; i++){
    int costi, timei;
    scanf("%d %d", &costi, &timei);
    if(timei <= t && costi < mincost){
      mincost = costi;
    }
  }
  
  if(mincost == 1001){
    printf("TLE\n");
  }else{
    printf("%d\n", mincost);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    if (B <= N) {
        cout << A * (B - 1) / B << endl;
    } else {
        cout << A * N / B << endl;
    }
}


Measured memory_bytes: 3624
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine(); 
            int n = Int32.Parse(input);

            var line = Console.ReadLine().Split(' ');

            var data = new int[n];
            int i = 0;
            foreach(string s in line)
            {
                data[i] = int.Parse(s);
                i++;
            }

            int minMod = data.Min();

            bool loopFlg = true;
            while(loopFlg)
            {
                loopFlg = false;

                for(i = 0; i < n; i++)
                {
                    int mod = data[i] % minMod;
                    if(mod != 0 && minMod > mod)
                    {
                        minMod = mod;
                        loopFlg = true;                 
                    }
                }
            }

            Console.WriteLine(minMod);
        }      
    }
}


Measured memory_bytes: 18912
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() 
{
	ios_base::sync_with_stdio(NULL); cin.tie(NULL);
	int n,m; cin>>n>>m;
	cout<<(n*(n-1))/2+(m*(m-1))/2;
	return 0;
}

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

using namespace std;

typedef long long ll;

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

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

vector<ll> a;
vector<ll> sums;

void calc_sums(const ll N) {
    vector<ll> part_sums(N + 1, 0);
    for (int i = 0; i < N; i++) {
        part_sums[i + 1] = part_sums[i] + a[i];
    }

    int ind = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {
            sums[ind] = part_sums[j + 1] - part_sums[i];
            ind++;
        }
    }
}

ll solve(const int cur_bit, const vector<ll> &g, const ll N, const ll K) {
    if (cur_bit < 0) return 0;

    ll count = 0;
    vector<ll> next_g;

    for (int i = 0; i < (int) g.size(); i++) {
        if (g[i] & (1LL << cur_bit)) {
            count++;
            next_g.push_back(g[i]);
        }
    }
    if (count >= K) {
        return (1LL << cur_bit) | solve(cur_bit - 1, next_g, N, K);
    } else {
        return solve(cur_bit - 1, g, N, K);
    }
}

int main(void) {
    ll N, K;
    cin >> N >> K;

    a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    ll sums_len = N * (N + 1) / 2;
    sums.resize(sums_len);
    calc_sums(N);

    // for (int i = 0; i < sums_len; i++) {
    //     cout << sums[i] << endl;
    // }
    // // sort by descending order
    // sort(sums.begin(), sums.end(), [](const ll &a, const ll &b) {
    //         return a > b;
    //         });

    int start_bit = -1;
    for (int i = 40; i >= 0; i--) {
        ll count = 0;
        for (int j = 0; j < sums_len; j++) {
            if (sums[j] & (1LL << i)) {
                count++;
            }
        }
        if (count >= K) {
            start_bit = i;
            break;
        }
    }

    if (start_bit == -1) {
        cout << "0" << endl;
        return 0;
    }

    vector<ll> g;
    for (int i = 0; i < sums_len; i++) {
        if (sums[i] & (1LL << start_bit)) {
            g.push_back(sums[i]);
        }
    }

    cout << solve(start_bit, g, N, K) << endl;
    return 0;
}


Measured memory_bytes: 11768
#include <bits/stdc++.h> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;
/****************************** START ******************************/

signed main(){
  string S;
  cin >> S;
  if (S.at(S.size()-1) == 's'){
    cout << S + "es";
  } else {
    cout << S << 's';
  }
}


Measured memory_bytes: 3648
using System;

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int b = int.Parse(input[0]);
            int c = int.Parse(input[1]);
            
            var a = b * c;

            var ans = a % 2 == 0 ? "Even" : "Odd";
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 1) {
				cnt++;
			}
		}
		if (cnt % 2 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 38108
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
typedef long long ll;
typedef unsigned un;
typedef std::string str;
typedef std::pair<ll,ll> pll;
typedef std::pair<int,int> pii;
typedef std::pair<double,double> pd;
ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return f*x;}
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
void umax(int& a,int t){if(t>a)a=t;}
bool umin(ll& a,ll t){if(t<a)return a=t,1;return 0;}
#define MAXN 1000011
const double PI=acos(-1.0);
struct comp
{
    double a,b;
    comp(double _a=0,double _b=0){a=_a,b=_b;}
    comp operator +(comp t){return comp(a+t.a,b+t.b);}
    comp operator -(comp t){return comp(a-t.a,b-t.b);}
    comp operator *(comp t){return comp(a*t.a-b*t.b,a*t.b+b*t.a);}
}w[MAXN];
int status[MAXN];
void FFT(comp* a,int len,int type)
{
    for(int i=0;i<len;++i)
        if(status[i]>i)std::swap(a[status[i]],a[i]);
    for(int cur=1;cur<len;cur<<=1)
        for(int j=0;j<len;j+=cur<<1)
            for(int k=0;k<cur;++k)
            {
                comp t=w[len/cur*k];t.b*=type;
                comp x=a[j+k],y=t*a[j+cur+k];
                a[j+k]=x+y,a[j+cur+k]=x-y;
            }
}
ll lg[MAXN],c[MAXN];
comp f[MAXN];
int main()
{
    ll n=read(),p=200003,now=1,x,ans=0;
    for(int i=0;i<p;++i)
    {
        lg[now]=i;
        now=now*11%p;
    }
    for(int i=1;i<=n;++i)
    {
        x=read();
        if(!x)continue;
        ans-=x*x%p, ++f[lg[x]].a;
    }
    int len=1;
    while(len<=p+p)len<<=1;
    for(int i=0;i<len;++i)
        status[i]=(status[i>>1]>>1)+((i&1)*(len>>1)),w[i]=comp(cos(PI/len*i),sin(PI/len*i));
    FFT(f,len,1);
    for(int i=0;i<len;++i)f[i]=f[i]*f[i];
    FFT(f,len,-1);
    now=1;
    for(int i=0;i<len;++i)c[now]+=ll(f[i].a/len+0.5),now=now*11%p;
    for(int i=0;i<p;++i)ans+=i*c[i];
    printf("%lld",ans/2);
    return 0;
}

Measured memory_bytes: 40520
n = int(input())
a = list(map(int, input().split()))
a.sort()
res = True
if n % 2 != 0:
  if a[0] != 0:
    res = False
    print(0)
  a = a[1:]
for i in range(0, len(a), 2):
  if a[i] != a[i+1]:
    print(0)
    res = False
    break

p = 10**9 + 7
if res:
  print(pow(2, n//2, p))

Measured memory_bytes: 20408