akhauriyash/Code-Regression huggingface dataset:
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

/* see https://github.com/pllk/cphb/ */
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;

typedef unsigned int uint;
typedef long long ll;
//typedef __int128 lll;

#define fori(n) for(ll i=0; i<(n); i++)

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int n, a, b;
    cin>>n>>a>>b;

    cout<<min(a*n, b)<<endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    ll n,m;
    cin>>n>>m;
    vector<int>a(n);
    map<ll,ll>fr;
    loop(i,0,n)
    {
        cin>>a[i];
        fr[a[i]]++;
    }

    loop(i,0,m)
    {
        ll b,c;
        cin>>b>>c;
        fr[c]+=b;
    }

    ll rem = n;
    ll ans = 0;
    for(auto it=fr.rbegin(); it != fr.rend(); it++ )
    {
        ll occ = it->S;
        ll val = it->F;
        if( occ <= rem )
        {
            ans += val*occ;
            rem -= occ;
        }
        else
        {
            ans += val*rem;
            break;
        }
    }
    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 13184
from collections import deque
n,m = map(int,input().split())
V = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    V[a].append(b)
    V[b].append(a)
    
reach = [0]*(n+1)
ans = 0
for i in range(1,n+1):
    if reach[i] != 0:
        pass
    else:
        q = deque([])
        q.append(i)
        reach[i] = 1
        j = 1
        while q:
            x = q.popleft()
            
            for y in V[x]:
                if reach[y] == 0:
                    reach[y] = 1
                    q.append(y)
                    j += 1
                    
            ans = max(ans, j)
            
print(ans)

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

int main(){
	int n,a[200],l;
	  cin >> n;
	  for (int i=0; i<n; i++){
		  cin >> a[i];
	  }
  bool bend =false;
  while (true){
  	for (int i=0; i<n; i++){
 	   if (a[i]%2 != 0) {
       	bend =true;
        break; 	
       }
    	else a[i] /= 2;
    }
    if (bend) break;
  l++;
  }
  cout << l <<endl;
}


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

const long long MOD = 998244353;

long long modpow(long long b, long long p) {
  if (p == 0) {
    return 1;
  }
  long long ans = modpow((b * b) % MOD, p / 2);
  if (p % 2 == 1) {
    ans = (ans * b) % MOD;
  }
  return ans;
}

long long inv(long long x) {
  return modpow(x, MOD - 2);
}

vector<long long> fact;

long long C(int n, int k) {
  return ((fact[n] * inv(fact[k])) % MOD * inv(fact[n - k])) % MOD;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  fact.resize(n + 1);
  fact[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * (long long) i) % MOD;
  }
  long long ans = 0;
  for (int i = 0; i <= k; i++) {
    long long tmp = ((long long) m * modpow(m - 1, n - i - 1)) % MOD;
    ans = (ans + tmp * C(n - 1, i)) % MOD;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4756
#include<stdio.h>
int main(){
  int d[10][10],x=0,i,j,k,w,h,t;
  scanf("%d%d",&h,&w);
  for(i=0;i<100;i++)scanf("%d",&d[i/10][i%10]);
  for(k=0;k<10;k++)for(i=0;i<10;i++)for(j=0;j<10;j++)d[i][j]=d[i][j]<d[i][k]+d[k][j]?d[i][j]:d[i][k]+d[k][j];
  for(i=0;i<h*w;i++){scanf("%d",&t);if(t+1)x+=d[t][1];}
  printf("%d",x);
}


Measured memory_bytes: 1712
#include<cstdio>

int turn(int x)
{
	return x=14;
}

int main()
{
	int A,B;
	scanf("%d %d",&A,&B);
	if(A==1) A=turn(1);
	if(B==1) B=turn(1);
	if(A>B) printf("Alice");
	else if(A<B) printf("Bob");
	else printf("Draw");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vvec<int> g(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vec<int> ans(N,0);
    vec<int> col(N,0);
    auto dfs = [&](auto&& self,int cur,int par,int c)->void{
        col[cur] = c;
        for(auto& e:g[cur]) if(e!=par){
            self(self,e,cur,-c);
        }
    };
    dfs(dfs,0,-1,1);
    map<int,int> cnt;
    for(int i=0;i<N;i++) cnt[col[i]]++;
    int micol = (cnt[-1]<cnt[1]? -1:1);
    if(cnt[micol]<=N/3){
        set<int> s0,s1;
        for(int i=1;i<=N;i++){
            if(i%3==0) s0.insert(i);
            else s1.insert(i);
        }
        for(int i=0;i<N;i++){
            if(col[i]==micol){
                ans[i] = *s0.begin();
                s0.erase(ans[i]);
            }else{
                ans[i] = *s1.begin();
                s1.erase(ans[i]);
            }
        }
        for(int i=0;i<N;i++) if(ans[i]==0){
            cerr << i << "\n";
            if(!s0.empty()){
                ans[i] = *s0.begin();
                s0.erase(ans[i]);
            }else if(!s1.empty()){
                ans[i] = *s1.begin();
                s1.erase(ans[i]);
            }
        }
    }else{
        vec<set<int>> s(3);
        for(int i=1;i<=N;i++) s[i%3].insert(i);
        for(int i=0;i<N;i++) if(col[i]==micol){
            if(!s[1].empty()){
                ans[i] = *s[1].begin();
                s[1].erase(ans[i]);
            }else if(!s[0].empty()){
                ans[i] = *s[0].begin();
                s[0].erase(ans[i]);
            }
        }
        for(int i=0;i<N;i++) if(col[i]!=micol){
            if(!s[2].empty()){
                ans[i] = *s[2].begin();
                s[2].erase(ans[i]);
            }else if(!s[0].empty()){
                ans[i] = *s[0].begin();
                s[0].erase(ans[i]);
            }
        }
        for(int i=0;i<N;i++) if(ans[i]==0){
            for(int k=0;k<3;k++) if(!s[k].empty()){
                ans[i] = *s[k].begin();
                s[k].erase(ans[i]);
                break;
            }
        }
    }
//    for(int i=0;i<N;i++) cerr << col[i] << (i!=N-1? " ":"\n");
    for(int i=0;i<N;i++){
//        assert(ans[i]>=1);
        cout << ans[i] << (i!=N-1? " ":"\n");
    }
}

Measured memory_bytes: 23920
/* Author: topcoderme123
   Date: 5th july 
*/

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define np next_permutation
using namespace std;
using vi=vector<int>;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define vii vector<vi>
#define vb vector<bool>
#define pr pair<int,int>
#define vl vector<ll>
#define vs vector<string>
#define us unordered_map<int,int>
#define Mpq priority_queue<int>
#define mpq priority_queue<int,vi,greater<int>> 
#define eb emplace_back
#define prl pair<ll,ll>
#define vp vector<pr>
#define inf 1000000000000000008
#define ld long double
const ll N=2e5+23;

ll n,sum,j;

ll a[N];
map<ll,ll> dp;

void solve(){
   cin>>n;
   lp(i,n) cin>>a[i],dp[a[i]]=1;
   sort(a,a+n,greater<int>());

   lps(i,1,n){
     if(i==1) sum+=a[j++],dp[a[i]]<<=1;
     else{
       sum+=a[j];
       if(dp[a[i]]!=N) dp[a[i]]=min(N,dp[a[i]]*2);
       dp[a[j]]--;
       while(!dp[a[j]] and j<n) j++;
     }
   }
   cout<<sum<<"\n";
}

int main(){
   ios_base::sync_with_stdio(0);
   cin.tie(nullptr);

   //assert(freopen("input.txt", "r", stdin));
   //assert(freopen("output.txt", "w", stdout));   

   solve();
   return 0;   	
}



Measured memory_bytes: 17716
k,a,b=map(int,input().split())
kosupa=b-a
j=0
bisket=1
if kosupa>2 and k>a:
    bisket=a
    k=k-a+1
    j=int(k/2)
    k-=j*2
    bisket+=j*(b-a)
    if k >= 1:
        k-=1
        bisket+=1
else:
    bisket+=k
    k=0
print(int(bisket))

Measured memory_bytes: 3064
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,x,y=MI()
    to=[[] for _ in range(n)]
    for i in range(n-1):
        to[i].append(i+1)
        to[i+1].append(i)
    to[x-1].append(y-1)
    to[y-1].append(x-1)
    ans=[0]*n
    for i in range(n):
        q=deque()
        q.append(i)
        dist=[-1]*n
        dist[i]=0
        while q:
            u=q.popleft()
            for v in to[u]:
                if dist[v]!=-1:continue
                dist[v]=dist[u]+1
                ans[dist[v]]+=1
                q.append(v)
    for a in ans[1:]:
        print(a//2)

main()

Measured memory_bytes: 46940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int a,b;cin>>a>>b;
int sum=a;int count=1;
if(b==1)cout<<0<<endl;
else{
    while(sum<b){
        sum=sum+a-1;
        count++;
    }
    cout<<count<<endl;
}


}

Measured memory_bytes: 384
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const string YES = "Yes";
const string NO = "No";

ll N;
ll M;
ll K;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    cin >> M;
    cin >> K;
    solve();
}

// 1 <= N,M <= 1000
// 0 <= K <= NM

// ll N, ll M, ll K
// 黒く塗られたマスの個数をちょうど K 個にできるなら Yes を、そうでないなら No を出力せよ。
void solve(){
    repe(i,N)repe(j,M){
        if(i*j+(N-i)*(M-j)==K){
            cout<<YES<<endl;
            return;
        }
    }
    cout<<NO<<endl;
}


Measured memory_bytes: 3652
object Main{
  def main(args: Array[String]){
    val sc = new java.util.Scanner(System.in)
    val num = sc.nextInt
    var sum = 0L
    var list = List[Int]()
    var min = 0L
    var max = 0L
    for(i <- 1 to num){
      val in = sc.nextInt
      if(i == 1){
        min = in
        max = in
      }

      if(in < min){
        min = in
      }
      if(in > max){
        max = in
      }
      sum = in + sum
    }

    println(min + " " + max + " " + sum)
  }
}

Measured memory_bytes: 61148
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int m;
  cin>>m;
  int a[m];int sum=0;
  for(int i=0;i<m;i++)
    cin>>a[i];
  for(int i=0;i<m;i++)
    sum+=a[i];
  if(sum>n)
    cout<<"-1";
  else
    cout<<n-sum;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    int flag = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> h.at(i);
    }

    int count = 1;

    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {

            if (h.at(i) < h.at(j))
            {
                flag = 1;
            }
        }
        if (flag == 0)
        {
            count++;
        }
        flag = 0;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string s,t; cin>>s>>t; 
    int ans=10001;
    int n=sz(s),m=sz(t);
    for (int i=0;i<=n-m;i++){
        string h=s.substr(i,m);
        int c=0;
        for (int j=0;j<m;j++){
            if (h[j] != t[j]) c++;
        }
        ans = min(ans,c);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
ll a,b,c,k,ans;
cin>>a>>b>>c>>k;
ans += min(a,k);
k -= a+b;
if(k<0){
 k=0;
}
ans -= min(c,k);
 cout<<ans;
}

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

const string YES = "Yes";

const string NO = "No";

void solve(int N, vector<vector<int>> D)
{
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (D.at(i).at(0) == D.at(i).at(1))
        {
            cnt++;
            if (cnt >= 3)
            {
                cout << YES << endl;
                return;
            }
        }
        else
        {
            cnt = 0;
        }
    }
    cout << NO << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> D(N, vector<int>(2));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            cin >> D.at(i).at(j);
        }
    }
    solve(N, move(D));
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

bool solve(vector<string>& line, int a, int b)
{
    int n = line[0].size() + 1;
    int m = line.size();

    for(int i=0; i<m; ++i){
        if(a > 0 && line[i][a-1] == '1'){
            -- a;
        }else if(a < n-1 && line[i][a] == '1'){
            ++ a;
        }
    }

    return a == b;
}

int main()
{
    for(;;){
        int n, a, b, m;
        cin >> n >> a >> b >> m;
        if(n == 0)
            return 0;
        -- a;
        -- b;

        vector<string> line(m);
        for(int i=0; i<m; ++i)
            cin >> line[i];

        if(solve(line, a, b)){
            cout << 0 << endl;
            continue;
        }

        bool ok = false;
        for(int i=0; i<m; ++i){
            for(int j=0; j<n-1; ++j){
                if(!ok && (j == 0 || line[i][j-1] == '0') && line[i][j] == '0' && (j == n-2 || line[i][j+1] == '0')){
                    line[i][j] = '1';
                    if(solve(line, a, b)){
                        cout << (i+1) << ' ' << (j+1) << endl;
                        ok = true;
                    }
                    line[i][j] = '0';
                }
            }
        }
        if(!ok)
            cout << 1 << endl;
    }
}

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << endl;
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

const int MAXN=100005;
	
	void solve() {
        long int n;
        cin>>n;
        if(n>=400 && n<600)
            cout<<"8";
        else if(n>=600 && n<800)
            cout<<"7";
        else if(n>=800 && n<1000)
            cout<<"6";
        else if(n>=1000 && n<1200)
            cout<<"5";
        else if(n>=1200 && n<1400)
            cout<<"4";
        else if(n>=1400 && n<1600)
            cout<<"3";
        else if(n>=1600 && n<1800)
            cout<<"2";
        else 
            cout<<"1";
        cout<<endl;
	}
	
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
    	// cout<<"Case #"<<tt<<": ";
    	solve();
    }
    cerr << "Time : " << 1000 * ((double) clock()) / (double) CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int main(){
  int s;
  int h,m;
  cin >> s;
  h = s/3600;
  s -= h*3600;
  m = s/60;
  s -= m*60;
  cout << h <<":" << m << ":" <<s <<endl;
  return 0;
}



Measured memory_bytes: 3096
/* Bismillahir Rahmanir Rahim */
#include<stdio.h>
#include<string.h>
int main()
{
    char a[100];
    int j,i;
    gets(a);
    int k=strlen(a);
    printf("2018/");
    for(i=5;i<k;i++)
        printf("%c",a[i]);

    printf("\n");

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> count(N, 0);
  
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    
    while (tmp >= 2) {
      if (tmp % 2 != 0) break;
      
      count[i] += 1;
      tmp /= 2;
    }
  }
  
  int min = *std::min_element(count.begin(), count.end());
  cout << min << endl;
}


Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [a, b, k] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const ans = () => {
  let right = a
  for (let i = 0; i < k && right <= b; i++, right++) {
    console.log(right)

    if (right >= b) {
      return
    }
  }

  let left = b
  let lefts = []
  for (let i = 0; i < k && right - 1 < left; i++, left--) {
    lefts.push(left)
  }

  lefts.reverse().forEach(v => console.log(v))
}

ans()


Measured memory_bytes: 9132
def main():
    s = input()

    cnt, k = [0 for i in range(3)], 0
    for i in range(len(s)):
        idx = ord(s[i])-ord('a')
        cnt[idx] += 1
        if cnt[idx] == 1:
            k += 1

    if k <= 2 and k < len(s):
        print("NO")
        return

    over = 0
    for i in range(3):
        if (len(s)+2) // 3 < cnt[i]:
            print("NO")
            break
        elif len(s) // 3 < cnt[i]:
            over += 1
    else:
        if over <= len(s) % 3:
            print("YES")
        else:
            print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import sys
input=sys.stdin.readline

def main():
    s = input()
    cnt = 0
    trial = 0
    for i in s: # 本当に全通りO（n^2）やらなくても最長の部分がわかれば良い
        if i in "ACGT":
            trial += 1
        else:
            cnt = max(cnt, trial)
            trial = 0
    print(cnt)

if __name__=="__main__":
    main()


Measured memory_bytes: 61840
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
LL a[200005],sum[200005];
inline LL Abs(LL a)
{
	if(a<0)return -a;
	return a;
}
int main(void)
{
	int i,n;
	LL b,ans=0x3F3F3F3F3F3F3F3F;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);a[i]-=i;
	}
	sort(a+1,a+n+1);
	for(i=1;i<=n;++i)sum[i]=sum[i-1]+a[i];
	for(i=1;i<=n;++i)
	{
		ans=min(ans,(i-1)*a[i]-sum[i-1]+(sum[n]-sum[i])-(n-i)*a[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
    int n,c;
    cin >> n >> c;
    int d[c][c] = {};
    int a[n][n] = {};
    int c1[c] = {};
    int c2[c] = {};
    int c3[c] = {};
    
    for(int i=0; i<c; i++) 
        for(int j=0; j<c; j++) cin >> d[i][j];
    for(int i=0; i<n; i++) 
        for(int j=0; j<n; j++){
            cin >> a[i][j];
            a[i][j]--;
            if((i+j)%3 == 0){
                c1[a[i][j]]++;
            }else if((i+j)%3 == 1){
                c2[a[i][j]]++;
            }else{
                c3[a[i][j]]++;
            }
        }
    
    int ans = 1e9;
    for(int i=0; i<c; i++){
        for(int j=0; j<c; j++){
            if(i == j) continue;
            for(int k=0; k<c; k++){
                if(k == i || k == j) continue;
                int tmp = 0;
                for(int l =0; l<c; l++){
                    tmp += c1[l]* d[l][i];    
                    tmp += c2[l]* d[l][j];  
                    tmp += c3[l]* d[l][k];  
                }
                ans = min(ans, tmp);
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}
  

Measured memory_bytes: 1280
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;

    public BigInteger gcd(BigInteger a, BigInteger b) {
        if (b.equals(BigInteger.ZERO)) return a;
        return gcd(b,a.remainder(b));
    }

    public BigInteger lcm(BigInteger a, BigInteger b) {
        return a.multiply(b).divide(gcd(a,b));
    }

    public BigInteger f(BigInteger a, BigInteger b, BigInteger c) {
        BigInteger n =  b.divide(c).subtract(a.subtract(BigInteger.ONE).divide(c));
        return n;
    }

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        BigInteger A = sc.nextBigInteger(), B = sc.nextBigInteger();
        BigInteger C = sc.nextBigInteger(), D = sc.nextBigInteger();
        out.println((B.subtract(A).add(BigInteger.ONE)).subtract(f(A,B,C)).subtract(f(A,B,D)).add(f(A,B,lcm(C,D))));
    }

    public static void main(String[] args) {
        new Main()._main(args);
    }
}


Measured memory_bytes: 21972
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), X = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N ; i++){
            a[i] = sc.nextInt();
            X -= a[i];
        }
        Arrays.sort(a);
        int ans = N;
        ans += X / a[0];
        System.out.println(ans);
    }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << ' ';
  cout << max(0, a + b - n) << '\n';
  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    S = list(input())
    T = list(input())

    start = [-1 for i in range(26)]
    stop = [-1 for i in range(26)]

    fail = False
    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')

        if start[a] != -1 or stop[b] != -1:
            if start[a] != b or stop[b] != a:
                print('No')
                fail = True
                break
        else:
            start[a] = b
            stop[b] = a

    if not fail:
        print('Yes')

Measured memory_bytes: 6704
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

// output N*2 values


int check(int N) {
    int foo = 1;
    while (true) {
        if (foo * (foo + 1) / 2 == N) {
            return foo;
        } else if (foo * (foo + 1) / 2 > N) {
            return -1;
        } else {
            foo++;
        }
    }
}

int main(void) {
    int N;
    cin >> N;
    int K = check(N);
    if (K == -1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        cout << K + 1 << endl;
        VVI ans;
        int foo = 2;
        {
            VI row;
            row.EB(1);
            ans.EB(row);
            row = VI();
            row.EB(1);
            ans.EB(row);
        }
        REP(i, K - 1) {
            VI row;
            RREP(i, ans.size()) {
                ans[i].EB(foo);
                row.EB(foo++);
            }
            ans.EB(row);
        }
        REP(i, ans.size()) {
            cout << ans[i].size() << " ";
            REP(j, ans[i].size()) cout << ans[i][j] << " ";
            cout << endl;
        }
    }
}


Measured memory_bytes: 2560
n,m = map(int,input().split())
A = set()
for i in range(m):
    A.add(int(input()))
dp = [0]*(n+1)
dp[0] = 1
if 1 not in A:
    dp[1] = 1
else:
    dp[1] = 0
for i in range(2,n+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1]+dp[i-2])%(10**9+7)
print(dp[-1])

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

int main()
{
  int N;
  cin >> N;
  vector<int> dp(100010,100010);
  dp[N] = 0;
  for(int i=N;i>0;i--){
    dp[i-1] = min(dp[i] + 1,dp[i-1]);
    for(int j=1;j<=6;j++){
      int a = (int)pow(6.0,(double)j);
      if(a<=i){
        dp[i-a] = min(dp[i]+1,dp[i-a]);
      }
    }
    for(int j=1;j<=5;j++){
      int a = (int)pow(9.0,(double)j);
      if(a<=i){
        dp[i-a] = min(dp[i]+1,dp[i-a]);
      }
    }
  }
  cout << dp[0] << endl;
  return 0;
}



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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  vector<int> a(n);
  rep(i, n) a[i] = i + 1;

  map<vector<int>, int> mp;
  do {
    mp[a] = mp.size();
  } while (next_permutation(a.begin(), a.end()));

  int res = abs(mp[p] - mp[q]);
  cout << res << endl;
  return 0;
}

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

int main() {
  string n;
  cin>>n;
  char ans=n.at(n.size()-1);
  if(ans=='2'||ans=='4'||ans=='5'||ans=='7'||ans=='9'){
    cout<<"hon"<< endl;
    return 0;
  }
  if(ans=='0'||ans=='1'||ans=='6'||ans=='8'){
    cout<<"pon"<< endl;
    return 0;
  }
  if(ans=='3'){
    cout<<"bon"<< endl;
    return 0;
  }
}
  

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
//orz kczno1    POD only
template<typename T>
struct vec{T *a;int n;void clear(){n=0;}
void pb(const T &x){if((n&-n)==n)a=(T*)realloc(a,(n*2)*sizeof(T));a[n++]=x;}
inline T* begin(){return a;}inline T* end() {return a+n;}};
int main()
{
	string s;
	cin>>s;
	if(s.substr(0,4)=="YAKI") puts("Yes");
	else puts("No");
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    char c;
    cin >> c;
    c += 1;
    cout << c << endl;
}

Measured memory_bytes: 3496
<?php
fscanf(STDIN, "%d %d", $n, $m);
if (!$m) exit('0');
while ($n--) {
	fscanf(STDIN, "%d %d %d", $x, $y, $z);
	$sum[0][] = $x + $y + $z;
	$sum[1][] = $x * -1 + $y + $z;
	$sum[2][] = $x + $y * -1 + $z;
	$sum[3][] = $x + $y + $z * -1;
}
$max = 0;
foreach ($sum as $s) {
	sort($s);
	$s1 = array_slice($s, 0, $m);
	$x = abs(array_sum($s1));
	if ($x > $max) $max = $x;
	$s2 = array_slice($s, -$m);
	$x = abs(array_sum($s2));
	if ($x > $max) $max = $x;
}
echo $max;

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

int main(void){
    long long n, m;
    cin >> n >> m;
    if(n<m) swap(n, m);
    long long ans;
    if(n==1 && m==1) ans = 1;
    else if(m==1) ans = n-2;
    else if(m>2){
        ans = (n-2)*(m-2);
    }else if(m==2){
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL a, b, k;
	cin >> a >> b >> k;
	
	LL x, y;
	if(a >= k) { x = a - k; y = b; } else { x = 0; y = max(a + b - k, 0LL); }
	
	cout << x << " " << y << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<int[]> list = new LinkedList<int[]>();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N];

		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
			B[i]=sc.nextInt();
			int[] tmp={A[i],B[i]};
			list.add(tmp);
		}

        Comparator<int[]> comparator = new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return Integer.valueOf(o1[1]).compareTo(Integer.valueOf(o2[1]));
            }
        };

        Collections.sort(list,comparator);
        List<int[]> list_2 = new ArrayList<int[]>(list);
        long time = 0L;

        for (int i=0;i<N;i++) {
        	time+=list_2.get(i)[0];
        	if (time>list_2.get(i)[1]) {
        		System.out.println("No");
        		break;
        	}
        	if (i==N-1) {
        		System.out.println("Yes");
        	}
        }
	}
}

Measured memory_bytes: 167736
s = input()

from collections import Counter

count = Counter(s)

ans = float('inf')

for c in count:
    
    m_l = 0

    items = list(s.split(c))

    first = items.pop(0)
    last = items.pop()

    m_l = max(len(first),len(last))

    for item in items:
        m_l = max(m_l,len(item))

    ans = min(ans,m_l)

print(ans)

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

const int INF = 100000000;

int n, m;
short pic1[100][100];
short pic2[50][50];
int ax, ay;

bool check(int y, int x){
  bool f;
  f = true;
  ax = -1;
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      if(pic2[i][j] == -1) continue;
      if(pic1[y+i][x+j] != pic2[i][j]){
	i = INF;
	f = false;
	break;
      }
      if(ax == -1){
	ax = x+j+1;
	ay = y+i+1;
      }
    }
  }
  if(f) return true;
  f = true;
  ax = -1;
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      if(pic2[j][m-1-i] == -1) continue;
      if(pic1[y+i][x+j] != pic2[j][m-1-i]){
	i = INF;
	f = false;
	break;
      }
      if(ax == -1){
	ax = x+j+1;
	ay = y+i+1;
      }
    }
  }
  if(f) return true;
  f = true;
  ax = -1;
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      if(pic2[m-1-i][m-1-j] == -1) continue;
      if(pic1[y+i][x+j] != pic2[m-1-i][m-1-j]){
	i = INF;
	f = false;
	break;
      }
      if(ax == -1){
	ax = x+j+1;
	ay = y+i+1;
      }
    }
  }
  if(f) return true;
  f = true;
  ax = -1;
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      if(pic2[m-1-j][i] == -1) continue;
      if(pic1[y+i][x+j] != pic2[m-1-j][i]){
	i = INF;
	f = false;
	break;
      }
      if(ax == -1){
	ax = x+j+1;
	ay = y+i+1;
      }
    }
  }
  return f;
}

main(){
  while(cin >> n >> m && (n || m)){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin >> pic1[i][j];
      }
    }
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
	cin >> pic2[i][j];
      }
    }
    for(int i=0;i+m<=n;i++){
      for(int j=0;j+m<=n;j++){
	if(check(i, j)){
	  i = INF;
	  break;
	}else{
	  ax = -1;
	}
      }
    }
    if(ax == -1){
      cout << "NA" << endl;
    }else{
      cout << ax << ' ' << ay << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: usize,
        w: usize,
        a: [String; h],
    }

    println!(
        "{}",
        (0..w + 2).fold(String::new(), |b, _| b + &"#".to_string())
    );

    for a_ in a.iter() {
        println!("#{}#", a_);
    }
    println!(
        "{}",
        (0..w + 2).fold(String::new(), |b, _| b + &"#".to_string())
    );
}


Measured memory_bytes: 4352
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<60;

/** /////////// ** Code ** /////////// **/
const int N  =1010;

int n , m;
int a,b,c;
ll mem[N][N];
ll x[N],y[N],z[N];

ll dp(int i,int j){
    if(j == m)return 0LL;
    if(i == n)return -inf;
    ll &ret = mem[i][j];
    if(ret != -1) return ret;
    return ret=max( dp(i+1,j) , dp(i+1,j+1)+a*x[i]+b*y[i]+c*z[i] );
}

int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%lld%lld%lld",x+i,y+i,z+i);
    ll ans =0;
    for(a=-1;a<2;a+=2)
        for(b=-1;b<2;b+=2)
            for(c=-1;c<2;c+=2){
                memset(mem,-1,sizeof mem);
                ans=max(ans,dp(0,0));

            }

    printf("%lld",ans);
    return 0;
}


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

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

void solve() {
    int n; cin >> n;
    while (n--) {
        int k, p; cin >> k >> p;
        int a = k % p;
        if (a == 0) a = p;
        cout << a << "\n";
    }
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    solve();
}


Measured memory_bytes: 3216
#include<iostream>
#include<iomanip> 
using namespace std;
int main(){
	int a,b;
	cin>>a;
	for(int i=1;i<=a;i++){
		if(i%2==1)
		b+=1;
		
	}
	cout<<fixed<<setprecision(10)<<double(b)/a;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
ll const mod = 998244353;
const ll MAX = 300000;
vector<vector<int>>e;
vector<int>used;
int n, m;

int dfs(int a) {
    int res = 0;
    used[a] = 1;
    bool ok = true;
    for (int x : e[a]) {
        if (used[x] == 1)continue;
        ok = false;
        res += dfs(x);
    }
    
    if (ok) {
        rep(i, n) {
            if (used[i] == 0) {
                used[a] = 0;
                return 0;
            }
        }
        used[a] = 0;
        return 1;
    }
    used[a] = 0;
    return res;

}

int main() {
    cin >> n >> m;
    e.resize(n);
    used.resize(n, 0);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int ans = 0;
    used[0] = 1;
    for (int x : e[0]) {
        ans += dfs(x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
def main():
    N, A, B = (int(i) for i in input().split())
    S = input()
    cnt = 0
    cnt_ob = 0
    for s in S:
        if s == "a":
            if cnt < A+B:
                print("Yes")
                cnt += 1
            else:
                print("No")
        elif s == "b":
            if cnt < A+B and cnt_ob < B:
                print("Yes")
                cnt += 1
                cnt_ob += 1
            else:
                print("No")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4016
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const long long MAX = INT_MAX;

int main()
{
    int n, t;
    string s;
    cin >> n >> t >> s;

    long long ret = 0;
    for(unsigned i=0; i<s[i]; ++i){
        if(!isdigit(s[i]))
            continue;

        long long tmp = 1;
        for(int j=0; j<s[i]-'0'; ++j){
            tmp *= n;
            tmp = min(tmp, MAX);
        }
        ret += tmp;
        ret = min(ret, MAX);
    }

    ret *= t;
    if(ret <= 1000000000)
        cout << ret << endl;
    else
        cout << "TLE" << endl;

    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
    const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        vector<string> s(n);
        map<int,int> prev;
        REP(i, n) {
            cin >> s[i];
            if (i == 0) continue;
            int depth = 0;
            REP(j, SZ(s)) {
                if (s[i][j] != '.') break;
                ++depth;
                s[i][j] = ' ';
            }
            s[i][depth-1] = '+';
            if (prev.count(depth)) {
                FOR(j, prev[depth]+1, i) {
                    s[j][depth-1] = '|';
                }
            }
            prev[depth] = i;
            auto tmp = prev;
            for (auto &tp : prev) {
                if (tp.first > depth) tmp.erase(tp.first);
            }
            swap(tmp, prev);
        }

        REP(i, n) {
            cout << s[i] << endl;
        }
    }

    return 0;

}



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

int main(){
  int N,M;
  cin >>N>>M;
  vector<pair<long long,long long>> P(N);
  
  for(int i=0;i<N;i++){
    int a,b;
    cin >>a>>b;
    P[i] = make_pair(a,b);
  }
  
  sort(P.begin(),P.end());
  
  int target = 0;
  long long ans = 0;
  
  for(int i=0;i<N;i++){
    if (target == M) break;
    if (target + P[i].second <= M){
      target += P[i].second;
      ans += P[i].first * P[i].second;
    }else{
      for(int j=0;j<P[i].second;j++){
        if(target == M) break;
        target ++;
        ans += P[i].first;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792