akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

const int mod = 1e9+7;

int const MAX_N = 100;
int const MAX_K = 100005;
int dp[MAX_N][MAX_K];
int sum[MAX_N][MAX_K];

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

  int N, K;
  cin >> N >> K;
  vi A(N);
  rep(i, 0, N) {
    cin >> A[i];
  }

  rep(i, 0, K+1) {
    if (A[0] >= i) {
      dp[0][i] = 1;
    } else {
      dp[0][i] = 0;
    }
  }
  sum[0][0] = dp[0][0];
  rep(i, 1, K+1) {
    sum[0][i] = sum[0][i-1] + dp[0][i];
    sum[0][i] %= mod;
  }

  rep(i, 1, N) {
    rep(j, 0, K+1) {
      int ma = max(0, j - A[i]);
      if (ma == 0) {
        dp[i][j] += sum[i-1][j];
        dp[i][j] %= mod;
      } else {
        dp[i][j] += ((sum[i-1][j] + mod - sum[i-1][j - A[i] - 1]) % mod);
        dp[i][j] %= mod;
      }
    }
    sum[i][0] = dp[i][0];
    rep(j, 1, K+1) {
      sum[i][j] = sum[i][j-1] + dp[i][j];
      sum[i][j] %= mod;
    }

  }

  cout << dp[N-1][K] << endl;

  return 0;
};


Measured memory_bytes: 78336
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
a.sort()
b.sort()
c.sort()
for i in range(n):
    ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))
print(ans)

Measured memory_bytes: 23360
s = input()
len_s = len(s)
def calc_one_sum(n):
    r = len_s
    l = len_s - 1
    i = 0
    one_sum = 0
    while l > 0:
        if n & 1<<i != 0:
            one_sum += int(s[l:r])
            r = l
            l -= 1
        else:
            l -= 1
        i += 1
    one_sum += int(s[l:r])
    return one_sum
ans = 0
for i in range(2**(len_s - 1)):
    ans += calc_one_sum(i)
print(ans)

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

int tab[100005];
int main()
{   
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {  int a;
        cin>>a;
        tab[a]=i;
    }
    for(int i=1; i<=n; i++)
    cout<<tab[i]<<" ";
    return 0;
}

Measured memory_bytes: 1152
s = list(input())
ans = 0
cnta = 0
flagb = 0
flabc= 0
for i in range(len(s)):
  if s[i]=="A":
    if flagb==0:
      cnta+=1
    else:
      cnta=1
      flagb=0
  if s[i]=="B":
    if flagb==0 and cnta:
      flagb=1
    else:
      flagb=0
      cnta=0
  if s[i]=="C":
    if flagb and cnta:
      ans+= cnta
      flagb=0
    else:
      cnta=0
      flagb=0
print(ans)


Measured memory_bytes: 4840
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if(b % a == 0)
        cout << (a + b) << endl;
    else
        cout << (b - a) << endl;

    return 0;
}


Measured memory_bytes: 764
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main(){
	auto F=readln.split.to!(int[]),a=F[0],b=F[1],c=F[2];
	if(a+b==c||a+c==b||b+c==a)writeln("Yes");
	else writeln("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int K = 110, N = 1010;

int a[K],n,k;
int ret[N], curlen;

inline bool check(){
	int mn=a[1], mx=a[1];
	for(int i=1;i<=k;i++)mx=max(mx,a[i]), mn=min(mn,a[i]);
//	cerr << mn << " " << mx << "???" << endl;
	return mn*2>=mx;
}
int vis[K];

inline void merge(int *x,int *y,int *z,int len1,int len2){
	int i=1,j=1;
	int l=0;
	while(i<=len1&&j<=len2){
		if(x[i]<y[j])z[++l]=x[i++];
		else z[++l]=y[j++];
	}
	while(i<=len1)z[++l]=x[i++];
	while(j<=len2)z[++l]=y[j++];
}

int b[K], x[K], y[K], z[K], l1, l2, l3;

vector<int> solve_ext(int len){
	l1=l2=l3=0;
	for(int i=1;i<=k;i++)vis[i]=0,b[i]=a[i];
	for(int i=0;i<k-len;i++){
		vis[ret[curlen-i]]=curlen-i;
	}
	for(int i=1;i<=k;i++){if(!vis[i])b[i]--;if(b[i]<0)return vector<int>(1,k+1);}
	int mn,mx;mn=mx=b[1];
	for(int i=1;i<=k;i++){
		mn=min(mn, b[i]);
		mx=max(mx, b[i]);
	}
	if(mn*2>=mx){
		vector<int> ret;
		for(int i=1;i<=k;i++)if(!vis[i])ret.push_back(i);
		return ret;	
	}
	else if(mn*2+1==mx){
		vector<int> res;
		for(int i=1;i<=k;i++)if(!vis[i] && b[i]==mx)x[++l1]=i;
		for(int i=1;i<=k;i++)if(!vis[i] && b[i]==mn)x[++l1]=i;
		for(int i=1;i<=k;i++)if(!vis[i] && b[i]!=mx && b[i]!=mn)y[++l2]=i;
		merge(x,y,z,l1,l2);l3=l1+l2;
		res=vector<int>(z+1,z+l3+1);
		int p1=0,p2=0;
		for(int i=curlen-(k-len-1);i<=curlen;i++){
//			if(len==29)cerr << ret[curlen] << ":" << k-len-1 << " " << i << ":" << ret[i] << endl;
			if(b[ret[i]]==mx)p1=i;
			if(b[ret[i]]==mn&&!p2)p2=i;
		}
		for(int i=1;i<=l3;i++){
			if(b[z[i]]==mx)p1=i+curlen;
			if(b[z[i]]==mn&&!p2)p2=i+curlen;
		}
		if(p1<p2)return res;
		else return vector<int>(1,k+1);
	}else
		return vector<int>(1,k+1);
}

bool cmp(vector<int> a, vector<int> b){
	for(size_t i=0;i<a.size();i++){
		if(i>=b.size())return 1;
		if(a[i]>b[i])return 1;
		if(a[i]<b[i])return 0;
	}
	return 0;
}

inline void extend(){
	vector<int> ext(1,k+1);
//	cerr << ret[curlen] << "!!!" ;
	for(int extlen=1;extlen<=k&&curlen+extlen<=n;extlen++){
		int d=k-extlen;
		if(curlen-d+1>=1){
//			if(extlen==29)cerr << ret[curlen] << "!" << endl;
			vector<int> nw=solve_ext(extlen);
//			if(extlen==29){cerr << extlen << "::";for(size_t i=0;i<nw.size();i++)cerr << nw[i] << " ";cerr << endl;}
			if(cmp(ext,nw))ext=nw;
		}
	}
	for(size_t i=0;i<ext.size();i++){
		printf("%d ",ext[i]);
		ret[++curlen]=ext[i];
		a[ext[i]]--;
	}
	return ;
}

int main()
{
	cin >> k;
	for(int i=1;i<=k;++i)scanf("%d",&a[i]),n+=a[i];
	if(!check()){
		puts("-1");
		return 0;
	}
	while(curlen<n){
		extend();
	}puts("");
}

Measured memory_bytes: 3808
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define re register
#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read() {
	char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
const int maxn=2e5+5;
struct E{int v,nxt,w;}e[maxn<<1];
struct Edge{int a,b;LL c;}E[maxn*55];
int sum[maxn],vis[maxn],head[maxn],mx[maxn],a[maxn],fa[maxn],sz[maxn];
int n,num,m,dx,S,rt;LL dw,pre[maxn];
inline void add(int x,int y,int z) {
	e[++num].v=y;e[num].nxt=head[x];head[x]=num;e[num].w=z;
}
void getroot(int x,int fa) {
	sum[x]=1,mx[x]=0;
	for(re int i=head[x];i;i=e[i].nxt) {
		if(vis[e[i].v]||e[i].v==fa) continue;
		getroot(e[i].v,x);sum[x]+=sum[e[i].v];
		mx[x]=max(mx[x],sum[e[i].v]);
	}
	mx[x]=max(mx[x],S-sum[x]);
	if(mx[x]<mx[rt]) rt=x;
}
void getdis(int x,int fa) {
	E[++m]=(Edge){dx,x,pre[x]+a[x]+dw};
	for(re int i=head[x];i;i=e[i].nxt) {
		if(vis[e[i].v]||e[i].v==fa) continue;
		getdis(e[i].v,x);
	}
}
void chk(int x,int fa) {
	if(pre[x]+a[x]<dw) dw=pre[x]+a[x],dx=x;
	for(re int i=head[x];i;i=e[i].nxt) {
		if(vis[e[i].v]||e[i].v==fa) continue;
		pre[e[i].v]=pre[x]+e[i].w;chk(e[i].v,x);
	}
}
void dfs(int x) {
	dx=x,dw=a[x];vis[x]=1;pre[x]=0,chk(x,0),getdis(x,0);
	for(re int i=head[x];i;i=e[i].nxt) {
		if(vis[e[i].v]) continue;
		S=sum[e[i].v],rt=0,getroot(e[i].v,0),dfs(rt);
	}
}
inline int find(int x) {return x==fa[x]?x:fa[x]=find(fa[x]);}
inline int merge(int x,int y) {
	int xx=find(x),yy=find(y);
	if(xx==yy) return 0;
	if(sz[xx]<sz[yy]) fa[xx]=yy,sz[yy]+=sz[xx];
		else fa[yy]=xx,sz[xx]+=sz[yy];
	return 1;
}
inline int cmp(Edge A,Edge B) {return A.c<B.c;}
int main() {
	n=read();
	for(re int i=1;i<=n;i++) a[i]=read();
	for(re int x,y,z,i=1;i<n;i++) 
		x=read(),y=read(),z=read(),add(x,y,z),add(y,x,z); 
	mx[0]=n+1,S=n,rt=0,getroot(1,0),dfs(rt);
	std::sort(E+1,E+m+1,cmp);
	LL ans=0;
	for(re int i=1;i<=n;i++) sz[i]=1,fa[i]=i;
	for(re int i=1;i<=m;i++) if(merge(E[i].a,E[i].b)) ans+=E[i].c;
	std::cout<<ans;
	return 0;
}

Measured memory_bytes: 74368
def dice_swap(a, b):
    return b, (7-a)

def f(s, a, b, c):
    if s == 'North':
        a, b = dice_swap(a, b)
    elif s == 'East':
        c, a = dice_swap(c, a)
    elif s == 'West':
        a, c = dice_swap(a, c)
    elif s == 'South':
        b, a = dice_swap(b, a)
    elif s == 'Right':
        b, c = dice_swap(b, c)
    elif s == 'Left':
        c, b = dice_swap(c, b)
    return a, b, c

while True:
    n = int(raw_input())
    if n == 0:
        break
    r, a, b, c = 1, 1, 2, 3
    for _ in range(n):
        a, b, c = f(raw_input(), a, b, c)
        r += a
    print r

Measured memory_bytes: 4400
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

signed main(){
	string s;
	cin>>s;
	if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi") puts("Yes");
	else puts("No");
}

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

int main(){
    int n; cin >> n;
    string s;cin >> s;
    const int m='Z'-'A'+1;
    for(int i=0;i<s.length();i++){
        s[i]=(s[i]-'A'+n)%m+'A';
    }
    cout << s << endl;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n;cin>>n&&n;){
		deque<int> b;
		rep(i,n){
			int x; cin>>x;
			if(i&1)
				b.push_front(x);
			else
				b.push_back(x);
		}
		if(n&1)
			reverse(all(b));
		rep(i,n)
			cout<<b[i]<<"\n "[i+1<n];
	}
}


Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    priority_queue<ll> cnt;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        ans -= b;
        cnt.push(a + b);
    }
    rep(i, n) {
        if (i % 2 == 0) {
        ans += cnt.top();
        cnt.pop();
    }
    else{
        cnt.pop();
     }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
def c_typical_stairs(N, M, A, MOD=(10**9 + 7)):
    a = set(A)
    stairs = [0] * (N + 1)
    stairs[0] = 1
    for i in range(1, N + 1):
        if i in a:
            continue
        if i - 1 >= 0:
            stairs[i] += stairs[i - 1]
            stairs[i] %= MOD
        if i - 2 >= 0:
            stairs[i] += stairs[i - 2]
            stairs[i] %= MOD
    return stairs[N] % MOD

N, M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)]
print(c_typical_stairs(N, M, A))

Measured memory_bytes: 13216
#include<bits/stdc++.h>
using namespace std;
const int N=201000;
const int K=20;
double EPS=1e-7;
typedef long long ll;
#define lef(x) (x<<1)
#define rig(x) (lef(x)+1)
vector<int> a={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};
int32_t main()	
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll x,y;
	cin>>x>>y;
	if(x==1 || y==1)
		cout<<"1\n";
	else
		cout<<(x*y+1)/2<<"\n";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) < sum(b):
	print(-1)
	exit(0)
res = 0
t = 0
for i in range(N):
	if a[i] < b[i]:
		t += b[i] - a[i]
		a[i] = b[i]
		res += 1
ab = [(a[i], b[i]) for i in range(N)]
ab.sort(key = lambda x: (x[1] - x[0]))
for i in range(N):
	if t <= 0: break
	if ab[i][0] - ab[i][1] > 0:
		t -= ab[i][0] - ab[i][1]
		res += 1
print(res)

Measured memory_bytes: 19572
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<pair<int,int>>a(5);
for(int i=0;i<5;i++){
    cin>>a[i].second;
    a[i].first=0;
    while((a[i].second)%10!=0){
    (a[i].second)++;
    (a[i].first)++;
    }
}
int sum=0;
sort(a.begin(),a.end());
for(int i=0;i<4;i++){
    sum+=a[i].second;
}
cout<<sum+(a[4].second)-(a[4].first);

return 0;
}

Measured memory_bytes: 256
import copy

N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))
T = list(input())

total = 0
choice = {'r':0,'s':1,'p':2}
lst = [P,R,S]

for i in range(K):
    total += lst[choice[T[i]]]
    
for i in range(K,N):
    if T[i] != T[i-K]:
        total += lst[choice[T[i]]]
    else:
        T[i] = ''

print(total)

Measured memory_bytes: 4540
tate,yoko=map(int,input().split())
masu=0
h=int(tate/2)
if yoko%2==1:
  gyou=int(yoko/2)+1
  if tate%2==1:
    masu=(2*gyou*h+gyou-h)
  else:
    masu=(2*gyou-1)*h
else:
  gyou=int(yoko/2)
  masu=(gyou*tate)

if yoko==1 or tate==1:
  print(1)  
else:
  print(masu)
  


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
		
		System.out.println(t/a*b);
		

	}

}

Measured memory_bytes: 24020
w,h,n = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
list_w = [1]*w
list_h = [1]*h

for i in range(n):
  if a[i][2] == 1:
    for j in range(a[i][0]):
      list_w[j] = 0
  elif a[i][2] == 2:
    for j in range(w-1,a[i][0]-1,-1):
      list_w[j] = 0
  elif a[i][2] == 3:
    for j in range(a[i][1]):
      list_h[j] = 0
  elif a[i][2] == 4:
    for j in range(h-1,a[i][1]-1,-1):
      list_h[j] = 0

h = list_h.count(1)
w = list_w.count(1)
print(h*w)




Measured memory_bytes: 3064
#include <iostream>
#include <string>

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

  int32_t N;
  std::cin >> N;
  std::string S, T;
  std::cin >> S >> T;
  std::string res = "";
  for (int i = 0; i < N; i++) {
    res = res + S[i];
    res= res + T[i];
  }
  std::cout << res << std::endl;
  return 0;
}


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

main(){
  int N;
  cin >> N;
  for(int i=1; i<10; i++){
    int dev = N/i;
    if(N%i==0 && dev<10){
	  cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
friend=[[] for _ in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    friend[A-1].append(B-1)
    friend[B-1].append(A-1)
ans=0
ischecked=[0]*N
for i in range(N):
    if ischecked[i]==1:
        continue
    group=1
    ischecked[i]=1
    ship=friend[i]
    while ship:
        nex=ship.pop()
        if ischecked[nex]==1:
            continue
        ischecked[nex]=1
        group+=1
        ship.extend(friend[nex])
    ans=max(ans,group)
print(ans)

Measured memory_bytes: 45388
//itp1_8-a
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
 char c;
 while(true){
  scanf("%c",&c);
  if(c=='\n'){
   cout<<endl;
   break;
  }
  if(isupper(c)){
   c=tolower(c);
   cout<<c;
  }
  else if(islower(c)){
   c=toupper(c);
   cout<<(c);
  }
  else
   cout<<c;
 }
 return 0;
}

Measured memory_bytes: 1148
x, y = map(int, input().split())

def cmb(n, r, mod):
    from operator import mul
    from functools import reduce

    N = n + r
    g1 = [1, 1]  # 元テーブル
    g2 = [1, 1]  # 逆元テーブル
    inverse = [0, 1]  # 逆元テーブル計算用テーブル

    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod )
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    if (r<0 or r>n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


if (x+y) % 3 != 0:
    ans = 0

else:
    a = (x + y)//3
    b = x-a

    if x-a <0 or y-a <0:
        ans = 0
    else:
        mod = 10**9+7 #出力の制限
        ans = cmb(a, b, mod)

print(int(ans))


Measured memory_bytes: 127432
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){

	int N;
	cin>>N;
	
	vector<long long> a(N);
	
	long long sum = 0;
	
	for(int i=0;i<N;i++){
		cin>>a[i];
		sum += a[i];
	}
	
	long long sum2 = 0;
	long long ans = Inf;
	for(int i=0;i<N-1;i++){
		sum2 += a[i];
		sum -= a[i];
		ans = min(ans,abs(sum-sum2));
	}
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	LL n,m;
	LL pt[55][2];
	int i,j,k,l;
	LL a,b,c,d;
	LL p,q,r;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>pt[i][0]>>pt[i][1];
	}
	r=-1;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			a=pt[i][0],b=pt[j][0];
			if(a>b)swap(a,b);
			for(k=0;k<n;k++){
				for(l=k+1;l<n;l++){
					c=pt[k][1],d=pt[l][1];
					if(c>d)swap(c,d);
					for(p=0,q=0;p<n;p++){
						if(a<=pt[p][0] && pt[p][0]<=b && c<=pt[p][1] && pt[p][1]<=d)q++;
					}
					if(q>=m){
						if(r==-1 || r>(b-a)*(d-c))r=(b-a)*(d-c);
					}
				}
			}
		}
	}
	cout<<r<<endl;
					
}


Measured memory_bytes: 384
a,b,c,X = [int(input()) for i in range(4)]
l = []
for x in range(a + 1):
  for y in range(b + 1):
    for z in range(c + 1):
      s = 500*x + 100*y + 50*z
      l.append(s)
print(l.count(X))

Measured memory_bytes: 8276
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  for(int bit = 0;bit < (1<<4);bit++) {
    string a="",b="",c="",d="";
    if(bit&1) a = "A";
    if(bit>>1&1) b = "A";
    if(bit>>2&1) c = "A";
    if(bit>>3&1) d = "A";
    string s = a+"KIH"+b+'B'+c+'R'+d;
    if(S == s) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
 
def gcd(x,y):
   if x % y == 0:
       return y
   return gcd(y, x % y)
 
CD = (c * d) // gcd(c,d)
 
h_b =b - (b // c) - (b // d) + (b // CD)
h_a = (a - 1) - (a - 1) // c - (a - 1) // d + (a - 1) // CD
 
print(h_b - h_a)

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int a, b;
    cin >> a >> b;
    int ans = 0;

    for ( int i = a; i <= b; i++ ) {
        string normal = to_string(i);
        string contrario = to_string(i);
        reverse(all(contrario));

        if ( normal == contrario ) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int p,q,r;
int main(){
	cin>>p>>q>>r;
	int pp=abs(p+q);
	int qq=abs(q+r);
	int rr=abs(r+p);
	cout<<min(pp,min(qq,rr))<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int[] i = Arrays.stream(line.split(" ")).mapToInt(Integer::parseInt)
                                                .toArray();
        if (i[2] - i[4] < 0 || i[0] < i[2] + i[4]) {
            System.out.println("No");
        } else if (i[3] - i[4] < 0 || i[1] < i[3] + i[4]) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 32116
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
ll fact(ll a)
{
	ll ans = 1;
	for (ll i = 2; i <= a;i++)
	{
		ans = (ans * i)%mod;
	}
	return ans;
}
void solve()
{
	ll x, y,x1,y1,sol=0;
	cin >> x >> y;
	for (ll i = 0; i <= x; i++)
	{
		ll a, b;
		x1 = x;
	    y1 = y;
		x1 = x - i;
		y1 = y - 2 * i;
		if (x1 >= 0 && y1 >= 0 && x1 == 2 * y1)
		{
			 a = fact(i + y1);
			 b = (fact(i) * fact(y1))%mod;
			 sol = (sol % mod + (a * power(b, mod - 2, mod)) % mod) % mod;
		}	
	}
	cout << sol;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
class BIT:
    def __init__(self, size):
        self.size = size
        self.bit = [0] * (size + 1)

    # sum [0, i)
    def sum(self, i):
        s = 0
        while (i > 0):
            s += self.bit[i]
            i -= i & -i
        return s

    # sum [i, j)
    def sum_sec(self, i, j):
        return self.sum(j) - self.sum(i)

    def add(self, i, x):
        i += 1
        while (i <= self.size):
            self.bit[i] += x
            i += i & -i

n, q = map(int, raw_input().split())
bit = BIT(n)
for i in xrange(q):
    c, x, y = map(int, raw_input().split())
    if c == 0: bit.add(x - 1, y)
    else: print bit.sum_sec(x - 1, y)

Measured memory_bytes: 6064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for(int i=0; i<R; i++){
        cin >> r[i];
        r[i]--;
    }
    vector<vector<int>> d(N, vector<int>(N, 1 << 25));
    for(int i=0; i<M; i++){
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        d[A][B] = C;
        d[B][A] = C;
    }

    for(int k=0; k<N; k++)
        for(int i=0; i<N; i++)
            for(int j=0; j<N; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    int ans = 1 << 30;
    sort(r.begin(), r.end());
    do{
        int tmp = 0;
        for(int i=1; i<R; i++)
            tmp += d[r[i]][r[i-1]];
        ans = min(ans, tmp);
    }while(next_permutation(r.begin(), r.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
 
#define N 200003
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str1,str2;
    cin>>str1>>str2;
    string ans=str1+str2;
    lli temp=atoll(ans.c_str());
    lli root=sqrt(temp);
    if(root*root==temp)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
        
        
    
    return 0;
}    

Measured memory_bytes: 256
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))

if c1[0]+c2[1]+c3[2] == c1[1]+c2[2]+c3[0] == c1[2]+c2[0]+c3[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define F first
#define S second

int main() {



 ll N;string s;
 cin>>N;

 while(N > 0) {
   s.pb('a' + (N%26 == 0 ? 25 : (N%26)-1));
   N = (N-1)/26;
 }
 reverse(s.begin(),s.end());
 cout<<s;

  return 0;
}


Measured memory_bytes: 3624
n,m=map(int,input().split())
XY=[list(map(int,input().split())) for _ in range(m)]

cnt=[1 for _ in range(n)]
red=[True]+[False for _ in range(n-1)]
for x,y in XY:
  if cnt[x-1]>=1:
    cnt[x-1]-=1
    cnt[y-1]+=1
    if red[x-1]:
      red[y-1]=True
      if cnt[x-1]==0:
        red[x-1]=False
  else:
    red[x-1]=False
print(sum(red))

Measured memory_bytes: 29768
function Main(input){
	inputs = input.trim().split(' ');
	nums = inputs.map(inputs=>parseInt(inputs,10));
    a = nums[0]+(nums[0]-1);
    b = nums[1]+(nums[1]-1);
    c = nums[0]+(nums[1]);
	console.log(Math.max.apply(null, [a, b, c]));
}
 
Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

const int MOD1=1000000007;
const int MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const int dx[]={0,1,0,-1,1,-1,1,-1};
const int dy[]={1,0,-1,0,1,1,-1,-1};

#define unless(a) if(!(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(n);i++)
#define bitrep(i,s,n) for(int i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long cutup(long long a,long long b){return (a+b-1)/b;}
long long popcnt(long long a){return __builtin_popcountll(a);}
template<class T,class U> inline bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template<class T,class U> inline bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

struct edge{long long to,cost;};
struct edge2{long long from,to,cost;};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vl A(n);
    rep(i,n)cin>>A[i];
    rep(i,n-1)A[i+1]+=A[i];
    ll res=INF;
    rep(i,n-1)chmin(res,abs(A[n-1]-A[i]*2));
    cout<<res<<endl;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 200005;

int n;
int a[N];
int m;
int b[N];
multiset<int> S;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		S.insert(a[i]);
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		if (S.find(b[i]) == S.end()) {
			puts("NO");
			return 0;
		}
		S.erase(S.find(b[i]));
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 11264
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        if (k % 2 == 0) {
            int count1 = 0;
            for (int i = 1; i <= n; i++) {
                if (i % k == k / 2) count1++;
            }
            int count2 = 0;
            for (int i = 1; i <= n; i++) {
                if (i % k == 0) count2++;
            }
            
            long ans = (long)count1 * count1 * count1 + (long)count2 * count2 * count2;
            System.out.println(ans);
        } else {
            int count2 = 0;
            for (int i = 1; i <= n; i++) {
                if (i % k == 0) count2++;
            }
            
            long ans = (long)count2 * count2 * count2;
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 23380
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
  
      int a[] = new int[100];//配列100まで格納している
      int n = 0;//問題に該当する二つの数値を割り切れる数値の個数を定義している
      for(int i=1; i<=Math.min(A,B); i++){//1から、入力するA.Bどちらかの最小数値までを繰り返していく
      if(A%i==0 && B%i==0){//A.Bどちらでも割れる数値i
        n+=1;//i=1なのでnに1ずつ加算していく
        a[n] =i;//if文の条件に合うiの個数をa[n]に代入する
        }
      }
     System.out.println(a[n-K+1]);//大きい方からK番目に該当する数値を見つけるための式,a[n-K+1]番目に格納されている数値
    }
}
        

Measured memory_bytes: 23892
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string N;
  cin >> N;
  const char* n = N.c_str();

  ll s = 0;
  REP(i, 0, N.size()) {
    char* e;
    auto a = strtol(N.substr(i, 1).c_str(), &e, 10);
    s += a;
  }

  if (s % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a;
    cin >> a;
    if(a - 'A' >= 0 && 'Z' - a >= 0){
        cout << 'A' << endl;
    }
    else if(a - 'a' >= 0 && 'z' - a >= 0){
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3624
#include<stdio.h>
int main (void)
{
  int i,n,sum,x;
  scanf("%d",&n);
  while(n!=0){
    sum=0;   
    for(i=0;i<n/4;i++){
      scanf("%d",&x);
      sum+=x;
    }
    printf("%d\n",sum);
    scanf("%d",&n);
  }
  return 0;
}
    

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

int main() {
	int K, A, B;
	cin >> K >> A >> B;
	for (int i = (A / K); i <= (B / K) + 1; i++) {
		if (A <= i * K && i * K <= B) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}

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

int main() {
    string S; cin >> S;
    int Q; cin >> Q;
    bool reved = false;
    string top;
    string bottom;
    while (Q--) {
        int t; cin >> t;
        if (t == 1) {
            reved = !reved;
        } else {
            int F; cin >> F;
            char C; cin >> C;
            if ((F == 1 && !reved) || (F == 2 && reved)) {
                top += C;
            } else {
                bottom += C;
            }
        }
    }
    reverse(top.begin(), top.end());
    S =  top + S + bottom;
    if (reved) reverse(S.begin(), S.end());
    cout << S << endl;
}


Measured memory_bytes: 1348
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    string t = "";
    t += s[0];
    string k = "";
    ll ans = 1;
    for(ll i=1;i<s.size();++i){
        k += s[i];
        if(t != k){
            t = k;
            k = "";
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <bitset>
#include <algorithm>
#include <cstdio>
using namespace std;
bitset<10000> cookie[10];
int main()
{
    int R, C;
    while(scanf("%d%d",&R,&C)&&R>0)
    {
        int i, j;
        for (i = 0; i < R; ++i)
            for (j = 0; j < C; ++j)
            {
                bool upwards;
                cin >> upwards;
                cookie[i][j] = upwards;
            }

        // 在横向一共有2^R???
        int permute_r = 1 << R;
        int result = 0;
        for (i = 0; i < permute_r ; ++i)
        {
            // 完成当前的??
            for (j = 0; j < R; ++j)
            {
                // ?一行是否?当翻个面
                if (i & (1 << j))
                {
                    cookie[j].flip();
                }
            }


            // ??一列分?算出朝上和朝下的煎?个数，取其最大?
            int possible_answer = 0;
            for (j = 0; j < C; ++j)
            {
                int up_cookie_count = 0;
                for (int k = 0; k < R; ++k)
                {
                    if (cookie[k][j])
                    {
                        ++up_cookie_count;
                    }
                }
                possible_answer += max(up_cookie_count, R - up_cookie_count);
            }
            // ?果取最大?
            result = max(result, possible_answer);

            // ?原
            for (j = 0; j < R; ++j)
            {
                if (i & (1 << j))
                {
                    cookie[j].flip();
                }
            }
        }
        printf("%d\n",result);
    }

    return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>
int main(){
	int num,n,i,_height,weight,bestBmiN;
	double height,bmi,bmi_d,bestBmi;
	for(;scanf("%d",&n)&&n;){
		bestBmiN=0;
		bestBmi=10000;
		for(i=0;i<n&&scanf("%d %d %d",&num,&_height,&weight);i++){
			height=(double)_height/100.0;
			bmi=(double)weight/(height*height);
			if(22.0>bmi)bmi_d=22.0-bmi;
			else bmi_d=bmi-22.0;
			if(bmi_d<bestBmi){
				bestBmi=bmi_d;
				bestBmiN=num;
			}
		}
		printf("%d\n",bestBmiN);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	n%=10;
	if(n==3) cout<<"bon\n";
	else if(n==0 || n==1 || n==6 || n==8) cout<<"pon\n";
	else cout<<"hon\n";
	return 0;
}


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

using namespace std;

int main(){
  int n, ans;
  double t, a, h, diff = 1000000;
  
  cin >> n >> t >> a;
  for(int i = 0;i < n;i++){
    cin >> h;
    if(abs(a - (t - h * 0.006)) < diff){
      diff = abs(a - (t - h * 0.006));
      ans = i + 1;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(n == 0) break;
            int legState[] = new int[2];//現在の脚の状況legState[0]が左脚,[1]が右足、値が0が床、1が踏み台
            int prevSate = 0;//前回両足床(0)でカウントしたのか、両足踏み台(1)でカウントしたのか覚えておく
            int stepCount = 0;
            for (int i = 0; i < n; i++) {
                String moveLeg = sc.next();
                if(moveLeg.equals("lu")){
                    legState[0] = 1;
                }
                else if (moveLeg.equals("ru")) {
                    legState[1] = 1;
                }
                else if (moveLeg.equals("ld")) {
                    legState[0] = 0;
                }
                else if (moveLeg.equals("rd")) {
                    legState[1] = 0;
                }
                
                if(legState[0] == 0 && legState[1] == 0 && prevSate == 1){
                    stepCount++;
                    prevSate = 0;
                }
                else if(legState[0] == 1 && legState[1] == 1 && prevSate == 0){
                    stepCount++;
                    prevSate = 1;
                }
            }
            System.out.println(stepCount);
        }
    }
    public static void main(String[] args) {
        // new AOJ2582().run();
        new Main().run();
    }
}

Measured memory_bytes: 26948
import heapq

N, M = list(map(int, input().split()))
A = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(A)

for i in range(M):
    heapq.heappush(A, heapq.heappop(A)/2)
print(sum(map(lambda x: int(-x), A)))

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

const ll MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int n,m;cin>>n>>m;
	if(n==m)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >;
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
using namespace std;
int n;
int main(){
	cin>>n;
	vector<long double> v(n);
	for(int i=0;i<n;i++)
	cin>>v[i];
	sort(v.begin(),v.end());
	while(v.size()>1){
		long double x=v[0],y=v[1];
		x=(x+y)/2;
		v.erase(v.begin());
		v[0]=x;
	}
	cout<<v[0];
	re 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(;;){
            int n = sc.nextInt();
            int p = sc.nextInt();
            int[] s = new int[n];
            int c = 0; //???????????£??????????????°
            int ans = -1;
            if(n==0 && p==0) break;
            for(int i = 0; i < n; i++)
                s[i] = 0;
            for(;;){
                for(int i = 0; i < n; i++){
                    if(p!=0){
                        if(s[i]==0) c++;
                        s[i]++;
                        p--;
                    }else{
                        if(c==1){
                            ans = i==0 ? n-1 : i-1;
                            break;
                        }else{
                            p = s[i];
                            if(s[i]!=0){
                                s[i] = 0;
                                c--;
                            }
                        }
                    }
                    // System.out.println("s[" + i + "]:" + s[i]);
                    // System.out.println("c = " + c);
                }
                if(ans!=-1) break;
            }
            System.out.println(ans);
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N, greater<int>());
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      Alice += A[i];
    }
    else {
      Bob += A[i];
    }
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256