akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    int h,w,m;
    cin>>h>>w>>m;
    map<int,set<int>> mpx;
    map<int,set<int>> mpy;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        mpx[x].insert(y);
        mpy[y].insert(x);
    }
    int mxx=-1,mxy=-1;
    for(auto P:mpx){
        mxx=max(mxx,int(P.second.size()));
    }
    for(auto P:mpy){
        mxy=max(mxy,int(P.second.size()));
    }
    // deb(mxx);deb(mxy);
    vector<int> a,b;
    for(auto P:mpx){
        if(P.second.size()==mxx){
            a.emplace_back(P.first);
        }
    }
    for(auto P:mpy){
        if(P.second.size()==mxy)b.emplace_back(P.first);
    }
    int x=a[0],y=b[0];
    int ans=int(mpx[x].size()+mpy[y].size());
    int cnt=0;
    for(auto x:a){
        for(auto y:b){
            // cout<<x<<":"<<y<<"\n";
            if(!((mpx[x].count(y)||mpy[y].count(x)))){
                cout<<ans<<"\n";return;
            }
        }
    }
    cout<<ans-1<<"\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 91760
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}
int gcd(ll(a), ll(b)) {
	ll q = a;
	ll w = b;
	ll e = q;
	while (q % w != 0) {
		e = q % w;
		q = w;
		w = e;
	}
	return w;

}





int main() {
	string r,an="YES";
	int d = 0;
	cin >> r;
	rep(i, r.size()) {
		if (r.at(i) == 'x') {
			d++;
		}
	}
	if (d > 7) {
		an = "NO";
	}
	cout << an << endl;
	
}

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

typedef long long ll;

int main()
{
	ll n,w;
	cin>>n>>w;
	vector<pair<ll,ll> > v;
	int sum=0;
	for(int i=0;i<n;i++)
	{
		ll a,b;
		cin>>a>>b;
		v.push_back({a,b});
	//	cout<<a<<"*"<<b<<" ";
		sum+=b;
	}
	ll ans[n+1][sum+1];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=sum;j++)
		ans[i][j]=w+1;
	}
	ans[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=sum;j++)
		{
		//		cout<<i<<"*"<<j<<" ";
			if(j+v[i-1].second<=sum)
			ans[i][j+v[i-1].second]=min(ans[i-1][j+v[i-1].second], ans[i-1][j]+ v[i-1].first);
			ans[i][j]=min(ans[i-1][j], ans[i][j]);
		}
	}

	/*for(int j=0;j<=sum;j++)
		{
			if(ans[n][j]!=1e15)
			cout<<ans[n][j]<<"*"<<j<<" ";
		}*/
		//cout<<endl;
	for(int i=sum;i>=0;i--)
	{
		if(ans[n][i]<=w)
		{
			cout<<i;
			return 0;
		}
	}
}


Measured memory_bytes: 79104
n, m, x = map(int, input().split())
ll = [list(map(int, input().split())) for _ in range(n)]
ans = 10**9

for i in range(2**n):
    a = [0]*m
    cnt = 0
    for j in range(n):
        if i>>j & 1:
            for k in range(1, m+1):
                a[k-1] += ll[j][k]
            cnt += ll[j][0]
    if all(s >= x for s in a):
        ans = min(ans, cnt)
print(ans if ans < 10**9 else -1)


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

int main()
{
int sum,i=0;
 char str[1000];
  while(1){
        scanf("%s",&str);
        if (str[0]=='0')break;
        for (sum=0,i=0;str[i]!='\0'; i++) {
            sum+=(str[i]-'0');
        }
        printf("%d\n",sum);
        }
 return 0;
}

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

A, B = map(int, input().split())

if A == B:
    print("Draw")
    exit()

if A == 1:
    print("Alice")
    exit()

if B == 1:
    print("Bob")
    exit()

if A > B:
    print("Alice")
else:
    print("Bob")

Measured memory_bytes: 2940
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] C = new int[N];
        int[] D = new int[N + 1];
        int[] F = new int[N + 1];
        for (int i = 0; i < N; i++) {
            int A = sc.nextInt() - 1;
            C[A]++;
        }
        for (int i = 0; i < N; i++) {
            D[C[i]]++;
        }
        int nowSum = N-D[0];
        int lSum = 0*D[0];
        F[1] = nowSum;
        for (int i = 2; i <= N; i++) {
            nowSum -= D[i-1];
            lSum += (i-1)*D[i-1];
            F[i] = lSum/i + nowSum ;
        }
        int x = N;
        for(int nowK=1;nowK<=N;nowK++) {
            while (x > 0 && F[x] < nowK) {
                x--;
            }
            System.out.println(x);
        }
    }
}

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

int main() {
	// your code goes here
	int N; cin >> N;
	vector<int> input(N); for (auto&e: input) cin >> e;
	long long acc = 0;
	for (int i = 0; i < N; ++i) 
	    for (int j = i + 1; j < N; ++j) 
	        acc += (long long)(input[i] * input[j]);
	cout<< acc;
}   


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

string s, t;
long long a, n, c, c1, c2;
int main() {
	int i;
	cin >> s >> a;
	n = s.size();
	t = s;
	sort(t.begin(), t.end());
	if(t[0] == t[n-1]) {cout << n * a / 2; return 0;}
	for(i=1; s[i]; i++) if(s[i] == s[i-1]) c++, i++;
	for(i=c1=0; s[i] == s[0]; i++, c1++);
	for(i=n-1, c2=0; s[i] == s[n-1]; i--, c2++);
	cout << (s[0] != s[n-1] ? c*a : c*a - (c1/2 + c2/2 - (c1+c2)/2) * (a-1));
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def S(): return input().rstrip()


def LS(): return S().split()


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


mod = 1000000007
inf = 1e10

#solve


def solve():
    s = S()
    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define double long double
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second
#define fo(i, n) for(int i = 0; i < n; i ++)
#define foe(i, n) for(int i = 0; i <= n; i ++)
#define fo1(i, n) for(int i = 1; i < n; i ++)
#define fo1e(i, n) for(int i = 1; i <= n; i ++)
using namespace std;


int32_t main(){
  fastio
  int n; cin >> n;
  cout << (n * (n-1)) / 2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,m,i,j,k,l;
   scanf("%lld %lld %lld",&n,&m,&k);
   n=max(n,m);
   l=k/n;
   if(k%n>0)
    l++;
   printf("%lld\n",l);
}



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


int main() {

  string s;
  cin >> s;
  int n=s.size();
  int i=0;
  int a[n]={};
  
  while(i<n){
  int l=0,r=0;
    while(s[i]=='R'){
      i++;
      r++;
    }
    int p=i-1;
    while(s[i]=='L'){
      i++;
      l++;
    }
    a[p]=(r+1)/2+l/2;
    a[p+1]=r/2+(l+1)/2;
    
  }
  for(int q=0;q<n;q++){cout << a[q] << " " ;}
                       cout << endl;
}


Measured memory_bytes: 1024
using System;

namespace agc027A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            long N = long.Parse(str[0]);
            long x = long.Parse(str[1]);
            long[] a = new long[N];
            string[] src = Console.ReadLine().Split();
            for (int i = 0; i < N; i++)
            {

                a[i] = long.Parse(src[i]);
            }
            Array.Sort(a);
            int Ans = 0;
            long B = x;
            for (int i = 0; i < N; i++)
            {
                B = B - a[i];
                if (B >= 0)
                    Ans += 1;
            }
            if (B > 0)
                Ans -= 1;
            Console.WriteLine(Ans);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

int main() {
    cout << fixed << setprecision(10);
    
    int N, M, K; cin >> N >> M >> K;

    mint ans = 0;
    // nCrを計算する必要
    mint color = M;
    // xが同色が何組あるか
    
    for (int x = N-1; x >= 0; --x) {
        // spはsame pairで、隣どうしが同じ数の組み
        if (x <= K) {
            mint tsum = color;
            tsum *= c(N-1, x);
            // tsum *= color;
            ans += tsum;
        }
        color *= (M-1);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())

int main(){
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<unordered_map>
using namespace std;
int main(){

    int n;
    cin>>n;
    unordered_map<string, int> m;
    for(int i = 0; i < n; i++)
    {
        string temp ; 
        cin>>temp;
        m[temp]++;

    }
    int maxxx = 0;
    for(auto i: m)
        maxxx = max(i.second, maxxx);
    vector<string> fin;
    for(auto i: m)
        if( i.second == maxxx)
            fin.push_back(i.first);
    
    sort(fin.begin(), fin.end());
    for(auto i: fin)
        cout<<i<<endl;







    return 0;
}

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

#define lli long long int

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    int d1 = a - b;
    if(d1 >= c)
    {
        cout << 0;
    }
    else
    {
        cout << c - d1;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main(){
	
	int S,h,m,s;


	cin >> S;

 

	s = S % 60;
	m = S / 60 % 60;
	h = S / 3600 % 60;

	

	cout << h<<":"<<m<<":"<<s <<endl;



}


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

int main(){
	ll n;
	cin>>n;
	ll a[n], b[n], c[n];
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	ll dp[n][3];

	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	
	for(int i=1;i<n;i++){
		dp[i][0]=a[i]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][0], dp[i-1][1]);	
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

Measured memory_bytes: 8208
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll d[MAXn];

int main()
{
    IOS();
    ll n,m;
    cin>>n>>m;
    REP(i,m)cin>>d[i];
    sort(d, d + m);
    vector<ll> v;
    REP(i,m-1)v.pb(d[i+1] - d[i]);
    sort(ALL(v), greater<ll>());
    if(m <= n)cout<<0<<endl;
    else
    {
        ll tt = d[m-1] - d[0];
        REP(i, n-1)tt -= v[i];
        cout<<tt<<endl;;
    }
}


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

long long nCr(int n, int r){
    long long ans = 1;
    for(int i = n; i > n - r; --i) ans = ans*i;
    for(int i = 1 ; i < r + 1; ++i) ans = ans / i;
    return ans;
}

int main(){
  int N;
  cin >> N;
  map<string, int> S;
  for(int i = 0; i < N; i++){
    string temp;
    cin >> temp;
    sort(temp.begin(), temp.end());
    if(S.count(temp) == 0) S[temp] = 1;
    else S[temp] += 1;
  }
  long long ans = 0;
  for(auto itr : S){
    int num = itr.second;
    if(num != 1){
      long long tempAns = nCr(num, 2);
      ans += tempAns;
    }
  }
  cout << setprecision(12);
  cout << ans << endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  string s; cin >> s;
  int n = s.size();
  int cnt = 0;
  for(int i=0; i<n/2; i++) {
    if(s[i] != s[n-1-i]) cnt++;
  }
  cout << cnt << endl;

  return 0;
}

// EOF


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

long long n,m,i,tg,s;

int main()
{
    cin >> n >> m;
    for (i=1;i<=m;i++)
    {
        cin >> tg;
        s+=tg;
    }
    if (n-s >= 0) cout << n-s;
    else cout << -1;
}

Measured memory_bytes: 3652
n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i).sort
h = m.times.map{ gets.split.map(&:to_i) }
i = 0
h.sort_by{|u, v| -v}.each do |x, y|
  break if a[i] >= y

  x.times do
    a[i] = y
    i += 1
    break if i >= n
    break if a[i] >= y
  end
  break if i >= n
end


puts a.sum


Measured memory_bytes: 25424
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

int main(){
    int A,B; cin >> A >> B;
    int ans;
    if (abs(A-B) >= 1)
    {
        ans = 2*max(A,B)-1;
    }
    else{
        ans = 2*A;
    }
    cout << ans;
    return 0;   
    
}

Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include <functional>
#include <limits>


using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

class BIT{
	vector<int> bit;
	
public:
	
	BIT(){
	}
	
	BIT(int size){
		init(size);
	}
	
	void init(int size){
		bit.clear();
		bit.resize(size+1);
	}
	
	int sum(int i){
		int s = 0;
		while(i > 0){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}

	void add(int i , int x){
		while(i < bit.size()){
			bit[i] += x;
			i += i & -i;
		}
	}

	int lower_bound(int w){
		if(w <= 0) return 0;
		int x = 0, t = 1;
		while(t*2 < bit.size()) t *= 2;
		
		for(int k = t; k > 0; k /= 2){
			if(x + k < bit.size() && bit[x + k] < w){
				w -= bit[x + k];
				x += k;
			}
		}
		return x + 1;
	}
};

// struct fast_io {
	// fast_io(){
		// cin.tie(nullptr);
		// ios::sync_with_stdio(false);
	// };
// } fio;

signed main(){
	// cout<<fixed<<setprecision(10);
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int N, Q;
	string S;
	vector<BIT> bit(26);
	
	cin>>N;
	cin>>S;
	cin>>Q;
	
	for(int i = 0; i < 26; i++){
		bit[i].init(N+10);
	}
	
	for(int i = 0; i < N; i++){
		bit[S[i] - 'a'].add(i+1, 1);
	}
	
	for(int i = 0; i < Q; i++){
		int a, b;
		
		cin>>a>>b;
		
		
		if(a == 1) {
			char c;
			
			cin>>c;
			
			bit[S[b-1] - 'a'].add(b, -1);
			bit[c - 'a'].add(b, 1);
			S[b-1] = c;
			
		} else {
			int r;
			cin>>r;
			
			int con = 0;
			for(int j = 0; j < 26; j++){
				if(bit[j].sum(r) - bit[j].sum(b-1) >= 1) con++;
			}
			
			cout<<con<<endl;
		}
	}
	
	return 0;
}

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
#define N 200093
long long k;
int T,f[N],g[N],u,v,st[N],t,n,a[N],h[N],tt,hh[N];
inline void pr(int u)
{
	while(u<=n){
		if(f[u]>u)u=f[u]; else printf("%d ",a[u]);
		++u;
	}
	exit(0);
} 

int main()
{
	n=read(); cin >> k;
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n;++i) {
		if(!h[a[i]])h[a[i]]=i;
	}
	for(int i=n;i;--i){
		if(!g[a[i]])f[i]=h[a[i]]; else f[i]=g[a[i]];
		g[a[i]]=i;
	}
	
	
	u=1;
	 
	T=1;
	while(1){
		v=f[u]+1;
		if(v<=u+1)++T;
		if(v==n+1)break;
		u=v;
	}
	
	/*
	T=1;
	while(1){
		if(f[u]<=u)++T;
		v=f[u]+1; 
		if(v==n+1)break;
		u=v;
	}*/
	
	u=1; --k; k%=T; if(!k)pr(u);
	while(1){
		v=f[u]+1;if(v>n)v=1;
		if(v<=u+1)--k;
		if(!k)pr(v);
		u=v;
	}
}

Measured memory_bytes: 5376
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	xx := make([]float64, n)
	yy := make([]float64, n)
	for i := 0; i < n; i++ {
		xx[i] = getNextFloat64(scanner)
		yy[i] = getNextFloat64(scanner)
	}
	pp := Permutation{}
	pp.init(n)
	pp.xx = xx
	pp.yy = yy
	pp.calc(n)

	for i := 0; i < n; i++ {
		pp.ans /= float64(i + 1)
	}
	fmt.Fprintln(writer, pp.ans)
}

// Permutation ...
type Permutation struct {
	a      []int
	xx, yy []float64
	ans    float64
}

func (p *Permutation) init(n int) {
	p.a = make([]int, n)
	for i := 0; i < n; i++ {
		p.a[i] = i
	}
}
func (p *Permutation) calc(n int) {
	if n == 1 {
		for i := 1; i < len(p.a); i++ {
			p.ans += math.Sqrt(math.Pow(p.xx[p.a[i]]-p.xx[p.a[i-1]], 2) + math.Pow(p.yy[p.a[i]]-p.yy[p.a[i-1]], 2))
		}
		return
	}

	for i := 0; i < n; i++ {
		p.calc(n - 1)
		if n%2 == 0 {
			p.a[i], p.a[n-1] = p.a[n-1], p.a[i]
			continue
		}
		p.a[0], p.a[n-1] = p.a[n-1], p.a[0]
	}
}


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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int i;
  int k=2;
  if(A%2||B%2||C%2)cout<<0<<endl;
  else{
    if(A==B&&B==C)cout<<-1<<endl;
    else{
      for(i=0;;i++){
        if(A%k!=B%k||B%k!=C%k||C%k!=A%k)break;
        k*=2;
      }
      cout<<i<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

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


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


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}



int main() {

    string S;
    cin >> S;

    if(S[0] >= 'a' && S[0] <= 'z') cout << 'a' <<endl;
    else cout << 'A' <<endl;

    return 0;    
}



Measured memory_bytes: 3620
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for std::str::SplitWhitespace<'a>
where
    T: std::str::FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n: usize = iter.parse();
    let m = iter.parse();
    let mut v: Vec<i64> = (0..m).map(|_| iter.parse()).collect::<Vec<_>>();
    v.sort();

    let mut dists: Vec<_> = v.windows(2).map(|w| w[1] - w[0]).collect();
    dists.sort();

    for _ in 0..(n - 1) {
        if dists.pop() == None {
            break;
        }
    }

    println!("{}", dists.into_iter().sum::<i64>());
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), m = in.nextInt();
			long[] xs = in.nextLongArray(n);
			long[] ys = in.nextLongArray(m);

			long sumx = 0, sumy = 0;

			for (int i = n-1; i >= 0; i--) {
				int r = n - (i+1);
				int l = i;
				sumx += (l-r)*xs[i];
			}

			for (int i = m-1; i >= 0; i--) {
				int r = m - (i+1);
				int l = i;
				sumy += (l-r)*ys[i];
			}

			out.println((sumx % MOD) * (sumy % MOD) % MOD);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 43704
#include<stdio.h>
int main(void){
int n,m;
int MIN=1000001,MAX=-1000001;
long int SUM=0;
scanf("%d\n",&n);
while(n>0){
scanf("%d",&m);
if(MIN>m) MIN=m;
if(MAX<m) MAX=m;
SUM = SUM + m;
n--;
}
printf("%d %d %ld\n",MIN,MAX,SUM);
}



Measured memory_bytes: 2148
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll a,b;cin>>a;
// stirng s;cin>>s;
 ll ans;
 
 ll tmp=400;
 if(tmp<=a&&a<tmp+200)ans=8;
 tmp+=200;
 if(tmp<=a&&a<tmp+200)ans=7;
 tmp+=200;
 if(tmp<=a&&a<tmp+200)ans=6;
 tmp+=200;
 if(tmp<=a&&a<tmp+200)ans=5;
 tmp+=200;
 if(tmp<=a&&a<tmp+200)ans=4;
 tmp+=200;
 if(tmp<=a&&a<tmp+200)ans=3;
 tmp+=200;
 if(tmp<=a&&a<tmp+200)ans=2;
 tmp+=200;
 if(tmp<=a&&a<tmp+200)ans=1;
 tmp+=200;
 pr(ans);
return 0;}

Measured memory_bytes: 3636
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    r = INT()
    print(2 * pi *r)


if __name__ == '__main__':
    main()


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    LL N, Y;
    cin >> N >> Y;
    LL r = Y/1000 - N;
    REP(i, N + 1) {
        REP(j, N + 1 - i) {
            LL c = 10000*i + 5000*j + 1000*(N - i - j);
            if(c == Y) {
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

int main()
{
    cin >> N;
    vector<double> a(N);
    double p = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        p += 1. / a[i];
    }
    printf("%9lf\n", 1. / p);
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

void warshall_floyd(int n, vvi& dp) {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) { dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]); }
        }
    }
}

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

    int h, w;
    cin >> h >> w;

    vvi maze(h, vi(w, 0));
    map<int, int> m_to_v;
    int v_num = 0;

    rep(i, 0, h) {
        rep(j, 0, w) {
            char c;
            cin >> c;
            if (c == '.') {
                maze[i][j] = 1;
                m_to_v[i * w + j] = v_num++;
            }
        }
    }

    vvi g(v_num, vi(v_num, 10000));
    rep(i, 0, h) {
        rep(j, 0, w) {
            if (maze[i][j] == 0) { continue; }
            g[m_to_v[i * w + j]][m_to_v[i * w + j]] = 0;
            if (i < h - 1 && maze[i + 1][j] == 1) {
                g[m_to_v[i * w + j]][m_to_v[(i + 1) * w + j]] = 1;
            }
            if (i > 0 && maze[i - 1][j] == 1) {
                g[m_to_v[i * w + j]][m_to_v[(i - 1) * w + j]] = 1;
            }
            if (j < w - 1 && maze[i][j + 1] == 1) {
                g[m_to_v[i * w + j]][m_to_v[i * w + j + 1]] = 1;
            }
            if (j > 0 && maze[i][j - 1] == 1) {
                g[m_to_v[i * w + j]][m_to_v[i * w + j - 1]] = 1;
            }
        }
    }
    warshall_floyd(v_num, g);

    int ans = 0;
    rep(i, 0, v_num) {
        rep(j, 0, v_num) {
            ans = max(ans, g[i][j]);
            // cout << g[i][j] << " ";
        }
        // cout << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
$N=<>;
$K=(1+sqrt$N*8+1)/2;
if($K=~/\./){
	print"No\n"
}else{
	print"Yes\n$K\n";
	for$i(0..$K-2){
		for$j(0..$i){
			$S[$i+1][$j]=$S[$j][$i]=++$t
		}
	}
	print@$_." @$_\n"for@S
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
#define maxn 100005
#define mod 1000000007

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	if(a<=0&&b>=0){
		cout<<"Zero";
	}
	else if(a>=0){
		cout<<"Positive";
	}
	else{
		int cnt=-a+min(0,b);
		if(cnt%2==0)cout<<"Negative";
		else cout<<"Positive";
	}

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
def main():
  N, M, *L = map(int, open(0).read().split())
  dic = defaultdict(list)
  par =  [None]*N
  cnt = [0]*(N+1)
  for a,b in zip(*[iter(L)]*2):
    dic[a] += [b]
    cnt[b] += 1

  for i in range(1,N+1):
    if cnt[i]==0:
      q = deque([i])
      par[i-1] = '0'
      break
  
  while q:
    m = q.popleft()
    for c in dic[m]:
      cnt[c] -= 1
      if cnt[c]==0:
        par[c-1] = str(m)
        q += [c]

  ans = '\n'.join(par)
  print(ans)
  
if __name__== '__main__':
  main()


Measured memory_bytes: 37140
process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const r = Number(inputs[0].split(' ')[0]);

  console.log(r * 2 * Math.PI);
}


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

using namespace std;


int main() {
    string s, t, u;
    cin >> s >> t;
    int a, b;
    cin >> a >> b >> u;
    if(s == u) cout << a - 1 << " " << b << endl;
    else cout << a << " " << b - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,q = gets.chomp.split(" ").map(&:to_i)
a = []
b = []
c = []
d = []
q.times do |i|
  a[i],b[i],c[i],d[i] = gets.chomp.split(" ").map(&:to_i)
end
ans = 0

[*1..m].repeated_combination(n).each do |x|
  sum = 0
  q.times do |i|
    sum += d[i] if x[b[i]-1]-x[a[i]-1] == c[i]
  end
  ans = sum if sum > ans
end

puts ans

Measured memory_bytes: 14580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);

		int N = sc.nextInt();
		int[] a = sc.nextIntArray(N);

		int ans = 0;
		boolean flag = true;

		while (flag) {
			int m = pow(2, ans+1);
			for (int i = 0; i < a.length; i++) {
				if (a[i]%m != 0) {
					flag = false;
					break;
				}
			}

			if (flag) {
				++ans;
			}
		}

		System.out.println(ans);
	}

	static int pow(int a, int n) {
		int ans = 1;
		for (int i = 0; i < n; i++) {
			ans *= a;
		}
		return ans;
	}

	static class FastScanner {

		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;

	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }

	}

}


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

int main(){

  int a=0;
  int b=0;

  cin>>a>>b;
  int max=a+b;
  if(max<(a-b))max=a-b;
  if(max<(a*b))max=a*b;
  
  cout<<max;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m,mi_d,tmp,idx;
  cin >> n >> m;
  ll a[n],b[n],c[m],d[m];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;i++){
    cin >> c[i] >> d[i];
  }
  for(int i=0;i<n;i++){
    mi_d = 10000000000000;
    idx = 0;
    for(int j=0;j<m;j++){
      tmp = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(tmp<mi_d){
        idx = j;
        mi_d = tmp;
      }
    }
    cout << idx+1<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char* argv[])
{
  int R;
  scanf("%d", &R);

  std::string ans = "ABC";
  if (R < 1200) ans = "ABC";
  else if (R < 2800) ans = "ARC";
  else ans = "AGC";

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


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main()
{
  int i=0;
  int stack[100];
  char s[100];
  
  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      stack[i-2] += stack[i-1];
      i--;
    }
	else if(s[0] == '-'){
      stack[i-2] -= stack[i-1];
      i--;
    }
	else if(s[0] == '*'){
      stack[i-2] *= stack[i-1];
      i--;
    }
	else{
      stack[i++] = atoi(s);
    }
  }

  printf("%d\n", stack[0]);
  return 0;
}

Measured memory_bytes: 548
def main():
    n = int(input())
    a = [None]*n
    for i in range(n):
        s, p = map(str, input().split())
        p = int(p)
        p *= -1
        a[i] = [s, p, i+1]
    a.sort(key=lambda x: (x[0], x[1]))
    for i in range(n):
        print(a[i][2])

if __name__ == "__main__":
    main()

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

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

    if(a < b)cout << "a < b" << endl;
    if(a > b)cout << "a > b" << endl;
    if(a == b)cout << "a == b" << endl;

    return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
int main(void) {
	int a, b, c;
	int count = 0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a == b && b == c) {
		count = 1;
	}
	else if (a != b && b != c && c != a) {
		count = 3;
	}
	else {
		count = 2;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int N;
  std::string s;
  std::cin >> N >> s;
  std::vector<int> l(N + 2, 0);
  std::vector<int> r(N + 2, 0);
  for (int i = 1; i <= N; ++i) {
    l[i] = l[i - 1] + (s[i - 1] == 'W' ? 1 : 0);
  }
  for (int i = N; i >= 1; --i) {
    r[i] = r[i + 1] + (s[i - 1] == 'E' ? 1 : 0);
  }
  int min = N * 2;
  for (int i = 1; i <= N; ++i) {
    min = std::min(l[i - 1] + r[i + 1], min);
  }
  std::cout << min << std::endl;
  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
const int N = 1e3;
int h,w,a,b,ans[N][N];
int main(){
	//freopen("input.txt","r",stdin);
	scanf("%d%d%d%d",&h,&w,&a,&b);
	for(int i = 0;i < b;i++)
		for(int j = 0;j < a;j++)
			ans[i][j] = 1;
	for(int i = b;i < h;i++)
		for(int j = a;j < w;j++)
			ans[i][j] = 1;
	for(int i = 0;i < h;i++,puts(""))
		for(int j = 0;j < w;j++)
			printf("%d",ans[i][j]);
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int n;
  cin >> n;
  int j;
  for(int i = 1; i <= n;i++) {
    if(i%3==0) {
      cout << " " << i;
      continue;
    }
    j = i;
    while(j) {
      if(j%10==3) {
        cout << " " << i;
        break;
      }
      j/=10;
    }
    
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3116
N,M = map(int,input().split())
list_aaa = [list(map(int,input().split())) for i in range(N)]
list_aaa = sorted(list_aaa,key= lambda x:x[0])

cnt_mount=0
cnt_money=0

for i in range(M):
    cnt_money +=(list_aaa[i][0])*(list_aaa[i][1])
    cnt_mount +=list_aaa[i][1]
    if cnt_mount>=M:
        cnt_money -=(cnt_mount-M)*list_aaa[i][0]
        break
print(cnt_money)




Measured memory_bytes: 29796
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

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

	int T;
	cin >> T;
	while(T--) {
		int N, D;
		cin >> N >> D;
		int ans = 0;
		for(int i = 0; i < N - 1; i++) {
			ans += 127;
			D = D ^ 127;
		}
		ans += D;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
N, M = map(int, input().split())
K_S = []
for m in range(M):
    k_s = list(map(int, input().split()))
    K_S.append(k_s)
P = list(map(int, input().split()))

result = 0
for switch_pattern in range(2 ** N):
    light_up = True
    for i, k_s in enumerate(K_S):
        count = 0
        for s in k_s[1:]:
            if (switch_pattern >> (s - 1)) & 1:
                count += 1
        # print(f"count: {count}")
        if count % 2 != P[i]:
            light_up = False
            break
    if light_up:
        result += 1
print(result)

# O: 1024*10*10 = 10**5

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

ll euclidean_gcd(ll a, ll b) {
    if (a < b) return euclidean_gcd(b, a);
    ll r;
    while(r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

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

int main()
{
    ll a, b;
    cin >> a >> b;

    cout << lcm(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
let rec fix f x = f (fix f) x
let ans =
  Scanf.scanf "%d %s" @@ fun n s ->
  let s = Array.init n (fun i -> Char.(code s.[i] - code '0')) in
  (0, 0) |> fix (fun f (i, a) ->
    if i >= 1000 then a else 
    let d = [|i/100; i/10 mod 10; i mod 10|] in
    let b = 
      (0, 0) |> fix (fun g (i, j) -> 
        if j >= 3 then 1
        else if i >= n then 0
        else if d.(j) = s.(i) then g (i+1, j+1) else g (i+1, j))
    in f (i+1, a+b))
let _ = Printf.printf "%d\n" ans


Measured memory_bytes: 5504
import collections

n = int(input())
A = list(map(int, input().split()))

C = collections.Counter(A)

num = []
num2 = []
for k,v in C.items():
    if (v>=2):
        num.append(k)
    if (v>=4):
        num2.append(k)

num.sort(reverse=True)
num2.sort(reverse=True)
if (len(num) >= 2 and len(num2) >= 1):
    print(max(num[0]*num[1],num2[0]**2))
elif (len(num) >= 2):
    print(num[0]*num[1])
else:
    print(0)

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

using namespace std;

int main(void){
  int n, m, l, r;
  cin >> n >> m;
  cin.ignore();

  int maxl = 1, minr = n;

  cin >> l >> r;
  cin.ignore();
  maxl = l, minr = r;

  for (int i = 1; i < m; i++){
    cin >> l >> r;
    if(maxl < l){
      maxl = l;
    }
    if(minr > r){
      minr = r;
    }
    cin.ignore();
  }

  if(maxl <= minr){
    cout << minr - maxl + 1 << endl;
  }else {
    cout << 0 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<ll,int>
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vpii vector<pii>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
   
    while(t--){
       int n;
       cin>>n;
       int k,l,sum=0;
       for(int i=1;i<=n;i++){
            l=log10(i)+1;
            if(l%2!=0){
                sum++;
            }
       }
       cout<<sum<<endl;
    }

    return 0;
} 

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

using namespace std;

int main(int argc, char const *argv[])
{
    string s, subsf, subsl;
    cin >> s;
    subsf = s.substr(0, 2);
    subsl = s.substr(2, 2);
    bool tff = false, tfl = false;
    if (stoi(subsf) <= 12 && stoi(subsf) > 0) {
        tff = true;
    }
    if (stoi(subsl) <= 12 && stoi(subsl) > 0) {
        tfl = true;
    }

    if (tff && tfl) {
        cout << "AMBIGUOUS" << endl;
    }
    else if (tff) {
        cout << "MMYY" << endl;
    }
    else if (tfl) {
        cout << "YYMM" << endl;
    }
    else {
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 998244353
ll dp[3005][3005];
int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    dp[a][b] = 1;
    for(ll i = a; i <= c; i++) { 
        for(ll j = b; j <= d; j++) { 
            if(i == a) {
                if (j == b) continue;
                dp[i][j] = dp[i][j - 1] * a % MOD;
            }
            if(j == b) {
                dp[i][j] = dp[i - 1][j] * b % MOD;
            } else {
                dp[i][j] = ((dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) * (j - 1)) % MOD + MOD) % MOD;
            }
        }
    }
    cout << dp[c][d];
    return 0;
}

Measured memory_bytes: 74000