akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

long c = 0;

void merge(unsigned long long a[], long l, long m, long r)
{
	long n1 = m - l;
	long n2 = r - m;
	vector<unsigned long long> L(n1 + 1), R(n2 + 1);

	for (long i = 0; i < n1; i++)
		L[i] = a[l + i];

	for (long i = 0; i < n2; i++)
		R[i] = a[m + i];

	L[n1] = 1000000001;
	R[n2] = 1000000002;
	long i = 0, j = 0;

	for (long k = l; k < r; k++) {
		if (L[i] <= R[j]) {
			a[k] = L[i];
			i++;
		}
		else {
			a[k] = R[j];
			j++;
			c += n1 - i;
		}
	}
}

void mergeSort(unsigned long long a[], long l, long r)
{
	if (l + 1 < r) {
		long m = (l + r) / 2;
		mergeSort(a, l, m);
		mergeSort(a, m, r);
		merge(a, l, m, r);
	}
}

int main()
{
	long n = 0;
	unsigned long long a[200000] = { 0 };

	cin >> n;

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

	mergeSort(a, 0, n);

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 5900
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long N;
  cin >> N;
  vector<long> x(N), y(N), h(N);
  for (long i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  long ansx = 0, ansy = 0;
  long tmp = -1;
  for (long cx = 0; cx < 101; cx++) {
    for (long cy = 0; cy < 101; cy++) {
      for (long i = 0; i < N; i++) {
        if (tmp == -1 && h[i] > 0) {
          tmp = abs(x[i]-cx)+abs(y[i]-cy)+h[i];
          goto next;
        }
      }
next:
      for (long i = 0; i < N; i++) {
        long h1 = tmp-abs(x[i]-cx)-abs(y[i]-cy);
        long h2 = h1 > 0 ? h1 : 0;
        if (h[i] != h2) goto out;
      }
      ansx = cx;
      ansy = cy;
      goto end;
out:
      tmp = -1;
      ansx = -1;
      ansy = -1;
    }
  }
end:
  cout << ansx << " " << ansy << " " << tmp << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int findans(long long int h,long long int i)
{
    if(h==1)
    {
        return 1;
    }
    if(h==0)
    {
        return 0;
    }

    return pow(2,i)+findans(h/2,i+1);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long int h;
    cin>>h;
    cout<<findans(h,1)<<"\n";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 105;
int n, m, k, col[N * N], a[N][N];
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m >> k;
    for(int i = 1; i <= k; i++)
        cin >> col[i];
    int idx = 1;
    for(int i = 0; i < n; i++){
        if(i % 2){
            for(int j = m - 1; j > -1; j--){
                if(col[idx])
                    a[i][j] = idx, col[idx]--;
                else{
                    idx++;
                    j++;
                }
            }
        }
        else{
            for(int j = 0; j < m; j++){
                if(col[idx])
                    a[i][j] = idx, col[idx]--;
                else
                    idx++, j--;
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++)
            cout << a[i][j] << ' ';
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 384
#include<math.h>
c,n;main(i){for(;scanf("%d",&n),n;printf("%s number\n",n>c?"deficient":n<c?"abundant":"perfect"),c=0)if(n>2)for(c=1,i=2;i<=sqrt(n);i++)if(n%i==0){c+=i;if(i!=n/i)c+=n/i;}exit(0);}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll h; cin >> h;
    ll a=1;
    for(int i=0;i<64;i++){
        if(h<a) break;
        a*=2;
    }
    cout << a-1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    L = list(map(int, readline().split()))
    L.sort(reverse=True)
    ans = 0
    for l in L[:K]:
        ans += l
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
ll n,a[100001],minn=INF;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=n;i>=1;--i)
	{
		minn=min(minn,a[i]);
		if (a[i]>=minn+2)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>

using namespace std;

#define MODULUS 1000000007

int main() {
    long long n;
    long long allCount = 1;
    long long excludingOneCount = 1;
    long long excludingTwoCount = 1;
    long long result;

    cin >> n;

    for (int i = 0; i < n; i++) {
        allCount = allCount * 10 % MODULUS;
    }

    for (int i = 0; i < n; i++) {
        excludingOneCount = excludingOneCount * 9 % MODULUS;
    }

    for (int i = 0; i < n; i++) {
        excludingTwoCount = excludingTwoCount * 8 % MODULUS;
    }

    result = (allCount - 2 * excludingOneCount + excludingTwoCount) % MODULUS;

    if (result < 0) result += MODULUS;

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
using namespace  std;
int main(){
  int c[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c[i][j];
    }
  }
  for(int i=0;i<=100;i++){
   for(int j=0;j<=100;j++){
     for(int k=0;k<=100;k++){
       if(((c[0][0]+c[1][0]+c[2][0])-i-j-k)%3==0){
         if(((c[0][1]+c[1][1]+c[2][1])-i-j-k)%3==0){
           if(((c[0][2]+c[1][2]+c[2][2])-i-j-k)%3==0){
             cout <<"Yes"<<endl;
             return 0;
           }
         }
       }
     }
   }
  }
  cout <<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int 
#define ll long long 
#define f(i, n) for(int i=0; i<n; i++)

using namespace std;




void test()
{
	int n;
	cin>>n;
	
	cout<<n + (n*n) + (n*n*n)<<endl;
}

int main(){
	
	/*int t;
	cin>>t;
	
	while(t--){
		test();
	}*/
	
	test();
	return 0;

}







Measured memory_bytes: 3592
#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>;
using Graph = vector<vector<int>>;



int main(){

    string S; cin >> S;

    rep(i, (int)S.size()){
        cout << "x";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  int N;
  int a[110];
  cin >> N;
  for (int i=0; i<N ;i++) cin >> a[i];
  
  sort(a,a+N,greater<int>());
  int Alice = 0;
  int Bob = 0;
  for(int i=0;i<N;i++){
    if(i%2 == 0){
      Alice += a[i];
    }
    else{
      Bob += a[i];
    }
  }
  cout << Alice-Bob << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[105];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
	scanf("%d",&a[i]);
}
for(int i=1;i<=n;i++){
	if(a[i]%2==0){
		if(a[i]%3!=0){
			if(a[i]%5!=0){
				printf("DENIED");
				return 0;
			}
		}
	}
}
printf("APPROVED");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

struct Node {
    int parent = -1;
    int right = -1;
    int left = -1;
    int sibling = -1;
    int depth = 0;
    int height = 0;
};

int calc_depth(int root_idx, Node * nodes, int depth) {
    nodes[root_idx].depth = depth;
    if (nodes[root_idx].left == -1 && nodes[root_idx].right == -1) {
        nodes[root_idx].height = 0;
        return 0;
    }
    int height = 0;
    if (nodes[root_idx].left != -1) {
        height = calc_depth(nodes[root_idx].left, nodes, depth + 1) + 1;
    }
    if (nodes[root_idx].right != -1) {
        height = std::max(height, calc_depth(nodes[root_idx].right, nodes, depth + 1) + 1);
    }
    nodes[root_idx].height = height;
    return height;
}

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

    Node nodes[n];
    
    for (int _ = 0; _ < n; _++) {
        int i, l, r;
        std::cin >> i >> l >> r;
        nodes[i].left = l;
        nodes[i].right = r;
        nodes[l].parent = i;
        nodes[r].parent = i;
        nodes[l].sibling = r;
        nodes[r].sibling = l;
    }

    int root_idx = 0;
    for (int i = 0; i < n; i++) {
        if (nodes[i].parent == -1) {
            root_idx = i;
            break;
        }
    }

    calc_depth(root_idx, nodes, 0);

    for (int i = 0; i < n; i++) {
        int sibling = -1;
        if (nodes[i].parent != -1) {
            int sib_l = nodes[nodes[i].parent].left;
            int sib_r = nodes[nodes[i].parent].right;
            sibling = sib_l == i ? sib_r : sib_l;
        }
        int degree = int(nodes[i].left != -1) + int(nodes[i].right != -1);
        std::string type = "internal node";
        if (nodes[i].parent == -1) {
            type = "root";
        } else if (degree == 0) {
            type = "leaf";
        }
        std::cout << "node " << i << ": parent = " << nodes[i].parent
                  << ", sibling = " << sibling
                  << ", degree = " << degree
                  << ", depth = " << nodes[i].depth
                  << ", height = " << nodes[i].height
                  << ", " << type << std::endl;
    }
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define REP(n) FOR(i,n)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)

int main() {
  int n;
  cin>>n;
  nvec(int,l,n);
  sort(all(l));
  int sum=0;
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < i; j++) {
      sum+=int(lower_bound(all(l),l[i]+l[j])-l.begin()-i-1);
    }
  }
  cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    int total = 0;
    int pos = 0;
    int current, next;
    vector<int> cost(N);
    for(int i = 0; i < N; i++) {
        current = A.at(i);
        total += abs(current - pos);
        next = (i == N - 1) ? 0 : A.at(i + 1);
        if((pos <= current && current <= next) || (pos >= current && current >= next)){
            cost.at(i) = 0;
        }
        else{
            if(pos < current) {
                cost.at(i) = (current - max(pos, next)) * 2;
            } else {
                cost.at(i) = (min(pos, next) - current) * 2;
            }
        }
        pos = A.at(i);
    }
    total += abs(pos);

    for(int i = 0; i < N; i++) {
        cout << (total - cost.at(i)) << endl;
    }

    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
 
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
 
//C++14 (GCC 5.4.1)
int main() {
    double N,K;
    cin >>N>>K;
    //-----------------------------------
    double ans=0;
    vector<int> Kd(30);
    Kd[0]=0;
    Kd[1]=1;
    int maxi;
 
    repd(i,1,29){
        Kd[i+1]=Kd[i]*2;
    }
    rep(i,N){
        rep(j,29){
            if((i+1)*Kd[j]<K && K<=(i+1)*Kd[j+1]){
                ans+=1.0/N/Kd[j+1];
                break;
            }
        }
    }
 

    printf("%.15lf\n",ans);

    return (0);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N = inputI()
T,A = inputIL()
H = inputIL()

H_T = [T-h*0.006 for h in H]

MIN = INF
POS = None

for i in range(N):
  if abs(H_T[i] - A) < MIN:
    MIN = abs(H_T[i] - A)
    POS = i+1
    
print(POS)

Measured memory_bytes: 64108
import java.util.Scanner;

public class Main{

	int[][] board;

	void run(){
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		for(int i=0; i<N; i++){
			board = new int[5][5];
			for(int j=0; j<5; j++){
				for(int k=0; k<5; k++){
					board[j][k] = in.nextInt();
				}
			}
			System.out.println(solve());
		}
	}

	int solve(){
		int ret = 0;
		for(int lx=0; lx<5; lx++)for(int ux=lx+1; ux<=5; ux++)
			for(int ly=0; ly<5; ly++)for(int uy=ly+1; uy<=5; uy++){
				int tar = (ux-lx)*(uy-ly);
				if(tar > ret){
					int cnt = 0;
					for(int i=lx; i<ux; i++){
						for(int j=ly; j<uy; j++){
							cnt += board[i][j];
						}
					}
					if(cnt == tar){
						ret = tar;
					}
				}
			}
		
		return ret;
	}

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

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;

int main() {
    int d, n;
    cin >> d >> n;
    if (d == 0) {
        if (n == 100) cout << n + 1 << endl;
        else cout << n << endl;
    }
    else if (d == 1) {
        if(n == 100) cout << (n + 1) * 100 << endl;
        else cout << n * 100 << endl;
    }
    else {
        if(n == 100) cout << (n + 1) * 100 * 100 << endl;
        else cout << n * 100 * 100 << endl;
    }
}

Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def xxx(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def resolve():
    readline=sys.stdin.readline

    h=int(readline())
    if h==1:
        print(0)
        return
    arr=xxx(h)
    ans=0
    for a in arr:
        n=a[1]
        i=1
        cnt=0
        while n>0:
            n-=i
            i+=1
            cnt+=1
        if n<0:
            cnt-=1
        ans+=cnt
    print(ans)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16432
import numpy as np
from collections import Counter

N, M = [int(i) for i in input().split()]

s = np.ones(M)

c = np.ones(M)
if M>0:
    for i in range(M):
        s[i], c[i] = [int(i) for i in input().split()]
    
    ans = 0   
    if i in range(M):
        for j in range(M):
            if s[i] == s[j]:
                if c[i] == c[j]:
                    pass
                else:
                    ans = -1
                    break

          
          
    a_100 = int(0)
    a_10 = int(0)
    a_1 = int(0)
    flag_3 = 0
    flag_2 = 0
    for i in range(M):
        if (N-s[i]+1) == 1:
            a_1 = int(c[i])
        elif (N-s[i]+1) == 2:
            a_10 = int(c[i])
            flag_2 +=1
        elif (N-s[i]+1) == 3:
            a_100 = int(c[i])
            flag_3 +=1
    aaa = str(a_100)+str(a_10)+str(a_1)
    if (N==3) & (a_100 == 0) & (ans!=-1)&(flag_3 ==0):
        a_100 =1
        aaa = str(a_100)+str(a_10)+str(a_1)
        ans = int(''.join(map(str,aaa)))
    elif (N==3) & (a_100 == 0) & (ans!=-1)&(flag_3 >0):
        ans =-1
    elif (N==2) & (a_100 == 0)& (a_10 == 0)&(ans!=-1)&(flag_2 ==0)&(flag_3 ==0):
        a_10 = 1
        aaa = str(a_10)+str(a_1)
        ans = int(''.join(map(str,aaa)))
    elif (N==2) & (a_100 == 0)& (a_10 == 0)&(ans!=-1)&(flag_2 >0)&(flag_3 >0):
    	ans=-1
    elif (N==2) & (a_100 == 0)& (a_10 == 0)&(ans!=-1)&(flag_2 ==0)&(flag_3 >0):
        a_10 = 1
        aaa = str(a_10)+str(a_1)
        ans = int(''.join(map(str,aaa)))
    elif (N==2) & (a_100 == 0)& (a_10 == 0)&(ans!=-1)&(flag_2 >0)&(flag_3 ==0):
    	ans=-1
    elif (N==2) & (a_100 > 0)&(ans!=-1):
        ans =-1
    elif (N==1) & ((a_100 > 0)| (a_10 > 0))  &(ans!=-1):
        ans =-1
    
    else:
        aaa = str(a_100)+str(a_10)+str(a_1)

        ans = int(''.join(map(str,aaa)))
    if i in range(M):
        for j in range(M):
            if s[i] == s[j]:
                if c[i] == c[j]:
                    pass
                else:
                    ans = -1
                    break
if M ==0:
    if N ==1:
        ans =0
    elif N ==2:
        ans = 10
    elif N==3:
        ans =100
print(ans) 
    
    
        


Measured memory_bytes: 12532
n, m = map(int, input().split())
x = list(map(int, input().split()))

if n >= m:
    print(0)
else:
    x.sort()
    y = []
    for i in range(m-1):
        y.append(abs(x[i]-x[i+1]))
    y.sort()
    sa = m - n
    res = 0
    for i in range(sa):
        res += y[i]
    print(res)

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

using namespace std;

const int MAX_N = 1e3 + 5;
const int MOD = 1e9 + 7;

int n, m;

char c;

int dp[MAX_N][MAX_N];

int main() {
  // dp[i][j] = the number of ways i can get in (i, j)
  // if mat[i][j] == '#', i can't go there, so dp[i][j] = 0
  // else, i can get in (i, j) from (i - 1, j) and (i, j - 1), so i can chose anyone from those two
  // Then, dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
  cin >> n >> m;
  cin.get();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> c;
      if (i == 1 && j == 1) {
        dp[i][j] = 1;
        continue;
      }
      if (c == '.') {
        dp[i][j] = (1LL * dp[i - 1][j] % MOD + dp[i][j - 1] % MOD) % MOD;
      } else {
        dp[i][j] = 0;
      }
    }
    cin.get();
  }
  cout << dp[n][m] << "\n";
  return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		if ( A+B < 10 ) {
			System.out.println( A + B );
		} else if ( 10 <= A + B) {
			System.out.println("error");
		}
	}
}

Measured memory_bytes: 25172
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	s := getNextString(scanner)

	weeks := map[string]int{
		"SUN": 0,
		"MON": 1,
		"TUE": 2,
		"WED": 3,
		"THU": 4,
		"FRI": 5,
		"SAT": 6,
	}

	fmt.Fprintln(writer, 7-weeks[s])
	writer.Flush()
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
   int N;
   string S;
   cin >> N;
   cin >> S;
   REP(i,S.size()){
       char c = S[i];
       int a = c-'A';
       a+=N;
       a %=26;
       S[i] = 'A' + a;
   }
   cout << S << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll>cnt(100001);
  rep(i,n) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  int q;
  cin >> q;
  ll ans = 0;
  rep(i,100001) ans+=i*cnt[i];
  rep(i,q) {
    int b,c;
    cin >> b >> c;
    ans-=b*cnt[b];
    ans+=c*cnt[b];
    cnt[c]+=cnt[b];
    cnt[b]=0;
    cout << ans << endl;
  }
}

Measured memory_bytes: 4016
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int x, y;
	cin >> x >> y;
	
	if (abs(x) == abs(y))
	{
		if (x > 0 && y < 0)
			printf("1\n");
		else if (x < 0 && y > 0)
			printf("1\n");
		else
			printf("0\n");
	}
	else if (abs(x) < abs(y))
	{
		int ans = 0;
		if (x < 0)
			ans++;
		ans += abs(y) - abs(x);
		if (y < 0)
			ans++;
		printf("%d\n", ans);
	}
	else
	{
		int ans = 0;
		if (x > 0)
			ans++;
		ans += abs(x) - abs(y);
		if (y > 0)
			ans++;
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,bs=0;
	cin >> a >> b;
	int ans=b;
	while(b != b/10)
	{	
		bs++;
		b /= 10;
	} 
	for(int i=0;i<bs;i++)
		a *= 10;
	ans += a; 
	for(int i=0;i<1000;i++)
		if(ans == i*i)
		{
			puts("Yes");
			return 0; 
		} 
	puts("No");
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

void solve()
{   int n;
    cin>>n;
    int cnt = 0;
    for(int c = 1;c<=n;c++){
        int prod = n - c;
        for(int i =1;i*i<=prod;i++){
            if(prod%i==0){
                int j = prod/i;
                cnt++;
                if(j!=i)
                cnt++;
            }
        }
    }
    cout<<cnt<<'\n';
   
}
int main(){
    IOS;
    int tt;
    tt = 1;
    // cin>>tt;
    int i = 1;
    while(tt--){
        // cout<<"tc "<<i<<" ";
        solve();
        i++;
    }
    return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
import bisect

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

    B = []
    t = 0
    for a in A:
        t += a
        B.append(t)

    T = B[N - 1]

    i2 = bisect.bisect_left(B, T / 2, lo = 1, hi = N - 2)
    i1 = bisect.bisect_left(B, B[i2] / 2, hi = i2)
    i3 = bisect.bisect_left(B, (T + B[i2]) / 2, lo = i2 + 1)

    P = B[i1]
    Q = B[i2] - B[i1]
    R = B[i3] - B[i2]
    S = T - B[i3]

    min_d = max(P, Q, R, S) - min(P, Q, R, S)
    min_half = T / 2 - min_d
    max_half = T / 2 + min_d

    i2_lo = bisect.bisect_left(B, min_half, lo = 1, hi = N - 2)
    i2_hi = bisect.bisect_left(B, max_half, lo = i2_lo, hi = N - 2) + 1

    for i2 in range(i2_lo, i2_hi):
        if min_d * 2 < abs(T - 2 * B[i2]):
            continue

        i1 = bisect.bisect_left(B, B[i2] / 2, hi = i2)
        i3 = bisect.bisect_left(B, (T + B[i2]) / 2, lo = i2 + 1)
        i1_lo, i1_hi = i1, i1 + 1
        i3_lo, i3_hi = i3, i3 + 1
        if B[i1] * 2 != B[i2] and 0 < i1:
            i1_lo -= 1
        if B[i3] * 2 != T + B[i2] and i2 + 1 < i3:
            i3_lo -= 1

        for i1 in range(i1_lo, i1_hi):
            P = B[i1]
            Q = B[i2] - B[i1]
            for i3 in range(i3_lo, i3_hi):
                R = B[i3] - B[i2]
                S = T - B[i3]
                d = max(P, Q, R, S) - min(P, Q, R, S)
                if d < min_d:
                    min_d = d


    print(min_d)


if __name__ == '__main__':
    main()



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


void solve(long long N, long long A, long long B){
    cout << min(N * A, B) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#define f(cnt) (((cnt) + 1) * (cnt) / 2)
#define watch(x) cout << (#x) << " = " << x << endl;

const double PI = 2 * acos(0.0);

template<typename T>
struct edge {
    int from, to;
    T w;
    edge(int from, int to, T w): from(from), to(to), w(w) { }
    edge() { }
};


template<class T>
void show(T a) {
    for (auto x : a)
        cout << x << " ";
    cout << endl;
}

const int N = 1e5 + 9;
bool a[N];
int n;

inline bool is_palindromic() {
    for (int i = 1; i <= n; ++i)
        if (a[i] != a[n - i]) return false;
    return true;
}

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

    string s;
    cin >> s;
    n = s.size();
    for (int i = 0; i < n; ++i) {
        a[i + 1] = s[i] == '1';
    }
    if (!a[1] || a[n] || !is_palindromic()) {
        cout << "-1";
        return 0;
    }
    int cur = 1;
    vector<pii> ans;
    for (int i = 1; i < n; ++i) {
        ans.push_back({i + 1, cur});
        if (a[i]) {
            cur = i + 1;
        }
    }
    for (auto p : ans) {
        cout << p.first << " " << p.second << "\n";
    }
}

Measured memory_bytes: 2500
XS = list(map(int, open(0).read().split()))
for i in range(0, len(XS), 3):
    m, f, r = XS[i:i+3]
    if m == -1 and f == -1 and r == -1:
        break

    t = m + f
    if m == -1 or f == -1:
        print("F")
    elif t >= 80:
        print("A")
    elif t >= 65:
        print("B")
    elif t >= 50:
        print("C")
    elif t >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5592
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0)->ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
int fact[int(2e5+1)];
int inv[int(2e5+1)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

/*  FUCNTION TEMPLATE ENDS HERE */
void cal()
{
  fact[0]=1;
  inv[0]=1;
  for(int i=1;i<int(2e5+1);++i)
  {
    fact[i]=(1LL*fact[i-1]*i)%mod;
    inv[i]=exp(fact[i],mod-2,mod)%mod;//always use 1ll at first
  }

}
int ncr(int n,int r)
{
  if(n-r==0||r==0)return 1;
  int cal1=fact[n];
  int cal2=inv[r];
  int cal3=inv[n-r];
  return (1LL*((1ll*cal1*cal2)%mod)*cal3)%mod;

}
int main()
{
   VALHALLA  
   int h,w,a,b;
   cin>>h>>w>>a>>b;
   cal();
   int ans=0;
   for(int i=1;i<=h-a;++i)
   {
      int cal1=ncr(i-1+b-1,i-1);
      int cal2=ncr(h-i+w-b-1,h-i);
      ans+=(1ll*cal1*cal2)%mod;
      ans%=mod;
   }
   cout<<ans;
   
   


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb push_back()
#define popb pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
int main(){
    string s;cin>>s;
    vector<int> count(s.size());
    rep(i,s.size()){
        char a=s[i];
        if((a=='A')+(a=='C')+(a=='G')+(a=='T')){
            count[i]=1;
        }else{
            count[i]=0;
        }
    }
    int ans=count[0];
    rep(i,1,s.size()){
        if(count[i]){
            count[i]+=count[i-1];
            ans=max(ans,count[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 100000007
# define INF 100000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=100005;

map<int,int>vis;

int main ()
{
    int n, x, ans=0;
    scanf("%d",&n);
    FOR(i,1,n) scanf("%d",&x), ++vis[x];
    for (auto i=vis.begin(); i!=vis.end(); ++i) {
        if (i->first <= i->second) ans+=i->second-i->first;
        else ans+=i->second;

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



Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
main(){
  while(1){
    string s;
    cin>>s;
    if(s=="#") break;
    long long now=0;
    int root[6][2]={{1,2},{-1,3},{1,-1},{4,5},{5,2},{2,1}};
    for(int i=0;i<s.size();i++){
      if(now==-1){
	break;
      }
      now=root[now][s[i]-'0'];
    }
    if(now==5) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;

vector<P> G;
signed main(){
	int h, w, n;
	scanf("%lld%lld%lld", &h, &w, &n);
	
	for(int i = 0;i < n;i++){
		int x[2], y[2];
		scanf("%lld%lld%lld%lld", &y[0], &x[0], &y[1], &x[1]);
		if(y[0] && y[0] != h && x[0] && x[0] != w)continue;
		if(y[1] && y[1] != h && x[1] && x[1] != w)continue;
		
		for(int j = 0;j < 2;j++){
			if(y[j] == 0)G.push_back(P(x[j], i));
			else if(x[j] == w)G.push_back(P(w+y[j], i));
			else if(y[j] == h)G.push_back(P(h+w+(w-x[j]), i));
			else G.push_back(P(2*w+h+(h-y[j]), i));
		}
	}
	sort(G.begin(), G.end());
	
	stack<int> st;
	for(int i = 0;i < G.size();i++){
		int p = G[i].second;
		if(!st.empty()){
			if(st.top() == p)st.pop();
			else st.push(p);
		}else st.push(p);
	}
	if(st.empty())printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 6000
//abc117_b.cpp
//Thu Feb  7 21:18:14 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	sort(l,l+n);

	int longest = l[n-1];
	int others = 0;
	for (int i=0;i<n-1;i++){
		others += l[i];
	}

	if (longest < others){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <cmath>
#define F first
#define S second
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int n,w;
int V[120],W[120];
int dp[11000]={};

int main()
{
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		cin>>V[i]>>W[i];
	}

	for(int i=0;i<=w;i++)
	{
		for(int l=0;l<n;l++)
		{
			dp[i+W[l]]=max(dp[i+W[l]],dp[i]+V[l]);
		}
	}
	cout<<dp[w]<<endl;
	return 0;

}

Measured memory_bytes: 1204
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i < x + k; ++i) cout << i << " ";
}


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

#define _ << ": " <<
#define watch1(var1) cerr << (#var1) _ var1 << '\n'
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n'
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n'
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < int(size); i++) cerr << arr[i] << " \n"[i+1 == int(size)]

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ll long long
#define ints(a...) int a; read(a)
#define IN(a) for (auto &it : a) cin >> it

int dp[(int)1e5 + 1][3];

void solve() {
    ints(n); 
    read(dp[1][0], dp[1][1], dp[1][2]);
    for (int i = 2; i <= n; i++) {
        ints(a, b, c);
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c;
    }
    show(max({dp[n][0], dp[n][1], dp[n][2]}));
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 4792
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m,p;
  while(cin>>n>>m>>p,n+m+p){
    vector<int>pl(n);
    int sum=0;
    for(int i=0;i<n;i++){
      cin>>pl[i];
      sum+=pl[i];
    }
    sum*=(100-p);
    int ans=0;
    if(pl[m-1]==0){
      ans=0;
    }else{
      ans=sum/pl[m-1];
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3004
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

const int N=1e5+5;
int n;
ll l,t;
ll x[N];
int w[N];

int main() {
        cin >> n >> l >> t;
        for (int i=0; i<n; i++)
                cin >> x[i] >> w[i];

        ll inc=0;
        for (int i=1; i<n; i++) {
                if (w[i] != w[0]) {
                        ll first2 = abs(x[i]-x[0]);
                        if (w[0] == 1 && x[0] > x[i])
                                first2 = l-first2;
                        else if (w[0] == 2 && x[0] < x[i])
                                first2 = l-first2;
                        if (2*t >= first2)
                                inc += 1 + (2*t-first2)/l;
                }
        }
        inc %= n;
        if (w[0] == 2)
                inc = (n-inc)%n;

        vector<pair<ll,pair<int,int> > > pos;
        for (int i=0; i<n; i++) {
                ll ps = ((x[i]+(3-2*w[i])*t)%l+l)%l;
                pair<int,int> pi = make_pair(-w[i],i);
                pos.push_back(make_pair(ps,pi));
        }
        sort(pos.begin(),pos.end());

        int ant0;
        for (int i=0; i<n; i++) {
                if (pos[i].second.second == 0)
                        ant0 = i;
        }

        for (int i=0; i<n; i++) {
                int cur = (ant0-inc+i+n)%n;
                cout << pos[cur].first << "\n";
        }
}

Measured memory_bytes: 4080
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.trim().split('\n')[0]

const ans = _ => {
  let head,
    cCount = 0,
    lCase = true

  for (let i = 0; i < s.length; i++) {
    if (i === 0) {
      head = s[i] === 'A'
    } else if (i >= 2 && i < s.length - 1) {
      if (s[i] === 'C') cCount++
    } else {
      lCase = lCase && isLowerCase(s[i])
    }
  }

  const mid = cCount === 1

  return head && mid && lCase ? 'AC' : 'WA'
}

const isLowerCase = str => str === str.toLowerCase()

console.log(ans())


Measured memory_bytes: 11468
#include <iostream>
#include <vector>
#include <utility>              // swap
using namespace std;

int bubbleSort(vector<int>& A) {
    bool flag = true;
    int i = 0;
    int cnt = 0;                // 交換した回数

    while (flag) {
        flag = false;
        for (auto j = A.size()-1; j >= i+1; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                flag = true;
                cnt++;
            }
        }
        i++;
    }
    return cnt;
}

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

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

    int ans = bubbleSort(ary);
    for (auto i = 0; i < ary.size(); i++) {
        cout << (i ? " " : "") << ary[i];
    }
    cout << endl;
    cout << ans << endl;

    return 0;
}

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

int main(void){
    string w;
    cin >> w;

    int n = w.size();

    bool flag = true;

    for(int i = 0; i < n; i++){
        int cnt = 0;
        for(int j = 0; j < n; j++){
            if(w.at(j) == w.at(i)) cnt++;
        }
        if(cnt % 2 == 1) flag = false;
    }

    if(flag) {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int s;
  int a,b,c,d;
  int flag_l = 0,flag_r = 0;
  cin >> s;
  a = s%10;
  s /= 10;
  b = s%10;
  s /= 10;
  c = s%10;
  d = s/10;
  
  if(d == 1 && c < 3){
    flag_l=1;
  }else if(d==0 && c > 0){
    flag_l=1;
  }
  
  if(b == 1 && a < 3){
    flag_r=1;
  }else if(b==0 && a > 0){
    flag_r=1;
  }
  
  if(flag_l==1 && flag_r==1){
    cout << "AMBIGUOUS" << endl;
  }else if(flag_l==0 && flag_r==1){
    cout << "YYMM" << endl;
  }else if(flag_l==1 && flag_r==0){
    cout << "MMYY" << endl;
  }else if(flag_l==0 && flag_r==0){
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        long[] b = new long[n];
        long[] r = new long[n];

        for(int i = 0;i < n;i++) {
            b[i] = stdIn.nextLong() * 2;
        }

        r[0] = 0;
        for(int i = 0; i < n;i++) {
            if(i % 2 == 0) {
                r[0] += b[i];
            }else {
                r[0] -= b[i];
            }
        }
        r[0] /= 2;

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

    
       

        for(long i : r) {
            System.out.println(i);
        }
        
        
    }
}


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

bool has3(int x){
	while (x) {
		if (x % 10 == 3)return true;
		x /= 10;
	}
return false;
}

void call(int n) {
	for (int x = 1; x <= n; x++) {
		if (x % 3 == 0 || has3(x)) {
			cout << " " << x;
		}
	}
	cout << endl;
}

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

	return 0;
}

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

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

   if (A >= K)
      cout << A-K << " " << B << endl;
   else if (K > A+B)
      cout << 0 << " " << 0 << endl;
   else
      cout << 0 << " " << B-(K-A) << endl;

}



Measured memory_bytes: 256
<?php

$n = (int)trim(fgets(STDIN));

$input = explode(' ', trim(fgets(STDIN)));
$l = [];
foreach ($input as $str) {
	$l[] = (int)$str;
}
sort($l);

$sum = 0;
for ($i=0; $i < $n-1; $i++) { 
	$sum += $l[$i];
}

if ($sum > $l[$n-1]) {
	echo 'Yes';
}else{
	echo 'No';
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX


string s;

signed main() {
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    else if (s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, X[201010], A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> X[i];
    rep(i, 0, N) A[i] = X[i];
    sort(A, A + N);

    map<int, int> idx;
    rrep(i, N - 1, 0) idx[A[i]] = i;

    rep(i, 0, N) {
        int j = idx[X[i]];
        if (j < N / 2) printf("%d\n", A[N / 2]);
        else printf("%d\n", A[N / 2 - 1]);
    }
}

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

int main(){
  int n;
  cin >> n;
  if(n % 4 == 0){
    cout << "Yes" << endl;
    return 0;
  }
  for(int k = n; k > 0; k -= 4){
    if(k % 7 == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
 long a,v,b,w,t; cin>>a>>v>>b>>w>>t;
 // string s; cin>>s;
  
  if(a==b)cout<<"YES";
  else if(a<b){cout<<(a+v*t>=b+t*w?"YES":"NO");}
  else {cout<<(a-v*t<=b-t*w?"YES":"NO");}
  
  
}


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

m=-1

for i in range(3,1000,2):
    if i*i==8*n+1:
        m=(1+i)//2

if m==-1:
    print('No')
    exit(0)

cnt=1
s=[[0] for _ in range(m+1)]

for i in range(1,m+1):
    for j in range(i+1,m+1):
        s[i][0]+=1
        s[j][0]+=1

        s[i].append(cnt)
        s[j].append(cnt)

        cnt+=1

print('Yes')
print(m)
for i in range(1,m+1):
    print(' '.join([str(c) for c in s[i]]))

Measured memory_bytes: 75416
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N, M;
  cin >> N >> M;
  vector<ll> A(N), B(N);
  vector<ll> C(M), D(M);
  for(int i=0; i<N; i++)
    cin >> A[i] >> B[i];
  for(int i=0; i<M; i++)
    cin >> C[i] >> D[i];
  for(int i=0; i<N; i++) {
    ll dis = 1000000000;
    int ans = 0;
    for(int j=0; j<M; j++) {
      if(dis > abs(C[j] - A[i]) + abs(D[j] - B[i])) {
	dis = abs(C[j] - A[i]) + abs(D[j] - B[i]);
	ans = j+1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256