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

ll keisan(ll n){
    if(n < 0) return 0;
    else return n * (n+1) / 2;
}

int main(){
    string s;
    cin >> s;
    ll i,ans,left,right,hoge,huga;
    left = 0,right = 0;
    ll size = s.length();
    if(s[0] == '<') right = 1;
    else left = 1;
        for(i = 1; i < size; i++){
            if(s[i] == '>' && s[i-1] == '>') left++;
            else if(s[i] == '<' && s[i-1] == '<') right++;
            else if(s[i] == '>' && s[i-1] == '<') left++;
            else if(s[i] == '<' && s[i-1] == '>'){
                hoge = min(left,right);
                huga = max(left,right);
                ans += keisan(hoge-1);
                ans += keisan(huga);
                left = 0;
                right = 1;
            }
        }
        hoge = min(left,right);
                huga = max(left,right);
                ans += keisan(hoge-1);
                ans += keisan(huga);

    cout << ans << endl;
    
}

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

int main() {
  int N, M; // [2, 50]
  cin >> N >> M;
  vector<int> n(N, 0); // cities
  for(int i=0;i<M;i++){
    //edges
    int a, b;
    cin >> a >> b;
    n.at(a-1)++;
    n.at(b-1)++;
  }
  for(int i=0;i<N;i++){
    cout << n.at(i) << endl;
  }
}


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

using namespace std;

int main()
{
    string S;
    cin >> S;
    for (int i = 0;i < 3;i++) {
        if(S[0] == S[1] && S[1] == S[2]){
            cout<<"No"<<endl;
            return 0;
        }else {
            cout<<"Yes"<<endl;
            return 0;
        }

    }
}




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

using namespace std;

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

    for (int i = 0; i < s.length(); i++) {
        if (s[i]-'A'+n >= 26) {
            char t = 'A'+(s[i]-'A')+n-26;
            cout << t;
        }
        else {
            char c = s[i] + n; 
            cout << c;
        }
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

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

  int cnt = 0;
  rep(i,S.size()-1){
    if(S[i] != S[i+1]) cnt++;
  }

  cout << N-1-max(0,cnt-2*K) << endl;
  
  return 0;
}



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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n) cin >> l[i];

    int position = 0;
    int count = 0;
    rep(i, n)
    {
        position += l[i];
        if (position > x)
        {
            break;
        }
        count++;
    }
    cout<<count+1<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main(){
  var a,b int
  fmt.Scan(&a,&b)

  fmt.Printf("%d", lcm(a,b))
}

func gcd(a int, b int)int{
  if b>a{
    tmp := b
    b = a
    a = tmp
  }
  if b == 0{
    return a
  }
  if a == 1 || b == 1{
    return 1
  }
  if a == b {
    return a
  } else {
    return gcd(b,a%b)
  }
}

func lcm(a int, b int)int{
  return a*b/gcd(a,b)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int x,y,z,a,b,c,s;
	scanf("%d",&x);
	if (x==1) printf("Hello World");
	else {
		scanf("%d",&y);
		scanf("%d",&z);
		printf("%d",y+z);
		
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
//function<long long(int)> choose2 = [&](int n) {};
void solve(){
	ll n,k;
	cin>>n>>k;
	ll p=(n-1)*(n-2)/2;
	if(k>p) cout<<"-1"<<endl;
	else{
		vpi ans;
		for(int i=2;i<=n;i++) ans.eb(1,i);
		for(int i=2;i<n;i++){
			for(int j=i+1;j<=n;j++){
				if(p>k){
					ans.eb(i,j);
					p--;
				}
			}
		}
		cout<<ans.size()<<endl;
		for(auto it:ans) cout<<it.f<<" "<<it.se<<endl;
	}
	
	
	
	
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
typedef pair<int,string> Q;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll total=0;
int a[200000],b[200000];
int x;
int m1,m2,n1,n2;
int c[100005]={};
string s;
vector<P> v[200001];
int ans[100005]={};
int main() {
	cin>>x;
	int m=x/105;
	if(x%105!=0)++m;
	if((m*105-x)>m*5)cout<<0<<endl;
	else cout<<1<<endl;
	return 0;
}


Measured memory_bytes: 6016
#include <stdio.h>
int main(void){
    char W[11], T[1100];
    int i, count=0;
    
    scanf("%s", &W);
    while(scanf("%s", &T)) {
        if (strcmp(T,"END_OF_TEXT") == 0)  break;
        for(i=0; i < strlen(T); i++) {
            T[i] = tolower(T[i]); 
        }
        if(strcmp(W,T) == 0) count++;
    }
    printf("%d\n", count);
    return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;  cin >> n;
    int sum = 0;
    vector<int> t(n);
    rep (i, n) {
      cin >> t[i];
      sum += t[i];
    }
    cin >> m;
    vector<int> p(m), x(m);
    rep (i, m) {
      cin >> p[i] >> x[i];
    }
    rep (i, m) {
      int ans = sum - (t[p[i] - 1] - x[i]);
      cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import math

k = int(input())
ret = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for k in range(1, k+1):
            ret += math.gcd(math.gcd(i, j), k)
print(ret)

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

int n;

int main(){
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	//--
	sort(v.begin(), v.end());
	double greed = 1.0*v[0];
	for(int i = 1; i < n; i++){
		greed = (greed + v[i])/2;
	}
	//
	printf("%.6lf", greed);
}


Measured memory_bytes: 256
n, k = input().split()
n = int(n)
k = int(k)
aa = input().split()
aa = [int(a) for a in aa]
ans = 0
nn = n
f = False
while nn > 0:
    if f:
        nn += 1
    f = True
    ans += 1
    nn -= k
print(ans)

Measured memory_bytes: 52780
N = int(input())
a = list(map(int, input().split()))
ans = [0]*9
for i in a:
    if i < 400: ans[0] = 1
    elif i < 800: ans[1] = 1
    elif i < 1200: ans[2] = 1
    elif i < 1600: ans[3] = 1
    elif i < 2000: ans[4] = 1
    elif i < 2400: ans[5] = 1
    elif i < 2800: ans[6] = 1
    elif i < 3200: ans[7] = 1
    else: ans[8] += 1
print(max(sum(ans[:8]), 1), sum(ans[:8])+ans[-1])



Measured memory_bytes: 9100
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
#define Endl endl
const int INF=100000000;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a+b+c-max({a,b,c})<<endl;
	return 0;
}

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

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = gcd(a,b);
		
		// 計算
		long result = 1;
		//System.out.println("n:" + n + "sqrt:" + sqrt(n));
		ArrayList<NumList> list = new ArrayList<NumList>();
		for(long m = 2; m*m <= n; m++){
		    if(n == 1) break;
		    if(n%m == 0){
		        NumList numList = new NumList(m, 0);
		        while(n%m == 0){
		            n = n/m;
		            numList.num2++;
		        }
		        list.add(numList);
		    }
		}
		if(n != 1) list.add(new NumList(n, 1));
		result += list.size();
		// 出力
		System.out.println(result);
        
	}
	
	static long gcd(long x, long y){
	    if(x < y){
	        long temp = x;
	        x = y;
	        y = temp;
	    }
	    if(y == 0) return x;
	    if(x%y == 0) return y;
	    return gcd(y , x%y);
	}
}

class NumList {
    long num1;
    long num2;
    
    NumList(long num1, long num2){
        this.num1 = num1;
        this.num2 = num2;
    }
}


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

const int MAX = 1500 * 1000 + 1;
int N, M;
int H[2020];
int W[2020];
ll A[MAX];
ll B[MAX];

bool solve() {
    cin >> N >> M;
    REP(i, N) cin >> H[i];
    REP(i, M) cin >> W[i];
    if (N == 0) return false;

    REP(i, N) {
        int tmp = 0;
        REP2(j, i, N) {
            tmp += H[j];
            A[tmp] += 1;
        }
    }
    
    REP(i, M) {
        int tmp = 0;
        REP2(j, i, M) {
            tmp += W[j];
            B[tmp] += 1;
        }
    }

    ll ans = 0;
    REP(i, MAX) {
        ans += A[i] * B[i];
    }
    cout << ans << endl;

    memset(A, 0, sizeof(A));
    memset(B, 0, sizeof(B));
    return true;
}

int main() {
    while (solve());
}



Measured memory_bytes: 26516
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	if (A >= B) {
		ans = A;
		A--;
	}
	else {
		ans = B;
		B--;
	}
	if (A >= B) {
		ans += A;
		A--;
	}
	else {
		ans += B;
		B--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.math, std.regex;

void main()
{
	auto n = readln.split.to!(int[]);
	if(abs(n[1] - n[0]) < abs(n[2] - n[0])){
		writeln('A');
	} else {
		writeln('B');
	}
}

Measured memory_bytes: 256
n = int(input())
a = [0]*n

def print_str():
    for i in reversed(a):
        print(chr(97+i), end='')
    print()

print_str()
while True:
    for i in range(n-1):
        if a[i] <= max(a[i+1:]):
            a[i] += 1
            for j in range(i):
                a[j] = 0
            print_str()
            break
    else:
        break


Measured memory_bytes: 5548
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e7+1;
int b[N];
void sev()
{
    for(int i=1;i<N;i++){
        for(int j=i;j<N;j+=i)b[j]++;
    }
    for(int i=1;i<N;i++)b[i]*=i;
    for(int i=1;i<N;i++)b[i]+=b[i-1];
}
main()
{
    sev();
    int n;
    cin>>n;
    cout<<b[n]<<endl;
}


Measured memory_bytes: 81696
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
  int r,g,b,sum;
  cin >> r >> g >>b;
  sum = r*100+g*10+b;
  if (sum%4 == 0)
  {
    cout << "YES" << endl;
  }else
  {
    cout << "NO"  << endl;
  }
  
  
  
  
  
 
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(13<=a) cout << b << endl;
    else if(6<=a && a<=12) cout << b/2 << endl;
    else cout << 0 << endl;

    return 0;
}

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


int main(void){
    
    string S;
    long long K;
    cin >> S >> K;
    
    long long cont = 0;
    long long contS = 0;
    long long contE = 0;

    
    if(K == 1){
        

        
        for(int i = 0; i < S.size();i++){
            if(i != S.size()-1){
                if(S[i] == S[i+1]){
                    S[i+1] = '#';
                    cont++;
                }
            }
        }
        cout << cont << endl;   
        return 0;            
    }
    

        
    if(S[0]==S[S.size()-1]){
        
        contS = 1;
        contE = 1;
            
        while(S[contS-1] == S[contS])contS++;
        while(S[S.size() - contE] == S[S.size() - contE - 1])contE++;
        
        if(S.size()==contS){
            
            if(S.size()==1){
                cout << K/2 <<endl;
                return 0;
            }
            
            if(S.size()%2==0)cout << (S.size()/2)*K <<endl;
            else{
                long long difA = S.size()/2;
                long long difB = S.size() - difA;
                //cout << difA <<" "<<difB<<endl;
                long long sum = 0;
                for(int i = 0; i < K;i++){
                    if(i%2==0)sum += difA;
                    else sum += difB;
                }
                cout << sum <<endl;
                
            } 
            return 0;
        }
    }
        
    for(int i = contS; i < S.size()-contE;i++){
        if(i != S.size()-1){
            if(S[i] == S[i+1]){
                S[i+1] = '#';
                cont++;
            }
        }else{
            if(S[0] == S[i]){
                S[0] = '#';
                cont++;
            }
        }
    }
    // cout <<contS<<endl;
    // cout <<contE<<endl;
    cout << cont * K + (contS+contE)/2*(K-1)+ contS/2+contE/2 <<endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{

int a[10000], min, max, n, i;
long long sum = 0;
scanf("%d", &n);//1??\????????\????????????????????¨?????????
for(i = 0; i < n; i++){
scanf("%d", &a[i]);
sum += a[i];
}
max = min = a[0];//??¨?????????????????????????´?????????????????????????
for(i = 1; i < n; i++){//2????????\??????????´???¨??????
if(a[i] > max)max = a[i];
if(a[i] < min)min = a[i];
}
printf("%d %d %lld\n", min, max, sum);

return 0;
}

Measured memory_bytes: 640
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    S = input()
    cnt = 0
    mx = 0
    for i in range(len(S)):
        if (S[i] == 'R'):
            cnt += 1
        else:
            cnt = 0
        mx = max(mx, cnt)
    print(mx)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9100
import java.util.Scanner;

public class Main {

    /*
     * https://atcoder.jp/contests/abc164/tasks/abc164_a
     */

    public static void main(String[] args) {

        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        stdIn.close();

        String[] arguments = input.split(" ");
        int sheep = Integer.valueOf(arguments[0]);
        int wolf = Integer.valueOf(arguments[1]);

        if (sheep > wolf) {
            System.out.print("safe");
        } else {
            System.out.println("unsafe");
        }

    }
}

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

int main(){
  int N,ans;
  string A,B,C;
  cin >> N >> A >> B >> C;
  ans=2*N;
  for(int i=0; i<N; ++i){
    if(A[i]==B[i] && B[i]==C[i]) ans -= 2;
    else if(A[i]==B[i] && B[i]!=C[i]) ans -= 1;
    else if(B[i]==C[i] && C[i]!=A[i]) ans -= 1;
    else if(C[i]==A[i] && A[i]!=B[i]) ans -= 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    num = 0
    for i in range(N):
        a, b = MI()
        if a == b:
            num += 1
            if num == 3:
                print("Yes")
                return
        else:
            num = 0

    print("No")


main()


Measured memory_bytes: 65176
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

// const (
// 	initialBufSize = bufio.MaxScanTokenSize //65536
// 	maxBufSize     = 100000
// )
func main() {
	scanner.Split(bufio.ScanWords)
	// buf := make([]byte, initialBufSize)
	// scanner.Buffer(buf, maxBufSize)

	h, w := nextInt(), nextInt()
	a := make([]string, h)
	for i := range a {
		a[i] = next()
	}
	ans := make([]string, h+2)
	for i := 0; i < w+2; i++ {
		ans[0] += "#"
	}
	for i := range a {
		ans[i+1] += "#" + a[i] + "#"
	}
	for i := 0; i < w+2; i++ {
		ans[h+1] += "#"
	}
	for _, v := range ans {
		fmt.Println(v)
	}
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}
func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main(void) {
	ll n;
	cin >> n;
	ll t = n / 11;
	n -= t * 11;
	t *= 2;
	if(n > 0) ++t;
	if(n > 6) ++t;
	cout << t << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <time.h>
using namespace std;
typedef long long ll;

int main(void) {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << min(b, n * a) << endl;

}
/*
g++ -std=c++14 _main.cpp
 */


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

using std::cout;
using std::endl;
using std::cin;

int main()
{
    uint64_t N, M;
    std::ios::sync_with_stdio(false);
    cin >> N >> M;
    if ((N << 1) > M)
    {
        cout << M / 2 << endl;
    }
    else
    {
        cout << N + (M - 2 * N) / 4 << endl;
    }
}

Measured memory_bytes: 256
n,q=map(int,input().split())
s=input()
d=[0]*n
#l=[int(i) for i in input().split()]
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        d[i]+=d[i-1]+1
    else:
        d[i]=d[i-1]
#print(*d)
for i in range(q):
    l,r=map(int,input().split())
#    print(l,r,s[l-1:r],d[l-1],d[r-1])
    print(d[r-1]-d[l-1])

Measured memory_bytes: 50904
/* Ashish Joshi
   NIT Hamirpur */

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

void test(){
	int x;cin>>x;
	cout<<(x^1);
}

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

    int t=1;
    //cin>>t;
    for(int tc=1;tc<=t;tc++){
    	// cout<<"Case #"<<tc<<": ";
    	cout<<fixed<<setprecision(15);
    	test();
    }
}

Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,Q=map(int,input().split())
    a=[0]*(N-1)
    b=[0]*(N-1)
    cns=[[] for _ in range(N)]
    for i in range(N-1):
        a[i],b[i]=map(lambda x: int(x)-1,input().split())
        cns[a[i]].append(b[i])
        cns[b[i]].append(a[i])
    l_x=[0]*N
    for i in range(Q):
        p,x=map(int,input().split())
        l_x[p-1]+=x
    c=[0]*N
    c[0]+=l_x[0]
    def saiki(pn,ppn,x):
        for cn in cns[pn]:
            if cn != ppn:
                z=x+l_x[cn]
                c[cn]+=z
                saiki(cn,pn,z)
        return
    saiki(0,0,c[0])
    print(*c)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 283696
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto V=vecin(N);
	
	int M=0;
	vector<int> G;
	for(int i=0;;i++){
		int v = (int)(pow(3,i+1))/2;
		if(v>N) break;
		M++;
		G.push_back(v);
	}
	reverse(ALL(G));

	int cnt = 0;
	REP(i,M){
		for(int j=G[i];j<N;j++){
			int v=V[j];
			int k=j-G[i];
			while(k>=0 && V[k]>v){
				V[k+G[i]] = V[k];
				k = k-G[i];
				cnt++;
			}
			V[k+G[i]]=v;
		}
	}

	out(M);
	REP(i,M-1){
		cout << G[i] << ' ';
	}
	out(G[M-1]);
	out(cnt);
	REP(i,N){
		out(V[i]);
	}

	return 0;
}



Measured memory_bytes: 6792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

int main()
{
    int N; cin >> N;
    int h, h_old = 0;

    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        cin >> h;
        if (h_old < h)
            ans += h - h_old;
        
        h_old = h;
    }

    cout << ans << endl;        
}

Measured memory_bytes: 256
def move(up,bottom,right,left,front,back,direction):
    if direction == "N":
        return (front,back,right,left,bottom,up)
    elif direction == "S":
        return (back,front,right,left,up,bottom)
    elif direction == "E":
        return (left,right,up,bottom,front,back)
    elif direction == "W":
        return (right,left,bottom,up,front,back)
    
def check(up,bottom,right,left,front,back,up_current,front_current):
    if front_current == front and up_current == up:
        print(right)     
    elif front_current == front:
        if left == up_current:
            print(up)
        elif bottom == up_current:
            print(left)
        elif right == up_current:
            print(bottom)
    elif up_current == up:
        if right == front_current:
            print(back)
        elif back == front_current:
            print(left)
        elif left == front_current:
            print(front)
    else:
      
        up,bottom,right,left,front,back = move(up,bottom,right,left,front,back,"S")
        check(up,bottom,right,left,front,back,up_current,front_current)
                
                
                
                
up,front,right,left,back,bottom = input().split()
n = int(input())

for i in range(n):
    up_current,front_current = input().split()
    check(up,bottom,right,left,front,back,up_current,front_current)
    

Measured memory_bytes: 7716
import kotlin.math.abs

fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val mod = (1e9 + 7).toLong()
        val n = sc.nextInt()
        val m = sc.nextInt()
        if (abs(n - m) >= 2) {
            println("0")
            return
        }
        var ans = if (n == m) 2L else 1L
        for (i in 1..n) {
            ans *= i
            ans %= mod
        }
        for (i in 1..m) {
            ans *= i
            ans %= mod
        }

        println(ans)
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 36452
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n = int(input())

    ans = []
    for i in range(20):
        if n == 0:
            break
        n -= 1
        ans.append(n%26)
        n //= 26

    print("".join(chr(ord('a') + i) for i in ans[::-1]))
main()

Measured memory_bytes: 65100
/* hpd.c */

#include <stdio.h>

int main(void){
   int A;
   int B;

   scanf("%d %d",&A,&B);

   if( 8 < A || 8 < B){
     printf(":(\n");
   }
   else if( (1 <= A && A <= 8) && (1 <= B && B <= 8) ){
     printf("Yay!\n");
   }

   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <string>

using namespace std;

enum dir_t {NORTH, EAST, WEST, SOUTH};
enum face_t {TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT};

class Dice {
public:
    Dice(int32_t top, int32_t bottom, int32_t front, int32_t back, int32_t left, int32_t right) {
        val[TOP]    = top;
        val[BOTTOM] = bottom;
        val[FRONT]  = front;
        val[BACK]   = back;
        val[LEFT]   = left;
        val[RIGHT]  = right;
    }

    int32_t operator[](face_t f) {
        return val[f];
    }

    void roll(dir_t dir) {
        switch (dir) {
            case NORTH: inner_roll(TOP, FRONT, BOTTOM, BACK); break;
            case EAST:  inner_roll(TOP, LEFT, BOTTOM, RIGHT); break;
            case WEST:  inner_roll(TOP, RIGHT, BOTTOM, LEFT); break;
            case SOUTH: inner_roll(TOP, BACK, BOTTOM, FRONT); break;
        }
    }

private:
    array<int32_t, 6> val;

    void inner_roll(face_t f1, face_t f2, face_t f3, face_t f4) {
        int32_t temp;
        temp = val[f1];
        val[f1] = val[f2];
        val[f2] = val[f3];
        val[f3] = val[f4];
        val[f4] = temp;

        return;
    }
};

int main() {
    int32_t top, bottom, front, back, left, right;
    string op;

    cin >> top >> front >> right >> left >> back >> bottom >> op;

    Dice d(top, bottom, front, back, left, right);

    for (uint8_t dir : op) {
        switch (dir) {
            case 'N': d.roll(NORTH); break;
            case 'E': d.roll(EAST);  break;
            case 'W': d.roll(WEST);  break;
            case 'S': d.roll(SOUTH); break;
        }
    }

    cout << d[TOP] << endl;

    return 0;
}

Measured memory_bytes: 3132
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
m = map(int, read().split())

count = [1] * (N+1)
red = [0] * (N+1)
red[1] = True
for x, y in zip(m, m):
    count[x] -= 1
    count[y] += 1
    if red[x]:
        red[y] = 1
    if not count[x]:
        red[x] = 0

print(sum(red))

Measured memory_bytes: 22496
#include<iostream>

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

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

    int x = (a + b) / 2;
    if ((a + b) % 2 != 0) {
      x++;
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int a,b,c,k;
long long ans=0;

int min(int x,int y) {
	return x<y?x:y;
}

int main() {
	read(a),read(b),read(c),read(k);
	ans+=min(a,k);
	k-=a,k-=b;
	if(k<=0) {
		std::cout<<ans<<'\n';
		return 0;
	}
	ans-=min(c,k);
	std::cout<<ans<<'\n';
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n;cin>>n;
    int mod;
    string s="";
    while(n!=0){
        n--;
        mod=n%26;
        char c=(97+mod);
        s=c+s;
        n/=26;
    }
    cout <<s<<endl;
}


Measured memory_bytes: 3572
user_input=[]
for i in range(3):
    user_input.append(input())
N=int(user_input[0])
S=user_input[1]
K=int(user_input[2])-1

S_list=[]
for i in S:
    S_list.append(i)

obj=S_list[K]
for i in range(N):
    if S_list[i] != obj:
        S_list[i]='*'
S_after=''.join(S_list)
print(S_after)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, modinv, bitSearch, bitList, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color; vll path; vl D; ll C;
//***********//
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 0) ans++;
	}
	if (ans == N) cout << "second";
	else cout << "first";
}

Measured memory_bytes: 1024
// Problem : D - Wizard in Maze
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 1005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int n,m,s1,s2,e1,e2,vis[maxn][maxn],X[]={1,-1,0,0}, Y[]={0,0,1,-1};
string adj[maxn];
bool check(int x,int y){
	return (x >=0  and x < n and y >= 0 and y < m);
}
void dfs(int x,int y,queue<pp> &q,int cnt)
{
	vis[x][y]=cnt,q.push({x,y});
	for(int i=0;i<4;i++)
	{
		int x1 = x+X[i],y1 = y+Y[i];
		if(check(x1,y1) and adj[x1][y1]=='.' and vis[x1][y1]==-1)
			dfs(x1,y1,q,cnt);
	}
}
void solve()
{
	memset(vis,-1,sizeof(vis));
	cin >> n >> m >> s1 >> s2 >> e1 >> e2;
	s1--,s2--,e1--,e2--;
	for(int i=0;i<n;i++)
	cin >> adj[i];
	queue<pp> q;
	dfs(s1,s2,q,0);
	while(q.size())
	{
		pp p = q.front();
		q.pop();
		int x=p.ff;
		int y=p.ss;
		for(int i=x-2;i<=x+2;i++)
			for(int j=y-2;j<=y+2;j++)
			if(check(i,j) and adj[i][j]=='.' and vis[i][j]==-1)
				dfs(i,j,q,vis[x][y]+1);
	}
	cout << vis[e1][e2];
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 12796
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N,M,ans=0,k=0;cin>>N>>M;
    vector<pair<int,int>>vec(N);
    REP(i,N){
        int a,b;cin>>a>>b;
        vec[i]={a,b};
    }
    sort(vec.begin(),vec.end());
    priority_queue<int>q;
    REPS(i,M){
      	while(k<=N-1&&vec[k].first==i){
            q.push(vec[k].second);
            k++;
        }
        if(!q.empty()){
            ans+=q.top();q.pop();
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> dp(n+1);
  double p;

  dp[0] = 1; //probability of i heads so far
  for (int i=0; i<n; ++i) {
    cin >> p;
    for (int j=i+1; j>=0; --j) {
      dp[j] = (!j ? 0 : dp[j-1] * p) + dp[j] * (1-p);
    }
  }

  double ans = 0;
  for (int i=n; i>n/2; --i)
    ans += dp[i];

  cout.precision(10);
  cout << ans << '\n';

  return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

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

  int n; cin >> n;
  vector<pair<ll, ll>> v(n);
  for(int i=0;i<n;++i) {
    ll x, l; cin >> x >> l;
    v[i].second = x - l;
    v[i].first = x + l;
  }
  sort(v.begin(), v.end());
  //printv(v);

  int cnt = 0;
  ll now = -LINF;
  for(int i=0;i<n;++i) {
    if(now <= v[i].second) {
      cnt++;
      now = v[i].first;
    }
  }
  cout << cnt << endl;

}


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

#define reint register int
#define coint const int

using namespace std;

typedef long long ll;

coint SIZE  = 50 + 5;
coint SIZE2 = SIZE * SIZE / 2 + 5;
coint MOD   = 1e9 + 7;

ll dp[SIZE][SIZE][SIZE2 * 2];

inline ll mod(const ll num) { return num >= MOD ? num - MOD : num; }
inline void add(ll &a, const ll b) { a = mod(a + b); return; }

int main(void) {
    int n, k;
    scanf("%d%d", &n, &k);

    dp[0][0][SIZE2] = 1;
    for (reint i = 0; i < n; ++i)
        for (reint j = 0; j <= i; ++j)
            for (reint l = 0; l < (SIZE2 << 1); ++l) {
                if (!dp[i][j][l]) continue;
                const ll tmp = dp[i][j][l];
                add(dp[i + 1][j][l], tmp);
                if (l >= (i << 1))
                    add(dp[i + 1][j + 1][l - (i << 1)], tmp);
                add(dp[i + 1][j][l], tmp * j % MOD);
                add(dp[i + 1][j][l], tmp * j % MOD);
                if (j && l + (i << 1) < (SIZE2 << 1))
                    add(dp[i + 1][j - 1][l + (i << 1)],
                        tmp * j % MOD * j % MOD);
            }
    //for (reint i = 0; i <= n; ++i)
        //for (reint j = 0; j <= i; ++j)
            //for (reint l = 0; l < (SIZE2 << 1); ++l) {
                //if (!dp[i][j][l]) continue;
                //printf("dp[%d][%d][%d] = %lld\n",
                       //i, j, l, dp[i][j][l]);
            //}

    printf("%lld\n", dp[n][0][k + SIZE2]);

    return 0;
}



Measured memory_bytes: 65792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {

  string s;
  cin >> s;
  


  cout << ( s=="ABC"      ?  "ARC " : "ABC" ) << endl ;     //小文字だったら直す


}



Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=2001;

int gcd(int a,int b){
  if(!b)  return a;
  else return gcd(b,a%b);
}

int main(){
  int a,b,c;
  cin >> a >> b >> c ;
  int g=gcd(a,b);
  if(g==1 || c%g ==0 ) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

using namespace std;


int main() {
	int n[2];
	cin >> n[0] >> n[1] >> n[2];
	sort(n, n + 3);
	cout << n[0] << " " << n[1] << " " << n[2] << endl;
	return 0;
}

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

typedef long long int ll;

int main()
{
    ll n, m, sum = 0;
    cin >> n >> m;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
        sum += a[i];
    }

    ll cnt = 0;
    for(ll i = 0;i < n;i++){
        if(4 * m * a[i] >= sum){
            cnt++;
        }
    }

    if(cnt < m){
        cout << "No";
    }
    else{
        cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var n = Integer.parseInt(br.readLine());

      System.out.println((1 + n) * n / 2);
    }
  }
}


Measured memory_bytes: 32324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, bossNumber;
  cin >> N;
  vector<int> bossList(N);
  for (int i = 0; i < (N - 1); i++){
    cin >> bossNumber;
    bossList.at(bossNumber - 1) = bossList.at(bossNumber - 1) + 1;
  }
  for (int i = 0; i < N; i++){
    cout << bossList.at(i) << endl;
  }
}

Measured memory_bytes: 4048
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>


#define CI cin >>
#define CO cout <<
#define E << endl;
#define F(i,max) (for(int i = 0;i < max;++i))

using namespace std;


int main(void) {
	int m[10000];
	int f[10000];
	int r[10000];

	char result[10000];

	for (int i = 0; i < 10000; i++) {
		CI m[i];
		CI f[i];
		CI r[i];
		if (m[i] == -1 && f[i] == -1 && r[i] == -1) {
			break;
		}

		if (m[i] == -1 || f[i] == -1) {
			result[i] = 'F';
		}
		else {
			if ((m[i] + f[i]) >= 80) {
				result[i] = 'A';
			}

			if (65 <= (m[i] + f[i]) && (m[i] + f[i]) < 80) {
				result[i] = 'B';
			}

			if (50 <= (m[i] + f[i]) && (m[i] + f[i]) < 65) {
				result[i] = 'C';
			}

			if ((30 <= (m[i] + f[i]) && (m[i] + f[i]) < 50) && r[i] < 50) {
				result[i] = 'D';
			}

			if ((30 <= (m[i] + f[i]) && (m[i] + f[i]) < 50) && r[i] >= 50) {
				result[i] = 'C';
			}

			if ((m[i] + f[i]) < 30) {
				result[i] = 'F';
			}
		}

		CO result[i] E
	}
}

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

int main()
{
    double head,legs;
    cin>>head>>legs;
    if((int)legs%2!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        if(legs/head<=4 && legs/head>=2)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3720
#include <cstdio>
#include <cmath>
#include <algorithm>

const int maxn=100000;

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

struct seg
{
  int l,r,flag;
};

seg s[maxn+10];

bool cmpl(int a,int b)
{
  return s[a].l>s[b].l;
}

bool cmpr(int a,int b)
{
  return s[a].r<s[b].r;
}

int n,a[maxn+10],b[maxn+10];
long long rans;

inline int dist(int now,int to)
{
  if(now<s[to].l)
    {
      return s[to].l-now;
    }
  else if(now>s[to].r)
    {
      return now-s[to].r;
    }
  else
    {
      return 0;
    }
}

inline int getnow(int now,int to)
{
  if(now<s[to].l)
    {
      return s[to].l;
    }
  else if(now>s[to].r)
    {
      return s[to].r;
    }
  else
    {
      return now;
    }
}

int main()
{
  n=read();
  for(int i=1; i<=n; ++i)
    {
      s[i].l=read();
      s[i].r=read();
      a[i]=b[i]=i;
    }
  std::sort(a+1,a+n+1,cmpl);
  std::sort(b+1,b+n+1,cmpr);
  int left=1,right=1,now=0;
  long long ans=0;
  s[a[1]].flag=1;
  ans+=dist(now,a[1]);
  now=getnow(now,a[1]);
  for(int i=1; i<n; ++i)
    {
      while(s[a[left]].flag)
        {
          ++left;
        }
      while(s[b[right]].flag)
        {
          ++right;
        }
      if(dist(now,a[left])>dist(now,b[right]))
        {
          s[a[left]].flag=1;
          ans+=dist(now,a[left]);
          now=getnow(now,a[left]);
        }
      else
        {
          s[b[right]].flag=1;
          ans+=dist(now,b[right]);
          now=getnow(now,b[right]);
        }
    }
  for(int i=1; i<=n; ++i)
    {
      s[i].flag=0;
    }
  rans=ans+abs(now);
  left=right=1;
  now=ans=0;
  s[b[1]].flag=1;
  ans+=dist(now,b[1]);
  now=getnow(now,b[1]);
  for(int i=1; i<n; ++i)
    {
      while(s[a[left]].flag)
        {
          ++left;
        }
      while(s[b[right]].flag)
        {
          ++right;
        }
      if(dist(now,a[left])>dist(now,b[right]))
        {
          s[a[left]].flag=1;
          ans+=dist(now,a[left]);
          now=getnow(now,a[left]);
        }
      else
        {
          s[b[right]].flag=1;
          ans+=dist(now,b[right]);
          now=getnow(now,b[right]);
        }
    }
  printf("%lld\n",std::max(ans+abs(now),rans));
  return 0;
}

Measured memory_bytes: 2176
N = int(input())

cand = [4*i for i in range(1, 100 // 4 + 1)]+[7*i for i in range(1, 100 // 7 + 1)]
cand = cand + [c + 7*i for c in cand for i in range(1,15)]

if N in set(cand):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int r,c,sum,i,j,add=0;
    cin>>r>>c;
    int a[r][c];
    for( i=0;i<r;i++){
        for( j=0;j<c;j++){
            cin>>a[i][j];
        }
    }
    for(i=0;i<r;){
sum=0;
        for( j=0;j<c;j++){
        cout<<a[i][j]<<" ";
        sum+=a[i][j];
        }
    add+=sum;
    cout<<sum<<endl;
    sum=0;
    i++;
    }
for(i=0;i<c;){
  sum=0;
        for( j=0;j<r;j++){
            sum+=a[j][i];
        }
        cout<<sum<<" ";
        sum=0;
        i++;
}
cout<<add<<endl;
return 0;
}


Measured memory_bytes: 3056