akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] NAB=cin.ArrayInt(3,0);
        int ans=Math.Min(NAB[0]*NAB[1],NAB[2]);
        Console.WriteLine(ans);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(void) {
	char s[30000];
	int w,i=0;
	scanf("%s",s);
	scanf("%d",&w);
	while(1){
		printf("%c",s[i]);
		i+=w;
		if(s[i]=='\0') break;
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n,m; cin >> n >> m;
  vector<ll> A(n);
  vector<pair<ll,ll>> X(m);
  for(ll i=0;i<n;i++) cin >> A[i];
  // ll max_time = 0;
  for(ll i=0;i<m;i++){
    ll b,c; cin >> b >> c;
    // max_time += b;
    X[i] = make_pair(c,b);
  }
  // Cの大きい順にソート
  sort(X.rbegin(),X.rend());
  ll cnt = n;
  for(auto c:X){
    while(cnt && c.second){
      A.push_back(c.first);
      cnt--;
      c.second--;
    }
  }
  /*for(ll i=0;;i++){
    if(cnt > n) break;
    for(ll j=0;j<X[i].second;j++){
      if(cnt > n) break;
      A.push_back(X[i].first);
      cnt++;
    }
    if(cnt > n) break;
  }
  */
  ll ans = 0;
  sort(A.rbegin(),A.rend());
  for(ll i=0;i<n;i++) ans += A[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    int n;
    cin >> n;
    map<string,int> m;
    vector<string> v(n);
    rep(i,n){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        v[i]=s;
    }
    //sort(v.begin(),v.end());
    vector<ll> cnt;
    ll ans=0;
    ll tmp = 0; 
    rep(i,n){
        m[v[i]]++;
    }
    for (auto w:m){
        //cout << w.second << endl;
        if (w.second == 1) continue;
        ans+=(ll)w.second*(w.second-1)/2;
    }
    cout << ans << endl;
    
}

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

long long top(long long n, long long a)
{
    if (n % a == 0)
        return n / a;
    else
        return n / a + 1;
}

int main()
{
    long long n, value, min_value = LLONG_MAX;

    cin >> n;

    for (int i = 0; i < 5; i++)
    {
        cin >> value;
        min_value = min(value, min_value);
    }

    cout << top(n, min_value) + 4 << endl;

    return 0;
}

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

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

using namespace std;

int h,arr[10][5];
bool erase[10][5];

void compute(){
  bool update = true;
  int score = 0;
  while( update ){
    memset(erase,false,sizeof(erase));
    update = false;
    for(int y=h-1;y>=0;y--){
      for(int x=0;x<3;x++){
        if( arr[y][x] == 0 ) continue;
        int cnt = 1;
        REP(x2,x+1,5) {
          if( arr[y][x] != arr[y][x2] ) break;
          ++cnt;
        }
        if( cnt >= 3 ) {
          update = true;
          REP(x2,x,5) {
            if( arr[y][x] != arr[y][x2] ) break;
            erase[y][x2] = true;
          } 
        }
      }
    }
    rep(y,h) rep(x,5) if( erase[y][x] ) { score += arr[y][x]; arr[y][x] = 0; }
    for(int y=h-1;y>=0;y--){
      for(int x=0;x<5;x++){
        if( arr[y][x] == 0 ) {
          int ny = y;
          while( 1 ){
            ny -= 1;
            if( ny < 0 ) break;
            if( arr[ny][x] ) { swap(arr[y][x],arr[ny][x]); break; }
          }
        }
      }
    }
  } 
  cout << score << endl;
}

int main(){
  while( cin >> h, h ){
    rep(i,h) rep(j,5) cin >> arr[i][j];
    compute();
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

ll memo[102][100'050];
ll n;
ll W[120];
ll V[120];
ll w;

ll dp(ll at, ll v) {
    if(at >= n) {
        if(v == 0) return 0;
        return w+1;
    }
    if(memo[at][v] != -1) return memo[at][v];
    ll mx = dp(at+1,v);
    if(v - V[at] >= 0) mx = min(mx, dp(at+1, v - V[at])+W[at]);
    return memo[at][v] = mx;
}

int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> n >> w;
    rep(i,0,n) {
        cin >> W[i] >> V[i];
    }
    int ans = 0;
    rep(i,0,100'050) {
        ll val = dp(0,i);
        if(val <= w) ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80000
#include <stdio.h>
typedef long long ll;
int main(){
  ll a,b;
  scanf("%lld %lld",&a,&b);
  if(a>0) printf("Positive\n");
  else if(a==0||b==0||a<=0&&b>=0) printf("Zero\n");
  else if((b-a)&1) printf("Positive\n");
  else printf("Negative\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
int main() {
    string str;
    cin >> str;

    string answer;
    answer.push_back(str[0]);
    answer += to_string(str.length() - 2);
    answer.push_back(str[str.size() - 1]);

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 3640
import sys
N, Y = map(int, input().split())
for i in range(0, min(N, Y//10000) + 1):
    for j in range(0, min(N-i, Y//5000) + 1):
        for k in range(N-i-j, min(N-i-j, Y//1000) + 1):
            if i*10000 + j*5000 + k*1000 == Y and i+j+k == N:
                print(i, j, k)
                sys.exit()
print(-1, -1, -1)


Measured memory_bytes: 41196
import math
import sys
from collections import deque
a=input()
for i in range(8):
  c=int(a[0])
  l=[a[0]]
  for j in range(3):
    if i>>j & 1:
      c+=int(a[j+1])
      l+=["+",a[j+1]]
    else:
      c-=int(a[j+1])
      l+=["-",a[j+1]]
  if c==7:
    for i in l:
      print(i,end="")
    print("=7")
    sys.exit()


Measured memory_bytes: 3316
def op(a,b,n):
  if n == 0:
    return a+b
  else:
    return a-b
def p(n):
  if n == 0:
    return '+'
  else:
    return '-'
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
for i in range(2):
  for j in range(2):
    for k in range(2):
      s1 = op(a,b,i)
      s2 = op(s1,c,j)
      tmp = op(s2,d,k)
      if tmp == 7:
        ans = str(a) + p(i) + str(b) + p(j) + str(c) + p(k) + str(d) +"=7"
        print(ans)
        exit()

Measured memory_bytes: 3064
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    char c;
    cin >> c;
    cout << char(c + 1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int H,N;
  cin >> H >> N;
  
  int d = 0;
  for(int i=0;i<N;i++){
    int p;
    cin >> p;
    d += p;
  }
  
  if(H > d) cout << "No" << endl;
  else cout << "Yes" << endl;
  
  
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60);
typedef long long ll;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	int two_c = 0;
	int four_c = 0;
	vector<ll> a(N);
	for (int i = 0; i < N;i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) two_c++;
		if (a[i] % 4 == 0) four_c++;
	}
	if (four_c >= N / 2) {
		cout << "Yes" << endl;
		return 0;
	}
	int x = four_c * 2;
	int two_only = two_c - four_c;
	N -= x;
	if (two_only >= N) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n;
	vector<int> ie;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int v;
		cin >> v;
		ie.push_back(v);
	}
	sort(ie.begin(), ie.end());

	int res = 0;

	for (int i = 0; i < n - 1; i++) {
		res += ie[i + 1] - ie[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <vector>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

const int vx[4] = { 0, 1, 0, -1 }, vy[4] = { 1, 0, -1, 0 };

int W, H;
std::string s[21];
bool is_searched[21][21];

int solve() {
  int sx, sy;

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (s[i][j] == '@') {
        sx = i, sy = j;
        break;
      }
    }
  }

  std::memset(is_searched, false, sizeof is_searched);

  int ans = 1;

  std::queue<std::pair<int, int> > que;
  que.push({ sx, sy });
  is_searched[sx][sy] = true;

  while (!que.empty()) {
    std::pair<int, int> p = que.front();
    que.pop();

    for (int i = 0; i < 4; ++i) {
      int nx = p.first + vx[i], ny = p.second + vy[i];

      if (0 <= nx && nx < H && 0 <= ny && ny < W && !is_searched[nx][ny] && s[nx][ny] == '.') {
        ans++;
        is_searched[nx][ny] = true;
        que.push({ nx, ny });
      }
    }
  }

  return ans;
}

int main() {
  while (cin >> W >> H, H | W) {
    for (int i = 0; i < H; ++i) {
      cin >> s[i];
    }

    int ans = solve();

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b;
    cin >> a >> b;
    if (abs(a - b) % 2){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (a + b) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 2e+9
using namespace std;

int main(){
	int n,x[100001],l,q,next[100000][340];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> x[i];
	x[n] = INF;
	cin >> l >> q;
	for(int i = 0;i < n;i++){
		next[i][0] = upper_bound(x,x + n + 1,x[i] + l) - x - 1;
	}
	for(int i = 1;i < 340;i++){
		for(int j = 0;j < n;j++){
			next[j][i] = next[next[j][i - 1]][0];
		}
	}
	for(int i = 0;i < q;i++){
		int a,b,res = 0;
		cin >> a >> b;a--;b--;
		if(a > b){
			int t = a;
			a = b;
			b = t;
		}
		while(next[a][339] < b){
			res += 340;
			a = next[a][339];
		}
		for(int j = 0;j < 340;j++){
			res++;
			if(next[a][j] >= b) break;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 134016
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;
const ll inf = 1000000000000000000;

ll sum;
string s;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    for (ll i = 0; i < (ll)s.size(); ++i)
        sum += (s[i] - '0');
    if (sum % 9 == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

const [_n, a, b, c] = stdin.trim().split('\n')

const n = Number(_n)

const ans = _ => {
  let count = 0
  for (let i = 0; i < n; i++) {
    if (a[i] !== b[i] && b[i] !== c[i] && a[i] !== c[i]) {
      count += 2
    } else if (!(a[i] === b[i] && b[i] === c[i] && a[i] === c[i])) {
      count++
    }
  }
  return count
}

console.log(ans())


Measured memory_bytes: 7372
import numpy as np
from numba import njit

N, K = map(int, input().split())

max_candies = np.array(list(map(int, input().split())), dtype='int64')

dpt = np.full((N+1, K+1), 0, dtype='int64')
for i in range(K+1):
    dpt[0][i] = 1

@njit('i8(i8,i8,i8[:],i8[:,:])', cache=True)
def dp(N, K, max_candies, dpt):
    for i in range(1, N+1):
        for j in range(0, K+1):
            dpt[i][j] += dpt[i-1][j]
            t = j - max_candies[i-1] - 1
            if t >= 0:
                dpt[i][j] -= dpt[i-1][t]
            if j > 0:
                dpt[i][j] += dpt[i][j-1]
            dpt[i][j] = dpt[i][j] % (10**9+7)
    return (dpt[N][K] - dpt[N][K-1]) % (10**9+7)

if K > 0:
    print(dp(N, K, max_candies, dpt))
else:
    print(1)


Measured memory_bytes: 191456
inputList = []
inputList.extend(int(i) for i in input().split())
inputList.extend(int(i) for i in input().split())
inputList.extend(int(i) for i in input().split())

one = 0
two = 0
three = 0
four = 0

for i in inputList:
    if i == 1:
        one = one + 1
    elif i == 2:
        two = two + 1
    elif i == 3:
        three = three + 1
    elif i == 4:
        four = four + 1

if one < 1 or one >= 3 or two < 1 or  two >= 3 or three < 1 or three >= 3 or four < 1 or four >= 3:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3064
#include <stdio.h>
#define N 4
#define MAX 15
typedef struct{
    int A[N][N];
}Pazzle;
Pazzle P;
int d_x[4]={0,1,0,-1};
int d_y[4]={1,0,-1,0};

void swap(int *A,int *B){
 int hoge;
 hoge=*A;
 *A=*B;
 *B=hoge;
 
 
}

int check(Pazzle P){
    int sum=0,i,j,hy,hx;
    for(i=0;i<N;i++){
 
    for(j=0;j<N;j++){
        if(P.A[i][j]==0)
        continue;
        hy=(P.A[i][j]-1)/N-i;
        hx=(P.A[i][j]-1)%N-j;
        if(hy<0)
        sum-=hy;
        else
        sum+=hy;
        if(hx<0)
        sum-=hx;
        else
        sum+=hx;
 
 
}
}
 
return sum;
}

int dfs(int x,int y,int max,int cnt,int m){
         int i;
  int heau;
  int x_0,y_0;
  int ans=-1;   
  heau=check(P);
  if(heau==0) return cnt;
  if(cnt+heau>max) return -1; 
  for(i=0;i<4;i++){
    x_0=x+d_x[i];
    y_0=y+d_y[i];      
   
    if((m!=-1&&i==(m+2)%4)||!(0<=x_0 && x_0<N && 0<=y_0 && y_0<N)) continue;    
    swap(&P.A[y][x],&P.A[y_0][x_0]);
    ans=dfs(x_0,y_0,max,cnt+1,i);
    if(ans!=-1) return ans;       
     swap(&P.A[y][x],&P.A[y_0][x_0]);
  }   
  return -1;
}

int main(void){
    Pazzle t_P;
    int  i,j,ans;
    int x0,y0;

    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            scanf("%d",&P.A[i][j]);
            if(P.A[i][j]==0){
                x0=j;
                y0=i;
                
            }
            
        }
    }
    t_P=P;
    for(i=1;i<46;i++){
        P=t_P;
    ans=dfs(x0,y0,i,0,-1);
    if(ans!=-1){printf("%d\n",ans); break;}
    }
    return 0;
}






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

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

class Dice{
private:
  int tmp;
public:
  int d[6];
 
  void rollN(){
    tmp = d[0];
    d[0] = d[1];
    d[1] = d[5];
    d[5] = d[4];
    d[4] = tmp;
  }
  
  void rollE(){
    tmp = d[0];
    d[0] = d[3];
    d[3] = d[5];
    d[5] = d[2];
    d[2] = tmp;
  }
 
  void rollS(){
    tmp = d[0];
    d[0] = d[4];
    d[4] = d[5];
    d[5] = d[1];
    d[1] = tmp;
  }
 
  void rollW(){
    tmp = d[0];
    d[0] = d[2];
    d[2] = d[5];
    d[5] = d[3];
    d[3] = tmp;
  }

  void rotation(){
    tmp = d[1];
    d[1] = d[3];
    d[3] = d[4];
    d[4] = d[2];
    d[2] = tmp;
  }

  int getRight(int top,int front){
    rep(i,3){
      rollN();
      if(top == d[0]){
        break;
      }
      rollW();
      if(top == d[0]){
        break;
      }
    }
    rep(i,3){
      if(front == d[1]){
        break;
      }
      rotation();
    }

    return d[2];
  }
};
 
int main(){
  Dice dice;
  int q,top,front;
 
  rep(i,6){
    cin >> dice.d[i];
  }
  cin >> q;
  while(q--){
    cin >> top >> front;
    cout << dice.getRight(top,front) << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
typedef long long ll;
ll p,q,a,n,an;

ll gcd(ll a,ll b){
  if(b)return gcd(b,a%b);
  return a;
}

void dfs(ll d,ll s,ll t,ll k,ll j){
  if(d>n||s*q>p*k)return;
  if(s*q==p*k){an++;return;}
  for(int i=j;t*i<=a;i++){
    //ll cd=gcd(k,i);
    dfs(d+1,s*i+k,t*i,k*i,i);
  }
}

int main(){
  while(cin>>p>>q>>a>>n&&n){
    an=0;
    dfs(0,0,1,1,1);
    cout<<an<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  string s;cin>>s;
  ll stsi=s.size(),ans=0,b=0;
  ll a[stsi];fill(a,a+stsi,0);
  for(ll i=0;i<stsi;i++){
    if(s.at(i)=='W'){a[i]++;}
  }
  for(ll i=0;i<stsi;i++){
    if(a[i]==1){ans+=i-b;b++;}
  }
  cout << ans<<endl;
}

Measured memory_bytes: 5288
n = int(input())
shop_list = []

for i in range(n):
    name, score = map(str, input().split())
    shop_list.append([i+1, name, int(score)])

shop_list.sort(key=lambda x: (x[1], -x[2]))

for shop_info in shop_list:
    print(shop_info[0])


Measured memory_bytes: 3060
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#define ll long long
using namespace std;



int main(){
   
  ll K,N,ans=0;
  cin>>K>>N;

  vector<ll> A(N);
  vector<ll> S(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int j=0;j<N-1;j++){
    S[j]=A[j+1]-A[j];
  }
  S[N-1]=K-A[N-1]+A[0];

  sort(S.begin(),S.end());

  ans=K-S[N-1];

 


  cout<<ans<<endl;



  


  
    return 0;
}


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

#define ll long long

ll read(){
    char c= getchar(); ll f = 1, ret = 0;
    for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for(; isdigit(c); c = getchar()) ret = ret*10 + c - '0';
    return ret*f;
}
void write(ll x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) write(x / 10);
    putchar(x%10 + '0');
}
#define nl puts("")
#define bs putchar(' ')
signed main(){
    ll x = read(), y = read();
    ll ans = 0;
    if(x == 1 && y == 1) {
        puts("1000000");
    } else {
        ans += max(0ll, 4 - x) * 100000;
       ans += max(0ll, 4 - y) * 100000;
       write(ans), nl;
    }
    return 0;
}

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

using namespace std;

class points {
public:
  int x;
  int y;
};

int main() {
  int nSize;
  const int dx[] = {-1, 0, 1, 0};
  const int dy[] = {0, -1, 0, 1};
  points fst;
  fst.x = 0;
  fst.y = 0;
  while(cin>>nSize && nSize>0) {
    vector<points> sq;
    sq.push_back(fst);
    int n, d;
    int xMax, yMax, xMin, yMin;
    xMax = 0;
    yMax = 0;
    xMin = 0;
    yMin = 0;
    for(int i=0; i<nSize-1; i++) {
      cin>>n>>d;
      points tmp;
      tmp.x = sq[n].x+dx[d];
      tmp.y = sq[n].y+dy[d];
      sq.push_back(tmp);
      if(xMax < tmp.x) {
	xMax = tmp.x;
      }
      if(yMax < tmp.y) {
	yMax = tmp.y;
      }
      if(tmp.x < xMin) {
        xMin = tmp.x;
      }
      if(tmp.y < yMin) {
        yMin = tmp.y;
      }
    }
    int xRange = xMax-xMin+1;
    int yRange = yMax-yMin+1;
    cout<<xRange<<" "<<yRange<<endl;
  }
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rs64() {
	int64_t n;
	scanf("%" SCNd64, &n);
	return n;
}
#define MOD 1000000007
template<int mod>
struct ModInt{
	int x;
	ModInt():x(0){}
	ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator-()const{return ModInt(-x);}
	ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
	ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
	ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
	ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
	bool operator==(const ModInt &p)const{return x==p.x;}
	bool operator!=(const ModInt &p)const{return x!=p.x;}
	explicit operator int() const { return x; }						   // added by QCFium
	ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
	ModInt inverse()const{
		int a=x,b=mod,u=1,v=0,t;
		while(b>0){
			t=a/b;
			a-=t*b;
			std::swap(a,b);
			u-=t*v;
			std::swap(u,v);
		}
		return ModInt(u);
	}
	friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
		return os<<p.x;
	}
	friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
		long long x;
		is>>x;
		a=ModInt<mod>(x);
		return (is);
	}
};
typedef ModInt<MOD> mint;

struct MComb {
	std::vector<mint> fact;
	std::vector<mint> inversed;
	MComb(int n) { // O(n+log(mod))
		fact = std::vector<mint>(n+1,1);
		for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
		inversed = std::vector<mint>(n+1);
		inversed[n] = fact[n] ^ (MOD-2);
		for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
	}
	mint ncr(int n, int r) {
		return (fact[n] * inversed[r] * inversed[n-r]);
	}
	mint npr(int n, int r) {
		return (fact[n] * inversed[n-r]);
	}
	mint nhr(int n, int r) {
		assert(n+r-1 < (int)fact.size());
		return ncr(n+r-1, r);
	}
};


int main() {
	int n = ri(), k = ri();
	int a[n];
	for (auto &i : a) i = ri();
	std::sort(a, a + n);
	mint res = 0;
	MComb com(n + 1);
	for (int i = 0; i + 1 < n; i++) {
		mint base = com.ncr(n, k);
		if (i + 1 >= k) base -= com.ncr(i + 1, k);
		if (n - 1 - i >= k) base -= com.ncr(n - 1 - i, k);
		res += base * (a[i + 1] - a[i]);
	}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;
typedef int64_t i64;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

typedef struct range {
  i32 l, r;
} range;

typedef range radix_type;
typedef uint32_t u32;

#define RADIX_WIDTH 9
const u32 radix_type_max = 17;
const u32 radix_type_begin = 0;
const u32 radix_width = RADIX_WIDTH;
const u32 radix_mask = (1 << RADIX_WIDTH) - 1;
#undef RADIX_WIDTH

static inline u32 radix_get_bit (radix_type v, u32 shift) {
  return (u32)(v.r - v.l) >> shift & radix_mask;
}

void radix_sort (radix_type *a, u32 n) {
  radix_type * const array = (radix_type *) calloc (n, sizeof (radix_type));
  i32 *next = (i32 *) calloc (n + (1 << radix_width), sizeof (i32));
  i32 *start = next + n;
  for (u32 shift = radix_type_begin; shift < radix_type_max; shift += radix_width) {
    for (i32 i = 0; i < (i32)(1 << radix_width); ++i) {
      start[i] = -1;
    }
    for (i32 i = 0; i < (i32)n; ++i) {
      u32 bit = radix_get_bit (a[i], shift);
      array[i] = a[i];
      next[i] = start[bit];
      start[bit] = i;
    }
    for (i32 bit = radix_mask, i = n - 1; bit >= 0; --bit) {
      for (i32 p = start[bit]; p != -1; p = next[p]) {
	a[i--] = array[p];
      }
    }
  }
  free (array);
  free (next);
}

void add (i32 *bit, i32 x, i32 v) {
  i32 n = bit[0];
  for (i32 i = x; i <= n; i += i & -i) {
    bit[i] += v;
  }
}

i32 find (i32 *bit, i32 x) {
  i32 sum = 0;
  for (i32 i = x; i > 0; i -= i & -i) {
    sum += bit[i];
  }
  return sum;
}

void run (void) {
  i32 n = read_int();
  i32 m = read_int();
  range *p = (range *) calloc (n, sizeof (range));
  for (i32 i = 0; i < n; ++i) {
    p[i].l = read_int();
    p[i].r = read_int() + 1;
  }
  radix_sort (p, n);
  i32 *bit = (i32 *) calloc (m + 2, sizeof (i32));
  bit[0] = m + 1;
  for (i32 d = 1, i = 0; d <= m; ++d) {
    for (; i < n && p[i].r - p[i].l < d; ++i) {
      add (bit, p[i].l, 1);
      add (bit, p[i].r, -1);
    }
    i32 ans = n - i;
    for (i32 j = d; j <= m; j += d) {
      ans += find (bit, j);
    }
    print_int (ans);
    putchar ('\n');
  }
}

int main (void) {
  run();
  return 0;
}


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

int main()
{
  int w,h,n;
  cin >> w >> h >> n;
  
  int x[n],y[n],a[n];
  rep(i,n) cin >> x[i] >> y[i] >> a[i];
  
  int withl = 0,withr = w;
  int haiu = 0,haio = h;; 
  rep(i,n){
    if(a[i] == 1){
      if(x[i] > withl){
        withl = x[i];
      }
    }else if(a[i] == 2){
      if(x[i] < withr){
        withr = x[i];
      }
    }else if(a[i] == 3){
      if(y[i] > haiu){
        haiu = y[i];
      }
    }else if(a[i] == 4){
      if(y[i] < haio){
        haio = y[i];
      }
    }//else if
  }
  
  if(withl >= withr || haiu >= haio){
    cout << 0 << endl;
    return 0;
  }
    
  cout << (withr - withl) * (haio - haiu) << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int x;
    cin>>x;
    for(int i =1 ; ; i++ ) {
        if(360*i%x == 0) {
            cout<<360*i/x<<'\n';
            return 0;
        }
    }
    return 0;
    
}

Measured memory_bytes: 3636
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
//#include<utility>
//#include<initializer_list>
//#include<tuple>
//#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
bool isSubstring(string substr, string t) {
	int n = substr.length();
	int seek = 0;
	rep(i, n) {
		bool ex = 0;
		for (int j = seek; j < t.length(); j++) {
			if (substr[i] == t[j]) {
				ex = 1;
				seek = j + 1;
				break;
			}
		}
		if (ex) {
			continue;
		}
		else {
			return false;
		}
	}
	return true;

}

int LongestCommonSubstring(string s, string t) {
	// Wrong plan
	vector<int>dp(s.length(), 0);
	int n = s.length();
	string lcs = "";
	if (isSubstring(s.substr(n - 1, n), t)) {

		dp[n - 1] = 1;
		lcs = s[n - 1];
	}
	for (int i = n - 2; i >= 0; i--) {
		//string substr = s.substr(i, n);
		string substr = s[i] + lcs;
		int issubst = isSubstring(substr, t);
		if (issubst) lcs = substr;
		dp[i] = dp[i + 1] + issubst;
	}
	return dp[0];
}
int LongestCommonSubstring2(string s, string t) {
	vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1, 0));
	int n = s.length() + 1;
	int m = t.length() + 1;
	rep(i, n - 1) {
		rep(j, m - 1) {
			dp[i + 1][j + 1] = s[i] == t[j] ? dp[i][j] + 1 : max(dp[i][j + 1], dp[i + 1][j]);
		}
	}
	return dp[n - 1][m - 1];
}
int main() {
	//cout << isSubstring("abc", "abcde") << endl;
	//cout << isSubstring("bd", "abcde") << endl;
	//cout << isSubstring("db", "abcde") << endl;

	//cout << LongestCommonSubstring2("bacd", "becd") << endl;
	//cout << LongestCommonSubstring2("abcd", "becd") << endl;
	//cout << endl;
	//cout << LongestCommonSubstring2("a", "a") << endl;
	//cout << LongestCommonSubstring2("bbb", "bbb") << endl;
	//cout << LongestCommonSubstring2("aba", "bbaba") << endl;
	//cout << LongestCommonSubstring2("abababbbaa", "bbabaabba") << endl;
	//cout << LongestCommonSubstring2("a", "aaaaa") << endl;
	//cout << LongestCommonSubstring2("aizojfeiz", "aaaizojifeizz") << endl;
	//cout << LongestCommonSubstring2("zzyiioxizu", "zzsyoizuo") << endl;
	//cout << LongestCommonSubstring2("iooooioiooiio", "ooiiioioiooooiioio") << endl;
	//cout << LongestCommonSubstring2("ajfoaooieellzljieoaelj", "ajoiiffoaolliseellzljieoaelj") << endl;
	//cout << LongestCommonSubstring2("zzzzzyyzyy", "zzyyyyz") << endl;
	//cout << LongestCommonSubstring2("abcdef", "fedcba") << endl;
	//cout << LongestCommonSubstring2("abc", "xyz") << endl;
	int q;
	cin >> q;
	vector<string> s(q);
	vector<string> t(q);
	rep(i, q) {
		cin >> s[i] >> t[i];
	}
	rep(i, q) {
		cout << LongestCommonSubstring2(s[i], t[i]) << endl;
	}

	return 0;
}

Measured memory_bytes: 6796
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m>>k;
    rep(i,n+1){
        rep(j,m+1){
            ans=m*i+n*j;
            ans-=i*j*2;
            if(ans==k){
                Cout("Yes");
                return 0;
            }
        }
    }
    Cout("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N, M; cin  >> N >> M;
  vi L(M), R(M);
  rep(i,M) {
    cin >> L.at(i) >> R.at(i);
    L.at(i)--, R.at(i)--;
  }

  cout << max(*min_element(all(R))-*max_element(all(L))+1,0) << endl;
}

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

ll n, h, a, b;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> h;
    
    // Damage, 0 = slash, 1 = throw
    vector<pair<ll, ll>> katanas;
    for (int i = 0; i < n; i++) {
		cin >> a >> b;
		katanas.push_back({a, 0});
		katanas.push_back({b, 1});
	}
	sort(katanas.begin(), katanas.end(), greater<pair<ll, ll>>());
	
	ll damage = 0, hits = 0;
	for (int i = 0; i < 2*n; i++) {
		if (damage >= h) break;
		if (katanas[i].second == 1) {
			damage += katanas[i].first;
			hits++;
		} else {
			hits += ceil((h - damage) / (long double)katanas[i].first);
			break;
		}
	}
	cout << hits;
    return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
int main() {
    unordered_map<string, int> cnt;
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        cnt[s]++;
    }

    int M; cin >> M;
    for (int i = 0; i < M; i++) {
        string s;
        cin >> s;
        cnt[s]--;
    }

    int ma = 0;
    for (auto const &x: cnt) {
        ma = max(ma, x.second);
    }

    cout << ma << endl;

    return 0;
}


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

int main() {
  long A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  long dis = abs(A - B);
  long sp = V - W;
  cout << ((sp * T >= dis) ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 3644
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
const int maxn = 1e6 + 6;
ll dp[maxn];
ll n, W;
ll v[maxn], w[maxn];

int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    memset(dp, 0x3f, sizeof(dp));
    sf(n, W);
    rep(i, 1, n) sf(w[i], v[i]);
    ll ans = 0ll;
    dp[0] = 0;
    rep(i, 1, n) {
        per(j, (int)1e5, v[i]) {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
            pr(j);prln(dp[j]);
            if (dp[j] <= W) chmax(ans, j);
        }
    }
    cout << ans << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 11392
#include <iostream>
using namespace std;
int main() {
    int a = 0;
    int b = 0;
    int c = 0;
    cin >> a >> b >> c;
    int min = 9999;
    if(a+b < min){
        min = a +b;
    }
    if(b + c < min){
        min = b + c;
    }
    if(c + a < min){
        min = c + a;
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005],b[200005];
int main()
{
	ll n,m,k,x,ans=0;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++) cin>>x,a[i]=a[i-1]+x;
	for(int i=1;i<=m;i++) cin>>x,b[i]=b[i-1]+x;
	ll j=m;
	for(int i=0;i<=n;i++)
	{
		if(a[i]>k) break;
		while(a[i]+b[j]>k) j--;
		ans=max(ans,i+j);
	}
	cout<<ans;
}

Measured memory_bytes: 6732
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=2e6+5,M=1e7+50,mo=1e9+7;
ll ten[20],inc[20],ans,d,upb,i,j,cons,L,D[N],xs;
void dfs(int x,ll y,ll z)
{
	if (x>L/2-1)
	{
		if (L%2) z*=10;
		if (y==d)
			ans+=z;
		return ;
	}
	ll i=-9;
	while (i<=9&&y+i*(ten[L-x-1]-ten[x])<=d) i++;
	i--;
	D[x]=i;
	dfs(x+1,y+i*(ten[L-x-1]-ten[x]),z*(inc[i+cons]-(x==0&&i>=0)));
	i++;
	if (i>9) return ;
	D[x]=i;
	dfs(x+1,y+i*(ten[L-x-1]-ten[x]),z*(inc[i+cons]-(x==0&&i>=0)));
	//d[i]=s[i]-s[l-1-i]，gx=d[i]*(10^i-10^(l-i-1)) , 
	//s[L-1]!=0, 当d>=0,存在s[L-1]=0 
}
int main()
{
	scanf("%lld",&d);
	xs=1;
	//while (d%10==0) d/=10,xs*=10;
	ten[0]=1;
	fo(i,1,18) ten[i]=ten[i-1]*10;
	cons=10;
	fo(i,0,9) fo(j,0,9) inc[i-j+cons]++;
	fo(upb,0,9) if (ten[upb]>d) break;
	fo(L,0,19)
		dfs(0,0,1);
	//xs=xs/10*9; 
	printf("%lld",ans*xs);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int t = 1e9, n;
  cin >> n;
  rep(i, n+1){
    int tmp = 0, c = i, d = n - i;
    while(c > 0){
      tmp += c % 6;
      c /= 6;
    }
    while(d > 0){
      tmp += d % 9;
      d /= 9;
    }
    t = min(t, tmp);
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
A = []
b = []
for i in range(3):
  A.append(list(map(int, input().split())))
N = int(input())
for i in range(N):
  b.append(int(input()))

for i in range(N):
  for j in range(3):
    if b[i] in A[j]:
      A[j][A[j].index(b[i])] = 0

flag = 0

for i in range(3):
  if sum(A[i]) == 0:
    flag = 1

for i in range(3):
  if A[0][i] + A[1][i] + A[2][i] == 0:
    flag = 1

if A[0][0] + A[1][1] + A[2][2] == 0:
  flag = 1

if A[0][2] + A[1][1] + A[0][2] == 0:
  flag = 1

if flag == 1:
  print('Yes')
else:
  print('No')

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

typedef struct{
    long i;
    long v;
} pair_t;

bool pless(const pair_t& a, const pair_t& b){
    if(a.v!=b.v){
        return a.v<b.v;
    }else{
        return a.i<b.i;
    }
}

long ifind(const vector<pair_t>& v, long ind){
    long n=v.size();
    for(long i=0; i<n; i++){
        if(v[i].i==ind){
            return i;
        }
    }
}

int main(void){
    long n;
    cin >> n;
    vector<pair_t> v(n);
    vector<long> f(n/2);
    for(long i=0; i<n; i++){
        v[i].i = i;
        cin >> v[i].v;
    }
    sort(v.begin(), v.end(), pless);
    for(long i=0; i<n/2; i++){
        f[i] = v[i].i;
    }
    sort(f.begin(), f.end());
    /*
    for(long i=0; i<n; i++){
        cout << v[i].i << " ";
    }
    cout << endl;
    for(long i=0; i<n; i++){
        cout << v[i].v << " ";
    }
    cout << endl;
    */
    for(long i=0; i<n; i++){
        auto k=binary_search(f.begin(), f.end(), i);
        //cout << "k=" << k << endl;
        if(k){
            cout << v[n/2].v << endl;
        }else{
            cout << v[n/2-1].v << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for ( int i = 1; i <= m; ++i ) {
        for ( int j = 1; j <= d; ++j ) {
            if ( ( j % 10 >= 2 ) && ( j / 10 >= 2 ) && ( j % 10 ) * ( j / 10 ) == i ) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int n,m;
  cin>>n>>m;
  bool flag=false;
  int ans=m;
  for(;n--;)
    {
      int s1,s2;
      cin>>s1>>s2;
      m+=s1;
      m-=s2;
      if(m<0)
	flag=true;
      ans=max(ans,m);      
    }
  if(flag)
    ans=0;
  cout<<ans<<endl;
}

Measured memory_bytes: 1160
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''


get = stdin.readline().rstrip().split()
N = int(get[0])
K = int(get[1])
people = stdin.readline().rstrip().split()
res = len([x for x in people if int(x) >= K])
print(res)


Measured memory_bytes: 10124
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

int A[1000][999];
bool todayState[1000][1000*999/2];
queue<int>que;
vector<int>shintyoku(1000, 0);
int endCount = 0;
int N;

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N;
	cin >> N;

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

	sort(v.begin(),v.end());
	double current = v[0];
	for (int i = 1; i < N;++i) {
		current = (current + (double)v[i]) / 2.0;
	}
	printf("%.7f\n",current);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		str = str.replace(',', ' ');
		str = str.replace('.', ' ');
		String[] s = str.split(" ");
		boolean first = true;
		for(int i = 0; i < s.length; i++){
			if(s[i].length() >= 3 && s[i].length() <= 6){
				if(!first){
					System.out.print(" ");
				}
				System.out.print(s[i]);
				
				first=false;
			}
		}
		System.out.println();
	}

}

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

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

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

    ll ans = 0;
    if(a[0] > x){
        ans += a[0] - x;
        a[0] -= ans;
    }

    for(int i = 1; i < n; i++){
        if(a[i - 1] + a[i] > x){
            while(1){
                if(a[i - 1] + a[i] == x){
                    break;
                }
                ans++;
                a[i]--;
            } 
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int ll

int h, w, n, k, ans;

int pot[50*50];

int query(int y1, int y2, int x1, int x2)
{
	cout << "? " << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
	int ans;
	cin >> ans;
	return ans;
}

void solve(int y1, int y2, int x1, int x2, int cnt, int split)
{
	if(cnt==0)
		return;

	if(cnt==(y2-y1+1)*(x2-x1+1))
	{
		for(int i = y1; i <= y2; ++i)
		{
			for(int j = x1; j <= x2; ++j)
			{
				ans += pot[i*w+j];
				ans %= k;
			}
		}

		return;
	}

	if(y1!=y2)//split)
	{
		int m = (y1+y2)/2;
		int h = query(y1, m, x1, x2);
		solve(y1, m, x1, x2, h, split^1);
		solve(m+1, y2, x1, x2, cnt-h, split^1);
	}
	else
	{
		int m = (x1+x2)/2;
		int h = query(y1, y2, x1, m);
		solve(y1, y2, x1, m, h, split^1);
		solve(y1, y2, m+1, x2, cnt-h, split^1);
	}
}

int32_t main()
{
	cin >> h >> w >> n >> k;

	pot[0] = 1;

	for(int i = 1; i < 50*50; ++i)
	{
		pot[i] = pot[i-1]*2%k;
	}

	for(int j = 0; j < w; j += 16)
	{
		for(int i = 0; i < h; i += 16)
		{
			solve(i, min(i+15, h-1), j, min(j+15, w-1), query(i, min(i+15, h-1), j, min(j+15, w-1)), 1);
		}
	}

	/*for(int i = 0; i < h; i += 5)
	{
		for(int j = 0; j < w; j += 5)
		{
			solve(i, i+4, j, j+4, query(i, i+4, j, j+4), 1);
		}
	}*/

	//solve(0, h-1, 0, w-1, n, 1);

	cout << "! " << ans << endl;
}

Measured memory_bytes: 720