akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;


int main() {
	int h, w;
	cin >> h >> w;
	int counter = 0;
	int factor[600][600];
	int count[600][600];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> factor[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			count[i][j] = 0;
			if (factor[i][j] % 2 == 1) {
				if (factor[i][j+1] % 2 == 1&&j+1 != w) {
					factor[i][j + 1] = factor[i][j + 1]+factor[i][j];
					count[i][j] = 1;
				}else if(factor[i+1][j] % 2 == 1&&i+1 != h) {
					factor[i+1][j] = factor[i+1][j] + factor[i][j];
					count[i][j] = 2;
				}
				else if(j+1 != w){
					factor[i][j + 1] = factor[i][j + 1] + factor[i][j];
					count[i][j] = 1;
				}
				else if(i+1 != h){
					factor[i+1][j] = factor[i+1][j] + factor[i][j];
					count[i][j] = 2;
				}
				else {
					continue;
				}
				counter++;
				
			}
			else {
				continue;
			}
		}
	}

	cout << counter << endl;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (count[i][j] == 1) {
				cout << i+1 << " " << j+1 << " " << i+1 << " " << j + 2 << endl;
			}
			else if (count[i][j] == 2) {
				cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
			}
			else {
				continue;
			}
		}
	}




}

Measured memory_bytes: 4480
#include <stdio.h>

int main(void) {

    int a, b;

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

    if (a > b) {
        printf("a > b\n");
    } else if (a < b) {
        printf("a < b\n");
    } else {
        printf("a == b\n");
    }
    

    return 0;
}

Measured memory_bytes: 580
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto I = readln.split.to!(long[]);
  auto A = I[0];
  auto B = I[1];

  long solve() {
    foreach(i; 0..30000) {
      auto cp8 = (i * 108) / 100 - i;
      auto cp10 = (i * 110) / 100 - i;

      if (cp8 == A && cp10 == B) return i;
    }
    return -1;
  }

  solve().writeln;
}


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

int main(void){
	int a=0,b=0,i,r;
	scanf("%d%d",&a,&b);
	r = b;
	for(i = 2;i <= a;i++){r*=(b-1);}
	printf("%d\n",r);
	return 0;
}

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

int main() {
    while(1){
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int sum = 0;
        for (int i = 1;i <= (n-2);i++){
            for (int j = (i+1);j <= (n-1);j++){
                for (int k = (j+1);k <= n;k++){
                    if (i+j+k == x){
                        sum ++;
                    }
                }
            }
        }
        cout << sum <<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
# coding: utf-8
# 86

a = input()
A = a.replace(',','')
B = A.replace('.','')
#print(B)
C=B.split()
#print(C)
#print(len(C))
R=[]
for i in range(len(C)):
    if len(C[i])>2 and len(C[i])<7:
       R.append(C[i])

print(*R)


Measured memory_bytes: 5560
class Dice:
    def __init__(self, num):
        self.num = num
    def roll(self, fn):
        if fn == "S":
            ue = self.num[4]
            self.num[4] = self.num[5]
            self.num[5] = self.num[1]
            self.num[1] = self.num[0]
            self.num[0] = ue
        elif fn == "W":
            ue = self.num[2]
            self.num[2] = self.num[5]
            self.num[5] = self.num[3]
            self.num[3] = self.num[0]
            self.num[0] = ue        
        elif fn == "N":
            ue = self.num[1]
            self.num[1] = self.num[5]
            self.num[5] = self.num[4]
            self.num[4] = self.num[0]
            self.num[0] = ue                
 
    def spin(self, fn):
        if fn == "migi":
            mae = self.num[3]
            self.num[3] = self.num[4]
            self.num[4] = self.num[2]
            self.num[2] = self.num[1]
            self.num[1] = mae
num = list(map(int, input().split(" ")))
dice1 = Dice(num)
n = int(input())
a = []
for i in range(n):
    u, f = map(int, input().split(" "))
    count = 0
    while num[0] != u and count<5:
        dice1.roll("S")
        count+=1
    count = 0
    while num[0] != u and count<5:
        dice1.roll("W")
        count+=1        
    while num[1] != f:
        dice1.spin("migi")
    a.append(num[2])
for i in range(n):
    print(a[i])
    


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

signed main()
{
	int n;
	int x, y, h, w;

	while (true)
	{
		cin >> n;
		if (n == 0) break;
		int ans = 0;
		rep(i,n)
		{
			cin >> x >> y >> h >> w;
			int len = x + y + h;

			if (len <= 60 && w <= 2)
			{
				ans += 600;
			}
			else if (len <= 80 && w <= 5)
			{
				ans += 800;
			}
			else if (len <= 100 && w <= 10)
			{
				ans += 1000;
			}
			else if (len <= 120 && w <= 15)
			{
				ans += 1200;
			}
			else if (len <= 140 && w <= 20)
			{
				ans += 1400;
			}
			else if (len <= 160 && w <= 25)
			{
				ans += 1600;
			}
		}

		printf("%d\n", ans);
	}
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int cntr = 0;
  int cntb = 0;
  rep(i,n) {
    if(s[i] == '0') cntr++;
    if(s[i] == '1') cntb++;
  }
  cout << min(cntr,cntb)*2 << endl;
  return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){   
    ll h, n;
    cin >> h >> n;
    ll a[n], b[n];
    rep(i, n)cin >> a[i] >> b[i];

    ll dp[n+1][h+1];
    rep(i, h+1)dp[0][i] = LINF;
    dp[0][0] = 0;

    rep(i, n)rep(j, h+1){
        if(j < a[i]){
            dp[i+1][j] = min(dp[i][j], b[i]);
        }
        else {
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-a[i]]+b[i]);
        }
    }
    cout << dp[n][h] << endl;
}

Measured memory_bytes: 78464
import itertools
from collections import Counter
N = int(input())
src = [input() for i in range(N)]
ctr = Counter()
for s in src:
    ctr[s[0]] += 1

ans = 0
for ptn in itertools.combinations('MARCH',3):
    a,b,c = ptn
    ans += ctr[a]*ctr[b]*ctr[c]
print(ans)

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
    li a, b;
    li n;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        li res1 = a + (b - a - 1) / 2;
        li res2 = (n - b + 1) + (n - (a + n - b + 1)) / 2;
        cout << min(res1, res2) << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>

using namespace std;

int cards[5];
int card[14]={0};


int main()
{
	start:
	while(scanf("%d,%d,%d,%d,%d",&cards[0],&cards[1],&cards[2],&cards[3],&cards[4])!=EOF)
	{
		fill(card,card+14,0);
		for(int i=0;i<5;i++)
		{
			card[cards[i]-1]++;
			if(cards[i]==1)card[13]++;
		}
		for(int i=0;i<13;i++)
		{
			if(card[i]==4)
			{
				printf("four card\n");
				goto start;
			}
			if(card[i]==3)
			{
				for(int j=0;j<13;j++)
				{
					if(card[j]==2)
					{
						printf("full house\n");
					    goto start;
					}
				}
				printf("three card\n");
					goto start;
			}
		}
		int flag=0;
		for(int i=0;i<13;i++)
		{
			if(card[i]==2)flag++;
		}
		if(flag==2)
		{
			printf("two pair\n");
					goto start;
		}
		if(flag==1)
		{
			printf("one pair\n");
					goto start;
		}
		for(int i=0;i<14;i++)
		{
			int k=1;
			for(int j=0;j<5;j++)
			{
				k*=card[i+j];
			}
			if(k==1)
			{
				printf("straight\n");
				goto start;
			}
		}
		printf("null\n");
		goto start;
	}
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

int min(int a, int b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

int avd_i(int a, int b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

int main() {
	
	int N, a[100005], count = 0;

	cin >> N;
	for (int i = 1; i <= N; i++) {

		cin >> a[i];
		if (a[i] < i) {

			if (a[a[i]] == i)count++;

		}

	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
int main()
{
    int n,m;
    cin >> n >> m;
    queue<int> q;
    rep(i,m){
        int a;
        cin >> a;
        q.emplace(a);

    }
    vector<int> dp(n+1,0);
    
    dp[0] = 1;
    dp[1] = 1;
    if(q.front() == 1){
        dp[1] = 0;
        q.pop();
    }
    rep(i,n+1){
        if (i-2<0)continue;
        if (i-1<0)continue;
        
        dp[i] = (dp[i-1]%mod+dp[i-2]%mod)%mod;
        if(q.front() == i){
            dp[i] = 0;
            q.pop();
        }

    }



        cout << dp[n] << endl;
    return 0;
}

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

const long long MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n * 2);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        v.at(i) = make_pair(a, 0);
    }
    for (int i = n; i < n * 2; i++) {
        int b;
        cin >> b;
        v.at(i) = make_pair(b, 1);
    }
    sort(v.begin(), v.end());

    vector<int> cnt(2);
    long long ans = 1;
    for (int i = 0; i < n * 2; i++) {
        int kind = v.at(i).second;
        if (cnt.at(kind ^ 1) > 0) {
            ans *= cnt.at(kind ^ 1);
            ans %= MOD;
            cnt.at(kind ^ 1)--;
        }
        else cnt.at(kind)++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	int ans = 0;
	int N, K;
	cin >> N >> K;
	
	map<int, int> mymap;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		mymap[a]++;
	}
	int n, *A;
	n = mymap.size();
	A = new int[n];
	map<int, int>::iterator it = mymap.begin();
	for (int i = 0; i < n; i++,it++)
		A[i] = it->second;
	
	sort(A, A + n);
	reverse(A, A + n);

	for (int i =K ; i < n; i++)
		ans += A[i];


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


Measured memory_bytes: 10368
class MergeSort:
    def __init__(self, array):
        self._arr = array
        self._cnt = 0

    def _merge(self, left, mid, right):
        arr1 = self._arr[left:mid] + [float('inf')]
        arr2 = self._arr[mid:right] + [float('inf')]

        i, j = 0, 0
        for k in range(left, right):
            if arr1[i] <= arr2[j]:
                self._arr[k] = arr1[i]
                i += 1
            else:
                self._arr[k] = arr2[j]
                j += 1
                self._cnt += len(arr1) - i - 1


    def _merge_sort(self, left, right):
        if right <= left + 1:
            return

        mid = (left + right) // 2
        self._merge_sort(left, mid)
        self._merge_sort(mid, right)
        self._merge(left, mid, right)

    def sort(self):
        self._merge_sort(0, len(self._arr))

    def print(self):
        # print(*self._arr)
        print(self._cnt)

n = int(input())
arr = [int(s) for s in input().split()]

alg = MergeSort(arr)
alg.sort()
alg.print()


Measured memory_bytes: 28356
#include <stdio.h>



int main(void)
{
	//変数の宣言
	int a,b,n;
	int ans;
	
	//データの読み込み
	scanf("%d",&n);
	
	if(n==1){
		printf("Hello World");
	}else{
		scanf("%d %d",&a,&b);
		printf("%d",a+b);
	}
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
//	ans = (a-1)*(b-1);
	
//	printf("計算部分終了\n");
	
	//出力
	
//	printf("%d",a+b);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
import java.util.*;

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

    double b = a/1.08;
    double c = (a+1)/1.08;
    int d = (int)c;

    if(b<=d){    
      double e = d*1.08;
      int f = (int)e;
    if(f == a){
      System.out.println(d);        
    }

    else{
      System.out.println(":(");
    }
    }

    else{
     System.out.println(":(");
    }
  }
}

Measured memory_bytes: 23380
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

a_c = Counter(sorted(a))
a_v = list(a_c.values())
a_k = list(a_c.keys())
count_max = a_v[0]
for i in range(1, len(a_v)):
    count = 0
    if a_k[i] - a_k[i - 1] == 1: 
        count += a_v[i - 1]
    if i < (len(a_v) - 1) and a_k[i + 1] - a_k[i] == 1:
        count += a_v[i + 1]
    count += a_v[i]
    if count > count_max:
        count_max = count
print(count_max)

Measured memory_bytes: 15332
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

using int64 = long long;

map< int64, int > prime_factor(int64 n)
{
    map< int64, int > ret;
    for(int64 i = 2; i * i <= n; i++){
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return(ret);
}

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i += 2){
        auto this_factors = prime_factor(i);
        int sum = 1;
        for(auto j: this_factors){
            sum *= j.second + 1;
        }
        ans += (sum == 8);
    }
    cout << ans << endl;
}


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

typedef long long lint;

int main(){
    lint n;
    cin >> n;
    vector<lint> a(n);
    for(lint i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    lint x = 0, y = 0;
    for(lint i = 0 ; i < n - 1 ; i++){
        if(a[i] == a[i+1]){
            if(x == 0){
                x = a[i];
            }else{
                y = a[i];
            }
            if(x != 0 && y != 0){
                break;
            }
            i++;
        }
    }
    cout << x * y << endl;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
divisors = []
def a(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    divisors.sort()
    return divisors
a(n)
x=len(divisors)//2
print(divisors[x]+divisors[x-1]-2)

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
int main() {
	ll n,k; cin >> n >> k;
	vint a(n);
	rep(i,n) cin >> a[i];
	int x=0;
	for(ll i=k;i<n;i++) {
		if(a[i]>a[x]) cout << "Yes" << endl;
		else cout << "No" << endl;
		x++;
	}
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  int arr[n];
  for(int i = 0; i < n; i++) cin >> arr[i];
  int dp[n];
  dp[0] = 0;
  for(int i = 1; i < n;i++) dp[i] = 1e+9;
  
  for(int i = 1; i < min(k,n); i++)
    for(int j = 0; j < i; j++)
      dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
  
  for(int i = k; i < n; i++)
    for(int j = i - k; j < i; j++)
      dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
    
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef long double ld;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int N;  cin>>N;
  vector<ll> v(N);
  rep(i,0,N) cin>>v[i];
  if(N==1||N==2){
    cout << 1 << endl;
    return 0;
  }
  int cnt=0;
  v.erase(unique(all(v)), v.end());
  rep(i,1,v.size()-1){
    if((v[i-1]<v[i] && v[i]>v[i+1])||(v[i-1]>v[i] && v[i]<v[i+1])) cnt++, i++;
  }
  cout << cnt+1 << endl;
  return 0;
}


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

using namespace std;
const int N=5e5+5,mod=1e9+7;
#define ll long long
int cnt[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>n) ans++;
        else cnt[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(cnt[i]>=i)
            ans+=cnt[i]-i;
        else ans+=cnt[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int cnt[30];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		int K;
		cin >> K;
		for (int j = 0; j < K; j++) {
			int A;
			cin >> A;
			A--;
			cnt[A]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < M; i++) {
		if (cnt[i] == N) ans++;
	}
	cout << ans << endl;
}

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

int main() {
  int n, c=0;
  cin >> n;
  vector<int> d(n),e(n);
  for(int i=0;i<n;i++){
    cin >> d.at(i) >> e.at(i);
    if(d.at(i) == e.at(i)){
      c++;
      if(c>=3){
        cout << "Yes";
        return 0;
      }
    }
    else
      c=0;
  }
  cout << "No";
  return 0;
}

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

int main() {
	int m, d, ans = 0;
	cin >> m >> d;
	for (int i = 1; i <= m; ++i)
		for (int j = 1; j <= d; ++j)
			ans += (j/10 >= 2) && (j%10 >= 2) && ((j/10)*(j%10) == i);
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    // 入力
    string S;
    cin >> S;
    
    //答えを入れる変数
    int ans = 0;
    
    //Sの部分文字列を全通り調べる
    for (int i = 0; i < S.size(); i++){
        for (int j = 1; j <= S.size() - i; j++){
            
            //部分文字列
            string word = S.substr(i, j);
            
            //ACGT文字列かどうかを判定するフラッグ
            bool can = true;
            
            //部分文字列がACGT文字列かどうかを調べる
            for (int i = 0; i < word.size(); i++){
                if(word[i] == 'A') continue;
                else if(word[i] == 'C') continue;
                else if(word[i] == 'G') continue;
                else if(word[i] == 'T') continue;
                else can = false;
            }
            
            //部分文字列がACGT文字列なら、ansとmaxする
            if(can) ans = max(ans, (int)word.size());
        }
    }
    
    //出力
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int positionA = Integer.MAX_VALUE;// Aは出来るだけ文字列の先頭で見つけたい
        int positionZ = 0;// Zは出来るだけ文字の後ろで見つけたい
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (positionA > i) positionA = i;
            } else if (s.charAt(i) == 'Z') {
                if (positionZ < i) positionZ = i;
            }
        }

        System.out.println(positionZ-positionA+1);
    }
}


Measured memory_bytes: 25044
def solve(mid):
    cnt = 0
    for i in range(n):
        cnt += (a[i] - 1) // mid
    return cnt <= k


n, k = map(int, input().split())
a = list(map(int, input().split()))

ok = 10 ** 18
ng = 0
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)

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

int main(){
	int a,b,c;
	int ans;
	int cnt=0;
	
	while(cin>>a>>b){
		//-----test-----
		if(0<=a && a<500) break;
		//if(0<=b && b<500) break;
		
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
		cnt++;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define is insert
#define es erase
#define pii pair<int,int>
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
const int N=1e6+11,mod=1e9+7;
int f[N];
int a[N],n;
map<int,int>s;
int main(){
	scanf("%d",&n);
	f[0]=1;
	rep(i,1,n){
		int x;
		scanf("%d",&x);
		f[i]=f[i-1];
		if(s[x]&&s[x]!=i-1)
			f[i]=(f[i]+f[s[x]])%mod;
		s[x]=i;
	}	
	printf("%d\n",f[n]);
	return 0;
}

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

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

  int res =0;
  int sum =0;
  int n5,n4,n3,n2,n1;
  
  for( int i = 1 ; i <= N; i++){
    n5 = i/10000;
  	n4 = (i-n5*10000)/1000;
    n3 = (i-n5*10000-n4*1000)/100;
    n2 = (i-n5*10000-n4*1000-n3*100)/10;
    n1 = (i-n5*10000-n4*1000-n3*100-n2*10);
    sum = n5+n4+n3+n2+n1;
//    cout << sum << endl;
    if( sum >= a && sum <= b){
//      cout << sum << endl;
      res += i;
    }
  }

  cout << res << endl;
}






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

int main()
{
	int n,m;
	cin >> n >> m;

	int k[10];
	int p[10];
	for(int i=0;i<m;i++){
		k[i] = 0;
		int ks;
		cin >> ks;
		int s;
		for(int j=0;j<ks;j++){
			cin >> s;
			s--;
			k[i] += (1<<s);
		}
		//cout << k[i] << endl;
	}
	//cout << "k" << endl;

	for(int i=0;i<m;i++){
		cin >> p[i];
	}

	int cnt = 0;
	for(int i=0;i<=(1<<n)-1;i++){
		//cout << "i:" << endl;
		bool flag = true;
		for(int j=0;j<m;j++){
			int bit = (i&k[j]);
			//cout << bit << endl;
			int bit_num = 0;
			for(; bit != 0; bit>>=1) {
		        bit_num += bit & 1;
		    }
		    if(bit_num%2 != p[j]){
		    	flag = false;
		    	break;
		    }
		}
		if(flag){
			cnt++;
			//cout << i << endl;
		}
	}

	cout << cnt << endl;
		
	return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

int point_exists(int point[][2], int p, int x, int y) {
	int i;
	for(i=0;i<p;i++) {
		if(point[i][0] == x && point[i][1] == y) {
			return 1;
		}
	}
	return 0;
}

int main(void) {
	int point[1000][2];
	char table[105][105];
	int i, p, row, col;
	int x, y;
	
	LABEL: while(scanf("%d %d\n", &row, &col) == 2) {
		if(row == 0 && col == 0) break;
		
		for(i=0;i<row;i++) {
			scanf("%s\n", table[i]);
		}
		
		p = 0;
		point[p][0] = x = 0;
		point[p][1] = y = 0;
		p++;
		
		while(1) {
			switch(table[y][x]) {
				case '>': // (大なり記号): 東向きの矢印が書かれたタイル
					x++;
					break;
				case '<': // (小なり記号): 西向きの矢印が書かれたタイル
					x--;
					break;
				case '^': // (べき記号) : 北向きの矢印が書かれたタイル
					y--;
					break;
				case 'v': // (小文字ブイ): 南向きの矢印が書かれたタイル
					y++;
					break;
				case '.': // (ピリオド) : 何も書かれていないタイル
					printf("%d %d\n", x, y);
					goto LABEL;
			}
			
			if(point_exists(point, p, x, y)) {
				printf("LOOP\n");
				break;
			}
			point[p][0] = x;
			point[p][1] = y;
			p++;
		}
	}
	
	return 0;
}

Measured memory_bytes: 636
N = int(input())
arr = list(map(int, input().split()))
Q = int(input())
que = [list(map(int, input().split())) for _ in range(Q)]

count_list=[0]*(10**5+1)

for i in range(N):
    count_list[arr[i]] +=1

ans = sum(arr)

for i in que:
    keep = count_list[i[0]]
    c_ans = ans+keep*(i[1]-i[0])
    print(c_ans)
    ans =c_ans
    if count_list[i[0]] == 0:
        continue
    if count_list[i[0]] != 0:
        count_list[i[1]] += count_list[i[0]]
        count_list[i[0]] = 0







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

int main() {
  int N;
  cin >> N;
  
  vector<int> data(N);
  for (int i = 0; i < N; i++) cin >> data.at(i);
  
  sort(data.begin(), data.end());
  
  int cnt = 0;
  for (int i = 0; i < N-2; i++) {
    for (int k = i+1; k < N-1; k++) {
      int l = k+1;
      while (data.at(i)+data.at(k) > data.at(l)) {
        cnt++;
        if (l == N-1) break;
        l++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define mer(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;




int main() {
	int L, R, d;
	cin >> L >> R >> d;
	cout << R/d - (L-1)/d << '\n';
	
	return 0;
}

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

int main(){
    ll n,m;
    std::cin >> n>>m;
    std::vector<vector<pair<ll,ll>>> graph(n);
    for (int i = 0; i < m; i++) {
        ll l,r,d;
        std::cin >> l>>r>>d;
        l--;
        r--;
        
        graph[l].push_back({r,d});
        graph[r].push_back({l,-d});
    }
    const ll INF = 1e14;
    vector<ll> dist(n,INF);
    std::queue<pair<ll,ll>> que;
    for (int i = 0; i < n; i++) {
        if(dist[i] != INF){
            continue;
        }
        dist[i] = 0;
        que.push({i,0});
        while(!que.empty()){
            auto q = que.front();
            que.pop();

            for (auto e : graph[q.first]) {
                if(dist[e.first] == INF){
                    dist[e.first] = dist[q.first] + e.second;
                    que.push({e.first,dist[e.first]});
                }else{
                    if(dist[e.first] != dist[q.first] + e.second){
                        std::cout << "No" << std::endl;
                        return 0;
                    }
                }
            }
        }
    }
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 14448
N = int(input())
list_A = list(map(int, input().split()))
money = 1000
stock = 0

for i in range(N - 1):
    if list_A[i] < list_A[i + 1]:
        money += stock * list_A[i]
        stock = money // list_A[i]
        money -= stock * list_A[i]
    elif list_A[i] > list_A[i + 1]:
        money += stock * list_A[i]
        stock = 0

last_stock_val = 0
for i in range(N -1):
    if list_A[-1-i] < list_A[-2-i]:
        continue
    else:
        last_stock_val = list_A[-1-i]
        break
money += stock * last_stock_val
print(money)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#include <string>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);


int main()
{
ll i;
cin>>i;
cout<<fixed<<setprecision(20)<<(double)(pow(i,3.0)/27.0)<<endl;
    return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


Measured memory_bytes: 4172
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    vector <ll> hs;
    REP(i, n){
        ll h; cin >> h;
        hs.push_back(h);
    }
    sort(hs.begin(), hs.end());
    ll teki = max(0, int(n-k));
    ll ans = 0;
    REP(i, teki){
        ans += hs[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
x=[[0]*3 for i in range(3)]
for b in B:
    for i,l in enumerate(A):
        for j,a in enumerate(l):
            if a==b:
                x[i][j]=1
print('Yes' if sum([all(l) for l in x]+[all(l) for l in zip(*x)]+[all([x[i][i] for i in range(3)]),all([x[i][2-i] for i in range(3)])]) else 'No')

Measured memory_bytes: 3064
#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;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

int main ()  {

    int n;cin>>n;
    int p[10],q[10];

    rep(i,n) {
        cin>>p[i];
    }
    rep(i,n) {
        cin>>q[i];
    }

    int array1[n],array2[10];
    rep(i,n) {
        array1[i]=i+1;
        array2[i]=i+1;
    }

    int a,b,cnt=0;
    do{
        cnt++;
        bool ok=true;
        for(int i=0; i<n; i++){
            if (array1[i]!=p[i]) {
                ok=false;
                break;
            }
        }
        if (ok) {
            a=cnt;
            break;
        }
    }while(next_permutation(array1,array1+n));

    cnt=0;

    do{
        cnt++;
        bool ok=true;
        for(int i=0; i<n; i++){
            if (array2[i]!=q[i]) {
                ok=false;
                break;
            }
        }
        if (ok) {
            b=cnt;
            break;
        }
    }while(next_permutation(array2,array2+n));

    cout<<abs(a-b)<<endl;

}

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

using namespace std;

int main() {
    long long N;
    cin >> N;

    for (long long a = 1; a <= 3500; ++a) {
        for (long long b = a; b <= 3500; ++b) {
            long long tmp = 4LL * a * b - N * b - N * a;
            if (tmp > 0 and (N * a * b) % tmp == 0) {
                long long c = (N * a * b) / tmp;
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  if(K<=A){cout<<K<<endl;}
  else if(K<=A+B){cout<<A<<endl;}
  else{cout<<2*A-K+B<<endl;}
}

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

typedef long long ll;
vector<ll>ele;
ll Pow[12];

void solve(int pos,int cur,ll now,int mx)
{
	if(cur<0||cur>9){
		return;
	}
	if(pos==0){
		ele.push_back(now+cur);
		return;
	}
	now += cur*Pow[pos];
	int lmt;
	if(mx==0){
		lmt = 9;
	}
	else{
		lmt = cur+1;
	}
	for(int i=cur-1;i<=lmt;i++){
		solve(pos-1,i,now,max(mx,i));
	}
}
int main()
{
	Pow[0] = 1;
	for(int i=1;i<=9;i++){
		Pow[i] = Pow[i-1]*10;
	}
	for(int i=0;i<=9;i++){
		solve(9,i,0,i);
	}
	int k;
	scanf("%d",&k);
	sort(ele.begin(),ele.end());
	printf("%lld\n",ele[k]);
}


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

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

int main()
{
    int kin;
    cin >> kin;

    int ans=0;
    for (int i=1;i<=kin;i++) {
        for (int j=1;j<=kin;j++) {
            for (int k=1;k<=kin;k++) {
                int tmp;
                if (i > j) {
                    tmp = gcd(i,j);
                    if (tmp > k) {
                        ans += gcd(tmp,k);
                    } else {
                        ans += gcd(k,tmp);
                    }
                } else {
                    tmp = gcd(j,i);
                    if (tmp > k) {
                        ans += gcd(tmp,k);
                    } else {
                        ans += gcd(k,tmp);
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

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

	long long A, B, N;
	scanf("%lld %lld %lld", &A, &B, &N);

	for (int i = 0; i < N; i++) {
		// cout << i << ":" << (A * i) / B << " " << A * (i / B) << " "
		//      << (A * i) / B - A * (i / B) << "\n";
	}

	if (N >= B) {
		cout << (A * (B - 1)) / B;
	} else {
		cout << (A * N) / B - A * (N / B);
	}

	return 0;
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a < b){
        for(int i=0;i<b;++i){
            cout << a;
        }
    }
    else{
        for(int i=0;i<a;++i){
            cout << b;
        }
    }
    cout << endl;

}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

b = [0]*N

b[0] = sum([A[i]*(-1)**i for i in range(N)])

for i in range(1, N):
    b[i] = 2*A[i-1] - b[i-1]

print(*b)

Measured memory_bytes: 14124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b) {
			System.out.println(c);
		} else if (b == c) {
			System.out.println(a);
		} else {
			System.out.println(b);
		}

		sc.close();
	}
}


Measured memory_bytes: 21716
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

int main() {
  intmax_t n;
  size_t m;
  scanf("%jd %zu", &n, &m);

  std::vector<intmax_t> a(m);
  for (auto& ai: a) scanf("%jd", &ai);

  for (auto ai: a) n -= ai;
  if (n < 0) n = -1;
  printf("%jd\n", n);
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e9+18
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=51;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
#define ub upper_bound
bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
 if(a.ss>b.ss)
 return 1;

 return 0;   
}
int main()
{
    ll n,i,j,l,k,m,d,p;
    cin>>n;
   k=n%10;
if(k==3)
    cout<<"bon";
else if(k==0||k==1||k==6||k==8)
    cout<<"pon";
else
    cout<<"hon";
}

Measured memory_bytes: 3612
import numpy as np

# arr = [
#     [0, 8, 8],
#     [0, 8, 8],
#     [0, 8, 8],
# ]
# arr = [
#     [2, 2, 2],
#     [2, 1, 2],
#     [2, 2, 2],
# ]
# 
# arr = [
#     [1, 0, 1],
#     [2, 1, 2],
#     [1, 0, 1],
# ]

arr = []
for i in range(3):
    arr.append([int(s) for s in input().split(" ")])





def calculate(arr):
        arr = np.array(arr)

        minValPerRow = min(arr[0])

        result = False

        for sa in range(minValPerRow+1):
            mrr = arr[0] - sa

            mrr1 = arr[1] - mrr
            mrr2 = arr[2] - mrr


            s1 = mrr1[0] == mrr1[1] == mrr1[2]
            s2 = mrr2[0] == mrr2[1] == mrr2[2]

            if s1 == True and s2 == True:
                result = True
                break


        if result:
            print("Yes")
        else:
            print("No")


calculate(arr)



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

using pll = pair<long, long>;
constexpr long MOD = 1000000007;

int main() {
	long n; cin >> n;
	vector<long> a(n, 0), b(n+1, 0);
	for (long i = 0; i < n; i++) {
		cin >> a[i];
		b[i+1] = a[i] + b[i];
	}

	long ans = 0;
	for (long i = 0; i < n-1; i++) {
		ans += (a[i] * ((b[n] - b[i+1]) % MOD)) % MOD;
		ans %= MOD;
	}

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


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

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

typedef long long LL;
typedef unsigned long long ULL;

int n, W;
LL v[110];
int w[110];

LL memo[110][100010];


int main(void)
{
	fastIO();
	
	cin >> n >> W;
	int S = 0;
	FOR(i,0,n){
		cin >> w[i] >> v[i];
		S += v[i];
	}

	FOR(i,0,n+1)
		FOR(j,0,S+1)
			memo[i][j] = 1e18;

	FOR(i,0,n)
		memo[i][0] = 0;

	FOR(j,0,S){
		FOR(i,0,n){
			memo[i+1][j+v[i]] = min(memo[i+1][j+v[i]], memo[i][j] + w[i]);
			memo[i+1][j] = min(memo[i+1][j], memo[i][j]);
		}
	}



	int ans = -1;
	FORI(j,S,0){
		if(memo[n][j] <= W){
			ans = max(ans,j);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,n,a,m,k,l,sum1=0,sum=0,flag,cnt=0,maxn,ans1,ans2,p=0,q=0,minn=INT_MAX,ans=INT_MAX;
    string s;
    char ch;
    vector<long long int>ar;
    cin>>k>>n;
    for(i=0; i<n; i++)
    {
        cin>>a;
        ar.push_back(a);

    }
    ans=ar[n-1]-ar[0];
    for(i=1; i<n; i++)
    {
        ans=min(ans,k-abs(ar[i]-ar[i-1]));
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main()
{
  int abcd;
  cin >> abcd;

  int num[4];
  for(int i=3; i>=0; i--){
    num[i] = abcd % 10;
    abcd /= 10;
    //cout << num[i] << endl;
  }
  
  int a = num[0];
  for(int j=0; j<2; j++){
    int b = j==0 ? num[1] : -num[1];
    for(int k=0; k<2; k++){
      int c = k==0 ? num[2] : -num[2];
      for(int l=0; l<2; l++){
        int d = l==0 ? num[3] : -num[3];          
        if(a+b+c+d==7){
          printf("%d%+d%+d%+d=7", a,b,c,d);
          return 0;
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    int ans = 1;
    for(int i = 1; i * i <= M; i++){
        if(M % i) continue;
        for(int d : {i, M / i}) if(M / d >= N) ans = max(ans, d);
    }
    cout << ans << endl;
    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int k;
    cin >> k;

    queue<ll> q;
    rep(i, 1, 10) { q.push(i); }

    ll x;
    rep(i, 0, k) {
        x = q.front();
        q.pop();

        if (x % 10 != 0) { q.push(10 * x + x % 10 - 1); }
        q.push(10 * x + x % 10);
        if (x % 10 != 9) { q.push(10 * x + x % 10 + 1); }
    }

    cout << x << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){

    char s;
    cin >> s;
    
    if(s == 'A'){
        cout << "T\n";
        return 0;
    }else if(s == 'T'){
        cout << "A\n";
        return 0;
    }else if(s == 'G'){
        cout << "C\n";
        return 0;
    }else{
        cout << "G\n";
        return 0;
    }


}

Measured memory_bytes: 256