akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>

using namespace std;
#define mp make_pair
typedef pair<int,int> PII;
typedef long long ll;

vector<PII> pairs;

bool isPositive(int num){
	return num >= 0;
}

int removeNums(vector<int> nums,int a,int b){
	if(a>=0&&b>=0){
		nums[a] = -1;
		nums[b] = -1;
		stable_partition(nums.begin(),nums.end(),isPositive);
	}
	if(nums[0] == -1) return 0;
	int min_num = 20-count(nums.begin(),nums.end(),-1);

	for(int i=0;i<pairs.size();i++){
		if(nums[pairs[i].first] != -1 && nums[pairs[i].first] == nums[pairs[i].second]){
			int r = removeNums(nums,pairs[i].first,pairs[i].second);
			if(r<min_num) min_num = r;
			if(r==0)break;
		}
	}
	return min_num;
}

void genPairs(){
	for(int i=0;i<20;i++){
		if(i%4!=3) pairs.push_back(PII(i,i+1));
	}
	for(int i=0;i<16;i++){
		pairs.push_back(PII(i,i+4));
	}
	for(int i=0;i<16;i++){
		if(i%4!=3) pairs.push_back(PII(i,i+5));
	}
	for(int i=0;i<16;i++){
		if(i%4!=0) pairs.push_back(PII(i,i+3));
	}
		
}

int main(){
  int datacase,n;
	genPairs();
	for(cin>>datacase;datacase>0;datacase--){
		vector<int> nums;
		for(int i=0;i<20;i++){
			cin>>n;
			nums.push_back(n);
		}
		cout<<removeNums(nums,-1,-1)<<endl;
	}
	
  return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Ubiquity
	var N int
	fmt.Scan(&N)

	var a, b, c int
	var ans int
	a = 1
	b = 2
	c = 1
	for i := 0; i < N; i++ {
		a = (a * 10) % (int(math.Pow10(9)) + 7)
		b = (b * 9) % (int(math.Pow10(9)) + 7)
		c = (c * 8) % (int(math.Pow10(9)) + 7)
	}
	//fmt.Println(a, b, c)
	ans = (a - b + c) % (int(math.Pow10(9)) + 7)
	if ans < 0 {
		ans += (int(math.Pow10(9)) + 7)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1796
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,p,i,cnt,x,ans=1;
  cin >> n >> p;
  if(n==1) {
    cout << p << endl;
    return 0;
  }
  for(i=2; i*i<=p; i++) {
    if(p%i==0) {
      x=p,cnt=0;
      while(x%i==0) {
        cnt++;
        x/=i;
      }
      if(cnt>=n) {
        ans=i;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
#!/usr/bin/env python3

"""
Python の queue モジュールは遅いので使わない
deque を使おう
"""

from collections import deque

h, w = map(int, input().split())
a = [ list(input()) for _ in range(h) ]

# direction vector
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]

# 訪れたかどうかの情報を持つ bool 値
is_visited = [ [False] * w for _ in range(h) ]

q = deque()

for x in range(w):
    for y in range(h):
        if a[y][x] == "#":
            q.append( (x, y, 0) )
            is_visited[y][x] = True

ans = 0

while q:
    # queue の先頭を取り出す
    x, y, dist = q.popleft()
    ans = max(ans, dist)
    # 4方向にループ
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]

        if nx < 0 or w <= nx or ny < 0 or h <= ny:
            continue

        if is_visited[ny][nx]:
            continue

        q.append( (nx, ny, dist+1) )
        is_visited[ny][nx] = True

print(ans)

Measured memory_bytes: 169052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}
	public void run() {
		Scanner sc = new Scanner(System.in);
		long n= sc.nextInt();
		long sum1=0;
		long sum2=0;
		long ans1=0;
		long ans2=0;
		for(long i=0; i<n; i++) {
			long a = sc.nextLong();
			sum1 += a;
			sum2 += a;
			if(i%2==0) {
				if(sum1 <= 0) {
					ans1 += (1-sum1);
					sum1=1;
				}
				if(sum2 >= 0) {
					ans2 += sum2+1;
					sum2=-1;
				}
			}else {
				if(sum1 >= 0) {
					ans1 += sum1+1;
					sum1 = -1;
				}
				if(sum2 <= 0) {
					ans2 += (1-sum2);
					sum2 = 1;
				}
			}
		}
		System.out.println(Math.min(ans1, ans2));
		sc.close();
	}

}




Measured memory_bytes: 48568
#!/usr/bin/env python

import sys

N, M = [int(x) for x in sys.stdin.readline().strip().split()]
votes = [int(x) for x in sys.stdin.readline().strip().split()]

thres = sum(votes) / (4.0 * M)
cnt = 0
for v in votes:
    if v >= thres:
        cnt += 1

if cnt >= M:
    print("Yes")
else:
    print("No")



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

long long gcd(long long a, long long b);

int main(){
    long long w, h, c;
    cin >> w >> h >> c;

    long long ky = gcd(w, h);
    long long ans1 = w / ky;
    long long ans2 = h / ky;
    long long ans = ans1 * ans2;
    cout << ans * c << '\n';
        return 0;
}

long long gcd(long long a, long long b){
    while(b != 0){
        long long r = a % b;
        a = b;
        b = r;
    }
    return a;
}


Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
#include<iomanip>
#include<algorithm>
#include<map>
#include<math.h>
#include<string.h>
#define ll long long
#define eb emplace_back
#define pb push_back
#define ins insert 
#define mp make_pair
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define M 1e9+7
#define inf 1000000000000000000
using namespace std;
void add(int& a,int b){
    a+=b;
    if(a>=M)
        a-=M;
}
void sub(int& a,int b){
    a-=b;
    if(a<0)
        a+=M;
}
void solve(){
    ll n , k;
    cin>>n>>k;
    vector<int> dp(k+1,0);
    dp[0]=1;
    for (int i = 0; i < n; ++i)
    {
        ll maxVal;
        cin>>maxVal;
        vector<int> store(k+1);
        for (int usedTillNow = k; usedTillNow>=0;--usedTillNow)
        {
            int upperLimit=usedTillNow+min(k-usedTillNow,maxVal);
            int lowerLimit=usedTillNow+1;
            int temp=dp[usedTillNow];
            if(lowerLimit<=upperLimit)
                add(store[lowerLimit],temp);
            if(upperLimit<=k-1)
                sub(store[upperLimit+1],temp);
        }
        int prefix=0;
        for (int j = 0; j<=k; ++j)
        {
            add(prefix,store[j]);
            add(dp[j],prefix);
        }
    }
    cout<<dp[k]<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1,t1=1;
    //cin>>t;
    while(t--){
        //cout<<"Case #"<<t1++<<": ";        
        solve();
    }
    return 0 ;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func main() {
	var s string
	fmt.Scan(&s)

	rCnt := 0
	lCnt := 0
	before := 'R'
	answer := make([]int, len(s))

	for i := 0; i < len(s); i++ {
		if s[i] == 'R' {
			rCnt++
			before = 'R'
		} else {
			lCnt++
			before = 'L'
		}

		if i != len(s) - 1 {
			if before == 'L' && s[i + 1] == 'R' {
				rIndex := i - lCnt
				lIndex := i - (lCnt - 1)

				answer[rIndex] = (rCnt + lCnt) / 2
				answer[lIndex] = (rCnt + lCnt) / 2

				if (rCnt + lCnt) % 2 != 0 {
					if rCnt % 2 == 0 {
						answer[lIndex] += 1
					} else {
						answer[rIndex] += 1
					}
				}

				rCnt = 0
				lCnt = 0
			}
		} else {
			rIndex := i - lCnt
			lIndex := i - (lCnt - 1)

			answer[rIndex] = (rCnt + lCnt) / 2
			answer[lIndex] = (rCnt + lCnt) / 2

			if (rCnt + lCnt) % 2 != 0 {
				if rCnt % 2 == 0 {
					answer[lIndex] += 1
				} else {
					answer[rIndex] += 1
				}
			}

			rCnt = 0
			lCnt = 0
		}
	}

	for i, num := range answer {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(num)
	}

	fmt.Println("")
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


Measured memory_bytes: 4736
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=65;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int f[1<<18][55];
PR a[MAXN];
int main()
{
	int n=read();
	for (int i=1;i<=n;i++) a[i].fi=read();
	for (int i=1;i<=n;i++) a[i].se=read();
	for (int i=0;i<1<<n;i++)
		for (int j=0;j<=50;j++) f[i][j]=INF; 
	f[0][1]=0;
	for (int i=1;i<1<<n;i++)
	{
		int t=__builtin_popcount(i);
		for (int p=1;p<=n;p++)
		if ((i>>(p-1))&1)
		{
			int j=(abs(t-p)&1)?a[p].se:a[p].fi,num=0;
			for (int k=p+1;k<=n;k++) if ((i>>(k-1))&1) num++;  
			for (int k=1;k<=j;k++) upmin(f[i][j],f[i^(1<<(p-1))][k]+num);
		}
	}
	int ans=INF;
	for (int i=1;i<=50;i++) upmin(ans,f[(1<<n)-1][i]);
	printf("%d\n",ans==INF?-1:ans);
	return 0;
}


Measured memory_bytes: 56704
#include<iostream>
#include<algorithm>
#include<iterator>
using namespace std;

int main(){
    long N;
    cin >> N;
    long A[N],B[N],C[N];
    long long ans;
    long *ibp, *icp;
    int ib[N], ic[N]; 
    long icsum[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        cin >> B[i];
    }
    for(int i=0; i<N; i++){
        cin >> C[i];
    }

    sort(A,A+N);
    sort(B,B+N);
    sort(C,C+N);

    ans=0;
    for(int i=0; i<N; i++){
        ibp=upper_bound(B,B+N,A[i]);
        ib[i]= distance(B,ibp);
    }
    for(int i=0; i<N; i++){
        icp=upper_bound(C,C+N,B[i]);
        ic[i]= distance(C,icp);
    }

    for(int i=N-1; i>=0; i--){
        if( i==N-1 ){
            icsum[i]=(long) ic[i];
        }else{
            icsum[i]=icsum[i+1]+ (long) ic[i];
        }
    }

    ans=0;
    for(int i=0; i<N; i++){
        if(ic[ib[i]]<N){
            ans +=  (long long) N*(N-ib[i])-icsum[ib[i]];
            //cout << "i ib ic " << i << " " << ib[i] << " " << ic[ib[i]] << endl;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  int h, w; cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  int cnt = 0;
  rep(i, h) rep(j, w) {
    if (s[i][j] == '.') cnt++;
  }

  vector<vector<int>> a(h, vector<int>(w, -1));
  a[0][0] = 0;
  queue<P> q;
  q.push(P{0, 0});
  while (!q.empty()) {
    P p = q.front(); q.pop();
    int nx, ny;
    nx = p.second;
    ny = p.first;

    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, 1, -1};
    for (int i=0; i<4; i++) {
      int tx = nx + dx[i];
      int ty = ny + dy[i];
      if (0 <= tx && tx < w && 0 <= ty && ty < h) {
        if (s[ty][tx] == '.' && a[ty][tx] == -1) {
          a[ty][tx] = a[ny][nx] + 1;
          q.push(P{ty, tx});
        }
      }
    }
  }
  if (a[h-1][w-1] == -1) cout << -1 << endl;
  else cout << cnt - a[h-1][w-1] - 1 << endl;

  return 0;
}


Measured memory_bytes: 256
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define po pop()
#define pu push
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
string en="\n";
string sp=" ";
string t="hello";
string Y="valid\n";
string N="invalid\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL ceil2(LL a,LL b){LL c=a/b; if(a%b)c++; return c; }
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;string st,s1,s2,s3; char ch;
    while(cin>>n)
    {
        f=1;
        for(i=1;i<=9;i++)
        {
            if(n%i==0)
            {
                if(n/i<10)
                {
                    f=0;
                    break;
                }
            }
        }
        if(f)cout<<"No"<<en;
        else cout<<"Yes"<<en;
    }
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-9;
const long long INF = OO;
const int MAXN = 206, MAXM = 102, Mod = 998244353, MAXLog = 20;


int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout
            << fixed;

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    vector<int> c(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        cin >> c[i];
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += b[a[i] - 1];
        if (i > 0 && a[i] == a[i - 1] + 1) {
            ans += c[a[i - 1] - 1];
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
cnt = [[float('inf')]*w for _ in range(h)]
moves = ((0, 1), (0, -1), (1, 0), (-1, 0))
q = deque([])
for i in range(h):
  for j in range(w):
    if a[i][j] == '#':
      cnt[i][j] = 0 

def bfs():
  while q:
    y, x = q.popleft()
    for dy, dx in moves:
      ny = y + dy
      nx = x + dx 
      if 0 <= ny < h and 0 <= nx < w and a[ny][nx] == '.' and used[ny][nx] == 0:
        used[ny][nx] = 1
        cnt[ny][nx] = min(cnt[ny][nx], cnt[y][x]+1)
        q.append([ny, nx])

used = [[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if a[i][j] == '#':
      used[i][j] = 1
      q.append([i, j])

bfs()

ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, cnt[i][j])
print(ans)

Measured memory_bytes: 180188
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a[100],n,k,ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		ans=ans+min(a[i],abs(k-a[i]));
		
	}
	
	cout<<ans*2<<endl;
	
}

Measured memory_bytes: 256
#pragma GCC diagnostic ignored "-Wunknown-pragmas" 
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
    
#pragma endregion library

int main(){
    // vscode-fold=1
    string s; cin >> s;
    bool flag = false;
    rep(i,3) if (s[i]=='7') flag = true;
    if(flag) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    
}

Measured memory_bytes: 3644
#include<iostream>

using namespace std;

int main(){
	int N,A,B;
        int ans=0;
	cin>>N>>A>>B;
	for(int i=1;i<=N;i++){
		int c=0,n=i;
		for(int j=0;j<5;j++){
			c=c+n%10;
			n=n/10;
		}
		if(A<=c&&c<=B)ans=ans+i;
	}
	cout<<ans;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>

using namespace std;

enum dir_t {NORTH, EAST, WEST, SOUTH, CLKW, CCLKW};
enum face_t {TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT};

face_t& operator++ (face_t& f) {
    f = static_cast<face_t>(f + 1);
    return f;
}

class Dice {
public:
    Dice(int32_t top, int32_t bottom, int32_t front, int32_t back, int32_t left, int32_t right) {
        val[TOP]    = top;
        val[BOTTOM] = bottom;
        val[FRONT]  = front;
        val[BACK]   = back;
        val[LEFT]   = left;
        val[RIGHT]  = right;
    }

    int32_t operator[](face_t f) {
        return val[f];
    }

    face_t operator[](int32_t v) {
        for (face_t f = TOP; f <= RIGHT; ++f) {
            if (v == val[f]) {
                return f;
            }
        }
        return TOP;
    }

    void roll(dir_t dir) {
        switch (dir) {
            case NORTH: inner_roll(TOP, FRONT, BOTTOM, BACK); break;
            case EAST:  inner_roll(TOP, LEFT, BOTTOM, RIGHT); break;
            case WEST:  inner_roll(TOP, RIGHT, BOTTOM, LEFT); break;
            case SOUTH: inner_roll(TOP, BACK, BOTTOM, FRONT); break;
            case CLKW:  inner_roll(FRONT, RIGHT, BACK, LEFT); break;
            case CCLKW: inner_roll(FRONT, LEFT, BACK, RIGHT); break;
        }
    }

private:
    array<int32_t, 6> val;

    void inner_roll(face_t f1, face_t f2, face_t f3, face_t f4) {
        int32_t temp;
        temp = val[f1];
        val[f1] = val[f2];
        val[f2] = val[f3];
        val[f3] = val[f4];
        val[f4] = temp;

        return;
    }
};

int main() {
    int32_t top, bottom, front, back, left, right, q;

    cin >> top >> front >> right >> left >> back >> bottom >> q;

    Dice d(top, bottom, front, back, left, right);

    while (q--) {
        cin >> top >> front;

        switch (d[top]) {
            case BOTTOM: d.roll(NORTH); d.roll(NORTH); break;
            case FRONT:  d.roll(NORTH);                break;
            case BACK:   d.roll(SOUTH);                break;
            case LEFT:   d.roll(EAST);                 break;
            case RIGHT:  d.roll(WEST);                 break;
            default:                                   break;
        }

        switch (d[front]) {
            case BACK:  d.roll(CLKW); d.roll(CLKW); break;
            case LEFT:  d.roll(CCLKW);              break;
            case RIGHT: d.roll(CLKW);               break;
            default:                                break;
        }

        cout << d[RIGHT] << endl;
    }

    return 0;
}

Measured memory_bytes: 3068
N = str(input())

if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9":
    print("hon")
elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
    print("pon")
elif N[-1] == "3":
    print("bon")


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
long dp[200007]={},sumdp[200007]={},mod = 998244353;
int main(){
    int n,k;
    cin >> n >> k;
    dp[0] = 1;
    sumdp[0] = 0;
    sumdp[1] = 1;
    int l[k],r[k];
    rep(i,k) cin >> l[i] >> r[i];
    for(int i=1;i<n;i++){
        rep(j,k){
            int x = i-l[j],y = max(i-r[j],0);
            if(x<y) continue;
            long k = sumdp[x+1]-sumdp[y];
            if(k<0) k += mod;
            dp[i] += k;
            dp[i] %= mod;
        }
        sumdp[i+1] = sumdp[i] + dp[i];
        sumdp[i+1] %= mod;
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 6756
n = int(input())

buf = [0]*n

def solv(idx,char):
    aida = n - idx
    if idx == n:
        print("".join(buf))
        return

    for i in range(char + 1):
        buf[idx] = chr(ord('a') + i)
        solv(idx+1,max(i + 1,char))

solv(0,0)

Measured memory_bytes: 57816
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#include <fstream>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
#define INF 4e18
using namespace std;
 
typedef tree<ll, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    /*ll t,tcitr;
    cin>>t;
    tcitr=0;
    while(tcitr<t)
    {*/
        string s;
        cin>>s;
        if(s[s.length()-1]=='s')s+="es";
        else s+='s';
        cout<<s<<"\n";
        /*tcitr++;
    }*/
    return 0;
}

Measured memory_bytes: 3648
def gcd(a,b):
    a,b = sorted([a,b])
    if a==1:
        return 1
    c = b%a
    if c==0:
        return a
    return gcd(c,a)

def yakusu(n):
    return [
        a
        for a
        in range(1,n+1)
        if n%a==0
    ]

def main():
    input()
    ns = [int(a) for a in input().split()]
    a = ns[0]
    b = ns[1]
    g = gcd(a,b)
    if len(ns)==3:
        g = gcd(g,ns[2])

    for a in yakusu(g):
        print(a)




if __name__ == '__main__':
    main()



Measured memory_bytes: 5604
N,M,X=map(int,input().split())
A=[]
C=[]
PriceLev=[[0,1] for i in range(2**N)]
EXP=[[0]*M for i in range(2**N)]
for i in range(N):
    A.append(list(map(int,input().split())))
    C.append(A[i].pop(0))

for pat in range(2**N):
    binstr=format(pat,'0'+str(N)+'b')
    for book in range(N):
        if binstr[book] == '1':
            PriceLev[pat][0] += C[book]
            for sub in range(M):
                EXP[pat][sub] += A[book][sub]

    for sub in range(M):
        if EXP[pat][sub] < X:
            PriceLev[pat][1] *= 0

PriceLev.sort(reverse=True, key=lambda x:(x[1],-x[0]))
if PriceLev[0][1]:
    print(PriceLev[0][0])
else:
    print(-1)

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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pb emplace_back

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, x;
    cin >> n >> x;
    int ans = n;
    int a = x;
    int b = n - x;
    while (a != 0)
    {
        int k = b / a;
        ans += a * k * 2;
        int c = a;
        a = b % a;
        b = c;
    }
    ans -= b;
    cout << ans;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val a= readLine()!!.split(" ").map{it.toLong()}
    var x=a[0]
    var y=a.sum()-a[0]
    var diff=Math.abs( x-y )
    for(i in 1..n-2){
        x+=a[i]
        y-=a[i]
        diff=Math.min(diff, Math.abs(x-y))
    }
    println(diff)
}

Measured memory_bytes: 82860
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

N, K = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))

s = list(itertools.accumulate(a))

# print(s)
for i in range(0, N+1):
    s[i] = (s[i] - i) % K

# print(s)

d = defaultdict(int)

count = 0
for j in range(1,N+1):
    d[s[j-1]] += 1
    if j-K >= 0:
        d[s[j-K]] -= 1
    # print(j,s[j],d)
    count += d[s[j]]

# print(d)
print(count)




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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int count = n;
  rep(i,n-1){
    if(s[i]==s[i+1]) count --;
  }
  cout << count << endl;
}


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

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

  ll n, q;
  cin >> n;

  vector<char> v;
  vector<char> vc = {
    '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'
  };

  while (n > 0)
  {
    q = (n-1) % 26;
    n = (n-1) / 26;
    v.push_back(vc.at(q));
  }
  reverse(v.begin(), v.end());

  for (int i = 0; i < v.size(); i++)
  {
    cout << v.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3636
a=input().split(" ")
b=[x,k,d]= [int(a[0]),int(a[1]),int(a[2])]  
ans = 0
if x - k*d > 0:
  ans = x - k*d
elif x + k*d < 0:
  ans = - k*d -x
else:
  if k%2==0:
    ans= x%(2*d)
    if d<x%(2*d):
      ans= 2*d-x%(2*d)
  elif k%2==1:
    ans= (x+d)%(2*d)
    if d<(x+d)%(2*d):
      ans= 2*d-(x+d)%(2*d)
print(ans)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string KUROE;
  int YUNI;
  double PKRN;
  cin >> YUNI;
  
  PKRN = 2 * YUNI * 3.141592;
  
  cout << PKRN << endl;
  
}

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

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

    int foundA = 0;
    int mini = 0;
    int maxi = 0;
    int length = s.length();
    for (int i = 0; i < length; i++)
    {
        if (s[i] == 'A' && foundA == 0)
        {
            mini = i;
            foundA = 1;
        }
        if (s[i] == 'Z')
        {
            maxi = i;
        }
    }
    cout << maxi - mini + 1;
    return 0;
}


Measured memory_bytes: 640
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll x,now=100,ans=0;
  cin >> x;
  while(now<x) {
    ans++;
    now*=1.01;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        String t = scan.next();
        int a = scan.nextInt();
        int b = scan.nextInt();
        String u = scan.next();

        if (u.equals(s)) {
            a -= 1;
        } else if (u.equals(t)) {
            b -= 1;
        }
        System.out.println(a+" "+b);

    }
}

Measured memory_bytes: 24020
import numpy as np

N, W = map(int, input().split())
WV = np.array([input().split() for _ in range(N)], np.int64)
V = sum(WV[:,1])
dp = np.zeros(V + 1, np.int64)
dp += 10 ** 10
dp[0] = 0
for w, v in WV:
    dp[v:] = np.minimum(dp[v:], dp[:-v] + w)
for v in range(V + 1):
    if dp[v] <= W:
        ans = v
print(ans)

Measured memory_bytes: 14788
using System;


namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            string A = Console.ReadLine();
            int a = int.Parse(A);
            for (int b = 1; b <= a; b++)
            {
                var B = Console.ReadLine().Split(' ');
                int x = int.Parse(B[0]);
                int y = int.Parse(B[1]);
                int z = int.Parse(B[2]);
                if (x*x == y*y + z*z) {
                    Console.WriteLine("YES");
                }
                else if (y*y == x*x + z*z) {
                    Console.WriteLine("YES");
                }
                else if (z*z == x*x + y*y) {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 8792
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset> 
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
// RAJJI KI MEHER 
#define fio ios_base::sync_with_stdio(false)
//#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll int
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%lld",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 100000000000000005
#define MINN -10000000000000000
#define INTMAX 1000001000
#define pii pair<li,li>
#define pdd pair<double,double>
#define pic pair<int,char>
//#define N 5005
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
using namespace std;
li bit[200005]={0};
li query(li i,li n){li ans=0;while(i>0){
    ans=max(ans,bit[i]);i=i-(i&(-i));}return(ans);}
void update(li i,li v,li n){while(i<=n){bit[i]=max(bit[i],v);i=i+(i&(-i));}}    
int main(){
    li n,i,j,t,x,ans=0;readl(n);
li h[n];li b[n];for(i=0;i<n;i++) readl(h[i]);
for(i=0;i<n;i++) readl(b[i]);
for(i=0;i<n;i++){x=query(h[i]-1,n);ans=max(ans,x+b[i]);
update(h[i],x+b[i],n);}
cout<<ans;    
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{

	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int n;cin>>n;
	v a(n),b(n),c(n-1);in(a,n);in(b,n);in(c,n-1);
	int ans=0;
	f(i,n)
	{
		if(i!=0 && a[i]==a[i-1]+1)
			ans+=c[a[i-1]-1];
		ans+=b[a[i]-1];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#define N 10000
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dik(void);

int G[N][N], n;

int main()
{
  int i, j, u, k, v, g, dis; 

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&g);
      G[u][v]=g;
    }
  }

  dik();

  return 0;
}

void dik()
{
  int i, j, color[n], mg[n], p[n], mc, place, to;

  for(i=0;i<n;i++){
    color[i]=WHITE;
    mg[i]=INT_MAX;
  }
  mg[0]=0;
  p[0]=-1;

  while(1){
    mc=INT_MAX;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && mg[i]<mc){
        mc=mg[i];
        place=i;
      }
    }

    if(mc==INT_MAX) break;

    color[place]=BLACK;
 
    for(to=0;to<n;to++){
      if(color[to]!=BLACK && G[place][to]!=0){
        if(mg[place]+G[place][to]<mg[to]){
          mg[to]=mg[place]+G[place][to];
          p[to]=place;
          color[to]=GRAY;
        }
      }
    }
  }

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



Measured memory_bytes: 2164
#include <stdio.h>


#define	ll_int	long long int


int main()
{
	ll_int a, b, c;
	ll_int min, max;

	scanf("%lld %lld %lld", &a, &b, &c);

	min = max = a;

	if(min > b)
		min = b;
	if(min > c)
		min = c;

	if(max < b)
		max = b;
	if(max < c)
		max = c;

	printf("%lld %lld\n", min, max);

	return 0;
}


Measured memory_bytes: 2112
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

int main()
{
    // input
    int K;
    int A, B;
    scanf( "%d", &K );
    scanf( "%d %d", &A, &B );

    // process

    // output
    if ( ( B / K ) - ( A / K ) > 0 or A % K == 0 or B % K == 0 ) {
        printf( "OK\n" );
    } else {
        printf( "NG\n" );
    }

    return 0;
}


Measured memory_bytes: 1624
from heapq import *
import sys
from collections import *

from itertools import *
from decimal import *
import copy
from bisect import *
import time

import math

def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()
S=input()
N=len(S)
for i in range(N//2):
    if S[i]!=S[-1-i]:
        print("No")
        exit()
for i in range(0,(N-1)//2):
    if S[i]!=S[(N-1)//2-1-i]:
        print("No")
        exit()

for i in range(0,(N-1)//2):
    if S[i+(N+2)//2]!=S[(N-1)//2-1-i+(N+2)//2]:
        print("No")
        exit()
print("Yes")


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

int main(){
    int n, S[10000];
    int q, T[500];
    int sw=0;
    
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> S[i];
    }
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> T[i];
    }
    
    for(int i=0; i<q; i++){
        for(int j=0; j<n; j++){
            if(T[i]==S[j]){
                sw++;
                break;
            }
        }
    }
    
    cout << sw << endl;
    
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	map<int,int> a;
	ll res = 0;
	for (int i = N-1; i >= 0; -- i) {
		if (a.count(A[i]+i)) res += a[A[i]+i];
		++ a[i-A[i]];
	}
	cout << res << endl;
}


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

void reverse(char* p, int len)
{
    int i;

    for (i = 0; i < len / 2; i++){
        char tmp = p[i];
        p[i] = p[len - i];
        p[len - i] = tmp;
    }
}

int main(void)
{
    int n;

    scanf("%d", &n);
    while (n--){
        char a[128] = {0};
        char b[128] = {0};
        int i;

        scanf("%s", a);
        scanf("%s", b);
        reverse(a, strlen(a) - 1);
        reverse(b, strlen(b) - 1);
        if (strlen(b) < strlen(a)){
            char t[128];

            strcpy(t, a);
            strcpy(a, b);
            strcpy(b, t);
        }

        for (i = 0; i < strlen(b); i++){
            if (i < strlen(a)) b[i] += a[i] - '0';
            if (b[i] - '0' > 9){
                b[i] -= 10;
                b[i + 1]++;
                if (b[i + 1] == 1) b[i + 1] += '0';
            }
        }
        if (strlen(b) > 80) puts("overflow");
        else {
            for (i = strlen(b) - 1; i >= 0; i--) putchar(b[i]);
            puts("");
        }
    }

    return 0;
}

Measured memory_bytes: 592
/*
 AtCoder XXX 000
 */
 
#include <stdio.h>

int main(void){
  int a,b;
  int d5,d4,d3,d2,d1;
  int cnt;
  
  scanf("%d %d",&a,&b);
  for(cnt=0; a<=b; a++){
    d1 = a%10;
    d2 = ( (a-d1)%100 ) / 10;
    d3 = ( (a-d1-10*d2) % 1000 ) / 100;
    d4 = ( (a-d1-10*d2-100*d3 ) % 10000 ) / 1000;
    d5 = (  a-d1-10*d2-100*d3-1000*d4 ) / 10000;
    
    
    if( a == (10000*d1+1000*d2+100*d3+10*d4+d5) ) cnt++;
  }
  
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int h,x,i,j;
    
    while(1){
        scanf("%d" "%d",&h,&x);
        if(h==0&&x==0){
            break;
        }else{
            for(i=0;i<h;i++){
                for(j=0;j<x;j++){
                    if((i+j)%2==0){
                        putchar('#');
                    }else{
                        putchar('.');
                    }
                }
                putchar('\n');
            }
        }
        putchar('\n');
    }
}


Measured memory_bytes: 2044
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
dp = [False] * (k + 1)
for i in range(1, k + 1):
    ok = False
    for j in a:
        if i - j >= 0:
            ok = ok or (not dp[i - j])
    dp[i] = ok

if dp[-1]:
    print("First")
else:
    print("Second")


Measured memory_bytes: 41964
from collections import deque

N,X,Y= map(int,input().split())

root = [[] for i in range(N)]
for i in range(N-1):
    root[i].append(i+1)
    root[i+1].append(i)

root[X-1].append(Y-1)
root[Y-1].append(X-1)

ans = [0]*(N-1)

for i in range(N):
    stack=deque([i])
    check = [-1]*N
    check[i] = 0

    while len(stack)>0:
        v = stack.popleft()
        for i in root[v]:
            if check[i] == -1:
                check[i]=check[v]+1
                stack.append(i)
    #print(check)
    for ch in check:
        if ch > 0:
            ans[ch-1] += 1

for aa in ans:
    print(aa//2)


Measured memory_bytes: 76800
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
long long P = 998244353;
set<string> ss;

long long po(long long e, long long x) {
  if (x == 0)
    return 1;
  if (x == 1)
    return e;
  if (x % 2 == 0)
    return po((e * e) % P, x / 2);
  return (e * po(e, x - 1)) % P;
}

int dfs(string &s) {
  if (ss.find(s) != ss.end())
    return 0;
  ss.insert(s);
  long long ret = 1;
  for (int i = 0; i < 2; i++) {
    set<char> c;
    c.insert('a');
    c.insert('b');
    c.insert('c');
    c.erase(s[i]);
    c.erase(s[i + 1]);
    if (c.size() == 1) {
      string t = s;
      t[i] = *c.begin();
      t[i + 1] = *c.begin();
      ret += dfs(t);
    }
  }
  return ret;
}

int main() {
  string s;
  cin >> s;
  bool same = true;
  int n = s.size();
  for (int i = 1; i < n; i++)
    if (s[0] != s[i])
      same = false;
  if (same) {
    cout << 1 << endl;
    return 0;
  }
  if (s.size() == 2) {
    cout << 2 << endl;
    return 0;
  } else if (s.size() == 3) {
    cout << dfs(s) % P << endl;
    return 0;
  }
  bool cont = false;
  for (int i = 1; i < n; i++)
    if (s[i - 1] == s[i])
      cont = true;
  vector<vector<vector<vector<long long>>>> dp(200020);

  for (int i = 0; i <= n; i++) {
    dp[i].resize(2);
    for (int j = 0; j < 2; j++) {
      dp[i][j].resize(3);
      for (int k = 0; k < 3; k++) {
        dp[i][j][k].resize(3);
      }
    }
  }
  dp[1][0][0][0] = 1;
  dp[1][0][1][1] = 1;
  dp[1][0][2][2] = 1;
  for (int i = 1; i < n; i++) {
    for (int mod = 0; mod < 3; mod++) {
      for (int last = 0; last < 3; last++) {
        for (int c = 0; c < 3; c++) {
          if (last != c) {
            dp[i + 1][0][(mod + c) % 3][c] =
                (dp[i + 1][0][(mod + c) % 3][c] + dp[i][0][mod][last]) % P;
          } else {
            dp[i + 1][1][(mod + c) % 3][c] =
                (dp[i + 1][1][(mod + c) % 3][c] + dp[i][0][mod][last]) % P;
          }
          dp[i + 1][1][(mod + c) % 3][c] =
              (dp[i + 1][1][(mod + c) % 3][c] + dp[i][1][mod][last]) % P;
        }
      }
    }
  }
  int mod = 0;
  for (int i = 0; i < n; i++)
    mod = (mod + s[i] - 'a') % 3;
  if (cont) {
    cout << (dp[n][1][mod][0] + dp[n][1][mod][1] + dp[n][1][mod][2]) % P
         << endl;
  } else {
    cout << (dp[n][1][mod][0] + dp[n][1][mod][1] + dp[n][1][mod][2] + 1) % P
         << endl;
  }

  return 0;
}


Measured memory_bytes: 86404
// oh, the less I know the better
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define endl '\n'
#define fst first
#define snd second
#define pb push_back
#define sz(x) int(x.size())
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = (1 << 20);

int bit;
int a[N];
ii trash = {-1,-1};
pair<ii,ii> dp[N]; // {value, index}

void show(pair<ii,ii> x){
	printf("First value = (%d,%d)\n",x.fst.fst,x.fst.snd);
	printf("Second value = (%d,%d)\n",x.snd.fst,x.snd.snd);
}

void relax(pair<ii,ii> &ans, pair<ii,ii> par){
	vector<ii> vec = {ans.fst,ans.snd,par.fst,par.snd};
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	int l = sz(vec);
	ans = make_pair( vec[l-1], vec[l-2] );
}

pair<ii,ii> go(int msk){
	pair<ii,ii> &ans = dp[msk];
	if(ans.fst != trash) return ans;
	ans = make_pair( make_pair(a[msk],msk),trash);
	for(int i = 0; i < bit; ++i){
		if(msk & (1 << i)){
			// turn off
			auto par = go( msk & (~(1 << i)) );
			relax(ans,par);
		}
	}
	//printf("Msk = %d\n",msk);
	//show(ans);
	return ans;
}

int main(){

	fastio;
	int n;
	cin >> n;
	bit = n;
	n = (1 << n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	REP(i,N) dp[i] = make_pair(trash,trash);
	dp[0] = make_pair(make_pair(a[0],0),trash);
	go(n-1);
	vector<int> ans(n);
	for(int i = 1; i < n; ++i){
		ans[i] = dp[i].fst.fst + dp[i].snd.fst;
		ans[i] = max(ans[i],ans[i-1]);
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 21840
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n;cin>>n;
    vector<int> ans(n);
    map<int,int> mp;
    rep(i,n){
        int t;cin>>t;t--;
        mp[t]=i;
    }
    for(auto x:mp){
        ans[x.first]=x.second;
    }
    rep(i,n){
        cout<<ans[i]+1;
        cout<<(i==n-1?"\n":" ");
    }
    return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}

signed main(){
	int a,b;cin>>a>>b;
	if(a>=13)cout<<b<<endl;
	else if(a>=6)cout<<b/2<<endl;
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256