akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

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

int ans=0;

int main()
{
	int a=read();int b=read();
	if(a>=b) ans+=a,a--;
	else ans+=b,b--;
	cout<<ans+max(a,b);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cmath>
#include<vector>

using namespace std;
using ll = long long;
const ll N = 1e6;
const double PI = acos(-1.0);
#define Test ll tesnum;tesnum = read();while(tesnum--)
ll read();

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b)){
        cout<<"Yes"<<endl;
    }else
        cout<<"No"<<endl;
    return "BT7274", NULL;
}

inline ll read() {
    ll hcy = 0, dia = 1;char boluo = getchar();
    while (!isdigit(boluo)) {if (boluo == '-')dia = -1;boluo = getchar();}
    while (isdigit(boluo)) {hcy = hcy * 10 + boluo - '0';boluo = getchar();}
    return hcy * dia;
}

Measured memory_bytes: 256
use std::collections::HashSet;
use std::borrow::Borrow;
use std::ops::IndexMut;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v: Vec<isize> = read_vec();
    let n: usize = v[0] as usize;
    let k: isize = v[1];
    let q: isize = v[2];

    let mut s: Vec<isize> = vec![k - q; n];

    for _ in 0..q {
        let a: i32 = read();
        let i: usize = (a - 1) as usize;
        s[i] += 1;
    }

    for i in 0..n {
        let i = i as usize;
        if s[i] > 0 {
            println!("Yes")
        } else {
            println!("No")
        }
    }
}


Measured memory_bytes: 4732
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N;
    cin >> N;
    vector<llong> X(N, 0);
    for(int i=0; i<X.size(); i++){
        cin >> X[i];
    }
    llong ans=INF;
    llong total;
    for(int P=1; P<=100; P++){
        total = 0;
        for(int i=0; i<X.size(); i++){
            total = total + (X[i]-P)*(X[i]-P);
        }
        ans = min(total, ans);
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
  int k,s;
  cin >> k >> s;
  int ans=0;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      int z = s-x-y;
      if(z <= k && z >= 0){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> S;
  rep(i,1,N)if(S[i]!=S[i-1])sum++;
  Out(sum+1);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  double N;
  cin>>N;
  vector<double> x(N);
  vector<double> y(N);
  vector<double> dist(0);
  double kaijou=1;
  for(ll i=0;i<N;i++){
    cin>>x.at(i)>>y.at(i);
    kaijou*=(i+1);
  }
  for(ll i=0;i<N-1;i++){
    for(ll j=i+1;j<N;j++){
      double distance=(x.at(i)-x.at(j))*(x.at(i)-x.at(j))+(y.at(i)-y.at(j))*(y.at(i)-y.at(j));
      dist.push_back((double)sqrt(distance));
    }
  }
  double ans=0;
  for(ll i=0;i<N*(N-1)/2;i++){
    ans+=dist.at(i)*2/N;
  }
  cout << fixed << setprecision(9) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n;
    string s;
    cin>>n>>s;
    for(int i = 0; i < s.size(); i++){
        if(s[i]+n>='A'&&s[i]+n<='Z')cout<<char(s[i]+n);
        else cout<<char(s[i]+n-26);
    }  
}
int main(){
    speed;
    foo();
}

Measured memory_bytes: 256
def main():
    S=int(input())

    mod=10**9+7

    resList=[1,0,0,1,1,1]
    n=6
    if S>=n:
        for i in range(n,S+1):
            resList.append(resList[i-1]+resList[i-3])
        print(resList[len(resList)-1]%mod)
    else:
        print(resList[S])




if __name__=="__main__":
    main()

Measured memory_bytes: 63252
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(); //高さ
	    double x = sc.nextDouble(); //水の体積
	    double max = Math.pow(a, 2) * b; //体積の最大値
	    //こぼれる瞬間が台形
	    double c = 0;
	    double d = 0;
	    double cos = 0;
	    if(x == max / 2) {
	        System.out.println((double)45);
	    }else if(x > max / 2) {
	        c = 2 * x / Math.pow(a, 2) - b;
	        d = Math.sqrt(Math.pow(a, 2)+Math.pow(b-c, 2));
	        cos = (Math.pow(a, 2) + Math.pow(d, 2) - Math.pow(b-c, 2)) / (2 * a * d);
	        System.out.println(_toDegrees(Math.acos(cos)));
	    //こぼれる瞬間が三角形    
	    }else {
	        c = a - ((2 * x) / (a * b));
	        d = Math.sqrt(Math.pow(a-c, 2)+Math.pow(b, 2));
	        cos = (Math.pow(a-c, 2) + Math.pow(d, 2) - Math.pow(b, 2)) / (2 * (a-c) * d);
	        System.out.println(_toDegrees(Math.acos(cos)));
	    }
	}
	
	private static double _toDegrees(double rad)
    {
        return rad * 180.0 / Math.PI;    
    }

}

Measured memory_bytes: 25044
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int H,W,K;
char c[7][7];

void solve(){
  int result=0;
  for(int i=0;i<(1<<H);i++){
    for(int j=0;j<(1<<W);j++){
      int cnt=0;
      for(int y=0;y<H;y++){
	for(int x=0;x<W;x++){
	  if(c[y][x]=='#'&&
	     (i&(1<<y))==0&&
	     (j&(1<<x))==0){
	    cnt++;
	  }
	}
      }
      if(cnt==K)result++;
    }
  }
  cout<<result<<endl;
}

int main(){
  cin>>H>>W>>K;
  REP(i,H)REP(j,W)cin>>c[i][j];
  solve();
  return 0;
}


Measured memory_bytes: 3636
i= 0
a,b = [],[]

while True:
    try:
        a.append(int(raw_input()))

        if a[i] == 0:
            b.append(a[i-1])
            a.pop()
            print a[i-1]
            a.pop()
            i -=1
        else:
            i +=1

    except:
        break


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


int main()
{
	int n;
	cin >> n;
	int a[4], ans, k;
	for (int i = 3; i >= 0; i--)
	{
		a[i] = n % 10; 
		n = n / 10;
	}
	string op;
	for (int i = 0; i < 8; i++)
	{
		ans = a[0];
		k = 1;
		for (int j = 2; j >= 0; j--)
		{
			if (i & (1 << j))
			{
				op += "-";
				ans -= a[k++];
			}
			else 
			{
				op += "+";
				ans += a[k++];
			}
		}
		if (ans == 7)
		{
			break;
		}
		else
		{
			op = "";
		}
	}
	string r = to_string(a[0]);
	k = 1;
	for (int i = 0; i < 3; i++)
		r += op[i] + to_string(a[k++]);
	r += "=7";
	cout << r << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P std::pair<int,int>
#define double long double
typedef long long ll;
using namespace std;
signed main() {
	string s;
	cin>>s;
	if(s.size()==3)reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;
    
    cin>>a>>b>>c;
    if (a+b+c<22) {
        cout<<"win"<<endl;
    }
    else {
        cout<<"bust"<<endl;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

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

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long
#define ALL(a) a.begin(),a.end()
#define vi vector<int>

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

clock_t first_attempt = clock();
inline void cek_time(){
	clock_t cur = clock()- first_attempt;
	cerr<<"TIME : "<<(double) cur/CLOCKS_PER_SEC<<endl;
}
inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

int n;

string s[2];

const int maxn = 105;
int DP[maxn][4][4];
int dp(int pos,int at,int bw){
	if(pos==-1)return 1;
	int &ret = DP[pos][at][bw];
	if(ret!=-1)return ret;
	
	ret = 0;
	rep(na,0,3)rep(nb,0,3){
		if(s[0][pos]==s[1][pos] && na!=nb)continue;
		if(s[0][pos]!=s[1][pos] && na==nb)continue;
		if(at!=3 && s[0][pos]==s[0][pos+1] && na!=at)continue;
		if(bw!=3 && s[1][pos]==s[1][pos+1] && nb!=bw)continue;
		
		if(at!=3 && s[0][pos]!=s[0][pos+1] && na==at)continue;
		if(bw!=3 && s[1][pos]!=s[1][pos+1] && nb==bw)continue;
		
		ret += dp(pos-1,na,nb);
		ret%=INF;
	}
	
	return ret;
}
int main(){
	scanf("%d",&n);
	
	rep(k,0,2)cin>>s[k];
	
	memset(DP,-1,sizeof DP);
	printf("%d\n",dp(n-1,3,3));
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int t;
int main()
{
	cin >> t;
	for(int i=1;i<=t;i++){
		int n,m; cin >> n >> m;
		bool dp[128][2]={};
		int cur = 0,nxt = 1;
		dp[m][0] = 1;
		for(int i=0;i<n-1;i++){
			for(int j=0;j<128;j++) dp[j][nxt] = 0;
			for(int j=0;j<128;j++){
				if(!dp[j][cur]) continue;
				dp[127-j][nxt] = 1;
			}
			swap(cur,nxt);
		}
		for(int i=127;i>=0;i--){
			if(dp[i][cur]){
				cout << 127*(n-1)+i << endl; break;
			}
		}
	}
}

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

int main(){
  string S;
  cin >> S;
  int flag = 0;
  REP(i,3) {
    flag |= 1 << (S[i] - 'a');
  }
  if ( flag == 7 ) cout << "Yes" << endl;
  else cout << "No" << endl;
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a=0,w=0,t=0,r=0,n;
	scanf("%d",&n);
	while(n--)
	{
		char str[5]={0};
		scanf("%s",str);
		if(str[0]=='A')
			a++;
		else if(str[0]=='W')
			w++;
		else if(str[0]=='T')
			t++;
		else 
			r++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",a,w,t,r);
}

Measured memory_bytes: 3840
#include <stdio.h>
int main(){
    
    int S,h,m,s;
    
    scanf("%d",&S);
    
    h=S/3600;
    S=S%3600;
    m=S/60;
    s=S%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
    
}

Measured memory_bytes: 592
N,M,X=map(int,input().split())
List = []
for i in range(N):
  List.append(list(map(int, input().split())))
res1= 10000000000000
res2= -1
Flag2 = False

def CheckMaster(a):
  Flag = True
  for i in range(M):
    if a[i] < X:
      Flag = False
    else:
      continue
  return Flag
    
for bits in range(2**N):
  Master=[0]*M
  Money = 0
  for j in range(N):
    if((bits>>j) & 1): 
      Money += List[j][0]#金額の足し上げ
      for k in range(M):
        Master[k] += List[j][k+1]#成熟度の足し上げ
    if CheckMaster(Master):#成熟度の確認
      Flag2 = True
      res1 = min(res1,Money) #OK なら金額が最小か判断
    else:  #NGなら無視
      pass
if Flag2:
  print(res1)
else:
  print(res2)

Measured memory_bytes: 9244
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 200006;
bool ok(int num){
    if(num % 2 == 0){
        return false;
    }
    int cnt = 0;
    for(int i = 1; i <= num; i ++){
        if(num % i == 0){
            ++cnt;
        }
    }
    return (cnt == 8);
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int ret = 0;
    for(int i = 1; i <= n; i ++){
        if(ok(i)){
            ret ++;
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
# https://atcoder.jp/contests/abc112/tasks/abc112_a

print('Hello World' if input() == '1' else int(input()) + int(input()))


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
int main(){
    int N, A;
    cin >> N;
    cin >> A;
    if(N%500 <= A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	long long int max,sum = 0;
	scanf("%lld", &max);
	for(int i = 0; i <= max; i++)
	{
		if(i % 3 != 0 && i % 5 != 0)
		{
			sum = sum + i;
		}
	}
	printf("%lld", sum);
return 0;
}

Measured memory_bytes: 1716
#include<cstdio>
#include<vector>
typedef long long ll;
const int N=1e5+3;
int M;
struct edge{int v,nxt;}g[N+N];
int n,head[N],k,f[N],g0[N+N],g1[N+N],h[N],ans[N];
std::vector<int>st[N];
inline void Insert(int u,int v){g[++k]=(edge){v,head[u]};head[u]=k;}
void Dfs0(int u,int fa){
	int v;
	f[u]=1;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa){
	  Dfs0(v,u),f[u]=(ll)f[u]*(f[v]+1)%M;  
	  st[u].push_back(i);
	}
	if(st[u].size())
	  g0[st[u][0]]=1;
	if(st[u].size()>1)
	  for(int j=1;j<st[u].size();j++)
		g0[st[u][j]]=(ll)g0[st[u][j-1]]*(f[g[st[u][j-1]].v]+1)%M;
	if(st[u].size())
	  g1[st[u][st[u].size()-1]]=1;
	if(st[u].size()>1)
	  for(int j=st[u].size()-2;j>=0;j--)
		g1[st[u][j]]=(ll)g1[st[u][j+1]]*(f[g[st[u][j+1]].v]+1)%M;
}
void Dfs1(int u,int fa){
	int v;
	ans[u]=(ll)(h[u]+1)*f[u]%M;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa)
	  h[v]=(ll)g0[i]*g1[i]%M*(h[u]+1)%M,Dfs1(v,u);
}
signed main(){
	int u,v;
	scanf("%d%d",&n,&M);
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),Insert(u,v),Insert(v,u);
	Dfs0(1,0);
	Dfs1(1,0);
	for(u=1;u<=n;u++)printf("%d\n",ans[u]);
	return 0;
}

Measured memory_bytes: 15488
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, K;


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

    if(2*N < K) cout << N << endl;
    else {
        int a = N%K;
        if(2*a < K) cout << a << endl;
        else cout << abs(a-K) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1000000000;

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {FIN
    
    ll a, b;
    cin >> a >> b;
    cout << gcd(a, b) << "\n";
    
    return 0;
}



Measured memory_bytes: 3160
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}

func NewConsole() Console {
	return Console{bufio.NewWriter(os.Stdout)}
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}

func Max(lhs int, rhs int) int {
	if lhs < rhs {
		return rhs
	} else {
		return lhs
	}
}
func Min(lhs int, rhs int) int {
	if lhs < rhs {
		return lhs
	} else {
		return rhs
	}
}

const DEF_VAL = 1<<31 - 1

type Node struct {
	begin int
	end   int
	value int
	// left  *Node
	// Right *Node
}
type Graph struct {
	// root *Node
	list []Node
}

func NewGraph(n int) Graph {
	// root := Node{0, n - 1, DEF_VAL, nil, nil}
	// return Graph{&root}
	list := make([]Node, 1)
	list[0] = Node{0, n - 1, DEF_VAL}
	return Graph{list}
}
func (this *Graph) Update(begin int, end int, value int) {
	this.list = append(this.list, Node{begin, end, value})
}

func (this *Graph) Find(index int) int {
	for i := len(this.list) - 1; 0 <= i; i-- {
		if this.list[i].begin <= index && index <= this.list[i].end {
			return this.list[i].value
		}
	}
	return -1
}

func main() {
	con := NewConsole()
	defer con.Close()

	var n, q int
	fmt.Scanf("%d %d", &n, &q)
	lines, _ := ReadLongLines(q)

	list := NewGraph(n)

	for i := 0; i < q; i++ {
		args := strings.Split(lines[i], " ")
		command := args[0]
		switch command {
		case "0":
			s, _ := strconv.Atoi(args[1])
			t, _ := strconv.Atoi(args[2])
			x, _ := strconv.Atoi(args[3])
			list.Update(s, t, x)
		case "1":
			i, _ := strconv.Atoi(args[1])
			x := list.Find(i)
			// con.Printf("Find(%d, %d) ", s, t)
			con.Printf("%d\n", x)
		}
	}
	// fmt.Println(list)
}



Measured memory_bytes: 15516
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int a, b; scan(a, b);
    int ans = (a - 1) + (a <= b);
    writeln(ans);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
using namespace std;
int main()
{
    int c1,c2,c3,c4,c5,c6;
    cin >> c1;
    cin >> c2;
    cin >> c3;
    cin >> c4;
    cin >> c5;
    cin >> c6;
    if(c1+(c2*5)+(c3*10)+(c4*50)+(c5*100)+(c6*500) >= 1000)
        cout<<"1"<<endl;
    else
        cout<<"0"<<endl;
    return 0;
}

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

class UnionFind
{
public:
    vector<int> parent;
    vector<int> sz;
    
    UnionFind(int n): parent(n), sz(n)
    {
        for(int i=0;i<n;i++)
        {
            parent[i] = i;
            sz[i] = 1;
        }
    }

    int root(int x)
    {
        return parent[x]==x ? x : parent[x] = root(parent[x]);
    }

    bool same(int x, int y)
    {
        return root(x)==root(y);
    }

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (sz[x] < sz[y])
            {
                parent[x] = y;
                sz[y] += sz[x];
            }
            else
            {
                parent[y] = x;
                sz[x] += sz[y];
            }
        }
    }

    int size(int x)
    {
        return sz[root(x)];
    }
};

#include <iostream>
#include <set>

int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> p(N);
    for (int &t: p)
        cin>>t, t--;
    vector<int> x(M), y(M);
    for (int i=0; i<M; i++)
        cin>>x[i]>>y[i], x[i]--, y[i]--;

    UnionFind UF(N);
    for (int i=0; i<M; i++)
        UF.unite(x[i], y[i]);

    vector<set<int>> V(N);
    for (int i=0; i<N; i++)
        V[UF.root(i)].insert(i);
    int ans = 0;
    for (int i=0; i<N; i++)
        for (int x: V[i])
            if (V[i].count(p[x]))
                ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 11520
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var pm = int.Parse(line[0]);
                var pe = int.Parse(line[1]);
                var pj = int.Parse(line[2]);
                Console.WriteLine(Dividing(pm, pe, pj));
            }
        }
    }
    public  static string Dividing (int pm ,int pe,int pj)
    {
        if (pm == 100 | pe == 100 | pj == 100) return "A";
        if (pm + pe >= 180) return "A";
        if (pm + pe +pj >= 240) return "A";
        if (pm + pe + pj >= 210) return "B";
        if ((pm+pe+pj >=150) && (pm >= 80 | pe >= 80)) return "B";
        return "C";
    }
}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size();  
    return 0;
}

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

using ll = long long;

struct FenwickTree
{
    int N;
    vector<int> data;

    FenwickTree(const int N) : N(N), data(N+1) {}

    void increment(const int n)
    {
        for (int i = n+1; i <= N; i += i & -i)
            data[i]++;
    }

    int query(const int n)
    {
        int result = 0;
        for (int i = n+1; i >= 1; i -= i & -i)
            result += data[i];
        return result;
    }
};

int main()
{
    int N, K; cin >> N >> K;

    struct PrefixSum { int index; ll sum; };
    vector<PrefixSum> prefix_sums;
    prefix_sums.push_back({0, 0});
    ll sum = 0;
    for (int i = 1; i <= N; i++)
    {
        int x; cin >> x;
        sum += x - K;
        prefix_sums.push_back({i, sum});
    }

    const auto compare = [&](const PrefixSum a, const PrefixSum b)
    {
        if (a.sum == b.sum)
            return a.index < b.index;
        else
            return a.sum < b.sum;
    };
    sort(begin(prefix_sums), end(prefix_sums), compare);

    ll answer = 0;
    FenwickTree tree(N+1);
    for (const PrefixSum ps : prefix_sums)
    {
        answer += tree.query(ps.index);
        tree.increment(ps.index);
    }
    cout << answer << endl;
}


Measured memory_bytes: 6512
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        L:f64
    }
    let l = L / 3f64;
    println!("{}", l * l * l);
}


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

int main(){
  int n;
  cin >> n;
  vector<int> vs(n);
  for (int i=0; i<n; i++) cin >> vs[i];
  sort(vs.begin(), vs.end());
  double ans = (vs[0]+vs[1])/2.0;
  for(int i=2; i<n; i++){
    ans = (ans+vs[i])/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import accumulate

n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]

num = [0] * (n + 1)
for l, r in lr:
    num[l - 1] += 1
    num[r] -= 1
num = list(accumulate(num))
print(num.count(m))

Measured memory_bytes: 31944
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
    string s;
    cin>>s;
    cout<<((s[0]=='9'||s[1]=='9')?"Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll adj[51][51];
ll n;
ll result[51][51];
void multiply1()
{
	ll adj1[n+1][n+1]={0};
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			for(ll k=1;k<=n;k++)
			adj1[i][j]=(adj1[i][j]%mod+adj[i][k]%mod*adj[k][j]%mod)%mod;
			
		}
	}
	for(ll i=1;i<=n;i++)
	for(ll j=1;j<=n;j++)
	adj[i][j]=adj1[i][j];
	/*for(ll i=1;i<=n;i++){
	for(ll j=1;j<=n;j++)
	cout<<adj[i][j]<<" ";
	cout<<endl;}*/
}
void multiply2()
{
	ll adj1[n+1][n+1]={0};
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			for(ll k=1;k<=n;k++)
			adj1[i][j]=(adj1[i][j]%mod+result[i][k]%mod*adj[k][j]%mod)%mod;
		}
	}
	for(ll i=1;i<=n;i++)
	for(ll j=1;j<=n;j++)
	result[i][j]=adj1[i][j];
}
void matrix_power(ll k)
{
	while(k>0)
	{
		if(k%2)
		multiply2();
		multiply1();
		k/=2;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	cin>>n;
	ll k;
	cin>>k;
	for(ll i=1;i<=n;i++)
	result[i][i]=1;
	for(ll i=1;i<=n;i++)
	for(ll j=1;j<=n;j++)
	cin>>adj[i][j];
	matrix_power(k);
	ll ans=0;
	for(ll i=1;i<=n;i++)
	for(ll j=1;j<=n;j++)
	ans=(ans%mod+result[i][j]%mod)%mod;
	cout<<ans%mod;
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

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

int main(){
	ios::sync_with_stdio(false);

	string s;
	getline(cin, s);
	
	transform(s.begin(), s.end(), s.begin(), ::toupper);

	cout<<s<<endl;
}

Measured memory_bytes: 3176
X=int(input())

answer=0
base=X
a=0

if X==2:
    print(2)
else:
    while a==0:
        for i in range(base//2):
            if base%(i+2)==0:
                base+=1
                break
            else:
                if i==base//2-1:
                    print(base)
                    a+=1
                    break
    

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll n;
  cin >> n;

  ll one = n % 10;
  if (one == 2 || one == 4 || one == 5 || one == 7 || one == 9)
  {
    cout << "hon";
  }
  else if (one == 3)
  {
    cout << "bon";
  }
  else
  {
    cout << "pon" << endl;
  }
}


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

int main () {
  int N, M;
  cin >> N >> M;

  // 偶数から2個 or 奇数から2個
  cout << (N * (N - 1) / 2) + (M * (M - 1) / 2); 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int second;
	cin >> second;
	int h, m, s;
	h = second / 3600;
	m = (second - h * 3600) / 60;
	s = second - h * 3600 - m * 60;
	cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	string s;
	int k;
	cin>>s>>k;
	rep(i, s.size()){
		if(s[i] == 'a') continue;
		int dist = 'z'-s[i]+1;
		if(dist <= k){
			k -= dist;
			s[i] = 'a';
		}
	}
	k %= 26;
	s[s.size()-1]+=k;
	cout<<s<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  string s;
  cin >> s;
  if (s.size() % 2 != 0) {
    cout << "No\n";
    return 0;
  }
  for (int i = 0; i < s.size() / 2; ++i) {
    // cout << s[2*i] << " " << s[2*i+1] << endl;
    if (s[2*i] != 'h' || s[2*i+1] != 'i') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b && a!=c) || (a==c && a!=b) || (a!=b && b==c)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main(){
	int N, M, ans=0;
  	cin >> N >> M;
  	int H[N];
  	bool check[N];
  	for(int i=0; i<N; i++){
      	/*if(check[i]==true){
        	cout << "true" << endl;
        }else{
        	cout << "false" << endl;
        }*/
    	check[i]=true;
    }
  	for(int i=0; i<N; i++){
    	cin >> H[i];
    }
  	int AB[M][2];
  	for(int i=0; i<M; i++){
    	cin >> AB[i][0] >> AB[i][1];
      	if(H[AB[i][0]-1]>H[AB[i][1]-1]){
        	check[AB[i][1]-1]=false;
        }else if(H[AB[i][0]-1]<H[AB[i][1]-1]){
        	check[AB[i][0]-1]=false;
        }else if(H[AB[i][0]-1]==H[AB[i][1]-1]){
        	check[AB[i][0]-1]=false;
          	check[AB[i][1]-1]=false;
        }
    }
  	for(int i=0; i<N; i++){
    	if(check[i]==true){
        	ans++;
        }
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4904
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1e9 + 7;
const double eps = DBL_EPSILON;

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	bool chk = true;
	cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] > a[i + 1]) {
			if (a[i] - 1 == a[i + 1]) a[i] = a[i + 1];
			else chk = false;
		}
	}
	cout << (chk ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	vi N(4);
	REP(i, 4) {
		cin >> N[i];
	}
	sort(RALL(N));
	if (N[0] == 9 && N[1] == 7 && N[2] == 4 && N[3] == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import combinations
read = sys.stdin.read

N, K, *xy = map(int, read().split())
xy = sorted(zip(*[iter(xy)] * 2))
X, Y = zip(*xy)
answer = 10 ** 20

for left, right in combinations(range(N), 2):
    width = X[right] - X[left]
    tmp_Y = sorted(Y[left:right + 1])
    h = len(tmp_Y)
    for i in range(h):
        if i + K > h:
            break

        S = width * (tmp_Y[i + K - 1] - tmp_Y[i])
        if S < answer:
            answer = S

print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define endl '\n'
#define PI acos(-1)
#define bitcount(a) __builtin_popcountll(a)
#define P pair<int,int>
#define ff first
#define ss second
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
long double eps=1e-9;
int mod=1e9+7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	if(a<=9&&b<=9)
	cout<<a*b;
	else
	cout<<-1;	
	return 0;
}

Measured memory_bytes: 256
#162D
#RGB Triplets

import collections

n=int(input())
S=input()
s=collections.Counter(S)
ans=s['R']*s['G']*s['B']
for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>n-1:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans-=1
print(ans)

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

long long arr[100000];

long long fun(long long i, long long j, long long k){
	return i*i+j*j+k*k+i*j+i*k+j*k;
}

int main(){
	long long N;
	cin>>N;
	for(int i=1; i<100; i++){
		for(int j=1; j<100; j++){
			for(int k=1; k<100; k++){
				arr[fun(i,j,k)]++;
			}
		}
	}
	for(int i=1; i<=N; i++){
		cout<<arr[i]<<'\n';
	}
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<char>s;
int main(){
    string a;
    cin>>a;
	for(int i=0;i<a.size();i++){
	    if(a[i]=='0'){s.push_back('0');}
	    else if(a[i]=='1'){s.push_back('1');}
	    else if(s.size()!=0){s.pop_back();}
	}
	for(int i=0;i<s.size();i++){cout<<s[i];}
}



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

ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=MOD;
  if(y%2==1) res*=x;
  return res%MOD;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k,ans,temp,kakeru;
  cin >> n >> k;
    ll record[k+1];
  ans = 0;
    for (ll i = 1; i < k+1; i++){
        record[i] = 0;
    }
    for(ll i = k; i > 0; i--){
        temp = (ll) pow(k / i,n);
      
        for(ll j = i*2; j <= k; j+= i){
            temp -= record[j];
         temp += MOD;
          temp %= MOD;
        }
        //record = temp;
        ans += i * temp ;
        record[i] = temp;
      ans = ans % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4432
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

int main() {
	double x,t;
    cin>>t>>x;
    cout<<t/x<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<bool>> f(n,vector<bool>(10,false));
    rep(i,n) rep(j,10) {
        int ftmp;
        cin >> ftmp;
        if(ftmp == 1) f[i][j] = true;
    }
    vector<vector<int>> p(n,vector<int>(11));
    rep(i,n) rep(j,11) cin >> p[i][j];
    const int INF = INT_MAX;
    int ans = -INF;
    for(int bits = 1;bits < 1<<10; bits++) {
        int anstmp = 0;
        vector<bool> op(10,false);
        rep(i,10) if(bits>>i&1) op[i] = true;
        rep(i,n) {
            int c = 0;
            rep(j,10) {
                if(f[i][j]&&op[j]) c++;
            }
            anstmp += p[i][c];
        }
        chmax(ans, anstmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

struct drink {
		ll A;
		ll B;
};

int main() {
		int N, M;
		cin >> N >> M;

		vector<drink> v(N, {0, 0});
		for ( int i = 0; i < N; i++ ) cin >> v[i].A >> v[i].B;

		sort(v.begin(), v.end(), [](const drink &x, const drink &y) { return x.A < y.A; });

		int bought = 0;
		ll ans = 0;
		for ( int i = 0; bought < M; i++ ) {
				if ( v[i].B <= ( M - bought ) ) {
						ans += v[i].A * v[i].B;
						bought += v[i].B;
				} else if ( v[i].B > (M - bought) ) {
						ans += v[i].A * (M - bought); 
						bought = M;
				}
		}

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


Measured memory_bytes: 1792