akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define MOD 1000000007
#define INF 2000000000
#define DESPACITO 1000000000000000000
#define PI acos(-1);
#define E 998244353
#define pb push_back
#define mp make_pair
#define pdd pair<double,double>
#define ll long long

using namespace std;

string s;

string transformString(string s)
{
	string t="";
	for(int i=0;i<s.length();)
	{
		if(i==s.length()-1)
		{
			t+=s[i];
			break;
		}
		else if(s[i]=='B' && s[i+1]=='C')
		{
			i+=2;
			t+='D';
		}
		else
		{
			t+=s[i];
			i++;
		}
	}
	return t;
}

int main()
{
	IOS;
	cin >> s;
	s=transformString(s);
	int ct=0;
	ll tot=0;
	REP(i,0,s.length()-1)
	{
		if(s[i]=='B' ||s[i]=='C')
			ct=0;
		else if(s[i]=='D')
			tot+=ct;
		else
			ct++;
	}
	cout << tot;
}

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

int main(){
  char cards[36][3], cards2[36][3];
  int n;

  cin >> n;
  rep(i, n){
    cin >> cards[i];
    strcpy(cards2[i], cards[i]);
  }

  rep(i,n){
    for (int j=n-1;j>i;j--){
      if (cards[j][1]<cards[j-1][1]){
        swap(cards[j], cards[j-1]);
      }
    }
  }

  rep(i, n){
    int minj = i;
    for (int j=i;j<n;j++){
      if (cards2[j][1]<cards2[minj][1]){
        minj = j;
      }
    }
    swap(cards2[i], cards2[minj]);
  }

  for (int i=0;i<n;i++){
    if (i!=0) cout << " ";
    cout << cards[i];
  }
  cout << endl << "Stable" << endl;

  bool flag=0;
  for (int i=0;i<n;i++){
         if (i!=0) cout << " ";
    cout << cards2[i];
    if (strcmp(cards[i],cards2[i])) flag=1;
  }
  cout << endl;

  cout << ((flag)?"Not stable":"Stable" )<< endl;

  return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//任意の自然数 k に対して、ある自然数 N を取ると、
//任意の自然数 n > N に対して、n と 2n の間に 素数が少なくとも k 個存在する
//(ポール・エルデシュの証明)
//よって問題が与えるnに対し2nの範囲でエラトステネスの篩を行えばよい

void sieve(int n) {
	vector<bool>is_prime(n, true);
	vector<int>p(0,0);
	is_prime[0] = false;
	is_prime[1] = false;
	for (int i = 2; i < sqrt(n); i++) {
		if (is_prime[i]) {
			for (int j = 2; i * j < n; j++) {
				is_prime[i*j] = false;
			}
		}
	}
	for (int k = 0; k < n; k++) {
		if (is_prime[k]) {
			p.push_back(k);
		}
	}
	for (int h = 0; h < p.size(); h++) {
		if (n / 2 <= p[h]) {
			cout << p[h] << endl;
			break;
		}
	}
}

int main() {
	int n;
	cin >> n;
	//このsieve関数はnまでの素数を求める
	//問題文には「X以上」の素数のうち、最小のものとあるので、
	//引数として2n*+1を与えればよい

	sieve(2*n+1);
	return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),(OUT(YES),1),(OUT(NO),0))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p998 = 998244353;
const LL p107 = 1000000007;
const LL p = p107;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
//LL A[SIZE],B[SIZE],C[SIZE];
LL V,P;
LL solve(){
	cin >> N>> M >> V >> P;
	V=N-V;
	VI A(N);
	REP(i,N) cin >> A[i];
	sort(ALL(A),greater<LL>());
	LL ans=0;
	ans+=P;
	LL needs=A[P-1];
	FOR(i,P,N){
		if(A[P-1]>A[i]+M) return ans;
		if(needs-A[i]*(i-P+1)<= V*M){
			ans++;
		}else return ans;
		needs+=A[i];
	}
	return ans;
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	LL T=1;

	REP(i,T){
		DEFAULT;

	}
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 14720
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c;
	if(a>b)
	{
		d=a;
		a=b;
		b=d;
	}
	if(b>c)
	{
		d=b;
		b=c;
		c=d;
	}
    if(a>b)
    {
    	d=a;
    	a=b;
    	b=d;
	}
	if(a+b==c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 998244353

//ここから編集する
class Combination {

public:
    vector<ll> fact;

    Combination(int max_n) {
        //1 ~ n!までの階乗modを求める
        int n = max_n;
        vector<ll> fact(n + 1);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i - 1] * i) % MOD;
        }
        this->fact = fact;
    }

    template<typename T>
    //templateをつかってみｔか
    ll pow(T x, int y) {
        if (y == 0) return 1;
        if (y == 1) return x;
        if (y == 2) return (x * x) % MOD;
//        if (y % 2 == 1) return pow(x, y / 2) * pow(x, y / 2) % MOD;
        if (y % 2 == 1) return pow(pow(x, y / 2), 2) * x % MOD;
//        return pow(x, y / 2) * pow(x, y / 2) % MOD;
        return pow(pow(x, y / 2), 2) % MOD;
    }

    ll nCk(int n, int k) {
//        return (fact[n] * pow(fact[n-k],MOD-2) * pow(fact[k],MOD-2)) % MOD;
        return (((fact[n] * pow(fact[n - k], MOD - 2)) % MOD) * pow(fact[k], MOD - 2)) % MOD;
    }
};

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


    ll N, A, B, K;
    cin >> N >> A >> B >> K;

    Combination com(N + 5);

    ll ans = 0ll;
    for (ll i = 0; i <= N; i++) {
        ll x = i;
        if (K - A * x >= 0 && (K - A * x) % B == 0) {
            ll y = (K - A * x) / B;
            if (N >= y) {
                ll tmp = com.nCk(N, x);
                tmp *= com.nCk(N, y);
                tmp %= MOD;
                ans += tmp;
                ans %= MOD;
            }


        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include<stdlib.h>
#include <math.h>
using namespace std;


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

    int a[n+1];
    for(int i = 0;i<n+1;i++){
        a[i]=abs(b[n+1]-b[i]);
    }
    int maxa,mina,maxmina,minmaxa;
    maxa = a[n];
    mina = a[n];
    minmaxa = a[n];
    maxmina = a[n];
    for(int i = n-1;i>0;i--){
        maxa = maxmina;
        if(maxa < a[i]){
            maxa = a[i];
        }
        mina = minmaxa;
        if(mina > a[i]){
            mina = a[i];
        }
        if(maxmina<mina){
            maxmina = mina;
        }
        if(minmaxa > maxa){
            minmaxa = maxa;
        }
    }
    cout << maxa;
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e5+5;
vector<ll> v[N];
int n;
ll l[N],r[N];
set<ll> s;

int prime[N];      // i番目の素数
bool i_prime[N+1]; // 数字iが素数かどうか
int num_prime[N];  // 数字iまでの素数の個数
// n以下の素数の数を返す O(n log log n) ≒ O(n)
int sieve(int n) {
  int p = 0;
  rep(i,n+1) i_prime[i] = true;
  i_prime[0] = i_prime[1] = false;
  for(int i = 2; i<=n; i++) {
    num_prime[i] = num_prime[i-1];
    if(i_prime[i]) {
      if(i%2 && i_prime[(i+1)/2]) num_prime[i]++;
      prime[p++] = i;
      for(int j = 2*i; j<=n; j += i) i_prime[j] = false;
    }
  }
  return p;
}

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  rep(i,n) {
    cin >> l[i] >> r[i];
  }
  sieve(N);
  rep(i,n) {
    cout << num_prime[r[i]] - num_prime[l[i] - 1] << endl;
  }
  // cout << << endl;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n;
    cin>> n;
    if(n%1000==0){cout<<0<<endl; return 0;}
    ll ans = ((n/1000)+1)*1000-n;
    cout<<ans<<endl;
}
    



Measured memory_bytes: 3480
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    LinkedList<Integer> dq = new LinkedList<Integer>();
    for(int i = 1; i <= n; i++) {
      int a = sc.nextInt();
      if((n - i) % 2 == 0) {
        dq.addFirst(a);
      } else {
        dq.addLast(a);
      }
    }
    for(int i = 0; i < n; i++) {
      System.out.println(dq.pollFirst());
    }
  }
}

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

int main(){
  int s,w;
  cin >> s >> w;
  if(s <= w) puts("unsafe");
  else puts("safe");
  return 0;
}


Measured memory_bytes: 3632
def main():
    a, b, c, x, y = map(int, input().split())
    p = {x: a, y: b}
    print(min(a * x + b * y, c * max(x, y) * 2, c * min(x, y) * 2 + (max(x, y) - min(x, y)) * p[max(x, y)]))


if __name__ == '__main__':
    main()



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

int N;
const int MAX_N = 1.0e5 + 100;
ll a[MAX_N], b[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];

    ll a_sum = 0, b_sum = 0;
    for (int i = 0; i < N; i++) {
        a_sum += a[i];
        b_sum += b[i];
    }

    ll a_cnt = 0, b_cnt = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] > b[i]) {
            b_cnt += a[i] - b[i];
        }
        else {
            if ((b[i] - a[i]) % 2 == 0) {
                a_cnt += (b[i] - a[i])/2;
            }
            else {
                a_cnt += (b[i] - a[i])/2 + 1;
            }
        }
    }

    if (b_sum - a_sum >= a_cnt && b_sum - a_sum >= b_cnt) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,a,b;
    cin>>n>>a>>b;
    
    char s;
    int cnt_a = 0;
    int cnt_b = 0;
    for(int i=0;i<n;++i){
        cin>>s;
        if(s=='a'&&cnt_b+cnt_a<a+b){
            cnt_a++;
            cout<<"Yes"<<endl;
            continue;
        }
        else if(s=='b'&&cnt_a+cnt_b<a+b&&cnt_b<b){
            cnt_b++;
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
        
    }
    
    
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

ll binPow(ll a, ll q,ll k)
{
    ll MOD = k;
     a %= MOD;
    if (q == 0) return 1;
    return ((q % 2 == 1 ? a : 1) * binPow(a * a, q / 2,k))%MOD ;
}

int main()
{

    ll i,j,k,l,m,n,q,p1,p2,q1,q2,x,ans,l1,l2,l3,l4,l5,l6,l7,l8;


    cin >> k;
    ans = 0;
   if(k%2 == 0||k%5==0)return cout << -1<<endl,0;
    for(i=0;i<1000000; i++)
    {
        ans += (7ll * binPow(10ll,i,k))%k;
        if(ans%k==0)
        {
           cout << i+1<<endl;
           break;
        }
    }



}


Measured memory_bytes: 3608
#

import sys
input=sys.stdin.readline

def main():
    D=int(input())
    C=list(map(int,input().split()))
    S=[list(map(int,input().split())) for i in range(D)]
    last=[[0]*27 for i in range(D+1)]
    satsum=0
    lastt=[[0]*27 for i in range(D+1)]
    for day in range(1,D+1):
        for i in range(D+1):
            for j in range(27):
                lastt[i][j]=last[i][j]
        maxt=0
        maxsat=0
        for t in range(1,27):
            sat=0
            for j in range(day,D+1):
                    last[j][t]=day
            sat+=S[day-1][t-1]
            for j in range(1,27):
                sat-=C[j-1]*(day-last[day][j])
            if t==1:
                maxt=t
                maxsat=sat
            elif maxsat<sat:
                maxt=t
                maxsat=sat
            for i in range(D+1):
                for j in range(27):
                    last[i][j]=lastt[i][j]
            
        satsum+=maxsat
        for j in range(day,D+1):
            last[j][maxt]=day
        satsum+=maxsat
        print(maxt)
    
if __name__=="__main__":
    main()


Measured memory_bytes: 69536
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int n,m;
vector<int> v[100010];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n>>m;
	
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		
		if(a<=m)v[m-a+1].pb(b);
	}
	
	priority_queue<int> q;
	
	int ans=0;
	
	for(int i=m;i>=1;i--)
	{
		for(int j=0;j<v[i].size();j++)q.push(v[i][j]);
		
		if(!q.empty()){ans+=q.top();q.pop();}
	}
	
	cout<<ans;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 5632
#include <iostream>
using namespace std;
 
int main() {
	string s;
    cin>>s;
    for(int i=0;i<3;i=i+1){
    	if(s[i]=='1')
    		cout<<9;
      	if(s[i]=='9') 
      		cout<<1;
    }
    return 0;
}

Measured memory_bytes: 3604
n = int(input())
a = list(map(int,input().split()))

for i in range(1,n):
	print(*a)
	j = i -1
	v = a[i]
	while j >= 0 and a[j] > v:
		a[j+1] = a[j]
		j -= 1
	a[j+1] = v
print(*a)


Measured memory_bytes: 5984
# -*- coding: utf-8 -*-


def main():
    n = int(input())

    # See:
    # https://www.youtube.com/watch?v=S1IkBhwnuYU
    # KeyInsight
    # 取り出した部分列が昇順かつ連続した数字が並んでいるかどうか

    # ■できた部分
    # N - 部分列の長さの最大値が答え

    # ■できなかった部分
    # 判定方法：
    # piの値が並び替え前にどこに位置しているかをメモ
    # 昇順かつ連続して並んでいる部分列の長さを数える
    p = [0 for _ in range(n)]

    for i in range(n):
        x = int(input())
        x -= 1
        p[x] = i

    len_max = 1
    count = 1

    for i in range(1, n):
        if p[i] > p[i - 1]:
            count += 1
        else:
            count = 1

        len_max = max(len_max, count)

    print(n - len_max)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11048
#include <string>
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

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

  int len_a, len_b;

  cin >> len_a;
  vector<int> vecA(len_a);
  for (int i = 0; i < len_a; i++) {
    cin >> vecA[i];
  }

  cin >> len_b;
  vector<int> vecB(len_b);
  for (int i = 0; i < len_b; i++) {
    cin >> vecB[i];
  }

  int len_min = min(len_a, len_b);
  for (int i = 0; i < len_min; i++) {
    if (vecB[i] > vecA[i]) {
      cout << 1 << endl;
      return 0;  // end
    } else if (vecB[i] < vecA[i]) {
      cout << 0 << endl;
      return 0;  // end
    } else {
      continue;
    }
  }

  if (len_b > len_a) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}




Measured memory_bytes: 3168
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    if (N / 10 == 9 || N % 10 == 9) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n,m;
while(cin>>n){
if(n==0) return 0;
int max = 0;
int min = 500;
for(int i=0;i<n;i++){
int s = 0;
for(int j=0;j<5;j++){
cin >> m;
s += m;
}
if(s>max) max = s;
if(s<min) min = s;
}
cout <<max << ' ' << min << endl;
}
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
s = input()
a = s[:2]
b = s[2:]
a = int(a)
b = int(b)
if 0<int(a) and int(a) <= 12 and 0<b and b <= 12:
    print("AMBIGUOUS")
elif 0<int(a) and int(a) <= 12:
    print("MMYY")
elif 0<b and b <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

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

    int ans = 1;
    n -= k;

    if (n % (k - 1) == 0)
    {
        ans += n / (k - 1);
    }
    else
    {
        ans += n / (k - 1) + 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

ostream& operator<<(ostream& os, const pair<char, int>& unit) {
  return os << unit.first << "^" << unit.second;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 100010;

int n;
int a[N], c[16], v[16], dp[1 << 15];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n;
  for (int rep = 1; rep < n; ++rep) {
    int u, v, w;
    cin >> u >> v >> w;
    a[u] ^= w;
    a[v] ^= w;
  }
  int ans = n;
  for (int i = 0; i < n; ++i)
    if (a[i])
      ++c[a[i]];
    else
      --ans;
  int m = 0;
  for (int i = 1; i <= 15; ++i) {
    ans -= c[i] >> 1;
    c[i] &= 1;
    if (c[i])
      v[m++] = i;
  }
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  for (int s = 1; s < 1 << m; ++s) {
    int xs = 0;
    for (int i = 0; i < m; ++i)
      if ((s >> i) & 1)
        xs ^= v[i];
    if (xs) continue;
    int t = (s - 1) & s;
    while (true) {
      if (dp[t] != -1)
        dp[s] = max(dp[s], dp[t] + 1);
      if (!t)
        break;
      t = (t - 1) & s;
    }
  }
  ans -= dp[(1 << m) - 1];
  cout << ans;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}



Measured memory_bytes: 768
N = list(str(input()))
mx = sum(map(lambda x: ord(x)-ord('0'),N))
for i in xrange(1,len(N)):
    N[i]='0'
N = int("".join(N))
mx = max(mx,sum(map(lambda x: ord(x)-ord('0'),str(N-1))))
print mx

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

int main(){
    int n;
    cin >> n;
    if(n/100==7){
        cout << "Yes" << endl;
        return 0;
    }
    int x = n-(n/100)*100;
    if(x/10==7){
        cout << "Yes" << endl;
        return 0;
    }
    int y = x-(x/10)*10;
    if(y == 7){
        cout << "Yes" << endl;
      return 0;
    } 
    cout << "No" << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll n, k, l, r;
    ll mod = 998244353;
    cin >> n >> k;
    vector<ll> cnt(n+1, 0);
    vector<ll> acc(n+1, 0);
    vector<vector<ll>> arr;
    for(int i = 0; i < k; i++) {
        cin >> l >> r;
        arr.push_back({l, r});
    }
    cnt[1] = acc[1] = 1;
    for(int i = 2; i <= n; i++) {
        for(int j = 0; j < k; j++) {
            l = arr[j][0];
            if (i-l < 0)
                l = i;
            r = arr[j][1];
            if (i-r < 1)
                r = i-1;
            ll tmp = (acc[i-l] - acc[i-r-1] + mod*10) % mod ;
            cnt[i] += tmp;// sum(cnt[i-r], .. cnt[i-l]);
            cnt[i] %= mod;
        }
        
        acc[i] = acc[i-1] + cnt[i];
        acc[i] %= mod;
    }
    cout << (cnt[n]%mod) << endl;
    return 0;
}


Measured memory_bytes: 6364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABCProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            ///C///
            //要素数N
            int n = int.Parse(Console.ReadLine());

            //空白ずつ取得
            string[] input = Console.ReadLine().Split(' ');

            //要素数Nの数字配列
            string[] number = new string[n];
            //List<int> number;

            //ユニークフラグ
            bool flag = false;

            for(int i = 0; i < n; i++)
            {
                number[i] = input[i];
            }

            var list = number.ToList();
            var beforeListCount = list.Count;

            var distinctList = list.Distinct();
            var afterListCount = distinctList.Count();

            if(beforeListCount != afterListCount)
            {
                flag = true;
            }

            

            if(flag == true)
            {
                Console.WriteLine("NO");
            }
            else
            {
                Console.WriteLine("YES");
            }

        }
    }
}


Measured memory_bytes: 49564
import java.util.Scanner;
import java.lang.Math;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		final int A = scan.nextInt();
		final int B = scan.nextInt();

		System.out.println(Math.max(A+B,Math.max(A-B,A*B)));
	}
}

Measured memory_bytes: 21716
#include <iostream>

using namespace std;

int main()
{
int x,y,z;
cin>>x>>y>>z;
if(x!=y&&y==z)cout<<x<<endl;
else if(y!=x&&x==z)cout<<y<<endl;
else if(z!=x&&x==y)cout<<z<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

string f(int offset, int n) {
    string response;
    cout << "? ";
    for (int i = offset; i < offset + n; i++) {
        cout << i + 1 << ' ';
    }
    cout << endl;

    cin >> response;
    return response;
}

string jump_val(int given_pos, int jump, int n) {
    string response;
    cout << "? " << given_pos + 1 << ' ';
    for (int i = 0; i < jump; i++) {
        cout << i + 1 << ' ';
    }
    for (int i = jump + n + 1; i < 2 * n; i++) {
        cout << i + 1 << ' ';
    }
    cout << endl;

    cin >> response;
    return response;
}

string inside_val(int given_pos, int inside, int n) {
    string response;
    cout << "? " << given_pos + 1 << ' ';
    for (int i = inside + 1; i < inside + n; i++) {
        cout << i + 1 << ' ';
    }
    cout << endl;

    cin >> response;
    return response;
}

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

    string to_search = f(0, n);
    string balls(2 * n, 'R');
    
    int left = 0, right = n - 1, middle, val = 0;
    while (left <= right) {
        middle = left + (right - left) / 2;
        if (f(middle, n) == to_search) {
            val = middle;
            left = middle + 1;
        }
        else {
            right = middle - 1;
        }
    }

    if (to_search[0] == 'R') {
        balls[val] = 'R';
        balls[val + n] = 'B';
    }
    else {
        balls[val] = 'B';
        balls[val + n] = 'R';
    }

    for (int i = 0; i < val; i++) {
        balls[i] = inside_val(i, val, n)[0];
    }
    for (int i = val + 1; i < val + n; i++) {
        balls[i] = jump_val(i, val, n)[0];
    }
    for (int i = val + n + 1; i < 2 * n; i++) {
        balls[i] = inside_val(i, val, n)[0];
    }

    cout << "! " << balls << endl;
    return 0;
}

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

int main(){
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  for(int i = 0; i < n; i++){
    cout << s[i];
  }
  cout << endl;
}



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

int main()
{
	ll h,w,n;
	cin >> h >> w >> n;
	map<pair<ll,ll>,ll> cnt;
	for(ll i = 0;i<n;i++)
	{
		ll x,y;
		cin >> x >> y;
		x--;y--;
		for(ll j = -1;j<=1;j++)
			for(ll k = -1;k<=1;k++)
			{
				cnt[make_pair(x+j,y+k)]++;
			}
	}
	vector<ll> ans(10);
	ll zero = h*w - h*2 - w*2+4;
	for(auto &i:cnt)
	{
		if(i.first.first>0&&i.first.first<h-1&&i.first.second>0&&i.first.second<w-1&&i.second>0)
		{
			ans[i.second]++;
			zero--;
		}
	}
	cout<<zero<<endl;
	for(ll i = 1;i<10;i++)cout<<ans[i]<<endl;

}


Measured memory_bytes: 59820
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long[] I = new long[N];
        long[] J = new long[N];

        HashMap<Long, Long> Jmap = new HashMap<>();

        for(int i = 0 ; i < N ; i++){
            A[i] = sc.nextInt();
            I[i] = A[i]+i+1;
            J[i] = i+1-A[i];

            if(Jmap.containsKey(J[i])){
                Jmap.put(J[i], Jmap.get(J[i])+1);
            }else{
                Jmap.put(J[i], (long)1);
            }
        }

        long ans = 0;
        for(int i = 0 ; i < N ; i++){
            Jmap.put(J[i], Jmap.get(J[i])-1);
            if(Jmap.containsKey(I[i])){
                ans += Jmap.get(I[i]);
            }
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 75380
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 25 18:33:18 2020

@author: Paras
"""

X = int(input())
if X>=1800:
    print("1")
elif X>=1600:
    print("2")
elif X>=1400:
    print("3")
elif X>=1200:
    print("4")
elif X>=1000:
    print("5")
elif X>=800:
    print("6")
elif X>=600:
    print("7")
elif X>=400:
    print("8")


Measured memory_bytes: 9192
s = input()
k = int(input())

k_sub = []
for l in range(1,k+1):
  for i in range(len(s)):
    if i+l<=len(s):
      k_sub.append(s[i:i+l])
    else:
      break
k_sub = sorted(list(set(k_sub)))
print(k_sub[k-1])

Measured memory_bytes: 5068
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long INT;
double PI = 3.14159265;

const long long INF = 1LL << 60;
//---//


int main() {
    int n, x, y, half, k[2010] = {},dis;

    cin >> n >> x >> y;

    for (int i = 2; i <= n; i++)for (int j = 1; j<i;j++) {
        dis = min(1 + abs(i - y) + abs(x - j), i - j);
        k[dis-1]++;
    }

    rep(i, n-1)cout << k[i] << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLongList()
    val devisor = devisor(m)
    var ans = 0L
    for (d in devisor) {
        if (d * n <= m) {
            ans = Math.max(ans, d)
        }
    }
    println(ans)
}

/**
O(n^(1/2)) // n * n <= Long.MAX_VALUE n <= 10^8 or more
約数列挙
 */
fun devisor(n: Long): List<Long> {
    val devisor = mutableListOf<Long>()
    var i = 1L
    while (i * i <= n) {
        if (n % i == 0L) {
            devisor.add(i)
            if (i * i != n) { devisor.add(n / i) }
        }
        i++
    }
    devisor.sort()
    return devisor
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 38004
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair

using namespace std;

const int Maxn = 100010;

int n, m, ed[Maxn], fa[Maxn], siz[Maxn], color[Maxn], cnt[3], vis[Maxn];

int fg;

vector<int> edge[Maxn], back[Maxn];

int find(int x) {
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

void unit(int x, int y) {
	x = find(x), y = find(y);
	if(x == y) return;
	siz[y] += siz[x];
	ed[y] += ed[x];
	fa[x] = y;
}

void dfs(int u, int co) {
	vis[u] = 1; color[u] = co; cnt[co]++;
	for(int it = 0; it < edge[u].size(); ++it) {
		if(!vis[edge[u][it]]) {
			dfs(edge[u][it], (co+1)%3);
		} else {
			if((co+1)%3 != color[edge[u][it]]) fg = 1;
		}
	}
	for(int it = 0; it < back[u].size(); ++it) {
		if(!vis[back[u][it]]) {
			dfs(back[u][it], (co+2)%3);
		} else {
			if((co+2)%3 != color[back[u][it]]) fg = 1;
		}
	}
}

long long ans;

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i)
		fa[i] = i, siz[i] = 1;
	for(int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		edge[u].pb(v);
		back[v].pb(u);
		unit(u, v);
		ed[find(u)]++;
	}
	for(int i = 1; i <= n; ++i)
		if(find(i) == i) {
			memset(cnt, 0, sizeof cnt);
			fg = 0;
			dfs(i, 0);
			if(fg) ans += 1ll*siz[i]*siz[i];
			else if(cnt[0] && cnt[1] && cnt[2]) {
				ans += 1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[0]*cnt[2];
			} else {
				ans += ed[i];
			}
		}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 19456
n,m = map(int,input().split())

mod = 10**9 + 7

if abs(n-m) >= 2:
    print(0)
else:
    dog = 1
    mon = 1
    
    for i in range(n,0,-1):
        dog *= i
        dog %= mod
        
    for i in range(m,0,-1):
        mon *= i 
        mon %= mod
        
    if abs(n-m) == 0:
        print(dog*mon*2%mod)
    else:
        print(dog*mon%mod)

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int h,w;
vector<vector<ll>> ma;

struct POS{
    int y;
    int x;
};

int ydir[]={ 1, 0,-1, 0};
int xdir[]={ 0, 1, 0,-1};

int main(){
    cin>>h>>w;
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    POS c={a,b};
    cin>>a>>b;
    a--;
    b--;
    POS d={a,b};
    string s;
    ma.resize(h,vector<ll> (w,-1));
    rep(i,h){ 
        cin>>s;
        rep(j,w){
            if(s[j]=='#') ma[i][j]=-2;
        }
    }
    queue<POS> q;
    q.push(c);
    ma[c.y][c.x]=0;
    while(!q.empty()){
        POS now=q.front();
        q.pop();
        bool wall=false;
        ll nowma=ma[now.y][now.x];
//        if(now.y==d.y && now.x==d.x) break;
        rep(i,4){
            POS nex={now.y+ydir[i],now.x+xdir[i]};
            if(nex.y<0 || nex.y>=h || nex.x<0 || nex.x>=w) continue;
            if(ma[nex.y][nex.x]==-1 || ma[nex.y][nex.x]>nowma){ 
                ma[nex.y][nex.x]=nowma;
                q.push(nex);
            }
            if(ma[nex.y][nex.x]==-2) wall=true;
        }
        if(wall){
            for(int i=-2;i<=2;i++){
                for(int j=-2;j<=2;j++){
                    POS nex={now.y+i,now.x+j};
                    if(nex.y<0 || nex.y>=h || nex.x<0 || nex.x>=w) continue;
                    if(ma[nex.y][nex.x]==-1 || ma[nex.y][nex.x]>nowma+1){
                        ma[nex.y][nex.x]=nowma+1;
                        q.push(nex);
                    }
                }
            }
        }
    }
    // rep(i,h){
    //     rep(j,w){
    //         cout<<ma[i][j];
    //     }
    //     cout<<endl;
    // }
    cout<<ma[d.y][d.x]<<endl;
    return 0;
}

Measured memory_bytes: 11576
import math
N=int(input())
numbers=[]
for a in range(N-1):
    list=[]
    C,S,F=input().split()
    list.append(int(C))
    list.append(int(S))
    list.append(int(F))
    numbers.append(list)
if N==1:
    print(0)
elif N==2:
    print(numbers[0][0]+numbers[0][1])
    print(0)
else:
    for a in range(N - 1):
        b = numbers[a][0] + numbers[a][1]
        while a < N - 2:
            if b>=numbers[a+1][1]:
                c = b - numbers[a + 1][1]
                d =math.ceil (c / numbers[a + 1][2])
                e = numbers[a + 1][1] + numbers[a + 1][2] * d
                b = e + numbers[a + 1][0]
            else:
                b=numbers[a+1][1]+numbers[a+1][0]
            a+=1
        print(round(b))
    print(0)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,x;
	cin>>a>>b>>x;
	if(a*a*b>=x*2){
		double r=x*2.0/a/b;
		double ans=atan(b/r)*180/PI;
		fcout(10)<<ans<<endl;
	}else{
		x=a*a*b-x;
		double r=x*2.0/a/a;
		double ans=90-atan(a/r)*180/PI;
		fcout(10)<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <set>

using namespace std;

int main() {
    set<int> set;
    int n,q;
    int count = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        int s;
        cin >> s;
        set.insert(s);
    }
    cin >> q;
    for(int i = 0;i < q;i++){
        int t;
        cin >> t;
        for(int a : set){
            if(a == t)count++;
        }
    }
    cout << count << endl;
    return 0;
};


Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int ans = 0;
        int[] input = ReadInts();
        int N = input[0];
        int K = input[1];
        string S = Read();
        List<int> nums = new List<int>();
        int i = 0, sum0 = 0,sum1 = 0,max = 0;
        while (i < N && S[i] == '1')
        {
            i++;
            sum1++;
        }
        max += sum1;
        while (i < N)
        {
            while (i < N && S[i] == '0')
            {
                i++;
                sum0++;
            }
            nums.Add(sum0 + sum1);
            max += sum0;
            sum0 = 0;
            sum1 = 0;
            while (i < N && S[i] == '1')
            {
                i++;
                sum1++;
            }
            max += sum1;
            if (nums.Count > K)
            {
                max -= nums[0];
                nums.RemoveAt(0);
            }
            ans = Math.Max(ans, max);
        }
        ans = Math.Max(ans, max);
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1; i<=n; i++)
        ans+=(ll)i*(n-i+1);
    for(ll i=1; i<=n-1; i++){
        ll u, v;
        cin >> u >> v;
        if(u>v)
            swap(u, v);
        ans-=(ll)u*(n-v+1);
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
int main(void){

 int x[3000];
 int y[3000];
 int n,i;
 
 i = 0;
 while(1){
  scanf("%d%d",&x[i],&y[i]);
  if(x[i]==0 && y[i]==0){
   break;
  }
  i++;
 }
 n=i;

for(i=0;i<n;i++){
if(x[i]<y[i]){
printf("%d %d\n",x[i],y[i]);
}else{
printf("%d %d\n",y[i],x[i]);
}

}


 return 0;

}

Measured memory_bytes: 1744
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(void){
  int N;
  cin >> N;
  int C[N-1], S[N-1], F[N-1];
  rep(i, N-1)
    cin >> C[i] >> S[i] >> F[i];
  //入力終わり

  //各駅スタート
  rep(i, N-1){
    int now = i;
    //時刻を更新していく
    int time = S[i]+C[i];
    //駅iから先を見ていく
    for(int j=i+1; j<N-1; j++){
      //到着時刻が，駅jの最初の出発時刻より先だったとき
      if(time < S[j])
	//最初の出発時刻まで待ってから出発
	time += (S[j] - time) + C[j];
      //到着時刻が，駅jの最初の出発時刻より後だったとき
      else{
	//待ち時間なし
	if(time % F[j] == 0)
	  time += C[j];
	//待ち時間あり
	else
	  time += F[j] - (time%F[j]) + C[j];
      }
    }
    //解答
    cout << time << endl;
  }

  
  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>

constexpr int ALPHA_SIZE = 'z' - 'a' + 1;
using datum = std::array<int, ALPHA_SIZE>;
std::vector<datum> S;
constexpr int MAX_SIZE = 10;
char str[MAX_SIZE+10];

int main(void){
    int n; scanf("%d", &n);
    S.resize(n);
    for(int i = 0; i < n; ++i){
        std::fill(S[i].begin(), S[i].end(), 0);
        scanf("%s", str);
        for(int j = 0; j < MAX_SIZE; ++j) S[i][str[j]-'a']++;
    }
    std::sort(S.begin(), S.end());
    long long int res = 0;
    int i;
    while(i < n){
        long long int cnt = 0;
        while(i+cnt < n and S[i] == S[i+cnt]) cnt++;
        i += cnt;
        res += cnt * (cnt-1) / 2;
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n>=1800){
		cout<<1<<endl;
	}else if(n>=1600){
		cout<<2<<endl;
	}else if(n>=1400){
		cout<<3<<endl;
	}else if(n>=1200){
		cout<<4<<endl;
	}else if(n>=1000){
		cout<<5<<endl;
	}else if(n>=800){
		cout<<6<<endl;
	}else if(n>=600){
		cout<<7<<endl;
	}else if(n>=400){
		cout<<8<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
long long min(long long x,long long y){
    if(x<y) return x;
    else return y;
}
int main(void){
    long long a,b,n;
    scanf("%lld%lld%lld",&n,&a,&b);
    if(a!=0) printf("%lld",a*(n/(a+b))+min(a,(n%(a+b))));
    else printf("0");
}

Measured memory_bytes: 128
n,s = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if n>1:
    dif = []
    for i in range(n-1):
        dif.append(x[i+1]-x[i])

    difs = []
    for i in range(n):
        difs.append(abs(s-x[i]))
    res = min(min(dif),min(difs))
    for i in range(res):
        flag = True
        for j in range(n-1):
            if dif[j]%(res-i)!=0:
                flag = False
                break
        if flag:
            res -= i
            break
                
    print(res)
else:
    print(abs(x[0]-s))

Measured memory_bytes: 15020
//
// Created by sark2 on 14-01-2020.
//

#include "bits/stdc++.h"

using namespace std;
#define pb push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)

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

const int mod = 1e9 + 7;

const int N = 1e5+10;


int main() {
    IOS


    string s, t;
    cin>>s>>t;

    int a, b;
    cin>>a>>b;

    string u;
    cin>>u;

    if(u == s)
        cout<<a-1<<" "<<b;
    else
        cout<<a<<" "<<b-1;



}


Measured memory_bytes: 256