akhauriyash/Code-Regression huggingface dataset:
n = int(input())

times = n
table = []
for _ in range(times):
    a = int(input())
    temp = []
    for _ in range(a):
        x , y = map(int,input().split())
        temp.append([x-1,y])
    table.append(temp)  # S += [input()] とも書ける
    
def check(i,n):
    flg = True
    for j in range(n):
        if i>>j & 1:
            for x,y in table[j]:
                if (i>>x)%2 != y:
                    flg = False
                    # print(flg)
                    return flg
    # print(flg)
    return flg

# print(table)
ans = 0
for i in range(2**n):   #bit全探索
    if check(i,n):
        ans = max(bin(i).count("1"),ans)

print(ans)


Measured memory_bytes: 3064
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
 
//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}
int n,m,x,y,ans;
main(){
	cin>>n;
	int a[2][n];
	rep(i,2)rep(j,n)cin>>a[i][j];
	rep(i,n){
		int tmp=0;
		for(int j=0;j<=i;j++){
			tmp+=a[0][j];
			debug(j,a[0][j]);
		}
		for(int k=i;k<n;k++){
			tmp+=a[1][k];
			debug(k,a[1][k]);
		}
		debug();
		chmax(ans,tmp);
	}
	dans;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int in[10000010]={0};
int main(){
	int n;
	cin>>n;
	in[0]=n;
	rep(i,n){
		int a;cin>>a;
		in[a+1]--;
	}
	rep(i,10000010)in[i+1]+=in[i];
	ll out=1;
	loop(i,1,10000010){
		if(in[i]==0)break;
		out+=min(4*i,in[i]);
	}
	cout<<out<<endl;
}

Measured memory_bytes: 40220
#include <iostream>
using namespace std;
int main() {
	int N,K;
	cin >> N;
	for (int i = 1; i < 10; i++)
	{
		K = 100 * i + 10 * i + i;
		if (K >= N) {
			break;
		}
	}
	cout << K << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(x) begin(x),end(x)
using namespace std;

int main(){
  string s,t;
  cin>>s>>t;
  vector<uint64_t> h(26);
  random_device rd;
  mt19937 mt(rd());
  REP(i,26) {
    h[i] = mt();
  }
  int ml = 0;
  REP(l,4001) {
    if (!l) continue;
    bool isok=false;
    if (min(s.size(), t.size()) >= l) {
      uint64_t hs = 0;
      uint64_t ht = 0;
      REP(i,l) hs += h[s[i]-'a'];
      REP(i,l) ht += h[t[i]-'a'];
      vector<uint64_t> vs, vt;
      vs.push_back(hs);
      REP(i, s.size()-l) {
        hs += h[s[i+l]-'a'] - h[s[i]-'a'];
        vs.push_back(hs);
      }
      vt.push_back(ht);
      REP(i, t.size()-l) {
        ht += h[t[i+l]-'a'] - h[t[i]-'a'];
        vt.push_back(ht);
      }
      sort(ALL(vt));
      REP(i,vs.size()) {
        auto itr = lower_bound(ALL(vt), vs[i]);
        if (itr != end(vt) && *itr == vs[i]) isok = true;
      }
    }
    if (isok) {
      ml = l;
    }
  }
  cout << ml << endl;
  return 0;
}

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

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

  vector<double> v(n);
  for (int i = 0; i < n; i++){
    cin >> v.at(i);
  }

  sort(v.begin(), v.end());
  for(int i = 0; i < n - 1; i++){
    v.at(i + 1) = (v.at(i) + v.at(i + 1)) / 2;
  }

  cout << v.at(n - 1) << endl;

  return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    let k = keta(b);

    if a == 0 {
        a = 1;
    }

    let xor_b = make(b, k);
    let xor_a = make(a - 1, k);

    let xor: Vec<bool> = xor_b.iter().zip(xor_a.iter())
        .map(|(b, a)| b != a)
        .collect();

    let mut ans: usize = 0;
    let mut x: usize = 1;
    for i in (0..k).rev() {
        if xor[i] {
            ans += x;
        }
        x *= 2;
    }
    ans.to_string()
}

fn keta(mut n: usize) -> usize {
    if n == 0 {
        return 1;
    }
    let mut k = 0;
    while n > 0 {
        n /= 2;
        k += 1;
    }
    k
}

fn make(n: usize, k: usize) -> Vec<bool> {
    let mut result = vec![false; k];
    let mut x = 2;
    for i in (0..k).rev() {
        let mut count = (n + 1) / x * x / 2;
        if (n + 1) % x > x / 2 {
            count += (n + 1) % x - x / 2;
        }
        result[i] = count % 2 == 1;
        x *= 2;
    }
    result
}


Measured memory_bytes: 2128
from fractions import Fraction
from itertools import product

A, B, C, D, E, F = map(int, input().split(' '))

a_max = F // (A * 100)
b_max = F // (B * 100)

waters = set()

for a, b in product(range(0, a_max + 1), range(0, b_max + 1)):
    w = (a * A + b * B) * 100
    if w > F:
        continue

    waters.add(w)

waters = sorted(waters)[1:]
sugars = []

for w in sorted(waters):
    f1 = F - w
    f2 = w // 100 * E
    c_max = min(f1 // C, f2 // C)
    d_max = min(f1 // D, f2 // D)

    max_sugar = 0

    for c, d in product(range(0, c_max + 1), range(0, d_max + 1)):
        s = C * c + D * d
        if s > f1 or s > f2:
            continue
        max_sugar = max(max_sugar, s)

    sugars.append(max_sugar)

dense = [Fraction(s, s + w) for w, s in zip(waters, sugars)]

max_dense = 0
index = -1
for i, d in enumerate(dense):
    if d > max_dense:
        max_dense = d
        index = i

if index == -1:
    print(A * 100, 0)
else:
    print(waters[index] + sugars[index], sugars[index])


Measured memory_bytes: 10404
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Created by zzt on 17-1-16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int L = scanner.nextInt();

        UnionFind road = new UnionFind(N);
        UnionFind railway = new UnionFind(N);

        for (int i = 0; i < K; i++) {
            road.union(scanner.nextInt() - 1, scanner.nextInt() - 1);
        }
        for (int i = 0; i < L; i++) {
            railway.union(scanner.nextInt() - 1, scanner.nextInt() - 1);
        }
        Map<Long, Integer> count = new HashMap<>();
        for (int i = 0; i < N; i++) {
            long key = (long) road.find(i) * N +railway.find(i);
            if (count.containsKey(key))
                count.put(key, count.get(key) + 1);
            else
                count.put(key, 1);
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N; i++) {
            long key = (long) road.find(i) * N +railway.find(i);
            sb.append(count.get(key)).append(" ");
        }
        System.out.println(sb);
    }

    static class UnionFind {
        private int[] id;
        private int count;
        private int[] sz;

        public UnionFind(int n) {
            count = n;
            id = new int[n];
            sz = new int[n];
            for (int i = 0; i < n; i++) {
                id[i] = i;
                sz[i] = 1;
            }
        }

        public int count() {
            return count;
        }

        public boolean connected(int p, int q) {
            return find(p) == find(q);
        }

        public int find(int p) {
            while (p != id[p]) {
                id[p] = id[id[p]];
                p = id[p];
            }
            return p;
        }

        public void union(int p, int q) {
            int i = find(p);
            int j = find(q);

            if (i == j)
                return;
            if (sz[i] < sz[j]) {
                id[i] = j;
                sz[j] += sz[i];
            } else {
                id[j] = id[i];
                sz[i] += sz[j];
            }
            count--;
        }
    }
}

Measured memory_bytes: 105796
import std.stdio, std.conv, std.string, std.algorithm;

void main()
{
auto ip = readln.split.to!(int[]);
auto x = 0;
if(ip[0] <= ip[1]){
  x += ip[0];
} else {
  x += ip[0] - 1;
}
  writeln(x);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define inf 0x3f3f3f3f
#define MN 100005
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int a[MN],n,k,pos,res;
int main()
{
	n=in();k=in();res=inf;
	for (int i=1;i<=n;++i) a[i]=in();a[n+1]=inf;
	pos=lower_bound(a+1,a+n+1,0)-a;
	if (pos+k-1<=n) res=min(res,a[pos+k-1]);
	if (a[pos]){
		if (pos-k>0) res=min(res,-a[pos-k]);
	}else{
		if (pos-k+1>0) res=min(res,-a[pos-k+1]);
	}
	for (int i=max(0,((a[pos])?pos-k:pos-k+1))+1;i<pos&&i+k-1<=n;++i)
	res=min(res,2*(a[i+k-1]-a[i])-max(a[i+k-1],-a[i]));
	printf("%d",res);return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
{
	int n,i,j,c,c1=0;
	cin>>n;
	string s1="ABC";
	string s2;
	cin>>s2;
	for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
			{
				if(s1[j]!=s2[i+j])
					break;
			}
		if(j==3)
		{
			c1++;
			j=0;
		}
	}
		
	cout<<c1<<endl;	
}

Measured memory_bytes: 3544
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>

void transferToGengo(int, int, int);

int main(void)
{
    int year, month, day;
    
    while (scanf("%d%d%d", &year, &month, &day) != EOF) {
        transferToGengo(year, month, day);
    }
    
    return 0;
}

void transferToGengo(int year, int month, int day)
{
    //年月日をくっつけて、大小を比較する。
    //intが16bitだと死ぬので32bitで指定する。
    int32_t year_month_day = year * 10000 + month *100 + day;
    
    if (year_month_day < 18680908) {
        printf("pre-meiji\n");
    } else if (year_month_day <= 19120729) {
        printf("meiji %d %d %d\n", year - 1868 + 1, month, day);
    } else if (year_month_day <= 19261224) {
        printf("taisho %d %d %d\n", year - 1912 + 1, month, day);
    } else if (year_month_day <= 19890107) {
        printf("showa %d %d %d\n", year - 1926 + 1, month, day);
    } else {
        printf("heisei %d %d %d\n", year - 1989 + 1, month, day);
    }

}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s1, s2;
    cin >> s1;
    reverse_copy(s1.begin(), s1.end(), back_inserter(s2));

    // 処理

    // 出力
    cout << (s1 == s2 ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int64_t> a(n);
    int cnt = 0;
    for(auto& e : a){
        cin >> e;
        if(e < 0){
            cnt++;
            e *= -1;
        }
    }
    sort(begin(a), end(a));
    if(a[0] == 0) cnt = 0;
    int64_t ans = accumulate(begin(a), end(a), 0LL);
    if(cnt % 2 != 0){
        ans -= 2 * a[0];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct node{
    int x,y,d;
}p[N],Q[N*2];
int fa[N];
bool cmp1(node a, node b ){
    return a.x<b.x;
}
bool cmp2(node a, node b ){
    return a.y<b.y;
}
bool cmp3(node a, node b ){
    return a.d<b.d;
}
int fin(int x){
    if(x!=fa[x]) fa[x]=fin(fa[x]);
    return fa[x];
}
void unit(int a,int b){
    int xx = fin(a);
    int yy =  fin(b);
    if(xx!=yy){
        fa[xx] = yy;
    }
}
bool check(int x,int y){
    if(fin(x)==fin(y)) return true;
    else return false;
}
int cnt=0;
int a(){
    int res=0 ;
    for(int i = 0 ; i< cnt ; i++){
        if(Q[i].d==0) unit(Q[i].x,Q[i].y);
        if(!check(Q[i].x,Q[i].y)){
            unit(Q[i].x,Q[i].y);
            res+=Q[i].d;
        }
    }
    return res;
}
int main(){
    int n ;
    cin>>n;
    for(int i = 0 ; i <=n ; i ++) fa[i] = i ;
    for(int i = 0 ; i < n ; i ++ ){
        cin >> p[i].x >> p[i].y;
        p[i].d = i;
    }
    sort(p , p + n , cmp1 );
    for(int i = 1; i < n ; i ++ ){
        Q[cnt].x=p[i-1].d;
        Q[cnt].y=p[i].d;
        Q[cnt].d = p[i].x - p[i-1].x;
        cnt++;
    }
    sort(p , p+ n , cmp2);
    for(int i = 1; i < n ; i ++ ){
        Q[cnt].x=p[i-1].d;
        Q[cnt].y=p[i].d;
        Q[cnt].d = p[i].y - p[i-1].y;
        cnt++;
    }
    sort(Q,Q+cnt,cmp3);
    int ans =a() ;
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;

ll ce(ll a, ll b)
{
	return (a+b-1)/b;
}

int main()
{
	ll x, k, d, l;
	scanf("%lld%lld%lld", &x, &k, &d);
	l = ce(abs(x), d);
	if (k >= l) printf("%lld\n", llabs((k-l)%2 ? llabs(x)-(l-1)*d : llabs(x)-l*d));
	else printf("%lld\n", llabs(llabs(x)-k*d));
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<c;++a)
#define repeq(a,b,c) for(int a=b;a<=c;++a)
#define debug(x) cerr<<(#x)<<": "<<x<<endl
typedef long long ll;
const int SZ=1e6;
ll s[SZ], a,b,c,d,e,f;
void test(ll x, ll j)
{
	if(j<=f && x>s[j] && (100+e)*x<=e*j)
		s[j] = x;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c >> d >> e >> f;
	repeq(i,0,f)
		s[i]=-1;
	s[0] = 0;
	ll bests, bestt;
	repeq(i,0,f)
		if(s[i]!=-1)
		{
			test(s[i],i+100*a);
			test(s[i],i+100*b);
			test(s[i]+c,i+c);
			test(s[i]+d,i+d);
			if(s[i]*bestt >= bests*i)
			{
				bestt = i;
				bests = s[i];
			}
		}
	cout << bestt << " " << bests << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
char a,b;
  cin>>a>>b;
  if(a=='H'){
  	if(b=='H'){
    cout<<"H"<<endl;
    }
    else{
    cout<<"D"<<endl;
    }
   }
  else{
  if(b=='H'){
  cout<<"D"<<endl;
  }
    else{
    cout<<"H"<<endl;
    }
  }
}

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

using namespace std;

int main(){

int a,b,c;

cin>>a>>b>>c;

if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)){

cout<<"YES"<<endl;

}

else cout<<"NO"<<endl;

return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll n, a[N], b[N], d[N], sum=0, cnt=0, les=0;
inline bool cmp( int x, int y )
{
	return x>y;
}
int main()
{
	scanf( "%lld", &n );
	for ( int i=1; i<=n; i++ )
	  scanf( "%lld", &a[i] );
	for ( int i=1; i<=n; i++ )
	  scanf( "%lld", &b[i] );
	for ( int i=1; i<=n; i++ )
	{
	    if ( a[i]<b[i] ) sum+=b[i]-a[i], ++les;
	    if ( a[i]>b[i] ) d[++cnt]=a[i]-b[i];
	}
	sort( d+1, d+cnt+1, cmp );
	int p=0;
	while ( sum>0&&p<cnt ) sum-=d[++p];
	if ( sum>0 ) printf( "-1" ); 
	else printf( "%lld", les+p );
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x,int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
		return ans;
}
int yakusuunowa(int n) {
	int ans=0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
int a[3];
signed main() {
	for (int i = 0; i < 3; i++)cin >> a[i];
	sort(a, a + 3);
	if ((a[2] - (a[0] + (a[2] - a[1]))) % 2 == 0)cout << (a[2] - a[1]) + (a[2] - (a[0] + (a[2] - a[1]))) / 2 << endl;
	else cout <<( a[2] - a[1]) + (a[2] - (a[0] + (a[2] - a[1]))) / 2 + 2 << endl;
	ll
}

Measured memory_bytes: 256
fn main() {
    let a = read_vec::<usize>();
    if a[0] + a[1] + a[2] >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int l = -(s[n-1]=='L'); 
    int r = -(s[0]=='R');
    int ans = 0;
    for(int i = 1; i < n; i++){
        if(s[i]=='L' && s[i-1]!=s[i]) r++;
        else if(s[i]=='R' && s[i]==s[i-1]) ans++;
        else continue;
    }
    for(int i = n-2; i>=0; i--){
        if(s[i]=='R' && s[i]!=s[i+1]) l++;
        else if(s[i]=='L' && s[i]==s[i+1]) ans++;
        else continue;
    }
    int p = 0;
    int q = 0;
    if(l<=k){
        p += 2*l;
        int t = k-l;
        if(s[0]=='L' && t>0){
            p++;
            t--;
        }
        if(s[n-1]=='L' && t>0){
            p++;
        }
    }
    else{
        p += 2*k;
    }
    if(r<=k){
        q += 2*r;
        int t = k-r;
        if(s[0]=='R' && t>0){
            q++;
            t--;
        }
        if(s[n-1]=='R' && t>0){
            q++;
        }
    }
    ans += max(p,q);
    cout << ans << endl;
}

Measured memory_bytes: 512
require 'pp'

c = []
c[0] = gets.chomp!.split(" ").map(&:to_i)
c[1] = gets.chomp!.split(" ").map(&:to_i)
c[2] = gets.chomp!.split(" ").map(&:to_i)

if c[0].zip(c[1]).map {|i, j| i - j }.uniq.length == 1 &&
   c[1].zip(c[2]).map {|i, j| i - j }.uniq.length == 1 &&
   c[2].zip(c[0]).map {|i, j| i - j }.uniq.length == 1
    x = c.transpose
    
    if x[0].zip(x[1]).map {|i, j| i - j }.uniq.length == 1 &&
       x[1].zip(x[2]).map {|i, j| i - j }.uniq.length == 1 &&
       x[2].zip(x[0]).map {|i, j| i - j }.uniq.length == 1
        puts "Yes"
    else
        puts "No"
    end
else
    puts "No"
end


Measured memory_bytes: 2300
#include<cstdio>
#include<bits/stdc++.h>
#define fi first
#define sc second
#define pb push_back


using namespace std;
 
 
int N, A;
int main() { 
	
	cin >> N >> A;
	N -= (500 * (N / 500));
	if (N > A) cout << "No\n";
	else cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    int H;
    int N;
    cin >> H >> N;
    int sum;
    int summand;
    sum=0;
    for (int i = 0; i < N; ++i){
        cin >> summand;
        sum+=summand;
    } 
    if (H<=sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
 
int main() {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
 
	vector<int> Nums;
	int now = 1; //今見ている数
	int cnt = 0; //nowがいくつ並んでいるか
	for (int i = 0; i < N; i++)
	{
		if (S[i] == (char)('0' + now)) cnt++;
		else {
			Nums.push_back(cnt);
			now = 1 - now; //0と1を切り替える時の計算 now ^= 1;
			cnt = 1; //新しいのをカウントし始める
		}
	}
	if (cnt != 0) Nums.push_back(cnt);
 
	//1-0-1-0-1-0-1って感じの配列が欲しい
	//1-0-1-0みたいに0で終わってたら、適当に１つ足す
	if (Nums.size() % 2 == 0) Nums.push_back(0);
 
	int Add = 2 * K + 1;
 
	//累積和を作る
	// 0 1 2 3 4 5 6
	//  0 1 2 3 4 5
 
	vector<int> sum(Nums.size() + 1);
	for (int i = 0; i < Nums.size(); i++)
	{
		sum[i + 1] = sum[i] + Nums[i];
	}
 
 
	int ans = 0;
	//1-0-1...の1から始めるので、偶数番目だけ見る
	for (int i = 0; i < Nums.size(); i += 2)
	{
		//次のleft, rightを計算する [left, right)
		int left = i;
		int right = min(i + Add, (int)Nums.size());
		int tmp = sum[right] - sum[left];
 
		ans = max(tmp, ans);
	}
 
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<P> a;
    for(int i = 0; i < n; i++){
        int aa;
        cin >> aa;
        a.push_back(P(aa, i));
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++)cout << a[i].second+1 << endl;

    return 0;
}

Measured memory_bytes: 1780
# N, Mが十分に大きい時
# 頂点: 4
# 端: 6
# それ以外: 9
# ひっくり返る
# はじめ表なので
# 頂点: 4 -> 表
# 端: 6 -> 表
# それ以外: 9 -> 裏
# となる。
# N, Mが小さい時は場合分けする必要がある
# NかMのどちらかだけが1のとき
# 頂点: 2 -> 表
# 端: 3 -> 裏
# それ以外: 3 -> 裏
# NかMのどちらかだけが2のとき
# 頂点: 4 -> 表
# 端: 6 -> 表
# それ以外: 6 -> 表
# NかMのどちらも1のとき
# 頂点: 1 -> 裏
# 端: 1 -> 裏
# それ以外: 1 -> 裏

# 頂点: max(N, 2) * max(M, 2)
# # 端(N>=3): min((N - 1) * (M), 6)

N, M = map(int, input().split())
N, M = max(N, M), min(N, M)
if N >= 3 and M >= 3:
    ans = N * M - (2 * N + 2 * M - 4)
    print(ans)
    exit()

if N >= 3 and M == 2:
    print(0)
    exit()

if N >= 3 and M == 1:
    print(N * M - 2)
    exit()

if N == 2:
    print(0)
    exit()

if N == 1 and M == 1:
    print(1)
    exit()


Measured memory_bytes: 3064
# coding: utf-8
# Your code here!

# リストのおさらい
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

p=input().rstrip()

weather=["Sunny","Cloudy","Rainy"]
for i in range(3):
    if p==weather[i]:
        #print(i)
        print(weather[(i+1)%3])
    #print(i)
    #print(weather[(i+1)%3])
#print(p)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);

int f(ll x) {
  int y = 0;
  while (x != 0) {
    x /= 10;
    y++;
  }
  return y;
}
 
int main() {
  ll N; cin >> N;
  int ans = 10;
  for (ll i = 1; i*i <= N; i++) {
    if (N % i == 0) {
      ll A = i;
      ll B = N / i;
      int F = max(f(A),f(B));
      ans = min(ans,F);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    res = Math.pow(parseInt(input[0])/3,3);
	console.log(res);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
#define M 200005

using namespace std;

int vis[200005];
vector<int>v[200005];
void dfs(int u)
{
    vis[u] = true;
    for(auto it : v[u])
    {
        if(!vis[it])
            dfs(it);
    }
    return ;
}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin >> n >> m;

    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    int ans  =0;

    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            ans++;
            dfs(i);
        }
    }
    cout << ans-1 << endl;
    return 0;

}


Measured memory_bytes: 12340
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int a,b,c,x,y;
  int num=0;
  cin >> a >> b >> c >> x >> y;
  if (a+b > 2*c) {
    if(x <= y) {
      if(b >= 2*c) {
        num=c*2*y;
      } else {
        num=c*2*x+b*(y-x);
      }
    } else {
      if(a >= 2*c) {
        num=c*2*x;
      } else {
        num=c*2*y+a*(x-y);
      }
    }
  } else {
    num=a*x+b*y;
  }
  cout << num << endl;
}


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

int main()
{
   int n,m;
   cin>>n>>m;
   int a[n+1];
   memset(a,0,sizeof(a));
   int ans1=0,ans2=0;
   while(m--)
   {
       int k;
       string s;
       cin>>k>>s;
       if(s=="WA")
       {
           if(a[k]==-1)
           {

           }
           else
           {
               a[k]++;
           }
       }
       else
       {
           if(a[k]!=-1)
           {
              ans1+=1;
              ans2+=a[k];
              a[k]=-1;
           }

       }

   }
   cout<<ans1<<" "<<ans2;
}


Measured memory_bytes: 640
#include<stdio.h>

#define BASENUMBER 10
#define MAX_PAY_ORDER 5
#define OK 1
#define NO 0

int power(int b, int p){
	int calc=1;
	for(int i=0; i<p; i++) calc*=b;
return calc;
}	

int getmin(int *D){
	for(int i=0; i<BASENUMBER; i++){
		if(D[i]==OK) return i;
	}
return -1;
}

int Num_order(int N){
	int order=0;

	for(order; ; order++){
		if(N/BASENUMBER==0){
			break;
		}else{
			N/=BASENUMBER;
		}
	}
return order;
}

int pay(int *N, int *D, int *min_useful_number){
	int n=*N, ans=0, flag=0;
	int N_order=Num_order(n);
	int payorder=N_order;
	int temp[MAX_PAY_ORDER];
	for(int i=0; i<MAX_PAY_ORDER; i++) temp[i]=*min_useful_number;

	do{
		if(payorder>N_order){
			for(int i=0; i<payorder; i++) temp[i]=*min_useful_number;
			
			if(*min_useful_number==0){
				for(int i=1; i<BASENUMBER; i++){
					if(D[i]==OK) temp[payorder]=i;
				}
			}

			for(int i=0; i<=payorder; i++){
				ans += temp[i] * power(BASENUMBER, i);
			}
			return ans;
		}

		int digit = ((*N)%power(BASENUMBER, payorder+1)) / power(BASENUMBER, payorder);

		if(D[digit]==OK && flag==0){
			temp[payorder]=digit;
			n -= digit * power(BASENUMBER, payorder);
			
			if(n==0){
				flag=1;
			}else{
				payorder--;
				continue;
			}
		
		}else{ 
			for(int i=digit+1; i<BASENUMBER; i++){
				if(D[i]==OK){
					temp[payorder]=i;
					flag=1;
					break;
				}
			}
		}

		payorder++;
		flag = (flag==1) ? 1 : -1;

	}while(flag!=1 && payorder<=MAX_PAY_ORDER);

	for(int i=0; i<=N_order; i++){
		ans += temp[i] * power(BASENUMBER, i);
	}
return ans;
}

int main(void){
	int N=0, K=0, temp=0, D[BASENUMBER], min_useful_number;
	for(int i=0; i<BASENUMBER; i++) D[i]=OK;

	scanf("%d %d", &N, &K);
	for(int i=0; i<K; i++){
		scanf("%d", &temp);
		D[temp]=NO;
	}

	min_useful_number=getmin(D);

	printf("%d\n", pay(&N, D, &min_useful_number));

return 0;
}


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

bool edge[9][9];
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		edge[a][b] = edge[b][a] = true;
	}
	int ans = 0;
	vector<int> v(n);
	for(int i = 0; i < n; i++) v[i] = i+1;
	do {
	    bool ok = true;
	    for(int i = 0; i < n-1; i++){
	    	if(!edge[v[i]][v[i+1]]) ok = false;
	    }
	    if(ok) ans++;
	} while(next_permutation(v.begin()+1, v.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner cin= new Scanner(System.in);
		int n=cin.nextInt();
		int k=n%10;
		if(k==2||k==4||k==5||k==7||k==9)
		{
			System.out.println("hon");
		}
		else
		{
			if(k==0||k==1||k==6||k==8)
			{
				System.out.println("pon");	
			}
			else
			{
				System.out.println("bon");
			}
		}
	}

}


Measured memory_bytes: 27072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e10;

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	for(auto &a : A) cin >> a;
	multiset<ll> st;
	st.insert(A[0]);
	for(int i=1;i<N;i++) {
		auto itr = st.lower_bound(A[i]);
		// 存在しなかった
		if(itr == st.begin()) {
			// A[i]を挿入
			st.insert(A[i]);
		} else {
			itr--;
			st.erase(itr);
			st.insert(A[i]);
		}
	}
	cout << st.size() << endl;
}

Measured memory_bytes: 5760
import itertools
import functools
import operator

N = int(input())

# nの約数をすべて求める
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

# 総積
prod = functools.partial(functools.reduce, operator.mul)

dists = []
# N = i*jとなる(i,j)のすべての組
for i in make_divisors(N):
    j = int(N/i)
    # print(i,j)

    # (i,j)までの距離
    dists.append(i-1 + j-1)

print(min(dists))

Measured memory_bytes: 4060
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
int n,tot,head[100010],to[200010],nxt[200010];
void add_edge(int u,int v){
	nxt[++tot]=head[u];
	to[tot]=v;
	head[u]=tot;
	return;
}
int dfs(int u,int father){
	int ret=0;
	for(int i=head[u];i;i=nxt[i]){
		int v=to[i];
		if(v!=father)
			ret+=dfs(v,u);
		if(ret>=2){
			puts("First");
			exit(0);
		}
	}
	return ret^1;
}
int rd(){
	int x=0;
	char c;
	do c=getchar();
	while(!isdigit(c));
	do{
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}while(isdigit(c));
	return x;
}
int main(){
	n=rd();
	for(int i=1;i<n;i++){
		int u=rd(),v=rd();
		add_edge(u,v);
		add_edge(v,u);
	}
	puts(dfs(1,0)?"First":"Second");
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    int a=0;
    if(n>104)a++;
    if(n>134)a++;
    if(n>164)a++;
    if(n>188)a++;
    if(n>194)a++;
    printf("%d\n",a);
}

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

int main(){
  string A;
  string B;
  cin >> A >> B;
  if(A.at(0)==B.at(2)&&A.at(1)==B.at(1)&&A.at(2)==B.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int gcd(int a, int b) {
    if(b > a) return gcd(b, a);
    else if(b == 0) return a;
    else return gcd(b, a % b);
}
vector<int> enum_div(int n)//nの約数を列挙
{
	vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int G = gcd(A, B);
    vector<int> v = enum_div(G);
    sort(v.begin(), v.end());
    set<int> st;
    for(auto &e: v) st.insert(e);
    int ans = 0;
    for(auto &e: v) {
        if(st.find(e) != st.end()) {
            //cerr << e << endl;
            ans++;
            auto itr = st.begin();
            if(e == 1) continue;
            while(itr != st.end()) {
                int num = *itr;
                if(num % e == 0) {
                    itr = st.erase(itr);
                } else {
                    itr++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    while (a.at(i)%2 == 0) {
      a.at(i) /= 2;
      count += 1;
    }
  }
  
  cout << count;

  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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;

}

vector< LL > Div( LL n ) {
    vector< LL > ret;
    for( LL i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL n;
    cin >> n;
    vector< LL > div = Div(n);

    LL sum = 0;
    for( int i = 0; i < div.size(); ++i ) {
        --div[i];
        if( div[i] == 0 ) continue;
        if( n / div[i] == n % div[i] ) sum += div[i];

    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 384
class UnionFind():
  def __init__(self, n):
    self.par = [i for i in range(n)]

  def root(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  
  def unite(self, x, y):
    x = self.root(x)
    y = self.root(y)
    self.par[y] = x

  def same(self, x, y):
    return self.root(x) == self.root(y)

N, Q = map(int, input().split())
uf = UnionFind(N)

for q in range(Q):
  c, x, y = map(int, input().split())
  if c:
    print(int(uf.same(x, y)))
  else:
    uf.unite(x, y)


Measured memory_bytes: 5996
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]

li.sort(key=lambda x:(x[0],x[1]))
cost = 0

while m > 0:
    if li[0][1] > 0:
        cost += li[0][0]
        li[0][1] -= 1
        m -= 1
    else:
        li.pop(0)

print(cost)

Measured memory_bytes: 35300
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int n,k;
vector<int> books[12];
int bn[12];
int dp[2002][12][2002]={0};//[何個目か][ジャンル][同じだった回数]

int solve(int co,int ja,int pt){
  if(dp[co][ja][pt]>0) return dp[co][ja][pt];
  int ret;
  if(co>=k) ret=0;// cout << "end" << endl;}
  else if(pt>=bn[ja]){
    //cout << "jamp" << endl;
    if(ja+1>10) ret=0;// cout << "end" << endl;}
    else ret=solve(co,ja+1,0);
  }
  else{
    // cout << co << " " << ja << " " << pt << endl;
    //cout << "現在値"<<books[ja][pt]+(pt*(pt+1)-pt*(pt-1)) << endl;
    ret=max(solve(co,ja+1,0),solve(co+1,ja,pt+1)+books[ja][pt]+(pt*(pt+1)-pt*(pt-1)));
  }
  //cout << co << " " << ja << " " << pt << "結果" << ret << endl;
      return dp[co][ja][pt]=ret;
}

main(){
  cin >> n >> k;
  for(int i=0;i<n;i++){
    int c,g;
    cin >> c >> g;
    books[g].push_back(c);
    bn[g]++;
  }
  int res=0;
  for(int i=1;i<11;i++){
    sort(books[i].begin(),books[i].end(),greater<int>());
    // for(int j=0;j<bn[i];j++)
      // cout << books[i][j] <<  " : " << i << endl;
  }
  res=solve(0,1,0);

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

Measured memory_bytes: 0
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

using namespace std;


int main(){

                int a,b;
                cin>>a>>b;

                if((a==1&&b==2)||(a==2&&b==1)){
                    cout<<"3";
                }
                 else if((a==2&&b==3)||(a==3&&b==2)){
                    cout<<"1";
                }
                else{
                    cout<<"2";
                }


         }
//Pavel


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

int main() {
	ll n;
	cin >> n;
	string ans = "";
	while (n) {
		n--;
		ans += ('a' + (n % 26));
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;

}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<=b;i++)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;

int N, C, X;
int D[30][39];
int t[3][30];

int main() {
	
	cin >> N >> C;

	rep(i, C)rep(j, C)cin >> D[i][j];
	rep(i, N)rep(j, N)cin >> X, t[(i + j) % 3][X - 1]++;
	int res = 1 << 30;

	rep(i, C)rep(j, C)if (i != j)rep(k, C)if (i != k&&j != k) {
		int tt = 0;
		rep(l, C)tt += D[l][i] * t[0][l];
		rep(l, C)tt += D[l][j] * t[1][l];
		rep(l, C)tt += D[l][k] * t[2][l];

		if (tt < res)res = tt;
	}

	cout << res << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> X(N+1);
  vector<int> Y(N+1);
  vector<int> T(N+1);
  X[0] = Y[0] = T[0] = 0;
  for (int i=0; i<N; i++) cin >> T[i+1] >> X[i+1] >> Y[i+1];

  bool f = true;
  for (int i=0; i<N; i++) {
    int d = T[i+1] - T[i];
    int dist = abs(X[i+1] - X[i]) + abs(Y[i+1] - Y[i]);
    if (dist > d) f = false;
    if (dist % 2 != d % 2) f = false;
  }

  if (f) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1408
import math

a, b, x = map(int, input().split())

y = a * (b ** 2) / (2 * x)
z = 2 * (a**2 * b - x)/ a**3
u = z * a
t = math.atan(y)
t = math.degrees(t)
p = math.atan(z)
p = math.degrees(p)
if u >= b:
    print(t)
else:
    print(p)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <fstream>
using namespace std;
typedef long long ll;

int main(){
  int n,x,y;cin>>n>>x>>y;
  vector<int> ans(n+1,0);
  for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
      int dist=min(min(j-i,abs(i-x)+abs(j-y)+1),abs(i-y)+abs(j-x)+1);
      ans[dist]++;
  }
  for(int i=1;i<n;i++)cout<<ans[i]<<endl;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 1e5 + 5;
const int inf = 1e16 + 2;


void solve(int Case) {
    int d , t , s ;
    cin >> d >> t >> s ;
    t *= s ;
    if(t >= d) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case ++);
    }
    return 0;
}


Measured memory_bytes: 3608
n,a,b=map(int,input().split())
cnt=0
c=100000000000000000
if (b-a)%2 == 0:
  cnt=b-(b+a)//2
  print(cnt)
  exit()
if (b-a)%2 == 1:
    cnt=min(a-1,n-b)+1+((b-a-1)//2)
    print(cnt)
    exit()

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

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

Measured memory_bytes: 256
import static java.lang.Math.*;

import java.util.Scanner;

public class Main {
	  public static void main(String[] args) {
		  int n,i,b,count,kekka=0,j,c;
		  double d;
		 
	    Scanner sc=new Scanner(System.in);
	    n=Integer.parseInt(sc.next());
	    
	    int a[]=new int[n+1];
	    for(i=0;i<n;i++){
	    	a[i]=Integer.parseInt(sc.next());
	    	
	    }
	    
	    for(i=0;i<n;i++){
	    	count=0;
	    	
	    	
    	d=sqrt(a[i]);
    	
    	if((int)d<d){
    		 c=(int)d+1;
    	}
    	else{
    		 c=(int)d;
    	}
    	
	    	for(j=2;j<=c;j++){
	    		if(a[i]==2){
	    			kekka++;
	    			
	    			break;
	    		}
	    		
	    		if(a[i]%j==0){
	    			count++;
	    			
	    		}
	    		
	    		if(count==1){
	    			
	    			break;
	    		}
	    		if(j==c){
		    		kekka++;
		    		
		    	}
	    	}
	    	
	    	
	    }
	    System.out.println(kekka);
	  }
	  }

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

const int mod = 1e9+7;

int dp[111111][2];

signed main() {
	string L;
	cin >> L;
	int n = L.size();

	dp[0][0] = 1;
	for (int i = 0; i < L.size(); i++) {
		Add(dp[i+1][1], 3*dp[i][1]);
		if (L[i] == '1') {
			Add(dp[i+1][0], 2*dp[i][0]);
			Add(dp[i+1][1], dp[i][0]);
		} else {
			Add(dp[i+1][0], dp[i][0]);
		}
	}

	int ans = dp[n][0] + dp[n][1];
	ans %= mod;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2048
fun main(args: Array<String>) {
    val S = readLine()!!

    val a = S.mapIndexed { idx, c -> if (idx % 2 == 0 && c == '0' || idx % 2 == 1 && c == '1') 0 else 1 }.sum()
    val b = S.mapIndexed { idx, c -> if (idx % 2 == 0 && c == '1' || idx % 2 == 1 && c == '0') 0 else 1 }.sum()
    println(Math.min(
        a,
        b
    ))
}


Measured memory_bytes: 36204
/**
    @Author:Monk_78
    @Topic:C:Vacation
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define vpshVar() int main()

vpshVar(){
    ll N;
    sl(N);
    Vl dp(3,0);
    for(ll t=0;t<N;t++){
      Vl temp(3,0);
      ll arr[3];
      for(ll i=0;i<3;i++)
      {
          sl(arr[i]);
          if(t==0) dp[i]=arr[i];
      }

      if(t==0)continue;
      for(ll i=0;i<3;i++){
            for(ll j=0;j<3;j++){
                    if(i!=j){
                        temp[j]=max(dp[i]+arr[j],temp[j]);
                    }
            }
        }
        dp=temp;
    }
    pl(max(dp[0],max(dp[1],dp[2])));
    fflush(stdout);
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int d1[n],d2[n];
  for(int i=0;i<n;i++)
  {
    cin>>d1[i]>>d2[i];
  }
  int flag=0;
  for(int i=0;i<n-2;i++)
  {
    if(d1[i]==d2[i] && d1[i+1]==d2[i+1] && d1[i+2]==d2[i+2])
    {
      flag=1;
      break;
    }
  }
  if(flag==1)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628