akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AUTHOR : kamesh_11 *
* INSTITUTION : GVPCOE *
******************************************/

#include <bits/stdc++.h>
using namespace std;

#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bs binary_search
#define endl '\n'
#define start_clock clock_t beginn=clock()
#define end_clock clock_t endd=clock()
#define cal_exec_time double time_spent=(double)(endd-beginn)/CLOCKS_PER_SEC
#define print_exec_time cout<<endl<<time_spent<<" secs"

typedef long long int ll;

const ll MOD = 1000000007;
const ll INF = 1e15;

ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

ll n, arr[405], pref[405];

ll get(ll L, ll R){
	return pref[R] - pref[L-1];
}

ll find_min(ll i, ll j, vector<vector<ll>>& dp){
	if(i == j)
		return dp[i][j] = 0;
	if(i+1 == j)
		return dp[i][j] = arr[i]+arr[j];

	if(dp[i][j] != -1)
		return dp[i][j];

	ll mini = INF;
	for(ll k=i;k<j;k++){
		ll cnt = get(i, j) + find_min(i, k, dp) + find_min(k+1, j, dp);
		if(cnt < mini)
			mini = cnt;
	}

	return dp[i][j] = mini;
}

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

	cin>>n;
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	for(ll i=1;i<=n;i++)
		pref[i] = pref[i-1] + arr[i];

	vector<vector<ll>>dp(n+1, vector<ll>(n+1, -1));
	cout<<find_min(1, n, dp);

	return 0;
}

Measured memory_bytes: 1536
import itertools

xs = list(map(int, input().split()))

anss = []
for ps in itertools.permutations(xs, len(xs)):
  ps = list(ps)
  head = ps[0]
  ps2 = ps.copy()
  ps2.insert(0, 0)
  s = [abs(a-b) for a, b in list(zip(ps, ps2))]
  #print(s, head)
  anss.append(sum(s)-head)
print(min(anss))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int N, Q;
    cin >> N >> Q;
    
    string S;
    cin >> S;
    
    
    int cnt = 0;
    vector<int> cntVec(N);
    for (int i=1; i<N; ++i)
    {
        if (S.substr(i-1,2) == "AC")
        {
            ++cnt;
        }
        cntVec[i] = cnt;
    }
    
    int l,r;
    for (int i=0; i<Q; ++i)
    {
        cin >> l >> r;
        cout << cntVec[r-1] - cntVec[l-1] << endl;
    }
    
    
    vector<int> vec(S.size());
    
    
    
    
    
    return 0;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

const ll mod = 1e9+7;

ll Pow(ll a, ll b)
{
	ll x = 1;
	for (; b > 0; b >>= 1)
	{
		if (b & 1) x = a * x % mod;
		a = a * a % mod;
	}
	return x;
}

ll n, k;

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	cin >> n >> k;

	vector<ll> fac(3*n+1), ifac(3*n+1);
	fac[0] = ifac[0] = 1;
	for (ll i = 1; i <= 3*n; ++i)
	{
		fac[i] = fac[i-1] * i % mod;
		ifac[i] = Pow(fac[i], mod-2);
	}

	auto comb = [&](ll i, ll j)
	{
		return fac[i] * ifac[i-j] % mod * ifac[j] % mod;
	};

	auto f = [&](ll k, ll i)
	{
		return comb(k+i-1, i-1);
	};

	ll ans = 0;
	for (ll i = 0; i <= min(n-1, k); ++i)
		ans = (ans + comb(n, i) * f(i, n-i)) % mod;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
long long inf=100000000000000;
using namespace std;
int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int i;
  long long ans=inf;
  for(i=0;i<=max(x,y)*2;i+=2){
    int pro=i/2;
    long long kari=max(0,x-pro)*a+max(0,y-pro)*b+i*c;
    ans=min(ans,kari);
  }
  cout << ans;
  return(0);
}

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

int main() {
	int K, i, j, count = 0;
	scanf("%d", &K);
	for (i = 2; i <= K; i += 2) {
		for (j = 1; j <= K; j += 2) {
			count++;
		}
	}
	printf("%d", count);
	return 0;
}

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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if(A+B > C+D) cout << "Left" << endl;
  else if(A+B < C+D) cout << "Right" << endl;
  else cout << "Balanced" << endl;



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s1[202],s2[202];
int st=100,ed=100,now=100,nown;
int n;
bool l;
char s[20];
bool jud()
{
	for(int i=st;i<=ed;i++)
		printf("%c",s1[i]);
	printf("\n");
	for(int i=st;i<=ed;i++)
		printf("%c",s2[i]);
	printf("\n");
	fflush(stdout);
	scanf("%s",s);
	if(s[0]=='F')
		return false;
	return true;
}
bool work()
{
	if(ed-st+1>n)
		return false;
	if(nown==4)
	{
		l=false;
		st++;
		ed++;
		nown=0;
	}
	if(l)
		now=st;
	else
		now=ed;
	if(nown&2)
		s1[now]='#';
	else
		s1[now]='.';
	if(nown&1)
		s2[now]='#';
	else
		s2[now]='.';
	if(jud())
	{
		nown=0;
		if(l)
			st--;
		else
			ed++;
	}
	else
		nown++;
	return true;
}
int main()
{
	l=true;
	scanf("%d",&n);
	nown=0;
	while(work());
	return 0;
}

Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)



long long modInverse(long long a, long long m) 
{ 
    long long m0 = m; 
    long long y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
       long long q = a / m; 
        long long t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 


int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    const ll M=1e9+7;
    ll N;
    cin>>N;
    vector<ll> A(N);

    ll tot_sum=0,sq_sum=0;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        tot_sum=(tot_sum+A[i])%M;
        ll temp=(A[i]*A[i])%M;
        sq_sum=(sq_sum+temp)%M;
    }
    tot_sum=(tot_sum*tot_sum)%M;
    ll ans=(tot_sum-sq_sum+M)%M;
    
    ll inv=modInverse(2,M);
    ans=(ans*inv)%M;

    cout<<ans<<"\n";

}


Measured memory_bytes: 4756
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
A,B,C = LI()
K = I()
count = 0
while 1:
    if A<B:
        break
    B *= 2
    count += 1
while 1:
    if B<C:
        break
    C *= 2
    count += 1
print('Yes' if count<=K else 'No') 


Measured memory_bytes: 9180
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
int main() {
    fast
    int n;
    cin>>n;
    ll a[n+1],prefix[n+1];;
    a[0]=0,prefix[0]=0;
    for(int i=1;i<n+1;++i) cin>>a[i],prefix[i]=prefix[i-1]+a[i];
    ll dp[n+1][n+1];
    for(int i=0;i<n+1;++i) dp[i][i] = 0;
    for(int i=1;i<n;++i) dp[i][i+1] = a[i]+a[i+1];
    for(int i=2;i<n;++i){
        for(int j=1;j+i<n+1;++j){
            dp[j][j+i] = LONG_MAX;
            for(int k=j;k<j+i;++k){
                dp[j][j+i] = min(dp[j][j+i],dp[j][k]+dp[k+1][j+i]+prefix[j+i]-prefix[j-1]);
            }
        }
    }
    cout<<dp[1][n];
}

Measured memory_bytes: 4840
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;

int w,h,c[50][50];
void island(int i,int j){
	int x,y;
	c[i][j]=0;
	for(x=-1;x<=1;x++){
		for(y=-1;y<=1;y++){
			if(0<=j+x&&j+x<w&&0<=i+y&&i+y<h&&c[i+y][j+x]==1){
				island(i+y,j+x);
			}
		}
	}

}
int main(){
	while(1){
		int sum=0,i,j,i1,j1;
		for(i=0;i<50;i++){
			for(j=0;j<50;j++){
				c[i][j]=0;
			}
		}
		cin>>w>>h;
		if(w==0&&h==0)break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				cin>>c[i][j];
			}
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(c[i][j]==1){
					island(i,j);
					sum++;
				}
			}
		}
		cout<<sum<<endl;
	}
    return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,d; 
int h;
int main() {
  cin>>a>>b;
  c=__gcd(a,b);
  d=sqrt(c);
  for(int i=2;i<=d;i++){
    if(c%i==0){
      while(c%i==0)
        c=c/i;
      h++;
     // cout<<i<<endl;
    }
  }
  if(c!=1)
    h++;
  cout<<h+1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int n;cin >>n;
  double x;
  string u;
  double ans=0;
  
  for(int i=0;i<n;i++){
    cin >> x >> u;
    if(u=="BTC"){
      ans+=380000*x;
    }
    else{
      ans+=x;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int partition(int *, int , int);

#define N 100000

int main(){

  int A[N], i, j=0, n, key, k;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&A[i]);

  i = partition(A, 0, n-1);

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

int partition(int *A, int p, int r){
  int x, i, j, tmp;

  x = A[r];
  i = p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i = i+1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[r];
  A[r] = A[i+1];
  A[i+1] = tmp;


 return i+1;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

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

	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if(i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3648
#atcoder template
def main():
    #import sys
    #imput = sys.stdin.readline
    #ここにコード
    #input
    S = str(input())
    T = str(input())

    #output
    end_word = T[-1]
    if S + end_word == T:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9040
#include <stdio.h>

int main(void)
{
    int a, b, y, counter, datacount;
    datacount = 0;
    while(1){
        counter = 0;
        scanf("%d %d", &a, &b);
        datacount++;
        if (a == 0&& b == 0){
            break;
        }
        y = a;
        if (datacount != 1)
            {
                printf("\n");
            }
        for (int i = a; i <= b; i++){// y == i
            if (!(y%400)){
                printf("%d\n", y);
                counter++;
            }else if((!(y%4)) && y%100){
                printf("%d\n", y);
                counter++;
            }
            y++;
        }
        if (counter == 0){
            printf("NA\n");
        }
    }
    return 0;
}
        
    

Measured memory_bytes: 1044
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

int main(void)
{
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<int> ACs(N+1,0);
	vector<int> l(N), r(N);
	for (int i = 0; i < Q; i++) {
		int L, R;
		cin >> L >> R;
		l[i] = L;
		r[i] = R;
	}

	for (int i = 2; i <= N; i++) {
		if (S[i - 2] == 'A'&&S[i - 1] == 'C') {
			ACs[i] = ACs[i - 1] + 1;
		}
		else {
			ACs[i] = ACs[i - 1];
		}
		//cout << i << ":" << ACs[i] << endl;
	}

	for (int i = 0; i < Q; i++) {
		int tmp = ACs[r[i]] - ACs[l[i]];
		cout << tmp << endl;
	}

	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
using namespace std;
int a[1000];
int main(){
	int n;
	cin>>n;
	for(int j=0;j<n;j++){
		cin>>a[j];
	}
	for(int i=n-1;i>0;i--){
		cout<<a[i]<<" ";
	}
	cout<<a[0]<<endl;
}



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

using namespace std;

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

  map<int, int> a;
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    a[s]++;
  }

  int ans = 0;
  for (auto i : a) {
    ans += i.second % 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4864
A, B, K = map(int, input().split())

ans = set()
for i in range(K):
    if A+i <= B:
        ans.add(A+i)
    if A <= B-i:
        ans.add(B-i)

ans = list(ans)
ans.sort()

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3060
X, Y = map(int,input().split()) #Xは動物総数、Yは足総数

kame = X
turu = 0


while kame >= 0:
    if 4*kame + 2*turu == Y:
        print("Yes")
        kame = -2
    kame -= 1
    turu += 1

if kame == -1:
    print("No")

Measured memory_bytes: 9180
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli a[100];
int main(void) {

	lli n, m, count = 0, sum = 0;
	cin >> n >> m;
	for (lli i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	for (lli i = 0; i < n; i++) {
		if (sum <= a[i] * (4 * m)) {
			count++;
		}
	}

	if (count >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define tam 1204
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define ptr tre*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000009 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
int mapa[tam][tam];
int main()
{
    int n;
    cin>>n;
    string txt;
    memset(mapa,0,sizeof mapa);
    forr(i,0,n)
    {
        cin>>txt;
        forr(j,0,txt.size())
        {
            mapa[i][txt[j]]++;
        }
    }
    forr(i,'a','z'+1)
    {
        int minn=1e9;
        forr(j,0,n)
        {
            minn=min(minn,mapa[j][i]);
        }
        forr(j,0,minn)
        {
            cout<<char(i);
        }
    }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  
  int num = 0;
  for(int i=0; i<k; i++) num += a[i];
  int ans = num;
  for(int i=k; i<n; i++) {
    num += a[i];
    num -= a[i-k];
    ans = max(num, ans);
  }

  cout << fixed << setprecision(7) << (ans+k)/2.0 << endl;
  return 0;
}

Measured memory_bytes: 3980
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

x = INT()

NN = x * 2 + 100
primes = []
isprime = [True for _ in range(NN + 1)]
#エラトステネスの篩
for i in range(2, NN + 1):
    if not isprime[i]:
        continue
    primes.append(i)
    for j in range(i * 2, NN + 1, i):
        isprime[j] = False

for i in primes:
    if i >= x:
        print(i)
        exit()

Measured memory_bytes: 73452
import sys
input = sys.stdin.readline

def cmin(a, b, i):
  if a > b:
    dp[i] = b
    return True
  return False

N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [sys.maxsize]*N
dp[0] = 0

for i in range(0, N):
  for j in range(1,K+1):
    cmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]), i)
    if i > 1:
      cmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]), i)
print(dp[N-1])    

Measured memory_bytes: 53852
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int k =kbd.nextInt();
   long a=0;
   for(int i=1;i<=k;i++){
     for(int l=1;l<=k;l++){
       for(int h=1;h<=k;h++){
         int d=gcd(i,l);
         int e=gcd(d,h);
         a=a+e;
       }
     }
   }
  System.out.println(a);
}

   static int gcd (int a, int b) {
     return b>0?gcd(b,a%b):a;
   }
}


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

#define N (1<<18)
#define ll long long
#define ld long double
#define M 1000000007
#define INF 0x5ADFACE5
#define LINF 0x51DEEFFEC7C0DECALL
#define pii pair<int, int>
#define pll pair<long long, long long>
#define F first
#define S second

using namespace std;

int v[111111];

int main() {
	int n, m;
	cin>>n>>m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin>>a>>b;
		v[a]++;
		v[b]++;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, v[i] % 2);
	}
	if (ans) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
int W, H, x, y, r;

scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

if (
 (x - r >= 0)
 && (y - r >= 0)
 && (x + r <= W)
 && (y + r <= H)
 ) {
 puts("Yes");
} else
{
 puts("No");
}

return 0;
}

Measured memory_bytes: 584
N, K = map(int, input().split())

num = [0] * K
for i in range(1, N + 1):
    num[i % K] += 1

res = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K == 0:
        res += num[a] * num[b] * num[c]
print(res)

Measured memory_bytes: 4596
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    for (int i = 0; i < m; i++) cin >> a[i];

    int cost0 = 0, costn = 0;
    for (auto &&i : a) {
        if (i >= x)
            costn++;
        else
            cost0++;
    }

    const int ans = min(cost0, costn);
    cout << ans << endl;
}

// 左か右に移動し続けるのが最適
// マス0とマスXの間の料金所の数が、左に移動し続けてマス0に到達してゴールするコスト
// マスNマスXの間の料金所の数が、右に移動し続けてマスNに到達してゴールするコスト
// この2つの小さい方が答え


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;cin>>s;
  	int mini = s.length();
	//start with 0
  int tot=0;
  for(int i=0;i<s.length();i++){
  	if(i%2==0 && s[i]!='0')tot++;
    if(i%2==1 && s[i]!='1')tot++;
  }
  mini = min(mini,tot);
 tot=0;
  for(int i=0;i<s.length();i++){
  	if(i%2==1 && s[i]!='0')tot++;
    if(i%2==0 && s[i]!='1')tot++;
  }
  mini = min(mini,tot);
  cout<<mini;
}

Measured memory_bytes: 512
k=int(input())
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Character>al = new ArrayList<Character>();
		
		String s = sc.next();
		int p = s.length();
		for(int i = 0; i < p ;i++) {
			char c = s.charAt(i);
			al.add(c);
			}
		
		int temp;
		int count = 0;
		do {
			
			temp = -1;
			for(int i = al.size() -1; i >= 1 ; i--) {
				if(al.get(i) != al.get(i - 1)) {
					al.remove(i);
					al.remove(i-1);
					temp = 0;
					count++;
					break;
				}
			}
		
		}while(temp == 0);
		
		System.out.println(count * 2);
		
		
	}

}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  sort(ALL(a));
  cout << a.at(a.size()-1) - a.at(0) << endl;
}


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

void solve() 
{
    int n,x,y;cin>>n>>x>>y;x--,y--;
    vector<int>G(n-1,0);
    REP(i,n-1)rep(j,i+1,n)G[min({abs(i-j)-1,abs(i-x)+abs(j-y),abs(i-y)+abs(j-x)})]++;
    REP(i,n-1)cout<<G[i]<<endl;
}

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3632
'''
問題：
    空港 A, B, C があり、それぞれの空港の間では、双方向に飛行機が運航しています。

    空港 A, B 間の飛行時間は片道 P時間、
    空港 B, C 間の飛行時間は片道 Q時間、
    空港 C, A 間の飛行時間は片道 R時間です。

    いずれかの空港からスタートして他の空港に飛行機で移動し、
    さらにそのどちらでもない空港に飛行機で移動するような経路を考えます。
    飛行時間の和は最短で何時間になるでしょうか。
'''

'''
制約：
    1 ≤ P, Q, R ≤ 100
    入力は全て整数である
'''

# 標準入力から P, Q, R の値を取得する
p, q, r = map(int, input().split())

# A-B-C の経路を計算して、最小値を出力する
result = [p + q, q + r, r + p]  # 全ての経路をリストに格納する
print(min(result))  # リストの最小値を出力する


Measured memory_bytes: 9172
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var mod = nk[0] % nk[1];
            Console.WriteLine(mod <= Math.Abs(mod - nk[1]) ? mod : Math.Abs(mod - nk[1]));
        }
    }
}


Measured memory_bytes: 13396
package main
import (
  "container/list"
  "fmt"
)
func main() {
  var k int
  fmt.Scan(&k)
  var d []int = make([]int,k)
  var v []bool = make([]bool,k)
  for i:=0;i<k;i++ { d[i] = 2147483646 }
  d[1] = 0
  v[1] = true
  deque := list.New()
  deque.PushFront(1)
  for deque.Len() > 0 {
    n,_ := deque.Remove(deque.Front()).(int)
    var a,b int = (10*n)%k,(n+1)%k
    if !v[a] {
      v[a] = true
      d[a] = min(d[a],d[n])
      deque.PushFront(a)
    } else {
      if d[a] > d[n] {
        d[a] = d[n]
        deque.PushFront(a)
      }
    }
    if !v[b] {
      v[b] = true
      d[b] = min(d[b],d[n]+1)
      deque.PushBack(b)
    }
  }
  fmt.Print(d[0]+1)
}
func min(n,m int) int {
  if n < m { return n }
  return m
}

Measured memory_bytes: 6656
/*
   __Allahu Akbar__
   __All_praises_to_Allah__
   __Bismillahir_Rahmanir_Rahim__

   Author: Abdullah Al Nayem
   Studying B.Sc in CSE at Leading University.

   Practice, like you've never won. Perform, like you've never lost.
   Practice hard, play hard. Be hard to beat.

*/

#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <bitset>
using namespace std;

#define MAX               1000000
#define ll                long long
#define pb                push_back
#define mkp               make_pair
#define F                 first
#define S                 second
#define Sort_arr(arr,x)   sort(arr,arr+x)
#define Sortr_arr(arr,x)  sort(arr, arr+n,greater<int>())
#define SortS(str)        sort(str.begin(), str.end())
#define SortRS(str)       sort(str.rbegin(), str.rend())
#define arr_rev(n)        sort(n.begin(), n.end(), greater<int>())
#define gin(a)            getline(cin,a)
#define Sz(a)             a.size()
#define Ignore            cin.ignore()
#define sq(n)             (n*n)
#define cube(n)           (n*n*n)
#define min3(a, b, c)     min(a, min(b, c))
#define max3(a, b, c)     max(a, max(b, c))
#define YES               cout << "YES" << endl
#define NO                cout << "NO" << endl
#define pYES              printf("YES\n")
#define pNO               printf("NO\n")
#define bs                binary_search
#define lb                lower_bound
#define ub                upper_bound
#define all(a)            a.begin(),a.end()
#define Fast_read         ios_base::sync_with_stdio(false);

int main()
{
    //freopen("Nayem.txt", "r", stdin);
    Fast_read

    int a,l,mn=INT_MAX,min_ind,arr[2000];
    cin>>a>>l;

    for (int i=1;i<=a;i++)
    {
        arr[i]=l+i-1;
        //cout<<arr[i]<<endl;
        if (mn>abs(arr[i])) mn=abs(arr[i]),min_ind=i;
    }
    //cout<<"MIn index : "<<min_ind<<endl;
    //cout<<"MIn element : "<<mn<<endl;
    int sum=0;
    for (int i=1;i<=a;i++)
    {
        if (i==min_ind) continue;
        sum+=arr[i];
    }
    cout<<sum<<endl;



    return 0;
}








Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	class Circle {
		int x, y, r, c;
		Circle (int x, int y, int r, int c) {
			this.x = x;
			this.y = y;
			this.r = r;
			this.c = c;
		}
	}
	final boolean DEBUG = false;
	final int MAX_N = 4 * 6;
	Circle[] circles;
	boolean[] isVisited;
	int n, ans;

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			n = scan.nextInt();
			if (n == 0)
				return;
			circles = new Circle[n];
			isVisited = new boolean[1 << 24];
			
			for (int i = 0; i < n; i++) {
				int x = scan.nextInt();
				int y = scan.nextInt();
				int r = scan.nextInt();
				int c = scan.nextInt();
				circles[i] = new Circle(x, y, r, c);
			}
			ans = 0;
			dfs(0);
			System.out.println(ans);
		}
	}
	
	int deleteCount(int bit) {
		int count = 0;
		while (bit != 0) {
			if ((bit & 1) != 0)
				count++;
			bit >>= 1;
		}
		return count;
	}
	
	boolean isTop(int bit, int circle) {
		if ((bit & (1 << circle)) != 0)
			return false;
		
		for (int i = circle - 1; i >= 0; i--) {
			if ((bit & (1 << i)) != 0)
				continue;
			int dx = circles[i].x - circles[circle].x;
			int dy = circles[i].y - circles[circle].y;
			if (circles[i].r + circles[circle].r > Math.sqrt(dx * dx + dy * dy))
				return false;
		}
		return true;
	}
	
	void dfs(int bit) {
		if (isVisited[bit])
			return;
		isVisited[bit] = true;
		if (DEBUG)
			System.out.println(bit);

		ans = Math.max(ans, deleteCount(bit));
		if (n - ans <= 1)
			return;
		
		for (int i = 0; i < n; i++) {
			if (DEBUG) {
				System.out.println(i + " " + !isTop(bit, i));
				System.out.println();
			}
			if (!isTop(bit, i))
				continue;
			for (int j = i + 1; j < n; j++) {
				if (DEBUG) {
					System.out.println("j: " + j + " " + !isTop(bit, j));
				}
				if (!isTop(bit, j))
					continue;
				if(circles[i].c == circles[j].c) {
					dfs(bit | (1 << i) | (1 << j));
					if (n - ans <= 1)
						return;
				}
			}
		}
	}

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



Measured memory_bytes: 359872
# C

import itertools
import bisect

n, m, k = map(int, input().split())
a_l = [int(x) for x in input().split()]
b_l = [int(x) for x in input().split()]

cumsuma_l = list(itertools.accumulate(a_l)) 
cumsumb_l = list(itertools.accumulate(b_l))

_idx = bisect.bisect_left(cumsumb_l, k)
if _idx == m or cumsumb_l[_idx] != k:
    _idx -= 1
ans = _idx + 1
    
for i in range(n):
    _a = cumsuma_l[i]
    if _a > k:
        break
    _tmp = k - _a
    _idx = bisect.bisect_left(cumsumb_l, _tmp)
    if _idx == m or cumsumb_l[_idx] != _tmp:
        _idx -= 1
    ans = max(ans, i + _idx + 2)
        
print(ans)

Measured memory_bytes: 131244
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N >> M;
  ll count[M] = {0};
  
  rep(i, N){
    cin >> K;
    rep(j, K) {
      cin >> A;
      count[A-1]++;
    }
  }
  ans = 0;
  rep(i, M){
    if (count[i] == N) ans++;
  }
  cout << ans << endl;


}


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

int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s/100;
  s2 = (s - s1*100)/10;
  s3 = (s - s1*100 -s2*10);
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    int n, a[101][101] = {};
    cin >> n; 
    for (int i = 1; i <= n; i++) {
        int p,m;
        cin >> p>>m;
        if (p != i) continue;
        for (int j = 0; j < m; j++) {
            int k;
            cin >> k;
            a[i][k]++;
        }
    }
    for (int i = 1;i <= n;i++) {
        for (int j = 1; j <= n;j++) {
            if (j-1) cout << " ";
            cout << a[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////

ll tn ; ll dp[200005]; ll ans[200005]; 
void solve()
{
 ll n ; 
 cin>>n; 
 ll a[n]; 
 for(int i =0; i<n ; i++)
 cin>>a[i]; 
 if(n==2)
 {
 	cout<<max(a[0],a[1])<<endl ;return; 
 }
 dp[0]=a[0]; 
 dp[1]=a[1];
 dp[2]= a[2]+a[0]; ans[1] = max(a[0],a[1]);
 ans[2]=max(a[2],max(a[1],a[2])); 
 for(int i =3; i<n ; i++)
 {  dp[i]= a[i]+dp[i-2]; 
 	if(i%2==0)
 	{
 		ans[i]= max(ans[i-2]+a[i], max(ans[i-1],dp[i-2]));
	 }
	 else
	 {
	 	ans[i]= max(a[i]+ans[i-2],dp[i-1]); 
	 }
 
 }
cout<<ans[n-1]<<endl; 
}
int main()
{ ios; 

ll t ;t = 1; 
  for(tn = 1; tn<=t; tn++)
	solve(); 
	return 0 ; 
}

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

using namespace std;

typedef long long ll;
int l[26];
int main(){
//	freopen("input.txt","r",stdin);// <--Remove Before Submit
	string s;
	cin >> s;
	for(int x=0;x<s.length();x++){
		l[s[x]-'a']=1;
	}
	for(int x=0;x<26;x++){
		if(l[x] == 0){
			cout << char(97+x) << endl;
			break;
		}else if(x==25){
			puts("None");
		}
	}
}

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

int main(){

  int H,W,A,B;
  cin >> H >> W >> A >> B;
  int x[H+1], y[W+1];
  int xx[H], yy[W];
  int numX,numY;
  bool can=false;
  For(i,H+1) x[i] = (W-A)*(H-i) + A*i;
  For(i,W+1) y[i] = (H-B)*(W-i) + B*i;
  For(i,H+1){
    if(can) break;
    For(j,W+1) if(x[i] == y[j]){
      can = true;
      numX = i;
      numY = j;
      break;
    }
  }
  For(i,H){
    if(numX>0){
      xx[i] = A;
      numX--;
    }else{
      xx[i] = W-A;
    }
  }
  For(i,W){
    if(numY>0){
      yy[i] = B;
      numY--;
    }else{
      yy[i] = H-B;
    }
  }

  if(!can) cout << "No" << endl;
  else if(W==1){
    For(i,H){
      if(B>0){
        cout << "1";
        B--;
      }else{
        cout << "0";
      }
      cout << endl;
    }
  } else if(H==1){
    For(i,W){
      if(A>0){
        cout << "1";
        A--;
      }else{
        cout << "0";
        }
      }
    cout << endl;
  }else {
    For(i,H){
      For(j,W){
        if(xx[i]>0&&yy[j]>0){
          cout << "1";
          xx[i]--;
          yy[j]--;
        }
        else cout << "0";
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1280
from sys import stdout
import sys,resource
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

k = inn()
a = inl()
if k==1:
    if a[0]==2:
        print("2 3")
    else:
        print(-1)
    exit()
l = r = 2
for i in range(k-1,-1,-1):
    mn = ((l+a[i]-1)//a[i])*a[i]
    mx = (r//a[i])*a[i]+a[i]-1
    if mn>mx:
        print(-1)
        exit()
    l = mn
    r = mx
print("{} {}".format(l,r))


Measured memory_bytes: 87528
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}
 
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e4 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readc(a, b, c);
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;



int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2;
}


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

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

const int N = 200005;
const int M = 105;
const LL INF = 1000000000000000000;

int n,pre[N];
int num[26][N];
int tot=1;
LL sum1[M],sum2[26][M];
int T;
char s[N];
LL l,r;

LL Calc(int c,LL lim) {
	LL ret=0;
	per(i,tot,1) if (lim>=sum1[i]) lim-=sum1[i],ret+=sum2[c][i];
	return ret+num[c][lim];
}

int main() {

	#ifndef ONLINE_JUDGE
	//	freopen("data.in","r",stdin);
	//	freopen("data.out","w",stdout);
	#endif

	scanf("%s",s+1); scanf("%lld%lld",&l,&r);
	n=strlen(s+1)/2;
	
	pre[1]=0; int k=0;
	rep(i,2,n) {
		while (k&&s[k+1]!=s[i]) k=pre[k];
		if (s[k+1]==s[i]) k++;
		pre[i]=k;
	} T=n-pre[n];
	
	rep(i,1,n) {
		rep(j,0,25) num[j][i]=num[j][i-1];
		num[s[i]-'a'][i]++;
	}
	
	sum1[0]=T; sum1[1]=n; rep(i,0,25) sum2[i][0]=num[i][T],sum2[i][1]=num[i][n];
	while (sum1[tot]<=r) {++tot; sum1[tot]=sum1[tot-1]+sum1[tot-2]; rep(i,0,25) sum2[i][tot]=sum2[i][tot-1]+sum2[i][tot-2];}
	
	rep(i,0,25) {
		printf("%lld",Calc(i,r)-Calc(i,l-1));
		if (i!=25) putchar(' '); else puts("");
	}

	return 0;
}


Measured memory_bytes: 20352
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>

using namespace std;


int main() {
	long long mod = 1e9+7;
//	long long int mod = 1000000007;
	int n, m;
	cin >> n >> m;
	vector<bool> holes(n+1, true);
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		holes[t] = false;
	}

	// その段数に行くには何通りの進み方があるか
	vector<long long int> stairs(n+1, 0);
	stairs[0] = 1;
	if (holes[1]) {
		stairs[1] = 1;
	}
	for (int now = 2; now < n+1; now+=2) {
		for (int next = now; next < min(now + 2, n+1); next++) {
			if (holes[next]) {
				stairs[next] = (stairs[next - 1] + stairs[next - 2]) % mod;
			}
		}
	}

	cout << stairs[n] << endl;

	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int A, B;
    cin >> A >> B;
    for(int i=0; i<10000; i++){
        if(100*A<=8*i && 8*i<100*(A+1) && 100*B<=10*i && 10*i<100*(B+1)){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	int a[51] = { 0 };
	int b[51] = { 0 };
	int res[51] = { 0 };
	for (int i = 1; i <= M; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i <= M; i++) {
		res[a[i]]++;
		res[b[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		cout << res[i] << endl;
	}

}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[][] c = new char[3][];
		c[0] = sc.next().toCharArray();
		c[1] = sc.next().toCharArray();
		c[2] = sc.next().toCharArray();
		sc.close();
		out.print(c[0][0]);
		out.print(c[1][1]);
		out.print(c[2][2]);
		out.println();
	}
}


Measured memory_bytes: 21588
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] stringList = new String[n];
        for (int i=0;i<n;i++){
            stringList[i] = scanner.next();
        }
        long count = 0;

        Map<String, Long> hashMap = new HashMap<>();
        for (int i=0;i<n;i++){
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 52444
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  100005;
const ll mod = 1e9 + 7;

ll a[N];
ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a % mod;
	if(b%2 == 1)
		return (power(a,b-1)*a) % mod;
	ll q = power(a,b/2);
	return (q*q) % mod;
}

void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n >> k;
  for (ll i = k; i >= 1; --i){
  	 a[i] = k/i;
  	 a[i] = power(a[i],n);
  	 for (ll j = 2*i; j <=k; j+=i){
  	 	a[i] = a[i] - a[j] + mod;
  	 	a[i]%= mod;
  	 }
  	 ans =(ans +  a[i] * i ) % mod;
  }
  c(ans);
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const ll inf = 1000000007;

int main() {
  ll n;
  cin >> n;
  ll e = 1;
  ll nine = 1;
  ll ten = 1;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (n == 2) {
    cout << 2 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    e = e * 8 % inf;
    nine = nine * 9 % inf;
    ten = ten * 10 % inf;
  }
  ll ans = (ten + e - nine * 2) % inf;
  if (ans < 0) ans += inf;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3672
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()

    val square1Size = a * b
    val square2Size = c * d

    val answer = if (square1Size < square2Size) square2Size else square1Size
    println(answer)
}

Measured memory_bytes: 31268
using System;
using System.Collections;
using System.Linq;
class Program
{
    static int Main()
    {
        //int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        int a, b, k;
        a = int.Parse(s[0]);
        b = int.Parse(s[1]);
        k = int.Parse(s[2]);

        if (a + k - 1 >= b - k + 1)
        {
            for (int i = a; i <= b; i++)
                Console.WriteLine(i);
        }
        else
        {
            for (int i = a; i <= a + k - 1; i++)
                Console.WriteLine(i);
            for (int i = b - k + 1; i <= b; i++)
                Console.WriteLine(i);
        }

        return 0;
    }
}

Measured memory_bytes: 11220
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
N = inp.shift() * 1
S = inp.shift()
s = []
for (i=0; i<S.length; i++) {
    c = S[i].charCodeAt() + N
    if (c > 90) {
        c = c - 26
    }
    s[i] = String.fromCharCode(c)
}
console.log(s.join(''))

Measured memory_bytes: 21064
A = list(input())
B = list(input())
C = list(input())
turn = "a"
while True:
	if turn == "a":
		if not A:
			win = "A"
			break
		turn = A[0]
		del A[0]
	elif turn == "b":
		if not B:
			win = "B"
			break
		turn = B[0]
		del B[0]
	elif turn == "c":
		if not C:
			win = "C"
			break
		turn = C[0]
		del C[0]
print(win)


Measured memory_bytes: 3192