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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

int main() {
	make2(n, L);
	makev(v, n);
	double x = 0.;
	double y = 0.;
	lint dupa = (n * 1LL * (n-1) * 1LL * (n-2))/6;
	FOR(i,0,n) FOR(j,i+1,n) {
		double lx = cos((v[i] + v[j])*(1./L)*M_PI);
		double ly = sin((v[i] + v[j])*(1./L)*M_PI);
		int ok = (i+n-1-j)-(j-i-1);
		x += ok * lx;
		y += ok * ly;
	}
	x = x*1./dupa;
	y = y*1./dupa;
	printf("%.17lf %.17lf\n", x, y);
}





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

using namespace std;
typedef long long ll;

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

    ll finish; cin >> finish;
    ll debet = 100; int year = 0;
    while (debet < finish) {
        debet += debet * 0.01;
        ++year;
    }

    cout << year;

    return 0;
}


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

using namespace std;
const int INF = 1e9 + 5;

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

	vector<int> h(n);

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

	vector<int> dp(n, INF);
	dp[0] = 0;

	for(int i = 0; i < n; i++)
	{
		for(int j = i + 1; j <= i + k; j++)
		{
			if(j < n)
			{
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}

	cout << dp[n - 1] << "\n";
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    rep (i, 5) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3576
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

map<ll, int> m;

int main()
{
	int n,ans=0;
	cin >> n;

	rep(i, n) {
		ll A;
		cin >> A;
		ans++;
		if (m[A]) {
			m[A] = 0;
			ans -= 2;
		}
		else {
			m[A] = 1;
		}
	}
	cout << ans << endl;
	return	0;
}

Measured memory_bytes: 6528
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

//<editor-fold defaultstate="collapsed" desc="Headers & Macros">
#include <bits/stdc++.h>

#pragma GCC optimize("O3")

using namespace std;

//</editor-fold>

class BPopularVote {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, m;

        in >> n >> m;

        vector<int> v(n);

        for (auto &x: v) {
            in >> x;
        }

        long long total_votes = accumulate(v.begin(), v.end(), 0L);

        int selected = 0;

        for (auto &x: v) {
            if (x >= total_votes / (4.0 * m)) {
                selected++;
            }
        }

        if (selected < m) {
            out << "No" << '\n';
        } else {
            out << "Yes" << '\n';
        }

//        in.setstate(ios_base::eofbit);
    }
};


int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    BPopularVote solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
A,B,M = list(map(int,input().split()))

a = list(map(int,input().split()))
b = list(map(int,input().split()))

mini = min(a)+ min(b)

def check(Mlist, mini):
    #print(Mlist)
    if mini > a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]:
        return a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]
    return mini
for i in range(M):
    mini = check(list(map(int,input().split())),mini)

print(mini)


Measured memory_bytes: 18684
#include <bits/stdc++.h>
    #include <string>
          #define ll int
          #define N 100000
          #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
          #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
          #define po pop_back
          #define pb push_back
          #define pp pair<ll,ll>
          #define lb lower_bound
          #define fi first
          #define se second
          #define debug(x) cout << #x << " = " << x << endl
          #define ub upper_bound
          #define ibs ios_base::sync_with_stdio(false)
          #define cti cin.tie(0)
          #define all(x) x.begin(),x.end()
          #define PI 3.14159265
          #define cot cout.tie(0)
          using namespace std;
         /**
          * @author :: Sawlani
          *
          */
          int main()
          {
              ll n;
              cin >> n;

              cout <<  n*n << endl;


          }


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  D2(x)       { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  all(x)      (x).begin(), (x).end()
#define  mem(a)      memset(a , 0 ,sizeof a)
#define  deb(x)      cout << #x << " - " << x << "\n";
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)  __builtin_popcountll(x)
#define  deb2(x,y)   cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b)  for(int i=a ; i>=b ; --i)
 
#define PI 3.141592653589793
const ll p = 5;
const ll INF = 1000000000;
const ll MAX_N = 1e5 + 2;

int main() {
    IOS;
    int n,k,num; cin >> n >> k;
    priority_queue<int>pq;
    
    rep(i,0,n) { cin >> num, pq.push(num); }
    
    while(k){
        int top = pq.top();
        pq.pop();
        top >>= 1;
        pq.push(top);
        k--;
    }
    
    ll sum = 0;
    while(!pq.empty()){
        sum += pq.top();
        pq.pop();
    }
    
    cout << sum;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  #define int long long
  int n, k;
  cin >> n >> k;
  vector<p> a(n, {0, 0});
  for(int i = 0; i < n; i++)
  {
    cin >> a[i].first >> a[i].second;
  }

  sort(all(a));

  for(auto i : a)
  {
    k -= i.second;
    if(k <= 0) {
      cout << i.first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m,ans=0;
int s[10],c[10],vis[10];
int main()
{
	cin>>n>>m;
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=m;i++)
	{
		int x;
		cin>>s[i]>>x;
		if(x==0&&s[i]==1&&n!=1){ printf("-1\n");return 0;}
		if(vis[s[i]]&&x!=c[s[i]]){ printf("-1\n");return 0;}
		  else { vis[s[i]]=1;c[s[i]]=x;}
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i])ans+=c[i]*pow(10,n-i);
		  else{
		  	if(i!=1)ans=ans;
		  	  else if(i==1&&n==1)ans=0;
		  	    else ans+=pow(10,n-i);
		  }
	}
	printf("%d\n",ans);
	return 0;
}

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

int pow(int b, int p){
  int t = b;
  for(int i = 1;i<p;i++){
    b = b * t;
  }
  return b;
}

int main(){
  int X;
  cin >> X;
  int max = 0;
  for(int i = 1; i * i <= X; i++){
    for(int j = 2;; j++){
      int ij = pow(i,j);
      if( ij > X ){
        break;
      }
      if( ij > max ){
        max = ij;
      }

      if(i == 1){
        break;
      }
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = gets.split.map &:to_i
ans = 0

(K..N+1).each do |i|
    min = (1 + i) * (i / 2) + (1 + i) / 2 * (i % 2)
    max = (N+1-i+1 + N+1) * (i / 2) + (N+1-i+1 + N+1) / 2 * (i % 2)
    ans = (ans + max - min + 1) % (10**9 + 7)
end

p ans

Measured memory_bytes: 14372
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
 
Node root;
void insert(int key){
   Node y = NIL;
   Node x = root;
   Node z;
    
   z =malloc(sizeof(struct node));
   z->key = key;
   z->left = NIL;
   z->right = NIL;
   while(x!=NIL){
     y=x;
     if(z->key < x->key)x=x->left;
     else x=x->right;
   }
   z->parent=y;
   if(y==NIL)root=z;
   else if(z->key <y->key)
   y->left=z;
   else
     y->right=z;
}
 
void inorder(Node root){
  if(root->left!=NIL)
    inorder(root->left);
  printf(" %d",root->key);
  if(root->right!=NIL)
    inorder(root->right);
}
 
void preorder(Node root){
  if(root!=NIL)
    printf(" %d",root->key);
  if(root->left!=NIL)
    preorder(root->left);
  if(root->right!=NIL)
    preorder(root->right);
}
 
int main(){
  int n, i, x;
  char com[10];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,k;
    cin >> a >> b >> k;
    int c = min(a,b);
    vector<int> ans;
    for(int i=c;i>=1;--i){
        if(a%i==0 and b%i==0){
            k--;
            if(k==0){
                cout << i << endl;
            }
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define M_PI           3.14159265358979323846  /* pi */
using namespace std;
using  ll = long long;

int main() {
    ll n;
    cin >> n;

    vector<ll>t(n + 1, 0);
    vector<ll>x(n + 1, 0);
    vector<ll>y(n + 1, 0);

    for (ll i = 1; i <= n; i++) {
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }
    ll tnow;
    ll xynow;
    bool result = true;

    for (ll i = 1; i <= n; i++) {
        tnow = (t.at(i) - t.at(i - 1));
        xynow = fabs(x.at(i) - x.at(i - 1)) + fabs(y.at(i) - (y.at(i - 1)));

        if (tnow < xynow)result = false;
        if (xynow % 2 != tnow % 2)result = false;
    }
    if (result == true)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 5632
// ARC089E.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 330;

int n, A, B, d[MAX_N][MAX_N], f[MAX_N][MAX_N];

int main()
{
    scanf("%d%d", &A, &B);
    for (int i = 1; i <= A; i++)
        for (int j = 1; j <= B; j++)
            scanf("%d", &d[i][j]);
    for (int i = 0; i <= 100; i++)
        for (int j = 0; j <= 100; j++)
            for (int p = 1; p <= A; p++)
                for (int q = 1; q <= B; q++)
                    f[i][j] = max(f[i][j], d[p][q] - i * p - j * q);
    for (int i = 1; i <= A; i++)
        for (int j = 1; j <= B; j++)
        {
            int dist = 1e9;
            for (int p = 0; p <= 100; p++)
                for (int q = 0; q <= 100; q++)
                    dist = min(dist, f[p][q] + i * p + j * q);
            if (dist != d[i][j])
                puts("Impossible"), exit(0);
        }
    puts("Possible"), puts("202 10401");
    for (int i = 1; i <= 100; i++)
        printf("%d %d X\n", i, i + 1);
    for (int i = 102; i < 202; i++)
        printf("%d %d Y\n", i, i + 1);
    for (int i = 0; i <= 100; i++)
        for (int j = 0; j <= 100; j++)
            printf("%d %d %d\n", 1 + i, 202 - j, f[i][j]);
    puts("1 202");
    return 0;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 998244353;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	int a[n];
	map<int, ll> ct;
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		++ct[a[i]];
	}
	for (auto it : ct)
	{
		ans += 1LL * it.second * (it.second - 1) / 2;
	}
	for (int i = 0; i < n; ++i)
	{
		ans -= 1LL * ct[a[i]] * (ct[a[i]] - 1) / 2;
		--ct[a[i]];
		ans += 1LL * ct[a[i]] * (ct[a[i]] - 1) / 2;
		cout << ans << ' ';
		ans -= 1LL * ct[a[i]] * (ct[a[i]] - 1) / 2;
		++ct[a[i]];
		ans += 1LL * ct[a[i]] * (ct[a[i]] - 1) / 2;
	}
}

Measured memory_bytes: 10368
#include<stdio.h>
#include<string.h>
char s[11];
int main()
{
    gets(s);
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') 
    printf("Yes\n");
    else 
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
from sys import stdin, stdout
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()

def main():
	k = int(rl())
	a, b = (int(x) for x in rll())
	for x in range(a, b+1):
		if x % k == 0:
			stdout.write("OK");stdout.write("\n")
			return
	stdout.write("NG");stdout.write("\n")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 61656
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	char sh[20];
	scanf("%s",sh);
	int l=strlen(sh);
	if(l<4)printf("No\n"); 
	else
	{
		if(sh[0]=='Y'&&sh[1]=='A'&&sh[2]=='K'&&sh[3]=='I')
		printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    a = x // 500
    b = (x % 500) // 5
    print(a  * 1000 + b * 5)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
a  = [2,
 7,
 17,
 37,
 47,
 67,
 97,
 107,
 127,
 137,
 157,
 167,
 197,
 227,
 257,
 277,
 307,
 317,
 337,
 347,
 367,
 397,
 457,
 467,
 487,
 547,
 557,
 577,
 587,
 607,
 617,
 647,
 677,
 727,
 757,
 787,
 797,
 827,
 857,
 877,
 887,
 907,
 937,
 947,
 967,
 977,
 997,
 1087,
 1097,
 1117,
 1187,
 1217,
 1237,
 1277,
 1297]
N = int(input())
print(" ".join(list(map(str,a[:N]))))

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

int n,zero = 0;

int main(){
	cin >> n;	
	long long arr[n+1];
	for(int i = 1;i <= n;i++){
		cin >> arr[i];
		if(arr[i] == 0)
			zero++;
	}
	if(zero)
		return cout << 0,0;
	
	long long product = 1;
	for(int i = 1;i <= n;i++){
		if(arr[i] > (long long)1e18 / product)
			return cout << -1,0;
		product *= arr[i];
	}
	cout << product;
				
}



Measured memory_bytes: 4460
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  int h, w;
  ios_base::sync_with_stdio(false);
  std::cin >> h >> w;
  vector<vector<char>> a(h, std::vector<char>(w, 0));

  const int INF = 10000;
  
  queue<pair<int, int>> q;
  vector<vector<int>> dist(h, vector<int>(w, INF));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
      if (a[i][j] == '#') {
        q.emplace(i, j); 
        dist[i][j] = 0;
      }
    }
  }

  auto on_board = [&](int i, int j) {
    return i >= 0 && i < h && j >= 0 && j < w;
  };

  int dx[4] = {-1, 0, 1, 0};
  int dy[4] = {0, -1, 0, 1};

  while (!q.empty()) {
    auto [x, y] = q.front();
    
    q.pop();

    for (int i = 0; i < 4; ++i) {
      int xx = x + dx[i];
      int yy = y + dy[i];
      if (on_board(xx, yy) && dist[xx][yy] > dist[x][y] + 1) {
        dist[xx][yy] = dist[x][y] + 1;
        q.emplace(xx, yy);
      }
    }
  }

  int ans = 0;
  for (auto &row : dist) {
    ans = max(ans, *max_element(row.begin(), row.end()));
  }
  cout << ans << endl;
}

Measured memory_bytes: 16244
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

def main():
    n, m = map(int, input().split())
    h = {}
    pres = [1] * n
    cities = []
    year_pres = {}
    years = []
    for i in range(m):
        p, y = map(int, input().split())
        cities.append((p, y))
        year_pres[y] = p
        years.append(y)
    years.sort()
    for year in years:
        pre = year_pres[year]
        h[year] = pres[pre - 1]
        pres[pre - 1] += 1
    for city in cities:
        a = str(city[0]).zfill(6)
        b = str(h[city[1]]).zfill(6)
        print(a + b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 41376
a=input()
l=[i for i in a]
kai=0
if len(l)%2==0:
    kai=len(l)//2
else:
    kai=len(l)//2+1
count=0
for i in range(kai):
    if l[i]!=l[len(l)-i-1]:
        count+=1
        
print(count)

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

int main(void){
	int N,K;
	cin>>N>>K;
	int **map = new int*[2*K+1];
	for(int i=0;i<2*K+1;i++){
		map[i] = new int[2*K+1];
		for(int j=0;j<2*K+1;j++)
			map[i][j]=0;
	}

	for(int i=0;i<N;i++){
		int x,y;
		char col[2];
		cin>>x>>y>>col;
		if(col[0] == 'B')
			map[(x%(2*K)+2*K)%(2*K)+1][(y%(2*K)+2*K)%(2*K)+1]++;
		else
			map[(x%(2*K)+3*K)%(2*K)+1][(y%(2*K)+2*K)%(2*K)+1]++;
	}

	for(int i=1;i<2*K;i++)
		for(int j=1;j<2*K+1;j++)
			map[i+1][j] += map[i][j];
	for(int i=1;i<2*K;i++)
		for(int j=1;j<2*K+1;j++)
			map[j][i+1] += map[j][i];
	
	int ans = 0;
	for(int i=0;i<K;i++){
		for(int j=0;j<K;j++){
			int work = 2*map[i][j]-2*map[i+K][j]+map[2*K][j]-2*map[i][j+K]+2*map[i+K][j+K]-map[2*K][j+K]+map[i][2*K]-map[i+K][2*K]+N;
			if(work < N-work)
				work = N-work;
			if(ans<work)
				ans = work;
		}
	}

	cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int N, dp[200010];
vector<int> G[200010];
ll ans[200010];

int dfs(int v, int p=-1){
	if(dp[v]) return dp[v];
	dp[v] = 1, ans[v] = 1;
	for(auto to:G[v]){
		if(to == p) continue;
		if(dfs(to, v) == 0) continue;
		dp[v] += dfs(to, v);
		ans[v] = (ans[v] + mpow(2, dfs(to, v)) - 1) % mod;
	}
	if(v != 0) ans[v] = (ans[v] + mpow(2, N-dp[v]) - 1) % mod;
	return dp[v];
}

int main(){
	cin >> N;
	rep(i, N-1){
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	dfs(0);
	ll tot = mpow(2, N-1), s = 0;
	rep(i, N) s = (s + tot - ans[i] + mod) % mod;
	cout << s*mpow(tot*2, mod-2)%mod << endl;
	return 0;
}


Measured memory_bytes: 24704
S = input()
LL = int(S[0]+S[1])
RR = int(S[2]+S[3])
# YY or MM
L = ""
if LL == 0 or LL > 12:
    L = "YY"
else:
    L = "YY or MM"

if L == "YY":
    if RR == 0 or RR > 12:
        print("NA")
    elif 1 <= RR <= 12:
        print("YYMM")
elif L == "YY or MM":
    if RR == 0 or RR > 12:
        print("MMYY")
    elif 1 <= RR <= 12:
        print("AMBIGUOUS")

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

int main() {
    string x;
    cin >> x;

    int ans=0, sc=0;
    for (int i=0; i<x.size(); i++) {
        if (x.at(i) == 'S') sc++;
        if (x.at(i) == 'T') {
            if (sc) {
                sc--;
            } else {
                ans++;
            }
        }
    }

    cout << ans+sc << endl;
}

Measured memory_bytes: 640
n=int(input())
l=list(map(int,input().split()))
k=[0]*n
k[0]=0
k[1]=abs(l[1]-l[0])
for i in range(2,n):
  k[i]=min(k[i-1]+abs(l[i]-l[i-1]),k[i-2]+abs(l[i]-l[i-2]))
print(k[n-1])

Measured memory_bytes: 13928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	private static final String RIGHT_TRIANGLE = "YES";
	private static final String NOT_RIGHT_TRIANGLE = "NO";

	/**
	 * <p>
	 * 与えられた三辺で直角三角形が作れるかを判定する。
	 * </p>
	 *
	 * @param args
	 *            利用しない。
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineCount = Integer.parseInt(br.readLine());
		for (int i = 0; i < lineCount; i++) {

			String[] input = br.readLine().split(" ");
			int[] side = { Integer.parseInt(input[0]),
					Integer.parseInt(input[1]), Integer.parseInt(input[2])};
			Arrays.sort(side);

			if (Math.pow(side[2], 2) == Math.pow(side[0], 2) + Math.pow(side[1], 2)) {
				System.out.println(RIGHT_TRIANGLE);
			} else {
				System.out.println(NOT_RIGHT_TRIANGLE);
			}
		}
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};

ll sum(ll l, ll r)
{
  return (l + r) * (r - l + 1) / 2;
}

int main()
{
  int n, k;
  cin >> n >> k;
  mint ans = 0;
  for (int i = k; i <= n + 1; ++i)
  {
    ll l = sum(0, i - 1), r = sum(n - i + 1, n);
    ans += r - l + 1;
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cmath>
#include<algorithm>
#define maxn 100002
using namespace std;
int a[maxn];
int main(){
	int n,k,ans=1e9;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(int i=1;i+k-1<=n;i++){
		ans=min(ans,a[i+k-1]-a[i]+min(abs(a[i]),abs(a[i+k-1])));
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];
            var line = new long[W + 2].Select(_ => '#').ToArray();
            WriteLine(line);
            for (var i = 0; i < H; ++i)
            {
                WriteLine($"#{ReadLine()}#");
            }
            WriteLine(line);
            Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
import { readFileSync } from 'fs'

function main(input: string) {
  const tileList = Array.from(input.trim(), Number)

  const count = tileList.filter((tile, i) => tile === i % 2).length

  console.log(Math.min(count, tileList.length - count))
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 15024
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        y = i * 10000 + j * 5000 + k * 1000
        if y == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)


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

ll gcd(ll a, ll b) { if (a < b)swap(a, b); if (!b)return a; return gcd(b, a%b); }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
int main() {
	ll a;
	while (scanf("%lld", &a), a) {
		vector<ll>v;
		for (ll i = 1; i*i <= a; i++) {
			if (a%i == 0) {
				v.push_back(i);
				if (i != a / i)v.push_back(a / i);
			}
		}
		sort(v.begin(), v.end());
		int cnt = 0;
		rep(i, v.size())for (int j = i; j < v.size(); j++) {
			if (lcm(v[i], v[j]) == a)cnt++;
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3132
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

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

  ll pt = 0, px = 0, py = 0;
  for (auto i = 0; i < N; i++) {
    ll t, x, y;
    cin >> t >> x >> y;
    ll dt = t - pt;
    ll dx = abs(px - x);
    ll dy = abs(py - y);
    if (t < (dx + dy) || (dt % 2) != ((dx + dy) % 2)) {
      cout << "No" << endl;
      return 0;
    }
    pt = t;
    px = x;
    py = y;
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,x,a[100],c[50], i;
    long long s=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i]; ///ordinea farfuriilor
    }
    for(i=1;i<=n;i++)
    {
        cin>>x; /// satisfactie B
        s=s+x;
    }

    for(i=1;i<=n-1;i++)
    {
        cin>>c[i];
    }
    for(int i=1;i<n;i++){
        if(a[i+1]-a[i]==1){
            int poz=a[i];
            s+=c[poz];
        }
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

string S, T, U;
int a,b,c;

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


    vi a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

bool is_prime(ll n){
    if(n < 2) return false;
    if(n == 2) return true;

    rep(i,2,sqrt(n)+1){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}


int main(){
    ll a,b;
    vector<ll> vec;
    cin >> a >> b;

    if(a > b) swap(a,b);

    
    
    rep(i,1,sqrt(b)+1){
        if(a % i == 0 && b % i == 0) vec.push_back(i);
        if(a % i == 0 && b % (a/i) == 0) vec.push_back(a/i);
        if(b % i == 0 && a % (b/i) == 0) vec.push_back(b/i);
    }
    
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()),vec.end());

    ll ans = 0;
    rep(i,0,vec.size()){
        if(vec[i] == 1 || is_prime(vec[i])) ans++;
    }

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

Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }

    let mut ans1 = 0;
    let s1 = s.clone();
    for (i, c) in s1.chars().enumerate() {
        if i % 2 == 0 {
            if c == '1' {
                ans1 += 1;
            }
        } else {
            if c == '0' {
                ans1 += 1;
            }
        }
    }
    let mut ans2 = 0;
    let s2 = s.clone();
    for (i, c) in s2.chars().enumerate() {
        if i % 2 == 0 {
            if c == '0' {
                ans2 += 1;
            }
        } else {
            if c == '1' {
                ans2 += 1;
            }
        }
    }

    println!("{}", std::cmp::min(ans1, ans2));
}


Measured memory_bytes: 4352
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();
        if (a < b) {
            System.out.println("a < b");
        } else if (b < a) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}
 


Measured memory_bytes: 26248
#include<stdio.h>

int main(void){
	int time, num[100], count;
	
	scanf("%d", &time);
	for(int i = 0; i < time; i++){
		scanf("%d", &num[i]);
	}
	
	for(int i = 0; i < time; i++){
		for(int j = i; j < time; j++){
			if(num[i] < num[j]){
				int tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}
		}
	}
	for(int i = 0; i < time; i++){
		if(num[i] != num[i+1]){
			count++;
		}
	}
	printf("%d\n", count);
}

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

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    vector<char> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    bool isYellowExist = false;
    for(char c : A){
        if(c == 'Y'){
            isYellowExist = true;
        }
    }

    if(isYellowExist){
        p("Four");
    }else{
        p("Three");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int n, k, x ,y, sum = 0;
	scanf("%d", &n);
	scanf("%d", &k);
	scanf("%d", &x);
	scanf("%d", &y);
	
	for (int i = 1; i <= n; i++) {
		if ( i <= k ) {
			sum += x;
		}
		else if ( i > k) {
			sum += y;
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

typedef pair<int, int> P;

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

bool comp(const P a, const P b) {
    return a.second > b.second;
}

signed main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int> > que;
    rep(n, i) {
        int a;
        cin >> a;
        que.push(a);
    }
    P act[m];
    rep(m, i) {
        cin >> act[i].first >> act[i].second;
    }
    sort(act, act + m, comp);
    int count = 0;
    int sum = 0;
    rep(m, i) {
        rep(act[i].first, j) {
            if (count >= n) break;
            int a = que.top();
            que.pop();
            a = max(a, act[i].second);
            count++;
            sum += a;
        }
    }
    while (que.size()) {
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2676
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	while(n=in()){
		int a;
		double b,c;
		int i;
		int res;
		double resbmi=100000;
		double bmi;
		for(i=0;i<n;i++){
			cin>>a>>b>>c;
			bmi=c*10000/b/b;
			if(fabs(bmi-22)<fabs(resbmi-22)){
				res=a;
				resbmi=bmi;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import math
N = int(input())

flag = False

for i in range(math.ceil(N/7)+1):
    for j in range(math.ceil(N/4)+1):
        if flag == True:
            continue
        #print(N - i * 7 - j * 4 )
        if N - i * 7 - j * 4 == 0:
            flag = True

if flag == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int k;
	string ans;
	cin >>s>>k;
	ans=s;
	rep(i,s.size()){
		if(s[i]=='a'){continue;}
		if(('z'-s[i] +1) <=k ){
			ans[i]='a';
			k -= ('z' - s[i] + 1);
		}
	}
	k%=('z'-'a'+1);
	ans[ans.size()-1]+=k;
	if(ans.back() >'z'){
		ans.back()-=('z'-'a');
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3820
#include <stdio.h>

int main(void)
{
	int map[1000];
	int move[1000];
	int n, m;
	int coor;
	int i;
	
	while (1){
		scanf("%d%d", &n, &m);
		
		if (n == 0 && m == 0){
			break;
		}
		
		for (int i = 0; i < n; i++){
			scanf("%d", &map[i]);
		}
		for (int i = 0; i < m; i++){
			scanf("%d", &move[i]);
		}
		
		i = coor = 0;
		while (coor + 1 < n){
			coor += move[i++];
			if (coor + 1 >= n) break;
			coor += map[coor];
		}
		
		printf("%d\n", i);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
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; }
const long long INF = 1LL << 60;

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

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

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

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n;
  cin>>n;
  vector<int> l,p,q;
  for(int i=1;i<=n;i++){
    l.pb(i);
  }
  rep(i,n){
    int a;cin>>a;
    p.pb(a);
  }
  rep(i,n){
    int a;cin>>a;
    q.pb(a);
  }
  int co=1;
  int a,b;
  do {
    if(l==p) a=co;
    if(l==q) b=co;
    co++;
  } while(next_permutation(all(l)));
  cout<<abs(a-b);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str, A: int, B: int, U: str):
    return (A-1, B) if S == U else (A, B-1)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    U = next(tokens)  # type: str
    print(*solve(S, T, A, B, U))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*input
99992

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

bool isPrime (ll n) {
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main()
{
  ios_base::sync_with_stdio(false); // 🏁 👀 💕
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  while (!isPrime(n)) n++;
  cout << n << endl;

  return 0;
}

Measured memory_bytes: 256
N=int(input())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
p=make_divisors(N)
ans=10**9
for i in range(len(p)):
  ans=min(max(len(str(N//p[i])),len(str(p[i]))),ans)
print(ans)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,q;
    cin>>n>>q;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll sum[n];
    ll tsum[n];
    sum[n-1]=a[n-1];
    tsum[0]=((n-1)%2==0)?a[0]:0;
    for(int i=n-2;i>=0;i--){
        sum[i]=a[i]+sum[i+1];
    }
    for(int i=1;i<n;i++){
        if((n-1-i)%2==0){
            tsum[i]=a[i]+tsum[i-1];
        }
        else{
            tsum[i]=tsum[i-1];
        }
    }
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        int ok=0,ng=n+1;
        while(ng-ok>1){
            int y=(ok+ng)/2;
            ll l=abs(a[n-y]-x);
            ll r=abs(a[n-(y+1)/2]-x);
            if(l>r)ng=y;
            else ok=y;
        }
        ll ans=sum[n-(ok+1)/2];
        if(ok!=n)ans+=tsum[n-ok-1];
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var ans = 0;
            for (var i = 0; i < N; i++) ans += A[i];

            Console.WriteLine(ans - N);
        }
    }
}

Measured memory_bytes: 13376
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

int main()
{
    int N;
    string S, T;
    cin >> N >> S >> T;
    
    //vector<string> ans(2*N);
    rep(i, N) {
        cout << S.at(i) << T.at(i);
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		String f = sc.next();
		String[] g = new String[] {"A", "B", "C", "D" , "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
		
		// 文字列の入力
		String h ="";
		for(int i = 0; i < f.length(); i++){
			for(int j = 0; j < 26; j++){
				if(f.substring(i, i + 1).equals(g[j])){
					h = h + g[((j + a) % 26)];
                  // System.out.println(j);
				}
              // System.out.println(f.substring(i, i + 1));
                
			}
              
		} 
		
		System.out.println(h);
		
		
	}
}

Measured memory_bytes: 56512
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    int N;
    cin >> N;
    ll h[100010];
    ll dp[100010];
    REP(i, N) cin >> h[i];
    REP(i, N) dp[i] = INF;
    dp[0] = 0;
    FOR(i, 1, N){
        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1) chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1792