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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int a, b;
    cin >> a >> b;
    vector<string> res(100);
    for (int i=0; i<100; i++) {
        for (int j=0; j<100; j++) {
            if (i < 50) res.at(i).push_back('.');
            else res.at(i).push_back('#');
        }
    }
    int x = 0, y = 0;
    for (int i=0; i<b-1; i++) {
        res.at(x).at(y) = '#';
        y += 2;
        if (y >= 100) {
            x += 2;
            y = 0;
        }
    }
    x = 51, y = 0;
    for (int i=0; i<a-1; i++) {
        res.at(x).at(y) = '.';
        y += 2;
        if (y >= 100) {
            x += 2;
            y = 0;
        }
    }
    cout << 100 << ' ' << 100 << '\n';
    for (string s : res) cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 256
H,W,A,B=map(int,input().split())
flag=0
T=[]
C=[]
if True:
    for i in range(A):
        T.append("1")
        C.append("0")
    for i in range(W-A):
        T.append("0")
        C.append("1")
    for i in range(B):
        print("".join(T))
    for i in range(H-B):
        print("".join(C))

else:
    print("No")

Measured memory_bytes: 3956
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();

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

		for ( int i=1; i<1001; i++ ) {
			if ( k*i >= a && k*i <= b ) {
				System.out.println("OK");
				System.exit(0);
			}
		}
		System.out.println("NG");
	}
}

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

int main() {
  int a,b;cin>>a>>b;
  
  for (int i=0;i<2*a-1;i++) {
    if (i!=2*a-2) cout<<b-a+1+i<<" ";
    else cout<<b-a+1+i<<endl;
  }
    
}


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/

#define ff first
#define ss second
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)3e5+5;


typedef long long ll;
const ll inf = 5e18+100;
typedef unsigned long long ull;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


void solve(){
    int n;
    cin >> n;
    map < string , int > cnt;
    cnt["WA"]=0;
    cnt["TLE"]=0;
    cnt["WA"]=0;
    cnt["RE"]=0;

    f0(i,n){
        string s;
        cin >> s;
        cnt[s]++;
    }

    cout << "AC x "<< cnt["AC"] << endl;
    cout << "WA x "<< cnt["WA"] << endl;
    cout << "TLE x "<< cnt["TLE"] << endl;
    cout << "RE x "<< cnt["RE"] << endl;
    return;
}

int main()
{
    CIN

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    //cout << "Fi Amanillah" << endl;

    int t = 1;
    //cin >> t;

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


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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();


        out.println(min(a,b)+" "+max(0,(a+b-n)));
        out.flush();
    }
    
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
const int AMAX=10005;
const int MAX=2000005;
int C[AMAX]={0},A[MAX],B[MAX];
void CountingSort(int A[],int B[],int n){
	for(int i=0;i<n;i++)C[A[i]]++;
	for(int i=1;i<AMAX;i++){
		C[i]+=C[i-1];
	}
	for(int i=n-1;i>=0;i--){
		B[C[A[i]]-1]=A[i];
		C[A[i]]--;
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	CountingSort(A,B,n);
	for(int i=0;i<n;i++){
		if(i)cout<<" ";
		cout<<B[i];
	}
	cout<<endl;
}


Measured memory_bytes: 18740
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int ROW, COLUMN;
vector<vector<char>> grid;
vector<vector<bool>> status;
vector<pos> directions = {
    {.row = 1, .column = 0},
    {.row = 0, .column = 1},
    {.row = -1, .column = 0},
    {.row = 0, .column = -1},
};

bool isValid(void) {
  rep(row, ROW) {
    rep(column, COLUMN) {
      if (grid[row][column] != '#') return false;
    }
  }
  return true;
}

void show(void) {
  rep(row, ROW) {
    rep(column, COLUMN) { cout << grid[row][column]; }
    cout << endl;
  }
}

int main(void) {
  cin >> ROW >> COLUMN;
  grid.resize(ROW);
  status.resize(ROW);
  rep(row, ROW) {
    grid[row].resize(COLUMN);
    status[row].resize(COLUMN);
    string tmp;
    cin >> tmp;
    rep(column, COLUMN) { grid[row][column] = tmp[column]; }
  }

  queue<pos> keep;
  queue<pos> nextKeep;
  int count = 0;
  rep(row, ROW) {
    rep(column, COLUMN) {
      if (grid[row][column] == '#') {
        nextKeep.push({.row = row, .column = column});
        status[row][column] = true;
      }
    }
  }

  while (nextKeep.size() > 0) {
    count++;
    while (nextKeep.size() > 0) {
      keep.push(nextKeep.front());
      nextKeep.pop();
    }
    while (keep.size() > 0) {
      pos current = keep.front();
      keep.pop();
      for (pos dire : directions) {
        int newRow = current.row + dire.row;
        int newColumn = current.column + dire.column;

        if (newRow < 0 || newRow >= ROW || newColumn < 0 || newColumn >= COLUMN)
          continue;
        if (status[newRow][newColumn]) continue;
        grid[newRow][newColumn] = '#';
        status[newRow][newColumn] = true;
        nextKeep.push({.row = newRow, .column = newColumn});
      }
    }
  }

  cout << count - 1 << endl;
  return 0;
}

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

int main(void) {
    int A,B,C,X,Y;
    int N,n;
    int ans;
    cin >> A >> B >> C >> X >> Y;
    N = max(X,Y);
    n = min(X,Y);
    if((A+B) > (C*2)) {
        ans = n * C * 2;
        if(X > Y) {
            if(A > (2*C)) { 
                ans += (X-Y) * 2 * C;
            } else {
                ans += (X-Y) * A;
            }
        } else {
            if(B > (2*C)) { 
                ans += (Y-X) * 2 * C;
            } else {
                ans += (Y-X) * B;
            }
        }
    } else {
        ans = X*A + Y * B;
    }
    cout << ans << endl;    
    return 0;
}


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

int main()
{
	int n, k;
	cin >> n>>k;
	vector<int> d(k);
	for (int i = 0; i < k; i++)
	{
		cin >> d.at(i);
	}
	int ans = 0;
	for (int i = n; n < 10 * n; i++)
	{
		int nn = i;
		vector<int> w(10);
		int s = 0;
		
		while (nn != 0)
		{
			
			w.at(s) = nn % 10;
				s++;
				nn /= 10;
		}
		int f = 0;
		for (int j = 0; j < s; j++)
		{
			for (int p = 0; p < k; p++)
			{
				if (w.at(j)==d.at(p))
				{
					f = 1;
					break;
				}
			}
			if (f==1)
			{
				break;
			}
		}
		
		if(f==0)
		{
			cout << i << endl;
			break;
		}

	}
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

constexpr ll INF = std::numeric_limits<ll>::max()>>2;

ll n, s;

int main()
{
  scanf( "%lld%lld", &n, &s );

  for( ll b = 2; b*b <= n; ++b )
  {
    ll l = n, sum = 0;
    while( l > 0 )
    {
      sum += l % b;
      l /= b;
    }

    if( sum == s )
    {
      printf( "%lld\n", b );

      return 0;
    }
  }

  if( n == s )
  {
    printf( "%lld\n", n+1 );

    return 0;
  }

  ll ans = INF;
  for( ll i = 1; i*i <= n-s; ++i ) if( (n-s) % i == 0 )
  {
    ll b = i+1;
    ll p = (n-s)/i;

    if( p < b && n-p*b < b && n-p*b >= 0 )
      ans = std::min( ans, b );

    b = (n-s)/i+1;
    p = i;

    if( p < b && n-p*b < b && n-p*b >= 0 )
      ans = std::min( ans, b );
  }

  if( ans != INF )
    printf( "%lld\n", ans );
  else
    puts("-1");
  
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>

int dp[40];

int main(void)
{
    memset(dp, 0, sizeof(dp));

    dp[0] = 1;
    for(int i=0; i < 35; i++)
    {
        dp[i+1] += dp[i];
        dp[i+2] += dp[i];
        dp[i+3] += dp[i];
    }

    while(true) {
        int n;
        scanf("%d", &n);
        if(!n) break;

        printf("%d\n", (int)ceil((double)dp[n]/365/10));

    }

    return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int p[30];
int n;
int main(){
	cin >> n;
	for(int i=0;i<n;i++)cin >> p[i];
	int ans = 0;
	for(int i=1;i<n-1;i++){
		if((p[i]>=p[i-1]&&p[i+1]>=p[i])||(p[i]<=p[i-1]&&p[i+1]<=p[i]))ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
a=int(input())
s=input()

ans=0
for i in range(1,a):
#print(s[:i],s[i:])
  seta=set(s[:i])
  setb=set(s[i:])
  setc=seta & setb
  if ans < len(setc):
    ans=len(setc)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int n, x;
    int cnt = 0;

    while(1)
    {
        cnt = 0;
        cin >> n >> x;
    
    if((n == 0) && (x == 0))
    {
        break;
    }
    for (int i= 1;i <= n;i++)
    {
        for (int j= i+1;j <= n;j++)
        {
            for (int k= j+1; k<= n;k++)
            {
                if((i+j+k) == x)
                {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
using namespace std;
bool a[10];
int main()
{
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < k; i++)
    {
        int num;
        cin >> num;
        a[num] = 1;
    }
    while(1)
    {
        int num = n;
        int flag = 1;
        while(num)
        {
            if(a[num%10])
            {
                flag = 0;
                break;
            }
            num /= 10;
        }
        if(flag)
        {
            break;
        }
        else n++;
    }
    cout << n << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

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

int main(){
	
	string T, P;
	cin >> T >> P;
	
	if(T.size() < P.size()){
		return 0;
	}
	
	for(int i = 0; i < T.size() - P.size() + 1; i++){
		if(T.substr(i, P.size()) == P){
			cout << i << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int t1=h1*60+m1,t2=h2*60+m2;
	int td=t2-t1;
	cout<<td-k<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <climits>
using namespace std;

int main(void){
    
    int N, K, A;
    cin >> N >> K;
    vector<int> ball(N+1,0);
    for(int i = 0; i < N; i++){
        cin >> A;
        ball[A]++;
    }
    
    int ball_Type = 0;
    
    for(int i = 0; i <= N; i++){
        if(ball[i] == 0){
            ball[i] = INT_MAX;
        }
        else ball_Type++;
    }
    
    sort(ball.begin(), ball.end());
    
    int ans = 0;
    
    for(int i = 0; i < (ball_Type - K) ; i++){
        //cout << ball[i] << endl;
        ans += ball[i];
    }
   
    cout << ans << std::endl;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100005];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	if(n==1)
	{
		puts("0");
		return 0;
	}
	int ps=0;
	for(int i=1;i<=n;i++)if(a[i]==1)ps=i;
	int x=k,p=1;
	while(x<n)x+=k-1,p++;
	printf("%d\n",p);
	return 0;
}

Measured memory_bytes: 640
a = input()[::-1]
add = 0
ans = [1] + [0] * 2018
ans_int = 0
d = 1

for i in range(len(a)):
    add = (add + int(a[i]) * d) % 2019
    d = (10 * d) %2019
    ans[add] += 1

for i in range(len(ans)):
    a =((ans[i] - 1) * ans[i]) /2
    ans_int += a

print(int(ans_int))


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

using namespace std;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    constexpr int A_MAX = 1000000;

    vector<int> min_factor(A_MAX);
    // q[n] = i where n = i * p^e, p = min_factor[n], p does not divide i. + 1);
    vector<int> q(A_MAX + 1, 1);
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        min_factor[i] = i;
    }
    for (int i = 2; i <= A_MAX; ++i) {
        if (min_factor[i] == i) {
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }

    int N;
    cin >> N;
    vector<int> a(A_MAX + 1);
    int A;
    for (int i = 0; i < N; ++i) {
        cin >> A;
        ++a[A];
    }

    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        if (a[n] > 1) {
            if (a[n] == N) {
                cout << "not coprime" << endl;
                return 0;
            }
            is_pairwise_coprime = false;
        }
        a[min_factor[n]] += a[n];
        a[q[n]] += a[n];
    }
    if (is_pairwise_coprime) {
        cout << "pairwise coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }

    return 0;
}

Measured memory_bytes: 15536
import random

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return (score - sum)

def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    #print(c)

    #print(s)

    last_d = [0 for i in range(26)]
    
    ans = []
    
    score = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2:
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 == c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2:
                if i-last_d[j] > i-last_d[idx]:
                    idx = j
        last_d[idx] = i+1
        score += s[i][j]
        down_score(i+1,c,last_d,score)
        
        ans.append(idx)

    for i in range(D):
        print(ans[i]+1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9680
import math
from fractions import gcd


a, b = map(int, input().split())
g = gcd(a, b)


s = int(math.sqrt(g))

f = {}
for i in range(2, s+1):
    while g % i == 0:
        f[i] = f.get(i, 0) + 1
        g = g/i
if g != 1:
    f[g] = f.get(g, 0) + 1

print(len(f)+1)

Measured memory_bytes: 5172
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

struct ufind {
    int parent;
    int depth;
};

#define VERTEX_MAX 100000
struct ufind *create_ufind(int vs) {
    static struct ufind ufind[VERTEX_MAX*2];
    int i;
    for(i = 0; i < vs; i++) {
        ufind[i].parent = i;
        ufind[i].depth = 0;
    }
    return ufind;
}

int find_root(struct ufind *ufind, int v) {
    struct ufind *elem = &ufind[v];
    int base = v;
    if(base == elem->parent) {
        return base;
    } else {
        int root = find_root(ufind, elem->parent);
        elem->parent = root;
        return root;
    }
}

int is_connect(struct ufind *ufind, int v1, int v2) {
    int bv1 = find_root(ufind, v1);
    int bv2 = find_root(ufind, v2);
    return bv1 == bv2;
}

void unite(struct ufind *ufind, int v1, int v2) {
    int bv1 = find_root(ufind, v1);
    int bv2 = find_root(ufind, v2);
    struct ufind *uv1 = &ufind[bv1];
    struct ufind *uv2 = &ufind[bv2];
    if(uv1->depth >= uv2->depth) {
        if(uv1->depth == uv2->depth) uv1->depth++;
        uv2->depth = uv1->depth;
        uv2->parent = uv1->parent;
    } else {
        uv1->depth = uv2->depth;
        uv1->parent = uv2->parent;
    }
    return;
}

int main(void) {
    int num, cs;
    get_int2(&num, &cs);
    struct ufind *ufind = create_ufind(num*2);

    int i;
    for(i = 0; i < cs; i++) {
        int v1, v2, coff;
        get_int3(&v1, &v2, &coff);
        // 1-indexed -> 0-indexed
        v1--; v2--;
        // even
        if(coff%2 == 0) {
            unite(ufind, v1*2, v2*2);
            unite(ufind, v1*2+1, v2*2+1);
        } else {
            unite(ufind, v1*2, v2*2+1);
            unite(ufind, v1*2+1, v2*2);
        }
    }

    int ans = 0;
    static int root_map[VERTEX_MAX*2];
    for(i = 0; i < num*2; i++) {
        int root = find_root(ufind, i);
        if(!root_map[root]) ans++;
        root_map[root]++;
    }
    printf("%d\n", ans/2);
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        int d = s[i] - '0';
        sum += d;
        sum %= 9;
    }
    if(sum == 0) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=100005;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,q;
      cin>>n>>q;
      vector<pair<int,pair<int,int>>> a; 
      for(int i=0;i<n;i++)
      {
            int s,t;
            cin>>s>>t;
            // s-=0.5;
            // t-=0.5;
            int x;
            cin>>x;
            s-=x;
            t-=x;
           // cout<<s<<" "<<t<<"\n";
            a.pb({s,{x,1e13}});
            a.pb({t,{x,-1e13}});   
      }
      for(int i=1;i<=q;i++)
      {
            int d;
            cin>>d;
            a.pb({d,{1e12,i}});
      }
      sort(all(a));
      int ans[q+1];
      multiset<int> s;
      for(int i=0;i<a.size();i++)
      {
     //       cout<<a[i].fi<<"\n";
            if(a[i].se.se==1e13)
            {
                  s.insert(a[i].se.fi);
            }
            else if(a[i].se.se==-1e13)
            {
                  // if(s.find(a[i].se.fi)==s.end())
                  // {
                  //       cout<<"*";
                  //       return 0;
                  // }
                  s.erase(s.find(a[i].se.fi));
            }
            else{
                  if(s.size()!=0)
                  ans[a[i].se.se]=*(s.begin());
                  else ans[a[i].se.se]=-1;
            }
      }
     for(int i=1;i<=q;i++) cout<<ans[i]<<"\n";
}     




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

int main() {
	string s, t;
	cin >> s >> t;
	//存在判定
	set<char> a_, b_;
	rep(i, s.size()) a_.insert(s[i]);
	bool ppp = true;
	rep(i, t.size()) {
		if (a_.find(t[i]) == a_.end()) ppp = false;
	}
	if (!ppp) {
		cout << -1 << endl;
		return 0;
	}
	//
	s += s;
	vector<set<int>> is(26);
	int n = s.size();
	int k = t.size();
	rep(i, n) {
		is[s[i] - 'a'].insert(i);
	}
	ll ans = 0;
	int now = 0;
	rep(i, k) {
		int tmp = t[i] - 'a';
		if (is[tmp].lower_bound(now) == is[tmp].end()) {
			ans += (n - now + *is[tmp].begin()) + 1;
			now = *is[tmp].begin() + 1;
		}
		else {
			ans += (*is[tmp].lower_bound(now) - now) + 1;
			now = *is[tmp].lower_bound(now) + 1;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef long long ll;
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;

template<typename T> vector<vector<T> > doubling(vector<T> vec, int depth) {
  int s = (int) vec.size();
  int vs = 1;
  while (1 << vs <= depth) vs++;
  vector<vector<T> > tbl(vs, vector<T>(s));
  for (int j = 0; j < s; j++) tbl[0][j] = vec[j];
  for (int i = 1; i < vs; i++) {
    for (int j = 0; j < s; j++) {
      tbl[i][j] = tbl[i - 1][tbl[i - 1][j]];
    }
  }
  return tbl;
}

void Main() {
  int N;
  scanf("%d", &N);
  vi X(N);
  rep(i, N) scanf("%d", &X[i]);
  int LIM, Q;
  scanf("%d%d", &LIM, &Q);

  vi L(N), R(N);
  rep(i, N) {
    int x = X[i];
    int r = distance(X.begin(), upper_bound(ALL(X), x + LIM)) - 1;
    int l = distance(X.begin(), lower_bound(ALL(X), x - LIM));
    //_p("%d: %d,%d,%d\n", i,x,l,r);
    L[i] = l;
    R[i] = r;
  }

  auto lt = doubling(L, 100001);
  auto rt = doubling(R, 100001);
  int H = SZ(lt);

  //rep(ii,SZ(rt)) { cout << "rt["<<ii<<"]:"; rep(jj, SZ(rt[ii])) cout << ' ' << rt[ii][jj]; cout << endl; }
  //rep(ii,SZ(lt)) { cout << "lt["<<ii<<"]:"; rep(jj, SZ(lt[ii])) cout << ' ' << lt[ii][jj]; cout << endl; }

  rep(q, Q) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--; b--;

    if (a < b) {
      int ok = 100000;
      int ng = -1;

      while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        bool c;
        {
          int v = a;
          rep(k, H) {
            if (mid & BIT(k)) {
              v = rt[k][v];
            }
          }
          c = v >= b;
        }
        // cout << "ok: " << ok << ", ng: " << ng << ", ";
        // cout << "check(" << mid << ") -> " << c << endl;
        if (c) ok = mid;
        else ng = mid;
      }
      _p("%d\n", ok);
    }
    else {
      int ok = 100000;
      int ng = -1;

      while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        bool c;
        {
          int v = a;
          rep(k, H) {
            if (mid & BIT(k)) {
              v = lt[k][v];
            }
          }
          c = v <= b;
        }
        // cout << "ok: " << ok << ", ng: " << ng << ", ";
        // cout << "check(" << mid << ") -> " << c << endl;
        if (c) ok = mid;
        else ng = mid;
      }
      _p("%d\n", ok);
    }
  }
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 16112
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    string s;
    ll ans = 0;
    cin >> s;
    for(auto x: s)
        ans += (x == 'x' ? 1 : 0);
    cout << (ans < 8 ? "YES" : "NO") << endl;
    return 0;
}

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

using namespace std;
#define LL long long
#define mst(a, b)	memset(a, b, sizeof a)
#define pill pair<int, int>
#define mk make_pair
const int qq = 5e5 + 10;
int n;
char st[qq];
int dp[qq];

int main() {
	scanf("%d%s", &n, st + 1);
	int f = -1;
	for(int i = 3; i <= n; ++i) {
		dp[i] = dp[i - 1];
		if(st[i] == '1'&& st[i - 1] == '0' && st[i - 2] == '1') {
			f = i;
			for(int j = i - 2; st[j] == '1' && j >= 1; --j) {
				dp[i] = max(dp[i], dp[j - 1] + i - j - 1);
			}
		}
		if(st[i] == '0')	f = -1;
		if(st[i] == '1' && f != -1) {
			dp[i] = max(dp[i], dp[f - 3] + i - f + 1);
		}
	}
	printf("%d\n", dp[n]);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  double ans=0;
  vector<double>x(n);
  vector<double>y(n);
  rep(i,n) cin >> x[i] >> y[i];
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      double d=pow(x[i]-x[j],2)+pow(y[i]-y[j],2);
      d=sqrt(d);
      ans+=d;
    }
  }
  cout << fixed << setprecision(10) << 2*ans/n << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

#define N 10

int main(){
	int i,j,k;
	int mountain[N];
	int tmp;
	int top[3];

	for(i=0;i<N;i++){
		scanf("%d",&mountain[i]);
	}

	for(i=0;i<3;i++){
		top[i]=0;
		for(j=0;j<N;j++){
			if(top[i] < mountain[j]){
				top[i] = mountain[j];
				tmp = j;
			}
		}
		mountain[tmp]=-1;
	}

	for(i=0;i<3;i++){
		printf("%d\n",top[i]);
	}
	

	return 0;
}

Measured memory_bytes: 600
/*input
20 3
0 5 15
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int t1=0, mx=0, i, n, k;
	cin >> k >> n;
	vector<int> a(n);
	for(i=0; i<n; i++)
		cin >> a[i];
	for(i=1; i<n; i++) {
		t1 += a[i] - a[i-1];
		mx = max(a[i] - a[i-1], mx);
	}
	if(mx > k - a[n-1] + a[0]) {
		t1 = t1 - mx + k - a[n-1] + a[0];
	}
	cout << t1 << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);		
	int t = 1;
	// cin >> t;
	while(t--) {
		run();
	}
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
import heapq
INF = float("inf")


def argmax(a):
    m, n = -(1 << 31), -1
    for i, v in enumerate(a):
        if m < v:
            m, n = v, i
    return m, n

# 無向グラフを仮定する。


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.V = list(range(N))
        self.E = [[] for _ in range(N)]

    def add_edge(self, edge):
        """辺を加える。edgeは(始点, 終点、重み)からなるリスト
        重みがなければ、重み1とする。
        """
        if len(edge) == 2:
            edge.append(1)
        elif len(edge) != 3:
            print("error in add_edge")
            pass

        s, t, w = edge
        self.E[s].append([t, w])
        self.E[t].append([s, w])  # 無向グラフを仮定。逆向きにも辺を張る

        pass


def shortestPath(g: Graph, s: int):
    """ グラフgにおいて、始点sから各頂点への最短路を求める
    引数
    g: グラフ, s: 始点
    返り値
    dist: 始点からの距離が格納されたリスト
    prev: 始点から最短経路で移動する場合、各頂点に至る前の頂点のリスト
    """
    dist = [INF]*g.N
    dist[s] = 0

    prev = [None]*g.N
    Q = []
    heapq.heappush(Q, (dist[s], s))

    while len(Q) > 0:
        _, u = heapq.heappop(Q)
        for v, w in g.E[u]:
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
                prev[v] = u
                heapq.heappush(Q, (dist[v], v))
    return dist, prev


def tree_diameter(g):
    # 木の直径を求める。
    # ダイクストラ法を二回行う実装。
    dist, prev = shortestPath(g, 0)
    m, s = argmax(dist)
    dist, prev = shortestPath(g, s)
    return max(dist)


def solve(N: int, a: "List[int]", b: "List[int]"):
    g = Graph(N)
    for aa, bb in zip(a, b):
        g.add_edge([aa-1, bb-1])

    L = tree_diameter(g)
    if L % 3 == 1:
        print("Second")
    else:
        print("First")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]"
    b = [int()] * (N-1)  # type: "List[int]"
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)


if __name__ == '__main__':
    main()


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

int ch(char c){
	switch (c){
	  case 'I':
		return 1;
	  case 'V':
		return 5;
	  case 'X':
		return 10;
	  case 'L':
		return 50;
	  case 'C':
		return 100;
	  case 'D':
		return 500;
	  case 'M':
		return 1000;
	}
	
}

int main()
{
	string s;
	int a,ans;
	while(cin >> s){
		a=0;
		ans=0;
		for(int i=s.size()-1;i>=0;--i){
			if(a>ch(s[i])){
				ans-=ch(s[i]);
			}else {
				ans += ch(s[i]);
			}
			a=ch(s[i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1180
package main
import "fmt"
func main(){
    // Your code here!
    
    var a,b,c,k int
    fmt.Scan(&a, &b, &c, &k)
    if a >= k{
        fmt.Println(1*k)
    }else {
        k -= a
        if b >= k{
            fmt.Println(1*a)
        }else{
            k -= b
            if k <= c{
                fmt.Println(1*a + -1*k)
            }
        }
    }
}

Measured memory_bytes: 1752
#include<cstdio>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn=1000005,tt=998244353;
int qsm(LL w,int b){LL num=1;while(b){if (b&1) num=num*w%tt;w=w*w%tt;b>>=1;}return num;}
int NI[maxn],n,a[maxn],m,w[maxn],sum[maxn];
LL ans;
inline int _read(){
	int num=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') num=num*10+ch-48,ch=getchar();
	return num;
}
int main(){
	n=_read();for (int i=1;i<=n;i++) a[i]=_read(),m=max(m,a[i]),sum[a[i]]++;
	for (int i=1;i<=m;i++) NI[i]=qsm(i,tt-2);
	for (int i=1;i<=m;i++){
		w[i]=(w[i]+NI[i])%tt;
		for (int j=i*2;j<=m;j+=i) w[j]=(w[j]-w[i]+tt)%tt;
	}
	for (int i=1;i<=m;i++){
		LL num1=0,num2=0;
		for (int j=i;j<=m;j+=i) num1+=(LL)sum[j]*j%tt,num2+=(LL)sum[j]*j%tt*j%tt;
		num1%=tt;num2%=tt;
		ans+=w[i]*((num1*num1-num2+tt)%tt)%tt;
	}
	printf("%lld\n",ans%tt*NI[2]%tt);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N ; i++) {
    cin >> d.at(i);
  }
  map<int, int> diameter;
  for (int i = 0; i < N; i++) {
    diameter[d.at(i)] += 1;
  }
  int ret = diameter.size();
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod = 1e9 + 7;
inline int mul( int x , int y ){ return 1LL * x * y % mod ;}
int power_mod( int x , int y ){int ret = 1;while( y ){if( y & 1 ) ret = mul( ret , x );y >>= 1;x = mul( x , x );}return ret;}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
using namespace std;
const int maxn = 2e5 + 500;

int N , K , L , fa1[maxn] , fa2[maxn] , vis[maxn] , ans[maxn] , value[maxn];
vector < int > v1[maxn] ;

int find_fa( int * fa , int x ){
	return fa[x] == x ? x : fa[x] = find_fa( fa , fa[x] );
}

void Unionset( int * fa , int x , int y ){
	int p1 = find_fa( fa , x ) , p2 = find_fa( fa , y );
	if( p1 != p2 )
		fa[p1] = p2;
}


int main(int argc,char *argv[]){
	N = read() , K = read() , L = read();
	for(int i = 1 ; i <= N ; ++ i)
		fa1[i] = i , fa2[i] = i;
	for(int i = 1 ; i <= K ; ++ i){
		int u = read() , v = read();
		Unionset( fa1 , u , v );
	}
	for(int i = 1 ; i <= L ; ++ i){
		int u = read() , v = read();
		Unionset( fa2 , u , v );
	}
	for(int i = 1 ; i <= N ; ++ i)
		v1[find_fa( fa1 , i )].push_back( i );
	for(int i = 1 ; i <= N ; ++ i){
		int x = find_fa( fa1 , i );
		if( vis[x] )
			continue;
		vis[x] = 1;
		for(auto it : v1[x])
			value[find_fa(fa2,it)]++;
		for(auto it : v1[x])
			ans[it] = value[find_fa(fa2,it)];
		for(auto it : v1[x])
			value[find_fa(fa2,it)]--;
	}
	for(int i = 1 ; i <= N ; ++ i){
		if( i > 1 ) putchar( 32 );
		printf( "%d" , ans[i]);
	}
	puts("");
	return 0;
}

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

using namespace std;

int main() {
    int n = 0;
    int m = 0;
    cin >> n;
    int counter = 0;

    int v[n] = {0};

    for(int i = 0 ; i < n ; i ++){
        m = 0;
        cin >> m;
        v[m - 1] ++;
    }
    
    for(int i = 0 ; i < n ; i ++){
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
int flip[MAXN], dp[MAXN][MAXN][2];
char board[MAXN][MAXN];
int f(vector <int> &x)
{
	stack < pair<int,int> > S;
	S.push(make_pair(-1,-1));
	int n = x.size();
	vector <int> lp(n), rp(n);
	for (int i = 0; i < n; ++i)
	{
		while(true)
		{
			pair <int,int> top = S.top();
			if(top.first >= x[i])
			{
				rp[top.second] = i;
				S.pop();
				lp[top.second] = (S.top()).second;
			}
			else
			{
				S.push(make_pair(x[i],i));
				break;
			}
		}
	}
	while(true)
	{
		pair <int,int> top = S.top();
		if(top.first >= 0)
		{
			rp[top.second] = n;
			S.pop();
			lp[top.second] = (S.top()).second;
		}
		else
		{
			break;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans = max(ans, x[i]*(rp[i] - lp[i]));
	}
	return ans;
}
int main(int argc, char const *argv[])
{
	int n,m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i)
	{
		scanf("%s", board[i]);
	}
	for (int i = 0; i + 1 < n; ++i)
	{
		for (int j = m - 1; j >= 0; --j)
		{
			if(board[i][j] == board[i+1][j])
			{
				dp[i][j][0] = dp[i][j+1][0] + 1;
				dp[i][j][1] = 0;
			}
			else
			{
				dp[i][j][0] = 0;
				dp[i][j][1] = dp[i][j+1][1] + 1;
			}

		}
	}
	int ans = max(n,m);
	for (int lf = 0; lf < m; ++lf)
	{
		for (int i = 0; i < n; ++i)
		{
			flip[i] = ((board[i][lf] == '#')? 1: 0);
		}
		vector <int> temp;
		for (int i = 0; i + 1 < n; ++i)
		{
			if(flip[i] == flip[i+1])
				temp.push_back(dp[i][lf][0]);
			else
				temp.push_back(dp[i][lf][1]);
		}
		ans = max(ans, f(temp));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 35584
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n);
  int sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  int minimum = INF;
  int ans;
  REP(i, n) {
    if (abs(sum-a[i]*n) < minimum) {
      minimum = abs(sum-a[i]*n);
      ans = i;
    }
  }
  cout << ans << "\n";
  return 0;
}


// For AtCoder Problems


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int x, b, c, ab, ac, bc;
    scanf("%d %d %d", &x, &b, &c);

    ab = x+b;
    ac = x+c;
    bc = b+c;

    if(ab<ac && ab<bc)
    {
        printf("%d", ab);
    }
    else if(ac<ab && ac<bc)
    {
        printf("%d", ac);
    }
    else
    {
        printf("%d", bc);
    }

    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define optimizator ios_base::sync_with_stdio(0);
#define ll long long
using namespace std;
int main(){
	optimizator;
	int n,cnt=0;
	cin>>n;
	string a;
	cin>>a;
	if(n%2==1){
		cout<<"No";
		return 0;
	}
	for(int i=0; i<n/2; i++){
		if(a[i]==a[i+n/2]){
			cnt++;
		}
	}
	if(cnt==n/2){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

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

 int main() {
 int A, B, C, K, cnt = 0;
 cin >> A >> B >> C >> K;
 while (A >= B) { cnt += 1; B *= 2; }
 while (B >= C) { cnt += 1; C *= 2; }
 if (cnt <= K) cout << "Yes" << endl;
 else cout << "No" << endl;
 return 0;
 }


Measured memory_bytes: 3644
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int a,b,c;
	std::cin >> a >> b >> c;
	print(std::max(c-a+b,0ll));
	return 0;
}


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

int main(void){
  int N;
  cin >> N;
  
  int a[3];
  a[0] = N%10; N /=10;
  a[1] = N%10; N /=10;
  a[2] = N%10; N /=10;
  
  if (a[0] == 7 || a[1] == 7 || a[2] == 7){
    cout << "Yes" << endl;
  } else {
    cout << "No"  << endl;
  }
  return 0;
}

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

int main() {
	int A, B; cin >> A >> B;
	
	if (A <= 8 && B <= 8)cout << "Yay!" << endl;
	else cout << ":(" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    string S;
    cin >> S;
    if(!(S[0] == S[1] & S[1] == S[2]) & ((S[0] == S[1] & S[2] == S[3]) | (S[0] == S[2] & S[1] == S[3]) | (S[0] == S[3] & S[2] == S[1]))){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
#time=list(map(int,input().split()))
time=np.array(input().split(),dtype=np.int64)
M = int(input())

p={}
x={}
for i in range(M):
    p[i],x[i] = map(int, input().split())
#print(x[1])

sumT=np.sum(time)
for i in range(M):
    PP = p[i]
#    print(np.sum(time_new))
    tot = sumT - time[PP-1] + x[i]
    print(tot)


Measured memory_bytes: 12448
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  while (N > 0) {
    N /= K;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }

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

    ll A, B; cin >> A >> B;
    ll num = B - A + 1;
    ll ans = 0;
    if(A % 2 == 0) {
        if(num % 2 == 0) {
            if((num / 2) % 2 == 0) cout << 0 << endl;
            else { ans = (B - 1) ^ B; cout << ans << endl; }
        }
        else {
            if((num-1)/2 % 2 == 0) cout << B << endl;
            else { ans = 1 ^ B; cout << ans << endl; }
        }
    }
    else {
        if(num % 2 != 0) {
            if(((num-1) / 2) % 2 == 0) cout << A << endl;
            else { ans = A ^ 1; cout << ans << endl; }
        }
        else {
            if(num/2 % 2 == 0) { ans = 1 ^ A ^ B; cout << ans << endl; }
            else { ans = A ^ B; cout << ans << endl; }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ipa pair<lld,lld>
#define lld long long int
#define x first
#define y second
#define ld long double
#define pb push_back
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI (atan(1)*4)
#define mp make_pair
#define mlog 21
#define mod 1000000007
using namespace std;
const int maxn=1e5+2;
main()
{
	fastread;
	lld i,j,n,m,h,w;
	string str[maxn];
	cin>>h>>w;
	for(i=0;i<h;++i)
	{
		cin>>str[i];
		str[i].push_back('#');
	}
	lld dp[h+2][w+2];
	memset(dp,0,sizeof(dp));
	dp[h-1][w-1]=1;
	for(i=h-1;i>=0;--i)
	{
		for(j=w-1;j>=0;--j)
		{
			if(str[i][j]=='#')continue;

			if(str[i+1][j]=='.'&&str[i][j+1]=='.')
			{
			 	dp[i][j]=((dp[i+1][j]%mod)+(dp[i][j+1]%mod))%mod;
			}  
			else if(str[i+1][j]=='.')
			{
			   dp[i][j]=dp[i+1][j]%mod;
			}
			else if(str[i][j+1]=='.')
			{
			    dp[i][j]=dp[i][j+1]%mod;
			}
		}
	}
	cout<<dp[0][0]<<" ";
}

Measured memory_bytes: 10880
a,b,k=[int(x) for x in input().split()]
if a>=k:
  a-=k
  print(str(a)+' '+str(b))
else:
  k-=a
  a=0
  if b>=k:
    b-=k
    print(str(a)+' '+str(b))
  else:
    b=0
    print("0 0")

Measured memory_bytes: 9124
def main():
    node_num, edge_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(edge_num)]

    inf = 10 ** 5 + 1
    length_data = [[inf for i in range(node_num + 1)] for j in range(node_num + 1)]

    for i in range(edge_num):
        a, b, c = data[i]
        length_data[a][b] = c
        length_data[b][a] = c

    for i in range(1, node_num + 1):
        for j in range(1, node_num + 1):
            for k in range(1, node_num + 1):
                length_data[j][k] = min(length_data[j][k], length_data[j][i] + length_data[i][k])

    ans = 0
    for i in range(edge_num):
        a, b, c = data[i]
        if c > length_data[a][b]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 1e18;
set<int> s;
int n,x;
void solve()
 {
  cin>>n;
  loop(i,0,n)
   {
	   cin>>x;
	   s.insert(x);
	}
 cout<<((int)s.size() == n ? "YES" : "NO");
  
 }  
signed main()
 {   
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0); 
   /*int t;
   cin>>t;
   loop(i,1,t+1)*/
      solve();
      
  //cerr<<END<<1.0*clock();
  return 0;
} 


Measured memory_bytes: 12960