akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int a[100009],b[100009],n;
int main() {
    string s;
    cin>>s;
    n = s.size();
    for(int i=1;i<=n;i++){
        // cout<<s[i];
        if(s[i-1]=='0'){
            a[i] = b[i-1];
            b[i] = a[i-1]+1;
        }
        else{
            b[i] = a[i-1];
            a[i] = b[i-1]+1;
        }
    }
    cout<<min(a[n],b[n])<<endl;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> P(N+M);
  int A,B,C;
  for(int i=0;i<N;i++){
    cin >> A;
    P.at(i) = make_pair(A,1);
  }
  for(int i=N;i<N+M;i++){
    cin >> B >> C;
    P.at(i) = make_pair(C,B);
  }
  sort(P.begin(),P.end());
  reverse(P.begin(),P.end());
  //for(int i=0;i<N+M;i++){
  //  cout << P.at(i).first << " " << P.at(i).second << endl;
  //}
  long long sum=0;
  int cards = 0;
  for(int i=0;i<N;i++){
    if(cards + P.at(i).second <= N){
      for(int j=0;j<P.at(i).second;j++){
        sum += P.at(i).first;
      }
      cards += P.at(i).second;
    }else{
      for(int j=0;j<N-cards;j++){
        sum += P.at(i).first;
      }
      break;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
  int X, Y;
  bool can = false;
  cin >> X >> Y;
  for (int i=0; i<=X; i++){
    if (2*i + 4*(X - i) == Y){
      can = true;
      break;
    }
  }
  cout << (can ? "Yes" : "No") << "\n";
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
#include<string>
#include<strstream>
#include<sstream>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<set>
int main()
{
	set<int>s;
	int n,x; cin >> n;
	while (n--)
	{
		cin >> x;
		s.insert(x);
	}
	cout << s.size();
	
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, char const *argv[])
{
    int h, w;

    while(true)
    {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                if(((i+j)%2) == 0)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 3096
#include <cstdio>
#include <cmath>

using namespace std;

void conv(int n)
{
	if (!n) return;
	int m = n * (n < 0 ? -1 : 1) % 10;
	if (n < 0) m = (10 - m) % 10;
	
	conv((n - m) / -10);
	
	printf("%d", m);
}

int main()
{
	int n;
	while (scanf("%d", &n) && n){
		conv(n); printf("\n");
	}
	return (0);
}

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

int main() {
    int N, M;
    cin >> N >> M;
    
    int left = 1;
    int right = N;
    for (int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        left = max(left, l);
        right = min(right, r);
    }

    int ans;
    if (right - left < 0) {
        ans = 0;
    } else {
        ans = right - left + 1;
    }

    cout << ans << endl;

    return 0;
}

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

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b;
    cin>>a>>b;
    if(a>0)puts("Positive");
    else if(a==0||a<0&&b>0)puts("Zero");
    else if((abs(b)-abs(a))%2!=0)puts("Positive");
    else puts("Negative");
}

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	q := getNextInt(scanner)
	d := NewDsu(n)
	for q > 0 {
		q--
		t := getNextInt(scanner)
		u := getNextInt(scanner)
		v := getNextInt(scanner)
		if t == 0 {
			d.Merge(u, v)
			continue
		}
		if d.Same(u, v) {
			fmt.Fprintln(writer, 1)
			continue
		}
		fmt.Fprintln(writer, 0)
	}
}

// Dsu Data structures and algorithms for disjoint set union problems
type Dsu struct {
	n            int
	parentOrSize []int
}

// NewDsu Constructor
func NewDsu(n int) *Dsu {
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = -1
	}
	return &Dsu{parentOrSize: p, n: n}
}

// Merge adds an edge (a, b).
func (d *Dsu) Merge(a, b int) int {
	x := d.Leader(a)
	y := d.Leader(b)
	if x == y {
		return x
	}
	if d.parentOrSize[x] > d.parentOrSize[y] {
		x, y = y, x
	}
	d.parentOrSize[x] += d.parentOrSize[y]
	d.parentOrSize[y] = x
	return x
}

// Same returns whether the vertices a and b are in the same connected component.
func (d *Dsu) Same(a, b int) bool {
	return d.Leader(a) == d.Leader(b)
}

// Leader returns the representative of the connected component that contains the vertex a.
func (d *Dsu) Leader(a int) int {
	if d.parentOrSize[a] < 0 {
		return a
	}
	d.parentOrSize[a] = d.Leader(d.parentOrSize[a])
	return d.parentOrSize[a]
}

// Size returns the size of the connected component that contains the vertex a.
func (d *Dsu) Size(a int) int {
	return -d.parentOrSize[d.Leader(a)]
}

// Groups divides the graph into connected components and returns the list of them.
func (d *Dsu) Groups() [][]int {
	result := make([][]int, d.n)
	for i := 0; i < d.n; i++ {
		l := d.Leader(i)
		result[l] = append(result[l], i)
	}
	return result
}


Measured memory_bytes: 5852
inputs = list(map(int, input().split()))
n5, n7 = 0, 0
flag = True

for e in inputs:
  if e == 5:
    n5 += 1
  elif e == 7:
    n7 += 1
  else:
    break
 
if flag and n5 == 2 and n7 == 1:
  print('YES')
else:
  print('NO')
  

Measured memory_bytes: 2940
/*バブルソート*/
#include <stdio.h>
#define N 100
int main(){
  int a[N], n, i, j, count=0, flag=1, tmp;

  scanf("%d", &n);

  for (i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  i=0;
  while(flag){
    flag=0;
    for (j=n-1; j>i; j--){
      if (a[j] < a[j-1]){
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	count++;
	flag = 1;
      }
    }
    i++;
  }

  for (i=0; i<n; i++){
    if (i==n-1){
      printf("%d\n", a[i]);
      break;
    }
    printf("%d ", a[i]);
  }

  printf("%d\n", count);

  return 0;
}
  



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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  arr(x,5);
  rep(i,5){
    if(x[i]==0){
      prt(i+1);
    }
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;
int n;
int a[200005];
int b[200005];

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		b[i]=a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	int t=n/2-1;
	int tt=a[t];
	int a1=a[t];
	int a2=a[t+1];
	for(int i=0;i<n;i++)
	{
		if(b[i]<tt) cout<<a1<<endl;else cout<<a2<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 3;
const int N = 1e3 + 10, M = 1e6 + 10;
const ll INF = 1e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi acos(-1)

int main()
{
    int ans = 0;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R')
        {
            int j;
            for(j = i; j < s.size(); j++)
            {
                if(s[j] != 'R')
                    break;
            }
            ans = max(ans, j - i);
            i = j;
        }
    }
    cout << ans << endl;
    return 0;
}
/*

*/

Measured memory_bytes: 3580
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
#ifdef XS
	#include<De>
#endif
using namespace std;
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	try{
		//while(1)
		//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
		inp();
	}
	catch(... ){
#ifdef XS
		printf("%s","exception");
#endif
	}//for compatibility with cygwin c++ runtime
	return 0;
}
const ll mod = 1e9 + 7;
#define mo(x) (x%=mod)
ll A(ll a){
	ll ans = 1 ;
	for(ll i = 1 ;i<= a;i++){
		ans*= i;
		mo(ans);
	}
	return ans;
}
ll pq(ll a,ll n){ll b = 1;while(n){if(n&1)b*=a;a*=a;mo(a);mo(b);n>>=1;}return b;}
ll C(ll r, ll n){
	ll ans = 1;
	for(;r>0&&n>0;){
		ans*= n;n--;
		mo(ans);
		ans*= pq(r,mod-2);r--;
		mo(ans);
	}
	return ans;
}
void inp(){
	ll a,b;
	scanf("%lld%lld", &a,&b);
	if(a>b)swap(a,b);
	ll ans = 0;
	if(a-1<=b&&b<=a+1){
		ans = 1;
		ans *= A(a);
		mo(ans);
		ans *= A(b);
		mo(ans);
		ans *= C(b-(a-1), 2);
		mo(ans);
	}
	printf("%lld\n", ans);
}
//C.cc by xsthunder at Wed Jul 19 08:45:55 2017


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
#include<ctime>
#include <algorithm>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-8;
int n;
/*
机选取一个点作为初始解，然后不断向当前距离最远点靠近，这是一个不断调整的过程，
将对应模拟淬火算法中不断向内能最低（半径最小）这一目标函数逼近，温度对应控制变量。
*/
struct Point
{
	double x,y,z;
	Point(double x = 0, double y = 0, double z = 0)
	{
		x = x;
		y = y;
		z = z;	
	}
}p[1010];
double dis(Point a, Point b)
{
	return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y)+(a.z-b.z)*(a.z - b.z) );
}

void solve()
{
	/*
	不要用随机取点，取不到结果
	*/
	Point temp = p[1];
	double ans = 9999999;
	double T = 100.0;
	while( T > eps)//如果温度小于eps，则达到最优解
	{
		int k = 1;
		for (int i = 1; i <= n; i++)
		{
			if (dis(temp, p[i]) > dis(temp, p[k]))
				k = i;//寻找距离temp最远的点
		}
		double dista = dis(temp, p[k]);
		ans = min(ans, dista);//找出该点的最小距离

			temp.x += (p[k].x - temp.x) / dista * T;
			//离temp最远的点与temp的x坐标差/两点最小距离*温度
			temp.y += (p[k].y - temp.y) / dista * T;
			temp.z += (p[k].z - temp.z) / dista * T;
		T *= 0.988;//降火的幅度
	}
	printf("%.5f\n", ans);
}

int main()
{
	std::ios::sync_with_stdio(false);
	while (cin>> n)
	{
		
		if (n == 0)break;
		memset(p, 0, sizeof(p));
		for (int i = 1; i <= n; i++)
		{
			cin >> p[i].x >> p[i].y>>p[i].z;
		}
		solve();
	}
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const ll MOD=1000000007;
ll n;
ll a[25];

ll dp[23][(1<<21)+20];

ll f(ll x, ll y){
	ll &r=dp[x][y];
	if(r>=0)return r;
	if(x==n){
		r=1; return r;
	}
	ll m=y&a[x];
	r=0;
	fore(i,0,n){
		if((1<<i)&m){
			r+=f(x+1,y^(1<<i));
			if(r>MOD)r-=MOD;
		}
	}
	return r;
}

int main(){FIN;
	cin>>n;
	fore(i,0,n){
		ll p=0;
		fore(j,0,n){
			ll lle; cin>>lle;
			p*=2;
			p+=lle;
		}
		a[i]=p;
	}
	//fore(i,0,n)cout<<a[i]<<"\n";
	mset(dp,-1);
	cout<<f(0,(1<<n)-1);
	
	return 0;
}

Measured memory_bytes: 377088
import sys
N = int(input())
S = input()

if not ( 1 <= N <= 100 ): sys.exit()
if not S.islower(): sys.exit()
if not ( len(S) == N ): sys.exit()
if N % 2 == 1: print('No'); sys.exit()
print('Yes') if ( S[:N//2] + S[:N//2] == S ) else print('No')

Measured memory_bytes: 9048
#include <iostream>
#include <vector>

int main(){
    // 入力 
    int N, M;
    std::cin >> N >> M;
    std::vector<long long> H(N);
    for(int i = 0; i < N; i++){
        std::cin >> H[i];
    }    

    // 比較　
    // ここに出てこない(道がない)展望台はいい展望台 
    std::vector<bool> goodH(N, true);     
    for(int i = 0; i < M; i++){
//        std::cout << "comperer" << i << std::endl;
        int A, B;
        std::cin >> A >> B;
        A--;    // インデックス 
        B--;    // インデックス 

        if(H[A] < H[B]){
            // Aの方が低い
            goodH[A] = false; 
//            std::cout << A << "is not Good\n";
        }else if(H[A] > H[B]){
            // Bの方が低い 
            goodH[B] = false;
//            std::cout << A << "is not Good\n";
        }else if(H[A] == H[B]){
            // 同率 
            goodH[A] = false;
            goodH[B] = false;
//            std::cout << A << " and " << B << "are not Good\n";
        }
    }

    // かぞえあげ
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(goodH[i] == true){
            ans++;
        }
    } 

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 4052
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String st = br.readLine();
            int n = Integer.parseInt(st);
            BigInteger answer = BigInteger.ZERO;
            BigInteger x = BigInteger.ZERO;
            String[] ss = new String[n];
            for (int i = 0; i < n; i++) {
                ss[i] = br.readLine();
            }
            for(int i=n-1;i>=0;i--){
                String[] s = ss[i].split(" ", 0);
                BigInteger a = x.add(new BigInteger(String.valueOf(s[0])));
                BigInteger b = new BigInteger(String.valueOf(s[1]));
                BigInteger c = a.remainder(b);
                BigInteger ci = BigInteger.ZERO;
                if (b!=BigInteger.ONE&&c!=BigInteger.ZERO) {
                    ci = b.subtract(c);
                    x = x.add(ci);
                }
                answer = answer.add(ci);
            }
            System.out.println(answer);
        } catch (Exception ex) {
            System.exit(0);
        }
    }
}

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

int main()
{
    int N;
    int64_t sum = 0;
    cin >> N;
    for(int i = 1; i <= N; ++i)
        if (i % 3 != 0 && i % 5 != 0)
        sum += i;
    
    cout << sum << endl;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main(){
    string S,T;
    cin >> S >> T;
    int s = S.length(),t = T.length();
    bool checker = false;
    int tmp = 0;
    for(int i=s-1;i>=0;i--){
            checker = true;
            int k = i;
            for(int j=t-1;j>=0;j--){
                if(T[j]!=S[k]&&S[k]!='?'){
                    checker = false;
                }
                k--;
                if(j==0&&checker==true){
                    tmp = i;
                    goto tag;
                }
        }
    }tag:
    string ans;
    if(checker){
        int z = 0;
        for(int i=0;i<s;i++){
            if(i>tmp-t&&i<=tmp){
                ans.push_back(T[z]);
                z++;
            }else{
                if(S[i]=='?')ans.push_back('a');
                else   ans.push_back(S[i]);
            }
        }
        cout << ans << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
    char ch;
    int i,count[26];
    
    for(i=0;i<26;i++){
		count[i]=0;
	}
    
    while(cin >> ch){
        if(islower(ch)){
            count[ch -'a']++;
        } else if(isupper(ch)){
            count[ch -'A']++;
        }
    }
    for(int i = 0;i < 26;i++){
        cout << char(i +'a') << " : " << count[i] << endl;
    }
    return 0;
}

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

void solve(vector<int> x)
{
    for (int i = 0; i < 5; i++)
    {
        if (x.at(i) == 0)
        {
            cout << i + 1 << endl;
            return;
        }
    }
}

int main()
{
    vector<int> x(5);
    for(int i = 0 ; i < 5 ; i++){
        cin >> x.at(i);
    }
    solve(move(x));
    return 0;
}


Measured memory_bytes: 3596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        int ans = 999;
        for (int i = 0; i < S.Length - 2; i++)
        {
            int A = int.Parse(S.Substring(i, 3));
            ans = Math.Min(ans, Math.Abs(A - 753));
        }
        Console.WriteLine(ans);
    }
    
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 11092
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */

public class Main {

    public static int solve(int N, String S, String T){
        for(int single=0; single<=N; single++){
            boolean flag = true;
            for(int i=0; i<N-single; i++){
                if(S.charAt(i+single)!=T.charAt(i)) flag=false;
            }
            if(flag) return N+single;
        }
        return 2*N;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        System.out.println(solve(N,S,T));


    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d; cin>>a>>b>>c>>d;
    if ((abs(b-a)<=d&&abs(c-b)<=d)||abs(c-a)<=d){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
    s=s+"es";
    else
    s=s+'s';
    cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3660
n = gets.to_i
h = {}
gets.split.each do |a|
    a = a.to_i
    if h.has_key?(a) then
        h[a] += 1
    else
        h[a] = 1
    end
end
num = 0
h.each do |k,v|
    if k < v then
        num += v-k
    elsif k > v then
        num += v
    end
end
puts num

Measured memory_bytes: 13700
N = int(input())
A = [0] * N
B = [0] * N
ab_sum = [[0] * 2 for _ in range(N)]

for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b
    ab_sum[i] = [a + b, i]

ab_sum.sort(reverse = True)

a = 0

ans = 0

for i in range(N):
    temp = ab_sum[i][1]
    if i % 2 == 0:
        ans += A[temp]
    else:
        ans -= B[temp]

print(ans)

Measured memory_bytes: 27952
def dfs(x):
    d = [-1] * (N + 1)
    stack = [x]
    while stack:
        x = stack.pop()
        for i in G[x]:
            if d[i] == -1:
                d[i] = d[x] + 1
                stack.append(i)
    return d

N = int(input())
G = [set() for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a].add(b)
    G[b].add(a)

d1, dn = dfs(1), dfs(N)
num = 0
for i in range(1, N + 1):
    if d1[i] <= dn[i]:
        num += 1
if num > N // 2:
    print('Fennec')
else:
    print('Snuke')

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

using namespace std;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;//AmShZ
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b, ll md = mod) {
    ll res = 1;while(b){if(b&1){res=(a*res)%mod;}a=(a*a)%mod;b>>=1;}return(res);
}

int n  , m;

int main(){
    migmig
    cin >> n >> m;
    cout << n*(n - 1)/2 + m*(m - 1)/2;
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
int INF = 1<<29;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

long long int i,j;

int main(){
	int h,w,n;
	cin>>h>>w>>n;
	int a[10005];
	int dp[101][101];
	int x,sum=0;
	for(i=0;i<n;i++){
		cin>>x;
		for(j=0;j<x;j++){
			a[sum+j]=i+1;
		}
		sum += j;
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(i%2==0)
			dp[i][j]=a[i*w+j];
			if(i%2!=0)
			dp[i][w-j-1]=a[i*w+j];
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
						cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}


	return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let height: usize = read();
    let width: usize = read();
    let mut vec: Vec<Vec<char>> = Vec::new();

    for h in 0..height {
        let line: String = read();
        let c_line: Vec<char> = line.chars().collect();
        vec.push(c_line);
    }

    let mut ans = "Yes";

    'outer: for h in 0..height{
        for w in 0..width {
            if vec[h][w] == '#' {
                if !isOk(
                    vec.clone(),
                    h.clone(),
                    w.clone(),
                    height-1,
                    width-1
                ) {
                    ans = "No";
                    break 'outer;
                }
            }
        }
    }

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

fn isOk(vec: Vec<Vec<char>>, h: usize, w: usize, max_h: usize, max_w: usize) -> bool {
    if (h > 0 && vec[h-1][w] == '#') ||
        (w < max_w && vec[h][w+1] == '#') ||
        (h < max_h && vec[h+1][w] == '#') ||
        (w > 0 && vec[h][w-1] == '#') {
        return true;
    }
    return false;
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

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

int main() {
    string s;
    cin >> s;
    int cnt[4];
    for(int i=0;i<4;i++){
      cnt[i]=0;
      if(s[i]==s[0]){
        cnt[i]=cnt[i]+1;
      }
      if(s[i]==s[1]){
        cnt[i]=cnt[i]+1;
      }
      if(s[i]==s[2]){
        cnt[i]=cnt[i]+1;
      }
      if(s[i]==s[3]){
        cnt[i]=cnt[i]+1;
      }
    }
    bool b=true;
    for(int i=0;i<4;i++){
      if(cnt[i]!=2){
        b=false;
      }
    }

    if(b==true) cout << "Yes" << endl;
    else  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 1234567
int n; ll f[SZ],qzh[SZ],MOD=1e9+7;
int main()
{
	scanf("%d",&n);
	f[1]=qzh[1]=n;
	for(int i=2;i<=n;i++)
	{
		f[i]=f[i-1]+(ll)(n-1)*(n-1);
		f[i]+=(i>=3?qzh[i-3]:0);
		f[i]+=n-max(i-1,2)+1;
		f[i]%=MOD; qzh[i]=(qzh[i-1]+f[i])%MOD;
	}
	ll ans=f[n];
	ans=(ans%MOD+MOD)%MOD;
	printf("%d\n",int(ans));
}


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

using namespace std;

int main(){
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  string ret = "";
  for (int i=0; i<S.size(); i++){
    if (i == K - 1){
      ret += (S[i] == 'A' ? 'a' : (S[i] == 'B' ? 'b' : 'c'));
    }
    else ret += S[i];
  }
  cout << ret <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int n, k ;
    cin >> n >> k ;
    int v[n], w[n], dp[k+1]= {0};
    rep(i, 0, n) cin >> w[i] >> v[i] ;
    for(int i=0; i<n; i++) {
        for(int j=k; j-w[i]>=0; j--) {
            dp[j] = max(v[i]+dp[j-w[i]], dp[j]) ;
        }
    }
    cout << *max_element(dp, dp+k+1) << endl ;
}
 
int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

Measured memory_bytes: 1024
[N, A, B] = map(int, raw_input().split())

i=1
g_sum = 0
while i<=N:
    sum = 0
    array = list(str(i))
#    print array
    while len(array) > 0:
        tmp = array.pop(0)
#        print tmp
        sum = sum + int(tmp)

    if (A <= sum) and (sum <= B):
        g_sum = g_sum + i
    i=i+1

print g_sum


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

int main() {
	string s, t; cin >> s;
	int a, b, c, abc, n;
	vector<int> pos;
	while (1) {
		if (s == "ABC") {
			cout << "Yes" << endl;
			return 0;
		}
		a = 0; b = 0; c = 0; abc = 0;
		n = s.size();
		pos.clear(); pos.resize(n, false);
		for (int i = 0; i < n; ++i) {
			if (i < n-2 && s.substr(i, 3) == "ABC") {
				abc++;
				pos[i] = true;
			}
			if (s[i] == 'A') a++;
			else if (s[i] == 'B') b++;
			else c++;
		}
		if (abc == 0 || (a != abc && b != abc && c != abc)) {
			cout << "No" << endl;
			return 0;
		}
		else if (a == abc) {
			if (a >= b || a >= c) {
				cout << "No" << endl;
				return 0;
			}
			t = "";
			for (int i = 0; i < n; ++i) {
				if (pos[i]) {
					t += "A";
					i += 2;
				} else t += s[i];
			}
			swap(s, t);
			t = "";
		} else if (b == abc) {
			if (b >= a || b >= c) {
				cout << "No" << endl;
				return 0;
			}
			t = "";
			for (int i = 0; i < n; ++i) {
				if (pos[i]) {
					t += "B";
					i += 2;
				} else t += s[i];
			}
			swap(s, t);
			t = "";
		} else if (c == abc) {
			if (c >= a || c >= b) {
				cout << "No" << endl;
				return 0;
			}
			t = "";
			for (int i = 0; i < n; ++i) {
				if (pos[i]) {
					t += "C";
					i += 2;
				} else t += s[i];
			}
			swap(s, t);
			t = "";
		}	
	}
}


Measured memory_bytes: 3248
from collections import deque
 
N, Q = map(int,input().split())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
P = [0] * N
for _ in range(Q):
    p,q = map(int,input().split())
    P[p-1] += q
 
stack = deque([0])
parent = [-1] * N

while stack:
    v = stack[-1]
    if G[v]:
        w = G[v].pop()
        if not parent[v] == w:
            parent[w] = v
            P[w] += P[v]
            stack.append(w)
    else:
        stack.pop()

print(*P)

Measured memory_bytes: 57616
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

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

const int lx[] = {0, 0, -1, 1};
const int ly[] = {-1, 1, 0, 0};

int a[505][505], vis[505][505];
int n, m;
ll bfs(int x, int y)
{
    ll w = 0, b = 0;
    queue<pii> q;
    q.push({x, y});
    vis[x][y] = 1;
    while(!q.empty()){
        x = q.front().first;
        y = q.front().second;
        q.pop();
        if(a[x][y]) b++;
        else w++;
        for(int k = 0; k < 4; k++){
            int nx = x + lx[k];
            int ny = y + ly[k];
            if(nx < n && ny < m && nx >= 0 && ny >= 0 && a[nx][ny] != a[x][y]) {
                if(vis[nx][ny]) continue;
                vis[nx][ny] = 1;
                q.push({nx, ny});
            }
        }
    }
    return b*w;
}
int main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(int j = 0; j < m; j++){
            if(s[j] == '#') a[i][j] = 1;
            else a[i][j] = 0;
        }
    }

    ll ans = 0;
    for(int i = 0; i< n; i++){
        for(int j = 0; j < m; j++){
            if(!vis[i][j]){
                ans += bfs(i, j);
            }
        }
    }
    cout << ans;

}


Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
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 long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  long double a,b,r,syo;
  lint e;
  cin>>a>>b;
  r=a*b;
  r=floorl(r);
  e=r;
  cout<<e<<endl;
}

Measured memory_bytes: 3676
#include <iostream>

using namespace std;

int main()
{
    size_t n, m;
    cin >> n >> m;
    bool as[n] = { false };
    bool bs[n] = { false };
    for (size_t i = 0; i < m; ++i) {
        size_t a, b;
        cin >> a >> b;
        if (a == 1) { as[b - 1] = true ; }
        if (b == n) { bs[a - 1] = true ; }
    }
    for (size_t i = 1; i < n; ++i) {
        if (as[i] && bs[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main(){
	var N,ma,num int
	fmt.Scan(&N)
	m := make(map[int]int)

	for i:=0;i<N;i++{
		fmt.Scan(&num)
		m[num] += 1
	}

	for key,_ := range m{
		if (m[key-1]+m[key]+m[key+1]>ma){
			ma = m[key-1]+m[key]+m[key+1]
		}
	}
	fmt.Println(ma)
}

Measured memory_bytes: 8064
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10**9+7
#preprocess
#y_culculate
y_sum = 0
ans = 0
x_sum = 0
for i in range(1,m):
    h = y[i] - y[i-1]
    y_sum += h * i * (m - i)
    y_sum %= mod
for i in range(1,n):
    w = x[i] - x[i-1]
    x_sum += w * i * (n - i)
    x_sum %= mod
print((x_sum * y_sum) % mod)
    

Measured memory_bytes: 83300
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a))
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
void solve(){
    ll a,b,n;
    cin >> a >> b >> n;
    ll x;
    if(b-1<=n){
        cout << (a*(b-1))/b << endl;
        return;
    }
    cout << (a*(n))/b << endl;
}
int main() {
    IOS;
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  ll x[N],y[N];
  vector<ll> xlis;
  vector<ll> ylis;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    xlis.push_back(x[i]);
    ylis.push_back(y[i]);
  }
  sort(xlis.begin(),xlis.end());
  sort(ylis.begin(),ylis.end());
  ll ans = Mod * Mod * 4;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int k = 0; k < N; k++) {
        for (int l = k+1; l < N; l++) {
          int cnt = 0;
          for (int m = 0; m < N; m++) {
            if (xlis[i] <= x[m] && x[m] <= xlis[j] && ylis[k] <= y[m] && y[m] <= ylis[l]) {
              cnt++;
            }
          }
          if (cnt >= K) {
            ans = min(ans,(xlis[j] - xlis[i]) * (ylis[l] - ylis[k]));  
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string s[n];
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    bool ans=true;
    for(int i=1; i<n; i++){
        if(s[i-1][s[i-1].size()-1]!=s[i][0]){
            ans=false;
            break;
        }
        for(int j=0; j<n; j++){
            if(i==j) continue;
            if(s[i]==s[j]){
                ans=false;
                break;
            }
        }
        if(ans==false) break;
    }
    if(ans)cout << "Yes";
    else cout << "No";

    return 0;
}

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

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

D getExpectation(D x) {
   return perform(x)/x;
}

int main()
{
    cin>>N;
    Int sum=0;Int ans=0;
    for(int i=0;i<N;++i){
        Int x;cin>>x;
        sum+=x;
        ans=max(ans,x);
    }
    Int rem=ans/2;
    sum-=ans;
    sum+=rem;
    cout<<sum<<"\n";
}

Measured memory_bytes: 26996
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int A, B, X, ans = 0;
	cin >> A >> B >> X;
	if (2 * B <= A){
		for (int i = 0;; i++){
			ans += B;
			X -= 500;
			if (X <= 0)break;
		}
	}
	else if (A <= B){
		for (int i = 0;; i++){
			ans += A;
			X -= 1000;
			if (X <= 0)break;
		}
	}
	else{
		for (int i = 0;; i++){
			if (X > 500){
				ans += A;
				X -= 1000;
			}
			else if (X>0){
				ans += B;
				X -= 500;
			}
			else break;
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 3112
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();
    let chars:Vec<char> = s.chars().collect();
    let mut ans = "NO";
    'outer: for i in 0..s.len() {
        for j in i..s.len() {
            if format!("{}{}", &chars[..i].iter().collect::<String>(), &chars[j..].iter().collect::<String>()) == "keyence" {
                ans = "YES";
                break 'outer;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2120
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

template<class In>
void print_array(In begin, In end) {
  cout << (*begin);
  begin++;
  for (; begin != end; begin++)
  {
    cout << " " << (*begin);
  }
  cout << endl;
}

int main()
{
  ll N;
  cin >> N;
  vector<pair<ll, ll>> ba(N);
  for (auto i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    ba[i] = make_pair(b, a);
  }
  sort(ba.begin(), ba.end());

  ll cur_time = 0;
  string res = "Yes";
  for (auto i = 0; i < N; i++) {
    cur_time += ba[i].second;
    if (cur_time > ba[i].first) {
      res = "No";
      break;
    }
  }

  cout << res << endl;

  return 0;
}


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

int main(){
long long int  a,ans;
ans=0;
string str;
cin>>a;
cin>>str;
for(int i=0;i<a-2;i++){
	if(str[i]=='A'){
		if(str[i+1]=='B'){
			if(str[i+2]=='C'){
				ans++;
			}
		}
	}
}
cout<<ans<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
    int n,k;
    cin >> n >> k;
    int i, j;
    vector<bool> s(n, true);
    int d;
    for (i = 0; i < k ; ++i) {
        cin >> d;
        for (j = 0; j < d; ++j) {
            int b;
            cin >> b;
            s[b - 1] = false;
        }
    }
    int ans{};
    for (i = 0; i < n; ++i) {
        if (s[i]) {
            ++ans;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3620
n = int(input())
dic = {k:50 for k in "abcdefghijklmnopqrstuvwxyz"}

for _ in range(n):
    S = input()
    for k in dic:
        dic[k] = min(S.count(k),dic[k])

ans = ""
for k in "abcdefghijklmnopqrstuvwxyz":
    ans = ans + k*dic[k]
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
int N,H,W;
int y,x;
vector<int> G[2][MAX];
bool visited[2][MAX];
int flg[4],cnt[4];

void dfs(int f,int p){
  visited[f][p]=true;
  if(p==1)flg[f]=true;
  if(p==(f==0?H:W))flg[2+f]=true;
  
  int r=1-f;
  for(int i=0;i<(int)G[f][p].size();i++){
    int w=G[f][p][i];
    if(visited[r][w])continue;
    dfs(r,w);
  }
}

int main(){
  scanf("%d %d %d",&N,&H,&W);
  for(int i=0;i<N;i++){
    scanf("%d %d",&y,&x);
    G[0][y].push_back(x);
    G[1][x].push_back(y);
  }
  
  int ans=0;
  for(int i=0;i<MAX;i++){
    if(G[0][i].size()==0)continue;
    if(visited[0][i])continue;
    for(int j=0;j<4;j++)flg[j]=0;
    dfs(0,i);
    ans++;
    for(int j=0;j<4;j++)cnt[j]+=flg[j];
  }
  for(int i=1;i<4;i++)cnt[i]=max(cnt[i],cnt[i-1]);
  if(ans==1){
    cout<<N-1<<endl;
  }else{
    cout<<N+ans-1-cnt[3]<<endl;
  }
  return 0;
}

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

int ans[100];

double pwd( double tei,int n ){
	double ans = 1;
	for(int i = 0;i < n;i++)
		ans *= tei;
	return ans;
}

int main(){
	int i,j;
	int n,y;
	int b,r,t;
	int max1_num,max1_r;
	int max2_num,max2_r;
	
	for(i = 0; cin >> n ;i++){
		if(n == 0)break;
		cin >> y;
		max1_num = 0;
		max1_r = 0;
		max2_num = 0;
		max2_r = 0;

		for(j = 0;j < n;j++){
			cin >> b >> r >> t;
			if( t == 1 && max1_r < r ){
				max1_num = b;
				max1_r = r;
			}
			if( t == 2 && max2_r < r ){
				max2_num = b;
				max2_r = r;
			}
		}
		double tanri = 1 + max1_r/100.0 * y;
		double fukuri = pwd( 1 + max2_r/100.0 , y );
		if( tanri > fukuri )
			ans[i] = max1_num;
		else
			ans[i] = max2_num;
	}
	for(j = 0;j < i;j++){
		cout << ans[j] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
#define chmin(x,y) x=min(x,y)
string d[40][500];
int x[400],y[400];
string cost[400];
int main(){
	while(true){
		int N,M,s,g;
		cin>>N>>M>>s>>g;
		if(N==0) break;
		rep(i,N) rep(j,500) d[i][j]=string(1,'z'+1);
		d[s][0]="";
		rep(i,M){
			cin>>x[i]>>y[i]>>cost[i];
		}
		rep(i,500){
			rep(j,M){
				int a=x[j],b=y[j];
				if(d[a][i][0]=='z'+1) continue;
				if(i+cost[j].size()<500) chmin(d[b][i+cost[j].size()],d[a][i]+cost[j]);
			}
		}
		string ans(1,'z'+1);
		rep(i,500){
			chmin(ans,d[g][i]);
		}
		if(ans.size()>240||ans[0]=='z'+1){
			puts("NO");
		}else{
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 15112
a, b, c, x = [int(input()) for _ in range(4)]
res = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                res += 1
print(res)

Measured memory_bytes: 2940