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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

string s, t;
int ns, nt;
const int N = 5000;
int a[N][N];
string res;

int solve(int i, int j){
	if(i >= ns || j >= nt) return 0;

	if(a[i][j] != -1) return a[i][j];

	int r = 0;

	if(s[i] == t[j]){
		r++;
		r += solve(i + 1, j + 1);
	}
	else{
		r += max(solve(i, j + 1), solve(i + 1, j));
	}

	a[i][j] = r;

	return r;
}

void result(int i, int j){
	if(i < ns && j < nt){
		if(s[i] == t[j]){
			res += s[i];
			result(i+1, j+1);
		}
		else{
			if(i < ns - 1 && j < nt - 1 && a[i][j+1] >= a[i+1][j]) result(i, j + 1);
			else if(i < ns - 1) result(i + 1, j);
			else result(i, j + 1);
		}
	}
}

int main(){
	cin >> s >> t;
	ns = s.size(); 
	nt = t.size();

	memset(a, -1, sizeof(a));

	int r  = solve(0, 0);
	result(0, 0);

	cout << res << endl;

}

Measured memory_bytes: 98176
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** Problem1240 : Unreliable Message **/
int main()
{
	int N; cin>>N;
	rep(z, N) {
		string k, s, ns;
		cin>>k>>s;
		int l=(int)s.size();
		
		rep(i, k.size()) {
			ns="";
			switch(k[k.size()-1-i]) {
				case 'J':
					rep(j, s.size()) {
						ns += s[(l-1+j)%l];
					}
					break;
				case 'C':
					rep(j, s.size()) {
						ns += s[(j+1)%l];
					}
					break;
				case 'E':
					if (l%2==0) {
						ns += s.substr(l/2, l/2);
						ns += s.substr(0, l/2);
					} else {
						ns += s.substr(l/2+1, l/2);
						ns += s[l/2];
						ns += s.substr(0, l/2);
					}
					break;
				case 'A':
					rep(j, l) {
						ns += s[l-1-j];
					}
					break;
				case 'P':
					rep(j, l) {
						if (isdigit(s[j])) {
							if (s[j]=='0')
								ns+='9';
							else
								ns+=s[j]-1;
						} else {
							ns += s[j];
						}
					}
					break;
				case 'M':
					rep(j, l) {
						if (isdigit(s[j])) {
							if (s[j]=='9')
								ns+='0';
							else
								ns+=s[j]+1;
						} else {
							ns += s[j];
						}
					}
					break;
			}
			
			s = ns;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1208
s=input()
s="L"+s+"R"
N=len(s)
a=[1]*N
for i in range(1,N-1):
    if s[i]=="R" and s[i+1]=="R":
        a[i+2]+=a[i]
        a[i]=0
for i in range(N-1,1,-1):
    if s[i]=="L" and s[i-1]=="L":
        a[i-2]+=a[i]
        a[i]=0
print(*a[1:-1])


Measured memory_bytes: 47672
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a;
  cin>>a;
  string x="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string y="abcdefghijklmnopqrstuvwxzy";
  for(int i=0;i<26;i++){
    if(a==x[i]){
      cout<<'A'<<endl;
    }
    if(a==y[i]){
      cout<<'a'<<endl;
    }
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,k,i,d,j,x,ans=0;
    cin>>n>>k;
    int ar[n+1]={0};
    for(i=0;i<k;i++)
    {
        cin>>d;
        for(j=0;j<d;j++)
        {
            cin>>x;
            if(ar[x]==0)
                ans+=1;
            ar[x]+=1;
        }
    }
    cout<<n-ans<<"\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans{};
  for (int i{1}; i <= N; ++i) {
    if (i % 2 == 0) continue;
    int count{};
    for (int j{1}; j <= i; ++j) {
      if (i % j == 0) ++count;
    }
    if (count == 8)
      ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int n , now = 0;
int saiki(int now){
	if( now == n )
		return 1;
	if( now > n )
		return 0;
	int res = 0;
	res += saiki(now+1)+saiki(now+2)+saiki(now+3);
	return res;
}
int main(){
	while(1){
		int x=0;
		cin >> n;
		if( n==0 ) break;
		int count = saiki(0);
		int co = count / 10;
		if( count%10 > 0 )
			co ++;
		x = co / 365 ;
		if(co%365>0)
			x ++;
		cout << x << endl;
	}
}

Measured memory_bytes: 3076
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

ll length(ll L) {
    return 4 * ((ll)1 << L) - 3;
}

ll eat_all(ll L) {
    return ((ll)1 << (L+1)) - 1;
}

ll eat(ll L, ll X) {
    if (X <= 0) {
        return 0;
    }
    if (length(L) <= X) {
        return eat_all(L);
    }
    ll ans = 0;
    X--;
    ans += eat(L-1, X);
    X -= length(L-1);
    if (X <= 0) {
        return ans;
    }
    X--;
    ans += 1;
    ans += eat(L-1, X);
    return ans;
}

int main() {
    ll N, X;
    cin >> N >> X;
    cout << eat(N, X) << endl;
}



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

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

int n;

void solve() {
  int a = 0, b = 0;
  rep(i,n) {
    int ta, tb; cin>>ta>>tb;
    if (ta > tb) a += ta + tb;
    else if (ta < tb) b += ta + tb;
    else a += ta, b += tb;
  }
  cout<<a<<" "<<b<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

char f(int x){
  char S;
  S='a'+x-1;
  return S;
}

int main(void){
  char s[11][115976][11];
  int a[11][115976];
  int c[11];
  int n,i,j,k,l,p;
  
  s[1][1][1]='a';
  a[1][1]=1;
  c[1]=1;
  
  for(i=2;i<=10;i++){
    p=0;
    for(j=1;j<=c[i-1];j++){
      for(k=1;k<=a[i-1][j]+1;k++){
        for(l=1;l<=i-1;l++){
          s[i][p+k][l]=s[i-1][j][l];
        }
        s[i][p+k][i]=f(k);
        if(k==a[i-1][j]+1){
          a[i][p+k]=a[i-1][j]+1;
        }else{
          a[i][p+k]=a[i-1][j];
        }
      }
      p=p+a[i-1][j]+1;
    }
    c[i]=p;
  }
  
  scanf("%d",&n);
  for(j=1;j<=c[n];j++){
    for(l=1;l<=n;l++){
      printf("%c",s[n][j][l]);
    }
    printf("\n");
  }
  
  return 0;
  
}

Measured memory_bytes: 16640
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN         PIC X(30).
01 A          PIC 9(10).
01 B          PIC 9(10).
01 ANS        PIC Z(9)9(1).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO A B.
  MULTIPLY A BY B GIVING ANS.
  DISPLAY FUNCTION TRIM(ANS).
  STOP RUN.


Measured memory_bytes: 3916
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();

        if (N % sum(N) == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static int sum(int n) {
        int sum = 0;
        while (n > 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

const int N = 2e5 + 7;

int p[N];
int rnk[N];

int get(int v) {
	if (p[v] != v) {
		p[v] = get(p[v]);
	}
	return p[v];
}

void merge(int a, int b) {
	a = get(a);
	b = get(b);
	if (rnk[a] < rnk[b]) swap(a, b);
	p[b] = a;
	if (rnk[a] == rnk[b]) rnk[a]++;
}

void init() {
	for (int i = 0; i < N; i++) {
		p[i] = i;
	}
}

int cnt[N];
int dga[N];
int dgb[N];

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

	init();

	int n, m, k;
	cin >> n >> m >> k;
	vector<pair<int, int>> a(m);
	for (auto &t : a) {
		cin >> t.first >> t.second;
		t.first--;
		t.second--;
		dga[t.first]++;
		dga[t.second]++;
		merge(t.first, t.second);
	}
	vector<pair<int, int>> b(k);
	for (auto &t : b) {
		cin >> t.first >> t.second;
		t.first--;
		t.second--;
	}
	for (int i = 0; i < n; i++) {
		cnt[get(i)]++;
	}
	for (auto t : b) {
		if (get(t.first) == get(t.second)) {
			dgb[t.first]++;
			dgb[t.second]++;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << cnt[get(i)] - 1 - dga[i] - dgb[i] << ' ';
	}
	cout << endl;
	
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
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<<"Right"<<endl;
}
else{cout<<"Balanced"<<endl;}
}


Measured memory_bytes: 764
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}
	
	cnt := strings.Count(s[2:len(s)-1], "C")
	if cnt != 1 {
		fmt.Println("WA")
		return
	}
	
	for i := 1; i < len(s); i++ {
		target := s[i]
		if !(target >= 'a' && target <= 'z' || target == 'C') {
			fmt.Println("WA")
			return
		}
	}
	fmt.Println("AC")
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int, int>> memo(n);
    rep(i,n){
        cin >> a[i];
        memo[i] = make_pair(a[i], i);
    }
    sort(memo.begin(), memo.end());
    bool land_flag = false;
    int cnt = 0;
    rep(i,n){
        if (a[i] != 0){
            if (!land_flag){
                cnt++;
                land_flag = true;
            }
        }
        else land_flag = false;
    }
    int ans = cnt;
    rep(i,n-1){
        int sec_no = memo[i].second;
        a[sec_no] = 0;
        if (memo[i].first == 0) continue;

        /* 左端の場合 */
        if (sec_no == 0){
            if (a[sec_no+1] == 0) cnt--;
        }
        /* 右端の場合 */
        else if (sec_no == n-1){
            if (a[sec_no-1] == 0) cnt--;
        }
        /* それ以外 */
        else{
            if ( (a[sec_no-1] == 0) && (a[sec_no+1] == 0) ) cnt--; 
            else if ( (a[sec_no-1] > 0) && (a[sec_no+1] > 0) ) cnt++; 
        }
        if (memo[i].first != memo[i+1].first)
            ans = max(cnt, ans);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    
    
    while(true){
        
        
        int m,f,r;
        cin>>m>>f>>r;
        
        if(m==-1&&f==-1&&r==-1)break;
        
        int ans=m+f;
        if(m==-1||f==-1){
            cout<<'F'<<endl;
        }
        else if(ans>=80){
            cout<<'A'<<endl;
        }else if(ans>=65){
            cout<<'B'<<endl;
        }else if(ans>=50){
            cout<<'C'<<endl;
        }else if(ans>=30){
            if(r>=50)cout<<'C'<<endl;
            else cout<<'D'<<endl;
        }else{
            cout<<'F'<<endl;
        }
        
        
    }
}


Measured memory_bytes: 3072
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int a[100];

int main(){
	IOS;
	int N;
	while(cin>>N){
		for(int i=0;i<100;i++){
			a[i]=0;
		}
		int amax=0;
		for(int i=0;i<N;i++){
			int x;
			cin>>x;
			a[x]++;
			amax=max(amax,x);
		}
		int ans=0;
		for(int i=0;i<=amax;i++){
			if(a[i]!=0){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
set<ll> st;

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

  cin >> n;
  rep(i, n) {
    cin >> a;
    st.insert(a);
  }
  if (Size(st) == n)
    Cout("YES");
  else
    Cout("NO");
  return 0;
}

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

int main() {
  int a, b, c, count = 0;
  cin >> a >> b >> c;

  for (int i = 0; i < b - a + 1; i++) {
    if (c % (a + i) == 0) count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 3100
// Problem : F - Unfair Nim
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    int n;
    cin >> n;
    vector<int> vec(n);
    int x = 0;
    for (int i = 0; i < n; i++) {
      cin >> vec[i];
      x = x ^ vec[i];
    }
    if (x == 0) {
      die(0);
    }
    x ^= vec[1];
    x ^= vec[0];
    int s = vec[0] + vec[1];
    if (s % 2 != x % 2) die(-1);
    if (s < x) die(-1);
    int an = (s - x) >> 1;
    // db2(s, an);
    bitset<41> bx(x), ba(an);
    // db2(bx, ba);
    int a = an;
    for (int i = 40; i >= 0; i--) {
      if (bx[i] == 1 && ba[i] == 0) {
        if ((a | (1LL << i)) <= vec[0]) {
          a = a | (1LL << i);
          // db2(i, a);
        }
      }
      if (bx[i] == 1 && ba[i] == 1) die(-1);
    }
    // db1(a);
    if (a > vec[0] || a == 0) die(-1);
    int temp = vec[1] + (vec[0] - a);
    if ((temp ^ a) != x) die(-1);

    cout << llabs(a - vec[0]);
  }

  return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[100];
void push(int x)
{
  S[++top]=x;
}

int pop()
{
  top--;
  return S[top+1];
}


int main()
{
  top=0;
  int a,b;
  char s[100];
  while(scanf("%s",s)!=EOF)
    {
      if(s[0]=='+')
	{
	  a=pop();
	  b=pop();
	  push(a+b);
	}
      else  if(s[0]=='-')
	{
	  b=pop();
	  a=pop();
	  push(a-b);
	}
      else if(s[0]=='*')
	{
	a=pop();
	b=pop();
	push(a*b);
	}
      else
	{
	  push(atoi(s));
	}
    }
  printf("%d\n",pop());

  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 1048576
bool p[N]={};

int main(){
	FOR(i, 2, N){
		if(p[i]) continue;
		for(int j = i*2; j < N; j += i){
			p[j] = true;
		}
	}
	ll a, b; scanf("%lld%lld", &a, &b);
	ll c = __gcd(a, b);
	int ans = 1;
	FOR(i, 2, N){
		if(p[i]) continue;
		int x = 0;
		while(c % i == 0){
			x = 1;
			c /= i;
		}
		ans += x;
	}
	if(c > 1) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 1280
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int m[200001];

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

    int X = gi();
    int Y = gi();
    int n = gi();

    for (int i = 0; i < X; i++)
        m[i] = Y;
    m[X] = 0;
    for (int i = 0; i < n; i++) {
        int x = gi()-1;
        int y = gi()-1;
        m[x] = MIN(m[x], y);
    }

    int y = 0;
    for (int i = 0; ; i++) {
        if (m[i+1] <= y) {
            printf("%d\n", i+1);
            break;
        }
        if (m[i+1] > y+1)
            y++;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int a[9999];
int f(int n,int d){return n==0||(d-n%10==1&&f(n/10,n%10));}
int main(){
	int n,r=-1,i=0,j,q;
	for(scanf("%d",&n);i<n;i++)scanf("%d",a+i);
	for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(q=a[i]*a[j],r<q&&f(q/10,q%10))r=q;
	*a=!printf("%d\n",r);
}

Measured memory_bytes: 600
#include <cstdio>

int main()
{
  long long n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  if (a > b || n == 1 && a != b)
  {
    puts("0");
    return 0;
  }

  printf("%lld\n", (a + b * (n - 1)) - (a * (n - 1) + b) + 1);
  return 0;
}

Measured memory_bytes: 128
from collections import deque

n = int(input())
result = deque()

for i in range(n):
  command = input()
  if command == "deleteLast":
    result.pop()
  elif command == "deleteFirst":
    result.popleft()
  else:
    com, value = command.split()
    value = int(value)
    if com == "insert":
      result.appendleft(value)
    elif com =="delete":
      try:
        result.remove(value)
      except:
        pass
      
print(*result, sep=" ")



Measured memory_bytes: 45948
#include <bits/stdc++.h>
using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
int INF = 1e9 + 7;
long long INF2 = 1e16;

int main(void) {
  int n;
  char c;
  cin >> n;
  vector <vector <bool>> v(n, vector <bool>(n));
  ffor(n) {
    fffor(n) {
      cin >> c;
      if (c == '0') v[i][j] = 0;
      else v[i][j] = 1;
    }
  }
  
  int max_mask = (1 << n) - 1;
  vector <long long> dp(max_mask + 1);
  dp[0] = 1;
  
  for(int mask = 0; mask < max_mask; mask++) {
    int bit_num = __builtin_popcount(mask);
    for(int i = 0; (1 << i) <= max_mask; i++) {
      if (((1 << i) & mask) == 0 && v[i][bit_num] == 1) {
        int new_mask = mask | (1 << i);
        dp[new_mask] += dp[mask];
        dp[new_mask] %= INF;
      }
    }
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 19608
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, h[1000] = {}; double t, a,m=1000;
    cin >> n >> t >> a;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        m = min(m, fabs(a - t + 0.006 * h[i]));
    }
    for (int i = 0; i < n; i++) {
        if (m== fabs(a - t + 0.006 * h[i])) cout << i + 1 << " ";
    }
    cout << endl;
}

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

string S;

int main() {
    cin >> S;

    int m = S.size() / 2;

    for (int i = 1; i < m; i++) {
        int len = S.size();
        S = S.substr(0, len - 2);
        bool tmp = true;
        // cout << S << endl;
        rep(j, S.size() / 2) {
            // printf("%c %c\n", S[j], S[S.size() / 2 + j]);
            if (S[j] != S[S.size() / 2 + j]) {
                tmp = false;
                break;
            }
        }

        if (tmp) {
            cout << S.size() << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int W = sc.nextInt();
        if (W >= S) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}

Measured memory_bytes: 35656
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin >> k;
    int a, ans = -1;
    for(int i=0; i<k; i++){
        if(i==0) a = 7;
        else a = (10*a + 7)%k;
        if(a%k == 0){
            ans = i + 1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

int n,temp,sum=0,maxi;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n;
    rep(i,1,n)
    {
        cin>>temp;
        if(i==1)
            maxi=temp;
        else
        {
            if(temp>=maxi)
                maxi=temp;
        }
        sum+=temp;
    }
    sum-=maxi/2;
    cout<<sum;
}



Measured memory_bytes: 256
from collections import deque
H, W, M = map(int, input().split())
bomb = []
counth = [0 for _ in range(H)]
countw = [0 for _ in range(W)]
for _ in range(M):
  h, w = map(int, input().split())
  h -= 1
  w -= 1
  bomb.append(h+ w*H)
  counth[h] += 1 
  countw[w] += 1


maxh = max(counth)
maxw = max(countw)

counth = deque(counth)
countw = deque(countw)

index_h = deque([])
index_w = []
for k in range(H):
  h = counth.popleft()
  if h == maxh:
    index_h.append(k)
lenh = len(index_h)

for k in range(W):
  w = countw.popleft()
  if w == maxw:
    index_w.append(k)
    lenw = len(index_w)
    if lenh*lenw > M:
      print(maxh + maxw)
      exit()    

ans = maxh + maxw - 1

bomb.sort()
bomb = deque(bomb)
kouho = []
for i in range(lenh):
  h = index_h.pop()
  for j in range(lenw):
    w = index_w[j]
    kouho.append(h+ H*w)
kouho.sort()
kouho = deque(kouho)
B = bomb.popleft()
K = kouho.popleft()
while True:
  if B > K:
    ans += 1
    break
  elif B == K:
    if len(kouho) == 0:
      break
    else:
      K = kouho.popleft()
  else:
    if len(bomb) == 0:
      ans += 1
      break
    else:
      B = bomb.popleft()
print(ans)



Measured memory_bytes: 56796
D,*CS = map(int, open(0).read().split())
C = CS[:26]
S = [CS[26*i:26*(i+1)] for i in range(1, D+1)]

def weight(xs):
    s = sum(CS)
    return [x / s for x in xs]

ds = [0] * 26
cmap = weight(C)

def pick(d):
    m = -1
    i = 0
    for j, x in enumerate(cmap):
        c = (d - ds[j]) * x
        if c > m:
            i = j
            m = c
    return i

for d in range(D):
    i = pick(d)
    ds[i] = d
    print(i + 1)

Measured memory_bytes: 10188
#include <bits/stdc++.h>
#define len(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define chmax(x, v) x = max((x), (v))
#define chmin(x, v) x = min((x), (v))
typedef long long int lli;
 
#define rep(i,a,b) for(int i=a;i<b;i++)
 
#define endl "\n"
using namespace std;
using ll = long long;
 
int notSame(string temp,string t)
{
    int ans=0;
    rep(i,0,temp.size())
    {
        ans+=(temp[i]!=t[i]);
    }
    return ans;
}
 
int main()
{
    string s,t;
    cin>>s>>t;
    int ans=1e9;
    rep(i,0,(s.size()-t.size()+1))
    {
      string temp=s.substr(i,t.size());
      ans=min(ans,notSame(temp,t));
    }
    cout<<ans<<endl;
    return 0;
 
 
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<ll> acc_sum(n+1,0);
    repp(i,1,n+1){
        ll a ;
        cin >> a;
        acc_sum[i] = acc_sum[i-1] + a;
    }
    ll res = INF;
    for(int i = 1;i < n;i++){
        res = min(res,abs(acc_sum[i] - (acc_sum[n] - acc_sum[i]) ));
    }
    cout << res << endl;
    return 0;
}

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

using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i{}; i < N; ++i) cin >> A[i];

  // 累積和
  vector<ll> s(N + 1, 0);
  for (int i{}; i < N; ++i) {
    s[i + 1] = s[i] + A[i];
  }

  map<ll, ll> num;
  for (int i{}; i <= N; ++i) {
    ++num[s[i]];
  }

  ll ans{};
  for (const auto &p : num) {
    ans += p.second * (p.second - 1) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 15104
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

main(){
    int n,A[1000];
    while(1){
        cin >>n;
        if (n==0)break;
        for(int i=0;i<n;i++)cin>>A[i];
        int sum=0;
        for(int i=0;i<n;i++)sum+=A[i];
        double avg=1.0*sum/n;
        double dist=0.0;
        for(int i=0;i<n;i++){
            dist += (avg-A[i])*(avg-A[i]);
            
        }
        printf("%lf\n",sqrt(dist/n));
    }
    return 0;
}


Measured memory_bytes: 3204
import math

n = int(input())

without_tax = float(n/1.08)
without_tax_floor = math.floor(without_tax)
without_tax_ceil = math.ceil(without_tax)

if math.floor(without_tax_floor * 1.08) == n:
    print(without_tax_floor)
elif math.floor(without_tax_ceil * 1.08) == n:
    print(without_tax_ceil)
else:
    print(':(')

Measured memory_bytes: 62132
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  int64_t N;
  cin>>N;
  int64_t ai[N];
  int64_t ans=0;
  for(int i=0;i<N;i++){
    cin>>ai[i];
    ans+=ai[i]-1;
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

lm = -9 # 最後に食べたメニュー
s = 0 # 満足度
N.times do |i|
  s += B[A[i]-1] # 通常の満足度
  s += C[lm] if (A[i]-1) - lm == 1 # 連続ボーナス
  lm = A[i] - 1
end
p s

Measured memory_bytes: 1788
#include <iostream>
#include <vector>

using std::cin, std::cout, std::endl;

constexpr long long mod = 1'000'000'007;

auto main (void) -> int {
  int n;
  cin >> n;

  std::vector<int> a (n);
  for (auto i = 0; i < n; i++) cin >> a[i];

  auto tmp_0 = 0LL;
  auto tmp_1 = 0LL;

  for (auto i : a) {
    auto c = static_cast<long long> (i);
    tmp_0 += c;
    tmp_1 += c * c;
    if (tmp_0 > mod) tmp_0 %= mod;
    if (tmp_1 > mod) tmp_1 %= mod;
  }
  tmp_0 = (tmp_0 * tmp_0) % mod;

  auto b = tmp_0 < tmp_1 ? tmp_0 - tmp_1 + mod : tmp_0 - tmp_1;

  // mod が奇数なので b が奇数だったり偶数だったりして / 2 で引っかかる
  // この時点でまあ mod 以下
  cout << (b + (b % 2) * mod) / 2 << endl;

  return 0;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n,i,j=0,x,y,m;
	cin >> n >> m;
	while(n--)
	{
		cin >> x >> y;
		if(x * x + y * y <= m * m)
		{
			j++;
		}
	}
	cout << j;
	return 0;
}

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

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

  rep(i, x + 1) {
    if ((i * 2 + (x - i) * 4) == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
n = int(input())
h = list(map(int,input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

print(dp[-1])

Measured memory_bytes: 13980
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int arr[3];
  for (int i = 0; i < 3; i ++){
    cin >> arr[i];
  }
  sort(arr, arr+3);

  for (int i = 0; i < 3; i ++){
    if (i == 2){
      cout << arr[i] << "\n";
    }else{
      cout << arr[i] << " ";
    }
  }

}



Measured memory_bytes: 3132
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    int ans = 0;
    string s;
    for(int c=0; c<2; c++){
      cin >>s;
      for(int i=0,x=1; i<s.size(); i++){
	if(s[i] == 'm'){ans+=x*1000;x = 1;}
	else if(s[i] == 'c'){ans+=x*100;x = 1;}
	else if(s[i] == 'x'){ans+=x*10;x = 1;}
	else if(s[i] == 'i'){ans+=x;x = 1;}
	else x = s[i]-'0';
      }
    }
    if(ans>=2000) cout <<ans/1000;
    if(ans>=1000){cout <<"m";ans%=1000;}
    if(ans>=200) cout <<ans/100;
    if(ans>=100){cout <<"c";ans%=100;}
    if(ans>=20) cout <<ans/10;
    if(ans>=10){cout <<"x";ans%=10;}
    if(ans>=2) cout <<ans;
    if(ans>=1) cout <<"i";
    cout <<endl;
  }
  return 0;
}

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

typedef long long lli;

const lli INF = 1LL<<60;

int main() {
  int N;
  cin >> N;
  vector<lli> a(N);
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  a.push_back(INF);
  sort(a.begin(), a.end());
  lli sum = 0;
  for(int i = 0; i < a.size(); ++i) {
    if(sum+1 < a[i]) {
      cout << sum+1 << endl;
      break;
    }
    sum += a[i];
  }
  return 0;
}

Measured memory_bytes: 1344
n,k=map(int, input().split())
an=[int(i) for i in input().split()]

def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r=min(r,n-r)
    return fact[n] * factinv[r] * factinv[n-r] %mod

mod = 10 ** 9 + 7
N = 10 ** 5
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2,N+1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

an=sorted(an)
r_an=list(reversed(an))

max1=0
min1=0
for i in range(1,n-k+2):
    c=cmb(n-i,k-1,mod)
    max1=max1 + an[-i]*c%mod
    min1=min1 + r_an[-i]*c%mod
print((max1-min1)%mod)

Measured memory_bytes: 79016
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        vector<int> a(n);
        in_arr(int, a, n);
        sort(a.begin(), a.end());
        int sum = 0;
        for(int i = 1; i < n - 1; ++i){
            sum += a[i];
        }
        cout << sum / (n - 2) << endl;
    }
    return 0;
}



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

int main(void){
    int k,x;
    cin >> k >> x;
    cout << (k*500 < x ? "No": "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool flag = false;
    for(int i=1; i<10; i++){
        if(!(n%i) && n/i < 10) flag = true;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    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++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    sort(ALL(p));
    int ans = 0;
    rep(i, K) {
        ans += p[i];
    }
    cout << ans << endl;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> b(N);
    for(int i = 0; i < N; i++){
        cin >> b[i];
        if(b[i] > i + 1){
            cout << -1 << endl;
            return 0;
        }
    }
    
    vector<int> ans(N);
    
    for(int i = 0; i < N; i++){
        int now = -1;
        for(int j = 0; j < b.size(); j++){
            if(b[j] == j + 1){
                now = j;
            }
        }
        if(now == -1){
            cout << -1 << endl;
            return 0;
        }
        
        ans[i] = now + 1;
        
        b.erase(b.begin() + now);
    }
    
    for(int i = N - 1; i >= 0; --i){
        cout << ans[i] << endl;
    }
}



Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func NextStr() string {
	scanner.Scan()
	return scanner.Text()
}

func NextInt() int {
	i, _ := strconv.Atoi(NextStr())
	return i
}

func Max(x ...int) int {
	res := x[0]
	for _, a := range x {
		if res < a {
			res = a
		}
	}
	return res
}

func main() {
	scanner.Split(bufio.ScanWords)
	R, C, K := NextInt(), NextInt(), NextInt()
	V := make([][]int, R)
	for i := 0; i < R; i++ {
		V[i] = make([]int, C)
	}

	for i := 0; i < K; i++ {
		r, c, v := NextInt(), NextInt(), NextInt()
		V[r-1][c-1] = v
	}

	// rows := make([]int, R)

	dp := make([][][]int, R)
	for i := 0; i < R; i++ {
		dp[i] = make([][]int, C)
		for j := 0; j < C; j++ {
			dp[i][j] = make([]int, 4)
		}
	}

	dp[0][0][0] = 0
	dp[0][0][1] = V[0][0]

	for i := 0; i < R; i++ {
		for j := 0; j < C; j++ {
			//  first item for the row
			for k := 0; k < 4; k++ {
				switch k {
				case 0:
					if i > 0 {
						dp[i][j][k] = Max(dp[i-1][j][k], dp[i][j][k])
					}
					if j > 0 {
						dp[i][j][k] = Max(dp[i][j-1][k], dp[i][j][k])
					}
				case 1, 2, 3:
					if i > 0 {
						for n := 0; n < 4; n++ {
							dp[i][j][k] = Max(dp[i-1][j][k], dp[i-1][j][n]+V[i][j], dp[i-1][j][n], dp[i][j][k])
						}
					}
					if j > 0 {
						dp[i][j][k] = Max(dp[i][j-1][k], dp[i][j-1][k-1]+V[i][j], dp[i][j][k])
					}
				}
			}
		}
	}
	fmt.Println(Max(dp[R-1][C-1]...))
}


Measured memory_bytes: 598760
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    char a; cin >> a;
    if (a >= 'a' && a <= 'z') {
        cout << "a" << endl;
    }
    else {
        cout << "A" << endl;
    }
}



















Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

int main(){
    int D,x,y;
    cin>>D;
    cin>>x;
    vector<int> X;
    for(int i=0;i<x;i++){
        string a;
        int p;
        cin>>a>>p;
        if(a=="D"){
            X.push_back(p);
        }
    }
    sort(X.begin(), X.end(),greater<int>());
    cin>>y;
    vector<int> Y;
    for(int i=0;i<y;i++){
        string bc;
        int q;
        cin>>bc>>q;
        if(bc=="DD"){
            Y.push_back(q);
        }
    }
    sort(Y.begin(), Y.end(),greater<int>());
    int ans=0;
    for(int d=0;d<=D;d+=2){
        int xx=D-d;
        int yy=d/2;
        int P=0;
        for(int i=0;i<xx&&i<X.size();i++){
            P+=X[i];
        }
        for(int i=0;i<yy&&i<Y.size();i++){
            P+=Y[i];
        }
        ans=max(ans,P);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, m;
    cin >> n >> m;
    vector<pair<long, long>> s(n);
    for(int i = 0; i < n; i++){
        long a, b;
        cin >> a >> b;
        s[i] = make_pair(a, b);
    }
    vector<pair<long, long>> p(m);
    for(int i = 0; i < m; i++){
        long a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    //for(auto a : s){ cout << a.first << " " << a.second << endl; }
    //for(auto a : p){ cout << a.first << " " << a.second << endl; }
    //cout << s.size() << " " << p.size() << endl;
    for(int i = 0; i < n; i++){
        long mi = 1000000000, po = -1;
        for(int j = m-1; j >= 0; j--){
            long len = abs(p[j].first - s[i].first) + abs(p[j].second - s[i].second);
            mi = min(mi, len);
            if(mi == len) po = j+1;
        }
        cout << po << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

//                                          mdsaqib
signed main(){
    fast;
    int n;
    cin >> n;
    int ans=1000-(n%1000);
    if(ans==1000)ans=0;
    cout << ans;
    
}

Measured memory_bytes: 3692
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String target = sc.next();
        int n = sc.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            s = s + s;
            if (s.contains(target)) {
                count++;
            }
        }
        System.out.println(count);
    }
}



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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	string s;
	cin >> s;
	long long ans = 0;
	int cnt_a = 0;
	for (int i = 0; i < (int)s.length(); ++i) {
		if (s[i] == 'A') {
			++cnt_a;
		} else {
			if (i < (int)s.length() - 1 && s[i] == 'B' && s[i + 1] == 'C') {
				ans += cnt_a;
				i += 1;
			} else {
				cnt_a = 0;
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 764
import sys
f=lambda:map(int,sys.stdin.readline().split())
n,m=f()
lt=sorted(tuple(map(int,input().split())) for _ in range(n))[::-1]
from heapq import *
q=[]
s=t=0
while t<m:
  t+=1
  while lt and lt[-1][0]==t:
    a,b=lt.pop()
    heappush(q,-b)
  if q: s-=heappop(q)
print(s)

Measured memory_bytes: 17328
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    String[] T = sc.nextLine().split(" ");
    int now = 0;
    int ans = 0;
    for(int i = 0; i < N; i++){
      int sec = Integer.parseInt(T[i]);
      if(i == 0){
        ans += M;
        now = sec;
      }else if(now + M > sec){
        ans += sec - now;
        now = sec;
      }else{
        ans += M;
        now = sec;
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;



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

	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << '\n';
	}
	else {
		cout << "No" << '\n';
	}

	return 0;	
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 n, m, a[101010], b[101010];
int d[101010];
void solve(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		d[a[i]]++; d[b[i]]++;
	}
	for(int i = 1; i <= n; i++){
		if(d[i] & 1){
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

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


Measured memory_bytes: 1408
x = int(input(''))

can = []
for a in range(10**3):
    a5 = a**5
    if not a5 in can:
        can.append(a5)

result = []
for a in can:
    for b in can:
        if a - b == x:
            ans = "{} {}".format(int(a**(1/5)),int(b**(1/5)))
            if not ans in result:
                result.append(ans)
        if a + b == x and a > b:
            ans = "{} {}".format(int(a**(1/5)),int(-1 * b**(1/5)))
            if not ans in result:
                result.append(ans)

for r in result:
    print(r)

Measured memory_bytes: 9480
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define endl "\n"
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000009

#define N_MAX 20

struct bit{
  long long dat[N_MAX + 1];

  void init(){
    for(int i = 0; i < N_MAX; i++){
      dat[i] = 0;
    }
  }

  long long sum(int i){
    long long s = 0;
    while(i > 0){
      s += dat[i];
      i -= i & -i;
    }
    return s;
  }

  void add(int i, long long x){
    while(i <= N_MAX){
      dat[i] += x;
      i += i & -i;
    }
  }
}bit1;

ll f(vector<ll> &v){
  bit1.init();
  ll ans = 0;
  rep(i,0,v.sz){
    ans += i-bit1.sum(v[i]);
    bit1.add(v[i],1);
  }
  return ans;
}

int main(){
  ll n;
  cin>>n;
  vector<pair<pair<ll,ll>,ll> > v;
  vector<ll> v1,v2;
  rep(i,0,n){
    ll a;
    cin>>a;
    v1.pb(a);
  }
  rep(i,0,n){
    ll a;
    cin>>a;
    v2.pb(a);
  }
  rep(i,0,v1.sz){
    if(i%2==0){
      v.pb(mp(mp(v1[i],v2[i]),i+1));
    }
    else{
      v.pb(mp(mp(v2[i],v1[i]),i+1));
    }
  }
  sort(all(v));
  ll c = 0;
  rep(i,0,n){
    if(i%2==0)c++;
  }
  vector<ll> vv;
  rep(i,0,c){
    vv.pb(1);
  }
  rep(i,0,n-c){
    vv.pb(0);
  }
  reverse(all(vv));
  ll mn = 1000000000;
  do{
    vector<pair<ll,ll> > vp[2];
    rep(i,0,n){
      if(vv[i]==0){
        vp[1].pb(mp(v[i].fi.se,v[i].se));
      }
      else{
        vp[0].pb(mp(v[i].fi.fi,v[i].se));
      }
    }
    sort(all(vp[0]));
    sort(all(vp[1]));
    vector<ll> v1;
    vector<ll> v2;
    ll index1 = 0;
    ll index2 = 0;
    while(1){
      if(index1+index2==n)break;
      v1.pb(vp[0][index1].fi);
      v2.pb(vp[0][index1].se);
      index1++;
      if(index1+index2==n)break;
      v1.pb(vp[1][index2].fi);
      v2.pb(vp[1][index2].se);
      index2++;
    }
    vector<ll> v3=v1;
    sort(all(v3));
    if(v3!=v1)continue;
    ll d = f(v2);
    mn = min(mn,d);
  }while(next_permutation(all(vv)));
  if(mn==1000000000){
    cout << -1 << endl;
  }
  else{
    cout << mn << endl;
  }
  return 0;
}

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

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

	int co = 0;

	for(int i=0;i<3;++i)
	{
		if(s[i] == t[i])	++co;
	}

	cout<<co<<"\n";

	return 0;
}

Measured memory_bytes: 256
#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 rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
    boost;
    ll n,i,j,x,t;
    map<ll,ll>mp;
    ll a,b,c;
    cin>>a>>b;
    mp[a]++;
    mp[b]++;
    if(mp[1]==0) cout<<1;
    if(mp[2]==0) cout<<2;
    if(mp[3]==0) cout<<3;
}

Measured memory_bytes: 256