akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static class Dice {
		private int[] label;
		
		public Dice(int[] num) {
			label = num;
		}
		
		public void roll(char op) {
			int tmp;
			
			switch (op) {
				case 'E':
					tmp = label[0];
					label[0] = label[3];
					label[3] = label[5];
					label[5] = label[2];
					label[2] = tmp;
					break;
				case 'N':
					tmp = label[0];
					label[0] = label[1];
					label[1] = label[5];
					label[5] = label[4];
					label[4] = tmp;
					break;
				case 'S':
					tmp = label[0];
					label[0] = label[4];
					label[4] = label[5];
					label[5] = label[1];
					label[1] = tmp;
					break;
				case 'W':
					tmp = label[0];
					label[0] = label[2];
					label[2] = label[5];
					label[5] = label[3];
					label[3] = tmp;
					break;
			}
		}
		
		public int getAboveNum() {
			return label[0];
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] nums = new int[6];
		
		for (int i = 0; i < nums.length; i++) {
			nums[i] = scan.nextInt();
		}

		Dice dice = new Dice(nums);
		String op = scan.next();
		
		for (int i = 0; i < op.length(); i++) {
			dice.roll(op.charAt(i));
		}

		System.out.println(dice.getAboveNum());
		scan.close();
	}

}

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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for (auto& i : v) cin >> i;
    auto d = v;
    sort(d.begin(), d.end());

    map<int,int> idx;
    for (int i = 0; i < N; i++) {
        idx[v[i]] = i;
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int x = idx[d[i]];
        if (abs(x - i) % 2) ans++;
    }

    cout << ans / 2 << endl;

    return 0;
}


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

int main(){
	string s, t;
	cin>>s>>t;
	forn(i, s.size())
		if(s[i]!=t[i]){
			cout<<"No\n";
			exit(0);
		}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 3560
//コッホ曲線
//再帰関数
using System;


namespace tst
{
    class Program
    {
        public static int n = 0;
        public static void Koch(int n, double[] p1, double[] p2)
        {
            if (n == 0) return;
            double[] s = new double[2];
            double[] t = new double[2];
            double[] u = new double[2];
            s[0] = (p1[0] * 2 + p2[0] * 1) / 3;
            s[1] = (p1[1] * 2 + p2[1] * 1) / 3;
            t[0] = (p1[0] * 1 + p2[0] * 2) / 3;
            t[1] = (p1[1] * 1 + p2[1] * 2) / 3;
            u[0] = (t[0] - s[0]) / 2                  - (t[1] - s[1]) * (Math.Sqrt(3) / 2) + s[0];
            u[1] = (t[0] - s[0]) * (Math.Sqrt(3) / 2) + (t[1] - s[1]) / 2                  + s[1];
            Koch(n - 1, p1, s);
            Console.WriteLine("{0} {1}", Marume(s[0]), Marume(s[1]));
            Koch(n - 1, s, u);
            Console.WriteLine("{0} {1}", Marume(u[0]), Marume(u[1])); 
            Koch(n - 1, u, t);
            Console.WriteLine("{0} {1}", Marume(t[0]), Marume(t[1]));
            Koch(n - 1 ,t, p2);
        }
        public static string Marume(double x)
        {//小数第９位を切捨て//x=0だと小数点以下が消えちゃうので無理やりstringで
            if (x%5==0)
            {
                return x + ".00000000";
            }
            else
            {
                double kurai = 100000000.0;
                x = (Math.Round(x * kurai)) / kurai;
                return x.ToString();
            }
        }
        public static void Main()
        {
            n = int.Parse(Console.ReadLine());
            Console.WriteLine("0.00000000 0.00000000");
            double[] p1 = { 0.00000000, 0.00000000 };
            double[] p2 = { 100.00000000, 0.00000000 };
            Koch(n, p1, p2);
            Console.WriteLine("100.00000000 0.00000000");
        }

    }
}


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

int bubbleSort(int A[],int N){
  int sw = 0;
  bool flag = true;
  for(int i=0;flag;i++){
    flag = 0;
    for(int j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
        swap(A[j],A[j-1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main(){
  int A[100],N,sw;

  cin >> N;

  for(int i=0;i<N;i++) cin >> A[i];

  sw = bubbleSort(A,N);

  for(int i=0;i<N;i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
  return 0;
}



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

long long INF = 1e18;

int main(){
    int a, b;
    cin >> a >> b;
    if(a<10){
    cout << 100 * (10 - a) +b<< endl;
    }else{
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define INF 1<<30
#define MAX 100000
using namespace std;
  
class Queue{
private:
  int inf[MAX];
  int head,tail;
   
public:
   
  Queue(){
    syokika();
  }
   
  void syokika(){
    head = 0;
    tail = 0;
  }
   
  void push(int x){
    inf[tail]=x;
    if(MAX == tail+1)tail = 0;
    else tail++;
  }
   
  void pop(){
    if(MAX == head+1)head=0;
    else head++;
  }
   
  int front(){
    return inf[head];
  }
   
  bool empty(){
    if(tail - head == 0)return true;
    else return false;
  }
   
  int size(){
    return tail - head;
  }
   
};
  
int imap[200][200];
int k[200] = {0};
int ans[200] = {0};
bool used[200];
  
int main(){
  int n,u[1000];
  cin >> n;
  for(int i=0;i<200;i++)for(int j=0;j<200;j++)imap[j][i] = INF;
  
  for(int i=0;i<200;i++){
    k[i]=ans[i]=u[i]=-1;
  }
  
  for(int i=0;i<n;i++){
    cin >> u[i];
    cin >> k[u[i]];
    for(int j=0;j<k[u[i]];j++){
      cin >> imap[u[i]][j];
    }
  }
  
   int h;
  for(int i=0;i<n;i++){
    int Min = i;
    for(int j=i;j<n;j++){
      if(u[Min] > u[j])Min = j;
    }
    h = u[Min];
    u[Min] = u[i];
    u[i] = h;
  }
  
  Queue que = Queue();
  
  que.push(u[0]);
  ans[u[0]]=0;
  used[u[0]]=true;
  
  while(!que.empty()){
    int p = que.front(); que.pop();
    for(int i=0;i<k[p];i++){
      if(!used[imap[p][i]]){
    que.push(imap[p][i]);//cout << "push!= " << imap[p][i] << endl;
    used[imap[p][i]] = true;
    ans[imap[p][i]] = ans[p] + 1;
      }
    }
  }
  //for(int i=0;i<n;i++)cout << u[i] << endl;
   
  for(int i=0;i<n;i++){
    cout << u[i] << " " << ans[u[i]] << endl;
  }
  
  return 0;
}

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

const int INF = 1001001001;

int main(){
    ll N, K, diff;
    cin >> N >> K;
    
    while(true){
       if(N == 0){
            break;
        } 
        ll n = N / K;
        if(n == 0){
            n = 1;
        }
        diff = N - n * K;
        if(diff < 0){
            diff *= -1;
        }
        if(N <= diff){
            break;
        }
        N = diff;
    }

    cout << N << endl;
}

Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():

    H,W=map(int,input().split())
    C=[list(input()) for i in range(H)]

    for i in C:
        print(*i,sep='')
        print(*i,sep='')

resolve()

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  int x;
  cin >> x;
  if(x == 0) cout << 1 << endl;
  else cout << 0 << endl;
	return 0;
}



Measured memory_bytes: 3616
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(n);
    vector<int> cnt(100100);
    rep(i, n) {
        cin >> x[i];
        cnt[x[i]]++;
    }

    int ans = 0;
    vector<int> v(m);
    vector<int> p(m);
    for (int i = 1; i <= 100000; i++) {
        if (cnt[i] == 0) continue;
        v[i % m] += cnt[i];
        p[i % m] += cnt[i] / 2;
    }

    ans += v[0] / 2;
    if (m % 2 == 0) ans += v[m / 2] / 2;

    for (int i = 1; i < m - i; i++) {
        if (v[i] >= v[m - i]) {
            ans += v[m - i];
            ans += min(p[i], (v[i] - v[m - i]) / 2);
        } else {
            ans += v[i];
            ans += min(p[m - i], (v[m - i] - v[i]) / 2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
CHARACTER(20) S(100)
INTEGER N,M
READ*,N
READ*,S(1)

DO I=2,N
  READ*,S(I)
  M = LEN_TRIM(S(I-1))
  ! LEN_TRIMっていちいち書くの面倒だった
  IF ( S(I-1)(M:M) /= S(I)(1:1) )THEN
    PRINT"(A)","No"
    STOP
  END IF
  
  DO J=1,I-1
    IF ( S(I) == S(J) )THEN
    PRINT"(A)","No"
    STOP 
    ENDIF
  END DO
  
END DO

PRINT"(A)","Yes"

END

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

using namespace std;
using ld = long double;

int main(void)
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    int hm_to_min = h*60 + m;
    int min_day = 12*60;
    ld h_angle = ((ld)hm_to_min / min_day);
    //ld h_angle = ((ld) h / 12.0 + ((ld)m / 60.0) / 12.0 );
    ld m_angle = ((ld) m / 60);

    ld angleBetween = 2 * M_PI * (h_angle - m_angle);
    
    ld l2 = (ld)(a*a + b*b) - (ld) (2 * a * b * cosl(angleBetween));
    cout << fixed<< setprecision(15) << sqrtl(l2) << endl;
}


Measured memory_bytes: 4112
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,ma = 0;
	string s;
	cin >> n >> s;
	for(int i = 1;i < n;i++){
		int ans = 0;
		for(int j = 0;j < 26;j++){
			bool a = false,b = false;
			for(int k = 0;k < n;k++){
				if(s[k] == j + 'a'){
					if(k < i) a = true;
					else b = true;
				}
			}
			if(a && b) ans++;
		}
		chmax(ma,ans);
	}
	cout << ma << endl;
	return 0;
}

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

int main() {

double x1,x2,y1,y2;
double x,y,z;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

x = (x2-x1) * (x2-x1);
y = (y2-y1) * (y2-y1);

printf("%.11lf",sqrt(x+y));


return 0;

}

Measured memory_bytes: 656
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
void Dice(char *p, int d[]);

int main() {
	int d[6], i;
	char dir[101],*p;
	for (i = 0; i < 6; i++)	scanf("%d", &d[i]);
	scanf("%s", dir);
	p = dir;
	Dice(p, d);
	printf("%d\n",d[0]);
	return 0;
}

void Dice(char *p, int d[]){
	int tmp;
	while (*p) {
		if (*p == 'S') { tmp = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = tmp; }
		if (*p == 'W') { tmp = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = tmp; }
		if (*p == 'E') { tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp; }
		if (*p == 'N') { tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp; }
		*(p++);
	}
}

Measured memory_bytes: 596
N = int(input())

def gcd(x, y):
    if x > y:
        x, y = y, x
    if y % x == 0:
        return x
    else:
        return gcd (y%x, x)


T1 = int(input())
ans = T1
for i in range(N-1):
    T2 = int(input())
    ans = T1 * T2 //gcd(T1, T2)
    T1 = ans

print (ans)

# print (gcd(12, 8))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int inf = 1001001001;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n,inf);
    dp[0] = 0;
    rep(i,n-1) {
        rep2(j,1,min(k+1,n-i)) {
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
d,g = map(int,input().split(" "))
li=[]
for x in range(d):
  li.append(list(map(int,input().split(" "))))

sum=[]
for i in range(2**(d)):
  s=0
  a=0
  z=[]
  for j in range(d):
    if i >> j & 1:
      s += li[j][0]*100*(j+1) + li[j][1]
      a += li[j][0]
    else:
      z.append(j)

  if s >= g:
    sum.append(a)
  else:
    k = max(z)
    h = g-s
    for l in range(li[k][0]):
      if l*(k+1)*100 >= h:
        sum.append(a+l)
        
print(min(sum))

Measured memory_bytes: 9240
def pat(K,count,keta,num):
    #print(str(num)+":"+str(count)+":"+str(keta))
    if count == -1:
        return -1
    elif keta == 1:
        if count == K-1:
            print(num)
            return count + 1
        else:
            return (count+1)

    else:
        if (int(num[-1])) -1 >= 0:
            count = pat(K,count,keta-1,num+str(int(num[-1])-1))
        count = pat(K,count,keta-1,num+num[-1])
        if (int(num[-1])+1) <= 9:
            count = pat(K,count,keta-1,num+str(int(num[-1])+1))
    if count >=K:
        return -1
    else:
        return count
K = int(input())
count = 0
ans = list()
keta = 0

while True:
    keta += 1
    for i in range(1,10):
        count = pat(K,count,keta,str(i))
        #print(count)
        if count  == -1:
            break
    if count == -1:
        break
        



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    
    int a;
    int b;
    
    cin >> a>> b;
    
    if((a*b)%2==0){
        
        
        cout << "Even"<< endl;
        
        
        
    }
    
    else{
        
        cout << "Odd"<< endl;
        
        
    }
    
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void AnsYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void AnsYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}







//ここまでライブラリ
//ここから本文





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

	for (int i = 0; i < s.size()+5; i++) {
		if (s == t) {
			AnsYes(true);
			return 0;
		}
		char a = s.at(s.size() - 1);
		s.pop_back();
		s.insert(s.begin(), a);
	}
	AnsYes(false);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int ans=1e9;
int main()
{
	int n,k,x[N],y[N];
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>y[i];
	sort(y,y+n);
	for(int i=0;i<n-k+1;i++)
		x[i]=y[i+k-1]-y[i];
	for(int i=0;i<n-k+1;i++)
	{
		if(x[i]<ans)
		{
			ans=x[i];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')


def solve():
    n = ni()
    a = nl()
    ok = -1
    ng = 10**18
    ans = -1
    while ng - ok > 1:
        v = mid = (ok + ng) // 2
        c = 0
        cnt = 0
        for x in a[:0:-1]:
            cnt += c + x
            c += x
            d = (c - 1) // 2 + 1
            if v > c - d:
                v -= c - d
                d = c
            elif v > 0:
                d += v
                v = 0
            c = d
        if a[0] + c > 1:
            ng = mid
        else:
            ok = mid
            ans = cnt + 1
    print(ans)
    return

solve()


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


inline int sub(int x, int y, int mod) {
  x -= y;
  if (x + mod <= 0) {
    x %= mod;
  }
  return (x < 0 ? x+mod : x);
}

int modPow(int a, int x, int p) {
 
    int res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

int modInverse(int a, int p) {

    return modPow(a, p-2, p);
}
int modBinomial(int n, int k, int p) {


    int numerator = 1; 
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    int denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

 
    return ( numerator* modInverse(denominator,p) ) % p;
}

signed main(){

	int n,a,b;
	cin>>n>>a>>b;

	int p = 1e9+7;

	int y = modPow(2,n,p);
     
    y = sub(y,1,p);



    int x1 = modBinomial(n,a,p);
    int x2 = modBinomial(n,b,p);

   // cout<<x1<<" "<<x2<<endl;
	
	y = sub(y,x1,p);
	y = sub(y,x2,p);

    cout<<max(0LL,y)<<endl;
}

Measured memory_bytes: 256
#include<iostream> 
#include<vector> 
#include<algorithm> 
using namespace std; 
#define lld long long int
#define X 1000000007
# define for(i,n) for(int i=0;i<n;i++) 
#define w(t) int t; cin>>y; while(t--)
int main()
{ios_base::sync_with_stdio(false); 
cin.tie(0); 
 lld n; 
 cin>>n; 
 lld a[n][3]; 
lld  dp[n][3] ; 
 for(i,n) 
 for(j,3)
 {  cin>>a[i][j]; 
    dp[i][j]=0; 
 } 
 dp[0][0]=a[0][0]; 
 dp[0][1]=a[0][1]; 
 dp[0][2]=a[0][2]; 
 for(i,n) 
 for(j,3)
 { if(i==0) 
     break; 
 dp[i][j]=max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3])+a[i][j]; 
 }
 lld x; 
 x=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])); 
 cout<<x<<endl; 
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; ll k;
	cin>>n>>k;
	vector<int> a(n);
	for(auto &x : a){
		cin>>x; x--;
	}
	vector<int> vec, vis(n, 0);
	int v = 0;
	while(!vis[v]){
		vec.push_back(v);
		vis[v] = 1;
		v = a[v];
	}
	for(int i = 0; i < vec.size(); i++){
		if(vec[i] == v){
			if(k <= i){
				cout<<vec[k] + 1<<'\n';
			}else{
				ll len = vec.size() - i;
				k -= i;
				k %= len;
				cout<<vec[i + k] + 1<<'\n';
			}
		}
	}

	return 0;
}

Measured memory_bytes: 5872
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int h, w, n;
  cin >> h >> w >> n;
  h = max(h, w);
  cout << (n + h - 1) / h;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
//
// Created by yamunaku on 2020/09/20.
//

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main() {
    //CFS;
    ll n;
    cin >> n;
    n *= 2;
    vl soinsu;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ll x = 1;
            while (n % i == 0) {
                n /= i;
                x *= i;
            }
            soinsu.push_back(x);
        }
    }
    if (n > 1) soinsu.push_back(n);
    int sz = soinsu.size();
    ll ans = LINF;
    rep(t, 1 << sz) {
        vl amari;
        rep(i, sz) {
            if (t & (1 << i)) amari.push_back(soinsu[i] - 1);
            else amari.push_back(0);
        }
        if (t == 0) ans = min(ans, crt(amari, soinsu).second);
        else ans = min(ans, crt(amari, soinsu).first);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>

using namespace std;

int main()
{
    int W, H, N, x, y, a, rect[110][110];

    cin >> W >> H >> N;

    for (int i = 0; i < W; i++)
    {
        for (int j = 0; j < H; j++)
        {
            rect[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        cin >> x >> y >> a;

        if (a == 1)
        {
            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < H; j++)
                {
                    rect[i][j] = 1;
                }
            }
        }
        if (a == 2)
        {
            for (int i = x; i < W; i++)
            {
                for (int j = 0; j < H; j++)
                {
                    rect[i][j] = 1;
                }
            }
        }
        if (a == 3)
        {
            for (int i = 0; i < W; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    rect[i][j] = 1;
                }
            }
        }
        if (a == 4)
        {
            for (int i = 0; i < W; i++)
            {
                for (int j = y; j < H; j++)
                {
                    rect[i][j] = 1;
                }
            }
        }
    }

    int ans = 0;

    for (int i = 0; i < W; i++)
    {
        for (int j = 0; j < H; j++)
        {
            if (rect[i][j] == 0)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int A,B,C,D,N;
    int ans;
    cin>>N;
    ans=N;
    rep(i,2)ans*=N;
    Out(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long n,M;
    cin >> n >> M;
    long long  H[n];
    long long  x[n];
    long long  y[n];
    long long  ans=0;
    
    for(int i=0;i<n;i++){
        cin >> H[i];
    }
    for(int i=0;i<n;i++){
        x[i]=0;
        y[i]=0;
    }
    while(M--){
        int a, b;
        cin>>a>>b;
        x[a-1]=x[a-1]+1;
        x[b-1]=x[b-1]+1;
        
        if(H[a-1]>H[b-1])
            y[a-1]=y[a-1]+1;
        else if(H[a-1]<H[b-1])
            y[b-1]=y[b-1]+1;
    }

    for(int i=0; i<n;i++){
        //cout<<"x["<<i<<"]="<<x[i]<<endl;
        //cout<<"y["<<i<<"]="<<y[i]<<endl;
        if(x[i]==0)
            ans=ans+1;
        else if(y[i]==x[i])
            ans=ans+1;
    }
    cout<<ans<<endl;
}
    


Measured memory_bytes: 5860
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<map>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;
typedef long long ll;

int main() {
	string S;
	int w;

	cin >> S >> w;

	//cout << S.size() << S[0] << ", " << S[1] << ", " << S[2]<<endl;

	int ende;
	if (S.size() % w == 0)
		ende = S.size() / w;
	else 
		ende = S.size() / w + 1;


	for (int i = 0; i < ende; i++) {
		//cout << i*w << endl;
		cout << S[i * w];

	}
		
	cout << endl;


	//cin >> S;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int a,b,c,d,sum=0;
  cin>>a>>b>>c>>d;
  sum += a+b+c+d;
  cout<<sum<<'\n';
  return 0;
}




Measured memory_bytes: 3076
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	mods := make([]int, 0)
	for n > 0 {
		mods = append([]int{n % k}, mods...)
		n = n / k
	}
	fmt.Println(len(mods))
}

func JoinInts(ints []int) string {
	return strings.Trim(strings.Join(strings.Fields(fmt.Sprint(ints)), ""), "[]")
}


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>

const int MAXN = 5e3 + 10, INF = 1e9;

int n, n1, n2;
int a[MAXN << 2], b[MAXN << 2];
char s[MAXN], t[MAXN];

int main() {
	scanf("%d %s %s", &n, s + 1, t + 1);
	for (int i = 1; i < n; ++i) if (s[i] != s[i + 1]) a[(++n1) + n + 20] = i;
	for (int i = 1; i < n; ++i) if (t[i] != t[i + 1]) b[(++n2) + n + 20] = i;
	for (int i = 1; i <= n + 20; ++i) a[n1 + n + 20 + i] = b[n2 + n + 20 + i] = n;
	int ans = INF;
	for (int i = -n1 - 2; i <= n2 + 2; ++i) if ((i & 1) != (s[1] == t[1])) {
		int now = 0;
		for (int j = std::min(0, -i) + n; j <= std::max(n1, -i + n2 + 1) + n + 30; ++j) now += abs(a[j] - b[i + j]);
		ans = std::min(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    char b;
    cin>>b;

    if(b=='A') cout<<'T'<<endl;
    else if(b=='T') cout<<'A'<<endl;
    else if(b=='C') cout<<'G'<<endl;
    else if(b=='G') cout<<'C'<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define POW_10_5 100000
#define POW_10_9 1000000000
#define INF (numeric_limits<int>::max()/2)
#define int long long

typedef pair<int, int> Pair;
typedef unordered_map<int, int> Hash;

// ---
int N;
string s;

string Ans() {
  int rn = 0, sn = 0;
  REP(i, s.length()) {
    if (s[i] == 'R') {
      ++rn;
    } else {
      ++sn;
    }
  }
  if (rn > sn) {
    return "Yes";
  } else {
    return "No";
  }
}

signed main() {
  cin >> N;
  cin >> s;

  auto ans = Ans();

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


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
	
    public static void main(String[] args)   throws Exception, IOException{        
        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n=sc.nextInt();
        int n=sc.nextInt()+sc.nextInt()+sc.nextInt();
        

        out.println(n>=22?"bust":"win");
     	out.flush();
    }


    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

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

//
//class P {
//	int x, y, d;
//	P(int  x, int y, int d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return -p.a+a;//as
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21076
n, x = map(int,input().split())
l = list(map(int,input().split()))
d = 0 #1回目の座標
#2回目以降
count = 1
for i in range (0,n):
    d = d + l[i]
    if(d > x):
        break
    count += 1

print(count)



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

void Main()
{
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main(void) {
    int x, i = 1;
    while (1) {
        cin >> x;
        if (x == 0) {
            break;
        }
        cout << "Case " << i << ": " << x << "\n";
        ++i;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>

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

int main(void){
    using namespace  std;
    long H;
    cin >> H;

    cout << (long)(pow(2, floor(log2(H)) + 1) - 1) << endl;

    return 0;
}

Measured memory_bytes: 512
<?php
    $arr = explode(' ', trim(fgets(STDIN)));
    
    $a = $arr[0];
    $b = $arr[1];

    // 8% でありうる範囲
    $amin = ceil($a * 12.5);
    $amax = ceil(($a + 1) * 12.5) - 1;

    // 10% でありうる範囲
    $bmin = ceil($b * 10);
    $bmax = ceil(($b + 1) * 10) - 1;

    $ret = max([$amin, $bmin]);

    if ($ret > $amax || $ret > $bmax) {
        echo '-1';
        return;
    }

    echo $ret;
    return;
?>

Measured memory_bytes: 4604
object Main extends App {
  val s = scala.io.StdIn.readLine
  val count1 = s.zipWithIndex.count { tmp =>
    val aa = '0' + ((tmp._2 + 1) % 2)
    //    println(aa.toChar)
    //    println(tmp._1 != aa)

    tmp._1 != aa
  }
  //println()

  val count2 = s.zipWithIndex.count { tmp =>
    val aa = '0' + ((tmp._2 + 2) % 2)
    //    println(aa.toChar)
    //    println(tmp._1 != aa)

    tmp._1 != aa
  }
  //println(List(count1, count2))

  println(List(count1, count2).min)

}

Measured memory_bytes: 37896
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var a, b int
	con.Scan(&a, &b)
	if a%3 == 0 || b%3 == 0 || (a+b)%3 == 0 {
		con.Println("Possible")
	} else {
		con.Println("Impossible")
	}
	return nil
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    vector<int> niz(n);
    for (int i = 0; i < n; i++)
        cin >> niz[i];
    long long cnt = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (niz[i] > niz[i + 1])
        {
            cnt += abs(niz[i] - niz[i + 1]);
            niz[i + 1] = niz[i];
        }
    }
    cout << cnt;
}


Measured memory_bytes: 4020
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=100005;

int n,m,cnt,last[N],dep[N],s;
bool vis[N],flag;
struct edge{int to,next;}e[N*4];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void addedge(int u,int v)
{
	e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x,int fa)
{
	vis[x]=1;s++;
	for (int i=last[x];i;i=e[i].next)
		if (vis[e[i].to]&&e[i].to!=fa) flag|=dep[x]==dep[e[i].to];
		else if(!vis[e[i].to]) dep[e[i].to]=dep[x]^1,dfs(e[i].to,x);
}

int main()
{
	n=read();m=read();
	for (int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		addedge(x,y);
	}
	LL ans=0;int t1=0,t2=0,t3=0;
	for (int i=1;i<=n;i++)
	{
		if (vis[i]) continue;
		flag=0;s=0;
		dfs(i,0);
		if (s==1) ans+=n*2-1,t3++;
		else if (!flag) ans+=2,t1++;
		else ans++,t2++;
	}
	ans-=(LL)t3*(t3-1);
	ans+=(LL)t1*(t1-1)*2+(LL)t2*(t2-1)+(LL)t1*t2*2;
	printf("%lld",ans);
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int ans = 0;
  int h = 0;
  
  for(int i = 0; i<3; i++){
    if(s[i] == 'R'){
      h++;
    }else{
      ans = max(ans,h);
      h = 0;
    }
  }
  
  ans = max(ans,h);
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll N, D, A; cin >> N >> D >> A;
    vector<pll> p;
    rep(i, N) {
        ll x, h;
        cin >> x >> h;
        p.emplace_back(x, h);
    }
    sort(p.begin(), p.end());

    vll s(N+1, 0);
    ll ans = 0, right = 0;
    rep(i, N) {
        p[i].second -= s[i];
        while(right < N && p[right].first <= p[i].first + 2*D) right++;
        if(p[i].second > 0) {
            ll num = (p[i].second + A - 1) / A;
            ans += num;
            s[i] += num * A;
            s[right] -= num * A;
        }
        s[i+1] += s[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 5872
N, a, b = map(int,input().split())

ans = 0

for i in range(N+1):
    d1 = int(i%10)
    d2 = int(i//10%10)
    d3 = int(i//100%10)
    d4 = int(i//1000%10)
    d5 = int(i//10000%10)
    d = d1+d2+d3+d4+d5
    if d >= a and d <= b:
        ans +=i

print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), a = in(), b = in();
	cout << min(a, b) << ' ' << max(a + b - n, 0LL) << endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	static final boolean debugMode = false;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = readInt(sc);
		
		int[] list = new int[n];
		for (int i = 1; i < n; i++) {
			int a = readInt(sc);
			list[a-1]++;
		}
		
		for (int i = 0; i < n; i++) {
			System.out.println(list[i]);
		}


	}

	// con.) a >= b
	static int gcm(int a, int b) {
		while (true) {
			if (b == 0)
				break;

			int mod = a % b;
			a = b;
			b = mod;
		}
		return a;
	}

	// con.) a >= b
	static int lcm(int a, int b) {
		return a * b / gcm(a, b);
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static Long readLong(Scanner sc) {
		return Long.parseLong(sc.next());
	}

	static void log(String s) {
		if (debugMode) {
			System.out.println(s);
		}
		return;
	}
}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}


Measured memory_bytes: 50612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 3e3 + 5;
string s, t;
int n, m, dp[N][N], vis[N][N];
int calc(int i, int j)
{
  if (i == n || j == m)
    return 0;
  if (vis[i][j])
    return dp[i][j];
  vis[i][j] = 1;
  if (s[i] == t[j])
    return dp[i][j] = calc(i + 1, j + 1) + 1;
  else
  {
    int x = calc(i + 1, j);
    int y = calc(i, j + 1);
    return dp[i][j] = max(x, y);
  }
}
int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  cin >> s >> t;
  n = s.size(), m = t.size();
  calc(0, 0);
  string ans = "";
  int i = 0, j = 0;
  while (i < n && j < m)
  {
    if (s[i] == t[j])
    {
      ans += s[i];
      i++, j++;
    }
    else
    {
      if (dp[i + 1][j] >= dp[i][j + 1])
        i++;
      else
        j++;
    }
  }
  cout << ans << endl;
}






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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int count{0};
    if (a != b) count++;

    if (a != c) count++;

    if (b != c) count++;

    if (a == b && b == c) count = 1;

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
long long n, m;

int main()
{
  ll k, x;
  cin >> k >> x;
  if(500*k>=x)
    cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <unordered_map>
#include <array>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <random>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
int N;
int p[MAX_N+1];

int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> p[i];

  int ans = 0, count = 0;
  for (int i = 1; i <= N; ++i) {
    if (i == p[i]) {
      ++count;
    } else {
      ans += (count+1)/2;
      count = 0;
    }
  }
  ans += (count+1)/2;
  
  cout << ans << endl;

  return 0;
}


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

#define fi first
#define se second
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define mst(a,v) memset(a,v,sizeof(a))
#define debug(x) cout<<#x": "<<x<<'\n';
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=100007;
const int M=10000007;
const int mod=1e8+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fLL;

template<class T> inline void gmax(T &A,T B)
{
    (A<B)&&(A=B);
}
template<class T> inline void gmin(T &A,T B)
{
    (A>B)&&(A=B);
}

template<class T> inline bool re(T &ret)
{
    char c;
    int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')? -1:1;
    ret=(c=='-')? 0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}

ll x,y;
int ans=0;

int main()
{
#ifdef local
    freopen("in.txt", "r", stdin);
#endif
    IOS
    cin>>x>>y;
    while(x<=y)
    {
        ans++;
        x<<=1;
    }
    cout<<ans;
    return 0;
}


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


using namespace std;

const long mod=1000000007; 

int main(){
  long n,k;
  cin >> n >> k;
  
  long c[2005][2005];
  
  for(int i=0;i<=n;i++){
  c[i][0]=1;
  c[i][i]=1;
  }
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<i;j++){
     c[i][j]=c[i-1][j-1]+c[i-1][j];
     c[i][j]%=mod;
    }
  }
  
  for(int i=1;i<=k;i++) cout << (c[n-k+1][i]*c[k-1][i-1])%mod << endl;
  

}

Measured memory_bytes: 31488
import sys
from collections import deque,defaultdict
from fractions import gcd
from math import ceil,atan,degrees

def N():
    return int(sys.stdin.readline())
def NK():
    return map(int,sys.stdin.readline().split())
def LS_I():
    return [int(x) for x in sys.stdin.readline().split()]
def LS_S():
    return list(input())
def main():
    a,b,x = NK()
    x_ = x/a
    if x_<= a*b/2:
        x_ = 2*x_/b
        theta = degrees(atan(b/x_))
        print(theta)
    else:
        x_ = a*b-x_
        x_ = 2*x_/a
        theta = degrees(atan(x_/a))
        print(theta)
if __name__ == "__main__":
    main()

Measured memory_bytes: 65388