akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    string S; int K; cin >> S >> K;

    using pi = pair<string, int>;
    priority_queue<pi, vector<pi>, greater<pi>> pq;
    REP(i, 0, S.size()) {
        string s{S[i]};
        pq.push({s, i});
    }

    set<string> ans;
    while ((int)ans.size() < K && !pq.empty()) {
        auto q = pq.top(); pq.pop();
        // cout << "# " << q.first << " : " << q.second << endl;
        ans.insert(q.first);
        if (q.second < (int)S.size() - 1) pq.push({q.first + S[q.second + 1], q.second + 1});
    }

    cout << *ans.rbegin() << endl;

    return 0;
}

Measured memory_bytes: 3720
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#ifdef LOCAL
mt19937 rng(unsigned(70));
#else
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
#define rand rng


int main() {
	// fios;
	int k;
	string s;
	cin >> k>> s;
	if((int)s.length() <= k) cout << s << endl;
	else {
		for(int i = 0; i < k; i++) cout << s[i];
		cout << "..." << endl;
	}

}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")

typedef long long ll;
typedef unsigned long long ull;
// typedef __int128_t lll;
#define fatnet ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

const ll MOD1 = 1e9 + 7;
const ll MOD2 = 2000003983; // 3571 1e9 + 97
const ll MOD3 = 1e9 + 9;
const ll p1 = 1e6 + 3;
const ll p2 = 2017; // 131 37
const ll p3 = 37;
const ll INF = 5e18;

int main() {
    fatnet;

    ll n;
    cin >> n;
    vector < ll > a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[n / 2] - a[n / 2 - 1] << "\n";

    return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	lli n, m, i, j, ans;
	vector<lli>a, s;

	cin >> n >> m;

	SIZE(a, m);
	SIZE(s, pow(10, 5)+1);
	rep(i, m) {
		cin >> a[i];
	}

	s[0] = 1;
	s[1] = 1;
	s[2] = 2;
	repj(i,3, pow(10, 5)+1) {
		s[i] = (s[i - 1] + s[i - 2]) % 1000000007;
	}
	j = 0;
	ans = 1;
	rep(i, m) {
		if (a[i]==j) {
			cout << 0;
			return 0;
		}
		ans *= s[a[i] - j - 1];
		ans %= 1000000007;
		j = a[i] + 1;
	}
	ans *= s[n - j];
	ans %= 1000000007;

	cout << ans;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define DEB 0

/*
real	0m2.093s  --> 
real	0m2.000s
*/
const int dx[] = {1,0,-1,0}; //r,d,l,u
const int dy[] = {0,1,0,-1};

int w,h,sx,sy,home,last;
int field[16][16];
int num[16][16];
int hS[25],hx[25],hy[25],edge[25][4][25]; //[src][dir][dest]
map<int,int> msi;

inline bool isnotgoal(int s){
  return (((last&s)) == last);
}
inline bool isnot(int s){
  rep(i,home)if( !(s&(1<<i)) ){
    if( (hS[i]&s)==hS[i] ) return true;
  }
  return false;
}
inline bool inside(int x, int y){
  return (x<0 || y<0 || x>=w || y>=h);
}

int dfs(int S){
  int src = S&((1<<5)-1);
  int x = hx[src];
  int y = hy[src];
  int s = S>>5;

  if( (1<<home)-1 == s ){ //âÎÉßêé
    return 1;
  }
  if( isnotgoal(s) ){ //³ïÉßé½ßÌÆðÁïµ½©Ç¤©
    return 0;
  }
#if DEB
  puts("hoyo");
#endif
  map<int,int>::iterator it = msi.lower_bound(S);
#if DEB
  puts("hoyo2");
#endif

  if( it!=msi.end() && it->first == S ){ //ùÉÊÁ½óÔ
    return it->second;
  }

#if DEB
  printf("src:%d x:%d y:%d s:%d\n",src,x,y,s);
#endif
  
  // v[gªu¯È¢ÆÌL³
  /*
    1831764
    ari  :: msi_sz: 885661  >0:376369  ==0:509292  already>0:222390 , already==0:408636
    nari :: msi_sz:1028771  >0:376369  ==0:652402  already>0:222390 , already==0:565310
   */
  
  if( s>0 && ((s&(s-1))!=0) && isnot(s&~(1<<src)) ){
    return 0;
  }
  
  
  int ret = 0;
  rep(k,4){
    for(int j=0; edge[src][k][j]!=-1; j++){
      int dest = edge[src][k][j];
      int nx = hx[dest];
      int ny = hy[dest];
      if( field[ny][nx]==1 ){
	field[ny][nx] = 0;
	ret += dfs(((s|(1<<dest))<<5)|dest);
	field[ny][nx] = 1;
	break;
      }
    }
  }
  if( it!=msi.end() )--it;
  msi.insert(it, make_pair(S,ret));
  return ret;
}

int main(){

  while(scanf("%d%d",&w,&h),w|h){
    msi.clear();
    memset(num,-1,sizeof(num));
    memset(edge,-1,sizeof(edge));
    memset(hS,0,sizeof(hS));
    home = last = 0;
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i][j]);
	if( field[i][j]==2 ){
	  sx=j; sy=i;
	}
	if( field[i][j]==1 ){
	  hx[home]=j; hy[home]=i;
	  num[i][j] = home;
	  home++;
	}
      }
    }
    hx[home] = sx;
    hy[home] = sy;

    // other homes
    rep(i,home){
      rep(k,4){
	int sz = 0;
	for(int j=1; j<20; j++){
	  int tx = hx[i] + dx[k]*j;
	  int ty = hy[i] + dy[k]*j;
	  if( inside(tx,ty) ) break;
	  if( field[ty][tx]==1 ){
	    hS[i] |= (1<<num[ty][tx]);
	    edge[i][k][sz++] = num[ty][tx];
	  }
	}
      }
    }

    //last homes
    rep(k,4){
      int sz = 0;
      for(int i=1; i<20; i++){
	int tx = sx + dx[k]*i;
	int ty = sy + dy[k]*i;
	if( inside(tx,ty) )break;
	if( field[ty][tx]==1 ){
	  last |= (1<<num[ty][tx]);
	  edge[home][k][sz++] = num[ty][tx];
	}
      }
    }
    printf("%d\n",dfs(home));
  }
  

  return 0;
}

Measured memory_bytes: 27000
import heapq
N = int( input())
A = [ list( map( int, input().split())) for _ in range(N)]
Q = []
for i in range(N-1):
    for j in range(i+1,N):
        heapq.heappush(Q, [A[i][j],i,j])
WF = [ [10**9+1]*N for _ in range(N)]
for i in range(N):
    WF[i][i] = 0
cnt = 0
while Q:
    a, s, g = heapq.heappop(Q)
    addcheck = 1
    for i in range(N):
        if i == s or i == g:
            continue
        else:
            if WF[s][i] + WF[i][g] == a:
                addcheck = 0
            elif WF[s][i] + WF[i][g] < a:
                 break
    else:
        WF[s][g] = a
        WF[g][s] = a
        if addcheck:
            cnt += a
        continue
    print(-1)
    break
else:
    print( cnt)

Measured memory_bytes: 53980
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
xr = max(x)
yl = min(y)

for i in range(X+1,Y+1):
    if(xr < i <= yl):
        print('No War')
        exit()

print('War')

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  
  int k = 1;
  for (int i = 0; i < N; i++) {
    k *= 3;
  }
  
  int pos = 1;
  for (int &e : A) {
    cin >> e;
    if (e % 2 == 0) pos *= 2;
  }
  
  cout << k - pos << endl;
}

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

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

    int n = s.size();
    int m = t.size();
    vector<vector<int>> a(26);
    for (int i = 0; i < n; i++) {
        int itr = s[i] - 'a';
        a[itr].push_back(i);
    }

    ll ans = 0;
    ll rep = 0;
    ll cur = -1;
    bool flag = true;
    for (int i = 0; i < m; i++) {
        int id = t[i] - 'a';
        if(a[id].empty()) {
            flag = false;
            break;
        }

        int nxt = upper_bound(a[id].begin(), a[id].end(), cur) - a[id].begin();
        if(nxt == a[id].size()) {
            cur = a[id][0];
            rep++;
        } else {
            cur = a[id][nxt];
        }
    }
    if(!flag) {
        cout << -1 << '\n';
        return 0;
    }
    ans = n * rep + cur + 1;
    cout << ans << '\n';
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353 
#define pb push_back
#define mb make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
	IOS;
	int n; cin >> n;
	int inp[n][3];
	for(int i=0;i<n;i++)
		cin >> inp[i][0] >> inp[i][1] >> inp[i][2] ;
	
	int dp[3][n];
	dp[0][0]=inp[0][0];
	dp[1][0]=inp[0][1];
	dp[2][0]=inp[0][2];
	for(int i=1;i<n;i++){
		// int mx = INT_MIN;
		dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + inp[i][0];
		dp[1][i] = max(dp[0][i-1],dp[2][i-1]) + inp[i][1];
		dp[2][i] = max(dp[0][i-1],dp[1][i-1]) + inp[i][2];
		// cout << dp[0][i] << " " << dp[1][i] << " " << dp[2][i] << endl;
	}
	cout << max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));


	return 0;
}




Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
char ten[6][8];
void tr(char*a){
  char st=a[0];
  a[0]=a[2];
  a[2]=a[3];
  a[3]=a[1];
  a[1]=st;
}
void spin(char *a,char*b,char *c,char*d,int aa,int aaa,int bb,int bbb,int cc,int ccc,int dd,int ddd,char*t){
  tr(t);
  char st1=a[aa];
  char st2=a[aaa];
  a[aa]=b[bb];
  a[aaa]=b[bbb];
  b[bb]=c[cc];
  b[bbb]=c[ccc];
  c[cc]=d[dd];
  c[ccc]=d[ddd];
  d[dd]=st1;
  d[ddd]=st2;
}


void mkten(char*b,int x,int y){
  ten[x][y]=b[0];
  ten[x][y+1]=b[1];
  ten[x+1][y]=b[2];
  ten[x+1][y+1]=b[3];
}
void sy(char*a,char c){
  for(int i=0;i<4;i++){
    a[i]=c;
  }
}

  
int main(){
  for(int i=0;i<6;i++){
    for(int j=0;j<8;j++){
      ten[i][j]='.';
    }

  }
  char fr[4];
  char up[4];
  char dow[4];
  char le[4];
  char ri[4];
  char ba[4];
  sy(fr,'y');
  sy(up,'r');
  sy(ri,'b');
  sy(dow,'o');
  sy(le,'g');
  sy(ba,'w');
  string a;
  cin >> a;
  for(int i=0;i<a.size();i++){
    if(a[i]=='R')spin(fr,dow,ba,up,1,3,1,3,2,0,1,3,ri);
    else if(a[i]=='F')spin(up,le,dow,ri,2,3,3,1,1,0,0,2,fr);
    else if(a[i]=='U')spin(ba,le,fr,ri,0,1,0,1,0,1,0,1,up);
    else if(a[i]=='D')spin(fr,le,ba,ri,2,3,2,3,2,3,2,3,dow);
    else if(a[i]=='L')spin(up,ba,dow,fr,0,2,3,1,0,2,0,2,le);
    else spin(up,ri,dow,le,0,1,1,3,3,2,2,0,ba);


  }
  mkten(fr,2,2);
  mkten(le,2,0);
  mkten(up,0,2);
  mkten(ri,2,4);
  mkten(ba,2,6);
  mkten(dow,4,2);
  for(int i=0;i<6;i++){
    for(int j=0;j<8;j++){
      cout << ten[i][j];
    }
    cout << endl;
  }
  return 0;
}

    
  

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
using namespace std;

int main() {
    int n, k;
    scan2Int(n, k);
    int i = 1;
    for (; n != 0; ++i) {
        n -= n % (int) pow(k, i);
    }
    printInt(i - 1);
    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long L, std::vector<std::string> S){
    sort(ALL(S));
    REP(i, N) {
        cout << S[i];
    }

    cout << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, L, std::move(S));
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define PB push_back
#define MP make_pair
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define INF (1 << 28)
#define LLINF (1LL << 60)
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n;
    ll ans=0;
    cin>>n;
    for(int i=1;i<n;i++){
        ans+=n/i;
        if(n%i==0){
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll tableF[200010];
ll tableI[200010];

ll modfact(ll a,ll m){
   if(tableF[a] != -1){
      return tableF[a];
   }
   if(a == 1){
      tableF[a] = 1;
      return tableF[a];
   }
   ll res = 1;
   res = a * modfact(a-1,m);
   res %= m;
   tableF[a] = res;
   return res;
}

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   if(n < 200010){
   ll res = 1;
   if(n < 0 || r < 0 || r > n){
     return 0;
   }
   res *= tableF[n];
   res %= m;
   res *= tableI[r];
   res %= m;
   res *= tableI[n-r];
   res %= m;
   return res;
   }else{
   ll res = 1;//tableを持ってないときよう
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
   }
}

void modfill(ll m){//忘れない　約300ms
   fill(tableF,tableF+200010,-1);
   fill(tableI,tableI+200010,-1);
   tableF[0] = 1;
   tableI[0] = 1;
   for(int i = 1;i < 200010;i++){
      tableF[i] = modfact(i,m);
      tableI[i] = modinv(tableF[i],m);
   }
}


int main(){
  ll N;cin >> N;
  vector<ll> A(N+1);
  vector<bool> frag(N+1,0);
  ll num = 0,l = 0,r = 0;
  for(int i = 0;i < N+1;i++){
    cin >> A[i];
    if(frag[A[i]]){
      num = A[i];
      r = i;
    }
    frag[A[i]] = 1;
  }
  for(int i = 0;i < N+1;i++){
    if(A[i] == num){
      l = i;
      break;
    }
  }
  r = N-r;
  modfill(MOD);
  for(int i = 1;i <= N+1;i++){
    if(modCON(N+1,i,MOD) - modCON(l+r,i-1,MOD) < 0){
      cout << modCON(N+1,i,MOD) - modCON(l+r,i-1,MOD) + MOD << endl;
    }else{
      cout << modCON(N+1,i,MOD) - modCON(l+r,i-1,MOD)<< endl;
    }
  }
}

Measured memory_bytes: 5120
/* 
 * Project: NOMURA Programing Contest A - Study Scheduling
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/30
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cmath>
using namespace std;

int h1;
int h2;
int m1;
int m2;
int k;

void solve() {
    int wake_time = 0;
    wake_time = h2*60 + m2 - (h1 *60 + m1);

    printf("%d\n", wake_time - k);
}

int main() {

    scanf("%d", &h1);
    scanf("%d", &m1);
    scanf("%d", &h2);
    scanf("%d", &m2);
    scanf("%d", &k);

    solve();

}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;

int main()
{  fast
int n;
string s;
cin>>n>>s;
if(s.size()>n)
{
	cout<<s.substr(0,n)<<"...";
}else
cout<<s;




}

Measured memory_bytes: 3680
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        if (s.length() > k) {
            s = s.substring(0, k) + "...";
        }

        System.out.println(s);
    }
}


Measured memory_bytes: 38680
from copy import deepcopy


def calc_key_str(aps_S, T):
    S = deepcopy(aps_S)

    for i in range(len(aps_S) - len(T) + 1):
        matched_flag = True
        for j in range(len(T)):
            if aps_S[-i-j-1] != T[-j-1] and aps_S[-i-j-1] != '?':
                matched_flag = False
                continue

        if matched_flag:
            S_list = list(S)
            S_list[-i-len(T):len(S)-i] = T
            S = "".join(S_list)
            S = S.replace('?', 'a')
            print(S)
            break

    if not matched_flag:
        print('UNRESTORABLE')


def main():
    aps_S = input()
    T = input()

    if len(aps_S) < len(T):
        print('UNRESTORABLE')
    else:
        calc_key_str(aps_S, T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
program main
  implicit none
  
  integer :: n,a,b,i,j,chk=0
  
  read(*,*)n
  
  a = ceiling(real(n)/4.)
  b = ceiling(real(n)/7.)
  
  do i = 0, a
    do j = 0, b
      if (n == (i*4 + j*7)) then
        write(*,*)'Yes'
        stop
      end if
    end do
  end do
  
  write(*,*)'No'
end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define int long
signed main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;

  int t=100*a,u=0;

  rep(i,31)rep(j,31){
    if(100*a*i+100*b*j > f) continue;
    int cap = min(e*(a*i+b*j), f-100*(a*i+b*j));
    for(int k=0; k<=cap; k+=c){
      int dd = (cap-k)/d;
      dd *= d;
      int tot = 100*a*i+100*b*j+k+dd;
      if(tot > f) continue;
      if(tot*u < (k+dd)*t){
        t = tot;
        u = k+dd;
      }
    }
  }

  assert(t!=0);
  cout << t << " " << u << endl;

  return 0;
}


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

dp = [10**9 for _ in range(N+1)] # 0円からN円までのリスト
dp[0] = 0

for i in range(1, N+1): # i円払う最小手数を入れる
    dp[i] = min(dp[i], dp[i-1] + 1)

    power_6 = 6
    while i >= power_6:
        dp[i] = min(dp[i], dp[i-power_6] + 1)
        power_6 *= 6

    power_9 = 9
    while i >= power_9:
        dp[i] = min(dp[i], dp[i-power_9] + 1)
        power_9 *= 9

ans = dp[N]
print(ans)


Measured memory_bytes: 3864
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

const int MAX = 2000000 ;
int sz ;

class SGT{
public :
	int n ;
	int num[MAX] ;

	void init(string &s,char c){
		n = sz ;
		for(int i=0;i<n;i++){
			if(i<s.size()) num[n-1+i] = (s.at(i)==c) ;
			else num[n-1+i] = 0 ;
		}
		for(int i=n-2;i>=0;i--){
			num[i] = num[i*2+1]+num[i*2+2] ;
		}
	}

	void update(int i,int a){
		i += n-1 ;
		num[i] = a ;
		while(i>0){
			i = (i-1)/2 ;
			num[i] = num[i*2+1]+num[i*2+2] ;
		}
	}

	int query(int a,int b,int l,int r,int now){
		if(r<=a||b<=l) return 0 ;
		if(a<=l&&r<=b) return num[now] ;
		ll r1 = query(a,b,l,(l+r)/2,now*2+1) ;
		ll r2 = query(a,b,(l+r)/2,r,now*2+2) ;
		return r1+r2 ;
	}
};

int main(){
	int n ; cin >> n ;
	string s ; cin >> s ;
	int q ; cin >> q ;
	vector<SGT> sgt(26) ;
	sz = 1 ;
	while(sz<s.size()) sz *= 2 ;
	for(int i=0;i<26;i++){
		sgt.at(i).init(s,'a'+i) ;
	}
	for(int i=0;i<q;i++){
		int a ; cin >> a ;
		if(a==1){
			int b ; cin >> b ;
			char c ; cin >> c ;
			b-- ;
			sgt.at(s.at(b)-'a').update(b,0) ;
			sgt.at(c-'a').update(b,1) ;
			s.at(b) = c ;
		}else{
			int l,r ;
			cin >> l >> r ;
			l-- ; r-- ;
			ll cnt = 0 ;
			for(int i=0;i<26;i++){
				cnt += (sgt.at(i).query(l,r+1,0,sgt.at(i).n,0)>0) ;
			}
			cout << cnt << endl ;
		}
	}
}


Measured memory_bytes: 211844
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B, C = get_ints

sum = A + B + C
stock = [A, B, C].max * 3

waru = (stock - sum)/2
amari = (stock - sum) % 2

puts waru + (amari == 1 ? 2 : 0)


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

int main(){

    int l;
    cin >> l;
    
    cout << setprecision(8) << (double)l*l*l/27 << endl;
    return 0;
}




Measured memory_bytes: 256
n,m,c=map(int,input().split())
base = list(map(int,input().split()))
x=[list(map(int, input().split())) for i in range(n)]
ans=0
cnt=0
for i in range(n):
    cnt=0
    for k in range(m):
        cnt+=base[k]*x[i][k]
    cnt+=c
    if cnt>0:
        ans+=1
    #←これがないとWAになるにゃ
print(ans)

Measured memory_bytes: 62172
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Coer
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] h = new int[n + 1];
            for (int i = 1; i < n + 1; i++) {
                h[i] = in.nextInt();
            }
            int[] dp = new int[n + 1];
            dp[1] = 0;
            dp[2] = Math.abs(h[1] - h[2]);
            for (int i = 3; i < n + 1; i++) {
                dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
            }
            out.println(dp[n]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 31768
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int a[2010]={0};
long long int b[2010][2010]={0};
int main()
{   long long int n,x,i,j,sum,minx,temp;
    scanf("%lld %lld",&n,&x);
 
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(i=1;i<=n;i++){
        b[i][0]=a[i];
        for(j=1;j<n;j++){
            temp=i-j;
            if(temp<=0)
                temp=n+temp;
            b[i][j]=min(b[i][j-1],a[temp]);  
        }
    }
    minx=0x3f3f3f3f3f3f3f3f;
    for(i=0;i<n;i++){
        sum=0;
        for(j=1;j<=n;j++)
            sum+=b[j][i];
        sum+=i*x;
        minx=min(sum,minx);
    }
    printf("%lld\n",minx);
    return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define msi map<string,int>
#define si set<int>
#define all(v) v.begin(),v.end()
#define sz(v)  int((v).size())
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define dep(i,a,b)    for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mp make_pair
#define    endl '\n'

using namespace std;
void solve()
{
    int n;
    cin>>n;
    int a[n];
    set<int> s;
    map<int,int> m;
    rep(i,0,n)
    {
        cin>>a[i];
        s.insert(a[i]);
        m[a[i]]++;
    }
    int ans=0;
    for(set<int> :: iterator it=s.begin();it!=s.end();++it)
    {
        ans+=(m[*it]*(m[*it]-1))/2;
    }
    rep(i,0,n)
    {
        cout<<ans-(m[a[i]]*(m[a[i]]-1))/2 + ((m[a[i]]-1)*(m[a[i]]-2))/2<<endl;
    }
} 



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

Measured memory_bytes: 18176
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  int n, k, x, y;
  cin >> n >> k >> x >> y;

  if( n <= k ) cout << x * n << endl;
  else cout << (x * k) + (y * (n - k)) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n;
    char A[n][n], B[n][n];

    rep(i, n) {
        rep(j, n) {
            cin >> A[i][j];
        }
    }

    rep(_, n) {
        rep(i, n) {
            rep(j, n) {
                B[i][j] = A[i][(j + _) % n];
            }
        }

        k = 1;
        rep(i, n) {
            rep(j, i) {
                if (B[i][j] != B[j][i])k = 0;
            }
        }

        ans += k;
    }

    cout << ans * n << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	int n ;
	scanf("%d", &n) ;
	
	cout << (n + 1) / 2 << endl ;

	return 0 ;
}

Measured memory_bytes: 3224
/*
 * ID: ITP1_2_D
 * Problem: Circle in a Rectangle
 */

#include <stdio.h>

int main(void)
{
    int W, H, x, y, r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if (x - r < 0 || y - r < 0 || x + r > W || y + r > H)
        printf("No\n");
    else
        printf("Yes\n");
    
    return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int left=0,right=0,x=0;
    for(int i=0;i<n;i++){
        if(s[i]==')')x++;
        else x--;
        left=max(left,x);
    }
    x=0;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='(')x++;
        else x--;
        right=max(right,x);
    }
    for(int i=0;i<left;i++)cout<<'(';
    cout<<s;
    for(int i=0;i<right;i++)cout<<')';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3604
// Gracias, Rodolfo
// Gracias, MarcosK
// Gracias, Graphter
// Obrigado, Dilson
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for (Long i = a; i < b; i++)
#define roF(i,a,b) for (Long i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long Long;
typedef long double Double;
typedef unsigned long long ULong;
typedef pair<Long, Long> Pair;
typedef vector<Long> Vector;
typedef vector<Pair> PairVector;

const int N = 1e5 + 10;
const Long INF = 1e18;
const Double EPS = 10e-9;
const Long MOD = 1e9 + 7LL;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
Long random(Long a, Long b) { return uniform_int_distribution<Long> (a, b) (rng); }

void solve() {
	string s;
	cin >> s;
	Long sz = s.size();
	Long dp[sz][13];
	For(i, 0, sz) For(j, 0, 13) dp[i][j] = 0LL;
	if (s[sz - 1] == '?') {
		For(i, 0, 10) dp[sz - 1][i] = 1LL;
	} else {
		Long c = s[sz - 1] - '0';
		dp[sz - 1][c] = 1LL;
	}
	Long pot = 10LL;
	roF(pos, sz - 2, 0) {
		if (s[pos] == '?') {
			For(i, 0, 10) {
				Long cur = (i * pot) % 13LL;
				For(j, 0, 13) {
					Long to = (cur + j) % 13LL;
					dp[pos][to] = (dp[pos][to] + dp[pos + 1][j]) % MOD;
			//		debug(dp[pos][to]);
				}
			}
		} else {
			Long c = s[pos] - '0';
			Long cur = (c * pot) % 13LL;
			For(j, 0, 13) {
				Long to = (cur + j) % 13LL;
				dp[pos][to] = (dp[pos][to] + dp[pos + 1][j]) % MOD;
			//	debug(dp[pos][to]);
			}
		}
		pot = (pot * 10LL) % 13LL;
	}
	cout << dp[0][5] << endl;
}

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

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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A.at(i);

  long long res = 0, sum = 0, right = 0;
  for (int left = 0; left < N; ++left) {
    while (right < N && ((sum + A[right]) == (sum ^ A[right]))) {
      sum += A[right];
      ++right;
    }
    res += (right - left);
    if (right == left) ++right;
    else sum -= A[left];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(){
	int F, L, count=0;
	scanf("%d %d", &F, &L);
	char add [L+F+2];
	scanf("%s", &add);
	
	for (int i=0; i<F+L+1; i++){
		if (i!=F){
			if (add[i]>=48 && add[i]<=57){
				count++;	
			}	
		} else {
			if (add[i]=='-'){
				count++;
			}
		}
	}
	(count==F+L+1)? (printf("Yes\n")):(printf("No\n"));	
return 0;
}

Measured memory_bytes: 1648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC107_C solver = new ABC107_C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC107_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            long[] map = new long[n];
            long ans = Long.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                map[i] = in.nextLong();
            }

            for (int i = 0; i <= n - k; i++) {
                long cost = 0;
                if (map[i] <= 0 && map[i + k - 1] <= 0) {
                    cost = Math.abs(map[i]);
                    ans = Math.min(ans, cost);
                    continue;
                }

                if (0 <= map[i] && 0 <= map[i + k - 1]) {
                    cost = Math.abs(map[i + k - 1]);
                    ans = Math.min(ans, cost);
                    continue;
                }

                if (map[i] < 0 && 0 < map[i + k - 1]) {
                    cost += Math.max(Math.abs(map[i]), Math.abs(map[i + k - 1]));
                    cost += Math.min(Math.abs(map[i]), Math.abs(map[i + k - 1])) * 2;
                    ans = Math.min(ans, cost);
                    continue;
                }


            }

            out.print(ans);
        }

    }
}



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

using namespace std;

int main()
{
    int A,B,C,N;

    cin >> N;

    A = N/100;
    B = (N-100*A)/10;
    C = N-100*A-10*B;

    if(A!=7 && B!=7 && C!=7){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
# -*- coding:utf-8 -*-
n, m, q = map(int, input().split())
sm = [[0 for x in range(n + 5)] for y in range(n + 5)]

for i, j in (map(int, input().split()) for _ in range(m)):
    sm[i][j] += 1

for i in range(1, n + 1):
    for j in range(i, n + 1):
        sm[i][j] += sm[i][j - 1]
for j in range(n + 1, 0, -1):
    for i in range(j, 0, -1):
        sm[i][j] += sm[i + 1][j]
        
for i, j in (map(int, input().split()) for _ in range(q)):
    print(sm[i][j])


Measured memory_bytes: 9460
// C - Grand Garden
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)

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

	vi H(N);
	rp(i,N)cin>>H[i];

	int V = 0;
	rp(i,N) V+=H[i];

	int E = 0;
	rp(i,N-1) E += min(H[i], H[i+1]);

	cout<< V-E <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  long long a;cin>>a;
  double b;cin >>b;
  long long bl = 100*b+0.0001;
  long long c = (a*bl)/100;
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b){
            System.out.println("a < b");
        }else if(a == b){
            System.out.println("a == b");
        }else{
            System.out.println("a > b");
        }
    }
}


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

using namespace std;

int main()
{
  string s;

  cin >> s;

  bool a[26];

  for (int i = 0; i < 26; i++)
    a[i] = false;

  for (int i = 0; i < s.size(); i++)
    a[s[i] - 'a'] = true;

  bool none = true;

  for (int i = 0; i < 26; i++)
  {
    if (!a[i])
    {
      printf("%c", char(i + 'a'));
      none = false;
      break;
    }
  }

  if (none)
  {
    printf("None");
  }
}


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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define debugs(s) cerr << s << "\n"
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

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

#define fst first
#define snd second
#define pb push_back
#define mk(x,y) make_pair((x),(y))

// http://ehafib.hatenablog.com/entry/2015/12/23/164137
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qpm(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define sz(v) int(v.size())

// x1, x2ライブラリとの被りを避ける
#define x1 x192837465
#define x2 x123456789
#define y1 y192837465
#define y2 y123456789

// typo
#define itn int
#define reutrn return
#define reutnr return

#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    make(int, X);

    if (X == 3 || X == 5 || X == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3588
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
#define MAX_N 500000
struct goods {
	ll val, siz;
};


bool cmp(const goods& a, const goods& b)
{
	return a.siz < b.siz;
}


goods g[MAX_N + 1];
//ll cs[MAX_N + 1];
int main() {
	ll S;
	ll ANS;
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> g[i].siz >> g[i].val;
	}

	/*
	for (int i = 1; i <= N-1; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (g[i].siz > g[j].siz) {
				goods temp;
				temp = g[i];
				g[i] = g[j];
				g[j] = temp;
			}
		}
	}
	*/

	sort(g + 1, g + N + 1, cmp);

	S = g[1].val + g[N].val;
	ANS = S - (g[N].siz - g[1].siz);
//	cs[0] = 0;
//	for (int i = 1; i <= N; i++) {
//		cs[i] = cs[i - 1] + g[i].val;
//	}
	ll SUM = 0;
	ll MIN = 0xffffffffffff;
	for (int i = 1; i <= N; i++) {
		SUM = SUM + g[i].val;
		if (SUM - g[i].val - g[i].siz < MIN)
			MIN = SUM - g[i].val - g[i].siz;
		ANS = max(ANS, SUM - g[i].siz - MIN);
	}
	cout << ANS << endl;
	return 0;
}


Measured memory_bytes: 10976
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MIN(a, b) (((a)<(b))?(a):(b))

int main(int argc, char **argv)
{
  int i = 0;
  int n = 0;
  int w[100] = {0};
  int l = 0;
  int r = 0;
  int diff_min = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
  {
    scanf("%d", &w[i]);
  }

  l = w[0];
  for(i = 1; i < n; i++)
  {
    r += w[i];
  }
  diff_min = abs(r - l);

  for(i = 1; i < n - 1; i++)
  {
    l += w[i];
    r -= w[i];
    diff_min = MIN(diff_min, abs(r - l));
  }

  printf("%d\n", diff_min);

  return 0;
}


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

int main() {
	int n;
	cin >> n;
	if (n < 1000)
	{
		cout << "ABC" << endl;
	}
	else
	{
		cout << "ABD" << endl;
	}
}

Measured memory_bytes: 256
N, x = [int(s) for s in input().split()]

l = N

n = max(x,N-x)
x = min(x,N-x)

while (True):
    q = n // x
    r = n % x
    if r == 0:
        print(l + (2*q-1)*x)
        break
    
    l += (2*q)*x
    n = x
    x = r

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string S;
  cin >> S;
  stack<char> st;
  REP(i,S.size()){
    if(st.size()!=0&&st.top()=='S'&&S.at(i)=='T'){
      st.pop();
    }else{
      st.push(S.at(i));
    }
  }

  cout << st.size() << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 10000000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n;
  cin >> n;
  ll maxx = 0, minn = INF, a;
  rep(i, n) {
    cin >> a;
    maxx = max(maxx, a);
    minn = min(minn, a);
  }
  cout << maxx - minn << endl;
	return 0;
}

Measured memory_bytes: 256
//author: JainBot27
//Created on: 08/22/20
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;


#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ts to_string
#define ub upper_bound
#define lb lower_bound
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int)x.size()
#define FOR(x, y, z) for(int x = (y); x < (z); x++)
#define ROF(x, y, z) for(int x = (y-1); x >= (z); x--)
#define F0R(x, z) FOR(x, 0, z)
#define R0F(x, z) ROF(x, z, 0)
#define trav(x, y) for(auto&x:y)


const string nl = "\n";
using ll = int64_t;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using str = string;
using vpii = vector<pii>;
using vpll = vector<pll>;


template<class T> inline bool ckmin(T&a, T b) {return b < a ? a = b, 1 : 0;}
template<class T> inline bool ckmax(T&a, T b) {return b > a ? a = b, 1 : 0;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


str ts(char c) { return str(1,c); }
str ts(bool b) { return b ? "true" : "false"; }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
template<class A> str ts(complex<A> c) { 
    stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) { 
    str res = "{"; for(int i = 0;i < (int)v.size(); i++) res += char('0'+v[i]);
    res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
    str res = ""; for(int i = 0; i < b.size(); i++) res += char('0'+b[i]);
    return res; }
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v) { 
    bool fst = 1; str res = "{";
    for (const auto& x: v) {
        if (!fst) res += ", ";
        fst = 0; res += ts(x);
    }
    res += "}"; return res;
}
template<class A, class B> str ts(pair<A,B> p) {
    return "("+ts(p.f)+", "+ts(p.s)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << ts(h); if (sizeof...(t)) cerr << ", ";
    DBG(t...); }


#ifdef D 
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

string n;

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    int sz = siz(n);
    ll sum = 0;
    for(int i=0; i < sz; i++){
        sum += n[i]-'0';
    }
    dbg(sum);
    cout << (sum%9==0?"Yes":"No") << nl;
}
/*
 * Stuff I should try:
 * Is it Monotonic? -> Binary Search
 * Is N small? -> Bitsets or other exponential
 * Edge Cases? Look Carefully 
 * Can't figure anything out? Brute Force and see patterns
 * Try to prove greedies
 * Prefix Sums, Amortization, DP, Data Structures
*/


Measured memory_bytes: 3776
#include<stdio.h>
main()
{
	int i,w,n,an,bn,a,b;
	scanf("%d",&w);
	int t[w+1];
	for(i=1;i<=w;i++){
		t[i]=i;
	}
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		bn=t[a];
		an=t[b];
		t[a]=an;
		t[b]=bn;
	}
	for(i=1;i<=w;i++){
		printf("%d\n",t[i]);
	}
	return 0;
}

Measured memory_bytes: 592