akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int MAX = 1e5+10;
vector<int> adj[MAX];
bool vis[MAX];
int disc[MAX];
int low[MAX];
int parent[MAX];
int n;
int count_of_bridges;
set< pair<int,int> > B;
void init()
{
    for(int i = 0; i <= n; i++)
    {
        disc[i] = 0;
        low[i] = INT_MAX;
        vis[i] = false;
        parent[i] = -1;
    }
}

void bridge(int x)
{
    static int c = 0;
    vis[x] = true;
    disc[x] = low[x] = c++;

    for(int i = 0; i < adj[x].size(); i++)
    {
        if( ! vis[ adj[x][i] ])
        {
            parent[adj[x][i]] = x;

            bridge(adj[x][i]);

            low[x] = min(low[x],low[ adj[x][i] ]);

            if( low[ adj[x][i] ] > disc[ x ])
            {
                if( adj[x][i] > x)
                {
                    B.insert( {x, adj[x][i]} );
                }
                else
                {
                    B.insert( {adj[x][i], x} );
                }
            }
        }
        else if(parent[x] != adj[x][i])
        {
            low[x] = min( low[x], disc[ adj[x][i] ] );
        }
    }
}

int main()
{
    int m;

    cin >> n >> m;

    for(int i = 0; i < m; i++)
    {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    count_of_bridges = 0;
    init();
    B.clear();
    bridge(1);
    count_of_bridges = B.size();
    cout << count_of_bridges << endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
        cin >> a.at(i);

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int A = 0;
    int B = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            A += a.at(i);
        } else {
            B += a.at(i);
        }
    }

    cout << A - B << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int n,sum = 100000000;
  cin >> n;
  vector<int> w(n);
  for (int i = 0; i < n; i++){
    cin >> w[i];
  }
  for (int i = 0; i < n-1; i++){
    int sum1 = 0,sum2 = 0;
    for (int j = 0; j <= i; j++){
      sum1 += w[j];
    }
    for (int j = i+1; j < n; j++){
      sum2 += w[j];
    }
    if (abs(sum1 - sum2) < sum){
      sum = abs(sum1 - sum2);
    }  
  }
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int h = Integer.parseInt(sc.next());
			int w = Integer.parseInt(sc.next());
			// テーブル
			int[][] square = new int[10][10];
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					square[i][j] = Integer.parseInt(sc.next());
				}
			}
			// 壁
			int[] wall = new int[h * w];
			for (int i = 0; i < h * w; i++) {
				wall[i] = Integer.parseInt(sc.next());
			}
			for (int n = 0; n < 3; n++) {
				for (int i = 0; i < 10; i++) {
					for (int j = 0; j < 10; j++) {
						for (int k = 0; k < 10; k++) {
							square[i][j] = Math.min(square[i][j], square[i][k] + square[k][j]);
						}
					}
				}
			}
			//			boolean flag = true;
			//			while (flag) {
			//				flag = false;
			//				for (int i = 0; i < 10; i++) {
			//					if (i == 1) {
			//						continue;
			//					}
			//					for (int j = 0; j < 10; j++) {
			//						if (j == 1 || i == j) {
			//							continue;
			//						}
			//						if (square[i][j] + square[j][1] < square[i][1]) {
			//							square[i][1] = square[i][j] + square[j][1];
			//							flag = true;
			//						}
			//					}
			//				}
			//			}
			long ans = 0;
			for (int i = 0; i < h * w; i++) {
				if (wall[i] == -1 || wall[i] == 1) {
					continue;
				}
				ans += square[wall[i]][1];
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 45040
// H - Grid 1
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define MOD 1000000007

int main(){
	int H,W; cin>>H>>W;
	vi dp(W+1); dp[1] = 1;
	for(int h=1; h<=H; h++){
		string a; cin>>a;
		for(int w=1; w<=W; w++) dp[w] = a[w-1]=='.'? (dp[w] + dp[w-1]) % MOD: 0;
	}
	cout<< dp[W] <<endl;
}

Measured memory_bytes: 256
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int a,b;
	scdd(a,b);
	while(a!=0 || b!=0)
	{
		forin(i,0,a)
		{
			forin(j,0,b)
			{
				if(j%2==0 && i%2==0)
				printf("#");
				else if(j%2==1 && i%2==0)
				printf(".");
				else if(j%2==1 && i%2==1)
				printf("#");
				else
				printf(".");
			}
			newline;
		}
		newline;
		scdd(a,b);
	}
	
	return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<string>
using namespace std;
double time5M, time10M;

void score(){
	string rank="NA";
	if(time5M < 70.0 && time10M < 148.0) rank="E";
	if(time5M < 55.0 && time10M < 116.0) rank="D";
	if(time5M < 50.0 && time10M < 105.0) rank="C";
	if(time5M < 43.0 && time10M < 89.0) rank="B";
	if(time5M < 40.0 && time10M < 83.0) rank="A";
	if(time5M < 37.5 && time10M < 77.0) rank="AA";
	if(time5M < 35.5 && time10M < 71.0) rank="AAA";
	cout << rank << endl;
}

int main(){
	while(cin >> time5M >> time10M){
		score();
	}
	return 0;
}

Measured memory_bytes: 0
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    m = A[0]
    sum = A[0] + A[1]
    for i in range(N-1):
        A = list(map(int, input().split()))
        if A[0] > m:
            m = A[0]
            sum = A[0] + A[1]
    print(sum)


Measured memory_bytes: 3188
from heapq import heappush, heappop
N, M = map(int, input().split())
ls = []
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,b)]
ls.sort(reverse=True)
hq = []
ans = 0
for i in range(1,M+1):
  while ls:
    if ls[-1][0]-i==0:
      heappush(hq,-ls[-1][1])
      ls.pop()
    else:
      break
  if hq==[]:
    continue
  ans -= heappop(hq)
print(ans)


Measured memory_bytes: 68312
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unrolong long-loops")
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#define F first
#define S second
using namespace std;
double a[200003];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    double ans=0;
    deque<double > d;
    double cur=0;
    for(int i = 1; i <= n; i++){
        cur+=((a[i]*(a[i]+1.00)/2.0)/a[i]);
        if(i>=m){
            if(i>m)
            cur-=((a[i-m]*(a[i-m]+1.0)/2.0)/a[i-m]);
            ans=max(ans,cur);
        }
    }
    cout.precision(7);
    cout<<fixed<<ans;
    return 0;
}
/*
 1 - u
 2 - d
 3 - r
 4 - l
 
 
 9
 0 1 0 2
 1
 0 2 0 3 2
 0 3 0 4 3
 0 4 1 0 4
 1 0 1 1 5
 1 1 1 2 6
 1 2 1 3 7
 1 3 1 4 8
 1 4 2 0 9
 */


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

int main(){
	int N , M , answer = 0, count = 0;
  	cin >> N;
  	vector<string> S(N);
  	for (int i = 0 ; i < N ; i++){
    	cin >> S.at(i);
    }
  
  	cin >> M;
  	vector<string> T(M);
  	for (int i = 0 ; i < M ; i++){
    	cin >> T.at(i);
    }
  	
  
  	for (int i = 0 ; i < N ; i++){
    	for(int j = 0 ; j < N ; j++){
        	if(S.at(i) == S.at(j)){
            	count++;
            }
        }
      	for(int j = 0 ; j < M ; j ++){
        	if(S.at(i) == T.at(j)){
            	count--;
            }
        }
      	if(answer<count){
        	answer = count;
        }
      	count = 0;
    }
  	cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
#define mp make_pair
//manip
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; }
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i_, n) cout << a[i_] << " "; cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always
//ctrl + command + e -> 変数一括変更



int main() {
    
    
   
    int n; cin >> n;
    int table[101][101]; fill_n(*table, 101 * 101, inf);
    rep(i, 101) table[i][i] = 0;
    vector<vector<pii> > edge(n);
    rep(i, n) {
        int u, k; cin >> u >> k;
        rep(j, k) {
            int v, c; cin >> v >> c;
            edge[u].eb(v, c);
        }
        
    }
    
    while (1) {
        int update = 0;
        rep(from, n) {
            rep(j, SZ(edge[from])) {
                int to = edge[from][j].F;
                int cost = edge[from][j].S;
                
                if (table[0][to] > table[0][from] + cost) {
                    update = 1;
                    table[0][to] = table[0][from] + cost;
                }
            }
        }
        if (update == 0) break;
    }
    
    out(0 << " " << 0);
    rep3(i, 1, n) out(i << " " << table[0][i]);
        
        
    
    
    
}



Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <tuple>

using namespace std;

using int64 = long long;

const int64 INF = (1LL<<60);

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

    int64 A = H * W;

    if (H == 1 || W == 1) {
        cout << 1 << "\n";
    } else {
        cout << (A + 1) / 2 << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int	main(void)
{
	int n,a,min=1000000,max=-1000000,i;
	long sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		min=(a<min ? a : min);
		max=(a>max ? a : max);
		sum+=a;
	}
	printf("%d %d %ld\n",min,max,sum);
	return	0;
}

Measured memory_bytes: 600
<?php
$hw = explode(' ',trim(fgets(STDIN)));
$h = $hw[0];
$w = $hw[1];

for ($i=0; $i<$h; $i++){
  $l = trim(fgets(STDIN));
  for ($k=0; $k<2; $k++){
    if (!($i==0 && $k==0))echo "\n";
    for ($j=0; $j<$w; $j++){
    	echo $l[$j];
  	}
  }
}

?>

Measured memory_bytes: 4604
a,b,c=map(int,input().split())
a,b,c=sorted([a,b,c])
d1,d2 = c-a,c-b

if d1==d2:print(d1)
elif (d1-d2)%2==1:print(d2+(d1-d2+1)//2+1)
else:print(d2+(d1-d2)//2)

Measured memory_bytes: 9136
#include<iostream>

using namespace std;

int n;
string now,unlock;

string make(string s, int start, int end, bool f){
  if(f){
    while(1){
      for(int i = start; i <= end; i++){
	if(s[i] == '9') s[i] = '0';
	else s[i]++;
      }
      if(s[start] == unlock[start]) break;
    }
  }else{
    while(1){
      for(int i = start; i <= end; i++){
	if(s[i] == '0') s[i]='9';
	else s[i]--;
      }
      if(s[start] == unlock[start]) break;
    }
  }
  return s;
}

int solve(string s, int rev, int fin){

  
  if(fin >= n) return rev;

  if(s[fin] == unlock[fin]) return solve(s,rev,fin+1);

  int ans = (1<<25);

  int rc=0,lc=0;
  //r -> --. l -> ++;


  if(s[fin] < unlock[fin]){
    lc = unlock[fin]-s[fin];
    rc = (10-unlock[fin]-'0')+s[fin]-'0';
  }else{
    lc = (10-s[fin]-'0')+unlock[fin]-'0';
    rc = s[fin]-unlock[fin];
  }

  bool isR=false;
  if(rc < lc) isR = true;

  
  for(int i = fin; i < n; i++){
    ans = min(ans,solve(make(s,fin,i,isR),rev+1,fin+1));
  }
  return ans;
}

int main(){
  
  while(cin >> n && n){
    cin >> now >> unlock;
    cout << solve(now,0,0) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1212
import java.util.*;

public class Main {
    public static void main(String[] args) {
//        test();
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

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

        System.out.println(calc(N, A, B, cities));
    }

    private static long calc(int n, int a, int b, long[] cities) {
        long cost = 0;

//        System.out.println(Arrays.toString(cities));
        for (int i = 0; i < n-1; i++) {
            cost += Math.min((cities[i+1] - cities[i])*a, b);
//            System.out.println("Move distance: " + (cities[i+1] - cities[i]) + "cost sum: " + cost);
        }

        return cost;
    }

}


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

void sort(int N, int *array){
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
        if(array[i]<array[j]){
            int temp = array[i];
            array[i]=array[j];
            array[j]=temp;
        }
        }
    }
    
}


int main(int argc, const char * argv[]) {
    // insert code here...
    int N ;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
        cin >>a[i];
    }
    sort(N,a);
    
    int sumA =1;
    //int sumB=0;
    
    for(int i=0;i<N-1;i++){
        if(a[i]-a[i+1]!=0)sumA++;
    }

    cout << sumA<<endl;
    
}


Measured memory_bytes: 256
using System;

namespace ABC123 {
  class ProblemB {
    static void Main(string[] args) {
      string str;
      int[] order = new int[5];
      int rest = 9, r = 9, index = 0;
      for (int i = 0; i < 5; i++) {
        str = System.Console.ReadLine();
        order[i] = int.Parse(str);
        r = (order[i] - 1) % 10;
        if (rest > r) {
          rest = r;
          index = i;
        }
      }
      int sum = 0;
      for (int i = 0; i < 5; i++) {
        if (i != index && order[i] % 10 != 0) {
          order[i] = (order[i] / 10 + 1) * 10;
        }
        sum += order[i];
      }
      
      System.Console.WriteLine(sum);
    }
  }
}

Measured memory_bytes: 11092
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto ai = readln.split.map!(to!int).array;

  auto flag = true, c = 0;
  while (flag) {
    flag = false;
    foreach_reverse (j; 1..n)
      if (ai[j] < ai[j - 1]) {
        swap(ai[j], ai[j - 1]);
        ++c;
        flag = true;
      }
  }

  writeln(ai.map!(to!string).join(" "));
  writeln(c);
}

Measured memory_bytes: 2488
#include<bits/stdc++.h>
using namespace std;
int n,a[111111][3],memo[111111][3];
int dp(int x,int y){
  int ret=0;
  if(memo[x][y]!=-1) return memo[x][y];
  if(x==n) return 0;
  if(x==0){
    for(int i=0;i<3;i++){
      ret=max(ret,dp(x+1,i)+a[x][i]);
    }
  }else{
    for(int i=0;i<3;i++){
      if(y!=i) ret=max(ret,dp(x+1,i)+a[x][i]);
    }
  }
  return memo[x][y]=ret;
}
int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
  cout<<dp(0,0)<<endl;
  return(0);
}


Measured memory_bytes: 10496
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int max = 0;

	for (int i=0; i<3; ++i){
		if (max < a[i]){
			max = a[i];
		}
	}

	int num=0;
	for (int i=0; i<3; ++i){
		if (max != a[i]){
			num += a[i];
		}
	}

	if (max==num){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


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

using namespace std;

const int MAXN = 1e5 * 2 + 1;
int arr[MAXN];
int n, k, ans;

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

	cin >> n;

	k = 1;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;

		if (k == a) {
			k++;
		}
		else {
			ans++;
		}
	}

	if (k > 1) cout << ans << "\n";
	else cout << "-1\n";

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from collections import Counter


def main():
    n = int(input().strip())
    d = list(map(int, input().strip().split()))
    if d[0] != 0:
        print(0)
        return
    e = sorted(list(set(d)))
    for i, v in enumerate(e):
        if i != v:
            print(0)
            return
    v = dict(Counter(d))
    if v[0] != 1:
        print(0)
        return
    i = 0
    ans = 1
    while True:
        if i in v:
            if i == 0:
                i += 1
                continue
            ans *= v[i-1] ** v[i]
            ans %= 998244353
        else:
            break
        i += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 70524
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll N,K;
  cin>>N>>K;
  vec A(N,0);
  rep(i,0,K) {
    ll d;
    cin>>d;
    rep(i,0,d) {
      ll a;
      cin>>a;
      A[a-1]=1;
    }
  }
  ll count=0;
  rep(i,0,N) {
    if(A[i]==0) {
      count+=1;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for((int)(i)=0;(i)<(int)(n);(i)++)
#define ll long long
 
using namespace std;
  
int main(){
  ll N,K,diff,ans;
  cin >> N >> K;
  
  diff = N % K;
  
  ans = min(diff,K - diff);
  cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MAX = 2 * 10 ** 5 + 5
MOD = 10 ** 9 + 7

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]

def comInit(mod):
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

def com(mod, n, k):
    numerator = 1
    for i in range(1, k + 1):
        numerator *= (n - i + 1)
        numerator %= mod
    return (numerator * finv[k] % mod)
comInit(MOD)

n, a, b = map(int, readline().split())
nb = n

def my_pow(base, n, mod):
    if n == 0:
        return 1
    x = base
    y = 1
    while n > 1:
        if n % 2 == 0:
            x *= x
            n //= 2
        else:
            y *= x
            n -= 1
        x %= mod
        y %= mod
    return x * y % mod
ans = (my_pow(2, n, MOD) - 1) % MOD

print((ans - com(MOD, nb, a) - com(MOD, nb, b)) % MOD)

Measured memory_bytes: 27280
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = -10000000000
ansi = -1
for i, h in enumerate(H):
    t = T - 0.006*h
    if abs(t - A) < abs(ans - A):
        ans = t
        ansi = i
print(ansi + 1)


Measured memory_bytes: 3060
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int a,b;
	cin >> a >> b;
	cout << 6 -(a+b);


    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int &x : A) cin >> x;
    vector<int> B(A);
    sort(B.begin(), B.end());
    int diff = 0;
    for (int i = 0; i < N; i++) {
        int pos = lower_bound(B.begin(), B.end(), A[i]) - B.begin();
        diff += abs(i - pos) % 2;
    }
    cout << diff / 2 << endl;
    return 0;
}

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


def solve(N: int):
    print("ABC"+str(N))
    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
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
program Multipleof
    implicit none
    character(len=200000) n
    integer(8) a,i,ans

    read *,n
    a=len_trim(n)
    ans=0
    do i=1,a
        if(n(i:i)=="1") then
            ans=ans+1
        else if(n(i:i)=="2") then
            ans=ans+2
        else if(n(i:i)=="3") then
            ans=ans+3
        else if(n(i:i)=="4") then
            ans=ans+4
        else if(n(i:i)=="5") then
            ans=ans+5
        else if(n(i:i)=="6") then
            ans=ans+6
        else if(n(i:i)=="7") then
            ans=ans+7
        else if(n(i:i)=="8") then
            ans=ans+8
        else if(n(i:i)=="9") then
            ans=ans+9
        end if
    end do
    if(mod(ans,9)==0) then
        print *,"Yes"
    else
        print *,"No"
    end if
end program Multipleof

Measured memory_bytes: 3292
#include<iostream>
using namespace std; 
int main(){
  char s[3],s1[3];
  int c=0;
  cin>>s>>s1;
  if(s[1]==s1[1])c++;
  if(s[0]==s1[0])c++;
  if(s[2]==s1[2])c++;
  cout<<c;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, k;

int main() {
	cin >> n >> k;
	
	cout << n - k + 1 << endl;
	
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long l;

int gcd(int a, int b){return b ? gcd(b, a%b): a;}

int max(int a, int b){return a > b ? a: b;}
int min(int a, int b){return a < b ? a: b;}

int main(void){
	
	int a, b, n, h, w, sum = 0;
	
	scanf("%d", &n);
	scanf("%d", &h);
	scanf("%d", &w);
	int i;
	for(i = 0; i < n; i++){
		scanf("%d", &a);
		scanf("%d", &b);
		
		if(h <= a && w <= b){sum++;}
	}
	
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 128
// ===========================================
// 20.03.12 Atcdoer DP まとめコンテスト. D - Knapsack 1 (knapsack dp)
// 
// 
// ===========================================
/*
N個の品物があります。 品物には 1,2,…,N と番号が振られています。 各 i
i(1≤i≤N1≤i≤N) について、品物 ii の重さは wi で、価値は vi です。

太郎君は、N 個の品物のうちいくつかを選び、ナップサックに入れて持ち帰ることにしました。 
ナップサックの容量は W であり、持ち帰る品物の重さの総和は W 以下でなければなりません。

太郎君が持ち帰る品物の価値の総和の最大値を求めてください。

1 <= v <- 10e9
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=1; i<=n; i++)
#define rez(i,n) for(int i = 0; i<n; i++)
#define ET "\n"
#define CLR(arr) memset(&arr, 0, sizeof(arr))
#define PAIR pair<int, int>
const ll INF = 1LL << 50;
const int mini = 10e5+5;



int main(){
    
    int n; cin >> n;
    int maxWght; cin >> maxWght;
    
    
    int w[n+1];
    int v[n+1];
    rep(i,n) cin >> w[i] >> v[i];
    
    ll dp[maxWght+1]; CLR(dp);
    for(int i=1; i<=n; i++){
        for(int j=maxWght; j-w[i]>=0; j--){
            dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
        }
    }
    cout << dp[maxWght];
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.141592653589793238462643383279502884197
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int a[214514];
signed main(){
	int n;
	cin>>n;
	vector<int> b;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=n;i>=1;i--){
		if( a[i] == 1 ){
			b.pb(i);
			for(int j=1;j*j<=i;j++){
				if( i % j == 0 ){
					a[j] = 1 - a[j];
					if( j*j != i ) a[i/j] = 1 - a[i/j];
				}
			}
		}
	}
	cout<<b.size()<<endl;
	for(int i=0;i<b.size();i++){
		cout<<b[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3572
# Problem C - To Infinity

# input
S = list(input())
s_len = len(S)
K = int(input())

# initialization
pos = 0
while K>0:
    K -= 1
    if int(S[pos])==1:
        pos += 1
    else:
        K += 1
        break
    if pos==s_len:
        pos -= 1
        break

# output
if K==0:
    print(S[pos-1])
else:
    print(S[pos])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int x, a, b; cin >> x >> a >> b;
    if ((b-a) <= 0) cout << "delicious" << endl;
    else if ((b-a) <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define INF 999999999
#define all(v) begin(v), end(v)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
    
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};


int n;
    
bool check(vector<int>& color){
    int m = color.size();
    if(color.size() < 4) return false;
    
    int cnt = 1;
    FOR(i, 1, m){
        if(color[i-1] == color[i]) cnt++;
        else{
            if(cnt >= 4 && i >= cnt){
                color.erase(color.begin()+(i-cnt), color.begin()+i);
                return true;
            }
            
            cnt = 1;
        }
    }
    
    if(cnt >= 4){
        color.erase(color.begin()+(m-cnt), color.end());
    }
    
    return false;
}
    
int solve(){
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    
    int ans = INF;
    vector<int> color;
    REP(i, n){
        color = v;
        if(color[i] == 1) color[i] = 2;
        else if(color[i] == 2) color[i] = 3;
        else color[i] = 1;
        while(check(color)){}
        if(ans > color.size()) ans = color.size();
        
        color = v;
        if(color[i] == 1) color[i] = 3;
        else if(color[i] == 2) color[i] = 1;
        else color[i] = 2;
        while(check(color)){}
        if(ans > color.size()) ans = color.size();
    }
    
    cout << ans << endl;
}

int main(){
    while(true){
        cin >> n;
        if(!n) return 0;
        solve();
    }
}

Measured memory_bytes: 1300
N = int(input())
S1=input()
S2=input()
MOD=10**9+7
for i in range(N):
  if i==0:
    if S1[0]==S2[0]:
      ans=3
    else:
      ans=6
  else:
    if S1[i-1]==S2[i-1]:
      ans*=2
    else:
      if S1[i]==S2[i]:
        pass
      else:
        if S1[i-1]==S1[i]:
          pass
        else:
          ans*=3
  ans%=MOD
print(ans)

Measured memory_bytes: 38384
#include"stdio.h"
#include"string.h"
#include"stack"
#include"map"
#include"math.h"
#include"iostream"
#include"vector"
#include"queue"
#include"algorithm"
using namespace std;
#define OK printf("\n");
#define Debug printf("this_ok\n");
#define INF 1e18
typedef long long ll;
#define scanll(a,b) scanf("%lld%lld",&a,&b);
#define scanl(a) scanf("%lld",&a);
#define printl(a,b) if(b == 0) printf("%lld ",a); else printf("%lld\n",a);
#define print_int(a,b) if(b == 0) printf("%d ",a); else printf("%d\n",a);
typedef pair<int,int> PII;

inline int read(){
    int s = 0, w = 1; char ch = getchar();
    while(ch < '0' || ch > '9')   { if(ch == '-') w = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') { s = (s << 3) + (s << 1) + (ch ^ 48); ch = getchar(); }
    return s * w;
}
const ll mod = 998244353;
const int N = 50010,M = 300010;
const  double pi = acos(-1);
const int inf = 1 << 29;
const int dirx[4] = {-1,0,1,0};
const int diry[4] = {0,1,0,-1};
int n,m,t,s,tot;
ll maxflow,sum;
int head[N],ver[M],Next[M],edge[M],d[N];
queue<int> q;

void add(int x,int y,int z){
    ver[++ tot] = y; Next[tot] = head[x];  edge[tot] = z; head[x] = tot;
    ver[++ tot] = x; edge[tot] = 0; Next[tot] = head[y]; head[y] = tot;
}

bool bfs(){
    memset(d,0,sizeof(d));
    while(q.size())q.pop();
    q.push(s); d[s] = 1;
    while(q.size()){
        int x = q.front(); q.pop();
        for(int i = head[x]; i; i = Next[i])
        if(edge[i] && !d[ver[i]]){
            q.push(ver[i]); d[ver[i]] = d[x] + 1;
            if(ver[i] == t) return 1;
        }
    }
    return 0;
}

int dinic(int x,ll flow){
    if(x == t) return flow;
    ll rest = flow,k;
    for(int i = head[x]; i && rest; i = Next[i]){
         if(edge[i] && d[ver[i]] == d[x] + 1){
            k = dinic(ver[i],min(rest,(ll)edge[i]));
            if(!k) d[ver[i]] = 0;
            edge[i] -= k;
            edge[i ^ 1] += k;
            rest -= k;
         }
    }
    return flow - rest;
}
int main(){
    n = read(),m = read();s = read();
    if(m * s >= n) printf("Yes\n");
    else printf("No\n");
}
/*
3
1 2 3
2
2 6
*/



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

int main(){
  
  int N,K;
  std::cin>>N>>K;
  
  std::vector<int> vector;
  for(int i=0;i<N;i++){
    int temp;
    std::cin>>temp;
    vector.push_back(temp);
  }
  
  std::sort(vector.begin(),vector.end());
  
  int min=1000000000;
  
  for(int i=0;i<=N-K;i++){
    int temp=vector[i+K-1]-vector[i];
    if(temp<min)
      min=temp;
  }
  
  std::cout<<min<<std::endl;
  
  return 0;
}

Measured memory_bytes: 892
import numpy as np
X, N = (int(i) for i in input().split())
p = sorted([int(i) for i in input().split()])
if X in p:
    s = p.index(X)
    i = 1
    while True:
        if (s-i)<0:
            print(p[0]-1)
            break
        elif p[s-i] != (X-i):
            print(X-i)
            break
        elif (s+i)>=N:
            print(p[N-1]+1)
            break
        elif p[s+i] != (X+i):
            print(X+i)
            break
        else:
            i = i + 1
else:
    print(X)

Measured memory_bytes: 27176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;


int main() {
    int x;
    cin >> x;
    int a = x / 500;
    int b = (x % 500) / 5;
    cout << a * 1000 + b * 5 << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    cout << 180*(n-2) << endl;
    return 0;
}

Measured memory_bytes: 888
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.io.*;

class Main
{
 public static void main(String[] args) throws IOException
 {
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     String str = br.readLine();
     String[] abc = str.split(" ", 0);
     int a = Integer.parseInt(abc[0]);
     int b = Integer.parseInt(abc[1]);
     int c = Integer.parseInt(abc[2]);

     if(a < b){
    	 if (b<c){   	 
         System.out.println("Yes");}
    	 else{
    		 System.out.println("No");}
    	 }    	 
     else {
         System.out.println("No");
 }
}
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
# 10 ** 7 might cause MLE
fac = [-1] * (10**6+1)
inv = [-1] * (10**6+1)
finv = [-1] * (10**6+1)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def NCMMod(n, k):
    if n < k:
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod
initNCMMod(10**6)

def checkf(R, C):
    ans = 0
    for r1 in range(R):
        for c1 in range(C):
            for r2 in range(R):
                for c2 in range(C):
                    ans += abs(r1-r2) + abs(c1-c2)
    return ans


def main():
    R, C, K = LI()
    def f(i):
        return (i * (i+1) // 2) % mod

    ans = 0
    for i in range(C):
        ans += f(C-i-1) * R * R % mod
        ans += f(i) * R * R % mod

    for i in range(R):
        ans += f(R-i-1) * C * C % mod
        ans += f(i) * C * C % mod
    ans *= inv[2]
    ans %= mod
    ans *= NCMMod(R*C-2, K-2)
    ans %= mod

    print(ans)

main()



Measured memory_bytes: 106972
#include <stdio.h>

int main(void){
  int i;

  int a, b;
  scanf("%d%d", &a, &b);

  int soket=1;
  for(i=0;; i++){
    if(soket>=b) break;
    soket+=a-1;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

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--)

int main(){
    int A,B,rs=0,goukei=0;
    cin >> A >> B;

    if(B > 1){
        rs++;
        goukei = A;
        while(goukei < B){
            goukei += A -1;
            rs++;
        
        }
    }

    cout << rs << endl;

    return 0;
    
} 

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = a * (n/(a+b));
  ans += min(n%(a+b), a);
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
tan_val1 = (2 * (a * a * b - x)) / (a*a*a)
tan_val2 = (a*b*b) / (2*x)
vol = (a*a*b)*0.5
if x > vol:
    ans = math.degrees(math.atan(tan_val1))
else:
    ans = math.degrees(math.atan(tan_val2))
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef int _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	doin();
	string s;
	cin >> s;
	int n = s.size();
	s = " " + s;
	if(s[n] != '0' || s[1] == '0')
		return cout << -1, 0;
	for(int i = 1; i < n; i++)
		if(s[i] != s[n-i])
			return cout << -1, 0;
	int root = 2, cnt = 2;
	cout << "2 1\n";
	for(int i = 3; i <= n; i++) {
		cout << root << " " << i << "\n";
		if(s[i-1] == '1') root = i;
	}
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=1e9+7;//998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b) {
    a %= mod;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%mod;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = add(C[j],C[j-1]); 
    } 
    return C[k]%mod; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 

//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

 ll int sum(ll int n) 
 { 
    ll int s; 
  
    /* Single line that calculates sum */
    for (s = 0; n > 0; s += n % 10, n /= 10); 
  
    return s; 
 } 

ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 
 
 int main() {
  ios;
  ll int n;
  cin>>n;
  ll int l=0;
  for(int i=1;i<n;i++)
  {
      for(int j=1;j<n;j++)
      {
          if(i*j<n)
          {
              l++;
          }
          else
          {
              break;
          }
      }
  }
  cout<<l<<endl;
  }


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

int main() {
  vector<int> vec(3);
  
  for(int i = 0; i <3; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int answer = 1;
  
  if(vec.at(0) != 5){
    answer *= 0;
  }
  
  if(vec.at(1) != 5){
    answer *= 0;
  }
  
  if(vec.at(2) != 7){
    answer *= 0;
  }
  
  if(answer == 1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
import sys

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(i) for i in input().split()]
    gcdA = A[0]
    for a in A: gcdA = gcd(gcdA, a)
    print(gcdA)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 20016
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const ll INF = 1e9;
const ll MOD = 1e9+7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    ll S; cin >> S;
    vl X(3), Y(3);
    X[0] = Y[0] = 0;
    X[1] = INF; Y[1] = 1;
    X[2] = (INF - S%INF)%INF; Y[2] = (S+X[2])/INF;
    REP(i, 3) cout << X[i] << " " << Y[i] << " ";
    cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int x; cin >> x;
  outl(x / 3);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main(void){
  int n,l,i,tmp;
  int min=1e9;
  int sum=0;
  scanf("%d %d",&n,&l);
  int a[n];
  for(i=0;i<n;i++){
    sum += a[i] = l+i;
    if(min>abs(a[i])){
      min = abs(a[i]);
      tmp = i;
    }
  }
  printf("%d\n",sum-a[tmp]);
  return 0;
}

Measured memory_bytes: 128