akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 2e5+555;
int const inf = 2e16;



void solve(){  
    int i,j,l;
    int n,k;
    cin >> n >> k;
    int a[n+1];
    for(i=1;i<=n;i++){
        cin >> a[i];
    }

    while(k--){
        int b[n+2] = {0};

        for(i=1;i<=n;i++){
            int r = min(i+a[i] , n);
            int l = max(1LL , i-a[i]);

            b[r+1]--;
            b[l]++;
        }

        for(i=1;i<=n;i++) b[i] += b[i-1];
        int cnt = 0;
        for(i=1;i<=n;i++) {
            a[i] = b[i];
            if(a[i] == n) cnt++;
        }
        if(cnt == n) break;
    }
    // cout<<k<<endl;
    for(i=1;i<=n;i++) cout<<a[i]<< " ";
    cout<<endl;
}           


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*



*/

Measured memory_bytes: 6772
N, T = map(int, input().split())
*A, = map(int, input().split())
min_price = A[0]
max_prof = 0
count = 1
for a in A[1:]:
    prof = a - min_price
    if prof < 0: min_price = a
    elif prof == max_prof: count += 1
    elif prof > max_prof: max_prof = prof; count = 1;
print(count)

Measured memory_bytes: 14252
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-8

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	int n, m;
	cin>>n>>m;
	vector<set<ll> > c(n);
	REP(i, m) {
		int a, b;
		cin>>a>>b;
		--a;
		--b;
		c[a].insert(b);
		c[b].insert(a);
	}
	vector<bool> d(n, false);
	REP(i, n) {
		if(c[i].count(n - 1) != 0) d[i] = true;
	}
	bool e = false;
	auto ite = c[0].begin();
	while(ite != c[0].end()) {
		if(d[*ite]) e = true;
		++ite;
	}
	if(e) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}


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

int n,fb,la,answer,nab;
bool abboth;
string s;
int main() {
    // insert code here...
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>s;
        int y=s.size();

        for (int u=0; u<y-2; u++) {
            if (s[u]=='A'&&s[u+1]=='B') {
                answer++;
            }
        }
        if(s[0]=='B')fb++;
        if(s[y-1]=='A')la++;
        if(s[0]=='B'&&s[y-1]=='A'){abboth=true;nab++; }
    }
    answer+=min(fb,la);
    if (abboth&&1>(la-nab)&&1>(fb-nab)) {
        answer-=1;
    }
    cout<<answer<<endl;
    return 0;
}


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

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n, m, k;
        cin >> n >> m >> k;
        vector<int> a(n), b(m);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            if (i > 0) a[i] += a[i - 1];
        }
        for (int i = 0; i < m; i++) {
            cin >> b[i];
            if (i > 0) b[i] += b[i - 1];
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > k) break;
            auto it = upper_bound(b.begin(), b.end(), k - a[i]);
            int j = it - b.begin();
            ans = max(ans, i + 1 + j);
        }
        for (int i = 0; i < m; i++) {
            if (b[i] > k) break;
            auto it = upper_bound(a.begin(), a.end(), k - b[i]);
            int j = it - a.begin();
            ans = max(ans, i + 1 + j);
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 6360
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

int main(void){
	int i,j,k,x;
	bool isexp[1234];
	fill(isexp,isexp+1234,false);
	for(i=2; i<10; ++i){
		for(j=1; j<=33; ++j){
			x = 1;
			for(k=0; k<i; ++k){
				x *= j;
				if(x > 1000){
					break;
				}
			}
			if(x > 1000){
				break;
			}
			isexp[x] = true;
		}
	}
	cin >> x;
	while(!isexp[x]){
		--x;
	}
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b, t, sum;
  double time;

  scanf("%d %d %d", &a, &b, &t);
  sum=0;
  for(time=a;time<=t+0.5;time+=a){
    sum+=b;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

#include <cstdlib>  // for abs

#include <iomanip>

using namespace std;
int main()
{
  // Standard incantation to set up fast IO.
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  int cur, next;
  if (n <= 1) {
    cout << 0 << '\n';
    return 0;
  }
  int a, b, c;
  cin >> a >> b;
  cur = 0;
  next = abs(a - b);
  if (n == 2) {
    cout << next << '\n';
    return 0;
  }
  int ans;
  for (int i = 2; i < n; i++) {
    cin >> c;
    ans = min(cur + abs(c-a), next + abs(c-b));
    a = b;
    b = c;
    cur = next;
    next = ans;
  }
  cout << ans << '\n';

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n = 0;
  int d = 0;
  scanf("%d %d", &n, &d);
  // i - D 
  // 1 = i -D
  // i1 = 1 + D
  int left = 1;
  int i = left + d;
  int right = i + d;
  if( right >= n ){
    printf("1");
    return 0;
  }
    
  int cnt = 2;
  while(1){
	left = right + 1;
    i = left + d;
    right = i + d;
    //printf("%d %d %d\n", i, left , right);
    if(right < n){
      cnt++;
      continue;
    }
    else{
      break;
    }
  }
  printf("%d", cnt);
  return 0;
}

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

int main()
{
    int N, K;
    string S;
    cin >> N >> S >> K;

    vector<int> s(N);

    int safe = S[K - 1];

    for (int n = 0; n < N; n++)
    {
        s[n] = S[n];
        if (s[n] == safe)
            cout << S[n];
        else
        {
            cout << '*';
        }
    }

    return 0;
}

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

#define false 0
#define true 1

#define INFTY 2147483647


void swapInt( int *n1, int *n2) {
  
  int tmp;
  
  tmp = *n1;
  *n1 = *n2;
  *n2 = tmp;
  
}

void swapChar( char *c1, char *c2) {
  
  char tmp;
  
  tmp = *c1;
  *c1 = *c2;
  *c2 = tmp;
  
}


int partition( int *a, char *c, int p, int r) {
  
  int x;
  int i, j;
  
  x = a[r];
  i = p-1;
  
  for( j=p; j<r; j++) {
    if( a[j] <= x ) {
      i++;
      swapInt( &a[i], &a[j]);
      swapChar( &c[i], &c[j]);
    }
  }
  swapInt( &a[i+1], &a[r]);
  swapChar( &c[i+1], &c[r]);
  return i+1;
  
}


quickSort(int*  a, char* c, int p, int r) {
  
  int q;
  
  if( p < r) {
    q = partition( a, c, p, r);
    quickSort( a, c, p, q-1);
    quickSort( a, c, q+1, r);
  }
} 


void merge( int* a, char* c, int left, int mid, int right) {
  
  int *l, *r;
  char *lc, *rc;
  int n1, n2;
  
  int i, j, k;
  
  n1 = mid - left;
  n2 = right - mid;
  
  l = (int *)malloc(sizeof(int) *(n1+1));
  lc = (char *)malloc(sizeof(char) *(n1+1));
  r = (int *)malloc(sizeof(int) *(n2+1));
  rc = (char *)malloc(sizeof(char) *(n1+1));
  
  for( i=0; i<n1; i++) {
    l[i] = a[left+i];
    lc[i] = c[left+i];
  }
  for( i=0; i<n2; i++) {
    r[i] = a[mid+i];
    rc[i] = c[mid+i];
  }
  
  l[n1] = INFTY;
  r[n2] = INFTY;
  
  i=0;
  j=0;
  
  for( k=left; k<right; k++) {
    
    if( l[i] <= r[j]) {
      a[k] = l[i];
      c[k] = lc[i];
      i++;
    }
    else {
      a[k] = r[j];
      c[k] = rc[j];
      j++;
    }
    
  }
  
  free(l);
  free(r);
  free(lc);
  free(rc);
  
}


void mergeSort( int* a, char* c, int left, int right) {
  
  int mid;
  
  if( left+1 < right) {
    mid = ( left + right)/2;
    mergeSort( a, c, left, mid);
    mergeSort( a, c, mid, right);
    merge( a, c, left, mid, right);
  }

}


main() {
  
  int n;
  int* a, * ma;
  char* c, * mc;
  int isStable;
  
  int i;
  
  scanf("%d", &n);
  
  a = (int*)malloc( sizeof( int ) * n );
  c = (char*)malloc( sizeof( char ) * n );
  
  //マージソート用配列
  ma = (int*) malloc( sizeof( int ) * n );
  mc = (char*)malloc( sizeof( char ) * n );
  
  
  for( i=0; i<n; i++) {
    scanf(" %c %d", &c[i], &a[i]);
    mc[i] = c[i];
    ma[i] = a[i];
  }
  
  quickSort( a, c, 0, n-1);
  mergeSort( ma, mc, 0, n);

  
  isStable = true;
  for( i=0; i<n; i++) {
    if(c[i] != mc[i]) {
      isStable = false;
      break;
    }
  }
  
  
  if( isStable == true) {
    printf("Stable\n");
  }else {
    printf("Not stable\n");
  }
  
  
  for( i=0; i<n; i++) {
    printf("%c %d\n", c[i], a[i]);
  }
  
  return 0;
}

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

int main(){
    long long A, B, C, K;
    cin >> A >> B >> C >> K;

    if (A >= K){
        cout << K << endl;
    }
    else if (A + B >= K){
        cout << A << endl;
    }
    else if( A + B + C >= K){
        K -= (A + B);

        cout << A - K << endl;
    }
}

Measured memory_bytes: 3600
using System;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
        string[] input = System.Console.ReadLine() .Split(' ');
        int a =int.Parse(input[0]);
        int b =int.Parse(input[1]);
        if(a%3==0 || b%3==0 || (a+b)%3 ==0)
        {
            System.Console.WriteLine("Possible");
        }
        else
        {
            System.Console.WriteLine("Impossible");
        }
        
    }
}

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



int main(){
  int N,M;
  cin>>N>>M;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int a=0;
  for(int i=0;i<N;i++){
    if(vec.at(i)*4*M>=sum) a+=1;
    else break;
  }
  if(a>=M) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    
}
   

Measured memory_bytes: 3596
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

int n;
ll m;
ll a[MAX];

bool f(ll x) {
  ll count = 0;
  for (int i = 0; i < n; i++) {
    count += n - distance(a, lower_bound(a, a + n, x - a[i]));
  }
  return count < m;
}

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

  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];

  sort(a, a + n);

  ll sum[n + 1];
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i - 1];
  }

  ll low = 0, high = INF_LONG;
  while (high - low > 1) {
    ll mid = (low + high) / 2;
    if (f(mid))
      high = mid;
    else
      low = mid;
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int j = distance(a, lower_bound(a, a + n, high - a[i]));
    ans += (sum[n] - sum[j]) + a[i] * (n - j);
    m -= (n - j);
  }
  ans += m * low;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
def rotate_string(s, n):
    s = s.lower()
    result = ""
    for i in range(len(s)):
        chr_num = 97 + (((ord(s[i]) + n) - 97) % 26)
        result += chr(chr_num)
    return result.upper()


def solve():
    n = int(input())
    s = input()
    print(rotate_string(s,n))


if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define  mx 1e5

vector<int> v(100000);
vector<int> dp(100000,-1);
int n;
bool f(ll a,ll b){
return a>b;
}

int fun(int curr){
	if(curr==n-1)return 0;
	if(dp[curr]!=-1)return dp[curr];
	int left=abs(v[curr]-v[curr+1])+fun(curr+1);
	int right=mx;
	if(curr<n-2){
		right=abs(v[curr]-v[curr+2])+fun(curr+2);
	}
	return dp[curr]=min(left,right);
}

int main(){
int t=1;

while(t--){
cin>>n;
for(int i=0;i<n;i++)
cin>>v[i];
cout<<fun(0)<<endl;
}

return 0;
}


Measured memory_bytes: 8696
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ll n, x, ans;
ll f(ll x){
    int res = 0;
    while(x % 2 == 0) res++, x /= 2;
    return res;
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    ans = 1e5;
    while(n--){
        cin >> x;
        ans = min(ans, f(x));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main()
{
	int N,a,b,c,i;
	scanf("%d",&N);
	for(N;N>0;N--){
		scanf("%d %d %d",&a,&b,&c);
		if(a<b){
			i=b;
			b=a;
			a=i;
		}
		if(a<c){
			i=c;
			c=a;
			a=i;
		}
		if(a*a==b*b+c*c){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

const int INF = numeric_limits<int>::max();

void fillDP(const vector< pair<int, long int> >& skills, vector<int>& dp, long int size) {
    dp.resize(size + 1);
    fill(dp.begin(), dp.end(), INF);
    dp[0] = 0;
    for(auto itr = skills.begin(); itr != skills.end(); itr++) {
        for(long int i = 0; i <= size; i++) {
            if(dp[i] == INF) {
                continue;
            }
            long int damage = min(i + itr->second, size);
            dp[damage] = min(dp[damage], dp[i] + itr->first);
        }
    }
}

int main() {
    while(1) {
        int enemyNumber, skillNumber;
        long int maxHP;
        vector<int> allDP, singleDP;
        vector<long int> hps;
        vector< pair<int, long int> > allSkills, singleSkills;

        cin >> enemyNumber;
        if(enemyNumber == 0) {
            break;
        }
        for(int i = 0; i < enemyNumber; i++) {
            long int hp;
            cin >> hp;
            hps.push_back(hp);
        }

        cin >> skillNumber;
        for(int i = 0; i < skillNumber; i++) {
            int mp;
            long int damage;
            string name, target;
            cin >> name >> mp >> target >> damage;
            if(target == "All") {
                allSkills.push_back(make_pair(mp, damage));
            } else {
                singleSkills.push_back(make_pair(mp, damage));
            }
        }

        maxHP = *max_element(hps.begin(), hps.end());
        fillDP(allSkills, allDP, maxHP);
        fillDP(singleSkills, singleDP, maxHP);

        int minimum = INF;
        for(long int i = maxHP; i > 0; i--) {
            minimum = min(minimum, singleDP[i]);
            singleDP[i] = minimum;
        }

        long int answer = (long int) INF;

        for(long int i = 0; i <= maxHP; i++) {
            if(allDP[i] == INF) {
                continue;
            }

            long int cost = allDP[i];

            for(int j = 0; j < enemyNumber; j++) {
                if(hps[j] - i > 0) {
                    cost += singleDP[hps[j] - i];
                }
            }

            answer = min(answer, cost);
        }

        cout << answer << endl;
    }

    return 0;
}

Measured memory_bytes: 1880
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	int A[30] = {}; int B[30] = {}; int C[30] = {}; 
	for(int i = 1; i <= N; i++) cin >> A[i]; 
	for(int i = 1; i <= N; i++) cin >> B[i]; 
	for(int i = 1; i < N; i++) cin >> C[i]; 
	int ans = 0; 
	for(int i = 1; i <= N; i++) ans += B[i]; 
	for(int i = 1; i < N; i++){
		if(A[i+1] == A[i] + 1){
			ans += C[A[i]]; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = 0;
		
		while(true){
			//int count= 0;
			
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0 && W==0) break;
			
			
			//if(H%2 == 0){
				for(int i=0; i<H; i++){
					for(int j=0; j<W; j++){
						if((j+i)%2 == 0){
							System.out.print("#");
						}else {
							System.out.print(".");
						}
						
					}
					System.out.print("\n");
			
				}
				System.out.print("\n");
			
					
		}
		
	}
}

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

int main() {
	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		mp[a]++;
	}
	vector<pair<int, int>> v;
	for (auto &p : mp) {
		v.emplace_back(p);
	}
	sort(v.begin(), v.end(), [](auto &p, auto &q) {
		return p.second < q.second;
	});
	int ans = 0;
	for (int i = 0; i < int(v.size()) - k; i++) {
		ans += v[i].second;
	}
	cout << ans << endl;
	return 0;
}

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

int n, k, a[114514];

int gcd(int n, int m){ return (m==0) ? n : gcd(m, n%m);}

int main(void){
  cin >> n >> k;
  int maxi = 0;
  for(int i=0;i<n;i++){
    cin >> a[i]; maxi = max(maxi, a[i]);
  }
  bool ans;
  if (n==1){
    ans = (a[0] == k);
  }else{
    int g = gcd(a[0], a[1]);
    for(int i=2;i<n;i++) g = gcd(g, a[i]);
    ans = (maxi >= k) && ((maxi - k) % g == 0);
  }
  cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}
    
  
  

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

void solve(int n, v_int &a) 
{
    for(int x = 1; x*x<=n; x++) {
        for(int y = 1; y*y<=n; y++) {
            for(int z = 1; z*z<=n; z++) {
                int d = x*x+y*y+z*z+x*y+y*z+x*z;
                if(d > 0 && d <= n) {
                    a[d]++;
                }
            }
        }
    }
}

int main(void)
{
    int n;
    cin >> n;
    
    v_int a(n+1);
    solve(n,a);

    irep2(i,1,n) {
        cout << a[i] << endl;
    }
    
    return 0;
}
/*atcoder*/


Measured memory_bytes: 3460
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cmath>

using namespace std;

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

int n;
int ans = 0;
void dfs(int* x, int m){
    

    int res = 0;
    int a[3];
    fill(a, a + 3, 0);
    for (int i = 0; i < m; i++){
        res *= 10;
        res += x[i];
        a[x[i]/2-1]++;
    }
    bool flag = true; 
    rep(i, 3) if (a[i] == 0) flag = false;
    if(res > n) flag = false;
    if (flag) ans++;
    if (m >= 1 && pow(10, m) > n) return; 
    
    int b[m+1];
    rep(i, m) b[i] = x[i];
    b[m] = 3;
    dfs(b, m + 1);
    b[m] = 5;
    dfs(b, m + 1);
    b[m] = 7;
    dfs(b, m + 1);
}

int main(){
    cin >> n;
    int x[1];
    dfs(x, 0);
    cout << ans << endl;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var (
		N, M, sum int
	)
	fmt.Scan(&N, &M)
	a := make([]int, N+10)

	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
		sum += a[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	ok := true

	for i := 0; i < M; i++ {
		if float64(a[i]) < float64(sum) / float64(4*M) {
			ok = false
		}
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main() {
  int k;
  int a[5];
  for(int i = 0; i < 5; i++){
    cin >> a[i];
  }
  cin >> k;
  bool flg = true;
  for(int i = 0; i < 5; i++){
    for(int j = i+1; j < 5; j++){
      int temp = abs(a[i] - a[j]);
      if(temp > k) flg = false;
    }
  }
  if(flg) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
#include <string>
#include <cmath>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
    int tri[100][3];
    int cnt[4] = {0};

    while(true){
        vector<int> point(3);
        cin >> point[0] >> point[1] >> point[2];
        sort(point.begin(), point.end());
        int x = point[0];
        int y = point[1];
        int z = point[2];
        if (x+y <= z) break;
        cnt[0]++;
        if (x*x + y*y == z*z){
            cnt[1]++;
        } else if (x*x + y*y > z*z){
            cnt[2]++;
        } else {
            cnt[3]++;
        }
    }
    for (int i = 0; i < 3; i++){
        cout << cnt[i] << " ";
    }
    cout << cnt[3] << endl;
    return 0;
}



Measured memory_bytes: 3132
#include<stdio.h>
#include<string.h>
int main(){
	int count=0, i;
	char s[100], p[1000];
	scanf("%s", s);
	for(i=0; s[i] != '\0';i++){
		s[i] = tolower(s[i]);
	}
	while(1){
		scanf("%s", p);
		if(strcmp(p, "END_OF_TEXT") == 0) {break;}
		for(i=0; p[i] != '\0';i++){
			p[i] = tolower(p[i]);
		}
		if(strcmp(s, p) == 0) {count++;}
	}
	printf("%d\n", count);
}


Measured memory_bytes: 2056
import java.util.*;
import java.util.stream.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int[] mt = new int[10];
      for (int i = 0; i < 10; i++) {
        mt[i] = Integer.parseInt(br.readLine());
      }
      Arrays.stream(mt)
        .boxed()
        .sorted(Comparator.reverseOrder())
        .limit(3)
        .forEach(System.out::println);
    } catch (IOException e) {

    }
  }
}

Measured memory_bytes: 30376
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n;
    scanf("%d", &n);
    lint a[n], sum = 0, m = mod;
    rep(i, n) {
        scanf("%lld", &a[i]);
        sum += a[i];
        chmin(m, a[i]);
    }
    if (n % 2 == 1){
        puts(sum % 2 == 1 ? "First" : "Second");
    }
    else{
        puts(sum % 2 == 1 || m % 2 == 1 ? "First" : "Second");
    }
}


Measured memory_bytes: 4700
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int i, j, n, a[N], spf[N];

void sieve()
{
    for (i = 1; i < N; ++i)
        spf[i] = i;
    for (i = 2; i * i < N; ++i)
    {
        if (spf[i] == i)
        {
            for (j = i * i; j < N; j += i)
            {
                if (spf[j] == j)
                    spf[j] = i;
            }
        }
    }
}

set<int> factorize(int x)
{
    set<int> ret;
    while (x != 1)
    {
        ret.insert(spf[x]);
        x /= spf[x];
    }
    return ret;
}

void solve()
{
    sieve();
    cin >> n;
    int hcf = 0;
    map<int, int> freq;
    for (i = 1; i <= n; i++)
    {
        cin >> a[i];
        hcf = gcd(hcf, a[i]);
        set<int> s = factorize(a[i]);
        for (int factor : s)
            freq[factor]++;
    }
    if (hcf > 1)
    {
        cout << "not coprime";
        return;
    }
    for (auto it : freq)
    {
        if (it.s > 1)
        {
            cout << "setwise coprime";
            return;
        }
    }
    cout << "pairwise coprime";
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 24120
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b,c;
int32_t main(){
CODE_START;
cin >> a;
cin >> b;
cin >> c;
cout << (a+b)*c/2;
}


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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 2e5 + 5;
using namespace std;

int main() {
    IO;
    int x, n, a[105];
    bool vis[105] = {};
    cin >> x >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        vis[a[i]] = 1;

    }
    for (int i = 0; i < n; ++i) {
        if (a[i] == x) {
            int l = a[i], r = a[i];
            while (true) {
                l--, r++;
                if (l < 0 || r > 101) break;
                if (l >= 0 && !vis[l]) {
                    return cout << l, 0;
                }
                if (!vis[r]) {
                    return cout << r, 0;
                }
            }
        }
    }
    //cout << "HNA";
    cout << x;


}

Measured memory_bytes: 3652
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define all(collection) (collection).begin(), (collection).end()
#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

class NyaGadgetString
{
public:
	/**
	@brief 要素削除関数
	@note
	定数時間O(4)でinput_collection[index]を削除する(STLのeraseはO(N))。
	ただし、内部で削除する要素と末尾の要素をswapする工夫をしているため、コンテナの要素の順番は保証されない。
	**/
	static void EraceO4(string& input_string, int index)
	{
		char temp = input_string[input_string.size() - 1];
		input_string[input_string.size() - 1] = input_string[index];
		input_string[index] = temp;
		input_string.erase(input_string.size() - 1, 1);

	}
};

class Abc120c {
public:
	void static Run(void)
	{
		string s; cin >> s;

		if (s.size() == 1)
		{
			cout << 0;
			return;
		}

		int index = 0;
		int count = 0;
		while (1)
		{
			if (s[index] != s[index + 1])
			{
				count++;
				NyaGadgetString::EraceO4(s, index);
				NyaGadgetString::EraceO4(s, index+1);
				if (index != 0)
					index--;
			}
			else
			{
				index++;
			}

			if (s.size() == 0)
				break;

			if (index == s.size() - 1)
				break;
		}

		cout << count * 2;
	}
};

int main()
{
	Abc120c::Run();
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

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

		String s = sc.next();
		char[] list = new char[4];
		int cntkind = 0;
		int checkidx = 0;
		int checkflg = 0;
		list = s.toCharArray();



		for (int i = 1; i < list.length; i++) {
			if (list[0] == list[i]) {
				cntkind++;
				checkidx = i;
			}
		}

		if (cntkind == 1) {
			if (checkidx == 1) {
				if (list[2] == list[3]) {
					checkflg = 1;
				}
			} else if (checkidx == 2) {
				if (list[1] == list[3]) {
					checkflg = 1;
				}
			} else if (checkidx == 3) {
				if (list[1] == list[2]) {
					checkflg = 1;
				}
			}
		}

		if (checkflg == 0) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, i, j, k, ans;
	cin >> n;
	vector<vector<long long>> a(n, vector<long long>(n));
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) cin >> a[i][j];
	}

	bool valid = true;
	for (k = 0; k < n; k++) {
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) if (a[i][j] > a[i][k] + a[k][j]) valid = false;
		}
	}

	if (!valid) cout << "-1\n";
	else {
		ans = 0;
		for (i = 0; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				bool found = false;
				for (k = 0; k < n; k++) {
					if ((i != k) && (j != k) && (a[i][j] == a[i][k] + a[k][j])) found = true;
				}
				if (!found) ans += a[i][j];
			}
		}
		cout << ans << "\n";
	}

	return 0;
}




Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int t,n;
    for(int i=0;i<4;i++){
        cin >> t >> n;
        if(t==1)cout << n*6000 << endl;
        if(t==2)cout << n*4000 << endl;
        if(t==3)cout << n*3000 << endl;
        if(t==4)cout << n*2000 << endl;
    }
}



Measured memory_bytes: 3096
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] hArr = new int[n + 1000];
        for (int i = 0; i < n; i++) {
            hArr[i] = sc.nextInt();
        }

        int[] dp = new int[n + 1000];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= k; j++) {
                dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(hArr[i] - hArr[i + j]));
            }
        }
        //debug(dp);
        System.out.println(dp[n - 1]);
    }


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

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 50480
menu = [int(input()) for _ in range(5)]

ans = 0
x = 10

for i in range(5):
    if menu[i] % 10 == 0:
        ans += menu[i]
    else:
        x = min(x, menu[i] % 10)
        ans += (menu[i] // 10 + 1)*10

ans -= 10-x

print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = Integer.parseInt(stdin.nextLine());
        String s = stdin.nextLine();
        String t = stdin.nextLine();

        for (int i = 0; i < n; i++) {
            if (s.substring(i).equals(t.substring(0, n - i))) {
                System.out.println(i + n);
                System.exit(0);
            }
        }
        System.out.println(n * 2);
    }

}


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


int main()
{
    string S;
    cin >> S;
    int firstpair, secondpair;

    if (S.at(0) < '0' || S.at(0) > '9' ||
        S.at(1) < '0' || S.at(1) > '9' ||
        S.at(2) < '0' || S.at(2) > '9' ||
        S.at(3) < '0' || S.at(3) > '9')
    {
        cout << "NA" << endl;
        return 0;
    }

    firstpair  = ((S.at(0)-'0') * 10) + (S.at(1)-'0');
    secondpair = ((S.at(2)-'0') * 10) + (S.at(3)-'0');

    if (firstpair > 12)
    {
        if (secondpair > 12 || secondpair == 0)
        {
            cout << "NA" << endl;
            return 0;
        }
        else
        {
            cout << "YYMM" << endl;
            return 0;
        }
    }

    if (secondpair > 12)
    {
        if (firstpair > 12 || firstpair == 0)
        {
            cout << "NA" << endl;
            return 0;
        }
        else
        {
            cout << "MMYY" << endl;
            return 0;
        }
    }

    if (firstpair == 0 && secondpair == 0)
    {
        cout << "NA" << endl;
        return 0;
    }

    if (firstpair == 0 && secondpair <= 12)
    {
        cout << "YYMM" << endl;
        return 0;
    }

    if (firstpair <= 12 && secondpair == 0)
    {
        cout << "MMYY" << endl;
        return 0;
    }
    

    cout << "AMBIGUOUS" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <assert.h>
#include <map>

using std::cerr;
using std::cin;
using std::cout;
using std::pair;
using std::string;
using std::vector;
//region
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (b); i >= (b); --i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n)-1; i >= 0; --i)
#define repr1(i, n) for (int i = (n); i > 0; --i)
#define outif(b, t, f) cout << ((b) ? (t) : (f)) << endl
#define all(vec) (vec).begin(), (vec).end()
#define sz(x) (int((x).size()))
#define mset(v, n) std::memset((v), n, sizeof(v))
#define BIT(N) (1LL << (N))
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using vint = vector<int>;
using vlong = vector<ll>;
using vstr = vector<string>;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpll = vector<pll>;
using vvi = vector<vint>;
using vvl = vector<vlong>;
vector<string> split(const string &s, const string &delim) {
  vector<string> res;
  uint pos = 0;
  while (true) {
    const int found = s.find(delim, pos);
    if (found < 0) {
      res.push_back(s.substr(pos));
      break;
    }
    res.push_back(s.substr(pos, found - pos));
    pos = found + delim.size();
  }
  return res;
}
template<typename T> string join(vector<T> &vec, const string &sep) {
  size_t size = vec.size();
  if (!size) return "";
  std::stringstream ss;
  for (int i = 0; i < size - 1; i++)
    ss << vec[i] << sep;
  ss << vec[size - 1];
  return ss.str();
}
template<typename T> std::istream &operator>>(std::istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template<typename Iter> inline void print(const Iter &first, const Iter &last, const std::string &d, bool endline) {
  cout << *first;
  for (Iter iter = first + 1; iter < last; ++iter) {
    cout << d << *iter;
  }
  if (endline) cout << "\n";
}
constexpr ll powmod(ll a, ull b, ull p) {
  ll res = 1;
  while (b > 0) {
    if (b % 2) res = res * a % p;
    a = a * a % p;
    b >>= 1u;
  }
  return res;
}
template<class T> bool chmax(T &a, const T &b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, const T &b) { return a > b ? (a = b, true) : false; }
template <typename T> void bsort(vector<T>& v) { std::sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T>& v) { std::sort(v.begin(), v.end(), std::greater<T>()); }
struct iii {
    iii() {
      cin.tie(nullptr); cout.tie(nullptr);
      std::ios::sync_with_stdio(false);
      cout << std::fixed << std::setprecision(16);
    }
} init;
//endregion

void solve();

int main() {
  int t = 1;
  // scanf("%d", &t);
  rep(_,t) solve();
  return 0;
}

void solve() {
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  ll min = std::min({A, B, C, D, E});
  cout << (N + min - 1) / min + 4 << std::endl;

}


Measured memory_bytes: 256
from collections import defaultdict

N, K, L = map(int, input().split())


class UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.par = list(range(n))
        self.rank = [1] * n

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        elif self.rank[x]  < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            self.rank[x] += 1

load_uf = UnionFind(N)
rail_uf = UnionFind(N)

for k in range(K):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    load_uf.unite(p, q)

for l in range(L):
    r, s = map(int, input().split())
    r -= 1
    s -= 1
    rail_uf.unite(r, s)

ans = []
d = defaultdict(int)
for i in range(N):
    lp = load_uf.root(i)
    rp = rail_uf.root(i)
    d[lp, rp] += 1

for i in range(N):
    lp = load_uf.par[i]
    rp = rail_uf.par[i]
    if i == N-1:
        print(d[lp, rp])
    else:
        print(d[lp, rp], end=' ')

#     print(rd[rp])
#     print(ld[lp])
#     ans.append(len(ld[lp] & rd[rp]))
# print(str(ans).replace(',', '')[1:-1])


Measured memory_bytes: 56156
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL vmax(vi v, LL n) {
	int MAX = 0;
	f(i, 0, n) {
		MAX = max(MAX, v[i]);
	}
	return MAX;
}

LL vmin(vi v, LL n) {
	int MIN = LL_INF;
	f(i, 0, n) {
		MIN = min(MIN, v[i]);
	}
	return MIN;
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//エラトステネスの篩
void sieve(LL n) {
	vb s(n + 1, true);
	f(i, 2, n + 1) {
		for (int j = 2; i*j <= n; j++) {
			s[i*j] = false;
		}
	}
	cout << "2から" << n << "までの素数" << endl;
	f(i, 2, n + 1) {
		if (s[i]) {
			cout << i << " ";
		}
	}
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int n, k;
	st s;
	cin >> n >> s >> k;
	char c = s[k - 1];
	f(i, 0, n) {
		if (s[i] != c) {
			cout << '*';
		}
		else {
			cout << s[i];
		}
	}
	return 0;
}

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

long long S[1000000], D[1000000];
long long d, n, m, sum, Left, Right, Mid, a, b;

int main() {
	while (true) {
		sum = 0;
		cin >> d;
		if (d == 0) { break; }
		cin >> n >> m;
		for (int i = 0; i < n - 1; i++) {
			cin >> S[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> D[i];
		}
		sort(S, S + n);

		for (int i = 0; i < m; i++) {
			Left = 0; Right = n - 1;
			for (int j = 0; j < 50; j++) {
				Mid = (Left + Right) / 2;
				if (S[Mid] <= D[i] && S[Mid + 1]>D[i]) {
					break;
				}
				if (S[Mid] < D[i]) { Left = Mid + 1; }
				if (S[Mid] > D[i]) { Right = Mid; }
			}
			a = abs(D[i] - S[Mid%d]);
			b = abs(S[(Mid + 1) % n] - D[i]);
			if (b == D[i]) {
				b = min(b, d - b);
			}
			sum += min(a, b);
		}
		cout << sum << endl;
	}
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  
  int n, k;
  cin >> n >> k;
  if (n%k) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int n;
    int ans=INF;
    string s;
    int rw=0,lb=0;
    cin >> n>>s;
    
    rep(i,n){
        if(s[i]=='.')rw++;
    }
    
    rep(i,n){
        if(s[i]=='#'){
            ans=min(ans,lb+rw);
            lb++;
        }else{
            rw--;
            ans=min(ans,lb+rw);
        }
    }
    
    cout << ans<<endl;
    
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random

import os
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = []
    B = []
    sai = []
    sai2 = []
    for i in range(N):
        a,b = inputMap()
        A.append(a)
        B.append(b)
        sai.append(a+b)
        sai2.append((a+b, i))
        
    sai2.sort()
    sai2 = sai2[::-1]
    
    takahashi = 0
    aoki = 0
    for i,val in enumerate(sai2):
        val, no = val
        if i == 0:
            takahashi += A[no]
        else:
            if i % 2 == 1:
                aoki += B[no]
            else:
                takahashi += A[no]
            
    print(takahashi - aoki)
                
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 77528