akhauriyash/Code-Regression huggingface dataset:
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    ll a,b,n,mx=0;
    cin>>a>>b>>n;
    ll i=min(b-1,n);
    ll vag=i/b;
    ll fst=(a*i)/b;
    vag=vag*a;
    cout<<(fst-vag)<<endl;
}





Measured memory_bytes: 3652
x, n = map(int, input().split())

if n != 0:
    ps = list(map(int, input().split()))

    ans = 0
    sa = x
    
    for i in range(0, 102):
        if i not in ps and abs(x-i) < sa:
            ans = i
            sa = x-i
    
    print(ans)
    
else:
    print(x)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  vector<pair<LL,LL>> v(2);
  forn(i,2) cin>>v[i].fi>>v[i].se;
  LL t;cin>>t;
  LL vi = v[0].se - v[1].se;
  if(vi*t >= (abs(v[0].fi-v[1].fi)) ){
    cout<<"YES"<<endl;
  }
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int i,k;

void solve()
{
    cin>>k;
    if(k%2==0 || k%5==0)
    {
        cout<<-1;
        return;
    }
    if(k%7==0)
        k/=7;
    int ans=1%k,cnt=1;
    while(true)
    {
        if(!ans)
            break;
        ans=(ans*10+1)%k;
        cnt++;
    }
    cout<<cnt;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insertx (int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

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

    z->parent = y;

    if(y == NIL){
        root = z;
    } else {
        if (z->key < y->key){
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

Node * findx(int k){
    Node *x = root;
    while(x != NIL && x->key != k){
        if(x->key > k){
            x = x->left;
        } else {
            x = x->right;
        }
    }
    return x;
}

void preOrder(Node *z){
    if (z == NIL){
        return;
    }
    cout << " " << z->key;
    preOrder(z->left);
    preOrder(z->right);
}

void inOrder(Node *z){
    if (z == NIL){
        return;
    }
    inOrder(z->left);
    cout << " " << z->key;
    inOrder(z->right);
}

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

    rep(i, m){
        string S; cin >> S;
        if(S == "insert"){
            int k; cin >> k;
            insertx(k);
        } else if(S == "print"){
            inOrder(root);
            cout << endl;
            preOrder(root);
            cout << endl;
        } else {
            int k; cin >> k;
            Node *x = findx(k);
            if(x == NIL){
                cout << "no" << endl;
            } else {
                cout << "yes" << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 21880
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
  ll q,h,s,d,n;
  cin>>q>>h>>s>>d;
  cin>>n;
  vi v,vv;
  v.pb(q*8);
  v.pb(h*4);
  v.pb(s*2);
  v.pb(d);
  v()
  vv.pb(q*4);
  vv.pb(h*2);
  vv.pb(s);
  sort(vv.begin(),vv.end());
  if(n==1)
  {
      cout<<vv[0]<<endl;
  }
  else
  {
    if(n%2==0)
    {
      cout<<1ll*v[0]*(n/2)<<endl;
    }
    else
    {
      cout<<1ll*v[0]*(n/2)+1ll*vv[0]<<endl;

    }
  }



    
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  int s = accumulate((X).begin(), (X).end(), 0);
  double r = double(s) / N;

  auto score = [&](int r) {
    int res = 0;
    for (int i = 0; i < (int)N; ++i) res += (r - X[i]) * (r - X[i]);
    return res;
  };
  cout << min(score(floor(r)), score(ceil(r))) << endl;

  return 0;
}


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

int main(){
  int n,m,i,wa=0;
  cin>>m;
  n=m;
  for(;;){
    wa+=n%10;
    n/=10;
    if(n==0){break;}
  }
  if(m%wa==0){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const long long INF = 1LL << 60;

bool is_prime(long long N) {
  if (N == 1) return false;
  for (long long i = 2; i * i <= N; ++i) {
      if (N % i == 0) return false;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,k; cin>>n>>k;
  
  int res = 0;
  rep(i,n) {
    int h; cin>>h;
    if (h>=k) ++res;
  }
  cout<<res;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; ll sum = 0;
  vl sidelong(n);
  rep(i,n){
    ll x; cin >> x;
    sum += x;
    sidelong.at(i) = x;
  }
  
  sort(all(sidelong));
  
  if(2*sidelong.at(n-1) < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>

std::vector<int64_t> v(2);
int64_t k;

int main(void)
{
    std::cin >> v.at(0) >> v.at(1) >> k;
    
    for (auto idx = 0; idx < k; ++idx) {
        auto i = idx%2;
        if (v.at(i)%2 == 1) v.at(i)--;
        v.at((i+1)%2) += v.at(i)/2;
        v.at(i) /= 2;
    }
    
    std::cout << v.at(0) << " " << v.at(1) << std::endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  if(c == 'a'
  || c == 'i'
  || c == 'u'
  || c == 'e'
  || c == 'o') {
    cout << "vowel" << endl;
    return 0;
  }
  cout << "consonant" << endl;
  return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	double N, M;
    vector<double> A;
    cin >> N >> M;
    A.resize(N);
    double sum = 0;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    }

    sort(A.begin(), A.end(), greater<double>());
    
    if(A[M - 1] >= sum / (4 * M))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	int a,b,c;
	a=z;
	b=x;
	c=y;
	cout<<a<<" "<<b<<" "<<c<<"\n";
	
}

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

int b = 1'000'000'007;
int h1 = 1'100'023'409;
int h2 = 1'200'017'417;
int h3 = 1'500'026'741;

long long modpow(long long x, long long y, long long p){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1, p) % p;
    return modpow(x, y / 2, p) * modpow(x, y / 2, p) % p;
}


//sのhash値をhashに格納する
//hashはsのsize+1であることに注意
void set_hash(string s, vector<vector<long long>> &hash){
    for (int i = 0; i < 3; i++) hash[i][0] = 0;
    for (int i = 0; i < s.size(); i++) hash[0][i + 1] = (hash[0][i] * b + s[i]) % h1;
    for (int i = 0; i < s.size(); i++) hash[1][i + 1] = (hash[1][i] * b + s[i]) % h2;
    for (int i = 0; i < s.size(); i++) hash[2][i + 1] = (hash[2][i] * b + s[i]) % h3;
}

//hashのx番目(0-indexed)からx_length文字のhash値をhash_tmpに格納して返す
//何度も使うときはmodpowが重いかもしれない
vector<long long> hash_tmp(3);
//vector<vector<long long>> modp(x_lengthの取りうる最大値, vector<long long>(3));
void get_hash(vector<vector<long long>> &hash, int &x, int &x_length){
    //long long p1, p2, p3;
    //p1 = modp[x_length][0];みたいにすると計算量落ちる
    hash_tmp[0] = (hash[0][x + x_length] - hash[0][x] * modpow(b, x_length, h1) % h1 + h1) % h1;
    hash_tmp[1] = (hash[1][x + x_length] - hash[1][x] * modpow(b, x_length, h2) % h2 + h2) % h2;
    hash_tmp[2] = (hash[2][x + x_length] - hash[2][x] * modpow(b, x_length, h3) % h3 + h3) % h3;
}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<long long>> hash(3, vector<long long>(n + 1));
    set_hash(s, hash);
    map<vector<long long>, int> mp;
    int ok = 0;
    int ng = n + 1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        bool flag = false;
        int id = 1;
        mp.erase(mp.begin(), mp.end());
        for (int i = 0; i < n; i++){
            if (mid + i > n) break;
            get_hash(hash, i, mid);
            if (mp[hash_tmp]) {
                if (mp[hash_tmp] + mid - 1 <= i) flag = true;
            }
            else {
                mp[hash_tmp] = i + 1;
                id++;
            }
        }
        if (flag) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

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

int n,m,p;
int d[10000];
int main(){
    cin>>n>>m>>p;p--;
    for(int i=0;i<m;i++){
        cin>>d[i];
        d[i]--;

        d[i]=(d[i]-p+n)%n;
    }

    if(m==1){
        cout<<min(d[0],n-d[0])*100<<endl;
        return 0;
    }

    sort(d,d+m);

    int mi=min(n-d[0],d[m-1]);
    for(int i=0;i<m-1;i++){
        mi=min(mi,d[i]*2+n-d[i+1]);
        mi=min(mi,(n-d[i+1])*2+d[i]);
    }

    cout<<mi*100<<endl;
    return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>

#define N 101
#define INFTY 200000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
void dijkstra();

int main(){
    int i,j;
    int k,c,u,v;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            M[i][j] = INFTY;
        }
    }
    
    for(i=0; i<n; i++){
        scanf("%d%d",&u,&k);
        for(j=0; j<k; j++){
            scanf("%d%d",&v,&c);
            M[u][v] = c;
        }
    }
    
    dijkstra();
    
    return 0;
}

void dijkstra(){
    int minv;
    int d[N],color[N];
    int i,u,v;
    
    for(i=0; i<n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    d[0] = 0;
    color[0] = GRAY;
    while(1){
        minv = INFTY;
        u=-1;
        for(i=0; i<n; i++) {
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u==-1) break;
        color[u] = BLACK;
        for(v=0; v<n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(i=0; i<n; i++){
        printf("%d %d\n",i,d[i]);
    } 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define N 1000005

int a[100005] = {0};

int memo[105][105][105];

void f(int x, int y, int z) {

    if(x>=100 || y>=100 || z>=100) return;

    if(memo[x][y][z] != -1) {
        return;
    }

    int ans = (x*x) + (y*y) + (z*z) + (x*y) + (y*z) + (z*x);

    memo[x][y][z] = ans;

    a[ans]++;

    f(x, y, z+1);
    f(x, y+1, z);
    f(x+1, y, z);
}



int main() {

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

    memset(memo, -1, sizeof memo);

    f(1, 1, 1);

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



Measured memory_bytes: 8584
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main (){
  int x[10000],N,i,j,num;
  
  scanf("%d",&N);

  if(N<1 || N>10000){
    printf("Please type 1 to 10000.");
    exit(1);
  }

  num = N;
  
  for(i=0;i<N;i++){
    scanf("%d",&x[i]);
    if(x[i]>100000000 || x[i] < 2){
      printf("Please type 2 to 100000000.");
      exit(2);
    }
  }
  for(i=0;i<N;i++){
    for(j=2;j<=(int)sqrt(x[i]);j++){
      if(x[i] % j == 0){
	num--;
	break;
      }
    }
  }printf("%d\n",num);
  
  return 0;
}




Measured memory_bytes: 2084
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
n=int(input())
a=factorization(n)
ans=0
for i in range(len(a)):
  tmp=0
  for j in range(1,50):
    tmp+=j
    if a[i][1] >= tmp:
      ans += 1
if n==1:
  print(0)
else:
  print(ans)

Measured memory_bytes: 9432
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double S =r*r*Math.PI, L =2*r*Math.PI;
            System.out.println(String.format("%.6f",S)+" "+String.format("%.6f",L));
        sc.close();
    }
}


Measured memory_bytes: 28372
#include <bits/stdc++.h>
using namespace std;
int vacation(int a[][3],int n,int last,int i,int dp[100001][3]){
    if(i==n){return 0;    }
    if(dp[i][last]!=-1){return dp[i][last];}
    int r;
    if(i==0){
        dp[i][0] = max(a[i][0]+vacation(a,n,0,i+1,dp),max(a[i][1]+vacation(a,n,1,i+1,dp),a[i][2]+vacation(a,n,2,i+1,dp)));
     dp[i][1]=dp[i][0]; dp[i][2]=dp[i][0];
        
    }
    else {
        if(last==0){
           dp[i][0] = max(a[i][1]+vacation(a,n,1,i+1,dp),a[i][2]+vacation(a,n,2,i+1,dp));
        }
        else if(last==1){
            dp[i][1] = max(a[i][0]+vacation(a,n,0,i+1,dp),a[i][2]+vacation(a,n,2,i+1,dp));
        }
        else if(last==2){
            dp[i][2] = max(a[i][0]+vacation(a,n,0,i+1,dp),a[i][1]+vacation(a,n,1,i+1,dp));
        }
    }
    return dp[i][last];
}
int main() {
	int n;
	cin >> n;
	int a[n][3];
	for(int i=0;i<n;i++){
	    cin >> a[i][0]>>a[i][1]>>a[i][2];
	} 
	int dp[100001][3];
	memset(dp,-1,sizeof dp);
	cout<<vacation(a,n,0,0,dp);
	return 0;
}

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

int main(){
    long long l, r, mn=2019; cin >> l >> r;
    for(long long  i = l; i < r && i < l+2019; i++){
        for(long long j = i+1; j <= r && j <= l+2019; j++){
            mn = min(mn, i*j % 2019);
        }
    }
    cout << mn << endl;
    return 0;
}


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

using ll=long long; 

struct P{
	int x,y;
};

void solve(){
	int n,m;
	cin>>n>>m;
	vector<P> a(n), b(m);
	for(auto& e:a){
		cin>>e.x>>e.y;
	}
	for(auto& e:b){
		cin>>e.x>>e.y;
	}
	for(int i=0; i<n; i++){
		vector<int> kyori;
		for(int j=0; j<m; j++){
			int x=abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y);
			kyori.push_back(x);
		}
		cout<<distance(kyori.begin(), min_element(kyori.begin(),kyori.end()))+1<<endl;
	}

}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;

  int flag = 0;
  if(S.at(0)=='R'){
    flag=1;
  }
  int cnt = 0;
  vector<int> vec;
  REP(i,N){
    if(flag==1&&S.at(i)=='R'){
      cnt++;
    }else if(flag==0&&S.at(i)=='L'){
      cnt++;
    }else if(flag==1&&S.at(i)=='L'){
      vec.push_back(cnt);
      cnt=1;
      flag=0;
    }else if(flag==0&&S.at(i)=='R'){
      vec.push_back(cnt);
      cnt=1;
      flag=1;
    }
  }
  vec.push_back(cnt);

  int ans = 0;
  REP(i,vec.size()){
    ans+=vec.at(i)-1;
  }
  
  cout << ans+min(2*K,(int)vec.size()-1) << endl;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const int MAX = 300010;
const int INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
//const int MOD = 1000000007;

int ara[MAX][3];
int dp[MAX][3];
int n;

int call(int pos,int last) {
    if(pos>n) return 0;
    if(dp[pos][last]!=-1) return dp[pos][last];
    int ret = 0;

    for(int i=0;i<3;i++) {
        if(last==i) continue;
        ret = max(ret, call(pos+1,i) + ara[pos][i]);
    }
    return dp[pos][last] = ret;
}

int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    si(n);
    for(int i=1;i<=n;i++) {
        for(int j=0;j<3;j++) si(ara[i][j]);
    }

    SET(dp);
    printf("%d\n",call(1,3));

    return 0;
}



Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
const ll MOD=1e9+7;

struct UnionFind {
   vector<int> par;
   UnionFind(int N) : par(N) {
      for(int i = 0; i < N; i++) par[i] = i;
   }
   int root(int x) {
      if (par[x] == x) return x;
      return par[x] = root(par[x]);
   }
   void unite(int x, int y) {
      int rx = root(x);
      int ry = root(y);
      if (rx == ry) return;
      par[rx] = ry;
   }
   bool same(int x, int y) {
      int rx = root(x);
      int ry = root(y);
      return rx == ry;
   }
};

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

    int N,M;
    cin>>N>>M;
    UnionFind tree(N);
    int X,Y,Z;
    REP(i,M){
        cin>>X>>Y>>Z;
        tree.unite(X-1,Y-1);
    }
    set<int>group;
    REP(i,N){
        group.insert(tree.root(i));
    }
    cout<<group.size()<<endl;
}

Measured memory_bytes: 5376
/*
 * Code from
 * Ali Ashadullah Arif
 * IT-18031_*_2017-18
 * Dept.Of.ICT,MBSTU
 * Date: Today
 * Platform ::::AtCoder:::Easy Linear Programming
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define TEST int t;cin>>t;for(int i=1;i<=t;i++)
int main()
{
    ll a,b,c,k,sum=0;
    cin>>a>>b>>c>>k;
    if(a>=k)
		cout<<k<<endl;
	else if(k>a and k<=a+b)
		cout<<a<<endl;
	else{
       ll s=k-a-b;
       ll ans=a+(s*(-1));
       cout<<ans<<endl;
	}
   // cout<<sum<<endl;
	//main();
    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> num(m);
    for (int i=0; i<n; ++i) {
        int k; cin >> k;
        for (int j=0; j<k; ++j) {
            int a;
            cin >> a; a--;
            num[a]++;
        }
    }
    int ans = 0;
    for (int i=0; i<m; ++i) {
        if (num[i] == n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 *  Created on: 2 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        ll k; cin >> k;
    ll a, b; cin >> a >> b;
    ll ans = ceil((ld)a / k) * k;
    if (ans >= a && ans <= b)
    {
        cout << "OK";
    }
    else
    {
        cout << "NG";
    }

}

Measured memory_bytes: 3648
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 998244353;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int a[3030];
ll dp[3030][3030];
int pw[3030];
ll ans = 0;

int main () {
	SpeedForce;
	
	cin >> n >> m;
	pw[0] = 1;
	For (i, 1, n) pw[i]= (pw[i-1]*2) % mod;
	dp[0][0] = 1;
	For (i, 1, n) {
		cin >> a[i];
		for (int j = m; j >= a[i]; --j) {
			(dp[i][j] += dp[i-1][j-a[i]]) %= mod;
		}
		for (int j = m; j >= 0; --j) {
			dp[i][j] = (dp[i][j] + (dp[i-1][j] * 2)) % mod;
		}
		
		//cout << "now: " << i << ' ' << dp[i][m] << '\n';
		ans += dp[i][m] * (ll) pw[n-i];
		ans %= mod;

	}
	cout << dp[n][m] << '\n';

	return Accepted;
}

// B...a

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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            string s;
            cin >> s;
            if (s == "snuke")
            {
                printf("%c%d\n", 'A' + j, i + 1);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;

struct keyAndValue{
	int key;
	int value;
};

bool compKey(struct keyAndValue left,struct keyAndValue right){
	return (left.value < right.value);
}

int main()
{
	int n,k;
	cin>>n>>k;
	map<int,int> numMap;
	rep(i,n){
		int num;
		cin>>num;
		if(numMap.count(num) == 0){
			numMap.insert(make_pair(num,1));
		}else{
			numMap[num]++;
		}
	}
	vector<struct keyAndValue> vec;
	for(auto iter = numMap.begin(); iter != numMap.end(); iter++){
		struct keyAndValue temp;
		temp.key = iter->first;
		temp.value = iter->second;
		vec.push_back(temp);
		//cout<<temp.key<<" "<<temp.value<<endl;
	}
	sort(vec.begin(),vec.end(),compKey);
	int ans = 0;
	int diverse = vec.size() - k;
	diverse = max(diverse,0);
	rep(i,diverse){
		ans += vec[i].value;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 11768
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())
nsl = lambda: list(nsm())

n, x = nm()
l = nl()
for i in range(n - 1):
    l[i + 1] += l[i]
cnt = 1
for j in range(n):
    if l[j] <= x:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        rep(i,a) cout<<b;
        cout<<endl;
    }
    else{
        rep(i,b) cout<<a;
        cout<<endl;
    }
}

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

int main(void) {
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    
    ll ans = abs(x - a[0]);
    for (int i=1; i<n; i++) ans = gcd(ans, abs(x - a[i]));
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4040
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N; cin >> N;
	// 全体から奇数になる組み合わせの数を引く
	// 3^10~O(1e5)なのでintで収まる
	int all = 1;
	int sub = 1;
	for (int i = 0; i < N; ++i)
	{
		all *= 3;
		int ai; cin >> ai;
		if (ai % 2 == 0) sub *= 2;
		else sub *= 1;
	}
	cout << all - sub << endl;
}


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

constexpr double EPS = 1e-10;
typedef complex<double> Point;
typedef Point Vector;
typedef pair<Point, Point> Segment;
typedef Segment Line;
typedef pair<Point, double> Circle;
typedef vector<Point> Polygon;
double dot(Vector a, Vector b){
	return real(a) * real(b) + imag(a) * imag(b);
}
double cross(Vector a, Vector b){
	return real(a) * imag(b) - imag(a) * real(b);
}
Point project(Line l, Point p){
	Vector base = l.second - l.first;
	base /= abs(base);
	double r = dot(p - l.first, base);
	return l.first + r * base;
}
Point reflect(Line l, Point p){
	return p + (project(l, p) - p) * 2.0;
}
int ccw(Point p0, Point p1, Point p2){
	Vector v = p1 - p0, w = p2 - p0;
	if(cross(v, w) > EPS) return 1; // COUNTER_CLOCKWISE
	if(cross(v, w) < -EPS) return -1; // CLOCKWISE
	if(dot(v, w) < -EPS) return 2; // ONLINE p2 - p0 - p1
	if(norm(v) + EPS < norm(w)) return -2; // ONLINE p0 - p1 - p2
	return 0; // ONLINE p0 - p1 - p2
}
bool isOrthogonal(Vector v, Vector w){
	double t = abs(dot(v, w));
	return t <= EPS;
}
bool isParallel(Vector v, Vector w){
	double t = abs(cross(v, w));
	return t <= EPS;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int q;
	cin >> q;
	while(q--){
		double x[4], y[4];
		for(int i=0; i<4; ++i) cin >> x[i] >> y[i];
		Point p0(x[0], y[0]), p1(x[1], y[1]), p2(x[2], y[2]), p3(x[3], y[3]);
		Vector v = p1 - p0, w = p3 - p2;
		if(isParallel(v, w)) cout << 2 << "\n";
		else if(isOrthogonal(v, w)) cout << 1 << "\n";
		else cout << 0 << "\n";
	}
}


Measured memory_bytes: 3328
#include <stdio.h>
int main() {
	int H, N, A[100000], i = 0, AD = 0;
	scanf("%d%d",&H,&N);
	while (i<N) {
		scanf("%d",&A[i]);
		AD = AD + A[i];
		i++;
	}
	if (AD>=H) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

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

#define N 200
 
int main(){

  char c[N];
  int s[N], top = 0;
  int x, y;
 
  while(scanf("%s", c) != EOF){
    if(c[0] == '+'){
      top = top-1;
      x = s[top+1];
      top = top-1;
      y = s[top+1];
      top++;
      s[top] = x + y;
    }

    else if(c[0] == '-'){
      top = top-1;
      x = s[top+1];
      top = top-1;
      y = s[top+1];
      top++;
      s[top] = y - x;
    }

    else if(c[0] == '*'){
      top = top-1;
      x = s[top+1];
      top = top-1;
      y = s[top+1];
      top++;
      s[top] = x * y;
    }

    else{
      x = atoi(c); 
      top++;
      s[top] = x;
    }
  }

  printf("%d\n", s[top]);

  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

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

    int five_h, five;
    five_h = x/500;
    if(five_h!=0) x -= 500*five_h;
    
    five = x/5;

    cout << 1000*five_h + 5*five << endl;

    return 0;
}

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

int main() {

	ll n; cin >> n;
	const ll q = 10;
	vector<vector<ll>> f(n, vector<ll>(q));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < q; j++) {
			cin >> f[i][j];
		}
	}
	vector<vector<ll>> p(n, vector<ll>(q + 1));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < q + 1; j++) {
			cin >> p[i][j];
		}
	}

	ll ans = -9223372036854775808LL;
	for (ll bit = 1; bit < (1 << q); ++bit) {
		ll tmpAns = 0;
		for (ll i = 0; i < n; i++) {
			ll cnt = 0;
			for (ll j = 0; j < q; ++j) {
				if (bit & (1 << j) && f[i][j] == 1 ) {
					cnt++;
				}
			}
			tmpAns += p[i][cnt];
		}
		ans = max(ans, tmpAns);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
int main()
{     
    long long x,y;
    cin >> x >> y;
    long long  ans = x*y;
    long long r=x%y;
    while(r!=0){
        x=y;
        y=r;
        r=x%y;
    }
    cout << (ans/y);

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 10;
LL v[maxn];
 
// edge
int cnt, h[maxn];
struct edge
{
    int to, pre;
} e[maxn<<1];
void add(int from, int to)
{
    cnt++;
    e[cnt].pre = h[from];
    e[cnt].to = to;
    h[from] = cnt;
}
 
int deg[maxn], ok;
LL dfs(int x, int f)
{
    if(deg[x] == 1) return v[x];
    LL ret = v[x] + v[x];
    for(int i = h[x]; i; i = e[i].pre)
    {
        int to = e[i].to;
        if(to == f) continue;
        LL tmp = dfs(to, x);
        if(tmp > v[x]) ok = 0;
        if(tmp > ret) ok = 0;
        ret -= tmp;
    }
    if(ret > v[x]) ok = 0;
    return ret;
}
 
int main(void)
{
    int N;
    scanf("%d", &N);
    for(int i = 1; i <= N; i++) scanf("%lld", v + i);
    for(int i = 1; i < N; i++)
    {
        int a, b;
        scanf("%d %d", &a, &b);
        add(a, b); add(b, a);
        deg[a]++; deg[b]++;
    }
    if(N == 2)
    {
        if(v[1] == v[2]) puts("YES");
        else puts("NO");
        return 0;
    }
    int rt = 0;
    for(int i = 1; i <= N; i++)
    if(deg[i] != 1) {rt = i; break;}
    ok = 1;
    if(dfs(rt, 0)) ok = 0;
    puts(ok ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 7424
a,b = list(map(int, input().split()))

# print(a,b)

coins = 0

if a > b:
	coins += a
	a -= 1
else:
	coins += b
	b -= 1

if a > b:
	coins += a
	a -= 1
else:
	coins += b
	b -= 1

print(coins)

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

using namespace std;

int main()
{
    int n,d,ans;
    cin >> n >> d;

    int scope = (2*d+1);

    if(n%scope == 0)
        ans = n/scope;
    else
        ans = n/scope + 1;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
AB = input()


mapped_AB  = map(int, AB.split())
#A = list(mapped_AB)[0]
#B = list(mapped_AB)[1]
listed_AB = list(mapped_AB)
A = listed_AB[0]
B = listed_AB[1]

if B%A == 0:
    print(A+B)
else:
    print(B-A)


Measured memory_bytes: 2940
fn main() {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut s: Vec<char> = buf.trim().chars().collect();
  
  let mut a: i32 = s[0] as i32;
  a = a - 48;
  let mut b: i32 = s[1] as i32;
  b = b - 48;
  let mut c: i32 = s[2] as i32;
  c = c - 48;
  let mut d: i32 = s[3] as i32;
  d = d - 48;
 
  if a + b + c + d == 7 {
    println!("{}+{}+{}+{}=7",a,b,c,d);
  }else if a+b+c-d == 7{
    println!("{}+{}+{}-{}=7",a,b,c,d);
  }else if a+b-c-d == 7{
    println!("{}+{}-{}-{}=7",a,b,c,d);
  }else if a-b-c-d == 7{
    println!("{}-{}-{}-{}=7",a,b,c,d);
  }else if a+b-c+d == 7{
    println!("{}+{}-{}+{}=7",a,b,c,d);
  }else if a-b-c+d == 7{
    println!("{}-{}-{}+{}=7",a,b,c,d);
  }else if a-b+c+d == 7{
    println!("{}-{}+{}+{}=7",a,b,c,d);
  }else if a-b+c-d == 7{
    println!("{}-{}+{}-{}=7",a,b,c,d);
  }
}

Measured memory_bytes: 4352
#include <stdio.h>
int L, N, X, W, T;
int main() {
	scanf("%d%d", &L, &N);
	for(int i = 0; i < N; i++) {
		scanf("%d%d", &X, &W);
		T -= X * W;
	}
	if(T > 0) {
		printf("1\n");
		printf("1 %d\n", T);
	}
	else if(T < 0) {
		printf("1\n");
		printf("-1 %d\n", -T);
	}
	else {
		printf("0\n");
	}
	return 0;
}

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

const int MAXN = 1e3+1;
const int MOD = 1e9+7;

int main() {
	int N;
	cin >> N;
	int n[MAXN];
	memset(n, 0, sizeof(n));
	for (int i = 2; i <= N; i++) {
		int _i = i;
		for (int j = 2; j <= i;) {
			if (_i <= 1) break;
			if (_i%j == 0) {
				n[j]++;
				_i /= j;
			} else {
				j++;
			}
		}
	}
	LL ans = 1;
	for (int i = 2; i <= N; i++) {
		if (n[i] > 0) {
			ans *= (n[i] + 1);
			ans %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define forn(i,a,b) for(long long i=a;i<=b;i++)
#define fork(i,a,b,k) for(long long i=a;i<=b;i+=k)
int n;
double p[3000],dp[3005][3005];
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i];
	dp[0][0]=1.0;
	for(int i=1;i<=n;i++){
		dp[i][0]=dp[i-1][0]*(1-p[i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i>=j)dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
		}
	}
	double ans=0.0;
	for(int i=(n+1)/2;i<=n;i++)ans+=dp[n][i];
	cout<<setprecision(10)<<ans;
}

Measured memory_bytes: 69120
#include <iostream>
#include <cstdint>
#include <vector>

template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

public:
    u64 a;

    constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
    constexpr u64& value() noexcept { return a; }
    constexpr const u64& value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint& operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint& operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint& operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint& operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

using Mint = modint<1000000007>;

constexpr Mint mpow(Mint a, int n) {
    Mint res = 1;

    int exp = n;
    while (exp) {
        if (exp % 2) {
            res *= a;
        }
        a *= a;
        exp /= 2;
    }
    return res;
}

template<typename F>
constexpr decltype(auto) fix(F&& f) {
    return[f = std::forward<F>(f)](auto&&... args) {
        return f(f, std::forward<decltype(args)>(args)...);
    };
}

int main() {
    int n, k;
    std::cin >> n >> k;

    std::vector memo(k + 1, -1);
    memo[1] = 1;

    auto count = fix([&](auto f, int m) -> Mint {
        if (memo[m] != -1)
            return memo[m];

        Mint res = mpow(m, n);
        for (int i = 2; i <= m; ++i) {
            if (i > m / 2) {
                res -= m - i + 1;
                break;
            }

            res -= f(f, m / i);
        }

        memo[m] = res.a;
        return res;
    });

    Mint ans = 0;
    for (int i = 1; i <= k; ++i)
        ans += count(k / i) * i;

    std::cout << ans.a << std::endl;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int main () {
  string S; cin >> S;
  int N = S.size();

  vi ans(N);
  rep(ri,2) {
    // solve R
    int cnt = 0;
    rep(i,N) {
      if (S[i] == 'R') {
        cnt++;
      }
      else {
        ans[i] += cnt/2;
        ans[i-1] += (cnt+1)/2;
        cnt = 0;
      }
    }

    reverse(all(ans));
    reverse(all(S));
    rep(i,N) {
      if (S[i] == 'L') {
        S[i] = 'R';
      }
      else {
        S[i] = 'L';
      }
    }
  }

  rep(i,N) {
    printf("%d%c", ans[i], i==N-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

int main () {

  string s;
  cin >> s;
  if( s == "zyxwvutsrqponmlkjihgfedcba" ) {
    cout << -1 << endl;
    return 0;
  }

  if( s.length() < 26 ) {
    char bmp[256];
    memset(bmp, 0, sizeof bmp);
    for(char &c:s)
      bmp[c]=1;
    char c;
    for(c='a'; c<='z' and bmp[c]; c++);
    cout << s << c << endl;
  } else {
    char str[27];
    memcpy(str, s.c_str(), 26);
    str[26] = 0;
    next_permutation(str, str+26);
    for(int i=0; i<26; i++) {
      cout << str[i];
      if( str[i] != s[i] )
	break;
    }
    cout << endl;
  }

  return 0;
}

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 256
// 2020-09-26 02:39:41
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
void answer() {
  ll h, w;
  cin >> h >> w;
  ll ans = min(h, w);
  auto update = [&](ll s1, ll s2, ll s3) {
    chmin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
  };
  rep(_, 2) {
    REP(hi, 1, h) {
      ll s1 = hi * w;
      {
        ll hj = (h - hi) / 2;
        ll s2 = hj * w;
        ll s3 = (h - hi - hj) * w;
        update(s1, s2, s3);
      }
      {
        ll wj = w / 2;
        ll s2 = (h - hi) * wj;
        ll s3 = (h - hi) * (w - wj);
        update(s1, s2, s3);
      }
    }
    swap(h, w);
  }
  cout << ans << '\n';
}

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

Measured memory_bytes: 3600