akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const int INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 



int main()
{
    map<int, ll> m;
    
    int N, Q;
    cin >> N;
    vector<int> A(N);
    ll ans = 0;
    rep(i, N){
        cin >> A[i];
        m[A[i]]++;
        ans += A[i];
    }
    cin >> Q;
    rep(i, Q){
        ll B, C;
        cin >> B >> C;
        ans += (C - B) * m[B];
        m[C] += m[B];
        m[B] = 0;
        cout << ans << endl;
    }
    return 0;
 
}


Measured memory_bytes: 9364
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int[] a = new int[sc.nextInt()];
			for(int i = 0; i < a.length; i++) {
				a[i] = sc.nextInt();
			}
			int[] b = new int[sc.nextInt()];
			for(int i = 0; i < b.length; i++) {
				b[i] = sc.nextInt();
			}
			boolean inc = true;
			for(int e : b) {
				int loc = Arrays.binarySearch(a, e);
				if(loc < 0) {
					inc = false;
					break;
				}
			}
			System.out.println(inc ? "1" : "0");				
		}
	}
}


Measured memory_bytes: 118988
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		int table[] = new int[10001];

		for(int i = 0; i <= 10000; i++){
			table[i] = 1;
		}

		int limit = (int)Math.sqrt(10000);
		for(int i = 2; i <= limit; i++){
			if(table[i] == 1){
				for(int k = 2*i; k <= 10000; k += i){
					table[k] = 0;
				}
			}
		}

		ArrayList<Integer> prime = new ArrayList<Integer>();
		for(int i = 2; i <= 10000; i++){
			if(table[i] == 1){
				prime.add(Integer.valueOf(i));
			}
		}

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int input,tmp,count = 0;
		boolean FLG;

		for(int loop = 0; loop < N; loop++){
			input = scanner.nextInt();

			FLG = false;
			for(int i = 0; i < prime.size(); i++){
				tmp = prime.get(i);
				if(input%tmp == 0 && (input/tmp) > 1){
					FLG = true;
					break;
				}
				if(tmp*tmp > input){
					break;
				}
			}
			if(!FLG)count++;
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 42896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	vector<ll> v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end());
	cout << v[0] + v[1] << endl;

	return 0;
}


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

int main(){
	int r,c;
	cin>>r>>c;
	int a[r+1][c+1];
	a[r][c]=0;
	for(int i=0;i<r;i++) a[i][c]=0;
	for(int i=0;i<c;i++) a[r][i]=0;

	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>a[i][j];
			a[r][j]+=a[i][j];
			a[i][c]+=a[i][j];
			a[r][c]+=a[i][j];
		}
	}
	for(int i=0;i<=r;i++){
		for(int j=0;j<=c;j++){
			if(j==c){
				cout<<a[i][j]<<endl;
			}else{
				cout<<a[i][j]<<" ";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3132
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  myout((N - 2) * 180);
}

Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	cout << max({ A + B, A - B, A * B }) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
  unsigned short *A, *B;

  int C[VMAX + 1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++) {
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++) {
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, ans;

int main()
{
	in >> N;
	ans = N;
	for (LL i = 0; i <= N; ++i)
	{
		LL n = i, res = 0;
		while (n > 0)
		{
			res += n % 6;
			n /= 6;
		}
		n = N - i;
		while (n > 0)
		{
			res += n % 9;
			n /= 9;
		}
		ans = std::min(ans, res);
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int k, t;
	cin >> k >> t;
	int res = 0;
	int pre = 0, m = 0;
	for (int i = 0; i < t; i++){		
		cin >> pre;
		m = max(pre, m);
		res += pre;
	}
	res -= m;
	if (m>res)
		cout << m - res - 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n-1):
    if (p[i] > p[i-1] and p[i] < p[i+1]) or (p[i] < p[i-1] and p[i] > p[i+1]):
        count += 1
print(count)

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

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

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

  int H, W, N;
  cin >> H >> W >> N;

  int sr, sc;
  cin >> sr >> sc;

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

  // L, Rについて
  int r = W;
  int l = 1;

  if(s[N-1]=='R'){
    r--;
  }
  if(s[N-1]=='L'){
    l++;
  }

  for(int i = N-2; i >= 0; i--){

    // 青木くん

    if(t[i]=='L'){
      r = min(r+1, W);
    }
    if(t[i]=='R'){
      l = max(l-1, 1);
    }

    if(s[i]=='R'){
      r--;
    }
    if(s[i]=='L'){
      l++;
    }

    if(l > r){
      cout << "NO" << endl;
      return 0;
    }
    if(l <= 0){
      cout << "NO" << endl;
      return 0;
    }
    if(r >= W+1){
      cout << "NO" << endl;
      return 0;
    }

  }
  if(sc < l || r < sc){
    cout << "NO" << endl;
    return 0;
  }

  r = H;
  l = 1;

  if(s[N-1]=='D'){
    r--;
  }
  if(s[N-1]=='U'){
    l++;
  }

  for(int i = N-2; i >= 0; i--){

    // 青木くん

    if(t[i]=='U'){
      r = min(r+1, H);
    }
    if(t[i]=='D'){
      l = max(l-1, 1);
    }

    if(s[i]=='D'){
      r--;
    }
    if(s[i]=='U'){
      l++;
    }

    if(l > r){
      cout << "NO" << endl;
      return 0;
    }
    if(l <= 0){
      cout << "NO" << endl;
      return 0;
    }
    if(r >= H+1){
      cout << "NO" << endl;
      return 0;
    }

  }
  if(sr < l || r < sr){
    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

ll const inf = 1LL<<60;
ll N, M, L;
vector<vector<ll>> dist(334, vector<ll>(334, inf));

void floyd() {
    rep(k, N) {
        rep(i, N) {
            if (dist[i][k] == inf) continue;
            rep(j, N) {
                if (dist[k][j] == inf) continue;
                chmin(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
}

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

    cin >> N >> M >> L;
    rep(i, N) dist[i][i] = 0;
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c; --a; --b;
        if (c>L) continue;
        dist[a][b] = dist[b][a] = c;
    }

    floyd();
    rep(i, N) rep(j, N) if(i!=j && dist[i][j]<=L) dist[i][j] = 1;
    floyd();
    int q; cin >> q;
    while(q--) {
        int s, t; cin >> s >> t; --s; --t;
        ll ans = dist[s][t];
        cout << (ans==inf? -1:ans-1) << endl;
    }
    
    return 0;
}




Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}

int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int> v;
    for(int i=0;i<n;i++)
    {
    	v.pb(i+1);
	}
	map<vector<int>,int> mp;
	vector<int> x,y;
	for(int i=0;i<n;i++)
	{
		int a;cin>>a;
		x.pb(a);
	}
	for(int i=0;i<n;i++)
	{
		int a;cin>>a;
		y.pb(a);
	}
	int k=1;
	do{
		mp[v]=k++;
	}while(next_permutation(all(v)));
	cout<<(abs(mp[x]-mp[y]))<<endl;
	return 0;
}













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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(n + 1);
  a[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '>') a[i] = a[i + 1] + 1;
    else a[i] = 0;
    // cout << i << ' ' << a[i] << endl;
  }
  for (int i = 1; i < n + 1; i++) {
    if (s[i - 1] == '<') {
      a[i] = max(a[i - 1] + 1, a[i]);
    } else {
      a[i] = min(a[i - 1] - 1, a[i]);
    }
    // cout << i << ' ' << a[i] << endl;
  }
  long long ans = 0;
  for (int i = 0; i < n + 1; i++) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2844
#include <stdio.h>
#include <math.h>
int main(void){
    int data1,data2,data3;
    int sum,dist;
    scanf("%d %d %d",&data1,&data2,&data3);
    
    //sum = data1 + data2;
    
    //printf("data1:%d   data2:%d  data3:%d",data1,data2,data3);
    //printf("if:%d",(data1+data2-data3));
    
    if((data1+data2-data3)>=0){
        printf("Yes");
    }else{
        printf("No");
    }
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> pol(n);
    rep(i, n) {
      cin >> pol[i];
    }
    sort(pol.begin(), pol.end(), greater<int>());
    int sum = 0;
    FOR(i, 1, n) {
      sum += pol[i];
    }
    if (pol[0] < sum) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
 int N;
 int first;
 int second;
 
 scanf("%d",&N);
 first = N/10;
 second = N - first*10;

 if((first==9)|(second==9))
 {
  printf("Yes\n");
 }else{
  printf("No\n");
 }

return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

vector<ll> a;
vector<ll> p;

ll rec(ll n,ll x){
    if(n==0){
        if(x<=0) return 0;
        else     return 1;
    }

    if(x==1) return 0;
    else if(x<2+a[n-1]) return rec(n-1,x-1);
    else if(x==2+a[n-1]) return p[n-1]+1;
    else if(x<a[n]) return rec(n-1,x-a[n-1]-2)+p[n-1]+1;
    else return p[n];
}

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x;
    cin >> n >> x;
    a.assign(n+1,(ll)1);
    p.assign(n+1,(ll)1);
    for(int i = 0; i < n; i++) {
        a[i+1]=a[i]*2+3;
        p[i+1]=p[i]*2+1;
    }
    ll ans=rec(n,x);
    cout << ans << "\n";
    return 0;
}

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

const int MOD = 1000000007;

long long continuous_pow(long long a, long long b){
	long long res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

long long combination(long long n, long long r){
  long long x = 1;
  long long y = 1;
  for(int i = n-r+1; i < n+1; i++){
    x = x*i%MOD;
  }

  for(int i = 1; i < r+1; i++ ){
    y = y*i%MOD;
  }
  return x*continuous_pow(y, MOD-2)%MOD;
}

int main() {
    long long n, a, b;
    cin >> n >> a >> b;

    //calculate 2^n -1
    long long flower_num = continuous_pow(2, n) -1;

    // exclude two 
    long long aa = combination(n, a);
    long long bb = combination(n, b);
    long long ans = ((flower_num-aa-bb)%MOD+MOD)%MOD;
    long long ans2 = flower_num - aa - bb;

    // 計算例
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
void Main(){
    ll x;cin>>x;
    ll ans=x/11*2;
    x%=11;
    if(x>6) ans+=2;
    else if(x>0) ans+=1;
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define N 55
using namespace std;
int n,m,sum,a[N]; ll f[2][N][N*N];
void upd(ll &x,ll y){ x+=y; }
int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,n) scanf("%d",&a[i]);
	int nk=0,k=1; f[0][0][0]=1;
	rep (i,1,n){
		sum+=a[i]; k^=1; nk^=1;
		rep (j,0,i) memset(f[nk][j],0,sizeof(f[nk][j]));
		rep (j,0,i) rep (t,0,sum){
			if (j && t>=a[i]) upd(f[nk][j][t],f[k][j-1][t-a[i]]);
			upd(f[nk][j][t],f[k][j][t]);
		}
	} ll ans=0;
	rep (i,1,n) upd(ans,f[nk][i][i*m]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<math.h>

using namespace std;

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

    int a[n], b[n];
    for(int i=0;i<n;i++)cin >> a[i] >> b[i];
    int c[m], d[m];
    for(int i=0;i<m;i++)cin >> c[i] >> d[i];

    int ans[n];
    for(int i=0;i<n;i++){
        int tmp = abs(a[i]-c[0]) + abs(b[i]-d[0]);
        ans[i] = 1;
        int len;
        for(int j=0;j<m;j++){
            len = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(len<tmp){
                tmp = len;
                ans[i] = j + 1;
            }
        }
    }
    for(int i=0;i<n;i++)cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,k;
    cin >> n >> k;
    int h, ans = 0;
    REP(i,n){
        cin >> h;
        if(h >= k){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

int main(){
  ll a,b,c; cin >> a >> b >> c;
  
  bool flag = false;
  
  rep(i,b){
    if(i*a % b == c) flag = true;
  }
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;

int main(){FIN
    
    ll n,k;cin>>n>>k;
    vll a(n);REP(i,n) cin>>a[i];
    map<ll,ll> mp;

    vll route(0);
    ll now = a[0];
    ll cnt=1;
    while(1){
        if(mp[now]) {
            break;
        }
        
        mp[now] = cnt;
        route.push_back(now);
        now = a[now-1];
        cnt++;
    }
    ll ans;
    if (k<=mp[now]) ans = route[k-1];
    else {
        k -= mp[now]-1;
        k--;
        k %= (route.size() - mp[now]+1);
        // cout<<route.size() - mp[now]+1<<endl;
        // cout<<k<<endl;
        // cout<<k<<endl;
        
        // cout<<k+mp[now]-1<<endl;
        ans = route[k+ mp[now]-1];
    }
    
    cout<<ans<<endl;
    return 0;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int k,s,c=0;
	cin>>k>>s;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if(s-(i+j)>=0 && s-(i+j)<=k)
					c++;
			
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
using ll = long long;

int main(){
	int x, y, flag[12] = {1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};
	cin >> x >> y;

	if (flag[x - 1] == flag[y - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
character(len=10**5) :: s
integer :: s_l

read(*,*) s

s_l = len_trim(s)

if ( s(1:1) ==  s(s_l:s_l) ) then
  if ( mod(s_l,2) == 0 ) then
    write(*,'(a)') 'First'
    stop
  else
    write(*,'(a)') 'Second'
    stop
  end if
else
  if ( mod(s_l,2) == 0 ) then
    write(*,'(a)') 'Second'
    stop
  else
    write(*,'(a)') 'First'
    stop
  end if
end if


contains
!!!!!! サブルーチンは↓
!!!!!!

END PROGRAM ATCODER

Measured memory_bytes: 700
import java.util.*;
class Main{
	public static void main(String []args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		System.out.println((Math.min(a,b)+Math.min(c,d)));
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int n,flag=0,len;
char ch[100][11],a;

int main()
{
    scanf("%d",&n);
    flag=0;
    for(int i=0;i<n;i++)
    {
        cin>>ch[i];
        if(i!=0&&a!=ch[i][0])
        flag=1;
        if(i>0)
        for(int j=0;j<i;j++)
        {
            if(strcmp(ch[j],ch[i])==0)
            {
                flag=1;
            }
        }
        len=strlen(ch[i]);
        a=ch[i][len-1];
    }
    if(flag==1)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var dp=new long[s[1]+1];
		for(int i = 1;i<=s[0];i++) {
			var e=sc.Ia;
			for(int j = e[1];j<=s[1];j++) {
				dp[j]=Max(dp[j],dp[j-e[1]]+e[0]);
			}
		}
		Console.WriteLine("{0}",dp.Max());
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 18360
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int GET_UP_H = Integer.parseInt(scanner.next());
    int GET_UP_M = Integer.parseInt(scanner.next());
    int SLEEP_H = Integer.parseInt(scanner.next());
    int SLEEP_M = Integer.parseInt(scanner.next());
    int STUDY_TIME = Integer.parseInt(scanner.next());
    scanner.close();

    int ans_h = 0;
    int ans_m = 0;

    ans_h = SLEEP_H-1;
    ans_m = SLEEP_M+60;

    ans_m -= GET_UP_M;

    if(ans_m/60 == 1){
      ans_m -= 60;
      ans_h ++;
    }

    ans_h -= GET_UP_H;

    System.out.println(ans_h*60+ans_m-STUDY_TIME);
  }
}


Measured memory_bytes: 35676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


#define N 200005
#define nil N+100
int main(){
    ll n,k;cin>>n>>k;
    ll a[2*n+1];rep(i,1,n)cin>>a[i];
    vector<ll>b[N];
    rep(i,1,n){
        b[a[i]].pb(i);
    }
    
    ll c[2*n+1];memset(c,-1,sizeof(c));
    rep(i,0,N-1){
        ll bs=b[i].size();
        rep(j,0,bs-1){
            if(j==bs-1)c[b[i][j]]=b[i][0]+n;
            else c[b[i][j]]=b[i][j+1];
        }
    }
    rep(i,n+1,2*n){
        c[i]=c[i-n]+n;
    }
    //rep(i,1,2*n)cout<<c[i]<<" ";cout<<endl;
    ll dp[n+1];memset(dp,-1,sizeof(dp));
    rep(i,n+1,2*n)a[i]=a[i-n];
    rep(i,1,n){
        if(dp[i]!=-1)continue;
        vector<ll>v;
        ll pos=i;v.pb(pos);
        while(1){
            if(c[pos]<=2*n)pos=c[pos]+1;
            else break;
            if(pos<=n)v.pb(pos);
            
            if(pos==2*n+1)break;
        }
        for(auto x:v)dp[x]=pos-n;
    }
    ll posss=n+1;
    while(1){
        if(c[posss]<=2*n)posss=c[posss]+1;
        else break;
    }
    dp[0]=posss-n;
    rep(i,0,n)if(dp[i]==n+1)dp[i]=nil;
    //cout<<"dp ";rep(i,0,n)cout<<dp[i]<<" ";cout<<endl;
    
    ll cou=0;
    ll pos=0;
    ll cal[N+1];
    while(pos!=nil){
        cou++;
        pos=dp[pos];
        cal[cou]=pos;
    }
    k%=cou;
    
    //cout<<"cal ";rep(i,1,cou)cout<<cal[i]<<" ";cout<<endl;
    //cout<<"cou"<<cou<<endl;
    stack<ll>v;
    bool ex[N+1];memset(ex,false,sizeof(ex));
    if(k==0){
        return 0;
    }
    ll start;
    start=cal[k];
    rep(po,start,n){
        if(ex[a[po]]){
            while(1){
                ll t=v.top();v.pop();
                ex[t]=false;
                if(t==a[po])break;
            }
        }else{
            v.push(a[po]);
            ex[a[po]]=true;
        }
    }
    
    vector<ll>ans;
    while(!v.empty()){
        ans.pb(v.top());v.pop();
    }
    reverse(ans.begin(),ans.end());
    for(auto x:ans)cout<<x<<" ";
    
    return 0;
}

















Measured memory_bytes: 24868
#include  <iostream>
#include  <stdio.h>
using namespace std;


int main(){

    int lenS;
    string S;
    cin >> S;
    lenS = (int)(S.length()); 
    int count_0;
    int count_1;
    count_0 = 0;
    count_1 = 0;


    for(int i = 0; i < lenS; i++){
        if(S.substr(i,1)=="0"){
            count_0 = count_0 + 1;
        }else{
            count_1 = count_1 + 1;
        }
    }
    if(count_1 > count_0){
        cout << count_0 * 2;
    }else{
        cout << count_1 * 2;
    }

}

Measured memory_bytes: 512
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
l = IL()

dp = [0]*N
dp[0] = l[0]

for i in range(1,N):
    if l[i-1] >= l[i]:
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-1]+l[i]-l[i-1]

print(dp[-1])

Measured memory_bytes: 21668
#include<bits/stdc++.h>
using namespace std;
int n;
bool f;
void dfs(int k)
{
    if(k>n) return;
    if(n%k==0) f=true;
    dfs(k+7);
    dfs(k+4);
}
int main()
{
    scanf("%d",&n);
    f=false;
    
    if(n%4==0) f=true;
    if(n%7==0) f=true;
    dfs(4);
    dfs(7);
    if(n<4) f=false;
    if(f) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	string str;
	ll p;
	map<string, priority_queue<ll, vector<ll>, greater<ll>>>mp;
	while (cin >> str >> p) {
		mp[str].push(p);
	}
	REPC(i, mp) {
		cout << i.first << endl;
		REP(j, i.second.size()) {
			if (j != 0)cout << ' ';
			cout << i.second.top();
			i.second.pop();
		}
		cout << endl;
	}
}


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

using namespace std;

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

	vector< pair<int,int> > data(N);
	int nmin = 1000001;
	int nmax = 0;
	for (int i = 0; i < N; ++i) {
		cin >> data[i].first >> data[i].second;
		nmin = min(nmin,data[i].first);
		nmax = max(nmax,data[i].second);
	}
	nmax = min(N+1,nmax);

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

	bool find = false;
	int res = 0;
	for (int i = nmax; !find && i >= nmin; --i) {
		int count = 0;
		for (int j = 0; j < N; ++j) {
			if (data[j].first <= i && data[j].second >= i) {
				++count;
			}
		}
		if (count >= i-1) {
			find = true;
			res = i-1;
		}
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;

void hawawa()
{
  int n;
  cin >> n;
  vector<int> a(n + 2);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long s = 0;
  for (int i = 1; i < a.size(); i++) {
    s += abs(a[i] - a[i - 1]);
  }
  for (int i = 1; i <= n; i++) {
    long long s1 = s;
    s1 -= abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
    s1 += abs(a[i + 1] - a[i - 1]);
    cout << s1 << "\n";
  }
}

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

Measured memory_bytes: 1664
//Code is like humor. When you have to explain it, it’s bad.
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long
using namespace std;
#define ss second
#define ff first
int32_t main()
{
    fastio;
    int T,n,m,i,j,k,a,b,c;
    T=1;
    string str;
    while(T --> 0)
    {
        cin>>n>>str;
        vector<int> R,G;
        unordered_map<int,bool> B;
        for(i=0;i<n;i++)
        if( str[i] == 'R')
            R.emplace_back(i);
        else if( str[i] == 'G')
            G.emplace_back(i);
        else
            B[i]=true;

        m=B.size();
        int ans=R.size()*G.size()*m;
        for(auto a:R)
        for(auto b:G)
        {
            if( (a+b)%2==0 and B[(a+b)/2] )
                ans--;
            if( B[2*a-b])
                ans--;
            if( B[2*b-a])
                ans--;
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int N, L;
    cin >> N >> L;
    string *ary = new string[N];
    getline(cin, ary[0]);
    for (int i = 0; i < N; i++)
    {
        getline(cin, ary[i]);
    }

    sort(ary, ary + N);
    string ret = "";

    for (int i = 0; i < N; i++)
    {
        ret += ary[i];
    }

    cout << ret << endl;
    delete[] ary;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
		}
		b[0] = 1;
		int now = 1;
		do{
			if(b[a[now-1]-1]==0){
				b[a[now-1]-1]=b[now-1]+1;
				now = a[now-1];
			}else{
				System.out.println(-1);
				break;
			}
			if(now==2){
				System.out.println(b[1]-1);
				break;
			}
		}while(true);
	}
}

Measured memory_bytes: 58044
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
int main(){
  ll h, w;
  cin >> h >> w;
  vector<vector<char>> s(h+2, vector<char>(w+2, 'z'));
  for (ll i = 1; i <= h; i++) {
    for (ll j = 1; j <= w; j++) {
      cin >> s[i][j];
    }
  }
  
  vector<vector<char>> t(h, vector<char>(w, '#'));
  ll count;
  for (ll i = 1; i <= h; i++) {
    for (ll j = 1; j <= w; j++) {
      count = 0;
      if (s[i-1][j-1]=='#') count++;
      if (s[i-1][j]=='#') count++;
      if (s[i-1][j+1]=='#') count++;
      if (s[i][j-1]=='#') count++;
      if (s[i][j+1]=='#') count++;
      if (s[i+1][j-1]=='#') count++;
      if (s[i+1][j]=='#') count++;
      if (s[i+1][j+1]=='#') count++;
      char c = count + 48;
      if (s[i][j] == '.') {
        t[i-1][j-1] = c;
      }
    }
  }
  
  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      cout << t[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" -> ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a, b;
    cin >> a >> b;
    if (b >= a) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

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


Measured memory_bytes: 3576
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t;
lo cev;
string s;
multiset<lo> st;
vector<lo> v;

int main(void){
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
	}
	b[n]=a[1];
	int yer=n;
	for(lo i=2;i<=n;i++){
		if(a[i]<=b[yer]){yer--;b[yer]=a[i];continue;}
		lo bas=yer;
		lo son=n;
		while(bas<=son){
			if(b[ort]<a[i])bas=ort+1;
			else son=ort-1;
		}
		b[son]=a[i];
	}
	printf("%lld\n",n-yer+1);
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const int maxn = 1e6 + 5;

ll popcount(ll x) {
    ll res = 0;
    while (x) {
	res += (x&1);
	x /= 2;
    }

    return res;
}


ll f(ll x) {
    ll res = 0;
    while (x) {
	res++;
	ll p = popcount(x);
	x %= p;
    }
    return res;
}

int n;
string s;

map<int, ll> pw2[maxn], acc[maxn], racc[maxn];

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

    cin>>n;
    cin>>s;

    int bits = std::count(s.begin(),s.end(),'1');

    for (int b=max(1,bits-1); b<=bits+1; b++) {
	ll cur=1;
	for (int i=n-1; i>=0; i--) {
	    pw2[i][b]=cur;
	    cur=(cur*2)%b;
	}

	for (int i=0; i<n; i++) {
	    acc[i][b] = (s[i]-'0')*pw2[i][b];
	    if (i>0) {
		acc[i][b] += acc[i-1][b];
		acc[i][b] %= b;
	    }
	}
	
	for (int i=n-1; i>=0; i--) {
	    racc[i][b] = (s[i]-'0')*pw2[i][b];
	    if (i+1<n) {
		racc[i][b] += racc[i+1][b];
		racc[i][b] %= b;
	    }
	}
    }

    for (int i=0; i<n; i++) {
	int curb=bits;
	if (s[i]=='1') curb--; else curb++;
	if (curb==0) {
	    cout<<"0\n";
	    continue;
	}
	ll left = (i>0 ? acc[i-1][curb] : 0);
	ll right = (i+1<n ? racc[i+1][curb] : 0);
	ll num = left+right;
	if (s[i]=='0') num += pw2[i][curb];
	num %= curb;

	ll ans = 1 + f(num);
	cout<<ans<<"\n";
    }


    return 0;
}


Measured memory_bytes: 256752
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#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 in(x) cin >> x
#define out(str) cout << str << endl

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; }

string N;
int cnt=0,num;
bool flag[3];
void makethree(int len,string S){
    if(S.length()==len){
        rep(i,3){
            flag[i]=0;
        }
        // out(S);
        rep(i,len){
            if(S[i]=='3')flag[0]=1;
            if(S[i]=='5')flag[1]=1;
            if(S[i]=='7')flag[2]=1;
        }
        if(flag[0]&&flag[1]&&flag[2]&&atoi(S.c_str())<=num)cnt++;
        return;
    }
    else{
        makethree(len,S+'3');
        makethree(len,S+'5');
        makethree(len,S+'7');
    }
}

int main(){
    cin>>N;
    num=atoi(N.c_str());
    repi(i,3,N.length()+1){
        makethree(i,"");
    }
    out(cnt);
}


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

int main(){
    int n,i,a[MAX_N];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=n-1;i>0;i--){
        cout<<a[i]<<" ";
    }
    cout<<a[0]<<endl;
    return 0;
}


Measured memory_bytes: 3088
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().rstrip()

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

    graph = defaultdict(lambda : defaultdict(int))
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        graph[u][v] = w
        graph[v][u] = w

    depth = [-1] * (N)
    depth[0] = 0
    def dfs(x):
        for i, g in graph[x].items():
            if depth[i] > -1:
                continue
            depth[i] = depth[x] + g
            dfs(i)
    dfs(0)
    print("\n".join(['1' if d % 2 == 0 else '0' for d in depth]))

if __name__ == '__main__':
    main()


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

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

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> dislike(k);
  rep(i, k) cin >> dislike[i];

  int ans = 0;
  while(!ans) {
    string s = to_string(n);
    vector<int> vec(s.size());
    rep(i, (int)s.size()) vec[i] = s[i] - '0';
    sort(vec.begin(), vec.end());
    vector<int> v(10);
    vector<int>::iterator it;

    it = set_intersection(vec.begin(), vec.end(), dislike.begin(), dislike.end(), v.begin());
    v.resize(it-v.begin());
    if(!v.size()) ans = n;
    else n++;
  }

  cout << ans << endl;
}

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;

int s[1000000001];

int main() {
    int n, q;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        s[a]++;
    }

    int ans = 0;
    cin >> q;
    rep(i, q) {
        int a;
        cin >> a;
        if (s[a]) ans++;
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6824
#include <bits/stdc++.h>
#include <string>
using namespace std;
#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 ll long long

int main() {
	int n, k;

	cin >> n >> k;
	vector<int> x(n);
	rep(i, n)
		cin >> x[i];

	int ans=INT_MAX;
	for (int i = 0;i < n - k + 1;++i) {
		int l = x[i];
		int r = x[i + k - 1];
		int m = min(abs(l), abs(r)) + abs(l - r);
		ans = min(ans, m);
	}

	cout << ans << endl;
}

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

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

  int cost = 0;
  if (a + b < c * 2) {
    cost = a * x + b * y;
  } else {
    int k = min(x, y);
    cost = c * 2 * k;
    x -= k, y -= k;
    if (x > 0 && a < c * 2) {
      cost += a * x;
    } else if (y > 0 && b < c * 2) {
      cost += b * y;
    } else {
      cost += c * 2 * (x + y);
    }
  }
  cout << cost << endl;
  return 0;
}


Measured memory_bytes: 256