akhauriyash/Code-Regression huggingface dataset:
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]

ans = True

for i in range(len(l)):
    time = l[i][0]
    x = l[i][1]
    y = l[i][2]
    dist = x + y
    if not ((dist <= time) & ((time - dist) % 2 == 0)):
        ans = False
print("Yes") if ans else print("No")


Measured memory_bytes: 27380
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.nextLine();
		in.close();
		
		String ans = str.charAt(5) == '1' ? "TBD"
				: str.charAt(6) > '4' ? "TBD" : "Heisei";
		System.out.println(ans);
	}
}

Measured memory_bytes: 19924
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

const int N = 100;
typedef long long ui;
int n; ui ans;
bool a[N];
char s1[N], s2[N], s[N];
ui f[N][N];

ui check() {
	int c1, c2, i, j;
	c1 = c2 = 0;
	dep(i, n+n, n+1)
	if(a[n+n+1-i]) s1[++c1] = s[i]; else s2[++c2] = s[i];
	rep(i, 0, c1)
		rep(j, 0, c2) {
			if(i || j) f[i][j] = 0; else f[i][j] = 1;
			if(i && s[i+j] == s1[i]) f[i][j] += f[i-1][j];
			if(j && s[i+j] == s2[j]) f[i][j] += f[i][j-1];
		}
	//printf("%d\n", f[c1][c2]);
	return f[c1][c2];
}

void dfs(int dep) {
	if(dep > n) {ans += check(); return;}
	a[dep] = 1; dfs(dep+1);
	a[dep] = 0; dfs(dep+1);
}

int main() {
	scanf("%d", &n);
	scanf("%s", s+1);
	dfs(1);
	printf("%lld\n", ans);
	return 0;
}

/*
17
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
*/

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

int main(){
string s;
cin>>s;
char answer;
int yes=0;
for(char i='a';i<='z';i++){
    int ok=1;
    if(yes==1)break;
    for(int k=0;k<s.size();k++){
        if(s.at(k)==i)ok=0;
    }
    if(ok==1){
        answer=i;
        yes=1;
    }
}
if(yes==1){
    cout<<answer;
}else{
    cout<<"None";
}
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n, k;
    string s;
    
    cin >> n >> k >> s;
    s[k-1] += 'a' - 'A';
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
int a[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    int ans=0;
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1]<<endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
string s;
int k;

int main() {
    cin >> s >> k;
    int i = 0;
    while (k) {
        if (s[i] != '1') {
            cout << s[i] << endl;
            exit(0);
        }
        --k;
        ++i;
    }
    cout << '1' << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N, long long X, long long Y){
  vector<int> v(N);

  FOR1(i, N) {
    FOR(j, i+1, N+1){
      // dv("i", i);
      // dv("j", j);
      int dis = min((ll)j - i, abs(X-i) + abs(j-Y) + 1);
      // dv("dis", dis); cerr << endl;
      v.at(dis) += 1;
    }
  }

  FOR(x, 1, N) cout << v.at(x) << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  solve(N, X, Y);
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void uniq(vector<int> &vec){sort(vec.begin(), vec.end());vec.erase(unique(vec.begin(), vec.end()), vec.end());}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    int lcm=c*d/gcd(c,d);
    int u=b-a;
    int x=b/c-a/c;
    int y=b/d-a/d;
    int z=b/lcm-a/lcm;
    cout<<u-x-y+z<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define ucin() ios :: sync_with_stdio(0)
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;
typedef double db;

const int N = 1e5 + 10;

bool vis[N];

int main() {
	ucin();
	for(int i = 1; i <= 9; i ++)
		for(int j = 1; j <= 9; j ++)
			vis[i * j] = 1;
	int x; cin >> x;
	cout << (vis[x] ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
/*
 * C言語のサンプルプログラム - Webkaru
 * - 入力した2つの自然数の最大公約数を求める -
 */
#include <stdio.h>
 #include<iostream>
 #include<stdlib.h>
int main(void)
{
	int N=0,X=0,r=0,tmp=0;
	scanf("%d %d",&N,&X);
	int x=0,y=0;
	scanf("%d",&x);
	x=abs(X-x);
	for(int i=1;i<N;i++)
	{
		scanf("%d",&y);
		y=abs(X-y);
  /* 自然数 a > b を確認・入替 */
  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
  /* ユークリッドの互除法 */
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
}
x=y;
}
  /* 最大公約数b */
 printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


N = int(input())

if N == 7 or N == 5 or N == 3:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
//
// Created on 2020/04/04.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    ll n,k;
    cin>>n>>k;
    ll ans = min(abs(k-n%k),n%k);

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
int n,d,ans=0;
int main(){
    scanf("%d%d",&n,&d);
    rep(i,1,n) {
        int x,y;
        scanf("%d%d",&x,&y);
        double k=sqrt(1.0*x*x+1.0*y*y);
        if(k<=d)++ans;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3800
#include"bits/stdc++.h"
using namespace std;

const long long MOD = 1e9 + 7;

vector<long long> fact, inv_fact;

long long POW(long long a, long long b) {
    long long result = 1;
    while (b) {
        if (b & 1) {
            result *= a;
            result %= MOD;
        }

        a *= a;
        a %= MOD;
        b /= 2;
    }

    return result;
}

long long combination(long long n, long long m) {
    if (n < m) {
        return 0;
    }
    return fact[n] * inv_fact[m] % MOD * inv_fact[n - m] % MOD;
}

int main() {
    long long n;
    cin >> n;
    vector<long long> a(n + 1);
    vector<long long > appear(n + 1, -1);
    long long left_index, right_index;
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
        if (appear[a[i]] != -1) {
            left_index = appear[a[i]];
            right_index = i;
        } else {
            appear[a[i]] = i;
        }
    }

    fact.resize(n + 2);
    inv_fact.resize(n + 2);
    fact[0] = 1;
    inv_fact[0] = 1;
    for (long long i = 1; i <= n + 1; i++) {
        fact[i] = i * fact[i - 1] % MOD;
        inv_fact[i] = POW(fact[i], MOD - 2);
        assert((fact[i] * inv_fact[i]) % MOD == 1);
    }

    long long left_num = left_index;
    long long right_num = n - right_index;

    for (long long  k = 1; k <= n + 1; k++) {
        cout << (combination(n + 1, k) + MOD - combination(left_num + right_num, k - 1)) % MOD << endl;
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const long long M = (long long)1e9+7;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) {
    if(a>=0)
        return a;
    return -a;
}
template<typename T> inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {
    return modpow(b, Mod - 2, Mod );
}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}

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

template <typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (; isdigit(ch); ch = getchar())
        n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}
template<typename T, typename U> inline void Int(T &a, U &b) {
    Int(a);
    Int(b);
}
template<typename T, typename U, typename W> inline void Int(T &a, U &b, W &c) {
    Int(a,b);
    Int(c);
}
template<typename T, typename U, typename W,typename X> inline void Int(T &a, U &b, W &c, X &d) {
    Int(a,b,c);
    Int(d);
}
vector<int> Unique(vector<int> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb			push_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

map<string,int>A,B;

int main() {
    int n = Int ;
    for(int i = 1 ; i <= n ; i++){
    	string s ; cin >> s ;
    	A[s]++;
    }
    int m = Int ;
    for(int i = 1 ; i <= m ; i++){
    	string s ; cin >> s ;
    	B[s]++ ;
    }
    int res = 0 ;
    for(auto u : A){
    	res = max ( res , u.ss - B[u.ff]);
    }
    printf("%d\n",res);

}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=200001;

int n;
vd a;

int main(){
	cin>>n;
	a=vd(n);
	vd dp(M);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<M;i++) dp[i]=fabs(a[0]-i)/a[0];
	for(int i=1;i<n;i++){
		vd DP(M,inf);
		for(int j=1;j<M;j++){
			for(int k=j;k<M;k+=j) DP[k]=min(DP[k],max(dp[j],fabs(a[i]-k)/a[i]));
		}
		dp=DP;
	}
	double res=inf;
	for(int i=1;i<M;i++) res=min(res,dp[i]);
	cout<<syosu(11)<<res<<endl;
}

Measured memory_bytes: 6284
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>

using namespace std;
int main() {

	int y, m, d;
	char c1, c2;

	cin >> y >> c1 >> m >> c2 >> d;

	if (m > 4) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}

	return 0;

}

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

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

    ll n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll res = 0;
    rep(i, n){
        if(a[i]>=b[i]) res += b[i];
        else{
            res += a[i];
            b[i] -= a[i];
            if(a[i+1]>=b[i]){
                res += b[i];
                a[i+1] -= b[i];
            }
            else{
                res += a[i+1];
                a[i+1] = 0;
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

ll rec(ll n,ll x){
    if (n == 0){
        return 1;
    }

    ll sou = pow(2,n+1) -3;
    ll pat = pow(2,n) -1;

    if (x == 1){
        return 0;
    }
    else if (x <= sou +1){
        return rec(n-1,x-1);
    }
    else if (x == sou +2){
        return pat +1;
    }
    else if (x <= (2*sou) +2){
        return pat + 1 + rec(n-1,x-sou-2);
    }
    else{
        return 2*pat +1;
    }
}

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

    ll n,x;
    cin >> n >> x;
    cout << rec(n,x) << endl;

}

Measured memory_bytes: 4020
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B.exe B.cpp 
Execute: ./B
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	string s, t; 
	cin >> s >> t; 
	
	int result = 1000000, x = 0; 
	
	for(int i = 0; i < s.size() - t.size() + 1; i++) {
		x = 0; 
		for(int j = 0; j < t.size(); j++) {
			if(s[i+j] != t[j])
				x++; 
		}
		if(x < result)
			result = x; 
	}
	
	cout << result << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  int64_t X,N,ans1,ans2;
  cin>>X>>N;
  if(N==0){
    cout<<X<<endl;
    return 0;
  }
  else{
unordered_map<int,int> m;
  ans1=X;
  ans2=X;
  //vector<int64_t> A(N);
 for(int i=0; i<N; i++){
   int a;
   cin>>a;
   m[a]=1;
 }
  while(true){
   if(!m.count(ans1)){cout<<ans1<<endl;break;return 0;}
   if(!m.count(ans2-1)){cout<<ans2-1<<endl;break;return 0;}
    
   if(!m.count(ans1+1)){cout<<ans1+1<<endl;break;return 0;}
    ans1++;
    ans2--;
  }

  }
  
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        if(r<1200){
            System.out.println("ABC");
        }else if(r<2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }
    }
}


Measured memory_bytes: 22868
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N; cin >> N;
    vector<Pi_i> vp(N);
    REP(i, N){
        int X, L; cin >> X >> L;
        vp[i] = {X+L, X-L}; //to, from
    }
    SORT(vp);
    int cnt = 0, cur = -2*INF;
    REP(i, N){
        if(cur <= vp[i].second){
            ++cnt; cur = vp[i].first;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

const int SIZE = 1010;
int dp[SIZE][SIZE];

int editDistance(string s, string t){
    rep(i, 0, SIZE) rep(j, 0, SIZE) dp[i][j] = 0;
    rep(i, 0, SIZE) dp[i][0] = i;
    rep(i, 0, SIZE) dp[0][i] = i;
    rep(i, 0, s.size()){
        rep(j, 0, t.size()){
            int cost = (s[i] == t[j]) ? 0 : 1;
            dp[i + 1][j + 1] = min(dp[i][j] + cost, min(dp[i + 1][j] + 1, dp[i][j + 1] + 1));
        }
    }
    return dp[s.size()][t.size()];
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    cout << editDistance(s, t) << endl;
}

Measured memory_bytes: 11216
n = int(input())

isp = []
for i in range(1, n+1):
    s, p = input().split()
    isp.append([i, s, int(p)])
    
isp = sorted(isp, key=lambda x: x[2], reverse=True)
isp = sorted(isp, key=lambda x: x[1])
for i in isp:
    print(i[0])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m;
    ll i,j;
    ll cnt=0;
    ll a,b;
    cin>>n;
    vector<pair<ll,ll> >vp;
    for(i=0; i<n; i++)
    {
        cin>>a>>b;
        vp.push_back({a,b});
    }
    for(i=0; i<n-2; i++)
    {
        if(vp[i].first==vp[i].second&&vp[i+1].first==vp[i+1].second&&vp[i+2].first==vp[i+2].second)
            cnt=1;
    }
    if(cnt)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;

}


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

using namespace std;


int main()
{
	int n, s=0;
	cin >> n;
	int a[10];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		s += a[i];
	}
	if (s > a[n-1])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, dp[5100][5100], ans;
string s;
int main() {
	cin >> n >> s;
	REP(i, n) {
		REP(j, n) {
			if (s[i] == s[j] and dp[i][j] + 1 <= j - i) dp[i + 1][j + 1] = dp[i][j] + 1;
			ans = max(ans, dp[i + 1][j + 1]);
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 201088
N,A,B=map(int,input().split())

nin=A*(N-1)+B
nax=A+B*(N-1)

if N==1 and A!=B:
    print(0)
    exit()
elif N==1:
    print(1)
    exit()
elif A>B:
    print(0)
    exit()
print(nax-nin+1)

Measured memory_bytes: 9208
#include<stdio.h>


int main (void){
    int N;
    int flag=0;
    scanf("%d",&N);


    if(N%10==7){
        flag=1;
    }else if((N/10)%10==7){
        flag=1;
    }else if(N/100==7){
        flag=1;
    }


    if(flag==1){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}



Measured memory_bytes: 1732
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;

signed main(){
    ll n;
    cin >> n;
    ll a[n];
    map<ll,ll> cnt;
    ll sum = 0;

    rep(i,0,n){
        cin >> a[i];
        sum += a[i];
        if(cnt.count(a[i]) == 0){
            cnt[a[i]] = 1;
        }
        else{
            cnt[a[i]]++;
        }
    }

    ll q;
    cin >> q;
    
    rep(i,0,q){
        ll b,c;
        cin >> b >> c;
        if(cnt.count(b) != 0){
            sum += (c-b)*cnt[b];
            cout << sum << endl;
        }
        else{
            cout << sum << endl;
        }
        
        if(cnt.count(b) != 0){
            if(cnt.count(c) == 0){
                cnt[c] += cnt[b];
                cnt[b] = 0;
            }
            else{
                cnt[c] += cnt[b];
                cnt[b] = 0;
            }
        }
    }

    return 0;
}


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

int main() {
  int N,K;
  cin >>N>>K;
  vector<int> c(N);
  for (int i=0;i<N;i++){
    cin >> c.at(i);
  }
  sort(c.begin(),c.end());
  int l=0;
  for (int i=N-1;i>N-K-1;i--){
    l+=c.at(i);
  }
  cout << l<<endl;
  
}


Measured memory_bytes: 256
class RangeMinimumQuery:
    def __init__(self, n, func=min, inf=float("inf")):
        self.n0 = 2**(n-1).bit_length()
        # 初期値
        self.op = func
        self.inf = inf
        self.data = [self.inf]*(2*self.n0-1)

    # [l, r)
    def query(self, l,r):
        l += self.n0
        r += self.n0
        res = self.inf
        while l < r:
            if r&1:
                r -= 1
                res = self.op(res, self.data[r-1])
            if l&1:
                res = self.op(res, self.data[l-1])
                l += 1
            l >>=1
            r >>=1
        return res

    def update(self, i, x):
        i += self.n0-1
        self.data[i] = x
        while i+1:
            i = ~-i//2
            self.data[i] = self.op(self.data[2*i+1], self.data[2*i+2])

n,k = map(int, input().split())
p = list(map(int, input().split()))

RminQ = RangeMinimumQuery(n)
RmaxQ = RangeMinimumQuery(n, func=max, inf=0)

for i, pi in enumerate(p):
    RminQ.update(i, pi)
    RmaxQ.update(i, pi)

a = [1]
for i in range(n-1):
    if p[i] < p[i+1]:
        a.append(a[-1]+1)
    else:
        a.append(1)

ans = n-k+1
flag = a[k-1] == k
for i in range(k, n):
    if (p[i] > RmaxQ.query(i-k+1, i) and p[i-k] < RminQ.query(i-k+1, i)) or (flag and a[i]>=k):
        ans -= 1
    if not flag and a[i] >= k:
        flag = True
print(ans)

Measured memory_bytes: 113656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

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(a-c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
X = list(map(int, input().split()))
Y = []

for n in range(N-K+1):
    t = abs(X[n]-X[n+K-1]) + min(abs(X[n]), abs(X[n+K-1]))
    Y.append(t)

if N - K == 0:
    ans = abs(X[0] - X[-1]) + min(abs(X[0]), abs(X[-1]))
    print(ans)
else:
    print(min(Y))


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    int N, M, K;
    cin >>N>>M>>K;
    rep(i,N+1) rep(j,M+1){
        if(K==i*(M-j)+(N-i)*j){
            Yes; return 0;
        }
    }
    No;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int cnt = 0, n = s.size();
	rep(i,n) if(s.at(i) == 'p') cnt++;
	cout << (n - cnt * 2) / 2 << endl;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int n=s.size();
    bool ok=1;
    rep(i,n){
        if(s[i]!=t[i]){
            ok=0;
        }
    }
    if(t.size()!=n+1){
        ok=0;
    }
    if(ok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=2005;
//i_am_noob
int n,ans=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n) rep1(j,n) rep1(k,n) ans+=__gcd(__gcd(i+1,j+1),k+1);
	print1(ans);
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <functional>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

#define Get(ty,...) ty __VA_ARGS__;cins(__VA_ARGS__);
#define ci cin
#define co cout
#define en endl;


void cins(){}

template<class Head,class... Tail>
void cins(Head& head,Tail&... tail) {
	cin >> head;
	cins(tail...);
}

int main() {
	Get(string, s)
		co<<count_if(s.begin(), s.end(), [](char c) {return c == '1'; })<<en
}


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

int bubbleSort(int *,int);

int main(){
  int n,count,i;
  int *a;

  count = 0;
  
  scanf("%d",&n);
  if(n < 1 || 100 < n)exit(0);

  a = malloc(n*sizeof(int));

  for(i = 0; i < n; i++){
    scanf("%d",a+i);
    if(*(a+i) < 0 || 100 < *(a+i))exit(1);
  }
  
  count = bubbleSort(a,n);
  
  for(i = 0; i < n; i++){
    if(i == 0){
      printf("%d",*(a+i));
      continue;
    }
    printf(" %d",*(a+i));
  }
  printf("\n");
  printf("%d\n",count);
  
  return 0;
}

int bubbleSort(int *a,int n){
  int count,i,flag,j,v;

  count = 0;
  flag = 1;
  
  while(flag){
    flag = 0;
    for(j = n - 1; j >= (i + 1); j--){
      if(*(a+j) < *(a+j-1)){
	v = *(a+j);
	*(a+j) = *(a+j-1);
	*(a+j-1) = v;
	count++;
	flag = 1;
      } 
    }
    i++;
  }
  
  return count;
}



Measured memory_bytes: 2084
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include <iomanip>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
#define _GLIBCXX_DEBUG

using namespace std;



int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v;
    rep(i, n) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ll count = 0;
    for (int i = k; i < n; i++) {
        count += v[i];
    }
    cout << count << endl;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
using lint = long long;

using namespace std;

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

  int h, w;
  cin >> h >> w;
  vector<vector<bool>> grid(h + 1, vector<bool>(w + 1));
  rep(i, h) {
    rep(j, w) {
      char c;
      cin >> c;
      grid[i][j] = (c == '.' ? true : false);
    }
  }
  vector<vector<int>> sums(h + 1, vector<int>(w + 1));
  rep(i, h + 1) {
    int sum = 0;
    rep(j, w + 1) {
      if (grid[i][j]) {
        ++sum;
      } else {
        irep(k, j - sum, j) {
          sums[i][k] += sum;
        }
        sum = 0;
      }
    }
  }
  rep(i, w + 1) {
    int sum = 0;
    rep(j, h + 1) {
      if (grid[j][i]) {
        ++sum;
      } else {
        irep(k, j - sum, j) {
          sums[k][i] += sum;
        }
        sum = 0;
      }
    }
  }
  int maxsum = 0;
  rep(i, h) {
    maxsum = max(maxsum, *max_element(all(sums[i])));
  }
  cout << maxsum - 1 << endl;
  return 0;
}

Measured memory_bytes: 16640
#include<stdio.h>

int main(){
    int a, b;
    scanf("%d %d", &a ,&b);
    while(!(a==0&&b==0)){
        for(int i=0; i<a; i++){
            for(int j=0; j<b; j++){
                printf("#");
            }
            puts("");
        }
        printf("\n");
         scanf("%d %d", &a ,&b);
    }
    
}


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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,m,b,mod;
    while(cin >> n >> m >> b >> mod){
        ll ans = m - n + 1;
        ll l = b * mod / __gcd(b,mod);
        ll low = (n - 1) / b;
        ll upp = m / b;
        ans -= upp - low;
        upp = m / mod;
        low = (n - 1) / mod;
        ans -= upp - low;
        upp = m / l;
        low = (n - 1) / l;
        ans += upp - low;
        cout << ans << endl;
    }

}

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

using namespace std;

int n, m, cnt[26];
char s[1000], ans[105][105];

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < m; j++)
      cnt[s[j] - 'a']++;
  }
  int dua = 0, satu = 0;
  if ((n & 1) && (m & 1))
    dua = (n + m - 2)/2, satu = 1;
  else if (n & 1)
    dua = m / 2;
  else if (m & 1)
    dua = n/2;
  for (int i = 0; i < 26; i++) {
    int now = cnt[i];
    now %= 4;
    dua -= now / 2;
    now %= 2;
    satu -= now;
  }
  if (!(satu >= 0 && dua >= 0)) {
    puts("No");
    return 0;
  }
  puts("Yes");
  // for (int i = 0; i < n-1-i; i++) {
  //   for (int j = 0; j < m-1-j; j++) {
  //     for (int k = 0; k < 26; k++)
  //       if (cnt[k] >= 4) {
  //         cnt[k] -= 4;
  //         ans[i][j] = ans[n-1-j][j] = ans[i][m-1-j] = ans[n-1-j][m-1-j] = k + 'a';
  //         break;
  //       }
  //   }
  // }
  // if (n & 1) {
  //   for (int j = 0; j < m-1-j; j++) {
  //     for (int k = 0; k < 26; k++) if (cnt[k] >= 2) {
  //       ans[n/2][j] = ans[n/2][m-1-j] = k + 'a';
  //       cnt[k] -= 2;
  //       break;
  //     }
  //   }
  // }

  // if (m & 1) {
  //   for (int i = 0; i < n-1-i; i++) {
  //     for (int k = 0; k < 26; k++) if (cnt[k] >= 2) {
  //       ans[i][m/2] = ans[n-1-i][m/2] = k + 'a';
  //       cnt[k] -= 2;
  //       break;
  //     }
  //   }
  // }
  // if ((n & 1) && (m&1)) {
  //   for (int k = 0; k < 26; k++) if (cnt[k]) {
  //     ans[n/2][m/2] = 'a' + k;
  //     break;
  //   }
  // }
  // for (int i = 0; i < n; i++) {
  //   ans[i][m] = 0;
  //   printf("%s\n", ans[i]);
  // }
  return 0;
}

Measured memory_bytes: 256
#A問題
A, B, C = map(int, input().split())
if A == B == 5 and C == 7:
    print("YES")
elif B == C == 5 and A == 7:
    print("YES")
elif C == A == 5 and B == 7:
    print("YES")
else:
    print("NO")

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;cin>>n>>k;
  int tot=0;
  int a[200005];
  rep(i,200005)a[i]=0;
  rep(i,n){
      int tmp;cin>>tmp;
      a[tmp]++;
  }
  sort(a,a+200005,greater<int>());
  for(int i=k;i<200005;i++){
      if(a[i]==0)break;
      tot+=a[i];
  }
  cout<<tot<<endl;
  return 0;
  }


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstdio>
using namespace std;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	ll n;
	cin>>n;
	int a1,a2,a3,a4;
	a1=n%10;
	a2=(n%100-a1)/10;
	a3=(n%1000-a2-a1)/100;
	a4=(n-a3-a2-a1)/1000;
	if(a1==a2&&a2==a3){
		cout<<"Yes";
		return 0;
	}
	if(a2==a3&&a3==a4){
		cout<<"Yes";
		return 0;
		
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	int H, W; cin >> H >> W;
	VS a(H); REP(i, H) cin >> a[i];
	VVB b(H, VB(W, true));
	VB c(H, true);

	bool flg;
	REP(i, H) {
		flg = true;
		REP(j, W) if (a[i][j] != '.') flg = false;
		if (flg) REP(j, W) b[i][j] = false;
		if (flg) c[i] = false;
	}
	REP(j, W) {
		flg = true;
		REP(i, H) if (a[i][j] != '.') flg = false;
		if (flg) REP(i, H) b[i][j] = false;
	}
	REP(i, H) {
		REP(j, W) {
			if (b[i][j]) cout << a[i][j];
		}
		if(c[i]) cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
INF  = Float::INFINITY
Edge = Struct.new(:from, :to, :cost)

class Graph
  attr :edges, :V, :E, :d
  def initialize(v,e)
    @V = v
    @E = e
    @edges = []
    @d = []
  end

  def add_graph_edge(u, v, w)
    @edges << Edge.new(u,v,w)
  end

  def bellman_ford(source=0)
    @d = Array.new(@V,INF)
    @d[source] = 0

    for count in 0...@V
      for i in 0...@edges.length
        v = edges[i].to
        u = edges[i].from
        c = edges[i].cost
        #puts "from[#{u}] to[#{v}] cost=#{c},count=#{count}"
        if @d[u] + c < @d[v]
          @d[v] = @d[u] + c
          #p count
          #p v
          return false if (count == @V-1)
        end
      end
    end
    true
  end
end

lines = $stdin.read
array = lines.split("\n")

V,E,R = array[0].split(" ").map(&:to_i)
graph = Graph.new(V,E)

array[1..E].each do |s|
  s,t,d = s.split(" ").map(&:to_i)
  graph.add_graph_edge(s,t,d)
end

if graph.bellman_ford(R)
  graph.d.each do |d|
    if d == INF
      puts "INF"
    else
      puts d
    end
  end
else
  puts "NEGATIVE CYCLE"
end



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

int n;

void dfs(string s) {

	if (s.size() == n)cout << s << endl;
	else {
		int mx = -1;
		rep(i, s.size())mx = max(mx, s[i] - 'a');

		rep(i, mx + 2) {
			char c = 'a' + i;
			string ss = s;
			ss += c;
			dfs(ss);
		}
	}
}


int main() {

	cin >> n;
	dfs("");

}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int h = tmp[0], w = tmp[1];
	char[][] a = new char[h+2][];
	a[0] = a[h+1] = (new string('#', w+2)).ToCharArray();
	for (int i = 1; i <= h; i++)
	{
	    a[i] = ("#" + ReadLine() + "#").ToCharArray();
	}

	List<Tuple<int, int>> next = new List<Tuple<int, int>>();
	// Search Initial '#'s
	for (int i = 1; i <= h; i++)
	{
	    for (int j = 1; j <= w; j++)
	    {
		if (a[i][j] == '#')
		    next.Add(Tuple.Create(i, j));
	    }
	}

	int ans = 0;
	// Solve
	while (next.Count > 0)
	{
	    ans++;
	    List<Tuple<int,int>> tls = next;
	    next = new List<Tuple<int,int>>();
	    foreach (Tuple<int,int> t in tls)
	    {
		int x = t.Item1, y = t.Item2;
		if (a[x-1][y] != '#'){ next.Add(Tuple.Create(x-1,y)); a[x-1][y] = '#'; }
		if (a[x+1][y] != '#'){ next.Add(Tuple.Create(x+1,y)); a[x+1][y] = '#'; }
		if (a[x][y-1] != '#'){ next.Add(Tuple.Create(x,y-1)); a[x][y-1] = '#'; }
		if (a[x][y+1] != '#'){ next.Add(Tuple.Create(x,y+1)); a[x][y+1] = '#'; }
	    }
	}

	WriteLine(ans-1);
    }
}


Measured memory_bytes: 54424