akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    int[][][] F;
    int[][] P;

    private void solve() {

        N = nextInt();
        F = new int[N][5][2];
        P = new int[N][11];

        for(int i = 0;i < N;i++) {
            for(int j = 0;j < 2;j++) {
                for(int k = 0;k < 5;k++) {
                    F[i][k][j] = nextInt();
                }
            }
        }

        for(int i = 0;i < N;i++) {
            for(int j = 0;j < 11;j++) {
                P[i][j] = nextInt();
            }
        }

        long ans = Long.MIN_VALUE;

        for(int i = 1;i < 1 << 10;i++) {
            long sum = 0;

            for(int j = 0;j < N;j++) {
                int c = 0;
                for(int k = 0;k < 10;k++) {
                    if ((i >> k & 1) == 1) {
                        c += F[j][k % 5][k % 2];
                    }
                }
                sum += P[j][c];
            }

            ans = Math.max(ans,sum);
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 23764
#include <cstdio>

using namespace std;

int main() {
    char input[3];
    int sum = 700;
    scanf("%c%c%c",  &input[0], &input[1], &input[2]);
    for (int i = 0; i < 3; i++) {
        if (input[i] == 'o') {
            sum += 100;
        }
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 128
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long i,n,m,x[262144],y[262144];
    long long xs=0,ys=0,k;
    scanf("%lld%lld",&n,&m);
    scanf("%lld",&x[1]);
    for(i=2;i<=n;i++){scanf("%lld",&x[i]);
        k=(i-1)*(n+1-i);k%=mod;
        xs+=(x[i]-x[i-1])*k;xs%=mod;
    }
    scanf("%lld",&y[1]);
    for(i=2;i<=m;i++){scanf("%lld",&y[i]);
        k=(i-1)*(m+1-i);k%=mod;
        ys+=(y[i]-y[i-1])*k;ys%=mod;
    }
    printf("%lld\n",(xs*ys)%mod);
    return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
using namespace std;

const int INF=100005;
int n,ans,beg;
vector<int> nei[INF];
int ok[INF];

void dfs(int x,int p){
	int cnt0=0,cnt1=0;
	for(int i=0;i<nei[x].size();i++){
		int to=nei[x][i];
		if(to==p) continue;
		cnt0++;
		dfs(to,x);
		if(ok[to]) cnt1++;
	}
	//cout<<x<<" "<<cnt0<<" "<<cnt1<<endl;
	if(cnt1) ok[x]=1;
	ans+=max(cnt0-1-cnt1,0);
	if(cnt0-1-cnt1>0) ok[x]=1;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		nei[x].push_back(y);
		nei[y].push_back(x);
	}
	for(int i=0;i<n;i++) if(nei[beg].size()<nei[i].size()) beg=i;
	dfs(beg,-1);
	printf("%d\n",ans==0?1:ans);
	return 0;
}

Measured memory_bytes: 13440
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll W;
    cin >> W;
    priority_queue<int> v[4];
    int h;
    rep(i, n) {
        int w, vv;
        cin >> w >> vv;
        if(!i) {
            h = w;
            v[0].push(vv);
        }
        else {
            v[w-h].push(vv);
        }
    }

    vvi dp(4, vi(n+1, 0));
    int ans = 0;
    rep(k, 4) {
        int sum = 0;
        while(!v[k].empty()) {
            int now = v[k].top();
            v[k].pop();
            sum++;
            dp[k][sum] = dp[k][sum-1] + now;
        }
        rep(i, n) {
            dp[k][i+1] = max(dp[k][i+1], dp[k][i]);
        }
    }
    rep(i, n+1) {
        rep(j, n+1-i) {
            rep(k, n+1-i-j) {
                rep(l, n+1-i-j-k) {
                    if(ll(i+j+k+l)*h+j+k*2+l*3 > W or ans >= (ll)dp[0][i]+dp[1][j]+dp[2][k]+dp[3][l]) continue;
                    ans = dp[0][i]+dp[1][j]+dp[2][k]+dp[3][l];
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a == 5 && b == 5 && c == 7)print("YES");
    else if(a == 5 && b == 7 && c == 5)print("YES");
    else if(a == 7 && b == 5 && c == 5)print("YES");
    else print("NO");
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int h,w;

  cin>>h>>w;

  vector<string> s(h);
  char x[h][w];
  for(int i=0;i<h;i++)cin>>s.at(i);
  //x=s;
  //r(i,h)cout<<s.at(i)<<endl;
  //cout<<endl<<s.at(1)<<endl;

  for(int i=0;i<h;i++){
    int sum=0;
    for(int j=0;j<w;j++){
      if(s.at(i).at(j)=='.'){
        if(i-1>=0&&j-1>=0){
          if(s.at(i-1).at(j-1)=='#')sum++;

        }
        if(i-1>=0){
        if(s.at(i-1).at(j)=='#')sum++;

      }
        if(i-1>=0&&j+1<=w-1){
          if(s.at(i-1).at(j+1)=='#')sum++;

        }

        if(j-1>=0){
          if(s.at(i).at(j-1)=='#')sum++;

        }
        if(j+1<=w-1){
          if(s.at(i).at(j+1)=='#'){sum++;}

        }
        if(i+1<=h-1&&j-1>=0){
          if(s.at(i+1).at(j-1)=='#')sum++;

        }
        if(i+1<=h-1){
          if(s.at(i+1).at(j)=='#'){sum++;}

        }
        if(i+1<=h-1&&j+1<=w-1){
        if(s.at(i+1).at(j+1)=='#')sum++;

      }
        cout<<sum;sum=0;
      }else{
        cout<<"#";
      }
    }
    cout<<endl;
  }



return 0;}


Measured memory_bytes: 256
def inp():
    return(int(input()))


n = inp()
scores = [0]
for i in range(n):
    scores.append(inp())
scores = sorted(scores)
d = 0
for s in scores:
    sm = sum(scores)
    if sm % 10 == 0:
        sm -= s
    if sm % 10 != 0:
        d = sm
        break
print(d)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int N=0,X=0,Y=0,Z=0,all=0;
	scanf("%d",&N);
	scanf("%d",&X);
	int a[X+1]={0};
	for(int i=1;i<X+1;i++)
	{
		scanf("%d",&a[i]);
	}
	scanf("%d",&Y);
	int b[Y+1]={0};
	for(int i=1;i<Y+1;i++)
	{
		scanf("%d",&b[i]);
	}
	scanf("%d",&Z);
	int c[Z+1]={0};
	for(int i=1;i<Z+1;i++)
	{
		scanf("%d",&c[i]);all+=1;
		for(int j=1;j<X+1;j++)
		{
			if(a[j]==c[i])
			{
				for(int k=1;k<Y+1;k++)
				{
					if(b[k]==c[i]){break;}
					else if(k==Y){all-=1;}
				}
			}
		}
	}
	printf("%d\n",all);
	return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>
#include<stdlib.h>
 
int top,S[10000];
 
void push(int x){
  S[++top]=x;
}
 
int pop(){
 return S[top--];
}
 
int main(){
  int a,b;
  char s[10];
  top=0;
   
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      b=pop();
      a=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      b=pop();
      a=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

bool e[52525];

int main(){
  ll sum=0, sumnum=0, cnt=0;
  ll val,num;
  while(~scanf("%lld,%lld",&val,&num)){
    if(val==-1)break;
    ++cnt;
    sum += val*num;
    sumnum += num;
  }
  cout<<sum<<endl;
  float x = (float)sumnum/(float)cnt;
  int res = (int)(x+0.5f);
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1212
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N = I()
d = LI()

d.sort()

ans = d[N//2]-d[N//2-1]

# print(d)
print(ans)

Measured memory_bytes: 38328
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i]; var[i]--;}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
class Graph{

public:
  vector<vector<int>> graphs;
  vector<bool> check; // For DFS
  vector<ll> dist;   // For BFS
  queue<int> q; // For BFS

  Graph(int n){
    graphs.resize(n);
    init(n);
  }
  ~Graph(){}

  void addedge(int u, int v){
    u--; v--;
    graphs[u].push_back(v);
    //graphs[v].push_back(u);
  }

  void addedge_cin(int m){
    rep(i,m){
      int a, b;
      cin >> a >> b;
      addedge(a, b);
    }
  }

  void init(int n){
    check.resize(n, false);
    dist.resize(n, -1);
  }

  void dfs(int v)
  {
    check[v] = true;

    for(auto next_v : graphs[v]){
      if(check[next_v]) continue;
      dfs(next_v);
    }
  }

  void bfs(int v)//----------------------
  {
    dist[v] = 0;
    q.push(v);

    while(!q.empty()){
      int cur_v = q.front();
      q.pop();

      for(int next_v : graphs[cur_v]){
        if(dist[next_v] != -1){
          continue;
        }

        dist[next_v] = dist[cur_v] + 1;
        q.push(next_v);
      }
    }
  }//-----------------------

};

int main(void) {
  int n;
  ll k;
  cin >> n >> k;
  arr(a,n);
  vecb check(n,false);

  vec v;
  v.pb(0);
  check[0]=true;
  int now=0;
  while(k>0){
    if(!check[a[now]]){
      v.pb(a[now]);
      check[a[now]]=true;
      k--;
      now=a[now];
    } else {
      k--;
      now=a[now];
      break;
    }
  }

  if(k>0){
    int loop=v.size();
    rep(i,v.size()){
      if(now!=v[i]){
        loop--;
      } else {
        now=v[i+k%loop];
        break;
      }
    }
  }
  
  prt(now+1);

}


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

const string musei = "ksthp";
const string boin = "aiueo";
enum phoneme : int {
    MUSEI,
    KITSU,
    SOKU,
    BOIN,
    SIIN,
};

int main() {
    string s;
    while (cin >> s, s != "#") {
        vector<pair<int, string>> cls;
        for (int i = 0; i < s.size(); i++) {
            if (boin.find(s[i]) != string::npos) {
                if (i > 0 && s[i] == s[i-1]) cls.push_back({SOKU, string(1, s[i])});
                else cls.push_back({BOIN, string(1, s[i])});
            } else {
                if (i < (s.size() - 1) && s[i] == s[i + 1]) cls.push_back({KITSU, string(1, s[i])});
                else if (musei.find(s[i]) != string::npos) {
                    if (i < (s.size() - 1) && s[i + 1] == 'y') {
                        cls.push_back({MUSEI, s.substr(i, 2)});
                        i++;
                    } else {
                        cls.push_back({MUSEI, string(1, s[i])});
                    }
                } else {
                    cls.push_back({SIIN, string(1, s[i])});
                }
            }
        }

        // for (auto x : cls) {
        //     cerr << "{" << x.second << " " << x.first << "}" << " ";
        // }
        // cerr << endl;

        string ans = "";
        bool before_musei = false;
        for (int i = 0; i < cls.size(); i++) {
            if (cls[i].first != BOIN) {
                ans += cls[i].second;
                continue;
            }

            bool is_musei = false;
            if (i > 0 && cls[i - 1].first == MUSEI) { // prev subword is musei ?
                // rule 1
                if ("iu"s.find(cls[i].second) != string::npos &&
                        ((i == cls.size() - 1) ||
                         (i < cls.size() - 1 && (cls[i + 1].first == MUSEI || musei.find(cls[i + 1].second) != string::npos)))) {
                    is_musei = true;
                }

                // rule 2
                else if ("ao"s.find(cls[i].second) != string::npos &&
                        (i + 2 < cls.size() && cls[i + 1].first == MUSEI && cls[i + 2].second == cls[i].second)) {
                    is_musei = true;
                }
            }

            if (is_musei && !before_musei) {
                ans += "(" + cls[i].second + ")";
                before_musei = true;
            } else {
                ans += cls[i].second;
                before_musei = false;
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3084
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
 *
 * @author Aeroui
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] arr = new int[N];

            int sum = 0;
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }

            sum = (int) Math.round(sum / (double) N);
            int ans = 0;
            for (int i = 0; i < N; i++) {
                ans += (sum - arr[i]) * (sum - arr[i]);
            }


            out.println(ans);
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,p,q,r,s,t,u,v,w,x,i,j;
    while(1)
    {
        cin>>m>>n;
        if(n==0&&m==0)
        {
            break;
        }

        for(i=1;i<=m;i++)
        {
          for(j=1;j<=n;j++)
          {
              if(i==1||i==m)
              {
                  cout<<"#";
              }
              else{
              if(j==1||j==n)
              {
                  cout<<"#";
              }
              else
              {
                  cout<<".";
              }
              }
          }
          cout<<'\n';
        }
       cout<<'\n';


    }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
const ll MOD = 1e9 + 7;

bool dp[(ll)1e5 + 10];

int main(){
    dp[0] = false;
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for(ll &a : A) cin >> a;
    ll line;
    for(ll i = 0; i <= K; i++){
        for(ll a : A){
            if(a + i > K) break;
            dp[i + a] |= !dp[i];
        }
    }
    cout << (dp[K] ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

void Quicksort(int, int);
int Partition(int, int);

 
typedef struct{
  int n;
  char c;
  int count;
}Card;
 
Card a[100000];
 
int main(void){
  int n,i,q,f=0;
  char y;
 
  scanf("%d%c",&n,&y);
  for(i = 1; i < n+1; i++){
    scanf("%c%d%c",&a[i].c, &a[i].n, &y);
    a[i].count = i;
  }
 
  Quicksort(1,n);
 
  for(i = 0; i < n; i++){
    if(a[i].n == a[i+1].n && a[i].count > a[i+1].count){
      f = 1;
      break;
    }
  }
 
  if(f == 0){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
 
  for(i = 1; i < n+1; i++){
    printf("%c %d\n",a[i].c,a[i].n);
  }
  return 0;
}
  void Quicksort(int p, int r){
  int q;
  if(p < r){
    q = Partition(p,r);
    Quicksort(p,q-1);
    Quicksort(q+1,r);
  }
}
int Partition(int p, int r){
  int i,j;
  Card x,tmp;
 
  x = a[r];
  i = p - 1;
 
  for(j = p; j <= r-1; j++){
    if(a[j].n <=  x.n){
      i =  i + 1;
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  tmp = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp;
 
  return i+1;
}
 

Measured memory_bytes: 2208
s=list(input())
s=s[::-1]
l=len(s)
mod=2019
count=[0]*2019
count[0]=1
num=0
seki=1
for i in range(l):
    num+=int(s[i])*seki
    num=num%mod
    count[num]+=1
    seki=(seki*10)%mod
ans=0
for i in range(2019):
    N=count[i]
    ans+=N*(N-1)//2
print(ans)

Measured memory_bytes: 79316
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
   string str;
   cin>>str;
   int n=0;
   long long int sum=0; 
   for(int i=0;i<str.length();i++)
   {
      n=n*10+(int)(str[i]-48);
      sum=sum+str[i]-48;
   }
   
   if(n%sum==0)
    cout<<"Yes";
else
    cout<<"No";
 



 return 0;
}








Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

typedef long long int lli;


int main()
{
	lli L, R;
	cin >> L >> R;

	if (R - L >= 2019 - 1)
	{
		cout << 0 << endl;
		return 0;
	}

	L %= 2019ll;
	R %= 2019ll;

	lli ans = 2018ll;

	for (lli i = L; i <= R - 1; i++)
	{
		for (lli j = L + 1; j <= R; j++)
		{
			lli t = (i * j) % 2019ll;
			if (t < ans)
			{
				ans = t;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    one_thousand, five_thousand, ten_thousand = 1000, 5000, 10000
    n, y = map(int, input().split())
    ans = []
    for i in range(0, n+1):
        for j in range(0, n+1-i):
            k = n - (i + j)
            one = one_thousand * i
            five = five_thousand * j
            ten = ten_thousand * k
            sum_price = one + five + ten
            if k >= 0 and n == i + j + k and sum_price == y:
                ans.append([k, j, i])
                break
        if ans != []:
            print(ans[0][0], ans[0][1], ans[0][2])
            break
    if ans == []:
        print(-1, -1, -1)


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	const VI cts ={ 99999, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	VI a(m);
	rep(i, m) cin >>a[i];
	vector<string> dp(n+4, "");
	dp[0] = "";
	rep(i, n+1) if(i==0 || sz(dp[i])>0) rep(j, m){
		int w = i + cts[a[j]];
		if(w > n) continue;
		bool jk =(sz(dp[w]) <= sz(dp[i]) +1) && (dp[w] < dp[i] + to_string(a[j]));
		if(sz(dp[w]) < sz(dp[i]) + 1 || jk )dp[w]  = dp[i] + to_string(a[j]); 
	}
	cout << dp[n] <<endl;
	return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,m,q;
int x[N];
int y[N];
int a[N],b[N];

int main(){
	cin >> n;
	for(int i = 1; i <= n; i ++ ){
		scanf("%d%d", x + i, y + i);
		a[i] = x[i] + y[i];
		b[i] = x[i] - y[i];
	} 
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	cout <<	max(a[n] - a[1], b[n] - b[1]) << endl;
	


	return 0;
}



Measured memory_bytes: 6916
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;
int main(){
	int x,a;

	scanf("%d %d",&x,&a);

	if(x<a)printf("0");
	else printf("10");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
typedef long double llu;

vector<lld> C[256];
lld exist[256];

int main()
{
    std::ios::sync_with_stdio(false);
    lld t = 1;
    // cin >> t;
    while(t--) {
        string s, t;
        cin >> s >> t;

        for(lld i = 0; i < s.size(); i++) {
            lld id = s[i] - 'a';
            C[id].push_back(i);
            exist[id] = 1;
        }

        if(!exist[t[0] - 'a']) {
            cout << -1;
            return 0;
        }

        lld prev = -1;
        lld cnt = 0;
        for(lld i = 0; i < t.size(); i++) {
            lld id = t[i] - 'a';
            if(exist[id]) {
                auto it = upper_bound(C[id].begin(), C[id].end(), prev);
                if(it == C[id].end()) {
                    cnt++;
                    prev = -1;
                }
                prev = *upper_bound(C[id].begin(), C[id].end(), prev);
                // prev++;

            } else {
                cout << -1;
                return 0;
            }
        }
        cout << (cnt * s.size()) + (prev + 1) << "\n";
    }
}


Measured memory_bytes: 1736
N, M = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_BC = [tuple(map(int, input().split())) for _ in range(M)]


lst_A.sort()
lst_BC.sort(key=lambda x:x[1], reverse=True)


lst_D = []
for b, c in lst_BC:
    lst_D += [c] * min(b, N - len(lst_D))
lst_D = lst_D + [0] * (N - len(lst_D))


for i in range(N):
    if lst_A[i] >= lst_D[i]:
        break
    lst_A[i] = lst_D[i]


print(sum(lst_A))

Measured memory_bytes: 22756
#include<iostream>
#include<string>

int main()
{
	std::string str;
	std::cin >> str;

	for (int i = 0; i != str.length(); ++i)
	{
		str[i] = str[i] + 'A' - 'D';
		if (str[i] < 'A')
			str[i] += 'Z' - 'A' + 1;
	}

	std::cout << str << std::endl;

	return 0;
}

Measured memory_bytes: 1184
using System;
using System.Linq;

namespace ABC115
{
    class C
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var h = Enumerable.Repeat(0, NK[0]).Select(_ => int.Parse(Console.ReadLine())).ToArray();
            h = h.OrderBy(x => x).ToArray();
            int cost = int.MaxValue;
            for (int i = 0; i < NK[0] - NK[1] + 1; i++)
            {
                cost = Math.Min(cost, h[i + NK[1] - 1] - h[i]);
            }
            Console.WriteLine(cost);
        }
    }
}

Measured memory_bytes: 21468
#include<bits/stdc++.h>
char s[100007];
int g[128];
int main()
{
    g['b'] = 0 , g['p'] = 1 , g['d'] = 2 , g['q'] = 3;
    scanf("%s",s+1);
    for(int l = strlen(s+1),i=1;i<=(l>>1)+1;i++)
    {
        if(g[s[i]]^((g[s[l-i+1]]+2)%4)) return printf("No\n"),0;
    }  
    return printf("Yes\n"),0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

LL s[100001];
inline void F(int n,int k,int d) {
	if (!n)
		return;
	if (n>30||!s[n]) {
		printf("%d ",k/2+1);
		F(n-1,k,d+1);
	} else {
		int t=k/2+1;
		while (d>=s[n])
			d-=s[n]*2,t--;
		while (d+s[n]*2<s[n])
			d+=s[n]*2,t++;
		if (t) {
			printf("%d ",t);
			F(n-1,k,d+1);
		}
	}
}

int main()
{
	int k=gi(),n=gi();
	if (k&1) {
		if (k==1) {
			for (int i=1;i<=(n+1)/2;i++) printf("1 ");
		} else {
			printf("%d ",k/2+1);
			s[1]=1;
			for (int i=2;(s[i]=s[i-1]*k+1)<=n*2;i++);
			F(n-1,k,1);
		}
	} else {
		printf("%d ",k/2);
		for (int i=2;i<=n;i++) printf("%d ",k);
	}
	return 0;
}


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

int bucket[100005]={0};

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

    bool flag = true;
    long long int ans = 1;
    for(int i=0;i<n;++i){
        if(i==0){
            if(n%2 && bucket[i] != 1 || n%2 == 0 && bucket[i] != 0){
                flag = false;
                break;
            }
        }else{
            if(n%2 && i%2==0 && bucket[i] != 2 || n%2==0 && i%2 && bucket[i] != 2){
                flag = false;
                break;
            }
        }
        if(bucket[i] == 2)ans = (ans * 2) % 1000000007;
    }

    if(flag)cout << ans << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 640
r, g, b, n = map(int, input().split())

ans = 0
r_p = n // r
for i in range(n // r + 1):
    tmp = n - r * i
    for j in range(tmp // g + 1):
        remain = tmp - g * j
        if remain % b == 0:
            ans += 1
print(ans)


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N, A, B;
	cin >>N >>A >>B;
	int S=0;
	for (int i=1; i<=N; i++) {
		int K=0;
		int I=i;
		while (I>0) {
			K +=I%10;
			I /=10;
		}
		if ((K>=A)&&(K<=B))
			S +=i;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k,p;
	char str[30],str2[15],str3[15];
	scanf("%lld%lld%lld",&n,&m,&k);
	if (big(big(n,m),k)==n+m+k-big(big(n,m),k)) { printf("Yes"); }
	else {
		printf("No");
	}
	
		
	
}


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	ll n;
	cin >> n;
	FOR(i,1,n+1){
		ll x=i;
		if(x%3==0){
			cout << " " << i;
			continue;
		}
		if(x%10==3||(x/10)%10==3||(x/100)%10==3||(x/1000)%10==3){
			cout << " " << i;
			continue;
		}
	}cout << endl;
  return 0;
}


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

#define PB emplace_back

using namespace std;

const int N = 5e5+100;

int par[N];

int fat(int x) {
    return (x == par[x]) ? x : par[x] = fat(par[x]);
}

void add(int u, int v) {
    u = fat(u);
    v = fat(v);
    if(u != v) {
        par[u] = v;
    }
}

int main () {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, m;
    cin >> n >> m;
    iota(par, par + n , 0);
    while(m--) {
        int t, u1, u2;
        cin >> t >> u1 >> u2;
        if(t) cout << (fat(u1) == fat(u2)) << '\n';
        else add(u1, u2);
    }
}


Measured memory_bytes: 4332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m, k; cin >> n >> m >> k;
    rep(h,n+1)rep(w,m+1) {
        if (h*m-h*w+w*n-w*h == k) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr long long int mod = 1e9 + 7;
using Container = vector<Int>;
using Grid = vector<vector<char>>; // [y][x]

struct Point {
	Int x, y;
	Point(Int x, Int y) :x(x), y(y) {}
	
	Point operator+(Point arg) {
		return Point(x + arg.x, y + arg.y);
	}

	Point operator-(Point arg) {
		return Point(x - arg.x, y - arg.y);
	}
};

bool inrange(Int l, Int r, Int val) {
	return l <= val && val <= r;
}

int main() {

	Int H, W; cin >> H >> W;
	Grid grid(H, vector<char>(W));
	rep(y, H) {
		string S; cin >> S;
		rep(x, W) {
			grid[y][x] = S[x];
		}
	}

	Point vec[4] = { Point(0, -1), Point(-1, 0), Point(0, 1), Point(1, 0) };
	Point s(0, 0);
	Int ans = LLONG_MIN;

	rep(y, H) {
		rep(x, W) {
			if (grid[y][x] == '#')continue;
			//スタートとゴールの位置を決める
			s = Point(x, y);
			vector<vector<bool>> visited(H, vector<bool>(W, false));
			vector<vector<Int>> dist(H, vector<Int>(W, -1));
			dist[y][x] = 0;
			visited[y][x] = true;
			queue<Point> q; q.push(s);
			while (!q.empty()) {
				auto cur = q.front(); q.pop();
				rep(i, 4) {
					auto next = cur + vec[i];
					if (inrange(0, W - 1, next.x) && inrange(0, H - 1, next.y) && !visited[next.y][next.x] && grid[next.y][next.x] == '.') {
						q.push(next);
						dist[next.y][next.x] = dist[cur.y][cur.x] + 1;
						ans = max(ans, dist[next.y][next.x]);
						visited[next.y][next.x] = true;
					}
				}
			}



		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repr(i, n) for (int i=n-1; i > 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x);
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int a,b;
    cin >> a >> b;
    int diff = b-a;
    int cnt = 0;
    repe(i,999) {
        cnt += i;
        if (i==diff) {
            cout << cnt-b << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    bool can_transform = false;
    for (int x = 0; x < s.length(); x++) {
        if (s.substr(x) + s.substr(0, x) == t) {
            can_transform = true;
        }
    }
    if (can_transform) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
char s[100];
int main() {
//	freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	printf("%c%c%c\n",s[1],s[2],s[3]);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 3728
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)



signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    rep(i,n)cin >> a[i];
    uintl money = 1000;
    rep(i,n - 1){
        intl num = 0;
        if(a[i] < a[i + 1])num = money / a[i];
        money += (a[i + 1] - a[i]) * num;
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int A,B,C,D,E,x=0,y=0;
	cin>>A;
	cin>>B;
	cin>>C;
	cin>>D;
	cin>>E;

	if(0>A){
		x=A*C*-1+D+B*E;
	}
	else if(0<A){
		y=(B-A)*E;
	}
	else{
		x=D+((B-A)*E);
	}
	cout<<x+y<<endl;

return 0;
}


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

using pii = pair<int, int>;

int i, n, m, k, l, x, y, a[15][2];

bool good(pii const& x) {
  int y = x.second;
  for(i = 0; i < n; i++) {
    if((y >> i) & 1 && (a[i][0] & y || a[i][1] & l - y))
      return false;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  for(cin >> n; i < n; i++) {
    for(cin >> m; m--;) {
      cin >> x >> y;
      a[i][y] |= 1 << x - 1;
    }
  }
  l = (1 << n) - 1;
  vector<pii> b;
  for(int i = 1; i <= l; i++) {
    b.emplace_back(__builtin_popcount(i), i);
  }
  sort(begin(b), end(b), [](pii const& x, pii const& y) {return x.first > y.first;});
  cout << find_if(begin(b), end(b), good)->first << '\n';
  
  return 0;
}


Measured memory_bytes: 640
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: 9152
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9

int main(){
    while(1){
        int n, m; cin >> n >> m;
        if(!n) break;
        vector<int> c(m);
        vector<int> x(n);
        for(int i = 0; i < m; i++) cin >> c[i];
        for(int i = 0; i < n; i++) cin >> x[i];
        vector<vector<int> > dp(256, vector<int> (n + 1, INF));
        for(int i = 0; i <= 255; i++) dp[i][n] = 0;
        for(int j = n - 1; j >= 0; j--){
            for(int i = 0; i <= 255; i++){
                for(int k = 0; k < m; k++){
                    int t = i + c[k];
                    if(t < 0) t = 0;
                    if(t > 255) t = 255;
                    dp[i][j] = min(dp[i][j], (t - x[j]) * (t - x[j]) + dp[t][j + 1]);
                }
            }
        }

        cout << dp[128][0] << endl;
    }
    return 0;
}


Measured memory_bytes: 22860
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;


vector<int>G[200020];

int ds[200020], dt[200020];

void dfs(int n, int pre, int res,int *d) {
	d[n] = res;
	for (auto nxt : G[n]) {
		if (nxt == pre)continue;
		dfs(nxt, n, res + 1, d);
	}
}

void solve() {
	int N, s, t; cin >> N >> s >> t;
	s--, t--;

	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(s, s, 0, ds);
	dfs(t, t, 0, dt);
	ll ans = 0;
	REP(i, N) {
		if (ds[i] < dt[i])ans = max(ans, dt[i]-1);
		else if (ds[i] == dt[i] && ds[i] + dt[i] == dt[s])ans = max(ans, ds[i]);
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 13696
fn read_lines() -> Vec<String> {
    use std::io::Read;

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    return buf.lines().map(|e| e.to_string()).collect::<Vec<_>>();
}

fn main() {
    let input = read_lines();
    let n: usize = input[0].parse().unwrap();
    let input_series: Vec<usize> = input[1].split_whitespace().map(|e| e.parse().unwrap()).collect::<Vec<usize>>();

    let max_series_element = 10_000;
    let mut counting: Vec<usize> = vec![0; max_series_element];
    for e in &input_series {
        counting[*e] += 1;
    }
    for i in 1..max_series_element {
        counting[i] += counting[i-1];
    }

    let mut output_series = vec![0; n];
    for j in (0..n).rev() {
        output_series[counting[input_series[j]]-1] = input_series[j];
        counting[input_series[j]] -= 1;
    }

    println!("{}", output_series.into_iter().map(|u| format!("{}", u)).collect::<Vec<_>>().join(" "));
}



Measured memory_bytes: 109408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int d,l;
    cin>>d>>l;
    cout<<d/l+d%l<<endl;
    
    return 0;
}



Measured memory_bytes: 3076