akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	string S;
	cin >> S;
	if(S[1]=='R'){
	    if(S[0]!=S[2]) cout << 2 << endl;
	    else if(S[0]=='R') cout << 3 << endl;
	    else cout << 1 << endl;
	}
	else{
	    if(S[0]=='R' || S[2]=='R') cout << 1 << endl;
	    else cout << 0 << endl;
	}
	return 0;
}


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

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

    int n, m;
    cin >> n >> m;

    int sum = 0;
    rep(i, m){
        int a;
        cin >> a;

        sum += a;
    }

    if(n-sum>=0) cout << n - sum << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

int main(){

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

  ll s=0;

  for(ll i=0;i<61;i++){
    ll b=0,c=0;
    for(ll j=0;j<n;j++){
      if(a[j] & (1LL<<i))b++;
      //if(a[j]>>i & 1)b++;
      else c++;
    }
    //if(i==0)cout << b <<" " << c << endl;
    ll d=powmod(2,i,mod);
    d*=b;
    d%=mod;
    d*=c;
    d%=mod;
    s+=d;
    s%=mod;
    //if(b*c!=0)cout << b << " " << c << endl;
  }

  cout << s << endl;

}

Measured memory_bytes: 5944
#include <iostream>
#include <string>
#include <queue>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){

	int n;
	while(cin >> n, n){
		vector<int> score;
		for(int i=0; i<n; i++){
			int s; cin >> s;
			score.push_back(s);
		}
		sort(score.begin(), score.end());
		int sum = accumulate(score.begin(), score.end(),0);
		cout << ( sum - score.back() - score.front() )/ (score.size()-2) << endl;
	}

	return 0;
}

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

vector<int> v;
int ant, n, c, k;

int main() {
#ifdef HOME
	freopen("agc11a.in", "r", stdin);
	freopen("agc11a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> c >> k;
	v.resize(n);
	for (auto &i: v)
		cin >> i;
	sort(begin(v), end(v));

	ant = 0;
	for (int l, i = 0; i < n;) {
		for (l = i; i < n && i - l + 1 <= c && v[i] - v[l] <= k; ++i);
		ant+= 1; }

	cout << ant << endl;

	return 0; }


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

string s;
int n;

signed main()
{
 	FLASH

 	cin>>s;
 	n = s.size();
 	int ans = 0;
 	string t = "";

 	fr(i, 0, n){
 		if(s[i] == 'A') t += '0';
 		else if(i < n - 1 and s[i] == 'B' and s[i + 1] == 'C') {t += '1'; i++;}
 		else t += '$';
 	}

 	n = t.size();
 	int las = 0, sm = 0;
 	fr(i, 0, n){
 		if(t[i] == '$') { las = -1; sm = 0;}
 		else if(t[i] == '0' and las == -1) {las = i; }
 		else if(t[i] == '1' and las != -1){
 			ans += i - las - sm;
 			sm++;
 		}
 	}

 	cout<<ans;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 h,w;
  cin >> h >> w;
  int32 ch,cw,dh,dw;
  cin >> ch >> cw >> dh >> dw;
  --ch,--cw,--dh,--dw;
  vector<string> s(h);
  REP(i,h)cin >> s[i];

  deque<pii> que;
  vector<vector<int32>> dist(h,vector<int32>(w,inf));
  dist[ch][cw] = 0;
  que.emplace_back(ch,cw);
  auto valid = [&](int32 ch,int32 cw){
    if(ch < 0 || h <= ch)return false;
    if(cw < 0 || w <= cw)return false;
    if(s[ch][cw] == '#')return false;
    return true;
  };
  while(!que.empty()){
    auto [ch,cw] = que.front();que.pop_front();
    REP(k,4){
      int32 nh = ch + dy[k];
      int32 nw = cw + dx[k];
      if(valid(nh,nw)){
        if(chmin(dist[nh][nw],dist[ch][cw])){
          que.emplace_front(nh,nw);
        }
      }
    }
    FOR(dh,-2,3){
      FOR(dw,-2,3){
        if(dh == 0 && dw == 0)continue;
        int32 nh = ch + dh;
        int32 nw = cw + dw;
        if(valid(nh,nw)){
          if(chmin(dist[nh][nw], dist[ch][cw] + 1)){
            que.emplace_back(nh,nw);
          }
        }
      }
    }
  }
  if(dist[dh][dw] == inf){
    ANS(-1);
    return 0;
  }
  ANS(dist[dh][dw]);
  // REP(i,h){
  //   REP(j,w){
  //     cout << dist[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  return 0;
}

Measured memory_bytes: 12616
#include<iostream>
#include<string.h>
#include<algorithm>

using namespace std;

int main(){
	int n,m,t;
	cin >> n >> m >> t;
	int a[100];
	
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	
	bool tcs[10000]; //time can study
	memset(tcs,1,sizeof(tcs));
	
	for(int i = 0;i < n;i++){
		for(int j = a[i] - m;j < min(a[i] + m,t);j++){
			tcs[j] = false;
		}
	}
	
	int count = 0;
	for(int i = 0;i < t;i++){
		if(tcs[i]){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3120
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    m = 2**15
    a = [[0]*(m+1) for _ in range(5)]
    a[0][0] = 1
    for i in range(1,m):
        ii = i**2
        if ii > m:
            break
        for k in range(4):
            for j in range(ii,m+1):
                a[k+1][j] += a[k][j-ii]

    def f(n):
        r = 0
        for i in range(5):
            r += a[i][n]
        return r

    while True:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str, rr))


print(main())




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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try( BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String str = br.readLine();
      StringBuilder transStr = new StringBuilder(str);
      StringBuilder order = new StringBuilder();
      StringBuilder revese = new StringBuilder();
      int q = Integer.parseInt(br.readLine());
      int[] sep = new int[]{0,0,0};
      int start = 0;
      int end   = 0;

      for ( int i = 0; i < q; i++ ) {

        order.append(br.readLine());
        sep[0] = order.indexOf(" ");
        sep[1] = order.indexOf(" ",sep[0]+1);

        switch(order.substring(0,sep[0])) {
          case "replace" :
            sep[2] = order.indexOf(" ",sep[1]+1);
            start = Integer.parseInt(order.substring(sep[0]+1,sep[1]));
            end   = Integer.parseInt(order.substring(sep[1]+1,sep[2]))+1;
            transStr.replace(start, end, order.substring(sep[2]+1));
            break;
          case "reverse" :
            start = Integer.parseInt(order.substring(sep[0]+1,sep[1]));
            end   = Integer.parseInt(order.substring(sep[1]+1))+1;
            revese.append(transStr.substring(start, end))
                  .reverse();
            transStr.replace(start, end, revese.toString());
            revese.setLength(0);
            break;
          case "print" :
            start = Integer.parseInt(order.substring(sep[0]+1,sep[1]));
            end   = Integer.parseInt(order.substring(sep[1]+1))+1;
            System.out.println(transStr.substring(start,end));
            break;
          default :
            break;
        }

        order.setLength(0);
      }
    }
  }
}


Measured memory_bytes: 24644
using System;

class Solution
{
    public static void Main(string[] args)
    {
        var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine("{0}", gcd(input[0], input[1]));
    }

    static int gcd(int a, int b)
    {
        if (b == 0) return a;
        return a % b == 0 ? b : gcd(b, a % b);
    }
}


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define ll                    long long int
#define ull                   unsigned long long int
#define vll                   vector<long long int>
#define loop(i,a,b) 		  for(ll i=(ll)a;i<(ll)b;++i)
#define pb                    push_back
#define ii					  pair<int, int> 
#define vii					  vector<ii>
#define vvi					  vector<vector<int>> 
#define pi                    acos(-1.0)
#define MOD                   1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void f_io(){
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
struct Interval 
{ 
    int val, idx; 
}; 
  
// Compares two intervals according to staring times. 
bool compareInterval(Interval i1, Interval i2) 
{ 
    return (i1.val < i2.val); 
}


int main(){ 
    f_io();
        ll t,n,w,a,k,x;
 
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    ll mx=arr[0];
    ll ans=0;
    for(int i=1;i<n;i++){
        if(mx>arr[i]){
            ans+=mx-arr[i];
        }
        else{
            mx=arr[i];
        }
    }
    cout<<ans;


   

}



    
    
    

        




    




      







   





         
    

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            int[] prev = new int[n];
            for (int i = 0; i < n; ++i) {
                int j = i - 1;
                while (j >= 0 && a[j] < a[i]) j = prev[j];
                prev[i] = j;
            }
            int[] next = new int[n];
            for (int i = n - 1; i >= 0; --i) {
                int j = i + 1;
                while (j < n && a[j] > a[i]) j = next[j];
                next[i] = j;
            }
            int[] chain = new int[n];
            for (int i = 0; i < n; ++i) {
                chain[i] = 1;
                if (i > 0 && a[i] > a[i - 1]) chain[i] += chain[i - 1];
            }
            int res = 1;
            boolean have = chain[k - 1] >= k;
            for (int left = 1; left + k <= n; ++left) {
                int right = left + k - 1;
                if (next[left - 1] >= right && prev[right] < left) {
                    res += 0;
                } else {
                    if (chain[right] >= k) {
                        if (!have) {
                            ++res;
                            have = true;
                        }
                    } else {
                        res += 1;
                    }
                }
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 47132
s = input()
t = input()

n = len(s);m = len(t)

# dp [n+1][m+1]

dp = [[0 for i in range(m+1)] for j in range(n+1)]

for i in range(n+1):
  dp[i][0] = 0
  
for j in range(m+1):
  dp[0][j] = 0
  
for i in range(1,n+1):
  for j in range(1,m+1):
    if s[i-1] == t[j-1]:
      dp[i][j] = 1 + dp[i-1][j-1]
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])
   
def path():
    ans=""
    ls=n;lt=m
    while ls>0 and lt>0:
        if dp[ls][lt]==dp[ls-1][lt]:
            ls-=1
        elif dp[ls][lt]==dp[ls][lt-1]:
            lt-=1
        else:
            ans=s[ls-1]+ans
            ls-=1
            lt-=1
 
    print(ans)
    
path()
#print(dp)

    
    
    

Measured memory_bytes: 119772
import sys
N = int(sys.stdin.readline())

L0 = 2
L1 = 1
L = L1
Lmin = L0

if N == 1:
  print(1)
  sys.exit()
for i in range(2, N+1):

  Li = L + Lmin
  Lmin = L
  L = Li

print(Li)


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

import sys


def string_to_list_spliter():
    h, w = [int(i) for i in sys.stdin.readline().split()]
    return h, w


def generate_crossboard(h, w):
    crossboard = ''
    for i in range(h):
        for j in range(w):
            if i % 2 == 0:
                if j % 2 == 0:
                    crossboard += '#'
                else:
                    crossboard += '.'
            else:
                if j % 2 == 0:
                    crossboard += '.'
                else:
                    crossboard += '#'
        crossboard += '\n'
    return crossboard


def print_crossboard():
    while True:
        h, w = string_to_list_spliter()
        if h == 0 and w == 0:
            break
        print(generate_crossboard(h, w))


def main():
    print_crossboard()


if __name__ == '__main__':
    main()

Measured memory_bytes: 7764
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using ll=long long;
using ld=long double;
#define inf INT_MAX  
const ll infll=1ll*inf*inf;
#define mode 998244353
#define mod 1000000007
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define pb push_back
#define mp make_pair
#define ub upper_bound 
#define lb lower_bound 
#define far(i,a,b) for (ll i = a; i <= b; i++)
#define rev(i,a,b) for (ll i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define sz(a) int((a).size())
#define ftr(c,i) for(auto i = begin(c); i != end(c); i++)
#define rtr(c,i) for(auto i = rbegin(c); i != rend(c); i++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define mii map<int,int>
#define mll map<ll,ll>
#define vs vector<string>
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define vii vector<pii >
#define vll vector<pll >
#define vvl vector<vector<ll> >
#define vvi vector< vector<int > >
#define wh(t) while(t --)
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout <<(ll)(it-arr.begin()) << ')' <<  *it << ' '; cout << endl;
#define printii(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << it->ff<<' '<<it->ss << endl; cout << endl;
#define MID(i,j) ((i)+(j))/2
#define nl '\n' 
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
ll max(ll a,ll b) {return (a>b? a:b);}
ll min(ll a,ll b) {return (a>b? b:a);}
ll gcd(ll a,ll b) {return (b==0)? a:gcd(b,a%b); }
ll gcd(ll a,ll b,ll & x,ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll modinv(ll a,ll b){
	ll x,y;
	gcd(a, b, x, y);
	return (x%b + b)%b;
}
ll ceiling(ll a,ll b){ 
        if(a%b==0) return a/b;
        else return a/b+1;
}
ll bpow(ll a,ll b,ll m){
	a%=m;
	ll res=1;
	while(b>0){
		if(b&1) res=(res*a)%m;
		b>>=1;
		a=a*a%m;
	}
	return res;
}
vvl mat_mul(vvl mat1,vvl mat2,ll mod1){
        vvl res(sz(mat1),vl(sz(mat2[0]),0));
        far(i,0,sz(mat1)-1){
                far(j,0,sz(mat2[0])-1){
                        far(k,0,sz(mat1[0])-1){
                                res[i][j]=(res[i][j]+(mat1[i][k]*mat2[k][j])%mod1)%mod1;          
                        }   
        }   
        }   
        return res;
}
vvl mat_exp(vvl mat,ll p,ll mod1){ 
        vvl res(sz(mat),vl(sz(mat[0]),0));
        far(i,0,sz(mat)-1) res[i][i]=1;
        while(p>0){
                if(p&1) res=mat_mul(res,mat,mod1);   
                mat=mat_mul(mat,mat,mod1);
                p>>=1;
        }   
        return res;
}
const int N=2*1e5+5;
ll n,m,q,t,k,x,y,z,ans;
vii rk; 
int main()
{
	fio;
	cin >> n;
	far(i,1,n){
		int a,b;
		cin >> a >> b;
		rk.pb(mp(b,a));
	}
	sort(all(rk));
	for(auto i:rk){
		x+=i.ss;	
		if(x>i.ff) y=1;
	}
	if(y) cout << "No" << nl;
	else cout << "Yes" << nl;
}


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

using namespace std;

struct Team {
	int tID;
	int penalty;
	int correct;
	int wrong[10];
};

int main(void)
{
	int T, P, R, tID, pID, time;
	string message;
	Team t[50];

	while (cin >> T >> P >> R, T && P && R)
	{
		for (int i = 0; i < T; ++i)
		{
			t[i].tID = i+1;
			t[i].penalty = t[i].correct = 0;
			for (int j = 0; j < P; ++j)	t[i].wrong[j] = 0;
		}

		for (int i = 0; i < R; ++i)
		{
			cin >> tID >> pID >> time >> message;
			if (message == "CORRECT")
			{
				++t[tID-1].correct;
				t[tID-1].penalty += t[tID-1].wrong[pID-1] * 1200 + time;
			}
			else	++t[tID-1].wrong[pID-1];
		}

		for (int i = 0; i < T; ++i)
		{
			for (int j = i+1; j < T; ++j)
			{
				if (t[i].correct < t[j].correct)	swap(t[i], t[j]);
				else if (t[i].correct == t[j].correct)
				{
					if (t[i].penalty > t[j].penalty)	swap(t[i], t[j]);
					else if (t[i].penalty == t[j].penalty)	if (t[i].tID > t[j].tID)	swap(t[i], t[j]);
				}
			}
		}

		for (int i = 0; i < T; ++i)	cout << t[i].tID << " " << t[i].correct << " " << t[i].penalty << endl;
	}
	return 0;
}

Measured memory_bytes: 928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
// #define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=998244353;
const int maxn=3e3+5;

int dp[maxn][maxn];

int32_t main(){
    fast_io;
    int n,s;
    cin>>n>>s;
    int a[n+1];
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i+1];
    }
    dp[0][0] = 1;
    fo(i,1,n){
    	for (int j = 0; j+a[i] < maxn; ++j)
    	{
    		dp[i][j+a[i]] = dp[i-1][j];
    	}
    	for (int j = 0; j < maxn; ++j)
    	{
    		dp[i][j] = (dp[i][j] + 2*dp[i-1][j])%MOD;
    	}
    }
    show(dp[n][s]);
    return 0;
}

Measured memory_bytes: 74092
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
ll fact[15];
ll solve1(ll a, ll b, ll c,ll n){
  // cout<<n<<endl;
  if(a+b+c==n){
    // cout<<n<<" "<<a<<" "<<b<<" "<<c<<endl;
    // cout<<fact[a]<<endl;
    return fact[n]/(fact[a]*fact[b]*fact[c]);
  }
  return solve1(a+1,b,c,n)+solve1(a,1+b,c,n)+solve1(a,b,c+1,n);
}
ll solve2(int n){
  ll ans=0;
  rep(i,3,n+1){
    ans+=solve1(1,1,1,i);
  }
  return ans;
}
void  solve(){
  // string s;
  // cin>>s;
  // fact[0]=1;
  // rep(i,1,13) fact[i]=i*fact[i-1];
  // int n=s.length();
  // ll ans=solve2(n-1);
  // ll mult=1;
  // // rep(i,1,n){
  // //   ll c=0;
  // //   if(s[i]>='3')  c++;
  // //   if(s[i]>='5')  c++;
  // //   if(s[i]>='7')  c++;
  // //   mult*=c;
  // // }
  // if(s[0]>'7'){
  //   ans+= 3*solve2(n-1);
  // }
  // else if(s[0]=='7' || s[0]>'5'){
  //   ans+=2*solve2(n-1);
  // }
  // else if(s[0]=='5' || s[0]>'3'){
  //   ans+= solve2(n-1);
  // }
  // if(s[0]<'3') mult=0;
  // else{
  //
  //   int x=stoi(s);
  //   if(s[0]>'7')
  //   rrep(i,x,)
  // }
  // ans+=mult;
  // cout<<ans<<endl;
  int n;
  cin>>n;
  int ans = 0;
  function<void(string, bool, bool, bool)> rec = [&](string s, bool three,
                                                     bool five, bool seven) {
    if (s.size() >= 10) return;
    if (three && five && seven && stoll(s) <= n) ++ans;
    rec(s + '3', true, five, seven);
    rec(s + '5', three, true, seven);
    rec(s + '7', three, five, true);
  };
  rec("", false, false, false);
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3588
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import deque

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

A = [int(x) for x in input().split()]
S = sum(A)

div = set()
for d in range(1,S+1):
    if d*d > S:
        break
    if S%d == 0:
        div.add(d)
        div.add(S//d)

def F(d):
    # 全部をdの倍数にするまでの最小コスト
    cost = 0
    q = deque(sorted(x%d for x in A))
    while q:
        x = q[0]
        if x == 0:
            q.popleft()
            continue
        y = q[-1]
        if y == 0:
            q.pop()
            continue
        z = d - y
        t = x if x < z else z
        cost += t
        q[0] -= t
        q[-1] += t
        q[-1] %= d
    return cost

answer = None
div = sorted(div, reverse = True)
for d in div:
    cost = F(d)
    if cost <= K:
        answer = d
        break

print(answer)


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

bool prime(int n) {
  bool b = 1;
  for (int i = 2; i * i <= n; i++) {
    if(n % i == 0){
   b = 0; 
   break;}
  }
  if(n >= 2) return b;
  else return 0; 
}

int main(){
int Q; 
cin >> Q; 
  int a[114514]; 
  for (int i = 1; i <= 110000; i++) {
    if(i % 2 == 1 && prime(i) == 1 && prime((i+1)/2) == 1)
   a[i] = 1;
  }
  int b[114514]; 
  for (int i = 1; i <= 110000; i++){
   b[i] = b[i-1] + a[i] ;
  }
  for (int i = 1; i <= Q; i++) {
   int l, r;
   cin >> l >> r; 
   cout << b[r] - b[l-1] << endl; 
  } 
  }

Measured memory_bytes: 1536
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int h = s/3600;
        s%=3600;
        int m = s/60;
        s%=60;
        System.out.println(h+":"+m+":"+s);
    }
}


Measured memory_bytes: 26196
#include <bits/stdc++.h>
#include <ctype.h>
#include <string>
#include <math.h>
#include <iomanip> 
#include <queue>
using namespace std;

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); 

	
	string a;
	cin >> a;
	if (isupper(a[0])){
		cout << 'A';
	} else {
		cout << 'a';
	}
	


}

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

int main() {
    int n, r;
    scanf("%d%d", &n, &r);
    if(n<10)
        printf("%d\n", r+100*(10-n));
    else
        printf("%d\n", r);
    return 0;
}


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

int main(){
    int N, M;
    cin >> N;
    vector<string> s(N);
    rep(i,N)cin>>s[i];
    cin >> M;
    vector<string> t(M);
    rep(i,M)cin>>t[i];
    int ans = 0;
    for(int i = 0; i < N; i++){
        int score = 0;
        for(int j = 0; j < N; j++){
            if(s[i]==s[j]){
                score++;
            }
        }
        for(int j = 0; j < M; j++){
            if(t[j]==s[i]){
                score--;
            }
        }
        ans = max(ans, score);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#https://atcoder.jp/contests/abc145/tasks/abc145_b
import sys
N = int(input())
S = list(input())
if N % 2 == 0:
    count = 0
    for i in range(N//2):
        if S[i] == S[N//2+i]:
            count += 1
    if count == N//2:
        print("Yes")
        sys.exit()
print("No")

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

double cal(double  a)
{
  double  sum=0,wa=a;
  for(int i=1;i<a+1;i++){
    sum+=i;
  }
  sum/=wa;
  return sum;
}
int main()
{
  int A[200001]={};
  int N,K,num,count,ans;
  double  ANS;
  int flag=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
     cin>>A[i];
  }

  for(int i=0;i<K;i++){
    count+=A[i];
  }
  flag=0;
  ans=count;
  for(int i=1;i<N-K+1;i++){
    int g =i+K-1;
    count+=A[g];
    count-=A[i-1];
    if(count>ans){
      ans=count;
      flag=i;
    }
  }
  ANS=0;
  for(int i=flag;i<flag+K;i++){
    ANS+=cal(A[i]);
  }
  printf("%.10f\n",ANS);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int Q;
    cin >> Q;
    multiset<i64, greater<i64>> left;
    multiset<i64, less<i64>> right;
    i64 ans = 0;
    for(int q = 0; q < Q; q++) {
        int mode;
        cin >> mode;
        if(mode == 1) {
            i64 a, b;
            cin >> a >> b;
            if(left.size()) {
                i64 l_margin = *left.begin() - a;
                i64 r_margin = a - *right.begin();
                if(l_margin > 0 || r_margin > 0) {
                    ans += max<i64>({l_margin, r_margin, 0});
                }
            }
            ans += b;
            left.insert(a), right.insert(a);
            while(*left.begin() > *right.begin()) {
                right.insert(*left.begin());
                left.insert(*right.begin());
                left.erase(left.begin());
                right.erase(right.begin());
            }
        } else {
            cout << *left.begin() << " " << ans << endl;
        }
    }
    return 0;
}



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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const ll N = 123456;

int a[N];
int k;


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

    int n , a , b;
    cin >> n >> a >> b;

    cout << min(n * a , b) << endl;

    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc143/tasks/abc143_d

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> Ln(n);

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

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

    int ans = 0;

    for (int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1 ; k < n; k++){

                if(Ln[k] < Ln[i] + Ln[j]){ans +=1;}

            }
        }
    }

    cout << ans << endl;

    return 0;

}


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

int main() {
    int a, b, c, ans = -1;
    cin >> a >> b >> c;
    for(int i=0;i<60;i++){
        int t = (a+b)*i%60;
        if(t <= c && t+a >= c){
            ans = (a+b)*i + c-t;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3104
#include <cstdio>


typedef long long int ll;

int main(){

    int N;
    scanf("%d",&N);


    ll sum=0ll;
    for(int i=1;i<=N;i++){
        if (i%3&&i%5) sum+=i;

    }

    printf("%lld\n",sum);

    return 0;
}

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

int main() {
 	int n, k;
  	cin >> n >> k;
  	int res = 0;
  	for (int i = 0; i < n; i++) {
    	int x; cin >> x;
      	res += (x >= k);
    }
  	cout << res << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
    //Solution by Sathvik Kuthuru
    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        for(int tt = 1; tt <= t; tt++) solver.solve(tt, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            String s = scan.next();
            out.println(s.contains("RRR") ? 3 : s.contains("RR") ? 2 : s.contains("R") ? 1 : 0);
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

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

    for(int i = 0; i < n - 1;i++){
        for(int j = n - 1; j > i; j--){
            if(a[j] < a[j - 1]){
                swap(a[j],a[j-1]);
                count++;
            }
        }
    }

    for(int i = 0; i < n; i++){
        if(i != n-1)
            cout << a[i] << " ";
        else
            cout << a[i] << endl;
    }

    cout << count << endl;

    return 0;
}


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

int INF = 100000000;

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

  int ans = INF;
  for (int i = 1; i < n / 2 + 1; i++) {
    int id0, id1, id2, id3, id4, id5;
    int j, jd0, jd1, jd2, jd3, jd4, jd5;

    id0 = i % 10;
    id1 = i / 10 % 10;
    id2 = i / 100 % 10;
    id3 = i / 1000 % 10;
    id4 = i / 10000 % 10;
    id5 = i / 100000;

    j = n - i;
    jd0 = j % 10;
    jd1 = j / 10 % 10;
    jd2 = j / 100 % 10;
    jd3 = j / 1000 % 10;
    jd4 = j / 10000 % 10;
    jd5 = j / 100000;

    int sum = id0 + id1 + id2 + id3 + id4 + id5 + jd0 + jd1 + jd2 + jd3 + jd4 + jd5;
    if (sum < ans) ans = sum;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//


// agc071
int main(){
	int N;
	cin>>N;
	vector<int> A(N);
	REP(i,N)cin>>A[i];

	sort(ALL(A),[&](int x,int y){
		return x > y;
	});
	A.push_back(-1);
	
	vector<pair<int,int>> t;
	REP(i,N+1){
		int cnt=1;
		int j=i;
		while(A[j]==A[++j])++cnt;
		if(cnt>=2)t.push_back(make_pair(A[i],cnt));
		i=j-1;
	}
	//for(auto itr : t)cout << itr.first << " "<< itr.second << endl;

	ll ans = 0;
	REP(i,t.size()){
		if(t[i].second >= 4)
			ans = max(ans,(ll)t[i].first*t[i].first);
		if(i!=t.size()-1)
			ans = max(ans,(ll)t[i].first*t[i+1].first);
	}

	cout << ans << endl;


	return 0;
}




Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];


ll N;

void func(long long cur, int use, long long &counter) {
  // base case
  if (cur > N) return;
  if (use == 0b111) ++counter;

  // 7, 5, 3を付け加える.
  func(cur * 10 + 7, use | 0b001, counter);
  func(cur * 10 + 5, use | 0b010, counter);
  func(cur * 10 + 3, use | 0b100, counter);
}


int main() {
  cin >> N;
  ll res = 0;
  func(0, 0, res);
  cout << res << endl;
}


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

using namespace std;

struct node {
  node *right,*left,*p;
  int key;
};

node *root;

void insert(int k) {
  node *y = NULL;
  node *x = root;
  node *z;

  z = (node*)malloc(sizeof(node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;

  while(x!=NULL) {
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;
  if(y==NULL) root = z;
  else {
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

node* find(int k) {
  node *x = root;
  while(x!=NULL) {
    if(x->key == k) return x;
    else if(x->key > k) x = x->left;
    else x = x->right;
  }
  return NULL;
}

node* treeMinimum(node *x) {
  while(x->left!=NULL) x = x->left;
  return x;
}

node* treeSuccessor(node* x) {
  if(x->right!=NULL) return treeMinimum(x->right);
  node* y = x->p;
  while(y!=NULL && x==y->right) {
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(node* z) {
  node* y;
  node* x;

  if(z->left==NULL || z->right==NULL) y = z;
  else y = treeSuccessor(z);

  if(y->left!=NULL) x = y->left;
  else x = y->right;

  if(x!=NULL) x->p = y->p;

  if(y->p==NULL) root = x;
  else {
    if(y==y->p->left) y->p->left = x;
    else y->p->right = x;
  }

  if(y!=z) z->key = y->key;

  free(y);
}

void preorder(node *u) {
  if (u == NULL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

void inorder(node *u) {
  if (u == NULL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}
  
int main(){
  int n; cin >> n;
  while(n--) {
    string s;
    cin >> s;
    if(s=="insert") {
      int k; cin >> k;
      insert(k);
    } else if(s=="find") {
      int k; cin >> k;
      cout << (find(k)!=NULL?"yes":"no") << endl;
    } else if(s=="delete") {
      int k; cin >> k;
      treeDelete(find(k));
    } else {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 21884
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int a,b,max,min;
cin>>a;
for(int i=0;i<a;i++){
cin>>b;
if(i==0){
min=b;
max=b;
}
if(min>b)min=b;
if(max<b)max=b;
}
printf("%d",max-min);
return 0;
}

Measured memory_bytes: 256
#define DBG 0 //submit 0
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
    #include <cmath>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


int main(){
    int i,N;
    cin >> N;
    vector<int> a(N),ans(N);
    for(i=0;i<N;i++){
        cin >> a[i];
        ans[a[i]-1] = i+1; 
    }

    for(i=0;i<N;i++){
        cout << ans[i] << " "; 
    }
    cout << endl;
}


Measured memory_bytes: 1664
s = input()
s_list = list(s)
ans = 0
for i in range(1 << (len(s) - 1)):
    a = 0
    for j in range(len(s_list)):
        if (i >> j) & 1 == 1:
            continue
        ans += int(s[a:j + 1])
        a = j + 1
print(ans)

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

using namespace std;

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

  if (a + b > c + d){
    cout << "Left" << endl;
  } else if (a + b == c + d){
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }

  return 0;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Wolfgang Beyer
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Checkpoint solver = new Checkpoint();
        solver.solve(1, in, out);
        out.close();
    }

    static class Checkpoint {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] px = new int[n];
            int[] py = new int[n];
            for (int i = 0; i < n; i++) {
                px[i] = in.nextInt();
                py[i] = in.nextInt();
            }
            int[] cx = new int[m];
            int[] cy = new int[m];
            for (int i = 0; i < m; i++) {
                cx[i] = in.nextInt();
                cy[i] = in.nextInt();
            }

            for (int i = 0; i < n; i++) {
                int minDist = editDistance(px[i], py[i], cx[0], cy[0]);
                int cp = 1;
                for (int j = 1; j < m; j++) {
                    int dist = editDistance(px[i], py[i], cx[j], cy[j]);
                    if (dist < minDist) {
                        minDist = dist;
                        cp = j + 1;
                    }
                }
                out.println(cp);
            }
        }

        public int editDistance(int a, int b, int x, int y) {
            return Math.abs(a - x) + Math.abs(b - y);
        }

    }

    static class InputReader {
        private static BufferedReader in;
        private static StringTokenizer tok;

        public InputReader(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
        }

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

        public String next() {
            try {
                while (tok == null || !tok.hasMoreTokens()) {
                    tok = new StringTokenizer(in.readLine());
                }
            } catch (IOException ex) {
                System.err.println("An IOException was caught :" + ex.getMessage());
            }
            return tok.nextToken();
        }

    }
}



Measured memory_bytes: 21588
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

// index が条件を満たすかどうか vector<>maeに検索したいvectorを入れる keyを超える最小の要素番号を返す
bool isOK(int index, long long key, vector<long long>&mae) {
	if (mae[index] >= key) return true;
	else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(long long key, vector<long long>&mae) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)mae.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key, mae)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}


long long mod(const long long &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
int mod(const int &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
bool get(const char a) {//黒なら1　白なら0
	if (a == 'B')return 1;
	else return 0;
}
long long fact(long long a) {
	long long ret = 1;
	for (int i = 1; i <= a; i++)
	{
		ret = mod(ret*i);
	}
	return ret;
}

int main() {
	int n;
	string s;
	cin >>n>> s;
	int state=0;
	VI inout(2*n,0);//1なら出る,0なら入る
	for (int i = 0; i < 2*n; i++)
	{
		if (state < 0) { puts("0");return 0; }
		if ((state + get(s[i])) % 2) {
			inout[i] = 1;state++;continue;
		}
		state--;
	}
	if (state) { puts("0");return 0; }
	ll ans = 1;
	int out = 0;
	for (int i = 0; i < 2*n; i++)
	{
		if (inout[i]) {
			out++;
		}
		else {
			ans = mod(ans*out);
			out--;
		}
	}
	ans = mod(ans*fact(n));
	cout << ans << endl;
}

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

int main()
{
    int N;
    cin >> N;
    int A[N], B[N], C[N];
    for(int i = 0; i < N; ++i) cin >> A[i];
    for(int i = 0; i < N; ++i) cin >> B[i];
    for(int i = 0; i < N; ++i) cin >> C[i];
    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);

    ll AB[N], BC[N];
    fill(AB, AB + N, 0);
    fill(BC, BC + N, 0);

    for(int i = 0; i < N; ++i) {
        AB[i] = lower_bound(A, A + N, B[i]) - A ;
        BC[i] = lower_bound(B, B + N, C[i]) - B ;
    }
    /*
    for(int i = 0; i < N; ++i) cout << A[i] <<  " ";
    cout << endl; 
    for(int i = 0; i < N; ++i) cout << B[i] <<  " ";
    cout << endl;
    for(int i = 0; i < N; ++i) cout << C[i] <<  " ";
    cout << endl;
    cout << endl;
    for(int i = 0; i < N; ++i) cout << AB[i] <<  " ";
    cout << endl;
    for(int i = 0; i < N; ++i) cout << BC[i] <<  " ";
    cout << endl;
    */
    for(int i = 1; i < N; ++i) AB[i] += AB[i-1];
    /*
    cout << endl;
    for(int i = 0; i < N; ++i) cout << AB[i] <<  " ";
    cout << endl;
    for(int i = 0; i < N; ++i) cout << BC[i] <<  " ";
    cout << endl;
    */
    ll res = 0;
    for(int i = 0; i < N; ++i) {
        int j = BC[i] - 1;
        if(j >= 0) res  += AB[j];
    }
    cout << res << endl;
    return 0;
}

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

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

    
    long long r=0;
    long long g=0;
    long long b=0;
    for(int i=0;i<n;i++)
    {
      if(s[i]=='R')
        r++;
      if(s[i]=='G')
        g++;
      if(s[i]=='B')
        b++;
    
    }    
    
    long long ans=r*g*b;
    
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j+i+i>n-1)
              break;
            if(s[j]!=s[j+i] and s[j+i]!=s[j+i+i] and s[j]!=s[j+i+i])
               ans--;
        }
        
    }
    
    
    // ans=-1;
    
    

    cout<<ans;
    
    
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll a,b,n;cin >>a >> b >> n;
  if(b==1||a==1){
    cout << 0;
    return 0;
  }
  ll x=b-1;
  while(x>n){
    x--;
  }
  ll ans = a*x/b;
  cout << ans;
  return 0;
}



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

bool f(int x) {
  if (x < 100) return false;
  if (2000 <= x) return true;
  rep(i,1,19) {
    int l = 100 * i, r = 105 * i;
    if (l <= x && x <= r) return true;
  }
  return false;
}

int main() {
  int X;
  cin >> X;
  cout << f(X) << endl;
  return 0;
}


Measured memory_bytes: 256