akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

struct edge{int to,cost;};
const int inf=1e9;

int N,M;
vector<edge> G[100010];

vint dijkstra(int s)
{
    vint dist(N,inf); dist[s]=0;
    priority_queue<pint,vector<pint>,greater<pint> >Q;
    Q.push(pint(0,s));

    while(!Q.empty())
    {
	pint p=Q.top(); Q.pop();
	int v=p.second;
	if(p.first>dist[v]) continue;

	for(auto e:G[v]){
	    if(dist[e.to]>dist[v]+e.cost){
		dist[e.to]=dist[v]+e.cost;
		Q.push(pint(dist[e.to],e.to));
	    }
	}
    }
    return dist;
}

signed main()
{
    int s; cin>>N>>M>>s;
    REP(i,M){
	int a,b,c; cin>>a>>b>>c;
	G[a].push_back((edge){b,c});
    }

    vint dist=dijkstra(s);
    REP(i,N){
	if(dist[i]==inf) cout<<"INF"<<endl;
	else cout<<dist[i]<<endl;
    }

}


Measured memory_bytes: 19488
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

void test_case(){
    
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    int h, w;
    cin >> h >> w;
    
    vector< string > a;
    rng(i, 0, h){
        string s; cin >> s;
        
        a.push_back(s);
    }
    int dp[h][w+1] = {};
    for( int i = 0; i< h; i++){
        for(int j = 0; j< w; j++){
            if( i == 0){
                if( j != 0){
                    if(a[i][j] == '.')
                        dp[i][j] = dp[i][j-1];
                    else if( a[i][j-1] == '#'){
                        dp[i][j] = dp[i][j-1];
                    }
                    else{
                        dp[i][j] = dp[i][j-1] + 1;
                    }
                }
                else{
                    if(a[i][j] == '#')
                        dp[i][j] = 1;
                }
            }
            else{
                if( j == 0){
                    if(a[i][j] == '.')
                        dp[i][j] = dp[i-1][j];
                    else if( a[i-1][j] == '#'){
                        dp[i][j] = dp[i-1][j];
                    }
                    else{
                        dp[i][j] = dp[i-1][j] + 1;
                    }
                }
                else{
                    dp[i][j] = INT_MAX;
                    
                    if( a[i][j] == '.'){
                        dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
                        continue;
                    }
                    if( a[i-1][j] == '#')
                        dp[i][j] = min(dp[i][j], dp[i-1][j]);
                    if(a[i][j-1] == '#')
                        dp[i][j] = min(dp[i][j], dp[i][j-1]);
                    
                    dp[i][j] = min({dp[i][j], dp[i-1][j]+1, dp[i][j-1]+1});
                }
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
//////////////////////////////////////
int main(){
    int n;
    cin>>n;
    vp xy(n);
    rep(i,n)cin>>xy[i].fs>>xy[i].sc;
    sort(all(xy));
    map<P,int>mp;
    rep(i,n){
        rep(j,i){
            int p=xy[i].fs-xy[j].fs;
            int q=xy[i].sc-xy[j].sc;
            mp[P(p,q)]++;
        }
    }
    int mx=0;
    for(auto x:mp){
        chmax(mx,x.sc);
    }
    cout<<n-mx<<endl;
    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> rd(n);
	for(int &x: rd)
		scanf("%d",&x);
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+k && j<n;j++)
		{
			dp[j] = min(dp[j],dp[i]+abs(rd[i]-rd[j]));
		}
	}
	cout<<dp[n-1]<<'\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
ll dp[100005];
int main()
{
    fio;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(c>d)
        swap(c,d);
    if(c==1)
        cout<<0;
    else
    {
        ll divc=(b-a)/c;
        if(a%c==0||b%c==0)
            divc++;
        else if(a%c>b%c)
            divc++;
        ll divd=(b-a)/d;
        if(a%d==0||b%d==0)
            divd++;
        else if(a%d>b%d)
            divd++;
        ll mul=(d*c)/__gcd(d,c);
        ll both=(b-a)/mul;
        if(a%mul==0||b%mul==0)
            both++;
        else if(a%mul>b%mul)
            both++;
        cout<<(b-a+1)-divd-divc+both;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin >> s;
    const char* cstr = s.c_str();
    bool check = false;
    while(*cstr != '\0'){
        if(*cstr == 'h' && *(cstr+1) == 'i'){
            check = true;
        }else{
            check = false;
        }
        cstr += 2;
    }
    cout << (check? "Yes": "No") << endl;
}

Measured memory_bytes: 256
import sys
import os
import collections

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.buffer.readline().split()))
    e = N * (N-1) // 2
    o = 0 if M <= 1 else M * (M-1) // 2
    print(e+o)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
int main(void){
   int N,A,B;
   cin>>N>>A>>B;
   int P[N];
   for(int i=0;i<N;i++){
       cin>>P[i];
   }
   sort(P,P+N);
   int count1=0; int count2=0; int count3=0;
   for(int i=0;i<N;i++){
       if(P[i]<=A){count1++;}
       if(A+1<=P[i]&&P[i]<=B){count2++;}
       if(B+1<=P[i]){count3++;}
   }
   int ans=min({count1,count2,count3});
   if(ans>0){cout<<ans;}
   else {cout<<0;}
   return 0;
}


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

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

/*
113459
419153 25
391514 25
*/

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 0, s = 0;
    if (N % 2 == 1) {
        int b = A[N / 2], c;
        rep(i, N / 2) {
            c = A[i];
            s += abs(b - c);
            b = A[N - 1 - i];
            s += abs(b - c);
        }
        ans = s;
        s = 0;
        b = A[N / 2];
        rep(i, N / 2) {
            c = A[N - 1 - i];
            s += abs(b - c);
            b = A[i];
            s += abs(b - c);
        }
        ans = max(ans, s);
    } else {
        int b = A[N / 2], c;
        rep(i, N / 2 - 1) {
            c = A[i];
            s += abs(b - c);
            b = A[N - 1 - i];
            s += abs(b - c);
        }
        c = A[N / 2 - 1];
        s += abs(b - c);
        ans = s;
        s = 0;
        b = A[N / 2 - 1];
        rep(i, N / 2 - 1) {
            c = A[N - 1 - i];
            s += abs(b - c);
            b = A[i];
            s += abs(b - c);
        }
        c = A[N / 2];
        s += abs(b - c);
        ans = max(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//dp[i][j]:iからとjから見始めた時の共通部分列の長さ
int dp[5005][5005];

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

    int N;cin >> N;
    string S;cin >> S;
    for(int i = 0;i<5005;i++)for(int j = 0;j<5005;j++) dp[i][j] = 0;
    for(int i = N-1;i>=0;i--){
        for(int j = N-1;j>=0;j--){
            if(S.at(i) == S.at(j)) dp[i][j] = dp[i+1][j+1]+1;
            else dp[i][j] = 0;
        }
    }

    int ans = 0;
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++){
            if(i >= j) continue;
            ans = max(ans,min(dp[i][j],j-i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 101492
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
int main()
{
	// freopen("yahoo2019-A.in", "r", stdin);
	int n, k;
	scanf("%d%d", &n, &k);
	puts(k <= (n + 1 >> 1) ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;
const long long MOD = 1e9 + 7;

int main(int argc, char *argv[])
{
  int N, A[123456];
  map<long long , long long> B;
  long long ans = 1;

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

  if (N % 2 == 1 && B[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  for (auto v : B) {
    if (N%2 == 1 && v.first == 0) continue;
    if (v.second != 2) {
      cout << 0 << endl;
      return 0;
    }

    ans *= 2;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


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


int main()
{
  string S;
  int S_len;
  cin >> S;
  S_len = S.size();
  int i = 0, cnt = 1;
  while (i < S_len - 1)
  {
    if (S.at(i) == S.at(i + 1))
    {
      if (i == S_len - 2)
      {
        cnt -= 2;
      }
      else if (i == S_len - 3)
      {
        cnt -= 1;
      }
      i += 2;
      cnt += 2;
    }
    else
    {
      cnt++;
    }
    i++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;

int main() {
    int a, b, c, x;    cin >> a >> b >> c >> x;

    int cnt = 0;

    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                int y = 500*i + 100*j + 50*k;
                if (y == x)
                    cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n,c[200005],res=1,tmp,two[200005]={1},fin=0;
int main() {
	cout<<setprecision(10);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c[i];
		tmp=res;
		res*=2;
		res%=mod;
	}
	for(int i=1;i<200004;i++){
		two[i]=2*two[i-1];
		two[i]%=mod;
	}
	sort(c,c+n,greater<long long int>());
	long long int memo=tmp;
	for(int i=0;i<n;i++){
		fin+=memo*c[i];
		fin%=mod;
		memo+=two[n-2];
		memo%=mod;
	}
	cout<<(res*fin)%mod<<endl;
	

} 


Measured memory_bytes: 3328
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Random;
import java.util.Collections;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Deque;

public class Main{
    public static void main (String args[]){

        Scanner first = new Scanner(System.in);
        int first_word = first.nextInt();
        
        int hundred = first_word/100;
        first_word = first_word-hundred*100;
        int ten     = (first_word)/10;
        first_word = first_word - ten*10;
        
        int one     = first_word;
        if(hundred == one ){
            System.out.println("Yes");

        }else{
            System.out.println("No");

        }
    }
}

Measured memory_bytes: 23760
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	var str = lines.join(), a = "a".charCodeAt(), z = "z".charCodeAt();
	for(var n=a;n<=z;n++){
		var c = String.fromCharCode(n);
		console.log(c + " : " + (str.split(new RegExp(c, "i")).length-1));
	}
}

Measured memory_bytes: 15548
from collections import Counter,defaultdict

class Bit:
  def __init__(self,n):
    self.size = n
    self.tree = [0]*(n+1)
 
  def sum(self,i):
    s = 0
    while i > 0:
      s += self.tree[i]
      i -= i & -i
    return s

  def add(self,i,x):
    while i <= self.size:
      self.tree[i] += x
      i += i & -i

s = input()
n = len(s)
c = Counter(s)
flg = 0
if n%2 == 0:
  for i in c.values():
    if i%2:
      print(-1)
      exit()
else:
  for st,i in c.items():
    if i%2 and flg:
      print(-1)
      exit()
    elif i%2:
      flg = 1
ans = 0
fstr = []
lstr = []
dc = defaultdict(int)
ptr = 0
for i in range(n):
  si = s[i]
  dc[si] += 1
  cnt = dc[si]
  if c[si]%2:
    if cnt*2-1 == c[si]:
      ans += i-ptr
      continue
  if cnt <= c[si]//2:
    ans += i-ptr
    ptr += 1
    fstr.append(si)
  else:
    lstr.append(si)
lstr = lstr[::-1]
n //= 2
perm = [0]*n
fdc = defaultdict(list)
ldc = defaultdict(int)
lcnt = 0
for i in range(n):
  fi = fstr[i]
  fdc[fi].append(i+1)
for i in range(n):
  li = lstr[i]
  perm[i] = fdc[li][ldc[li]]
  ldc[li] += 1
sol = Bit(n+2)
for i in range(n):
  p = perm[i]
  ans += sol.sum(n+1)-sol.sum(p)
  sol.add(p,1)
print(ans)

Measured memory_bytes: 59484
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int n;
    cin >> n;
    vector<int> data(n);
    rep(i, n) cin >> data.at(i);

    int cnt = 0;
    rep(i, n - 2) {
        if(data.at(i) < data.at(i + 1) && data.at(i + 1) < data.at(i + 2)) cnt++;
        if(data.at(i) > data.at(i + 1) && data.at(i + 1) > data.at(i + 2)) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    const int MAX =200005;
const int MOD =1000000007;

signed main(){
  int n;
  cin>>n;
  int a,b,p[n]={},q[n]={};
  for(int i=0;i<n;i++){
    cin>>a;a--;
    p[a]++;
  }
  for(int i=0;i<n;i++){
    cin>>b;b--;
    q[b]++;
  }
  for(int i=0;i<n;i++)if(p[i]>n-q[i]){
    cout<<"No"<<endl;
    return 0;
  }
  set<pair<int,int>> st1,st2,st3;
  vector<pair<int,int>> ans;
  for(int i=0;i<n;i++){
    if(p[i]+q[i]!=0){
      st1.insert({-p[i]-q[i],i});}
    if(p[i]!=0)  st2.insert({p[i],i});
    if(q[i]!=0)  st3.insert({q[i],i});
    

  }
  for(int i=0;i<n;i++){
    auto it=st1.begin();
    int j=it->second;
    st1.erase(it);
    it=st1.begin();
    if(p[j]+q[j]==n-i&&p[it->second]+q[it->second]==n-i){
      for(int k=0;k<p[j];k++)ans.push_back({j,it->second});
    for(int k=0;k<q[j];k++)ans.push_back({it->second,j});
    break;
    }
    st2.erase({p[j],j});
    st3.erase({q[j],j});
    int j2;
    if(p[j]==0){
      q[j]--;
      it=st2.begin();
      j2=it->second;
      ans.push_back({j2,j});
       st1.erase({-p[j2]-q[j2],j2});
      st2.erase({p[j2],j2});
    st3.erase({q[j2],j2});
    p[j2]--;
    }else{
      p[j]--;
      it=st3.begin();
      j2=it->second;
      ans.push_back({j,j2});
       st1.erase({-p[j2]-q[j2],j2});
      st2.erase({p[j2],j2});
    st3.erase({q[j2],j2});
    q[j2]--;
    }
  if(p[j]+q[j]!=0)st1.insert({-p[j]-q[j],j});
  if(p[j]!=0)st2.insert({p[j],j});
  if(q[j]!=0)st3.insert({q[j],j});
   if(p[j2]+q[j2]!=0) st1.insert({-p[j2]-q[j2],j2});
  if(p[j2]!=0)st2.insert({p[j2],j2});
  if(q[j2]!=0)st3.insert({q[j2],j2});
  // cerr<<j+1<<j2+1<<' ';
  }
  cout <<"Yes"<<endl;
  sort(ans.begin(),ans.end());
  for(auto&& i:ans)cout <<i.second+1<<' ';
  
}

Measured memory_bytes: 44040
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;


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

  long n,a,b; cin >> n >> a >> b;
  long ans = a*(n/(a+b));
  ans += min(a,n%(a+b));
  cout << ans << endl;
}






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

using namespace std;

int main()
{
    int H, W;
    cin>>H>>W;
    vector<string> a(H);
    for (string &t: a)
        cin>>t;
    vector<vector<int>> T(H, vector<int>(W));
    T[0][0] = 1;
    for (int y=0; y<H; y++)
    for (int x=0; x<W; x++)
    if (a[y][x] != '#')
    {
        if (y>0)
            T[y][x] += T[y-1][x];
        if (x>0)
            T[y][x] += T[y][x-1];
        T[y][x] %= 1000000007;
    }
    cout<<T[H-1][W-1]<<endl;
}


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

typedef long long ll;

int main(){
	ll k, a, b, ans;
	cin >> k >> a >> b;
	if((b - a <= 2) || k < a + 1) ans = k + 1;
	else{
		ans = a + (b - a) * ((k - a + 1) / 2);
		if((k - a + 1) % 2 == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
"IOI 2018" Japan, Tokyo.
*/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back()
#define ll long long
#define ld long double
#define ok puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define random ((1 << rand()) ^ rand())

using namespace std;

inline ll min(ll a, ll b) {
    return (a > b) ? b : a;
}

inline ll max(ll a, ll b) {
    return (a > b) ? a : b;
}

const int N = 5e3 + 7;;
const int inf = 1e9 + 7;
const ll linf = 1e18 + 9;
const double eps = 1e-004;

ll a[N];
int n, m;
ll numlog[N], pref[N];
ll b[N][203], ans;
ll table[203][20][N];

void build (int pos) {
    for (int i = 0; i <= numlog[n]; i++) {
        int curlen = (1 << i);
        for (int j = 1; j <= n; j++) {
            if (!i) {
                table[pos][i][j] = b[j][pos];
                continue;
            }
            table[pos][i][j] = max(table[pos][i - 1][j], table[pos][i - 1][j + curlen / 2]);
        }
    }
}

int get (int pos, int l, int r) {
    int curlog = numlog[r - l + 1];
    return max(table[pos][curlog][l], table[pos][curlog][r - (1 << curlog) + 1]);
}

void divide (int l, int r, int optl, int optr) {
    if (l > r) return ;
    int mid = (l + r) >> 1, opt = l;
    ll c = 0, res;
    for (int i = optl; i <= min(mid, optr); i++) {
        res = 0;
        for (int j = 1; j <= m; j++)
            res += get(j, i, mid);
        res -= pref[mid - 1] - pref[i - 1];
        if (res > c) {
            c = res;
            opt = i;
        }
    }
    ans = max(ans, c);
    divide(l, mid - 1, optl, opt);
    divide(mid + 1, r, opt, optr);
}

void pre () {
    scanf ("%d %d", &n, &m);
    for (int i = 2; i < N; i++) {
        numlog[i] = numlog[i / 2] + 1;
    }
    for (int i = 1; i < n; i++) {
        scanf ("%lld", &a[i]);
        pref[i] = pref[i - 1] + a[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf ("%lld", &b[i][j]);
        }
    }
    for (int i = 1; i <= m; i++) {
        build(i);
    }
}

main() {
    pre();
    divide(1, n, 1, n);
    printf ("%lld", ans);
}


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

using namespace std;

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

    int cnt = 0;

    if (s[0]=='1') cnt++;
    if (s[1]=='1') cnt++;
    if (s[2]=='1') cnt++;

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
// C - Lower

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

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

	int move = 0;
	int max_move = 0;
	int H, next_H;
	cin >> H;
	for (int i=0; i<N-1; i++) {
		cin >> next_H;
		if (H >= next_H) {
			move++;
			max_move = max(move, max_move);
		} else {
			move = 0;
		}

		H = next_H;
	}

	cout << max_move << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){  
	int H, W, i, j, k;
	for(i = 0; i < 90000; i++){
	scanf("%d %d", &H, &W);
	if ( H == 0 && W == 0) break;
	
	for (j = 0; j < H; j++){
		if(j == 0 || j == H - 1){
		for(k = 0; k < W; k++){
		printf("#");
		}}
		else{
		for(k = 0; k < W; k++){
		if(k == 0 || k == W -1)printf("#");
		else printf(".");
		}}
		printf("\n");
	}printf("\n");}
return 0;}



Measured memory_bytes: 1980
#include<stdio.h>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=500100,P=998244353;
inline char gc(){
    static char buf[N],*s=buf,*t=buf;
    return s==t&&(t=(s=buf)+fread(buf,1,N,stdin),s==t)?EOF:*s++;
}
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
ll ans,a[N];
int n,b[N];
int main(){
	//freopen("1.out","w",stdout);
	int i;
	n=read();
	for(i=1;i<=n;i++)a[i]=read(),b[i]=read();
	for(i=n;i;i--){
		a[i]+=ans;
		a[i]=a[i]%b[i];
		if(a[i])ans+=b[i]-a[i];
	}write(ans);
	return 0;
}

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

int main(){
  int n;
  int i,j;
  int *num,tmp;
  int x;
  
  scanf("%d",&n);

  num=malloc(sizeof(int)*(n+1));

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

  x=num[n-1];
  
  for(j=0,i=0;j<n;j++){
    if(num[j]<=x){
      tmp=num[i];
      num[i]=num[j];
      num[j]=tmp;
      i++;
    }
    
  }
  for(j=0;j<n;j++){
      if(i-1==j) printf("[%d] ",num[j]);
      else if(j!=n-1) printf("%d ",num[j]);
      else printf("%d\n",num[j]);
    }
    free(num);
    
    return 0;
 }

Measured memory_bytes: 888
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

d, t, s = LI()
if s*t < d:
    print('No')
else:
    print('Yes')

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    fastio;
    //fileio;

    ll a;
    cin >> a;
    cout << (a*a*a) + (a*a) + a << "\n";
    return 0;
}


Measured memory_bytes: 3644
import itertools
N = int(input())
L = list(map(int, input().split()))
l = list(itertools.combinations(set(L), 3))

count = 0
for a, b, c in l:
    if a+b>c and b+c>a and c+a>b:
        count +=1*L.count(a)*L.count(b)*L.count(c)
print(count)

Measured memory_bytes: 86524
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) return b; return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << '\n'; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
#define debug2(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
void err(istream_iterator<string> it, T a, Args... args) { cerr << "[ " << *it << " = " << a << " ]"; err(++it, args...);}
#define time__(d) for (auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second; debug2("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 9223372036854775800;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 62;
const long double PI = 3.141592653589793;
const int DIGITSIZE = 18;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
int x8[] = {1, 1, 1, -1, -1, -1, 0, 0};
int y8[] = {1, 0, -1, 1, 0, -1, 1, -1};
bool takeTestCases = 0;
bool printCaseNo = 0;

void getac(int T) {
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    ll ans=0;
    for(int i=0;i<k;i++){
        ans+=arr[i];
    }
    cout<<ans<<'\n';
}
int  main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
    fastio;
    int t = 1;
    if (takeTestCases) cin >> t;
    int t_t = 1;
    while (t--) {
        if (printCaseNo)
        case (t_t);
        getac(t_t);
        t_t++;
    }
    cerr << "Total time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 3812
N, x = map(int, input().split())

if x == 1 or x == 2 * N - 1 :
    print('No')

else :
    print('Yes')
    l, r = [1], [2*N-1]
    
    i = 2 * N - 2
    while len(l) < N - 1 :
        if i != x :
            l.append(i)
        i -= 1
    
    i = 2
    while len(r) < N - 1 :
        if i != x :
            r.append(i)
        i += 1
        
    for i in l[::-1] + [x] + r :
        print(i)
    

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

int tabnum(string &s){
	int ret = 0;
	for(; ret<(int)s.length() && s[ret]==' '; ret++);
	return ret;
}

int main(){
	string match;
	getline(cin, match);
	vector<string> stc(1, "");
	vector<int> tnum(1, -1);
	map<string, string> ext;
	string input;
	while(getline(cin, input)){
		int intab = tabnum(input);
		while(tnum.back() >= intab){
			stc.pop_back();
			tnum.pop_back();
		}
		string tmp = input.substr(intab, input.length() -intab);
		if(input.back() == ':'){
			tmp.pop_back();
			ext[stc.back() +"." +tmp] = "object";
			stc.push_back(stc.back() +"." +tmp);
			tnum.push_back(intab);
		}else{
			int pos = 0;
			while(tmp[pos] != ':') pos++;
			ext[stc.back() +"." +tmp.substr(0, pos)] = tmp.substr(pos+2, tmp.length()-pos-2);
		}
	}
	
	if(ext.count(match) == 0){
		cout << "no such property" << endl;
	}else if(ext[match] == "object"){
		cout << "object" << endl;
	}else{
		cout << "string \"" << ext[match] << "\"" << endl;
	}
	return 0;
}



Measured memory_bytes: 3416
from collections import defaultdict

n, m = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(m)]
ypi = sorted((y, p, i) for i, (p, y) in enumerate(PY))
d = defaultdict(lambda: 0)

ans = [None]*m

for y, p, i in ypi:
    d[p] += 1
    ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)

print(*ans, sep='\n')

Measured memory_bytes: 44088
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;
using P = pair<ll, ll>;
int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<P> B(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        B.at(i) = P(A[i], i);
    }

    sort(B.begin(), B.end(), greater<P>());
    vector<vector<ll>> dp = make_vec<ll>(N + 1, N + 1);  // x人を左端、y人を右端に寄せる
    for (int x = 0; x < N; x++) {
        for (int y = 0; x + y < N; y++) {
            chmax(dp[x + 1][y], dp[x][y] + B[x + y].first * abs(B[x + y].second - x));
            chmax(dp[x][y + 1], dp[x][y] + B[x + y].first * abs(B[x + y].second - (N - 1 - y)));
        }
    }
    ll ans = 0;
    for (int i = 0; i <= N; i++) {
        chmax(ans, dp[i][N - i]);
    }
    cout << ans << endl;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

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

ll dp[3010];

ll solve(ll n)
{
	if (dp[n] != -1) return dp[n];
	ll res = (n >= 3);
	for (ll i = 3; i <= n; ++i)
	{
		(res += solve(n - i)) %= MOD;
	}
	return dp[n] = res;
}

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n; cin >> n;
	REP(i, n+1) dp[i] = -1;
	std::cout << solve(n) << std::endl;
	
	return 0;
}


Measured memory_bytes: 3664
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i32>();
    let upper = a / 100;
    let lower = a % 100;
    let ans = match (01 <= upper && upper <= 12, 01 <= lower && lower <= 12) {
        (true, true) => "AMBIGUOUS",
        (true, false) => "MMYY",
        (false, true) => "YYMM",
        (false, false) => "NA"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
h, w = map(int,input().split())
s = [input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            check = 0
            for x, y in ([1,0],[0,1],[0,-1],[-1,0]):
                new_h, new_w = i + x, j + y
                #print(new_h,new_w)
                if new_h < 0 or new_h >= h or new_w < 0 or new_w >= w:
                    continue
                if s[new_h][new_w] == '.':
                    check += 1
            if check == 4:
                print('No')
                quit()
print('Yes')

Measured memory_bytes: 3064
#!/usr/bin/env python3

def main():
    sa = input().split(' ')
    a = [int(s) for s in sa]

    l = a[0] + a[1]
    r = a[2] + a[3]

    if l > r:
        print('Left')
    elif l < r:
        print('Right')
    else:
        print('Balanced')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#define int long long
int x=1000000007;
//a^b mod x
int mod(int a,int b)
{
    int ans=1;
    for(int i=0;i<30;i++)
    {
        if(b%2==1)ans=ans*a%x;
        a=a*a%x;
        b/=2;
    }
    return ans;
}


signed main()
{
    int m,n;
    scanf("%lld%lld",&m,&n);
    printf("%lld\n",mod(m,n));

    return 0;
}

Measured memory_bytes: 1028
#include <cstdio>
#include <algorithm>

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

using namespace std;

int n, x;
int v[100];
int w[100];
int dp[101][10001];

int main(){
	scanf("%d%d", &n, &x);
	rep(i, n){
		scanf("%d%d", &v[i], &w[i]);
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 0; j <= x; ++j){
			dp[i][j] = dp[i - 1][j];
			if(j >= w[i - 1]){
				dp[i][j] = max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i][j]);
			}
		}
	}
	printf("%d\n", dp[n][x]);
	return 0;
}

Measured memory_bytes: 4936
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    ll A, B, N;
    cin >> A >> B >> N;
    ll ans = 0, max = min(B - 1, N);
    ans = ( (A * max) / B) - (A * (max / B));
    cout << ans;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int,int> vii;
typedef vector<ll,ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
int p[30],n,sum;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>p[i];
    sort(p+1,p+1+n);
    sum += p[n]/2;
    for(int i=1;i<n;i++)sum+=p[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {   
  string s;cin>>s;
  int n = s.size();
  
  int cnt = 0;
  int S;S=0;
  rep(i,n){
    if(s[i] == 'S')S++;
    else{
      cnt += min(S,1)*2;
      S -= min(S,1);
    }
  }
  print(n-cnt);
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int maxNum = max({a, b, c});
  int minNum = min({a, b, c});
  cout << maxNum - minNum << endl;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> exi(n);
  vector<pair<int,int>> cp(m);
  
  for(int i=0;i<n;i++){
	cin >> exi.at(i).first >> exi.at(i).second;
  }
  for(int j=0;j<m;j++){
	cin >> cp.at(j).first >> cp.at(j).second;
  }
  vector<int> ans(n);
  for(int i=0;i<n;i++){
    int mn = 4*pow(10,8);
	for(int j=0;j<m;j++){
 	  int dis = abs(exi.at(i).first - cp.at(j).first) + abs(exi.at(i).second - cp.at(j).second);
      if( mn > dis ){
        mn = dis;
        ans.at(i) = j+1;
      }
    }
  }
  
  for(int i=0;i<n;i++){
	cout << ans.at(i) << endl;
  }
  return 0;
  
}

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

int func(int x){
  if(x%2 == 0) return x/2;
  else return 3*x+1;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  cin >> a;
  map<int, int> cnt;
  cnt[a]++;
  int m = 1;
  while(1){
    a = func(a);
    m++;
    if(cnt[a] > 0){
      cout << m << endl;
      return 0;
    }
    else
      cnt[a]++;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    np.set_printoptions(threshold=20)
    X = int(input())
    if X < 600:
        ans = 8
    elif X < 800:
        ans = 7
    elif X < 1000:
        ans = 6
    elif X < 1200:
        ans = 5
    elif X < 1400:
        ans = 4
    elif X < 1600:
        ans = 3
    elif X < 1800:
        ans = 2
    elif X < 2000:
        ans = 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

const int maxn=1e5+5;

pair<int,int> p[maxn];

int a[maxn];int b[maxn];

int f[maxn];
int vis[maxn];

void dfs(int u){
	if(vis[u]) return;
	vis[u]=1;
	dfs(f[u]);
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",b+i);
		p[i]={b[i],a[i]};
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(p+1,p+n+1); 
	for(int i=1;i<=n;i++){
		if(a[i]>b[i]){
			printf("No");return 0;
		}
	}
	for(int i=1;i<=n;i++){
		a[i]=p[i].second;
	}
	
	for(int i=1;i<=n;i++){
		f[i]=lower_bound(b+1,b+1+n,a[i])-b;
	}
	dfs(1);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			ans=1;break;
		}
	}
	printf("%s",ans==1?"Yes":"No");
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	while(input.hasNextInt()){
	    	int n = input.nextInt();
	    	int count = 0;
	    	if(n > 36){
	    		System.out.println("0");
	    	}else{
	    		for(int i = 0 ; i <= 9 ; i++){
	    			for(int j = 0 ; j <= 9 ; j++){
	    				for(int k = 0 ; k <= 9 ; k++){
	    					for(int l = 0 ; l <= 9 ; l++){
	    						if((i+j+k+l) == n)count++;
	    					}
	    				}
	    			}
	    		}
	    		System.out.println(count);
	    	}
    	}
    }
}

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

int main(){
 int n;
 cin >> n;
 vector<int> p(n),q(n);
 rep(i,n) cin >> p[i];
 rep(i,n) cin >> q[i];
 vector<int> a(n);
 rep(i,n) a[i]=i+1;
 map<vector<int>,int> mp;
  
 do{
   mp[a]=mp.size();
 }while(next_permutation(a.begin(),a.end()));
  
 int ans=abs(mp[p]-mp[q]);
  
  cout << ans << endl;
  
}
  
  
  


Measured memory_bytes: 8672
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(void){
  int R,C,K; cin>>R>>C>>K;
  vector<vector<ll>> rcv(R+1,vector<ll>(C+1,0));
  for(int i=0; i<K; ++i){ int r,c; cin>>r>>c; cin>>rcv[r][c];}
  vector<vector<vector<ll>>> dp(R+2,vector<vector<ll>>(C+2,vector<ll>(4,0)));
  for(int i=1; i<=R; ++i) for(int j=1; j<=C; ++j){
    for(int k=3; k>0; --k) dp[i][j][k]=max(dp[i][j][k],dp[i][j][k-1]+rcv[i][j]);
    for(int k=0; k<4; ++k){
      dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
      dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
    }
  }
  cout<<dp[R+1][C][0];
  return 0;
}


Measured memory_bytes: 707492
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int x=0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);}
  sort(vec.begin(),vec.end());
  for(int i=0;i<k;i++){
    x+=vec.at(i);}
  cout<<x<<endl;}
    

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split();
        int h = int.Parse(input[0]);
        long w = long.Parse(input[1]);
        long k = long.Parse(input[2]);
        var S = new int[h][];
        for(int i = 0; i < h; i++)
        {
            String temp = Console.ReadLine();
            S[i] = new int[w];
            for(int j = 0; j < w; j++)
            {
                S[i][j] = temp[j] - '0';
            }
        }
        var leastOp = int.MaxValue;
        for(int id = 0; id < (1 << (h - 1)); id++)
        {
            var curOp = PopCount(id);
            var iSectionCount = curOp + 1;
            int[] sectionH = new int[h];
            for (int j = 0; j < h - 1; j++) sectionH[j + 1] = sectionH[j] + (id >> j & 1);
            int[] curChocos = new int[iSectionCount];
            for(int j = 0; j < w; j++)
            {
                for(int i = 0; i < h; i++)
                {
                    if (S[i][j]==1) curChocos[sectionH[i]]++;
                }
                if (curChocos.Any(x => x > k))
                {
                    curOp++;
                    for (int i = 0; i < curChocos.Length; i++) curChocos[i] = 0;
                    for(int i = 0; i < h; i++) { if (S[i][j] == 1) curChocos[sectionH[i]]++; }
                    if (curChocos.Any(x => x > k)) goto end;
                }
            }
            leastOp = Math.Min(leastOp, curOp);
        end:;
        }
        Console.WriteLine(leastOp);
    }
    static int PopCount(int n)
    {
        int msb = 0;
        if (n < 0) { n &= int.MaxValue; msb = 1; }
        n = n - ((n >> 1) & 0x55555555);
        n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
        return (int)(((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24) + msb;
    }
}

Measured memory_bytes: 15504
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    vl rui(n+1);  // rui[i+1] : a[0]からa[i]までの和
    rep(i, n) {
        cin >> a[i];
        rui[i+1] = rui[i] + a[i];
    }
    
    vvl dp(n, vl(n+1));  // dp[L][R] : a[L],…,a[R-1]の状態からはじめて1匹にするためのコストの総和の最小値
    exrep(len, 2, n) {  // 区間の長さ(len = 1 のときのdpの値は0)
        for(ll L = 0; L + len <= n; L++) {  // 区間[L,R)の左
            ll R = L + len;  // 区間[L,R)の右
            // まずa[L],…,a[x-1]を合成してcost1でスライム1を作る
            // 次にa[x],…,a[R-1]を合成してcost2でスライム2を作る
            ll u = INF;
            exrep(x, L+1, R-1) {
                ll cost1 = dp[L][x];
                ll cost2 = dp[x][R];
                chmin(u, cost1 + cost2);
            }
            // 最後にスライム1とスライム2を合成してcost3でスライム3を作る
            ll cost3 = rui[R] - rui[L];  // スライム1の大きさ(rui[x] - rui[L]) + スライム2の大きさ(rui[R] - rui[x])
            dp[L][R] = u + cost3;
        }
    }

    out(dp[0][n]);
    re0;
}

Measured memory_bytes: 1536