akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define N 5010
#define ll long long
using namespace std ;
const int mod=1e9+7;
int n;
char s[N];
int f[N][N] ;
ll power(ll a,ll b) {
	ll ans=1,base=a;
	while(b){
		if(b&1)ans=(ans*base)%mod ;
		base=(base*base)%mod ;
		b/=2;
	}
	return ans%mod;
}
int main(){
	scanf("%d%s",&n,s+1);
	int len=strlen(s+1);
	f[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++) {
			f[i+1][j+1]+=2*f[i][j];
			f[i+1][j+1]%=mod;
			f[i+1][max(j-1,0)]+=f[i][j];
			f[i+1][max(j-1,0)]%=mod;
		}
	}
	ll ans=1ll*power(power(2,len),mod-2)%mod*f[n][len];
	ans%=mod;
	cout<<ans;
	return 0 ;
} 

Measured memory_bytes: 70556
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

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

		int n = sc.nextInt();
		Integer[] d = new Integer[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}

		Arrays.sort(d, Collections.reverseOrder());

		int ans = 1;
		for (int i = 1; i < n; i++) {
			if (d[i - 1] > d[i])
				ans++;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23636
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
import scipy
from collections import deque
#https://atcoder.jp/contests/abc141/tasks/abc141_d
#D - Powerful Discount Tickets
"""
need to consider the case that ticket is not enough to lower everything
"""
N = gi()
K = gi()
S = gw()

seg_cnt = 0
for i in range(0, N - 1):
    if S[i] != S[i + 1]:
        seg_cnt += 1

cur_happy = N - 1 - seg_cnt

if 2 * K >= seg_cnt:
    ans = N - 1
else:
    ans = cur_happy + 2 * K

print(ans)


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


int main()
{
	int N;
	cin>>N;
	map<int,int> m;
	rep(i,N)
	{
		int a;
		cin>>a;
		for(int j=-1;j<=1;j++)
		{
			m[a+j]++;
		}
	}
	int ans=0;
	for(auto p : m)
	{
		ans=max(ans,p.second);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7968
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int X = Integer.parseInt(N);
		String[] s = N.split("");
		int har = 0;
		for(int i = 0; i < s.length; i++) {
			har += Integer.parseInt(s[i]);
		}
		if(X % har == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  char a;
  cin >> a;
  if(a > 'Z') cout << "a\n";
  else cout << "A\n";
  return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Cube cube = new Cube(br);
		char[] act = br.readLine().toCharArray();
		cube.roll(act);
		System.out.println(cube.top);
	}
}

class Cube {
	String[] num;
	String top;
	String center;
	String back;
	String bottom;
	String right;
	String left;
	String temp;

	Cube(BufferedReader br) throws IOException {
		num = br.readLine().split(" ");
		this.top = num[0];
		this.center = num[1];
		this.right = num[2];
		this.left = num[3];
		this.back = num[4];
		this.bottom = num[5];
	}

	void south() {
		temp = this.top;
		this.top = this.back;
		this.back = this.bottom;
		this.bottom = this.center;
		this.center = temp;
	}

	void north() {
		temp = this.top;
		this.top = this.center;
		this.center = this.bottom;
		this.bottom = this.back;
		this.back = temp;
	}

	void east() {
		temp = this.top;
		this.top = this.left;
		this.left = this.bottom;
		this.bottom = this.right;
		this.right = temp;
	}

	void west() {
		temp = this.top;
		this.top = this.right;
		this.right = this.bottom;
		this.bottom = this.left;
		this.left = temp;
	}

	void roll(char[] act) {
		for (int i = 0; i < act.length; i++) {
			switch (act[i]) {
			case 'S':
				south();
				break;
			case 'N':
				north();
				break;
			case 'E':
				east();
				break;
			case 'W':
				west();
				break;
			}
		}
	}
}

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

int main(){
  int n, ac=0, wa=0, tle=0, re=0;
  string a;
  cin >> n;
  
  for(int i=0; i < n; i++){
    cin >> a;
    if(a == "AC") ac++;
    if(a == "WA") wa++;
    if(a == "TLE") tle++;
    if(a == "RE") re++;
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 3576
import java.util.Scanner;
import java.math.BigInteger;

public class Main{
    public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
	int N = scanner.nextInt();
	for (int i = 0; i < N; i++) {
	    String a = scanner.next(), b = scanner.next();
	    BigInteger A = new BigInteger(a), B = new BigInteger(b);
	    BigInteger sum = A.add(B);
	    if ((sum.toString()).length() > 80) {
		System.out.println("overflow");
	    }
	    else {
		System.out.println(sum.toString());
	    }
	}
    }
}

Measured memory_bytes: 12000
mod = 10 ** 9 + 7
N, M = map(int, input().split())

class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % mod
            self.inv[i] = -self.inv[mod % i] * (mod // i) % mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % mod) % mod

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

comb = Combination(M + 100)

A = comb.npr(M, N) % mod

B = 0
for i in range(N + 1):
    B += (-1) ** i * comb.ncr(N, i) * comb.npr(M - i, N - i) % mod

print(A * B % mod)

Measured memory_bytes: 98548
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,t;
  cin>>n>>t;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  ll sum=0;
  reps(i,t,n) if(a[i]>0) sum+=a[i];
  ll s=0;
  rep(i,t) s+=a[i];
  ll re=0;
  rep(i,n-t+1){
    //cout<<pii(sum,s)<<endl;
    MX(re,sum+max(s,0ll));
    if(i==n-t) break;
    s-=a[i];
    s+=a[i+t];
    if(a[i]>0) sum+=a[i];
    if(a[i+t]>0) sum-=a[i+t];
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 640
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))

##### main #####



def main():
	a,b, c,d = LI()
	if a+b == c+d:
		print("Balanced")
	else:
		print("Left" if a+b>c+d else "Right")

if __name__ == '__main__':
	main()

Measured memory_bytes: 3568
#include <stdio.h>

int main( void ) {
	int i, n;
	double debt = 100000;

	scanf( "%d", &n );

	for ( i = 0; i < n; i++ ) {
		debt *= 1.05;

		if ( debt / 1000 > (int)debt / 1000 )
			debt = ( (int)debt / 1000 + 1 ) * 1000;
	}

	printf( "%.0f\n", debt );

	return 0;
}

Measured memory_bytes: 628
#include <stdio.h>

int main(){
  int m, d, i, j;
  char today[7][10] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
  while(scanf("%d%d", &m, &d) && m && d){
    switch(m){
    case 12:
      d += 30;
    case 11:
      d += 31;
    case 10:
      d += 30;
    case 9:
      d += 31;
    case 8:
      d += 31;
    case 7:
      d += 30;
    case 6:
      d += 31;
    case 5:
      d += 30;
    case 4:
      d += 31;
    case 3:
      d += 29;
    case 2:
      d += 31;
      break;
    }

    printf("%s\n", today[d % 7]);
  }
  return 0;
}

Measured memory_bytes: 584
function combination(input) {
	var max = parseInt(input.split(" ")[0]);
	var sum = parseInt(input.split(" ")[1]);
	var count = 0;
	if(sum <= max){
		for(var x = 0; x < sum+1; x++){
			for(var y = 0; y < sum+1-x; y++){
						count++;
			}
		}
	} else if (sum > max){
		for(var x = 0; x < max+1; x++){
			if(sum-x <= max){
				for(var y = 0; y < sum+1-x; y++){
						count++;
				}
			}else if(sum-x > max){
				for(var y = 0; y < max+1; y++){
					if(sum-x-y <= max){
						count++;
					}else if(sum-x-y > max){

					}
				}
			}
		}
	}
	console.log(count);
}

combination(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N,M = map(int,input().split())
K=[0]*(N+1)
for i in range(M):
  a,b=map(int,input().split())
  if a==1:
    K[b] +=1
  if b == N:
    K[a] +=1
print('POSSIBLE' if 2 in K else 'IMPOSSIBLE')

Measured memory_bytes: 4596
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++) cin>>h[i];

  int dp[n];
  dp[0]=h[0];
  for(int i=1;i<n;i++) dp[i]=0;

  for(int i=1;i<n;i++)
  {
    if(h[i]==h[i-1]) dp[i]=dp[i-1];
    else if(h[i]>h[i-1]) dp[i]=dp[i-1]+(h[i]-h[i-1]);
    else dp[i]=dp[i-1];
  }

  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 256
x,k,d = gets.chomp.split(' ').map(&:to_i)
x = x.abs
closest_1 = x%d
ans = x
if x/d > k
    ans -= k*d
else
    k -= x/d
    if k.even?
        ans = closest_1
    else
        ans = [(closest_1-d).abs,(closest_1+d).abs].min
    end
end

puts ans

Measured memory_bytes: 14352
n, k, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()] + [-1]
ans = 10**15
for min_val in a[:-1]:
    takeble = []
    l, r = -1, -1 
    for i, item in enumerate(a):
        if item >= min_val and l == -1:
            l = i
        elif item < min_val and l != -1:
            r = i
            takeble.append(a[l:r])
            l = -1
    taken = []
    for part in takeble:
        if len(part) < k:
            continue
        part.sort()
        taken += part[:len(part)-k+1]
    if len(taken) < q:
        continue
    taken.sort()
    ans = min(ans, taken[q-1] - taken[0])
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N_MAX 1000003
#define LENGTH 16

int get_key(char entry[LENGTH]){
	int times = 1, value, key, i;

	key = 0;
	for(i=0; i<strlen(entry); ++i){
		if      ('A' == entry[i]){
			key += 1*times;
		}else if('C' == entry[i]){
			key += 2*times;
		}else if('T' == entry[i]){
			key += 3*times;
		}else if('G' == entry[i]){
			key += 4*times;
		}
		times *= 5;
	}
	return key;
}
int hash1(int key){
	return key % N_MAX;
}
int hash2(int key){
	return 1 + (key % (N_MAX - 1));
}
int hash(int key, int times){
	return (hash1(key) + times*hash2(key)) % N_MAX;
}
int insert(char (*dictionary)[LENGTH], char entry[LENGTH]){
	int entry_key, i = 0, hash_value;

	entry_key = get_key(entry);
	while(1){
		hash_value = hash(entry_key, i);
		if(0 == strcmp(dictionary[hash_value], entry)){
			return 1;
		}else if(0 == strlen(dictionary[hash_value])){
			strcpy(dictionary[hash_value], entry);
			return 0;
		}
		++i;
	}
	return 0;
}
int search(char (*dictionary)[LENGTH], char entry[LENGTH]){
	int entry_key, i=0, hash_value;

	entry_key = get_key(entry);
	while(1){
		hash_value = hash(entry_key, i);
		if(0 == strcmp(dictionary[hash_value], entry)){
			return 1;
		}else if(0 == strlen(dictionary[hash_value])){
			return 0;
		}
		++i;
	}
	return 0;
}

int main(void){
	int n, i;
	char query[8], entry[LENGTH];
	char (*dictionary)[LENGTH];

	dictionary = malloc(sizeof(char)*N_MAX*LENGTH);
	for(i=0; i<N_MAX; ++i)
		dictionary[i][0] = '\0';
	scanf("%d", &n);
	for(i=0; i<n; ++i){
		scanf("%s %s", query, entry);
		if(0 == strcmp(query, "insert")){
			insert(dictionary, entry);
		}else if(0 == strcmp(query, "find")){
			if(search(dictionary, entry)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}else{
			continue;
		}
	}
	free(dictionary);
	return 0;
}



Measured memory_bytes: 16912
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0;i < N;++i)
			A[i] = sc.nextInt();
		sc.close();
		
		int ans = 0;
		for(int i = 0;i < N;++i) {
			ans++;
			for(int j = A[i]+1;j <= D;j += A[i]) {
				ans++;
			}
		}
		ans += X;
		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <numeric>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i, n) for(int i = 1; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int> d1(n), d2(n);
	REP(i, n) {
		cin >> d1[i] >> d2[i];
	}
	d1.push_back(1);
	d1.push_back(1);
	d2.push_back(2);
	d2.push_back(2);
	REP(i, n) {
		if (d1[i] == d2[i] && d1[i + 1] == d2[i + 1] && d1[i + 2] == d2[i + 2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n, l;

vector<int> vl;

int main() {
    GI(n);

    FORN(i, 2*n) {
        GI(l);
        vl.PB(l);
    }

    sort(vl.begin(), vl.end());

    int res = 0;
    for (int i = 0; i < 2*n; i += 2) res += vl[i];

    cout << res << endl;
    return 0;
}


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

int main() {
    int A, B, fee;
    cin >> A >> B ;

    // 0~5歳（6歳より小さいならば）
    if (A < 6) { 
        fee = 0;
    } // 6~12歳（13歳より小さいならば）
    else if (A < 13)
    {
        fee = B / 2;
    }// 13歳以上
    else
    {
        fee = B;
    }

    // 結果を出力 
    cout << fee << endl;

    // おまじない？
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int a;cin>>a;
  int b=a/15;
  cout<<a*800-b*200<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 52
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
ll n;
int getres(ll a, ll b) {
	int cnta=0;
	int cntb=0;
	if (a == 0) {
		cnta++;
	} else {
		while(a) {
			cnta++;
			a /= 10;
		}
	}
	if (b == 0) {
		cntb++;
	} else {
		while(b) {
			cntb++;
			b /= 10;
		}
	}
	return max(cnta, cntb);
}
int main() {
	cin>>n;
	int ans = 0;
	for (ll a = 1; a * a <= n; ++a) {
		if (n % a == 0) {
			ll b = n/a;
			if (ans <= 0) {
				ans = getres(a, b);
			} else {
				ans = min(ans, getres(a, b));
			}
			if (a != b) {
				ans = min(ans, getres(b, a));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define LEN 100005
 

unsigned int time[LEN], head, tail;
char name[LEN][10];
 
int main()
{
    int n, runtime;
    head = tail = 0;
 
    scanf("%d %d", &n, &runtime);
    for (int i = 0; i < n; i++) {
        scanf("%s %d", name[i], &time[i]);
        tail++; // always point to empty
    }
 
    int timer = 0; // timer
    while (tail != head) { // Not empty <- Important, different between "tail != head" and "tail - head > 0"
        // Process - not finished
        if (time[head % LEN] > runtime) {
            timer += runtime;
            strcpy(name[(tail) % LEN], name[(head) % LEN]); // str copy
            time[(tail) % LEN] = time[(head) % LEN] -= runtime;
            tail++, head++;
        }
        else {
            timer += time[(head) % LEN];
            printf("%s %d\n", name[(head) % LEN], timer);
            head++;
        }
    }
 
    return 0;
}

Measured memory_bytes: 4076
package main

import (
	"fmt"
)

func main() {
  var K, A, B int
  fmt.Scan(&K, &A, &B)
  if A+2 > B {
    fmt.Println(1 + K)
  } else {
    c := 1
    m := 0
    for i := 1; i <= K; i++ {
      if m > 0 {
        m -= 1
        c += B
      } else if A <= c && i < K {
        m++
        c -= A
      } else {
        c++
      }
    }
    fmt.Println(c)
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
        v.push_back(make_pair(i+1,a[i]));
        //v.push_back(b[i]);
    }
    sort(b,b+n);
    int l=(n/2)-1;
    int r=l+1;
    for(int i=0;i<n;i++){
        //int x=find(v.begin(),v.end(),a[i])-v.begin();
        if(v[i].second<=b[l])cout<<b[r]<<endl;
        else cout<<b[l]<<endl;
    }
    
}

Measured memory_bytes: 5488
<?php
$N=trim(fgets(STDIN));
$A=explode(' ',trim(fgets(STDIN)),$N);

$out=implode(' ',$A).PHP_EOL;
for($i=1;$i<$N;$i++){
  $v=$A[$i];
  $j=$i-1;
  #A[i]????????§????????????????¶????????????????????§????
  while($j>=0 && $A[$j]>$v){
    $A[$j+1]=$A[$j];
    $j--;
  }
  $A[$j+1]=$v;
  $out.=implode(' ',$A).PHP_EOL;
}

print $out;

Measured memory_bytes: 15428
#include <stdio.h>
int main()
{
	int a, b, c, i;
	int syou, kosuu = 0;
	scanf("%d %d %d", &a, &b, &c);
	for (i = a; i <= b; i++){
		syou = c / i;
		if (c % i == 0)
			kosuu++;
	}
	printf("%d\n", kosuu);
	return 0;
}

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

// #define long long long 

template <typename T> void read_stdin(const size_t size, vector<T>& array)
{
   T value;
   for (size_t i(0); i < size; ++i) {
      cin >> value;
      array.push_back(value);
   }
}

template <typename T> void output_stdout(const vector<T>& array)
{
   for (const auto& value : array) {
      cout << value << endl;
   }
}

int main() {
   int N;
   string outputA("No");

   // read
   {
      cin >> N;
   }

   // process
   {
      for (size_t i(1); i < 10; ++i) {
         if ((0 == N % i) && (N / i < 10)) {
            outputA = "Yes";
            break;
         }
      }
   }

   // output
   {
      cout << outputA << endl;
   }
   
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m;
	cin>>n;
	vi a(n+1),dp(n+1),pref(n+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	dp[0] = 0;
	dp[1] = 0;
	pref[1] = a[1];
	for(int i=3;i<=n;i+=2){
	    pref[i] = a[i]+pref[i-2];
	}
	for(int i=2;i<=n;i++){
	    if(i&1){
	    	dp[i] = max(dp[i-2]+a[i], dp[i-1]);
	    }
	    else{
	    	dp[i] = max(dp[i-2]+a[i], pref[i-1]);
	    }
	}

	cout<<dp[n];
	
	

	return 0;
}







Measured memory_bytes: 7928
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  if(S=="SUN"){
    cout<<7<<endl;
  }
  else if(S=="MON"){
    cout<<6<<endl;
  }
  else if(S=="TUE"){
    cout<<5<<endl;
  }
  else if(S=="WED"){
    cout<<4<<endl;
  }
  else if(S=="THU"){
    cout<<3<<endl;
  }
  else if(S=="FRI"){
    cout<<2<<endl;
  }
  else {
    cout<<1<<endl;
  }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int a, b;
  fscanf(stdin, "%d %d", &a, &b);
  while (b) {
    int c = a % b;
    a = b;
    b = c;
  }
  fprintf(stdout, "%d\n", a);
  return 0;
}

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const ll mod=1e9+7;
int main()
{
    cin.tie( 0 );
    ios::sync_with_stdio( false );
	
	ll a,b,c,d;
	cin>>a>>b>>c>>d;

	ll a1=a-1;
	ll tmp=b/c-a1/c + b/d-a1/d;
	
	ll x=c*d;
	if(c<d){
		ll tmp=c;
		c=d;
		d=tmp;
	}
	ll r=c%d;
	while(r!=0){
		c=d;
		d=r;
		r=c%d;
	}
	ll e=x/d;
	tmp-=b/e-a1/e;

	ll ans=b-a+1-tmp;
	cout << ans << endl;
    return 0;
}

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

int main() {
string s,t;
cin >> s >> t;
vector<char> a(s.size());
vector<char> b(t.size());

sort(s.begin(), s.end());
sort(t.begin(), t.end());
reverse(t.begin(), t.end());

if(s<t)
{
	cout << "Yes" << endl;
}
else
{
	cout << "No" << endl;
}
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

balance = 1000
position = A[0]

for i in range(1,N):
    if A[i] > position:
        balance = (balance//position)*A[i] + balance%position
        position = A[i]
    else: position = A[i]

print(balance)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int Count(int n){
  int cou = 0;
  for (int i=1; i<=n; i++){
    if (n%i == 0) cou++;
  }
  return cou;
}

int main(){
  int n; cin>>n;
  int ans = 0;
  for (int i=1; i<=n; i++){
    if (i%2==1){
      if (Count(i)==8) ans++;
    }
  }
  cout << ans << endl;
}

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


int main(){
  const int MOD=1000000007;
  int N;
  cin >> N;
  int64_t retval = 1;
  for (int i=1;i<=N;i++){
    retval *= i;
    retval %= MOD; 
  }

  cout << retval << endl;
}
 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int n, i, j;
  int C[VMAX+1];
 unsigned short *A,*B;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

for(i=0;i<=VMAX;i++) {
  C[i]=0;
}
  for (i = 0; i < n; i++) {
    scanf("%hd",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++) C[i]=C[i]+C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i==n)  printf("%d\n",B[i]);
    else printf("%d ",B[i]);
  }
  return 0;
}



Measured memory_bytes: 9656
// 
	#include<bits/stdc++.h> 
	#include <sstream> 
	using namespace std; 
	typedef long long ll;
	inline bool cmp(pair< ll , ll > &a , pair< ll , ll >  &b){
		if(a.first != b.first)
			return a.first > b.first;
		else
			return a.second < b.second;
	}

	int main() 
	{ 
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    int a , b;
	    cin >> a >> b;
	    cout << 6 - (a + b) << endl;
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define rep(a,b,c) for(int a=(int)b;a<(int)c;a++)
#define repk(a,b,c,k) for(int a=(int)b;a<(int)c;a+=(int)k)
#define comeback std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define int long long int
#define pii pair<int,int>
#define ful(a) a.begin(),a.end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
using namespace std;
int em(int x,int n)
{
    if(n==0)
    return 1;
    else if(n%2==0)
    return em((x%mod*x%mod)%mod,n/2);
    else
    return (x%mod*em((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
vector<int>v[100009];
int vis[100009];
int dis[100009];
int dfs(int x)
{
	if(vis[x])
		return dis[x];
	vis[x]=1;
	for(int y:v[x])
		dis[x]=max(dis[x],1+dfs(y));
	return dis[x];
}
signed main()
{
	comeback
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output1.txt","w",stdout);
	#endif*/
		int n,m,i,j,k,l,b,c;
		cin>>n>>m;
		for(i=1;i<=n;i++)
			v[i].clear();
		for(i=0;i<m;i++){
			cin>>b>>c;
			v[b].pb(c);
		}
		memset(dis,0,sizeof(dis));
		for(i=1;i<=n;i++){
			if(!vis[i])
				dfs(i);
		}
		int maxi=0;
		for(i=1;i<=n;i++)
			maxi=max(maxi,dis[i]);
		cout<<maxi;

}

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

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    mint ans = 1;
    ll count = 0;
    for(char c : s){
        if(c == 'W'){
            if(count == 0){
                cout << 0 << endl;
                return 0;
            }else if(count % 2 == 1){
                count++;
            }else{
                ans *= count;
                count--;
            }
        }else if(c == 'B'){
            if(count % 2 == 1){
                ans *= count;
                count--;
            }else{
                count++;
            }
        }
    }
    if(count != 0){
        cout << 0 << endl;
    }else{
        REP(i, n){ ans *= i + 1; }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3736
#include<stdio.h>

int selectionSort(int A[], int N){
	int i,j,t,sw=0,mini;
	for(i=0;i<N-1;i++){
		mini = i;
		for(j=i; j<N; j++){
			if(A[j] < A[mini]) mini = j;
		}
		t = A[i]; A[i] = A[mini]; A[mini] = t;
		if (i != mini) sw++;
	}
	
	return sw;
}

int main(){
	int A[100], N,i,sw;
	scanf("%d", &N);
	for(i=0; i<N; i++) scanf("%d", &A[i]);
	
	sw = selectionSort(A,N);
	
	for(i=0; i<N; i++){
		if(i>0) printf(" ");
		printf("%d", A[i]);
		
	}
	
	printf("\n");
	printf("%d\n",sw);
	
	return 0;
}

Measured memory_bytes: 2752
n = int(input())
a = list(map(int, input().split()))

sa = [0, 0]
count = [0, 0]

for i in range(n):
    sa[0] += a[i]
    if sa[0] <= 0 and i%2 == 0:
        count[0] += 1 - sa[0]
        sa[0] = 1
    elif sa[0] >= 0 and i%2 == 1:
        count[0] += 1 + sa[0]
        sa[0] = -1

    sa[1] += a[i]
    if sa[1] <= 0 and i%2 == 1:
        count[1] += 1 - sa[1]
        sa[1] = 1
    elif sa[1] >= 0 and i%2 == 0:
        count[1] += 1 + sa[1]
        sa[1] = -1

print(min(count))

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

public class Main {
    int n;
    String s;
    long sum = 0;
    boolean[] splitAts;
    void run() {
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        n = s.length();
        splitAts = new boolean[n - 1];
        dfs(0);
        System.out.println(sum);
    }

    void dfs(int i) {
        if (i == n - 1) solve(splitAts);
        else {
            splitAts[i] = false;
            dfs(i + 1);
            splitAts[i] = true;
            dfs(i + 1);
        }
    }

    void solve(boolean[] arr) {
        int current = 0;
        for (int i = 0; i < n - 1; i++) {
            if (arr[i]) {
//                debug("sub", s.substring(current, i + 1));
                sum += Long.parseLong(s.substring(current, i + 1));
                current = i + 1;
            }
//            debug(sum);
        }
        sum += Long.parseLong(s.substring(current, n));
    }

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

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

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <stdio.h>

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

int main(){
    int n; cin >> n;
    char s[n];
    rep(i,n) cin >> s[i];
    
    int ans = 1;
    
    char now = s[0];
    rep(i,n){
        if (s[i] != now) {
            now = s[i];
            ans++;
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
    int N,i,j;
    scanf("%d",&N);
    int H[N];
    int diff[N];
    int next_start=1;
    int count_same=0;

    for(i=0;i<N;i++){
        scanf("%d",&H[i]);
        diff[i]=0;
        if(i>=1){
            if(H[i]<H[i-1]){
                H[i-1]-=1;
                for(j=i-2;j>=0;j--){
                    if(H[j]==H[i-1]+1){
                        if(diff[j]==0){
                            H[j]-=1;
                        }else{
                            break;
                        }
                    }else{
                        break;
                    }
                }
                diff[i-1]=1;
                if(i>=2){
                    if(H[i-1]<H[i-2] && diff[i-2]==0){
                        H[i-2]-=1;
                    }
                }
            }
        }
    }
    
    for(i=1;i<N;i++){
        if(H[i]<H[i-1]){
            printf("No\n");
            break;
        }
    }

    if(i==N){
        printf("Yes\n");
    }
    return 0;
}

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

int main(){
  long int N;
  cin >>N;
  int a;
  vector<int>memo(N+1);
  for(int i=2;i<=N;i++){
  	cin>>a;
  	memo.at(a)++;
  }
  for(int i=1;i<=N;i++){
  	
  	cout <<memo[i]<<endl;
  }
  
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int len;
vector <string> v;
void iso (string cur, char maxi){
    if (cur.length()==len){
        v.push_back(cur);
        return;
    }
    for (char i='a'; i<=maxi+1; i++) iso(cur+i, max(i, maxi));
}
int main(){
    cin>>len;
    iso("a", 'a');
    sort (v.begin(), v.end());
    for (int i=0; i<v.size(); i++) cout<<v[i]<<endl;
}

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

int main(void){

    string b1, b2;
    cin >> b1;

    if (b1=="A")
        b2 = "T";
    else if (b1=="T")
        b2 = "A";
    else if (b1=="C")
        b2 = "G";
    else if (b1=="G")
        b2 = "C";
    
    cout << b2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string word;
    cin >> word;
    int q;
    cin >> q;
    for (int i=0;i<q;i++) {
        string order;
        cin >> order;
        if ( order == "print" ) {
            int print1,print2;
            cin >> print1 >> print2;
            string print = word.substr(print1,print2-print1+1);
            cout << print << endl;
        } else if ( order == "replace" ) {
            int rep1,rep2;
            cin >> rep1 >> rep2;
            string p;
            cin >> p;
            word = word.replace(rep1, rep2-rep1+1, p);
        } else if ( order == "reverse" ) {
            int rev1,rev2;
            cin >> rev1 >> rev2;
            string tmp = word.substr(rev1, rev2-rev1+1);
            word = word.erase(rev1,rev2-rev1+1);
            reverse(tmp.begin(),tmp.end());
            word = word.insert(rev1, tmp);
        }
    }
}


Measured memory_bytes: 3172
/*
 this->author = Fuad Ashraful Mehmet, CSE-UAP
 ToDo--
 https://codeforces.com/contest/707/problem/D
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;

using namespace std;

typedef long long ll;
int n,m,k;
string s;
int a[10][10],row[10],col[10];
int new_a[10][10];

int fun()
{
 
      //dbg("reached");
      // something
      for(int i=0;i<n;++i)
      {
            for(int j=0;j<m;++j)new_a[i][j]=a[i][j];
      }
      for(int i=0;i<n;++i)
      {
            if(row[i])
            {
                  for(int j=0;j<m;++j)new_a[i][j]=0;
            }
      }
      for(int j=0;j<m;++j)
      {
            if(col[j])
            {
                  for(int i=0;i<n;++i)new_a[i][j]=0;
            }
      }
      int cnt=0;
      for(int i=0;i<n;++i)for(int j=0;j<m;++j)cnt+=new_a[i][j];
      return cnt==k;
 
}
void HalfDead()
{
      cin>>n>>m>>k;

      for(int i=0;i<n;++i)
      {
            cin>>s;
            for(int j=0;j<m;++j)
            {
                  a[i][j]=(s[j]=='#');
            }
      }
      int res=0;

      for(int mask1=0;mask1<(1<<n);++mask1)
      {
            memset(row,0,sizeof row);
            for(int i=0;i<n;++i)
            {
                  if(mask1&(1<<i))row[i]=1;
            }

            for(int mask2=0;mask2<(1<<m);++mask2)
            {
                  memset(col,0,sizeof col);
                  for(int i=0;i<m;++i)
                  {
                        if(mask2&(1<<i))col[i]=1;
                  }
                  
                  res+=fun();
            }
      }

      cout<<res<<endl;
}
int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);
      HalfDead();

      return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int n,s,a[3010];
long long f[3010];
const int mod=998244353;
int main(){
    scanf("%d %d",&n,&s);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    long long ans=0;
    for(int i=1;i<=n;i++){
        for(int j=s-a[i];j>=0;j--){
            f[j+a[i]]=(f[j+a[i]]+f[j])%mod;
        }
        f[a[i]]+=i;
        ans+=f[s]%mod;
        ans%=mod;
        // for(int i=0;i<=s;i++) printf("%lld ",f[i]);
        // printf("\n");
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;

int main(void) {
    int n; cin >> n;
    vector<int> a(n), cnt(n + 1);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n) {
        if (i + a[i] < n) cnt[i + a[i]]++;
        if (i - a[i] >= 0) ans += cnt[i - a[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include<iostream>
#include<cstdio>
#include<cmath>
#define EPS 1e-10
using namespace std;

int main(){
  double x1,x2,x3,xp,y1,y2,y3,yp;
  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
    double A = sqrt(pow(x1-x2,2)+pow(y1-y2,2)),B = sqrt(pow(x2-x3,2)+pow(y2-y3,2)), C = sqrt(pow(x1-x3,2)+pow(y1-y3,2)) ;
    double s = (A+B+C)/2.0;
    double S = sqrt(s*(s-A)*(s-B)*(s-C));
 
   double A12 = sqrt(pow(x1-x2,2)+pow(y1-y2,2)),B1p =sqrt(pow(x1-xp,2)+pow(y1-yp,2)), C2p = sqrt(pow(xp-x2,2)+pow(yp-y2,2)) ;
    double s2 = (A12+B1p+C2p)/2.0;
    double S2 = sqrt(s2*(s2-A12)*(s2-B1p)*(s2-C2p));
    /*
    if(S2 == 0){
      cout << "NO" << endl;
      break;
    }
    */
    double A13 = sqrt(pow(x1-x3,2)+pow(y1-y3,2)), Cp3 = sqrt(pow(xp-x3,2)+pow(yp-y3,2));
    double s3 = (A13+B1p+Cp3)/2.0;
    double S3 =  sqrt(s3*(s3-A13)*(s3-B1p)*(s3-Cp3));
    /*
    if(s3 == 0){
      cout << "NO" << endl;
      break;
    }
    */
    double A23 = sqrt(pow(x3-x2,2)+pow(y3-y2,2));
    double s4 = (A23+C2p+Cp3)/2.0;
    double S4 =  sqrt(s4*(s4-A23)*(s4-C2p)*(s4-Cp3));
    /*
    if(S3 == 0){
      cout << "NO" << endl;
      break;
    }
    */
    double Ssum = S2+S3+S4;
    
    fabs(Ssum - S)< 0.00001?cout << "YES" << endl:cout << "NO" << endl;


  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
    int N = 0; int M = 0;
    scanf("%d %d", &N, &M);
    int K[30] = {0};
    int A[30][30] = {0};
    for(int i = 0; i < N; i++){
        scanf("%d", &K[i]);
        for(int j = 0; j < K[i]; j++){
            scanf("%d", &A[i][j]);
        }
    }
    int counter[30] = {0};
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j < K[i]; j++){
            counter[A[i][j] % 31]++;
        }
    }
    int like = 0;
    for(int k = 1; k <= M; k++){
        if(counter[k] == N){
            like++;
        }
    }
    printf("%d\n", like);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    int n; cin >> n;
    int cnt = 0;
    while(n > 0){
        if(n % 10 == 2){
            cnt++;
        }
        n /= 10;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define INF 2147483647
#define full(c) c.begin(), c.end()
#define PRIME 1000000007
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	int i, cnt = 0;
	string s;
	cin >> s;
	if (s[0] != 'A'){
		cout << "WA" << endl;
		return 0;
	}
	for (i = 2; i <= s.size() - 2; i++){
		if (s[i] == 'C') cnt++;
	}
	if (cnt != 1){
		cout << "WA" << endl;
		return 0;
	}
	for (i = 1; i < s.size(); i++){
		if ((s[i] < 'a' || 'z' < s[i]) && s[i] != 'C'){
			cout << "WA" << endl;
			return 0;
		}
	}
	cout << "AC" << endl;
	return 0;
}


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

void printNA() {
    cout << "NA" << endl;
}

void judgeB(string s) {
    if (s.substr(s.size() - 2, 2) != "~~") {
        printNA();
        return;
    }
    if (s.size() <= 4) {
        printNA();
        return;
    }
    for (int i = 2; i < s.size() - 2; i += 2) {
        if (s.substr(i, 2) != "Q=") {
            printNA();
            return;
        }
    }
    cout << "B" << endl;
}

void judgeA(string s) {
    int len = 0;
    int i;
    for (i = 2; s[i] == '='; i++) {
        len++;
    }
    if (len == 0 || s.size() < i || s[i] != '#') {
        printNA();
        return;
    }
    if (s.size() < 2 + 2 * len) {
        printNA();
        return;
    }
    for (i++ ; i <= 2 + 2 * len; i++) {
        if (s[i] != '=') {
            printNA();
            return;
        }
    }
    if (s.size() == i || s[i] != '~') {
        printNA();
    } else {
        cout << "A" << endl;
    }
}

int main() {
    int n;
    cin >> n;
    for (int c = 0; c < n; c++) {
        string s;
        cin >> s;
        if (s.substr(0, 2) == ">'") {
            judgeA(s);
        } else if (s.substr(0, 2) == ">^") {
            judgeB(s);
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a,k) distance((v).begin(),(k)+upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a,k) distance((v).begin(),(k)+lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};

struct D21{
  int is,js;
  D21(int isize,int jsize){
    is = isize;
    js = jsize;
  }
  int operator()(int i,int j){
    return i*js+j;
  }
};


void Main(){
  int n,a;
  cin>>n>>a;
  cout<<dup(n,a)<<endl;
  

} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main(){
	double R;
	cin >> R;

	double ans = M_PI * R * 2.0;

	cout << fixed << setprecision(10);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3780