akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

#define M 1046527
#define L 14
#define NIL (-1)

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i =0;;i++){
    h = (h1(key) + i * h2(key))%M;
    if( strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i =0;;i++){
    h = (h1(key) + i * h2(key))%M;
    if( strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);

	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 16064
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int x = in.nextInt();
		out.println(x*x*x);
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}


Measured memory_bytes: 26384
#include <iostream>
#include <vector>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdio.h>
#include <functional>
#define int long long
using namespace std;
 
signed main(){
    int n;
    int max=0;
    int min=0;
    cin>> n;
    int N=3*n;
    int a[N];
 
    priority_queue<int> PQ1;
    priority_queue<int, vector<int>, greater<int> >PQ2;
 
    int max_arr[n+2]={0};
    int min_arr[n+2]={0};
    
    for(int i=0;i<3*n;i++){
        cin>>a[i];
        
    }
 
    for(int i=0;i<n;i++){
        max+=a[i];
        min+=a[i+2*n];
    }
 
    // cout<<max<<" "<<min<<endl;
 
    max_arr[0]=max;
    
    for(int i=0;i<n;i++){
        PQ2.push(a[i]);
    }
 
    for(int i=n;i<2*n+1;i++){
        PQ2.push(a[i]);
        max+=a[i];
        max-=PQ2.top();
        PQ2.pop();
        max_arr[i-n+1]=max;
 
    }
 
    // for(int i=0;i<n+1;i++){
    //     cout<<max_arr[i]<<" ";
    // }
 
    min_arr[n]=min;
    for(int i=2*n;i<3*n;i++){
        PQ1.push(a[i]);
    }
    for(int i=3*n;i>2*n;i--){
        // cout<<i-n-1<<endl;
        PQ1.push(a[i-n-1]);
        min+=a[i-n-1];
        min-=PQ1.top();
 
        // cout<<PQ1.top()<<endl;
        PQ1.pop();
        min_arr[(i-2*n)-1]=min;
    }
    // cout<<count<<endl;
 
 
    // for(int i=0;i<n+1;i++){
    //     cout<<min_arr[i]<<" ";
    // }
 
 
    // for(int i=0;i<n+1;i++){
    //     max[i]=
    // }
 
    int ans=-1e19;
    for(int i=0;i<n+1;i++){
        if(ans<max_arr[i]-min_arr[i]){
            ans=max_arr[i]-min_arr[i];
        }
        // ans=max(ans,);
    }
    // cout<<ans<<endl;
    printf("%lld\n",ans);
 
}

Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


const int mod = 1000000007;
const int max_n = 2000050;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);
mint dp[1000100][2];

int main(){
    ll n;cin >> n;
    string s;cin >> s;
    /*dp[0][0]=1;
    rep(i,10){
        rep(j,s.size()+1){
            dp[i+1][j]+=dp[i][j]*25;
            dp[i+1][j+1]+=dp[i][j];
            if(j==s.size())dp[i+1][j]+=dp[i][j];
        }
    }
    rep(i,10){
        rep(j,10){
            cout << dp[i][j] <<" ";
        }
        cout << endl;
    }*/
    ll t=s.size();
    dp[0][0]=comb(t,t-1)*25;dp[0][1]=1;
    rep(i,1000010){
        dp[i+1][0]+=dp[i][0]/comb(t+i,t-1)*comb(t+i+1,t-1)*25;
        dp[i+1][1]+=dp[i][0]+dp[i][1]*26;
    }
    cout << dp[n][1] <<endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
    int64 N;
    cin >> N;
    vector<PLL> v(N);
    REP(i, N) {
        cin >> v[i].fs;
        v[i].sc = i;
    }
    sort(all(v));
    REP(i, N) {
        cout << v[i].sc+1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
ll N, M;
vector<pair<int,int> > v;
int main(){
   cin >> N >> M;
   int a,b;
   REP(i,N){
       cin >> a >> b;
       v.push_back(make_pair(a,b));
   }
   sort(v.begin(),v.end());
   REP(i,N){
       M -= v[i].second;
       if(M <= 0){
           cout << v[i].first << endl;
           return 0;
       }
   }

}

Measured memory_bytes: 1400
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

def lcm(a, b):
  return a*b//gcd(a,b)

n, m = map(int,input().split())
a = list(map(int, input().split()))

LCM = a[0]
c = 0
while a[0] % 2 == 0:
    c += 1
    a[0] = a[0] // 2
for i in range(1, n):
    LCM = lcm(LCM, a[i])
    k = 0
    while a[i] % 2 == 0:
        k += 1
        a[i] = a[i] // 2
    if k != c:
        print(0)
        exit()


x = (m * 2) // LCM
y = (m * 2) // (LCM * 2)

print(x - y)

Measured memory_bytes: 15060
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    A = [list(map(int,input().split())) for _ in range(N)]
    
    p = 0
    for i in reversed(range(N)):
        u,m = A[i]
        u += p
        p += (-(-u//m)*m-u)
        
    print(p)

if __name__ == "__main__":
    main()


Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

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

	int dp[m+1][n+1];for(int i=0;i<=m;i++) for(int sum=0;sum<=n;sum++) dp[i][sum]=inf;//dpは枚数を出力する
	dp[0][0]=0;

	for(int i=0;i<m;i++){
		for(int sum=0;sum<=n;sum++){
			if(sum>=c[i]) dp[i+1][sum]=min(dp[i][sum],dp[i+1][sum-c[i]]+1);
			else dp[i+1][sum]=dp[i][sum];
		}
	}

/*	for(int i=0;i<=m;i++){
		if(i==0) cout<<0<<":";
		else cout<<c[i-1]<<":";
		for(int sum=0;sum<=n;sum++){
			cout<<dp[i][sum]<<" ,";
		}
		cout<<endl;
	}
	*/
	cout<<dp[m][n]<<"\n";
}



Measured memory_bytes: 7176
#include <stdio.h>
#include <math.h>
int main(){
  int n;
  long int sum=1;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    sum=sum*i;   
  sum = sum%(1000000000 + 7);
  }
 
  printf("%ld",sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin >>n;
  int a[n],b[n],sum=0;
  for (int i=0;i<n;i++){
    cin >>a[i];
    sum+=a[i];
  }
  bool d=true;
  for (int i=0;i<n;i++){
    b[i]=sum-a[i];
    if (b[i]<=a[i])d=false;
  }
  if (d==true)cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		//スキャナークラスを宣言
		Scanner scan = new Scanner(System.in);

		//inｔ型の変数を
		int intNum1;
		int intNum2;

		while(true){
			//入力した内容を変数に代入
			intNum1 = scan.nextInt();
			intNum2 = scan.nextInt();

			//条件式 数が小さい順に表示される
			//二つの数値がともに０場合は何も出力せずループを抜ける
			if(intNum1 > intNum2){
				System.out.println(intNum2 + " " + intNum1);
			}else if(intNum1 < intNum2){
				System.out.println(intNum1 + " " + intNum2);
			}else if(intNum1 == intNum2 && intNum1 != 0){
				System.out.println(intNum1 + " " + intNum2);
			}else if(intNum1 == 0 && intNum2 == 0){
				break;
			}
		}
		scan.close();
	}
}



Measured memory_bytes: 35212
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[][] a = new int[3][3];

		for (int i = 0;i<3 ;i++ ) {
			for (int j = 0;j<3 ;j++ ) {
				a[i][j] = sc.nextInt();
			}
		}

		int n = sc.nextInt();
		int[] data = new int[n];

		for (int i = 0;i<n ;i++ ) {
			data[i] = sc.nextInt();
		}

		for (int k = 0;k<n ;k++ ) {
			for (int i = 0;i<3 ;i++ ) {
				for (int j = 0;j<3 ;j++ ) {
					if (a[i][j]==data[k]) {
							a[i][j] = -1;
					}
				}
			}
		}

		for (int i = 0;i<3 ;i++ ) {//横
			int count = 0;
			for (int j = 0;j<3 ;j++ ) {
				if (a[i][j]==-1) {
					count++;
				}
			}
				if (count==3) {
					System.out.println("Yes");
					System.exit(0);
				}
		}
		for (int j = 0;j<3 ;j++ ) {//たて
			int count = 0;
			for (int i = 0;i<3 ;i++ ) {
				if (a[i][j]==-1) {
					count++;
				}
			}
				if (count==3) {
					System.out.println("Yes");
					System.exit(0);
				}
		}

		if (a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1) {
			System.out.println("Yes");
			System.exit(0);
		}
		if (a[0][2]==-1&&a[1][1]==-1&&a[2][0]==-1) {
			System.out.println("Yes");
			System.exit(0);
		}
		System.out.println("No");

	}
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int x=max(max(a,b),c)*3;
  int y=a+b+c;
  if ((x-y)%2==0) cout << (x-y)/2 << endl;
  else cout << (x+3-y)/2 << endl;
}

Measured memory_bytes: 256
t = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

x = (b[0] - a[0]) * t[0]
y = (b[1] - a[1]) * t[1]

if x + y == 0
    puts x == y ? 0 : "infinity"
elsif x == 0 || y== 0 || (x > 0 && x + y > 0) || (x < 0 && x + y < 0)
    puts 0
elsif x + y > 0
    s, t = x.abs.divmod(x + y)
    puts t != 0 ? s * 2 + 1 : s * 2
else
    s, t = x.divmod((x + y).abs)
    puts t != 0 ? s * 2 + 1 : s * 2
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,k;
      cin>>n>>k;
      int ans=0;
      for(int i=0;i<n;i++)
      {
            int x;
            cin>>x;
            if(x>=k) ans++;
      }
      cout<<ans;
}
// I never lose. I either win or I learn

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:

bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

int main()
{

    ll n,m;
    cin >> n >> m;
    vector<ll> adj[n+5];
    bool vis[n+5];
    mset(vis,0);
    ll dis[n+5];
    mset(dis,0);
    queue<ll> q;
    for(ll i=0;i<m;i++)
    {

        ll x,y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    q.push(1);
    vis[1]=1;
    while(!q.empty())
    {

        ll u=q.front();q.pop();
        for(ll i=0;i<adj[u].size();i++)
        {

            ll v=adj[u][i];
            if(vis[v]==0)
            {

                vis[v]=1;
                dis[v]=u;
                q.push(v);
            }
        }
    }
    bool tf=1;
    for(ll i=2;i <= n;i++)
        if(dis[i]==0) {tf=0;break;}
    if(!tf) cout << "No\n";
    else cout << "Yes\n";
    for(ll i=2;i<=n;i++) cout << dis[i] << endl;
}


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

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans ;
    if (n>=b-1){
        ll c=b-1;
        ll d=c/b;
        ans = a*c/b -a*d;
    }else{
        ll d=n/b;
        ans =a*n/b-a*d;
    }
    cout<< ans;
}

Measured memory_bytes: 3584
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int n, p[22]; long long m, a[22], d[1048588];
long long gcd(long long x, long long y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> p[i];
	d[0] = 1;
	double v = log10(m);
	for (int i = 0; i < n; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			long long g = gcd(d[j - (1 << i)], a[i]);
			d[j] = d[j - (1 << i)] / g;
			if (log10(d[j]) + log10(a[i]) >= v + 0.01) d[j] = m + 1;
			else d[j] *= a[i];
		}
	}
	for (int i = 0; i < 1 << n; i++) d[i] = m / d[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 1 << n; j++) {
			if ((j >> i) & 1) d[j] -= d[j - (1 << i)];
		}
	}
	double ex = 0.0;
	for (int i = 0; i < 1 << n; i++) {
		double prob = 1.0;
		for (int j = 0; j < n; j++) {
			prob *= 0.01 * ((i >> j) & 1 ? p[j] : 100 - p[j]);
		}
		ex += prob * (m - abs(d[i]));
	}
	cout << fixed << setprecision(15) << ex << endl;
	return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	int n;cin>>n;
	vector<string> s(n);
	int i,j,k;
	rep(i,n) cin>>s[i];
	vector<ll> count(5,0);
	rep(i,n)
	{
		if(s[i][0]=='M')count[0]++;
		if(s[i][0]=='A')count[1]++;
		if(s[i][0]=='R')count[2]++;
		if(s[i][0]=='C')count[3]++;
		if(s[i][0]=='H')count[4]++;
	}
	ll ans=0;
	for(i=0;i<5;i++)
	{
		for(j=i+1;j<5;j++)
		{
			for(k=j+1;k<5;k++)
			{
				ans+=count[i]*count[j]*count[k];
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6144
# submit#2
s = input().rstrip()
v = [0, 0, 0]
for i in range(len(s)):
    if s[i] == 'a':
        v[0] = v[0] + 1
    elif s[i] == 'b':
        v[1] = v[1] + 1
    elif s[i] == 'c':
        v[2] = v[2] + 1

result = 'NO'
kind = 0
for i in range(len(v)):
    if v[i] != 0:
        kind = kind + 1

if len(s) <= 3:
    if kind == len(s):
        result = 'YES'

else:
    if kind == 3:
        minv = min(v)
        for i in range(len(v)):
            v[i] = v[i] - minv

        if sum(v) < 3:
            kind = 0
            for i in range(len(v)):
                if v[i] != 0:
                    kind = kind + 1

                if kind == sum(v):
                    result = 'YES'

print(result)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define fore(i,a,b) for(int i=a,thxicesi=b; i<thxicesi;i++)
#define FIN ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define sz(s) int(s.size())
using namespace std;

int main()
{FIN;
    int n; cin>>n;
    vector<int> a(n+1);
    fore(i,0,n-1){
        int b; cin>>b;
        a[b]++;
    }
    fore(i,1,1+n){
        cout<<a[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3968
<?php
  list($n, $k) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $f = array_map('intval', explode(" ", trim(fgets(STDIN))));

  sort($a);
  rsort($f);

  $max = 0;
  for($i = 0; $i < $n; $i++){
    $max = max($max, $a[$i]*$f[$i]);
  }

  $ok = $max;
  $ng = -1;

  while($ok - $ng > 1){
    $x = intdiv($ng+$ok, 2);
//    echo $ng." ".$ok." ".$x.PHP_EOL;
    $needK = 0;
    for($i=0; $i<$n; $i++){
      $h = intdiv($x, $f[$i]);
      if($h < $a[$i]){
        $needK += $a[$i]-$h;
      }
    }
//    echo ">".$k." ".$needK.PHP_EOL;
    if($k >= $needK){
      $ok = $x;
    }else{
      $ng = $x;
    }
  }

  echo $ok;



Measured memory_bytes: 44380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

ll MOD = 1000000007;

ll spow(ll a,ll p){
  if(p == 0) return 1;
  if(p == 1) return a;
  ll tmp = spow(a,p/2)%MOD;
  if(p%2 == 0) return tmp*tmp%MOD;
  else{
    ll ans = a*tmp%MOD;
    ans = ans*tmp%MOD;
    return ans;
  }
}

int main(){
  ll x,y;
  cin >> x >> y;
  if((x+y)%3 != 0){
    cout << 0 << endl;
    return 0;
  }
  ll a = (2*x-y)/3;
  ll b = (-x+2*y)/3;
  if(a < 0 || b < 0){
    cout << 0 << endl;
    return 0;
  }
  vector<ll> f(a+b+1,1);
  rep1(i,a+b) f[i] = (f[i-1]*i)%MOD;
  ll inv1 = spow(f[a],MOD-2);
  ll inv2 = spow(f[b],MOD-2);
  ll ans = f[a+b]*inv1%MOD;
  ans = ans*inv2%MOD;
  cout << ans << endl;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
int main()
{    
    int n;
    cin>>n;
    int a,b,j,x=100000;
	for(int i=1;i<n;i++)
	{
		j=0;
		a=i;
		b=n-i;
		while(a>0)
		{
			j+=a%10;
			a/=10; 
		}
		while(b>0)
		{
			j+=b%10;
			b/=10; 
		}
		x=min(x,j);
	} 
	cout<<x;
    return 0;
}


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


int main() {
    //input
    int n;
    std::cin >> n;

    //int a[n];
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());

    int range = a.at(n/2) - a.at(n/2-1);

    std::cout << range << std::endl;
    //for (int i=0;i<n;i++){
    //    std::cout << a.at(i) << std::endl;
    //}


    return 0;
}

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

int main(void) {
	int h, w, i, j;
	while (1) {
		cin >> h >> w;
		if (!h && !w)
			break;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
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; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
  	cin >> N;
    int A[N];
    double ans[N];
    double cnt = 0;
    REP(i,N){
        cin >> A[i];
        ans[i] = 1.0 / (double)A[i]; 
        cnt += ans[i];
    }
    cout << 1.0/cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll INF = 1e12;

int main() {
  int N;
  cin >> N;
  vector<int> counts;

  ll crnt;
  ll prev;
  int count = 0;
  for(int i = 0; i < N; ++i) {
    cin >> crnt;
    if(i != 0) {
      if(prev >= crnt) {
        count++;
        // cout << prev << " > " << crnt << endl;
      } else {
        counts.push_back(count);
        count = 0;
        // cout << "push : " << count << endl;
      }
    }
    prev = crnt;
  }
  // 最後
  counts.push_back(count);

  auto maxelm = max_element(counts.begin(), counts.end());
  cout << *maxelm << endl;

  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
const ull MOD = 1000000007;
const int MAX_N = 100000;
ull fact[MAX_N + 1];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<ull> ans;
	fact[0] = 0;
	fact[1] = 1;
	for (int i = 2; i < MAX_N + 1; i++) fact[i] = (fact[i - 1] * i) % MOD;
	while (1){
		int N, R;
		ull num = 0;
		cin >> N;
		if (N == 0) break;
		ans.push_back(0);
		vector<int> word(N);
		for (int i = 0; i < N; i++) word[i] = i;
		word.push_back(0);
		cin >> R;
		vector<int> s(2*R+1, 0);
		for (int i = 0; i < R; i++){
			cin >> s[i] >> s[i+R];
			s[i]--; s[i+R]--;
			word[s[i]] ^= word[s[i+R]];
			word[s[i+R]] ^= word[s[i]];
			word[s[i]] ^= word[s[i+R]];
		}
		sort(s.begin(), s.end());
		s.erase(unique(s.begin(), s.end()), s.end());
		s.push_back(N);
		for (int i = 0, R = s.size() - 1; i < R; i++){
			ull tmp = fact[N - s[i] - 1], tmp2 = 0;
			tmp *= word[s[i]];
			tmp = tmp % MOD;
			for (int j = i; j < R; j++){
				word[s[j]] -= (word[s[j]] > word[s[i]] ? 1 : 0);
				if (s[j] + 1 != s[j + 1]){
					word[s[j] + 1] -= (word[s[j] + 1] > word[s[i]] ? 1 : 0);
				}
			}
			for (int j = s[i] + 1; j < s[i + 1]; j++){
				tmp2 += fact[N - j - 1];
				tmp2 = tmp2 % MOD;
			}
			for (int j = i + 1; j < R; j++){
				word[s[j]] -= (word[s[j]] > word[s[i] + 1] ? s[i+1] - s[i] - 1 : 0);
				if (s[j] + 1 != s[j + 1]){
					word[s[j] + 1] -= (word[s[j] + 1] > word[s[i] + 1] ? s[i+1] - s[i] - 1 : 0);
				}
			}
			tmp2 *= word[s[i] + 1];
			tmp += tmp2;
			tmp += *(ans.end() - 1);
			*(ans.end() - 1) = tmp % MOD;
		}
	}
	for (int i = 0, l = ans.size(); i < l; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

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


int main()
{
	int N;
	cin>>N;
	cout<<N*(N+1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
int dp[1 << 26];
int main() {
	string s;
	cin >> s;
	int bit = 0, opt;
	fill(dp, dp + (1 << 26), INF);
	dp[0] = 0;
	rep(i, s.size()) {
		bit ^= (1 << (s[i] - 'a'));
		opt = INF;
		rep(j, 26) {
			opt = min(opt, dp[bit ^ (1 << j)] + 1);
		}
		if (bit == 0) opt = 1;
		dp[bit] = min(dp[bit], opt);
	}
	cout << opt << endl;
}

Measured memory_bytes: 262788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using namespace std;


int N, T;
int t[200010];
int td[200010];


void makeTD(){
	rep(i, 0, N-1) td[i] = t[i+1]-t[i];
	td[N-1] = INF;
}


llint solve(){
	llint X = 0;
	rep(i, 0, N){
		if(T <= td[i]) X += T;
		else X += td[i];
	}
	return X;
}


signed main(){
	cin >> N >> T;
	rep(i, 0, N) cin >> t[i];

	makeTD();

	cout << solve() << endl;

	return 0;
}

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

int main()
{
    long long H;
    cin >> H;

    int count = 0;
    while (true)
    {
        if (H == 1)
        {
            break;
        }
        H /= 2;
        count++;
    }

    long long ans = pow(2, count + 1) - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

ll dp[601][601];

void chmin(ll&a, ll b) {
	a = min(a, b);
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> H(N + 2, 0);
	for (int i = 1;i <= N;i++) {
		cin >> H[i];
	}

	ll a, b, c, d;

	for (int i = 0;i <= N + 1;i++)
		for (int j = 0;j <= K;j++)
			dp[i][j] = LLONG_MAX / 3;

	dp[0][0] = 0;

	for (int i = 0;i <= N + 1;i++) {
		for (int k = 0;k <= K;k++) {
			for (int j = i + 1;j <= N + 1;j++) {
				a = H[i];
				b = H[j];
				c = min(a, b);
				d = b * 2;
				chmin(dp[j][k + j - i - 1], dp[i][k] + d - c * 2);
			}
		}
	}
	a = LLONG_MAX;
	for (int i = 0;i <= K;i++) {
		chmin(a, dp[N + 1][i]);
	}
	cout << a / 2 << endl;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}

inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
   // freopen("input.txt","r",stdin);

    FastIO;
    int n;
    while(cin>>n){
        lli a[n+1];
        for(int i=1; i<=n; i++) cin>>a[i];
        lli ans = 0;
        for(int i=0; i<=60; i++){
            lli cnt = 0;
            for(int j=n; j ; j--){
                if(a[j] & (1LL<<i)){
                    ans = addmod(ans , mulmod(cnt,(1LL<<i)%mod));
                }
                else cnt++;
            }
            cnt = 0;
            for(int j=1; j<=n ; j++){
                if(a[j] & (1LL<<i)){
                    ans = addmod(ans , mulmod(cnt,(1LL<<i)%mod));
                }
                else cnt++;
            }
        }
        cout<<ans<<endl;
    }

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});
//

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,sum;
    cin>>n;
    int a[n],b[n],c[n];
    for(i=1; i<=n; i++)
        cin>>a[i];
    for(i=1; i<=n; i++)
        cin>>b[i];
    for(i=1; i<n; i++)
        cin>>c[i];
    sum=b[a[1]];
    for(i=2; i<=n; i++)
    {
        if(a[i]>a[i-1] && (a[i]-a[i-1])==1)

            sum+=b[a[i]]+c[a[i-1]];
             else
                 sum+=b[a[i]];
    }
    cout<<sum<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a[101]={};
    int i,n,mode=0;
    
    while(scanf("%d",&n) != EOF){
        for(i=1;i<=100;i++){
            if(i==n) a[i]++;
            if(mode<a[i]) mode=a[i];
        }
    }
    
    for(i=1;i<=101;i++){
        if(mode==a[i]) printf("%d\n",i);
    }

    return 0;
}

Measured memory_bytes: 596
/*input
6
*/
#include<bits/stdc++.h>
using namespace std;
const int N=55600;
#define int long long
#define pii pair<int, int>
#define f first
#define s second
inline pii mp(int a, int b)
{
	pii temp;temp.f=a;temp.s=b;return temp;
}
int read_int(){
	char r;
	bool start=false,neg=false;
	int ret=0;
	while(true){
		r=getchar();
		if((r-'0'<0 || r-'0'>9) && r!='-' && !start){
			continue;
		}
		if((r-'0'<0 || r-'0'>9) && r!='-' && start){
			break;
		}
		if(start)ret*=10;
		start=true;
		if(r=='-')neg=true;
		else ret+=r-'0';
	}
	if(!neg)
		return ret;
	else
		return -ret;
}
bool check(int i)
{
	i--;if(i%6==0) return true;i+=2;if(i%6==0) return true;return false;
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	vector<bool> isp(N, true);
	vector<int> primes;
	for(int i=2;i<N;i++)
	{
		if(isp[i])
		{
			if(i%5==1) primes.push_back(i);
			for(int j=i*i;j<N;j+=i) isp[j]=0;
		}
	}
	int n;cin>>n;
	for(int i=0;i<n;i++) cout<<primes[i]<<" ";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Including Policy Based DS
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define ULL unsigned long long
LL INF=10000000000000001LL;
#define PI (2.0*acos(0.0))

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

//typedef tree<
//int,
//null_type,
//less<int>,
//rb_tree_tag,
//tree_order_statistics_node_update>
//ordered_set;

#define READ 		freopen("in.txt","r",stdin)
#define WRITE  		freopen("out.txt","w",stdout)
#define BOOST		ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sf 			scanf
#define pf 			printf
#define F  			first
#define S  			second
#define pb 			push_back
#define NL			pf("\n")
#define ALL(v)		v.begin(),v.end()
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define mem(x,y) 	memset(x,y,sizeof x )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(int i=0;i<n;i++)
#define cnd			tree[idx]
#define lc			tree[idx*2]
#define rc			tree[idx*2+1]
#define lnd 		(2*idx),(b),((b+e)/2)
#define rnd 		((2*idx)+1),(((b+e)/2)+1),(e)

// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

bool Check(int N,int pos){return (bool)(N & (1<<pos));} // check bit
int Set(int N,int pos){	return N=N | (1<<pos);}// set bit

const LL mod=1000000007LL;
LL modMul(LL a, LL b){

    LL ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}

LL powerMod(LL a,LL b){
	if(b==0)return 1%mod;
	LL x=powerMod(a,b/2);
	x = (x%mod*x%mod)%mod;
	if(b%2==1)x = (x%mod*a%mod)%mod;
	return x%mod;
}

LL lcm( LL a,LL b ){
	LL g = __gcd(a,b);
	return (a*b)/g;
}
const int mx = 100095;
//-------------------------------------------------------------------------------

LL C[mx][3];
LL dp[mx][3];
int n;
LL f(int pos,int color){

    if(pos==n)return 0;
    if(dp[pos][color]!=-1)return dp[pos][color];

    LL x = 0;
    FOR(i,3){
		if(i==color)continue;
		x = max(x,C[pos][i]+f(pos+1,i));
    }
    return dp[pos][color] = x;

}


int main(){
//  READ;
//  WRITE;
//	BOOST;

    LL t,l,x,k,m;

    cin>>n;
    FOR(i,n)cin>>C[i][0]>>C[i][1]>>C[i][2];

	mem(dp,-1);
    x = 0;
    FOR(i,3)x = max(x,f(0,i));
    cout<<x<<endl;

    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int d[3][3];

int main(){
    int a[3][3];
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(k, n) {
        int b;
        cin >> b;
        rep(i, 3) rep(j, 3) {
            if (a[i][j] == b) d[i][j] = 1;
        }
    }
    bool ans = false;
    rep(i, 3) {
        int appear = 0;
        rep(j, 3) if(d[i][j]) appear++;
        if (appear == 3) ans = true;
    }
    rep(j, 3) {
        int appear = 0;
        rep(i, 3) if(d[i][j]) appear++;
        if (appear == 3) ans = true;
    }
    {
        int appear = 0;
        rep(j, 3) if(d[j][j]) appear++;
        if (appear == 3) ans = true;
    }
    {
        int appear = 0;
        rep(j, 3) if(d[j][2-j]) appear++;
        if (appear == 3) ans = true;
    }
    puts(ans ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



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


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        int ans = S.Length;
        for (int i = 0; i < S.Length - 1; i++)
        {
            if(S[i] != S[i + 1])
            {
                ans = Math.Min(ans, Math.Max(i + 1, S.Length - i - 1));
            }
        }
        Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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


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

int main()
{
    int n, ans = 0;
    cin >> n;
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        count = 0;
        int j = i;
        while (j >= 1)
        {
            j = j / 10;
            count++;
        }
        if (count % 2 == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
    int h,w,n;
    cin>>h>>w>>n;
    int painted=0;
    int cnt=0;
    while(painted<n){
        if(h>w){
            painted+=h;
            w--;
        }else{
            painted+=w;
            h--;
        }
        cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <set>
#include <iostream>
#include <cstdlib>
#include <queue>
#include <complex>
#include <algorithm>

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

using namespace std;

typedef complex<double> P;

const double EPS = 1e-4;
double dp[20][20][10000 + 10];
bool cango[20][20][20];
double dist[20][20];

inline bool ok(const P &p1, const P &p2, const P &p3, const double rad){
  P s1 = p2 - p1;
  P s2 = p3 - p2;
  return std::abs(arg(s2 / s1)) < rad + EPS;
}

int main(){
  int n;
  double r, theta;
  double rad;

  cin >> n >> r >> theta;
  rad = M_PI * theta / 180.0;

  vector<P> p(n);
  REP(i,n) cin >> p[i].real() >> p[i].imag();

  int ans   = 0;
  int limit = (int)(r + 3.0);
  const double bad = r + 10;

  REP(i,n) REP(j,n) REP(k,n){
    if(i != j && j != k && i != k && ok(p[i], p[j], p[k], rad))
      cango[i][j][k] = true;
  }
  REP(i,n) REP(j,n) dist[i][j] = abs(p[i] - p[j]);
  REP(i,n) REP(j,n) REP(k,limit)
    dp[i][j][k] = bad;

  REP(i,n) if(i != 0) dp[0][i][1] = dist[0][i];

  REP(k, limit) REP(i,n) REP(j,n) if(i != j && dp[i][j][k] != bad){
    if(dp[i][j][k] < r + EPS) ans = k;
    REP(l,n) if(i != l && j != l && cango[i][j][l])
      dp[j][l][k + 1] = min(dp[j][l][k + 1], dp[i][j][k] + dist[j][l]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 0
from collections import deque

def bfs():
    q = deque()
    q.append(1)
    dist[1] = 0
    while q:
        i = q.popleft()
        for g in G[i]:
            j, x = g[0], g[1]
            if dist[j] == -1:
                dist[j] = dist[i] + 1
                q.append(j)
                euse[x] = 1
                T[i].append([j, x])
                T[j].append([i, x])
                parent[j] = i
                v.append(j)
    return

n, m = map(int, input().split())
G = [[] for _ in range(n + 1)]
E = []
for i in range(m):
    a, b = map(int, input().split())
    G[a].append([b, i])
    G[b].append([a, i])
    E.append([a, b])
if m % 2 == 1:
    print(-1)
    exit()
T = [[] for _ in range(n + 1)]
euse = [0] * m
dist = [-1] * (n + 1)
parent = [0] * (n + 1)
v = deque()
bfs()
start = [0] * (n + 1)
for i in range(m):
    if not euse[i]:
        print(E[i][0], E[i][1])
        start[E[i][0]] += 1
while v:
    i = v.pop()
    for t in T[i]:
        if parent[i] == t[0]:
            j, x = t[0], t[1]
            break
    if start[i] % 2 == 0:
        start[j] += 1
        print(j, i)
    else:
        start[i] += 1
        print(i, j)

Measured memory_bytes: 147212
juwel_num = int(input())
juwel_value = list(map(int, input().split()))
juwel_cost = list(map(int, input().split()))

total_value = 0

for i in range(juwel_num):
    value_score = juwel_value[i] - juwel_cost[i]
    if value_score > 0:
        total_value += value_score

print(total_value)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{

    static void print(String[] s){
        for(int i = 0; i < s.length - 1; i++){
            System.out.print(s[i] + " ");
        }
        System.out.println(s[s.length - 1]);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());

        String[] a = new String[n];
        String[] b = new String[n];
        for(int i = 0; i < n; i++){
            String s = sc.next();
            a[i] = s;
            b[i] = s;
        }

        //bubblesort
        for(int i = 0; i < n; i++){
            for(int j = n - 1; j >= i + 1; j--){
                if(a[j].charAt(1) < a[j - 1].charAt(1)){
                    String tmp = a[j];
                    a[j] = a[j - 1];
                    a[j - 1] = tmp;
                }
            }
        }

        //selectionsort
        for(int i = 0; i < n; i++){
            int minj = i;
            for(int j = i + 1; j < n; j++){
                if(b[j].charAt(1) < b[minj].charAt(1))
                    minj = j;
            }
            String tmp = b[minj];
            b[minj] = b[i];
            b[i] = tmp;
        }

        print(a);
        System.out.println("Stable");

        print(b);
        boolean isStable = true;
        for(int i = 0; i < n; i++){
            if(!a[i].equals(b[i]))
                isStable = false;
        }

        if(isStable){
            System.out.println("Stable");
        }else{
            System.out.println("Not stable");
        }
    }
}




Measured memory_bytes: 26168
// AOJ 2621: Fox Observation
// 2017.11.26 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define HASHSIZ 999983
typedef struct { long long n; int w; } HASH;
HASH hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int ans;

void insert(int x, int y, int w)
{
	long long xy = ((long long)x << 32) + y;
	HASH *p = hash + xy % HASHSIZ;
	while (p->n) {
		if (p->n == xy) goto next;
		if (++p == hashend) p = hash;
	}
	p->n = xy;
next:
	w += p->w;
	p->w = w;
	if (w > ans) ans = w;
}

#define BASE 1000000000		// 10^9

char buf[35], *p;
int getint(void)
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, x, y, w;

	fgets(p=buf, 10, stdin);
	n = getint();
	ans = 0;
	while (n--) {
		fgets(p=buf, 35, stdin);
		x = BASE + getint(), p++, y = BASE + getint(), p++, w = getint();
		insert(x  , y  , w);
		insert(x+1, y  , w);
		insert(x  , y+1, w);
		insert(x+1, y+1, w);
	}
	printf("%d / 1\n", ans);
	return 0;
}

Measured memory_bytes: 17476