akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll k=in();string s;cin>>s;
    cout<<(s.length()<=k?s:s.substr(0,k)+"...")<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int R,G,B,N;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>R>>G>>B>>N;
    int ans=0;
    rep(i,0,3001){
        rep(j,0,3001){
            if(0<=N-R*i-G*j&&(N-R*i-G*j)%B==0) ans++;
        }
    }
    cout <<ans<<"\n";
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

void solve()
{
    int x;
    cin>>x;
    int p = 100;
    for(int i=1;i<=10000;i++){
        p = p*(1.01);
        if(p >= x - EPS){
            cout<<i<<"\n";
            break;
        }
    }
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3652
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    Map<Integer, List<PP>> map = new HashMap<>();
    public void solve() {
    	int N = Integer.parseInt(sc.next());
    	int a, x, y;
    	List<PP> list;
    	for (int i = 0; i < N; i++) {
        	a = Integer.parseInt(sc.next());
        	list = new ArrayList<>();
        	map.put(i, list);
        	for (int j = 0; j < a; j++) {
            	x = Integer.parseInt(sc.next()) - 1;
            	y = Integer.parseInt(sc.next());
				list.add(new PP(x, y));
			}
		}
    	int ans = 0, cnt;
    	for (int i = (1 << N) - 1; i >= 1; i--) {
//    		out.println("----- 状態　[" + Integer.toBinaryString(i) + "] ------");
    		cnt = 0;
    		LOOP:
			for (int j = 0; j < N; j++) {
				if((i & (1 << j)) == 0)		continue;	// 無視する
//				out.println(" 正直者　j = " + j);
				for(PP p : map.get(j)) {
//					out.println("  意見　[" + p.key + "] は　[" + p.val + "]");
					if((((i >> p.key)) & 1) != p.val) {
//						out.println(" ☆　矛盾が発生した　☆");
						cnt = -1;
						break LOOP;
					}
				}
				cnt++;
			}
    		if(cnt >= 0)
//    			out.println("矛盾はなかった　　[" + cnt + "]");
    		ans = Math.max(ans, cnt);
		}
    	out.println(ans);
    }    
    // Set に入れるなら　PPKEY　を使う！
    class PP{
    	public int key, val;
    	public PP(int key, int val) {
    		this.key = key;
    		this.val = val;
    	}
		public int getKey() {
			return key;
		}
		public void setKey(int key) {
			this.key = key;
		}
		public int getVal() {
			return val;
		}
		public void setVal(int val) {
			this.val = val;
		}
    }
    // ==================================================================
}



Measured memory_bytes: 27220
#include <iostream>
using namespace std;
int main(){
	int n,data[12],tmp[12];
	bool f[12];
	while(1){
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>data[i];
		}
		int ans=0;
		while(1){
			bool f=false;
			for(int i=0;i<n;i++){
				int cnt=0;
				for(int j=0;j<n;j++){
					if(data[i]==data[j])cnt++;
				}
				if(data[i]!=cnt)f=true;
				tmp[i]=cnt;
			}
			for(int i=0;i<n;i++){
				data[i]=tmp[i];
			}
			if(!f)break;
			ans++;
		}
		cout<<ans<<endl;
		for(int i=0;i<n-1;i++){
			cout<<data[i]<<" ";
		}
		cout<<data[n-1]<<endl;
	}
}

Measured memory_bytes: 1160
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> grad = new ArrayList<String>();
		for(;;){
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			if(m == -1 && f == -1 && r == -1){
				break;
			}
			if(m == -1 || f == -1){
				grad.add("F");
			} else if(m + f >= 80){
				grad.add("A");
			} else if(m + f >= 65){
				grad.add("B");
			} else if(m + f >= 50){
				grad.add("C");
			} else if((m + f >= 30) && r >= 50){
				grad.add("C");
			} else if(m + f >= 30){
				grad.add("D");
			} else if(m + f < 30){
				grad.add("F");
			}
		}

		for(String g : grad){
			System.out.println(g);
		}
	}
}

Measured memory_bytes: 26240
n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]
cnt = 0
for t in T:
    begin = 0
    end = n
    while begin < end:
        mid = (begin + end)//2
        if t == S[mid]:
            cnt += 1
            break
        elif t > S[mid]:
            begin = mid + 1
        else:
            end = mid
print(cnt)



Measured memory_bytes: 16900
import java.util.*;
public class Main {    
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int s=sc.nextInt();
        int[] nums=new int[1000000];
        nums[0]=s;
        
        flag:for(int i=0;i<999999;i++){
            nums[i+1]=nums[i]%2==0?nums[i]/2:nums[i]*3+1;
            for(int j=0;j<i;j++){
            if(nums[i+1]==nums[j]){
                System.out.println(i+1+1);
                break flag;
            
        }
        }
        
            
        }
            
            
        
        
        

    }
    
}

Measured memory_bytes: 25940
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
   ll a,b,i,j;
   cin>>a;
   for(i=1;i<=9;i++){
    if(a%i==0){
        if(a/i<=9){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
   }
   cout<<"No"<<endl;
return 0;
}


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

int n, q;
int a[30],m[3000];

bool f(int x,int i = 0,int sum = 0){
    if(sum == x) return true;
    else if(sum > x || i >= n) return false;
    return f(x,i + 1,sum) || f(x,i + 1,sum += a[i]);
}

int main(){
   cin >> n;
   for(int i = 0; i < n; i++) cin >> a[i];
   cin >> q;
   for(int i = 0; i < q; i++) cin >> m[i];

   for(int i = 0; i < q; i++) cout << (f(m[i]) ? "yes" : "no") << endl;

   return 0; 
}


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


int main(){
	int a,b,ans=0;
	bool flag;

	cin>>a>>b;

	for(int i=a;i<=b;i++){
		flag=false;
		if(i%10==i/10000)flag=true;
		if(!flag)continue;
		flag=false;
		if((i/1000)%10==(i%100)/10)flag=true;
		if(!flag)continue;
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
  
void color(int map[10][10], int x, int y)
{
  if (0 <= x && x <= 9 && 0 <= y && y <= 9){
    map[y][x]++;
  }
}
  
int main(void)
{
  int map[10][10] = {0};
  int x, y, size;
  int i, j;
  int white = 0, darkest = 0;
  
  while (scanf("%d,%d,%d", &x, &y, &size) != EOF){
    map[y][x]++;
    if (size == 3){
      color(map, x + 2, y);
      color(map, x - 2, y);
      color(map, x, y + 2);
      color(map, x, y - 2);
    }
    if (size >= 2){
      color(map, x + 1, y + 1);
      color(map, x - 1, y + 1);
      color(map, x + 1, y - 1);
      color(map, x - 1, y - 1);
    }
    if (size >= 1){
      color(map, x, y + 1);
      color(map, x, y - 1);
      color(map, x + 1, y);
      color(map, x - 1, y);
    }
  }
  
  for (i = 0; i < 10; i++){
    for (j = 0; j < 10; j++){
      if (map[i][j] == 0){
        white++;
      }
      if (darkest < map[i][j]){
        darkest = map[i][j];
      }
    }
  }
  
  printf("%d\n%d\n", white, darkest);
  
  return (0);
}

Measured memory_bytes: 600
//
//  code.cpp
//  Cpp
//
//  Created by Yash Jain on 25/02/20.
//  Copyright © 2020 Yash Jain. All rights reserved.
//

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int degree[200001];
long long fact[200001];

long long powermod(long long a,long long b){
    if(b == 0)
        return 1;
    if(b%2 == 1)
        return (a*(powermod((a*a)%mod,b/2)))%mod;
    return powermod((a*a)%mod, b/2);
}

long long ncr(long long a,long long b){
    long long temp = (fact[a]*powermod(fact[b],mod-2))%mod;
    temp = (temp*powermod(fact[a-b],mod-2))%mod;
    return temp;
}

int main(){
    
    int k,n;
    cin>>k>>n;
    
    long long a[n];
    
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    sort(a,a+n);
    
    long long ans = a[n-1]-a[0];
    for(int i=1;i<n-1;i++){
        long long dist1 = k - a[i] + (i-1>=0?a[i-1]:0);
        long long dist2 = (i+1<n?k-a[i+1]:0) + a[i];
        ans = min(ans,min(dist1,dist2));
    }
    
    cout<<ans;
    
}


Measured memory_bytes: 1792
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

struct s{
    int a,b,c,d;
};
vector
v;
int n,m,q,ans,curr[15];
void calc(){
    int tp=0;
    for(auto it:v) if(curr[it.b]-curr[it.a]==it.c) tp+=it.d;
    ans=max(ans,tp);
}
void rec(int i,int j){
    if(j>m) return;
    if(i>n){
        calc();
        return;
    }
    curr[i]=j;
    rec(i,j+1);
    curr[i]=j;
    rec(i+1,j);
}
signed main(){
    FastIO;
    cin>>n>>m>>q;
    rep(i,1,q){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        v.pb({a,b,c,d});
    }
    rec(1,1);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main() {

  int n,k,i,p;

  scanf("%d",&n);

  for(i=0;i<n;i++) {

    scanf("%d %d",&k,&p);

    if(k % p == 0) printf("%d\n",p);
    else  printf("%d\n",k % p);

  }

  return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}


//const ll mod = 998244353;
const ll mod = 1e9 + 7;
const ll MAX_SIZE = 1000005;
array<ll, MAX_SIZE> fac, inv, finv;
ll fac_init() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % mod;
    finv[0] = modpow(fac[MAX_SIZE - 1], mod - 2, mod);
    repe(i, 1, MAX_SIZE) finv[i] = finv[i - 1] * (MAX_SIZE - i) % mod;
    reverse(all(finv));

    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, mod - 2, mod);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % mod; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % mod * finv[a - b] % mod; }

int main() {
    init();
    ll N;
    cin >> N;
    vl C(N);
    rep(i, N) cin >> C[i];
    sort(all(C));
    reverse(all(C));

    ll S = modpow(4, N - 1, mod);

    ll ans = 0;
    rep(i,N){
        ans += C[i] * (i + 2) % mod;
        ans %= mod;
    }
    ans *= S;
    ans%=mod;

    cout << ans << endl;
}

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

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

LL getHoge(LL k) {
    LL hoge = 1;
    while (k != 0) {
        k = k >> 1;
        hoge = hoge << 1;
    }
    hoge = hoge >> 1;
    return hoge - 1;
}

int main() {
    int n;
    LL k;
    
    cin >> n >> k;
    
    LL ans1 = 0, ans2 = 0;
    vector<LL> as, bs;
    
    REP(i,n) {
        LL a, b;
        cin >> a >> b;
        as.push_back(a);
        bs.push_back(b);
    }
    
    if (k == 0) {
        LL ans4 = 0;
        REP(i,n) {
            if (as[i] == 0) {
                ans4 += bs[i];
            }
        }
        cout << ans4 << endl;
        return 0;
    }
    
    
    LL hoge = getHoge(k);
    REP(i,n) {
        if (as[i] <= hoge) {
            ans1 += bs[i];
        }
    }
    
    LL fuga = k - (hoge + 1);
    LL piyo = getHoge(fuga);
    
    
    REP(i,n) {
        if ((as[i] | k) <= k) {
            ans2 += bs[i];
        }
    }
    
    fuga = getHoge(k) + 1;
    piyo = k - fuga;
    while (piyo != 0) {
        LL ans2_tmp = 0;
        LL nyan = getHoge(piyo);
        nyan += fuga;
        
        REP(i,n) {
            if ((nyan | as[i]) <= nyan) {
                ans2_tmp += bs[i];
            }
        }
        ans2 = max(ans2, ans2_tmp);
        fuga += getHoge(piyo) + 1;
        piyo = k - fuga;
    }
    
    cout << max(ans1, ans2) << endl;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
int n,a[110],sum,ans;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	  cin>>a[i];
	sum=1;
	for (int i=1;i<=n+1;i++)
	{
	  if (a[i]==a[i-1]) sum++;
	  else {ans+=sum/2;sum=1;}
    }
    cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int k = sc.nextInt();

    if (n >= ((2 * (k - 1)) + 1)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }

  }
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(a - x) < abs(b - x))
        cout << "A" << endl;
    else
        cout << "B" << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
An = list(map(int,input().split()))
f_count = 0
r_count = 0

for i in range(N):
    for j in range(N):
        if i < j:
            if An[i] < An[j]:
                f_count += 1
            elif An[i] > An[j]:
                r_count += 1

Ans = (f_count * K*(K-1)//2 + r_count * (K*(K+1)//2)) % (10**9+7)

print(int(Ans))

Measured memory_bytes: 41708
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for (int i=0;i<=n;i++){
		for (int j=0;j<=m;j++){
			if (i*m+j*n-2*i*j==k){
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

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

void A()
{
    // 入力
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    
    // 起きている時間を求める（分）
    int M = (60 - M1) + M2 + (H2 - (H1 + 1)) * 60;
    
    // 出力
    cout << M - K << endl;
}

void B()
{
    // 入力
    string T;
    cin >> T;
    
    string S = T;
    int len = (int)S.length();
    
    // "???"の場合でも'?'='D'でよい
    for( int i = 0; i < len; ++i )
        if( S[i] == '?' ) S[i] = 'D';
        /*
        switch( T[i] ){
            case 'P': break;
            case 'D':
                ++ans;
                if( 0 < i && T[i-1] == 'P' ) ++ans;
                break;
            case '?':
                // P? = PD
                if( 0 < i && T[i-1] == 'P' ) S[i] = 'D';
                else if( i < len-1 && T[i+1] == '?' )
                break;
        }
        */
    
    // 出力
    cout << S << endl;
}

int main()
{
    // A();
    B();
    
    return 0;
}

Measured memory_bytes: 3924
N, x = gets.split.map(&:to_i)
ary = gets.split.map(&:to_i).sort
N.times do |n|
    x = x - ary[n]
    if x > 0
        next
    else
        if x == 0
            puts n + 1
        elsif x < 0
            puts n
        end
        exit 
    end
end
puts x == 0 ? N : N - 1

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

/*
最大のものとそれぞれの差が1, 1ならいけるone step, 0, 2ならone step, 1, 3ならtwo step
偶数と奇数で考える？
差が両方偶数なら単純に２を足していけばおｋ
両方偶数になるまでなんとかする？
両方奇数ならばそれらに１を足せば両方偶数になる。

差が大きい方に偶数足していって、
最大値の差が同じ奇数になったらそれぞれに１を足すみたいな感じかな。
*/

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

    // int maxv = 0;
    // int res = 0;
    // while (A == B && B == C)
    // {
    //     // get max
    //     maxv = max(A, B);
    //     maxv = max(maxv, C);

    //     int diff_A = maxv - A;
    //     int diff_B = maxv - B;
    //     int diff_C = maxv - C;
        
    // }
    vector<int> V(3);
    cin >> V[0] >> V[1] >> V[2];
    vector<int> D(3);
    int res = 0;
    while (!(V[0] == V[1] && V[1] == V[2]))
    {
        int maxv = -1, minv = 100000;
        int min_i, max_i;
        for (int i = 0; i < 3; i++)
        {
            if (minv > V[i]) {
                minv = V[i];
                min_i = i;
            }
            if (maxv < V[i]) {
                maxv = V[i];
                max_i = i;
            }
        }

        for (int i = 0; i < 3; i++)
        {
            D[i] = maxv - V[i];
        }

        if (max_i == 0) {
            if (D[1] == 1 && D[2] == 1) {
                res++;
                break;
            }
        }
        else if (max_i == 1)
        {
            if (D[0] == 1 && D[2] == 1) {
                res++;
                break;
            }
        }
        else
        {
            if (D[0] == 1 && D[1] == 1) {
                res++;
                break;
            }
        }

        V[min_i] += 2;
        res++;
    }

    cout << res << endl;
}

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

char c;
char c2;
int d[26];
char ccc[26];
int i;
int j;

main(){
		while ( scanf("%c", &c2) != EOF ){
				if(isupper(c2)){
					c =tolower(c2);
				}else{
					c = c2;
				}
				for(j=0; j<26;j++){
					if(j== c-'a'){
						d[j]++;

					}else{
						;
					}
				}
			
		}
		for(j=0; j<26; j++){
			ccc[j]= j+97;
			printf("%c : %d\n",ccc[j],d[j]);
		}
	
	return 0;
}

Measured memory_bytes: 548
#include<stdio.h>

int main(void)
{
  char s[1000];
  int a[1000];
  int i,j=0;

  for(i=0;i<100;i++) a[i]=0;

  scanf("%s",s);

  for(i=0;s[i]!=0;i++)
    a[s[i]]++;

  for(i='a';i<='z';i++)
    if(a[i]%2!=0) j++;

  if(j!=0)
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
N = int(input())
X = list(map(int, input().split()))

lhp = 100000000
for i in range(1, 100+1, 1):
    hp = 0
    for j in range(N):
        hp += (X[j] - i)**2
    if lhp >= hp:
        lhp = hp

print(lhp)

Measured memory_bytes: 3060
n=int(input())
A,B=[],[]
for _ in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
ans=0
for i in range(n-1,-1,-1):
    a,b=A[i],B[i]
    a+=ans
    ans+=b-a%b if a%b else 0
print(ans)

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

int main() {
  int N;
  cin >> N;
  string S;
  rep(i,N) cin >> S[i];

  bool test;
  rep(i,N){
    if(S[i]=='Y'){
      test=true;    
      break;
    }
    else test=false;
  }
  if(test) cout << "Four" << endl;
  if(!test) cout << "Three" << endl;
  /*if(S.find("Y") != std::string::npos) cout << "Four" << endl;
    else cout << "Three" << endl;*/
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int N, M, P;
    while (cin >> N >> M >> P, N) {
        vector<int> X(N);
        int gold = 0;
        for (int i=0; i<N; ++i) {
            cin >> X[i];
            gold += X[i] * 100;
        }
        if (X[M-1] == 0) {
            cout << 0 << endl;
        } else {
            cout << (gold - gold / 100 * P) / X[M-1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  int a[n];
  pair<int, int> p[n];
  rep(i,n){
    cin >> a[i];
    p[i]=mp(a[i],i+1);    
  }
  sort(p,p+n);
  rep(i,n){
    cout << p[i].second << " ";
  }
  cout << ""<<endl;
  return 0;
    

}


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

using ll = long long;
// #define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n;
  scanf("%d", &n);
  int weis[n];
  vector<int> left_v(n), right_v(n);
  REP(i,n) {
    scanf("%d", weis+i);
    left_v[i] = i - weis[i];
    right_v[i] = i + weis[i];
  }
  SORT(left_v); SORT(right_v);
  ll ans = 0;
  REP(i,n) {
    int right = right_v[i];
    auto itr = lower_bound(ALL(left_v), right);
    if(itr == left_v.end()) continue;
    auto itr2 = upper_bound(itr, left_v.end(), right);
    int counter = distance(itr, itr2);
    ans += counter;
  }
  cout << ans << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 5640
#include<stdio.h>
#include<stdlib.h>
int main(){
    int a ,b ,c ,d ,e , f;
    scanf("%d%d%d%d%d%d", &a,&b,&c,&d,&e,&f);
    int arr[] = {a,b,c,d,e} ;
    int i , j  , count = 0 ;
    for(i = 0 ; i < 4 ; i++){
        for(j=i+1 ; j<5 ; j++){
            if((arr[j]-arr[i]) > f){
                count++;
                //printf("%d - %d = %d \n" , arr[j], arr[i] ,arr[j] - arr[i]);

            }

        }
    }
    if(count >0){
        printf(":(");
    }else{
        printf("Yay!");
    }

}



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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll A, B;
    cin >> A >> B;
    vector<ll> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    ll ans = 0;
    for (int i = 0; i < N - 1; i++) {
        const ll d = x[i + 1] - x[i];
        ans += min(d * A, B);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
const long long INF = 1LL <<60;

int main(void){
  int N,M,rst;
  cin >>N>>M;
  long h[N],a[M],b[M];
  int i,j,tmp[N];
  rst=0;
  
  for(i=0;i<N;i++){
    cin>>h[i];
    tmp[i]=1;
  }
  
  for(i=0;i<M;i++){
    cin>>a[i]>>b[i];
    if(h[a[i]-1]==h[b[i]-1]){
      tmp[a[i]-1]=0;
      tmp[b[i]-1]=0;
    }
    else if(h[a[i]-1]>h[b[i]-1]){
      tmp[b[i]-1]=0;
    }
    else{
      tmp[a[i]-1]=0;
    }
  }

  for(i=0;i<N;i++){
    rst+=tmp[i];
  }

  
  cout<<rst<<endl;
  
  return 0;
}
      

Measured memory_bytes: 6344
while True:
    try:
        ok=0
        ng=0
        card_now=list(map(int,input().split()))
        total=sum(card_now[:2])
        for i in range (1,11):
            if i not in card_now:
                if total + i <= 20:
                    ok += 1
                else:
                    ng += 1
        print ("YES" if ok > ng else "NO")
                    
        
    except:
        break

Measured memory_bytes: 7528
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

void dfs(int n, vector<vector<bool> > &g, vector<bool> &visited){
  visited[n] = true;
  REP(i, g[n].size()){ // Nの値を渡していないのでg[n].size()を使う
    if(!g[n][i]) continue; // 辺がないところは見ない
    if(visited[i]) continue; // 訪問済みでも見ない
    dfs(i, g, visited);
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC075C - Bridge
  int N, M; cin >> N >> M;
  vector<vector<bool> > G(N, vector<bool>(N, false)); // 隣接行列形式
  vector<pair<int, int> > edge; // 辺の情報を別途残しておく（後で一つずつ消すので）
  REP(i, M){
    int a, b; cin >> a >> b; a--; b--; // 0-indexed
    G[a][b] = true; G[b][a] = true; // 隣接行列形式
    edge.emplace_back(a, b); // 辺の情報
  }
  vector<bool> visited(N, false); // DFSをやる前準備（訪問済みリスト）
  int ans = 0;
  REP(i, M){
    G[edge[i].first][edge[i].second] = false; // 一旦辺を消す
    G[edge[i].second][edge[i].first] = false;
    dfs(0, G, visited); // グラフと訪問済みリストは参照渡しをする
    REP(j, N){
      if(!visited[j]){
        ans++; break; // 1個でもfalseがあれば、それは橋だったということ
      }
    }
    G[edge[i].first][edge[i].second] = true; //辺の情報を元に戻す
    G[edge[i].second][edge[i].first] = true;
    REP(i, N) visited[i] = false; // 訪問済みリストも初期化しておく
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
struct Node {
	int ch[26];
	int spec;
	bool leaf;
};
Node nod[1000005];
int nid;
char str[1000005];
ll ans;
int cnt[1000005][26];
void go(int xi, int c = -1, int pi = -1) {
	Node* x = nod + xi;
	Node* p = nod + pi;
	for (int i = 0; i < 26; ++i) {
		if (!x->ch[i]) continue;
		go(x->ch[i], i, xi);
		cnt[xi][i] += nod[x->ch[i]].spec;
		for (int j = 0; j < 26; ++j) {
			cnt[xi][j] += cnt[x->ch[i]][j];
		}
	}
	for (int i = 0; i < 26; ++i) {
		if (!x->ch[i]) continue;
		if (nod[x->ch[i]].leaf) {
			assert(cnt[xi][i] >= 1);
			ans += cnt[xi][i] - 1;
		}
	}
}
int main() {
	int n;
	scanf("%d", &n);
	Node* root = &nod[nid++];
	for (int i = 0; i < n; ++i) {
		scanf("%s", str);
		int len = strlen(str);
		reverse(str, str + len);
		Node* p = root;
		vector<bool> isLas(len), has(26);
		for (int j = len - 1; j >= 0; --j) {
			if (!has[str[j] - 'a']) {
				isLas[j] = true;
				has[str[j] - 'a'] = true;
			}
		}
		for (int j = 0; j < len; ++j) {
			int x = str[j] - 'a';
			if (!p->ch[x]) {
				p->ch[x] = nid++;
			}
			p = &nod[p->ch[x]];
			if (isLas[j]) p->spec++;
		}
		p->leaf = true;
	}
	go(0);
	printf("%lld\n", ans);
}


Measured memory_bytes: 288924
#include <bits/stdc++.h>
#define int long long
#define R(i,a,n) for(int i=a;i<n;i++)
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int ddx[]={0,1,1,1,0,-1,-1,-1};
int ddy[]={-1,-1,0,1,1,1,0,-1};
int dp[111111];
#define pb push_back
vector<int>v;
signed main(){
  int a,b;
  cin>>a>>b;
  set<int>s;
  for(int i=1;i<=999;i++){
    s.insert((i+1)*(i)/2);
  }
  for(int j=1;;j++){
    int c=a+j;
    int d=b+j;
    for(int i=1;i<=999;i++){
      if((i+1)*(i)/2==c&&(i+2)*(i+1)/2==d){
        cout<<j<<endl;
        return 0;
      }
    }
  }
}

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

inline int getSum(int x) {
	int s = 0;
	while (x) {
		s += x % 10; x /= 10; }
	return s; }

int main(void) {
	int n, ans = 1000000000; cin >> n;
	for (int i = 1; i < n; ++i) {
		ans = min(ans, getSum(i) + getSum(n - i)); }
	cout << ans;
	return 0; }


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

using namespace std;

int main(){
	int score1[4],score2[4];
	int total1,total2;
	total1=total2=0;
	for(int i=0;i<4;i++){
		cin>>score1[i];
		total1 += score1[i];
 	}
	for(int i=0;i<4;i++){
		cin>>score2[i];
		total2 += score2[i];
	}
	if(total1>total2)cout<<total1<<endl;
	else cout<<total2<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for(int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int a, b; char c;
	cin >> a >> c >> b;
	if (c == '+') cout << a + b;
	else cout << a - b;
	cout << endl;

	return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

typedef pair<s,int> ss;

char S[5];
int N[5];
queue<ss> qu;//<<answer,index>, op>


int main(){
  scanf("%s",S);
  REP(i,4){
    N[i] = S[i]-'0';
  }
  N[4] = 0;
  qu.push(ss(s(N[0],0),0));
  while(!qu.empty()){
    int answer = qu.front().first.first;
    int index = qu.front().first.second;
    int op = qu.front().second;
    //printf("%d %d %d\n",answer,index, N[index]);
    qu.pop();
    if(index == 4){
      if(answer == 7){
        REP(i,4){
          printf("%d",N[i]);
          if(i==3){
            printf("=7\n");
            return 0;
          }
          if(((op >> i) & 1) == 1){
            printf("+");
          }else{
            printf("-");
          }
        }
      }
      continue;
    }
    qu.push(ss(s(answer+N[index+1],index+1),op | (1 << index)));
    qu.push(ss(s(answer-N[index+1],index+1),op));
  }
}


Measured memory_bytes: 256
#38
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
last = 9
time = 0
cou = 0
check = 0
#l = [[A,"A"],[B,"B"],[C,"C"],[D,"D"],[E,"E"]]
l = [A,B,C,D,E]
for i in l:
    if i%10 !=0 :
        if last%10 >= i%10:
            last = i
            check +=1
if check !=0:
    l.remove(last)
    l.append(last)
for i in range(5):
    time += l[i]
    if i == 4:
        break
    while time%10 != 0:
        time += 1
        
    
print(time)
        

Measured memory_bytes: 9200
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;

}
// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main() {
  string S;
  cin >> S;
  int n = 0;
  int s = 0;
  int e = 0;
  int w = 0;
  rep(i, S.size()) {
    if (S[i] == 'N') n++;
    if (S[i] == 'S') s++;
    if (S[i] == 'E') e++;
    if (S[i] == 'W') w++;
  }
  bool ok = true;
  if (n == 0 && s > 0 || n > 0 && s == 0) {
    ok = false;
  }
  if (w == 0 && e > 0 || w > 0 && e == 0) {
    ok = false;
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

int selectionSort(int A[],int N){
    int aw = 0,kl;
    for(int i = 0;i < N-1;i++){
        kl = i;
        for(int j = i;j < N;j++){
            if(A[j] < A[kl])kl = j;
        }
        swap(A[i],A[kl]);
        if(i != kl)aw++;
    }
    return aw;
}

int main(){
    int A[100],N,aw;
    cin >> N;
    for(int i = 0;i < N;i++)cin >> A[i];
    aw = selectionSort(A,N);
    for(int i = 0;i < N;i++){
        if(i > 0)cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << aw << endl;
}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(){

	int a;
	int b;
	int c;
	int d;

		cin >> d;

		for(int i=1; i<=d; i++){

	cin >> a >> b >> c;

	if(a*a+b*b==c*c || b*b+c*c==a*a || a*a+c*c==b*b){

	cout << "YES" << endl;

		}	

	else	{

		cout << "NO" << endl;

		}
	}

	return 0;
}

Measured memory_bytes: 1152
using System;

namespace CA {
	class Prg {
		static void Main() {
			int i = int.Parse(Console.ReadLine());
			string[] s = Console.ReadLine().Split(' ');
			while (i-- != 0) {
				Console.Write(s[i]);
				if (i > 0) Console.Write(" ");
			}
			Console.WriteLine();
        }
	}
}

Measured memory_bytes: 8852
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main() {
	int N,ans = 0;
	cin >> N;
	vector<int> P(N);
	for(int i = 0; i < N; i++){
		cin >> P.at(i);
	}
	sort(P.begin(),P.end());
	for(int i = 0; i < N; i++){
		int now = P.at(i);
		if(i == N - 1){
			now = P.at(i) / 2;
		}
		ans += now;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
# https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
pairs = []
for i in range(n):
    for j in range(i + 1, n):
        pairs.append((i, j))

ans = 0
for i, j in pairs:
    a, b = L[i], L[j]
    ans += bisect_left(L, a + b) - 1 - j
print(ans)

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

int main() {
  
  int N, l, r, s = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    s += r - l + 1;
   }
  
   cout << s << endl;
}

Measured memory_bytes: 3624
use std::io;
use std::collections::HashMap;

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let w  = read_one::<String>();

    let mut hm = HashMap::new();

    for c in w.chars() {
        let i = hm.entry(c).or_insert(0);
        *i += 1;
    }

    match hm.values().find(|&c| c % 2 != 0) {
        Some(_) => println!("No"),
        None => println!("Yes"),
    }
}

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

using namespace std;

#define int long long

const int MOD = 1000 * 1000 * 1000 + 7;

int mod(int n) {
    return (n % MOD + MOD) % MOD;
}

int fp(int a, int b) {
    if (b == 0) return 1;
    int t = fp(a, b >> 1);
    if (b & 1) return mod(mod(t * t) * a);
    else return mod(t * t);
}

int mdiv(int a, int b) {
    return mod(a * fp(b, MOD - 2));
}

int n;
const int MAXN = 1e5 + 7;

int a[MAXN];
int pref[MAXN];

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

    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    
    int f = 1;
    for (int i = 0; i < n; ++i) {
        f = mod(f * (i + 1));
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = mod(ans + mod(f * a[i]));
    }

    for (int i = 2; i < MAXN; ++i) {
        pref[i] = mod(pref[i - 1] + mdiv(f, i));
    }
    
    for (int i = 0; i < n; ++i) {
        ans = mod(ans + pref[i + 1] * a[i]);
        ans = mod(ans + pref[n - i] * a[i]);
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n,cnt,to,tot,maxx,last,res;
int head[1000005],book[1002][1002],in[1000002],ans[1000005];
struct node{
	int to,net;
}e[1000005];
void add(int x,int y){
	e[++tot].to =y;
	e[tot].net =head[x];
	head[x]=tot;
} 
void topp(){
	queue<int> q;
	for(int i=1;i<=cnt;i++)
	  if(in[i]==0) {
	  	q.push(i); 
	  	res++;
	  	ans[i]=1;
	  }
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int i=head[x];i;i=e[i].net ){
			int to=e[i].to ;
			in[to]--;
			ans[to]=ans[x]+1;
			if(in[to]==0) {
				q.push(to);res++;
			}
		}
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++) {
			scanf("%d",&to);
			if(!book[i][to]) {
				cnt++;
				book[i][to]=cnt;
				book[to][i]=cnt;
				if(j!=1) {
					add(last,cnt);in[cnt]++;
				} 
				last=cnt;
			}
			else {
				if(j!=1){
					add(last,book[i][to]);
				    in[book[i][to]]++;
				} 
				last=book[i][to];
			}
		}
	}
	/*for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++) printf("%d ",book[i][j]);
		cout<<endl;
	}
	for(int i=1;i<=cnt;i++) printf("%d ",in[i]);
	cout<<endl;
	for(int i=1;i<=cnt;i++)
	  for(int j=head[i];j;j=e[j].net ){
	  	printf("%d %d \n",i,e[j].to );
	  	
	  }*/
	topp();  
	for(int i=1;i<=cnt;i++) maxx=max(ans[i],maxx);
	if(res<cnt) printf("-1");
	else printf("%d",maxx);
	return 0;
}

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

int main() {
  int s, up, lw, f = 0;
  cin >> s;
  up = s / 100;
  lw = s % 100;
  if(0 < up && up < 13)
    f = 1;
  if(0 < lw && lw < 13)
    f |= 2;
  switch(f) {
  case 0:
    cout << "NA" << endl;
    break;
  case 1:
    cout << "MMYY" << endl;
    break;
  case 2:
    cout << "YYMM" << endl;
    break;
  case 3:
    cout << "AMBIGUOUS" << endl;
  }
}

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    S=input()
    Q=I()
    K=LI()
    ans=0
    
    
    
    for k in K:
        d=0
        m=0
        temp=0
        ans=0
        for i in range(k):
            if S[i]=="D":
                d+=1
            elif S[i]=="M":
                m+=1
                temp+=d
            elif S[i]=="C":
                ans+=temp
                #print(0,i,d,m)
        
        for i in range(k,N):
            if S[i-k]=="D":
                d-=1
                temp-=m
            elif S[i-k]=="M":
                m-=1
            
            if S[i]=="D":
                d+=1
            elif S[i]=="M":
                m+=1
                temp+=d
            elif S[i]=="C":
                ans+=temp
                #print(1,i,d,m)
                
        print(ans)
            
                
                
            
            
            

main()


Measured memory_bytes: 58220
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 2005;
const int mod = 1e9 + 7;

int n, siz[MAXN], g[MAXN][3], f[MAXN][MAXN][3];
vector <int> adj[MAXN];

inline void DFS(int x)
{
	siz[x] = 1, f[x][1][0] = 1;
	for (auto y : adj[x])
	{
		DFS(y), mcpy(g, f[x]), mset(f[x], 0);
		for (int dx = 0; dx <= 2; dx ++)
			for (int dy = 0; dy <= 2; dy ++)
				for (int dz = 0; dz <= 1; dz ++)
					if (!dz || (dx < 2 && dy < 2))
						for (int i = 1; i <= siz[x]; i ++)
							for (int j = 1; j <= siz[y]; j ++)
							{
								int cur = 1;
								if (dz)
								{
									cur = mod - 1;
									if (!dx && !dy)
										cur = (cur << 1) % mod;
									if (dx && dy)
										cur = cur >> 1;
								}
								f[x][i + j - dz][dx + dz] = (1LL * g[i][dx] * f[y][j][dy] % mod * cur + f[x][i + j - dz][dx + dz]) % mod;
							}
		siz[x] += siz[y];
	}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 2; i <= n; i ++)
		adj[Read()].pb(i);
	DFS(1);
	int ret = 0;
	for (int i = 0, cur = 1; i <= n; i ++, cur = 1LL * cur * i % mod)
		for (int j = 0; j <= 2; j ++)
			ret = (1LL * f[1][i][j] * cur + ret) % mod;
	return printf("%d\n", ret), 0;
}


Measured memory_bytes: 47488
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
abc = [iln() for _ in range(N)]
dp = [[0 for _ in range(3)] for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k: continue
            dp[i+1][j] = max(dp[i+1][j], dp[i][k]+abc[i][j])

print(max(dp[N]))

Measured memory_bytes: 95960