akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')
import sys
import itertools
import copy


def main():
    x = I()
    if x >= 30:
        print('Yes')
    else:
        print('No')
    # print(row)
    # total = sum(row)
    # target = total - K
    # if K == total:
    #     print(1)
    #     sys.exit()
    # col = []
    # for w in range(W):
    #     cnt = 0
    #     for h in range(H):    
    #         print(A[h][w])
    #         if A[h][w] == '#':
    #             cnt += 1
    #     col.append(cnt)
    # print(col)
    # ans = 0
    # for w in range(W):
    #     for h in range(H):
    #         if A[h][w] == '#':
    #             if col[w] + row[h] - 1 == target:
    #                 print(str(h) + str(w))
    #                 ans +=1
    #         else:
    #             if col[w] + row[h] == target:
    #                 print(str(h) + str(w))
    #                 ans +=1
    # print(ans)
    #     for  in x:


    # print('AC x ' + str(cnt['AC']))
    # print('WA x ' + str(cnt['WA']))
    # print('TLE x ' + str(cnt['TLE']))
    # print('RE x ' + str(cnt['RE']))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 10804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length() <= k){
        cout << s << endl;
    }
    else{
        s = s.substr(0,k);
        s += "...";
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long int ll;
using namespace std;
queue<ll> q;
int main(){
	io;
	ll k;
	cin >> k;
	for(ll i = 1;i < 10;++i){
		q.push(i);
	} 
	ll num,ys;
	for(ll i = 0;i < k;++i){
		num = q.front();
		q.pop();
		ys = num%10;
		if(ys != 0){
			q.push(num*10 + ys - 1);
		}
		q.push(num*10+ys);
		if(ys != 9){
			q.push(num*10 + ys + 1);
		}
	}
	cout << num;
	return 0;
} 

Measured memory_bytes: 1792
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.ArrayDeque;
import java.awt.Point;
 
class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        for(int i=1; i<=5; i++) {
            if(sc.nextInt()==0) {
                System.out.println(i);
            }
        }
    } 
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll mod = 1;
    ll n;
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    string ans = "";
    while (n != 0) {
        ll nxt = mod * (-2);
        ll hoge = (n % nxt != 0);
        ans += to_string(hoge);
        n -= hoge * mod;
        mod = nxt;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int main()
{
	long long n, m;
	scanf("%lld%lld", &n, &m);
	long long a = (2 * n + m) / 4;
	long long b = m / 2;
	printf("%lld\n", std::min(a, b));
	return 0;
}


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

int N;
vector<pair<int,int>> edgelist;
vector<vector<int>> adjlist;
unordered_map<int, int> color;
int K;

int edgehash(int u, int v) { return u + v*N; }

void dfs(int v, int cp){
  auto adjv = adjlist[v];
  int c = cp==1 ? 2 : 1;
  for(auto to : adjv) {
    color[edgehash(v,to)]=c;
    dfs(to, c);
    K = max(K, c);
    c++;
    if(c==cp) c++;
  }
}

signed main() {
  cin >> N;
  adjlist.resize(N);

  for(int i=0; i<N-1; i++) {
    int v,u;
    cin >> v >> u;
    v--;
    u--;
    auto e = make_pair(min(u,v), max(u,v));
    edgelist.push_back(e);
    adjlist[e.first].push_back(e.second);
  }

  K=1;
  dfs(0, 0);

  cout << K << endl;
  for(auto e : edgelist) cout << color[edgehash(e.first,e.second)] << endl;

  return 0;
}


Measured memory_bytes: 14068
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>


#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

const int MAX_V = 31;
const int MAX_DIR=5;
const int INF = 1<<28;



int h,w;
int c[4]={0};

struct state{
	int x,y,dir,cost;
	state(int t_x,int t_y,int t_dir,int t_cost){
		x=t_x;y=t_y;dir=t_dir,cost=t_cost;
	}
	bool operator>(const state& s) const {
		return cost > s.cost;
	}
};

int d[MAX_V][MAX_V][MAX_DIR];


int dx[] ={1,0,-1,0};
int dy[] ={0,1,0,-1};

void dijkstra(vector<vector<int> > G){
	priority_queue<state,vector<state>,greater<state> > que;
	fill_n((int *)d, sizeof(d)/sizeof(int),-1);
	que.push(state(0,0,0,0));

	while(!que.empty()){
		state p = que.top(); que.pop();
		if(d[p.y][p.x][p.dir]!=-1&&d[p.y][p.x][p.dir]<=p.cost) continue;
		else d[p.y][p.x][p.dir] = p.cost;	

		if(p.x==w-1 && p.y==h-1){
			cout << p.cost << endl;
			return;
		}

		rep(i,4){
			int x=p.x+dx[p.dir];
			int y=p.y+dy[p.dir];
			if(x<w&&y<h&&x>=0&&y>=0){
				if(G[p.y][p.x]==i) que.push(state(x,y,p.dir,p.cost));
				else que.push(state(x,y,p.dir,p.cost+c[i]));
			}
			p.dir=(p.dir+1)%4;
		}
	}
}


int main(){

	while(1){
		cin >> w >> h;
		if(w==0&&h==0) break;
		vector<vector<int> > G(h,vector<int>(w));

		rep(i,h) rep(j,w) cin >> G[i][j];
		rep(i,4) cin >> c[i];

		dijkstra(G);
	}
	return 0;
}

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

int main ()
{
    int n , a, b, c=0;

    cin >> n >> a >> b ;

    for (int i=a; i<=b; i++){
        if (i%n==0) c++;
    }
    if (c>0) cout << "OK\n" ;
    else cout << "NG\n" ;

}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	string O, E;
	cin >> O >> E;
	int N = O.size() + E.size();
	REP(i, N) {
		if (i % 2 == 0) cout << O[i / 2];
		else cout << E[i / 2];
	}
	cout << "\n";

	return 0;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	int n;
	cin>>n;
	int a,b,c;
	cin>>a>>b>>c;
	ll dp[2][3];
	dp[1][0]=a;dp[1][1]=b;dp[1][2]=c;
	int i=1;
	fr(j,1,n){
		cin>>a>>b>>c;
		i^=1;
		dp[i][0]=max(dp[(i^1)][1],dp[(i^1)][2])+a;
		dp[i][1]=max(dp[(i^1)][2],dp[(i^1)][0])+b;
		dp[i][2]=max(dp[(i^1)][1],dp[(i^1)][0])+c;
	}
	ll ans=0;
	ans=max(dp[i][0],dp[i][1]);
	ans=max(ans,dp[i][2]);
	cout<<ans<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

const long long int inf = 1e9;

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<vector<long long int> > dp(M+1, vector<long long int>((1<<N), inf));
    dp[0][0]=0;
    vector<long long int> cost(M+1, 0);
    vector<long long int> tre_num(M+1);
    for(int m=1; m<M+1; m++) {
        int treNUM;
        cin >> cost[m] >> treNUM;
        long long int S_num=0;
        for(int t=0; t<treNUM; t++) {
            int tnum;
            cin >> tnum;
            S_num += 1<<(tnum-1);
        }
        tre_num[m] = S_num;
    }
    
    for(int m=1; m<M+1; m++) {
        for(int n=0; n<(1<<N); n++) {
            if(dp[m-1][n]!=inf) {
                dp[m][n] = min(dp[m][n], dp[m-1][n]);
            }
            if((tre_num[m]&n)!=tre_num[m]) {
                dp[m][n|tre_num[m]] = min(dp[m][n|tre_num[m]], dp[m-1][n]+cost[m]);
            }
            // cout << dp[m][n] << " ";
        }
        // cout << endl;
    }
    
    if(dp[M][(1<<N)-1]==inf) {
        cout << -1 << endl;
    } else {
        cout << dp[M][(1<<N)-1] << endl;
    }

    return 0;
    
}

Measured memory_bytes: 32384
Option Strict On
Imports System.Collections.Generic
Public Class Main
    Public Shared Sub Main(ByVal args() As String)
        Dim H, N As Integer
        Dim arr(2) As String
        arr = Split(Console.ReadLine())
        H = Integer.Parse(arr(0)) : N = Integer.Parse(arr(1))
        Dim A As New List(Of Integer)(Array.ConvertAll(Of String, Integer) _
            (Split(Console.ReadLine()), AddressOf Integer.Parse))
        Dim accum As Integer = 0
        For Each Ai As Integer In A
            accum += Ai
        Next
        Console.WriteLine(If(accum < H, "No", "Yes"))
    End Sub
End Class


Measured memory_bytes: 28768
object Main extends App {
  import scala.io.StdIn._

  val prevs = Array.tabulate(10){_ ⇒ 0}
  val position = Array.tabulate(10){_ ⇒ 0}
  solve
  def solve: Unit = {
    val n = readInt
    if (n == 0) return
    val nodes = Array.tabulate(n){_ ⇒ readLine.trim.split(' ').map(_.toInt)}
    for (i ← 0 until n; j ← 0 until n if i != j) nodes(i)(j) = math.max(nodes(i)(j), nodes(j)(i))
    var min = Int.MaxValue
    sub(n - 1, 0)
    println(min)
    solve
    def sub(next: Int, flag: Int): Unit= {
      if (next < 0) {
        if (position.head < min)
          min = position.head
      }else{
        for (i ← 0 until n if ((1 << i) & flag) == 0){
          prevs(next) = i
          position(next) = 0
          for (j ← next + 1 until n) {
            if (position(next) < nodes(prevs(j))(i) + position(j)) {
              position(next) = nodes(prevs(j))(i) + position(j)
            }
          }
          if (position(next) < min) sub(next - 1, flag | (1 << i))
        }
      }
    }
  }
}



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

int main(void){

	while(1){
		int n, k, m;
		cin >> n >> k >> m;
		if ( n == 0 && k == 0 && m == 0 ) break;

		int ans = 0;
		for(int i = 1; i < n; i++) {
			ans = ( ans + k ) % ( i );
		}
		ans = ( ans + m ) % n + 1 ;
		cout << ans << endl;
 	}

    return 0;
}

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

int main(void){
  int n;

  cin >> n;

  int a[n];

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

  for ( int i = n; i > 0; i-- ){
    if ( i == n ){
      cout << a[i-1];
    }else{
      cout << " " << a[i-1];
    }
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 3076
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll x,y,a,b,c,n,m,i,j,k;
     cin>>x>>y>>a>>b>>c;
     vector<ll> p(a),q(b),r(c);
     for(i=0;i<a;i++) cin>>p[i];
     for(i=0;i<b;i++) cin>>q[i];
     for(i=0;i<c;i++) cin>>r[i];
     sort(all(p),greater<ll>() );
     sort(all(q),greater<ll>() );
     sort(all(r),greater<ll>() );
     vector<ll> v;
     for(i=0;i<x;i++) v.pb(p[i]);
     for(i=0;i<y;i++) v.pb(q[i]);
     for(i=0;i<min(x+y,c);i++) v.pb(r[i]);
     sort(all(v),greater<ll>() );
   ll ans=0;
     for(i=0;i<(x+y);i++) ans+=v[i];
      cout<<ans;
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
const int INF=1000010000;
int main() {
  int n,k;cin >> n >> k;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  vector<bool> dp(k+1,false);
  for(int i=0; i<k; i++){
    for(int j=0; j<n; j++){
      if(!dp[i]){
        if(i+a[j]<=k) dp[i+a[j]]=true;
      }
    }
  }
  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}

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

using namespace std;
typedef pair<int,int> ii;
map<ii,int> mp;
set<ii> s;
int dx[] = {0,0,0,-1,-1,-1,-2,-2,-2};
int dy[] = {0,-1,-2,0,-1,-2,0,-1,-2};
int ans[10];

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

    int n,m,q;
    cin>>n>>m>>q;

    while(q--)
    {
        int x,y;
        cin>>x>>y;

        for(int i=0;i<9;i++)
        {
            if(x+dx[i]<1||x+dx[i]>n-2)
                continue;
            if(y+dy[i]<1||y+dy[i]>m-2)
                continue;
            mp[ii(x+dx[i],y+dy[i])] ++;
            s.insert(ii(x+dx[i],y+dy[i]));
        }
    }

    long long res = (n-2)*(m-2);
    for(auto it:s)
    {
        int x = it.first;
        int y = it.second;
        //cout<<x<<" "<<y<<" = "<<mp[ii(x,y)]<<'\n';

        ans[mp[ii(x,y)]]++;
        res --;
    }

    ans[0] = res;
    for(int i=0;i<=9;i++)
        cout<<ans[i]<<'\n';
}


Measured memory_bytes: 112768
#include<stdio.h>
int main(){
  int n,m,a;
  double s,p,sp,max=0,e=0.0000001;
  scanf("%d",&n);
  while(n--){
    scanf("%*d %d",&m);
    for(s=sp=0;m--;s+=a*p){
      scanf("%d %lf",&a,&p);
      sp+=p;
    }
    if(max+e<s/sp)max=s/sp;
  }
  scanf("%*d %d",&m);
  for(s=sp=0;m--;s+=a*p){
    scanf("%d %lf",&a,&p);
    sp+=p;
  }//printf("%f %f\n",s/sp,max);
  printf("%s\n",s/sp+e<max?"YES":"NO");
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
    LL n, ma = 0, mi = 1000000000000;
    cin >> n;
    vector<LL> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        mi = min(mi, a[i]);
        ma = max(ma, a[i]);
    }

    cout << abs(mi - ma) << endl;


    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m, l = [ int(v) for v in input().split() ]
distance_list = [ [ 10**15 for i in range(n) ] for j in range(n) ]


for i in range(m): 
    a, b, d = [ int(v) for v in input().split() ]
    a, b = a-1, b-1
    if d <= l:
        distance_list[a][b] = d
        distance_list[b][a] = d

for k in range(n):
    for i in range(n):
        for j in range(n):
            if distance_list[i][j] > distance_list[i][k] + distance_list[k][j]:
                distance_list[i][j] = distance_list[i][k] + distance_list[k][j]


distance_list_2 = [ [ 1 if distance_list[i][j] <= l else 10**4 for i in range(n) ] for j in range(n) ]



for k in range(n):
    for i in range(n):
        for j in range(n):
            if distance_list_２[i][j] > distance_list_２[i][k] + distance_list_２[k][j]:
                distance_list_２[i][j] = distance_list_２[i][k] + distance_list_２[k][j]

q = int(input())
for i in range(q):
    s, t = [ int(v) for v in input().split() ]
    ans = distance_list_２[s-1][t-1]
    if ans == 10000:
        print(-1)
    else:
        print(distance_list_２[s-1][t-1]-1)

Measured memory_bytes: 58460
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  int K,S;
  cin >> K >> S;
  int t = 0;
  for(int i = 0; i <= K; i++) {
    for(int j = 0; j <= K; j++) {
      int tmp = S - i - j;
      if(tmp > K) continue;
      if(tmp < 0) continue;
      t++;
    }
  }
  cout << t << endl;

}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
alice = [1 if a <= i < b else 0 for i in range(0, 101)]
bob = [1 if c <= i < d else 0 for i in range(0, 101)]
print(len(['' for i in range(0, 101) if alice[i] == bob[i] == 1]))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int n, m, a, b, c;

int main(int argc, char *argv[]){
    cin >> n >> m;
    vec A(n);
    vec B(m);
    vec C(m);
    vector<pair<int, int>> BC(m);
    rep(i, n) cin >> A[i];
    sort(all(A));
    rep(i, m){
        cin >> b >> c;
        BC[i] = make_pair(c, b);
    }
    sort(all(BC), greater<pair<int, int>>());
    int p = 0;
    int q;
    rep(i, m){
        q = BC[i].first;
        if(A[p] < q){
        rep(j, BC[i].second){
            if(A[p] < q){
                A[p] = q;
                p++;
            }else{
                break;
            }
        }
        }else{
            break;
        }
    }
    ll res = 0;
    rep(i, n) res += A[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2176
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
def diff(t,high,flag):
    temp = t - high * 0.006
    d = abs(flag - temp)
    return d
min_d = diff(t,h[0],a)
ans = 1
for i in range(n):
    if min_d > diff(t,h[i],a):
        min_d = diff(t,h[i],a)
        ans = i+1
print(ans)

Measured memory_bytes: 3064
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

string s;

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

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    ll n=s.size();
    for(ll i=0; i<n; i++){
        if(s[i]==',') cout << " ";
        else cout << s[i];
    }
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef long double ld;
const ll mod = 998244353;//1e9+7

void solve() {
  int n,k;  cin>>n>>k;
  vector<int> a(n);
  rep(i,n)  cin>>a[i];
  while(k--) {
    vector<int> b(n+1,0);
    rep(i,n) {
      int from = max(0,i-a[i]);
      int to = min(n-1,i+a[i]);
      b[from]++;
      b[to+1]--;
    }
    bool changed = false;
    rep(i,n) {
      changed |= (a[i]!=b[i]);
      a[i] = b[i];
      b[i+1] += b[i];
    }
    if(!changed)  break;
  }
  rep(i,n)  cout<<a[i]<<' ';
  cout<<'\n';
}


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  #endif
  ll t = 1;
//  cin>>t;
  rep(i,t)  {
    solve();
  //  cout<<'\n';
  }
  return 0;
}


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

int main() {
  int d,t,s;
  cin>>d>>t>>s;
  if(t*s>=d){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 3632
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N = int(input())
    A = read_list()

    S = [A[0] + A[i] - i for i in range(1, N)]
    D = {}
    for s in S:
        D[s] = D.setdefault(s, 0) + 1

    res = 0
    t = 0
    for i in range(N - 1):
        res += D.setdefault(t, 0)
        D[S[i]] -= 1
        t -= A[i + 1] - A[i] + 1
    
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63816
A = input()

honlist = [2,4,5,7,9]
ponlist = [0,1,6,8]
bonlist = [3]

if int(A[-1]) in honlist:
    print("hon")
if int(A[-1]) in ponlist:
    print("pon")
if int(A[-1]) in bonlist:
    print("bon")  


Measured memory_bytes: 9192
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[600][600];

int main(){
  cin >> n >> m >> l;
  if(n % 2 == 0 || m % 2 == 0 || l % 2 == 0)puts("0");
  else print(min(n * l,min(n * m,m * l)));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <array>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cassert>
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define repeat(i,n) repeat_from(i,0,n)
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= (m); --(i))
#define repeat_reverse(i,n) repeat_from_reverse(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
typedef long long ll;
using namespace std;
vector<int> primes(int n) {
    vector<bool> is_prime(n+1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i * i <= n; ++ i) {
        if (is_prime[i]) {
            for (int j = 2*i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    vector<int> result;
    for (int i = 0; i <= n; ++ i) {
        if (is_prime[i]) {
            result.push_back(i);
        }
    }
    return result;
}
constexpr int max_n = 1120;
constexpr int max_k = 14;
int main() {
    vector<int> ps = primes(max_n);
    array<array<ll,max_k+1>,max_n+1> dp = {};
    dp[0][0] = 1;
    for (int p : ps) {
        repeat_reverse (k, max_k+1) {
            repeat (n, max_n+1) {
                if (n-p >= 0 and k-1 >= 0) {
                    dp[n][k] += dp[n-p][k-1];
                }
            }
        }
    }
    while (true) {
        int n, k; cin >> n >> k;
        if (n == 0 and k == 0) break;
        cout << dp[n][k] << endl;
    }
    return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

ll n, m;
vector<string> board;

bool in_board(ll x, ll y){
    return x >= 0 && x < n && y >= 0 && y < m && board[x][y] != '#';
}

int main(void) {
    cin >> n >> m;
    board.resize(n);
    rep(i, n) cin >> board[i];

    const ll sz = n * m + 2;
    const ll s = sz - 2, g = sz - 1;
    const int bias = 1000;
    mcf_graph<int, ll> mf(sz);
    ll sum = 0;
    rep(i, n) rep(j, m){
        if (board[i][j] == 'o'){
            mf.add_edge(s, i * m + j, 1, 0);
            sum += bias - i - j;
        }
        if (board[i][j] != '#') mf.add_edge(i * m + j, g, 1, bias - i - j);
    }
    rep(i, n){
        rep(j, m){
            if(in_board(i, j) && in_board(i + 1, j))
                mf.add_edge(i * m + j, (i + 1) * m + j, INF, 0);
            if(in_board(i, j) && in_board(i, j + 1))
                mf.add_edge(i * m + j, i * m + j + 1, INF, 0);
        }
    }

    auto p = mf.flow(s, g);
    co(sum - p.second);

    return 0;
}


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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e11;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int A, B, T;
    cin >> A >> B >> T;
    
    cout << T / A * B << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
ans = 0
arr = ['3','5','7']
for repeat in range(3,11):
    ite = itertools.product(arr, repeat=repeat)
    for l in ite:
        if '3' in l and '5' in l and '7' in l:
            num = int(''.join(l))
            if num > N:
                break
            else:
                ans += 1
            
print(ans)




Measured memory_bytes: 3064
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-17 17:23
# @url:https://atcoder.jp/contests/abc059/tasks/arc072_a

import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n=int(input())
    a=list(map(int,input().split()))
    prefix=[a[0]]
    for i in range(1,len(a)):
        prefix.append(prefix[-1]+a[i])
    s,t=0,0
    ans1,ans2=0,0
    for i in range(len(prefix)):
        if i%2==0:
            if prefix[i]+s<=0:
                ans1+=abs(prefix[i]+s)+1
                s=s+abs(prefix[i]+s)+1
            if prefix[i]+t>=0:
                ans2+=abs(prefix[i]+t+1)
                t=t-abs(prefix[i]+t+1)
        else:
            if prefix[i]+s>=0:
                ans1+=abs(prefix[i]+s+1)
                s=s-abs(prefix[i]+s+1)
            if prefix[i]+t<=0:
                ans2+=abs(prefix[i]+t)+1
                t=t+abs(prefix[i]+t)+1
    print (min(ans1,ans2))
if __name__ == "__main__":
    main()

Measured memory_bytes: 96864
import sys

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


def main():
    A, B = map(int, readline().split())

    if A % 2 == 1 and B % 2 == 1:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61848
S = input()

a_to_z = "abcdefghijklmnopqrstuvwxyz"
ans = [0 for i in range(26)]
for i in range(26):
    if a_to_z[i] not in S:
        ans[i] = 1
    else:
        ans[i] = 0
        
if sum(ans[x] for x in range(26)) > 0:
    print(a_to_z[ans.index(1)])
else:
    print("None")

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

using namespace std;

const int64_t MOD = 1e9+7;
int64_t N;

vector<int64_t> F, G;


int64_t g(int);

int64_t f(int n) {
	if (n == 1)
		return N;
	if (n <= 0)
		return 1;
	if (F[n] != -1)
		return F[n];
	int64_t ways = f(n-1);
	ways += (N-1);
	ways %= MOD;
	if (n >= 2)
		ways += (N-1)*(N-2);
	ways %= MOD;
	ways += g(n-3);
	ways %= MOD;
	ways += abs(n-1-N);
	ways %= MOD;
	// for (int num = 2; num <= N; ++num) {
	// 	ways += f(n-1-num);
	// 	ways %= MOD;
	// }
	return F[n] = ways;
}

int64_t g(int n) {
	if (n < 0)
		return 0;
	if (G[n] != -1)
		return G[n];
	return G[n] = (f(n)+g(n-1))%MOD;
}


int main() {
	cin >> N;
	F.assign(N+1, -1);
	G = F;
	cout << f(N) << endl;
}

Measured memory_bytes: 62720
import java.util.*;

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

    public static void main(String[]$) {
        int n = scanner.nextInt();
        String s = scanner.next();
        int max = 0;
        for (int i = 1; i < n; i++) {
            String t1 = s.substring(0, i);
            String t2 = s.substring(i);
            int count = 0;
            for (char ch = 'a'; ch <= 'z'; ch++) {
                if (t1.indexOf(ch) != -1 && t2.indexOf(ch) != -1) {
                    count++;
                }
            }
            max = Math.max(max, count);
        }
        System.out.println(max);
    }
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //agc14b
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        int[] count = new int[n];
        for (int i = 0; i < m; i++) {
            int a = in.ni()-1, b = in.ni()-1;
            count[a]++;
            count[b]++;
        }
        boolean flag = true;
        for (int i = 0; i < n; i++) flag &= count[i]%2==0;
        out.println(flag?"YES":"NO");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 40660
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];

	map<int, int> mp_even, mp_odd;
	for (int i = 0; i < n; i++) {
		if (i & 1) mp_odd[v[i]]++;
		else mp_even[v[i]]++;
	}

	auto comp = [](auto &l, auto &r) {return l.second > r.second; };
	vector<pair<int, int>> top2_odd(2), top2_even(2);
	partial_sort_copy(mp_odd.rbegin(), mp_odd.rend(), top2_odd.begin(), top2_odd.end(), comp);
	partial_sort_copy(mp_even.rbegin(), mp_even.rend(), top2_even.begin(), top2_even.end(), comp);

	if (top2_odd[0].first != top2_even[0].first) cout << n - (top2_odd[0].second + top2_even[0].second) << "\n";
	else cout << n - max(top2_odd[0].second + top2_even[1].second, top2_odd[1].second + top2_even[0].second) << "\n";

	return 0;
}

Measured memory_bytes: 5376
x,n = map(int,input().split())
p = list(map(int,input().split()))
i = 0
if n == 0:
    print(x)
else:
    for i in range(101):
        if not x - i in p:
            print(x-i)
            break
        elif not x + i in p:
            print(x+i)
            break
        else:
            i += 1

Measured memory_bytes: 9188
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	S := readBytes()
	count := make([]int, 3)
	for i := range S {
		count[S[i]-'a']++
	}
	sort.Ints(count)
	if count[2]-1 <= count[1] && count[2]-1 <= count[0] {
		println("YES")
	} else {
		println("NO")
	}
}

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


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int a[26]; string w;
int main(){
    int n;
    cin >> n;
    int b[n];
    for (size_t i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    
    int counter = 0;
    for (size_t i = 0; i < n-2; i++)
    {
        if(b[i] < b[i+1] && b[i+1] < b[i+2] || b[i+2] < b[i+1] && b[i+1] < b[i]) counter ++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Node{
	int v;
	int w;
	char t;
	long long d;
	char s[50];
}a[100010];
bool cmp(Node x, Node y)
{
	if(x.v != y.v) return x.v < y.v;
	else if(x.w != y.w) return x.w < y.w;
	else if(x.t != y.t) return x.t < y.t;
	else if(x.d != y.d) return x.d < y.d;
	else return (strcmp(x.s, y.s) < 0);
}
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=0; i<n; i++) scanf("%d %d %c %lld %s",&a[i].v,&a[i].w,&a[i].t,&a[i].d,a[i].s);
	sort(a,a+n,cmp);
	for(i=0; i<n; i++) printf("%d %d %c %lld %s\n",a[i].v,a[i].w,a[i].t,a[i].d,a[i].s);
	return 0;
}


Measured memory_bytes: 11060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string st;
    cin>>st;
    int a=stoi(st.substr(0,2));
    int b=stoi(st.substr(2,2));
    int ans=0;
    if(1<=a&&a<=12){
        ans+=2;
    }
    if(1<=b&&b<=12){
        ans+=1;
    }
    if(ans==3){
        cout<<"AMBIGUOUS"<<endl;
    }else if(ans==2){
        cout<<"MMYY"<<endl;
    }else if(ans==1){
        cout<<"YYMM"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
    return 0;
}

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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define Max(a,b) a=max(a,b)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; cin>>n;
	n++;
	int l[n],r[n];
	l[0]=r[0]=0;
	f(i,1,n) cin>>l[i]>>r[i];
	sort(l,l+n,greater<int>());
	sort(r,r+n);	
	ll pl[n], pr[n];
	f(i,0,n) pl[i] = (i?pl[i-1]:0)+l[i];
	f(i,0,n) pr[i] = (i?pr[i-1]:0)+r[i];
	ll ans = 0;
	f(k,0,n/2)
		Max(ans,pl[k]-pr[k]);	
	cout << 2LL*ans << endl;



#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 2560
# coding: utf-8
import re
import math
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
 

 
#main
h=int(input())
ans=1
if h==1:print(1)
else:
    for a in range(1,10000):
        h=h//2
        ans+=pow(2,a)
        if h==1:
            break
    print(ans)

Measured memory_bytes: 66924
program mix_juice
  implicit none
  integer :: n, k, p(1000) = 0, i
  read(*,*) n, k
  read(*,*) p(1:n)
  call quick_sort(p(1:n))
  write(*,'(i0)') sum(p(1:k))
contains
  recursive subroutine quick_sort(a)
    integer, intent(inout) :: a(:)
    integer :: n, l, r, m
    integer :: p
    n = size(a, 1)
    l = 1
    r = n
    m = (n + 1) / 2
    p = a(l) + a(m) + a(r) - max(a(l), a(m), a(r)) - min(a(l), a(m), a(r))
    do
      do while (a(l) < p)
        l = l + 1
      end do
      do while (a(r) > p)
        r = r - 1
      end do
      if (l >= r) exit
      a(l) = xor(a(l), a(r))
      a(r) = xor(a(l), a(r))
      a(l) = xor(a(l), a(r))
      l = l + 1
      r = r - 1
    end do
    if (l - 1 > 1) call quick_sort(a(1:l - 1))
    if (n > r + 1) call quick_sort(a(r + 1:n))
  end
end program mix_juice

Measured memory_bytes: 2940