akhauriyash/Code-Regression huggingface dataset:
#
# abc089 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
ZZ
ZZZ
Z
ZZZZZZZZZZ"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO"""
        output = """7"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    S = [input() for _ in range(N)]

    C = [0]*5
    for s in S:
        if s[0] == "M":
            C[0] += 1
        elif s[0] == "A":
            C[1] += 1
        elif s[0] == "R":
            C[2] += 1
        elif s[0] == "C":
            C[3] += 1
        elif s[0] == "H":
            C[4] += 1

    ans = 0
    for i, c1 in enumerate(C):
        for j, c2 in enumerate(C[i+1:], i+1):
            for c3 in C[j+1:]:
                ans += c1*c2*c3

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 23072
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdin =new Scanner(System.in);
		String s=stdin.next();
		int l=s.length();
		int i,j;
		int friend=0;
		boolean flag=true;
		char c[]=s.toCharArray();
		for(i=0;i<c.length;i++){
			for(j=0;j<c.length;j++)
				if(c[i]==c[j])
					friend++;

		if(friend%2!=0)
			flag=false;
		}
		if(flag)
			System.out.println("Yes");
		else if(!flag)
			System.out.println("No");
	}
}

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

int main(){
    string S ;
    cin >> S ;
    bool ans = true ;
    if(S[0] != 'A') ans = false ;
    int count = 0 ;
    for(int i = 1 ; i < S.size() ; i++ ){
        if( S[i] == 'C' ){
            count++ ;
            if( count == 2 )ans = false ;
            if( i >= 2 && i <= S.size() - 2 ) continue ;
            else ans = false ;
        } 
        else if( S[i] >= 97 && S[i] <= 122 ) continue ;
        else ans = false ;
    }
    if(ans&&count == 1 ) cout << "AC" << endl ;
    else cout << "WA" << endl;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
c=0
if x==y:
  pass
elif x==0:
  c+=abs(y)
  if y<0:
    c+=1
elif x<0 and y<=0:
  if abs(x)<abs(y):
    c=abs(y)-abs(x)
    c+=2
  else:
    c+=abs(x)-abs(y)
elif x<0 and 0<y:
  c=abs(abs(x)-y)
  c+=1
elif 0<x and y<=0:
  if abs(x)<abs(y):
    c=abs(y)-abs(x)
    c+=1
  else:
    c=abs(x)-abs(y)
    c+=1
elif 0<x and 0<y:
  if x<y:
    c=y-x
  else:
    c=x-y
    c+=2
print(c)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
  public static void main(String... args) {
    String out = "red";
    try (Scanner scan = new Scanner(System.in)) {
      int num = scan.nextInt();
      if (num >= 3200) out = scan.next();
    } catch (Exception e) {}
    System.out.println(out);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

double P[6],Q[6];

double sc(double x) {
	double ret=0;
	int i;
	FOR(i,6) ret += max(P[i]*x,Q[i]*(1-x));
	return ret;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,6) cin>>P[i], P[i]/=100;
	FOR(i,6) cin>>Q[i], Q[i]/=100;
	
	double L=0,R=1;
	FOR(i,200) {
		double M1=(L*2+R)/3;
		double M2=(L+R*2)/3;
		double V1=sc(M1);
		double V2=sc(M2);
		if(V1>=V2) L=M1;
		if(V1<=V2) R=M2;
	}
	_P("%.12lf\n",sc(L));
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long int n,k,q,b,i,j,sum=0,player;
    cin>>n>>k>>q;
    map<int,int>m;
    for(i=1;i<=q;i++)
    {
        cin>>b;
        m[b]++;
    }
    for(i=1;i<=n;i++)
    {
        if(k-(q-m[i])>0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


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

using namespace std;

int main(void) {
  
 int x1, x2, x3, x4, x5;
 cin >> x1 >> x2 >> x3 >> x4 >> x5;

int ans;
 if (x1 == 0) {
     ans = 1;
 }
 if (x2 == 0) {
     ans = 2;
 }
 if (x3 == 0) {
     ans = 3;
 }
 if (x4 == 0) {
     ans = 4;
 }
 if (x5 == 0) {
     ans = 5;
 }

 cout << ans << endl;

}


Measured memory_bytes: 3564
d=int(input())
*c,=map(int, input().split())
s=[]
for _ in range(d):
    *si,=map(int, input().split())
    s.append(si)
last=[-1]*26

ss=0
for i in range(d):
    ind=-1
    smx=-10**10
    for j in range(26):
        ssj=ss+s[i][j]
        for k in range(26):
            if k!=j:
                ssj-= c[k]*(i-last[k])
        if smx<ssj:
            smx=ssj
            ind=j
    last[ind]=i
    ss=smx        
    print(ind+1)








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

typedef long long int llint;

int main()
{
  string str;
  cin>> str;

  if(str == "zyxwvutsrqponmlkjihgfedcba") {
    cout<< -1 <<endl;
    return 0;
  }

  int exist[50] = {}; //0 ~ 25
  
  for(int i = 0; i < str.size(); i++) {
    exist[str[i] - 'a'] = 1;
  }
  
  if(str.size() == 26) {
    bool flg = false;
    while(!flg) {
      //cout<< str <<endl;
      int idx = str.size() - 1;
      if(str[idx] == 'z') {
	exist[str[idx] - 'a'] = 0;
	str.erase(str.begin() + idx);
	continue;
      }

      for(int i = str[idx] - 'a' + 1; i < 26; i++) {
	if(exist[i] == 0) {
	  str[idx] = 'a' + i;
	  flg = true;
	  break;
	}
      }

      if(!flg) {
	exist[str[idx] - 'a'] = 0;
	str.erase(str.begin() + idx);
      }
    }
  } else {
    for(int i = 0; i < 26; i++) {
      if(exist[i] == 0) {
	str += ('a' + i);
	break;
      }
    }
  }

  cout<< str <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std; 
   int N , A[3][3], b[10];
   bool win[3][3];
 int main() { 
  for (int i=0;i<3;i++) {
    for(int j=0;j<3;j++)  cin>>A[i][j];
  }
   cin>>N;
   for(int i=0;i<N;i++) cin>>b[i];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      win[i][j]=false;
      for(int k=0;k<N;k++) {
        if(A[i][j]==b[k]) win[i][j]=true;
      }
    }
  }
   string res="No";
   for (int i=0;i<3;i++) {
   if(win[i][0] and win[i][1] and win[i][2]) res="Yes";
   }
   for (int i=0;i<3;i++) {
   if(win[0][i] and win[1][i] and win[2][i]) res="Yes";
   }
   if(win[0][0] and win[1][1] and win[2][2]) res="Yes";
   if(win[2][0] and win[1][1] and win[0][2]) res="Yes";
   cout<<res<<endl;
 return 0;  
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,cnt[2],dep[101000],used[101000],fl;
vector<int>G[101000];
ll ans;
 
void dfs(int x,int fff){
	used[x]=1;
	cnt[dep[x]]++;
	for (int y:G[x]) if (y!=fff){
		if (!used[y]) dep[y]=dep[x]^1,dfs(y,x);
		else fl|=dep[x]==dep[y];
	}
}
 
int main(){
	scanf("%d%d",&n,&m);
	int x,y;
	for (int i=1;i<=m;i++)
		scanf("%d%d",&x,&y), G[x].push_back(y),G[y].push_back(x);
	dfs(1,0);
	ans= fl? (ll)n*(n-1)/2: (ll)cnt[0]*cnt[1];
	cout<<max(ans-m,0ll);
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,fa,rt1,rt2,cnt,cnt1,cnt2;
int val1[N],val2[N],to1[N],to2[N],tag[N],to[N<<2],nxt1[N],nxt2[N],nxt[N<<2],head[N],head1[N],head2[N];
inline void add1(int u,int v){
	to1[++cnt1]=v,nxt1[cnt1]=head1[u],head1[u]=cnt1;
}
inline void add2(int u,int v){
	to2[++cnt2]=v,nxt2[cnt2]=head2[u],head2[u]=cnt2;
}
inline void add(int u,int v){
	to[++cnt]=v,nxt[cnt]=head[u],head[u]=cnt;
}
int dfs1(int u){
	int lst=0;
	for(int i=head1[u];i;i=nxt1[i]){
		int v=to1[i],rt=dfs1(v); 
		if(!lst) lst=rt;
		else add(lst,rt),add(rt,lst),lst=0;
	}
	return (lst==0)?u:lst;
}
int dfs2(int u){
	int lst=0;
	for(int i=head2[u];i;i=nxt2[i]){
		int v=to2[i],rt=dfs2(v);
		if(!lst) lst=rt;
		else add(lst,rt),add(rt,lst),lst=0;
	}
	return (lst==0)?u:lst; 
}
void dfs(int u,int vv){
	tag[u]=vv;
	for(int i=head[u];i;i=nxt[i]) if(!tag[to[i]]) dfs(to[i],vv*-1); 
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) val1[i]=val2[i]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&fa);
		if(fa==-1) rt1=i;
		else add1(fa,i),val1[fa]^=1;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&fa);
		if(fa==-1) rt2=i;
		else add2(fa,i),val2[fa]^=1;
	}
	for(int i=1;i<=n;i++) if(val1[i]!=val2[i]) { puts("IMPOSSIBLE"); return 0; }
	puts("POSSIBLE");
	
	dfs1(rt1),dfs2(rt2);
	for(int i=1;i<=n;i++) if(tag[i]==0 && head[i]>0) dfs(i,1);
	for(int i=1;i<=n;i++) printf("%d ",(tag[i]!=0)?tag[i]:val1[i]);
}

Measured memory_bytes: 9728
// Fri Aug 21 19:35:37 IST 2020      
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int N = 1e5+7; 
const int INF = 2e9;
const int64 reallyBig = 1e16+7;

struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 

int tests(){    
    int N,X,T;
    cin >> N >> X >> T;
    cout << (N+X-1)/X *T << '\n';
    return 0;
}
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////

void solve(){
  ini(N);
  ins(S);
  int ans = 1;
  rep1(i,N-1){
    ans += S[i] != S[i-1];
  }
  out(ans);

}

Measured memory_bytes: 512
def f(n):
	e=[1,0,0,1];z=[1,1,1,0]
	while n:
		if n%2>0:e=g(e,z)
		z=g(z,z);n//=2
	return e[1]
M=998244353;g=lambda a,b:[(a[0]*b[0]+a[1]*b[2])%M,(a[0]*b[1]+a[1]*b[3])%M,(a[2]*b[0]+a[3]*b[2])%M,(a[2]*b[1]+a[3]*b[3])%M];n,m=map(int,input().split());I=[1,1];r=f(m+2*n-2);c=1
for i in range(2,n):I+=[(M-M//i)*I[M%i]%M]
for i in range(n-1):r=(r+c*(M-f(2*n-2-2*i)))%M;c=c*(m+i)*I[i+1]%M
print(r)

Measured memory_bytes: 53104
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {x: usize, y: usize};
    let mut flag = true;

    if y % 2 == 0 {
        for i in 0..=x {
            let sum = 2 * i + 4 * (x - i);
            if sum == y {
                println!("Yes");
                flag = false;
                break;
            }
        }
    }

    if flag {
        println!("No")
    }
}


Measured memory_bytes: 2164
#include<stdio.h>
#include<string.h>
int main(){
    int a=0;
    char s[4],t[4];
    scanf("%s %s",s,t);
    for(int i=0;i<3;i++){
        if(strncmp(&s[i],&t[i],1)==0){
            a++;
        }
    }
    printf("%d\n",a);
    return 0;
}


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int a,ans;
int main()
{
    cin>>a;
    if(a>=15)
        cout<<a*800-(a/15)*200;
    else
        cout<<a*800;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll ch[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	ll k;
	cin>>k;
	cout << ch[k-1];
	// your code goes here
	return 0;
}

Measured memory_bytes: 3528
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r,t){"use strict";e.exports=function(e){for(var r=Number(e[0]),t=e[1].split(" ").map(function(e){return Number(e)}),n=[],o=0;o<r;o++)n.push({num:o+1,sum:t[o]});n.sort(function(e,r){return e.sum-r.sum});for(var u=[],i=0;i<r;i++)u.push(n[i].num);console.log(u.join(" "))}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 56232
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main()
{
	int H, W;

	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
    return 0;
}


Measured memory_bytes: 3088
//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5,N=405;
int n,m,x[maxn],y[maxn];
bitset<N> b[N],ok;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m;
    rep(i,0,m)
    {
    	cin>>x[i]>>y[i];
    }
    rep(i,1,n+1)
    {
    	b[i][i]=1;
    	rrep(j,m-1,0)
    	{
    		if(b[i][x[j]]&&b[i][y[j]])
    		{
    			ok[i]=1;
    			break;
    		}
    		else if(b[i][x[j]])
    		{
    			b[i][y[j]]=1;
    		}
    		else if(b[i][y[j]])
    		{
    			b[i][x[j]]=1;
    		}
    	}
    }
    int re=0;
    rep(i,1,n+1)if(!ok[i])
    {
    	rep(j,i+1,n+1)if(!ok[j]&&(b[i]&b[j]).count()==0)
    	{
    		re++;
    	}
    }
    cout<<re;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int x, n, i, j, k, ans, a;

	cin >> x >> n;
	set<int> s;
	for (i = 0; i < n; i++) {
		cin >> a;
		s.insert(a);
	}

	for (i = 0; ; i++) {
		if (s.find(x - i) == s.end()) {
			ans = x - i;
			break;
		}
		if (s.find(x + i) == s.end()) {
			ans = x + i;
			break;
		}
	}

	cout << ans << "\n";
	

	return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int x,y,ans=0,z,n,i,j;
 cin>>n>>z;
   for(i=0;i<=n;i++)
   {
    for(j=0;j<=n;j++)
    {
        if((i*2+j*4)==z&&(i+j)==n)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
   }

   cout<<"No"<<endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll x;
 cin>>x;
 ll tmp=360;
 while(tmp%x!=0)tmp+=360;
 pr(tmp/x);
return 0;}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    string X;
    cin >> X;
    int N = X.length();

    int t = 0;
    int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        if (X[i] == 'S' && t > 0) {
            t--;
            ans++;
        } else if (X[i] == 'T') {
            t++;
        }
    }
    cout << N - ans * 2 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,a,b; cin>>n>>a>>b;
    int aa=0,ab=0,bb=0;
    rep(i,n){
        int p; cin>>p;
        if(p<=a) aa++;
        else if(p<=b) ab++;
        else bb++;
    }
    cout<<min({aa,ab,bb})<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string board[50];
int main() {
  int X, Y;
  cin >> X >> Y;
  int dx[8] = {1,1,0,0,-1,-1,1,-1};
  int dy[8] = {0,1,1,-1,0,-1,-1,1};
  for (int i = 0; i<X; i++) cin >> board[i];
  for (int i = 0; i<X; i++) {
    for (int j = 0; j<Y; j++) {
      if (board[i][j] == '.') {
        int cnt = 0;
        for (int k = 0; k<8; k++) {
          int x = i + dx[k];
          int y = j + dy[k];
          if (x >= 0 && x < X && y >= 0 && y < Y && board[x][y] == '#') {
            cnt++;
          }
        }
        board[i][j] = char(cnt + '0');
      }
    }
  }
  for (int i = 0; i<X; i++) cout << board[i] <<endl;
  return 0;
}

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


x = 26
y = n
ans = 'a'
while y > x:
    y -= x
    x *= 26
    ans += 'a'

y -= 1
ans = list(ans)
for i in range(len(ans)):
    x = pow(26, len(ans)-i-1)
    while y >= x:
        y -= x
        ans[i] = chr(ord(ans[i])+1)

print(''.join(ans))

Measured memory_bytes: 61832
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const N = parseInt(inputList[0].split(' ')[0]);
    inputList.shift();
    // お菓子持っている人リスト
    const sweetsNList = inputList.filter((ele, idx) => idx % 2 != 0)
                                 .map(ele => ele.split(' '))
                                 .flatMap(ele => ele);
    const trimSweetsNList = Array.from(new Set(sweetsNList)).map(ele => parseInt(ele));
    // N人の配列作成
    let NList = [];
    for(let i = 0; i < N; i++) {
      NList.push(i + 1);
    }
    
    // お菓子を持っていないリスト
    NList = NList.filter(ele => trimSweetsNList.includes(ele) == false);
    console.log(parseInt(NList.length))
  }
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
 
int main() {
    int N ;
    cin >> N;
    int K;
    cin >> K;
    vector<int> fruit(N);
    for(int i = 0;i < N ;i++){
        cin >> fruit.at(i);
    }
    sort(fruit.begin(),fruit.end());
    int sum = -1;
    for(int i = 0;i < K ;i++){
        sum += fruit.at(i);
    }
    cout << sum + 1 << endl;
    return 0;

}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template <typename T> using orderSet =
//tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000000000000018
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
 
#define MX 200005
 
int main()
{
	ll s, w;
	cin>>s>>w;
 
	if(s <= w) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<vector<int>>a(N,vector<int>(3));
  for(int i=0;i<N;i++)for(int j=0;j<3;j++)cin>>a[i][j];
  vector<vector<int>>dp(N+1,vector<int>(3,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k)continue;
        dp[i+1][j]=max(dp[i+1][j],dp[i][k]+a[i][j]);
      }
    }
  }
  int ans=0;
  for(int i=0;i<3;i++)ans=max(ans,dp[N][i]);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 11264
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		while(true){

			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();

			if(op.equals("+")){
				System.out.println(a + b);
			}else if(op.equals("-")){
				System.out.println(a - b);
			}else if(op.equals("*")){
				System.out.println(a * b);
			}else if(op.equals("/")){
				System.out.println(a / b);
			}else if(op.equals("?")){
				break;
			}
		}
	}
}

Measured memory_bytes: 26408
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#define LL long long
#define PP std::pair<LL,LL>
std::vector<PP> alpha[26];
char M[310][310];
int  res[310];
int N;
int ans;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			std::cin >> M[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				int A = (i + k) % N;
				if (M[i][j] == M[(j+N-k)%N][A]) {
					res[k]++;
				}
			}
		}
	}
	for (int i = 0; i < N; i++) {
		if (res[i] == N * N)ans += N;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
while n != 0:
  list = input().split()

  for i in range(len(list)):
    list[i] = int(list[i])

  avgs = sum(list) / n
  i = 0
  a = 0
  for i in range(len(list)):
    if list[i] <= avgs:
      a = a + 1
  print(a)
  n = int(input())


Measured memory_bytes: 6344
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl        	"\n"
#define int         	long long int  
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll         	pair<ll,ll>
#define vec     		vector<ll>
#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod     		1000000007

ll mod_pow(ll a,ll b)
{
    ll res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    
    return res;
}

void solve()
{
	ld L;
	
	cin>>L;
	
	ld a = L/3.0;
	ld b = L/3.0;
	ld c = L/3.0;
	
	cout<<setprecision(12)<<fixed<<a*b*c;
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	max := 0
	for i := 0; i < n; i++ {

		var h int
		fmt.Scan(&h)

		if max <= h {
			max = h
			continue
		}

		if max > h+1 {
			fmt.Print("No")
			return
		}

		max = h + 1
	}

	fmt.Print("Yes")
}


Measured memory_bytes: 5504
S = input()[::-1]

while len(S) > 0:
    if S[:5] == 'maerd':
        S = S[5:]
    elif S[:5] == 'esare':
        S = S[5:]
    elif S[:6] == 'resare':
        S = S[6:]
    elif S[:7] == 'remaerd':
        S = S[7:]
    else:
        print('NO')
        break

if len(S) == 0:
    print('YES')


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

int main(){
    int h, w;
    cin >> h >> w;
    long long ans = 1e10;
    for (int i = 1; i < h; i++){
        long long a, b, c;
        a = (long long)i * w;
        if ((h - i) % 2 == 0 || w % 2 == 0) b = (long long)w * (h - i) / 2, c = b;
        else if (w != 1 && h - i != 1) b = ((long long)w * (h - i) + min(w, h - i)) / 2, c = ((long long)w * (h - i) - min(w, h - i)) / 2;
        else if (w != 1 || h - i != 1) b = ((long long)w * (h - i) + 1) / 2, c = ((long long)w * (h - i) - 1) / 2;
        else continue;
        ans = min(ans, max({a, b, c}) - min({a, b, c}));
    }
    swap(w, h);
    for (int i = 1; i < h; i++){
        long long a, b, c;
        a = (long long)i * w;
        if ((h - i) % 2 == 0 || w % 2 == 0) b = (long long)w * (h - i) / 2, c = b;
        else if (w != 1 && h - i != 1) b = ((long long)w * (h - i) + min(w, h - i)) / 2, c = ((long long)w * (h - i) - min(w, h - i)) / 2;
        else if (w != 1 || h - i != 1) b = ((long long)w * (h - i) + 1) / 2, c = ((long long)w * (h - i) - 1) / 2;
        else continue;
        ans = min(ans, max({a, b, c}) - min({a, b, c}));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>

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

using namespace std;

const double EPS=1e-9;

int n,x[100],y[100];

struct Pos{
	double a,b;
	Pos(double A,double B):a(A),b(B){}
	bool operator<(const Pos &p)const{
		if(abs(a-p.a)>EPS) return a<p.a;
		if(abs(b-p.b)>EPS) return b<p.b;
		return false;
	}
};

vector<Pos> findNextPos(const Pos &p){
	vector<int> ca,cb;
	rep(i,n-1){
		if(x[i]-EPS<p.a && p.a<x[i+1]+EPS) ca.push_back(i);
		if(x[i]-EPS<p.b && p.b<x[i+1]+EPS) cb.push_back(i);
	}

	vector<Pos> res;
	rep(i,ca.size()) rep(j,cb.size()) {
		int i1=ca[i],i2=ca[i]+1,j1=cb[j],j2=cb[j]+1;
		double yy,x1,x2;

		if(y[i1]==y[i2] || y[j1]==y[j2]){
			if(y[i1]==y[i2]){
				res.push_back(Pos(x[i1],p.b));
				res.push_back(Pos(x[i2],p.b));
			}
			if(y[j1]==y[j2]){
				res.push_back(Pos(p.a,x[j1]));
				res.push_back(Pos(p.a,x[j2]));
			}
		}
		else{
			yy=min(max(y[i1],y[i2]),max(y[j1],y[j2]));
			x1=(double)(x[i2]-x[i1])/(y[i2]-y[i1])*(yy-y[i1])+x[i1];
			x2=(double)(x[j2]-x[j1])/(y[j2]-y[j1])*(yy-y[j1])+x[j1];
			res.push_back(Pos(x1,x2));

			yy=max(min(y[i1],y[i2]),min(y[j1],y[j2]));
			x1=(double)(x[i2]-x[i1])/(y[i2]-y[i1])*(yy-y[i1])+x[i1];
			x2=(double)(x[j2]-x[j1])/(y[j2]-y[j1])*(yy-y[j1])+x[j1];
			res.push_back(Pos(x1,x2));
		}
	}
	return res;
}

inline double height(double xx){
	rep(i,n-1) if(x[i]-EPS<xx && xx<x[i+1]+EPS) {
		return (double)(y[i+1]-y[i])/(x[i+1]-x[i])*(xx-x[i])+y[i];
	}
}

inline double calcDistance(const Pos &p,const Pos &q){
	double hpa=height(p.a),hpb=height(p.b),
		   hqa=height(q.a),hqb=height(q.b);
	return sqrt((p.a-q.a)*(p.a-q.a)+(hpa-hqa)*(hpa-hqa))
		  +sqrt((p.b-q.b)*(p.b-q.b)+(hpb-hqb)*(hpb-hqb));
}

double solve(){
	map<Pos,double> d;
	d[Pos(0,x[n-1])]=0;

	priority_queue< pair<double,Pos> > pq;
	pq.push(make_pair(0,Pos(0,x[n-1])));
	while(1){
		double cost=-pq.top().first;
		Pos p=pq.top().second; pq.pop();

		if(d[p]+EPS<cost) continue;
		if(abs(p.a-p.b)<EPS) return cost;

		vector<Pos> next=findNextPos(p);
		rep(i,next.size()){
			double cost2=calcDistance(p,next[i]);
			if(d.count(next[i])==0 || cost+cost2+EPS<d[next[i]]){
				d[next[i]]=cost+cost2;
				pq.push(make_pair(-(cost+cost2),next[i]));
			}
		}
	}
}

int main(){
	for(;scanf("%d",&n),n;){
		rep(i,n) scanf("%d%d",x+i,y+i);
		printf("%.15f\n",solve());
	}
	return 0;
}

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

int main() {
  int k,s,ans=0;
  cin>>k>>s;
  for (int x=0;x<=k;x++){
    for (int y=0;y<=k;y++){
      if (s-x-y>=0 && s-x-y<=k) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	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 getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(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
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	a := getNextInt64(scanner)
	b := getNextInt64(scanner)
	k := getNextInt64(scanner)

	mod := int64(998244353)
	cm := Com{}
	cm.mod = mod
	cm.init(n)

	if k == 0 {
		fmt.Fprintln(writer, 1)
		return
	}

	var ans int64
	for i := 0; i < n; i++ {
		x := int64(i + 1)
		if (k-a*x)%b != 0 {
			continue
		}
		y := (k - a*x) / b
		if y > int64(n) {
			continue
		}
		if y < 0 {
			continue
		}

		ans += cm.calc(n, int(x)) * cm.calc(n, int(y))
		ans %= mod
	}

	fmt.Fprintln(writer, ans)
}

// Com ...
type Com struct {
	facs, invs []int64
	mod        int64
}

func (cm *Com) init(n int) {
	cm.facs = make([]int64, n+1)
	cm.invs = make([]int64, n+1)

	cm.facs[0] = 1
	for i := 1; i <= n; i++ {
		cm.facs[i] = (cm.facs[i-1] * int64(i)) % cm.mod
	}
	cm.invs[n] = cm.inv(cm.facs[n])
	for i := n - 1; i >= 0; i-- {
		cm.invs[i] = cm.invs[i+1] * int64(i+1) % cm.mod
	}
}

func (cm *Com) inv(n int64) int64 {
	var ii [32]int64
	ii[0] = n
	for i := 1; i < 31; i++ {
		ii[i] = (ii[i-1] * ii[i-1]) % cm.mod
	}
	var ans int64
	ans = 1
	m := cm.mod - 2
	for i := 30; i >= 0; i-- {
		for m >= 1<<uint(i) {
			ans = (ans * ii[i]) % cm.mod
			m -= 1 << uint(i)
		}
	}

	return ans
}

func (cm *Com) calc(n, k int) int64 {
	ans := cm.facs[n] * cm.invs[k]
	ans %= cm.mod
	ans = ans * cm.invs[n-k]
	ans %= cm.mod
	return ans
}


Measured memory_bytes: 5504
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    ans = 0
    c = Counter(A)
    for k, v in c.items():
        if k < v:
            ans += v - k
        elif v < k:
            ans += v
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68136
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string S, T, a, b;
    int i, j, k, l, judge=0, N;

    cin >> S;

    N = S.size();

    //for(i=0; i<N-3; i++){
        for(j=0; j<N; j++){
            for(k=0; k<N; k++){
                //for(l=k+1; l<N; l++){
                    a = S.substr(0,j);
                    b = S.substr(N-k, k);
                    T += a;
                    T += b;
                    if(T=="keyence") judge = 1;

                    T = "";
                //}
            }
        }
    //}

    if(judge==1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
# Problem:
# Python  Try

import sys
# from collections import defaultdict
# import heapq
# import copy
# from collections import deque
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(totalsum):
    result = "No"
    for j in range(0, 100//4+1, +1):
        for k in range(0, 100//7+1, +1):
            thiscase = j * 4 + k * 7
            if thiscase == totalsum:
                result = "Yes"
    return result


if __name__ == "__main__":
    print("{}".format(solver(II())))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
//long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string N;
    int K;
    cin >> N >> K;
    if(N.size() < K){
        cout << 0 << endl;
        return 0;
    }
    int L = N.size();
    vector<vector<vector<int>>> DP(L+1,vector<vector<int>> (K+1, vector<int>(2,0)));
    DP[0][0][0] = 1;

    rep(i,L){
        rep(j,K+1){
            rep(m,2){
                int nd = N[i] - '0';
                rep(d,10){
                    int cm = m, cj = j;
                    if(m == 1){
                        if(d != 0){
                            cj++;
                        }
                        if(cj > K){
                            continue;
                        }

                    }else{
                        if(d > nd){
                            continue;
                        }
                        if(d != 0){
                            cj++;
                        }
                        if(d != nd){
                            cm = 1;
                        }
                        if(cj > K){
                            continue;
                        }
                    }
                    DP[i+1][cj][cm] += DP[i][j][m];
                }
            }
        }
    }
    cout << DP[L][K][0] + DP[L][K][1] << endl;
    /*
    ll tot=0;
    if(K == 1){
        tot += 9*(L-1);
        tot += N[0] - '0'; 
    }else if(K == 2){
        tot += 9*9*(L-1)*(L-2);
        ll tmp = 1;
        rep(i,L){
            if(N[i] == '0') continue;
            if(N[i] - '0' - 1 > 0 && L-i-1 >0){
                tmp *= ((N[i] - '0')-1)*9*(L-i-1);
            }else if(){
                int j=1;
                while(j < L){
                    if(N[j] == '0'){
                        j++
                        continue;
                    }else if()
                }
            }

        }
        tot += tmp;
    }else{
        tot += 9*9*9*(L-1)*(L-2)*(L-3);
        ll tmp = 1;
        rep(i,L){
            //tot += (N[0] - '0')*9*9*(L-1)*(L-2);
            tmp *= (N[i] - '0')*(L-i-1)*9;
        }
        tot += tmp;
    }
    cout<< tot <<endl;*/
}


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

int main() {
  int X, Y, x, y;
  bool ans = false;
  cin >> X >> Y;
  
  if ( X == 1 ) {
    if ( Y == 4 || Y == 2 ) {
      ans = true;
    }
  } else {
    for ( int i = 0; i < X+1; i++ ) {
      x = i;      //亀
      y = X - i;  //鶴
      if ( x * 4 + y * 2 == Y ) {
        ans = true;
        break;
      }
    }
  }

  if ( ans ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int W[200010],fir[200010],dis[400010],nxt[400010],id;
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int ans[200010],max[200010],c,Ans[200010];
void DFS(int x,int fa=0){
	ans[x]=std::lower_bound(max,max+c+1,W[x])-max;
	Ans[x]=std::max(ans[x],Ans[fa]);
	int _=-1;
	if(ans[x]>c)max[++c]=W[x];
	else _=max[ans[x]],cnk(max[ans[x]],W[x]);
	for(int i=fir[x];i;i=nxt[i]){
		if(dis[i]==fa)continue;
		DFS(dis[i],x);
	}
	if(~_)max[ans[x]]=_;
	else--c;
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),a,b;
	for(int i=1;i<=n;++i)W[i]=gi();
	for(int i=1;i<n;++i)a=gi(),b=gi(),link(a,b),link(b,a);
	DFS(1);for(int i=1;i<=n;++i)printf("%d\n",Ans[i]);
	return 0;
}



Measured memory_bytes: 24344
fun main(args: Array<String>) = abc156d()

fun abc156d() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }

    var answer = modPow(2, n.toLong(), MOD)
    answer -= 1
    answer = (answer + MOD) % MOD
    answer -= comb(n, a, MOD)
    answer = (answer + MOD) % MOD
    answer -= comb(n, b, MOD)
    answer = (answer + MOD) % MOD

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private fun modPow(n: Long, p: Long, m: Long): Long {
    var x = n
    var y = p
    var result = 1L
    x %= m
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x) % m
        y = y shr 1
        x = (x * x) % m
    }
    return result
}

private fun comb(n: Int, k: Int, m: Long): Long {
    if (n < k) return 0
    val min = Math.min(k, n - k)
    var numerator = 1L
    var denominator = 1L
    for (i in 1L..min) {
        numerator *= n - i + 1
        numerator %= m
        denominator *= i
        denominator %= m
    }
    return numerator * modPow(denominator, m - 2, m) % m
}


Measured memory_bytes: 38244
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int num = sc.nextInt();
        long sum = 0;
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < num; i++){
            int col = sc.nextInt();
            sum += col;
            list.add(col);
        }
        Integer max = Collections.max(list);
        Integer min = Collections.min(list);

        System.out.println(min + " " + max + " " + sum);
    }
}



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

int main() {

  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> correct(Q);
  for (int i = 0; i < Q; i++) cin >> correct.at(i);

  vector<int> vec(N, K - Q);

  for (int i = 0; i < correct.size(); i++) {
    vec.at(correct.at(i) - 1) += 1;
  }

  for (int i = 0; i < vec.size(); i++) {
    if (vec.at(i) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>   
using namespace std;    
int main(){
  int n;
  cin>>n;
  if(n==111){
    cout<<999<<endl;
  }
  else if(n==119){
    cout<<991<<endl;
  }
  else if(n==191){
    cout<<919<<endl;
  }
  else if(n==199){
    cout<<911<<endl;
  }
  else if(n==911){
    cout<<199<<endl;
  }
  else if(n==919){
    cout<<191<<endl;
  }
  else if(n==991){
    cout<<119<<endl;
  }
  else if(n==999){
    cout<<111<<endl;
  }
}



  
  

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<llint> a(n);
    for(llint in=0;in<n;in++) {
        cin >> a.at(in);
    }

    llint ans = 0;
    vector<llint> l(n), r(n);
    llint ltmp, rtmp;
    for(llint in=0;in<n;in++) {
        ltmp = in + a.at(in);
        rtmp = in - a.at(in);
        if(ltmp<n) l.at(ltmp)++;
        if(rtmp>=0) r.at(rtmp)++; 
    }
    
    for(llint in=0;in<n;in++) {
        ans += l.at(in)*r.at(in);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7956
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int max = a[0] + (k-a[n-1]);
        int sum = max;
        for(int i=1; i<n; i++) {
            max = Math.max(max, a[i]-a[i-1]);
            sum += a[i]-a[i-1];
        }
        System.out.println(sum-max);
    }
}


Measured memory_bytes: 79320
from collections import deque


N = int(input())
S = [input() for _ in range(N)]
es = [[] for _ in range(N)]

for i in range(N):
    for j in range(i+1,N):
        if S[i][j] == "1":
            es[i].append(j)
            es[j].append(i)


INF = float("inf")

def bfs(node):
    dist = [INF] * N
    dist[node] = 0
    union = [[] for _ in range(N+1)]
    union[0].append(node)
    q = deque()
    q.append(node)
    while q:
        curr = q.popleft()
        for nxt in es[curr]:
            if dist[curr] + 1 < dist[nxt]:
                dist[nxt] = dist[curr] + 1
                union[dist[nxt]].append(nxt)
                q.append(nxt)

    d = max(dist)
    max_idx = dist.index(d)
    return max_idx, dist, union

s, dist, union = bfs(0)

for u in union:
    if len(u) >= 2:
        for i in u:
            for j in u:
                # 同じ集合なのに辺があると矛盾するのでNG
                if S[i][j] == "1":
 
                    print(-1)
                    exit()
ans = 0
for i in range(N):
    _, dist, _ = bfs(i)
    ans = max(ans, max(dist)+1)

print(ans)

Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int main() {
	int N, T, c, t;
	cin >> N >> T;
	int ans_c = 1001;
	bool flag = false;
	for(int i = 1; i <= N; i++) {
		cin >> c >> t;
		if (t <= T) {
			flag = true;
			if (c <= ans_c) ans_c = c;
		}
	}
	if (flag) {
		cout << ans_c << endl;
	} else {
		cout << "TLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 384