akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        Strategy strategy = new MyStrategy();
        strategy.solve(out, sc);
        out.flush();
    }
}

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        int N = sc.nextInt();
        int X = (int)Math.ceil(N / 1.08);
        if (Math.floor(X * 1.08) == N) {
            out.println(X);
        } else {
            out.println(":(");
        }
    }
}

interface Strategy {
    void solve(PrintWriter out, FastScanner sc);
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

int main(){
  long long n,k;
  cin >> n >> k;
  vector<long long> a(n);
  for(long long i=0;i<n;i++){
    cin >> a[i];
  }
  vector<long long> ans;
  std::map<long long,long long> s;
  //s[2] = 1;
  //cout << s[2];
  long long x=0;
  long long y=-1;
  long long z=0;
  for(long long i=0;i<n;i++){
    if(y!=-1) break;
    ans.push_back(x);
    s[x] = i+2;
    //cout << x << endl;
    x=a[x]-1;
    if(s[x]>0){
      y=s[x]-2;
      z=i;
      break;
    }
  }
  if(k<y){
    cout << ans[k]+1 << endl;
    return 0;
  }
  k-=y;
  k=k%(z-y+1);
  //cout << s[10000] << endl;
  cout << ans[y+k]+1 << endl;
}


Measured memory_bytes: 18532
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf 1e16
#define MOD 1e9+7
#define gcd __gcd //最大公約数,gcd(x,y)
int lcm(int a, int b){return a/gcd(a, b)*b;} //(int)最小公倍数,lcm(x,y)
ll llcm(ll a, ll b){return a/gcd(a, b)*b;}//(ll)最小公倍数,lcm(x,y)


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

    if((a==0)||(b==0)||((a<0)&&(b>0))){
        cout << "Zero" << endl;
    }else if(a<0){
        if(abs(b-a)%2 == 0){
            cout << "Negative" << endl;
        }else{
            cout << "Positive" << endl;
        }
    }else{
        cout << "Positive" << endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	scanf("%lld",&n);
	ll s=1;
	rep(i,1,n+1)s=s*i%1000000007;
	printf("%lld",s);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

map < string, int > mm;
int main() {
	fastio;
	int n; cin >> n;
	for(int i = 0; i < n; ++i) {
		string s; cin >> s;
		mm[s]++;
	}
	cout << mm.size() << endl;
	return 0;
}

Measured memory_bytes: 19164
#include<cmath>
#include<cstdlib>
#include<string>
#include<sstream>
#include<vector>
#include<iostream>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int N;
    long long a;
    vector<long long> A;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a;
        A.push_back(a);
    }

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

    long long n = A[N-1];
    long long ans;
    double half = (double)n / 2;
    double min = 1 << 30;
    for(int i=0; i<N-1; i++){
        if(abs(A[i] - half) < min){
            ans = A[i];
            min = abs(A[i] - half);
        }
    }
    cout << n << " " << ans << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define pb push_back
#define mp make_pair
#define PI 3.14159265359
//#define gc() getchar_unlocked();
using namespace std;
clock_t start_time,end_time;

inline float ellapse(){ return (clock()-start_time)*1.0/CLOCKS_PER_SEC; }
//inline int read_int() {register char c = gc();while(c<'0' || c>'9') c = gc();int ret = 0; while(c>='0' && c<='9') {ret = 10 * ret + c - 48; c = gc();}return ret;}
long long int gcd( long long int a , long long int b )
{
    return b == 0 ? a : gcd( b , a%b );
}

long long power( long long a , long long b )
{
    long long ret = 1 ;
    while( b ) {
        if( b%2 == 1 ) ret = ( ret * a ) % mod  ;
        a = (a * a) % mod ;
        b /= 2 ;
    }
    return ret ;
}


#define N 100010
int arr[ N ] ;

int main()
{

    int n , ans = 0 ;
    cin >> n ;

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

    for( int i = 0 ; i < n ; i++ ) {
      if( arr[ i ] == i + 1 ) {
        ans++ ;
        i++ ;
      }
    }
    cout << ans ;
    return 0 ;
}


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

using namespace std;
#define MAX 100010

typedef long long ll;
typedef pair< int , int > ii;

ll arr[ MAX ];


int main()
{
    int n ;
    cin >> n;
    for( int i = 0; i < n ; ++i )
	{
        cin >> arr[ i ];
	}
	ll tot = 0;
	for( int i = 0 ; i < n-1; ++i )
    {
        if( arr[ i ] & 1  && arr[ i+1 ] > 0  )
            arr[ i ]++ , arr[ i +1 ]--;

    }
    for( int i = 0; i < n ; ++i)
        tot += arr[ i ]>>1;
    cout << tot << "\n";
	return 0;
}


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 1e5 + 41;

int n;
int l[MAX];
int r[MAX];
multiset<pii> a, b;
ll ans;

void go(int s) {
	ll sum = 0;
	int x = 0;
	while (1) {
		if (!s) {
			if (!sz(a)) break;
			pii z = (*a.rbegin());
			a.erase(a.find(z));
			if (x - z.first >= 0) break;
			sum += z.first - x;
			x = z.first;
		}	else {
			if (!sz(b)) break;
			pii z = (*b.begin());
			b.erase(b.find(z));
			if (x - z.first <= 0) break;
			sum += x - z.first;		
			x = z.first;
		}
		s = 1 - s;
	}		
	sum += abs(x);
	ans = max(ans, sum);
}

void solve() {
	fi(1, n) {
		a.insert(mp(l[i], r[i]));
		b.insert(mp(r[i], l[i]));
	}	
	go(0);
	a.clear();
	b.clear();
	fi(1, n) {
		a.insert(mp(l[i], r[i]));
		b.insert(mp(r[i], l[i]));
	}	
	go(1);
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	fi(1, n) {
		scanf("%d %d", &l[i], &r[i]);
	}  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 12416
import os, sys, re, math

N = int(input())
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]

total = 0
for i in range(N, 0, -1):
    for j in [0, 1]:
        if A[i - j] and B[i - 1]:
            count = min(A[i - j], B[i - 1])
            A[i - j] -= count
            B[i - 1] -= count
            total += count

print(total)


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

using namespace std;

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007

int main(){
  int n;
  string s;
  cin >> n >> s;
  lli ans = 0;
  rep1(i,n-1){
          if(s[i]!=s[i-1])ans++;
  }
  cout << ans+1;
}

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

int main(void) {
	const char *SEP = " ";
	int N;
	char input_str[512];
	char *num_str;
	char arr[100];
	int x, y, z, n, max_num;
	int cnt;

	fgets(input_str, sizeof(input_str), stdin);
	N = atoi(input_str);

	for ( n = 1; n <= N; n++ ) {
		cnt = 0;
		for ( x = 1; x <= n; x++ ) {
			int xx = x*x;
			if ( n <= xx) break;
			for ( y = 1; y <= n; y++ ) {
				int xx_yy_xy = xx + y*y + x*y;
				if ( n <= xx_yy_xy ) break;
				for ( z = 1; z <= n; z++ ) {
					int xx_yy_zz_xy_yz_zx = xx_yy_xy + z*z + y*z + z*x;
					if ( n == xx_yy_zz_xy_yz_zx ) {
						cnt++;
					}
					else if ( n < xx_yy_zz_xy_yz_zx ) {
						break;
					}
				}
			}
		}
		printf("%d\n", cnt);
	}

	return 0;
}


Measured memory_bytes: 1668
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
 
using std::cin;
using std::cout;
using std::endl;
using std::cerr;
 
using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;
 
using std::min;
using std::max;
using std::sort;
using std::abs;
 
typedef long long int ll;
const int MOD = 1e9 + 7;
 
int main() {
    int n, a;
    cin >> n >> a;
 
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
 
    vector<vector<vector<ll>>> dp(
        n + 1, vector<vector<ll>>(n + 1, vector<ll>(2500 + 1)));
 
    for(int i = 0; i <= n; i++){
        dp[i][0][0] = 1;
    }
 
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= 2500; k++) {
                dp[i][j][k] = dp[i - 1][j][k];
                if (k - x[i - 1] >= 0) {
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i - 1]];
                }
            }
        }
    }
 
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += dp[n][i][i * a];
    }
    cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 52224
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
       
        for(int i = a; i <= b; i++) {
          String value = "" + i;
          StringBuilder builder = new StringBuilder();
          builder.append(value);
          builder.reverse();
          if (value.equals(builder.toString())) {
            ans++;
          }
        } 
    
		// 出力
		System.out.println(ans);
	}
}


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

double cal_Pow(int side){
    double cal;
    cal = pow(side,2);
    return cal;
}

int main(int argc, const char * argv[]){
    int i;
    int data_set;
    int side_a,side_b,side_c;
    scanf("%d",&data_set);
    if(data_set > 1000)
        exit(0);
    
    for(i = 0; i < data_set; i++){
        scanf("%d %d %d",&side_a,&side_b,&side_c);
        if((1 > side_a && side_a > 1000) && (1 > side_b && side_b > 1000) && (1 > side_c && side_c > 1000)){
            exit(0);
        }
        
        if((cal_Pow(side_a) + cal_Pow(side_b) == cal_Pow(side_c)) ||
           (cal_Pow(side_a) + cal_Pow(side_c) == cal_Pow(side_b)) ||
           (cal_Pow(side_b) + cal_Pow(side_c) == cal_Pow(side_a))){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
           
//        if(side_a != side_b){
//            if(side_a != side_c){
//                if(side_b != side_c){
//                    printf("NO");
//                }
//            }
//        }
//        if(side_a == side_b){
//            if(side_a != side_c){
//                printf("YES");
//            }else{
//                printf("NO");
//            }
//        }
//        if(side_a == side_c){
//            if(side_a != side_b){
//                printf("YES");
//            }else{
//                printf("NO");
//            }
//        }
//        if(side_b == side_c){
//            if(side_b != side_a){
//                printf("YES");
//            }else{
//                printf("NO");
//            }
//        }
    }
    return 0;
}

Measured memory_bytes: 580
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
  int X;
  cin >> X;
  if(X == 7 || X == 5 || X == 3){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  int counter=0;
  cin>>N;
  for(int i=1;i<=N;i++){
    if(i/10==0)counter++;
    else if(i/100==0);
    else if(i/1000==0) counter++;
    else if(i/10000==0) ;
    else if(i/100000==0) counter++;
  }
  cout<<counter<<endl;
}


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

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

    vector<int> p(n);

    for(int i=0;i<n;i++) {
        cin >> p.at(i);
    }

    int MAX, MIN, cnt = 0;
    for(int i=1;i<n-1;i++) {
        MAX = max(p.at(i-1), p.at(i));
        MAX = max(p.at(i+1), MAX);
        MIN = min(p.at(i-1), p.at(i));
        MIN = min(p.at(i+1), MIN);
        if(MAX!=p.at(i)&&MIN!=p.at(i)) cnt++;
    }

    cout << cnt << endl;

    return (0);
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int m;
  cin >> m;
  ll digsum = 0;
  ll dig = 0;
  for(int i = 0; i < m; i++) {
    ll c, d;
    cin >> d >> c;
    digsum += d * c;
    dig += c;
  }
  ll ans = ((digsum - 1) / 9 + (dig - 1));
  cout << ans << endl;
  return 0;
}


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

lli flag[100010]={0};
lli dp[100010] = {0};

int main(){

	lli n,m;
	cin>>n>>m;
	map<lli,map<lli,lli>> d;
	map<lli,vector<lli>> next;
	set<lli> s;

	REP(i,m){
		lli l,r,tmpd;
		cin>>l>>r>>tmpd;
		d[l][r] = tmpd;
		d[r][l] = -tmpd;
		next[l].push_back(r);
		next[r].push_back(l);
		s.insert(l);
		s.insert(r);
	}

	/*幅優先探索を行う*/
	queue<lli> q;
	if(DEBUG)cout<<"unko"<<endl;
	while(s.size() || q.size()){
		if(DEBUG)cout<<"s.size="<<s.size()<<endl;
		if(q.empty()){
			if(DEBUG)cout<<"q.empty~"<<endl;
			for(auto e:s){
				if(DEBUG)cout<<"s,itr,e="<<e<<endl;
				if(flag[e] == 0){
					q.push(e);
					s.erase(e);
					flag[e] = 1;
					dp[e]   = 0;
					break;
				}
			}
		}
	
		lli top = q.front();
		if(DEBUG)cout<<"top="<<top<<endl;
		q.pop();

		for(auto e:next[top]){
			if(DEBUG)cout<<"e="<<e<<endl;
			if(flag[e]){/*すでに割り当て済のとき*/
				lli real = dp[e] - dp[top];
				if(DEBUG)cout<<"top="<<top<<"dp[top]="<<dp[top]<<"e="<<e<<"dp[e]="<<dp[e]<<endl;
				if(d[top][e]!=real){
					cout<<"No"<<endl;
					return 0;
				}
			}
			else{
				q.push(e);
				s.erase(e);
				flag[e] = 1;
				dp[e] = dp[top] + d[top][e];
				if(DEBUG)cout<<"koushin,e="<<e<<" dp[e]="<<dp[e]<<endl;
			}
		}
	}
	cout<<"Yes"<<endl ;
	return 0;
}
 

Measured memory_bytes: 55680
N = int(input())
A = input()
ans = 0
R = 0
G = 0
B = 0
for i in A:
  if i == 'R':
    R += 1
  elif i == 'G':
    G += 1
  elif i == 'B':
    B += 1
ans = R*G*B
for i in range(0,N-2):
  for j in range(i+1,N-1):
    k = 2*j -i
    if k < N:
      if A[i] != A[j] and A[j] != A[k] and A[k] != A[i]:
        ans -= 1
print(ans)

Measured memory_bytes: 9152
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    int a,b;cin>>a>>b;
    if((a*b)%2 == 0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

using namespace std;

int calc(int num) {
  if (num % 100 != 0) {
    return 0;
  }
  return calc(num / 100) + 1;
}

int main()
{
    int A, B;
    cin >> A >> B;

    if (A <= 8 && B <= 8) {
      cout << "Yay!";
    } else {
      cout << ":(";
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
string = input()
c1=0
c2=0

for i, s in enumerate(string):
    if i%2==0:
        if(s=='0'): c1+=1
        if(s=='1'): c2+=1        
    else :
        if(s=='0'): c2+=1
        if(s=='1'): c1+=1        

print(min(c1,c2))



Measured memory_bytes: 3188
def dicing(lis, inst):
    if inst == 'N':
        ans_lis = [lis[1],lis[5],lis[2],lis[3],lis[0],lis[4]]
    if inst == 'W':
        ans_lis = [lis[2],lis[1],lis[5],lis[0],lis[4],lis[3]]
    if inst == 'S':
        ans_lis = [lis[4],lis[0],lis[2],lis[3],lis[5],lis[1]]
    if inst == 'E':
        ans_lis = [lis[3],lis[1],lis[0],lis[5],lis[4],lis[2]]
    
    return(ans_lis)

def turn_right(lis):
    inst = list('ENW')
    for i in range(len(inst)):
        lis = dicing(lis, inst[i])
    return(lis)

def find_above(lis, num1, num2):
    inst1 = list('NNNEWW')
    for i in range(len(inst1)):
        if lis[0] == num1 and lis[5] == num2:
            break
        
        lis = dicing(lis, inst1[i])
        if lis[0] == num1 and lis[5] == num2:
            break
    return(lis)

def find_samedice(dice1,dice2):
    YN = 'No'
    lis = find_above(dice1, dice2[0], dice2[5])
    for i in range(4):
        lis = turn_right(lis)
        if lis == dice2:
            YN = 'Yes'
            break
    return(YN)

N = int(input())
dices = []
for i in range(N):
    dices.append(list(map(int, input().split())))

ans = 'Yes'
for i in range(N):
    for j in range(N):
        if i < j:
            if find_samedice(dices[i], dices[j]) == 'Yes':
                ans = 'No'

print(ans)


Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    vector<int> n(3);
    cin >> n[0] >> n[1] >> n[2];
    
    std::sort(n.begin(),n.end());//昇順ソート
    cout << n[0]+n[1]+n[2]*10 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

template<class T>
bool chmin(T &a, T b)
{
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

long long dp[31];

int main()
{
    for(int i = 0; i < 31; i++){
        dp[i] = 0;
    }
    
    while(true){
        dp[0] = 1;
        dp[1] = 1;
        dp[2] = 2;
        int tmp;
        cin >> tmp;
        if(tmp == 0) break;
        for(int i = 3; i <= tmp; i++){
            dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
        }
        cout << (dp[tmp]-1)/10/365+1 << endl;
        for(int i = 0; i < 31; i++){
            dp[i] = 0;
        }
    }
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include <iostream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;
		
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
		
long long modInverse(long long a, long long m) { 
    if(__gcd(a, m) != 1){
		throw "modular inverse does not exist.";
	}
	long long m0 = m;
    long long y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1) {  
        long long q = a / m; 
        long long t = m;  
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }  
    if (x < 0) 
       x += m0; 
    return x; 
} 
 
long long modExp(long long a, long long b, long long p) {
	long long res = 1;
	long long mult = a;
	while (b > 0) {
		if (b % 2 != 0) {
			res = (res * mult) % p;
		}
		mult = (mult * mult) % p;
		b >>= 1;
	}
	return res;
}
 
vector<int> sieveOfEratosthenes(int n) {
	vector<int> primes;
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int p = 2; p * p <= n; p++) {
		if (prime[p] == true) {
			for (int i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (int p = 2; p <= n; p++)
		if (prime[p])
			primes.push_back(p);
	return primes;
}
 
struct edge{
	int a, b, cost;
};

void solve() {
	int n, m, p;
	cin >> n >> m >> p;
	vector<edge> e(m);
	vector<int> d(n, INT_MAX);
	d[0] = 0;
	for(int i = 0; i < m; i++){
		cin >> e[i].a >> e[i].b >> e[i].cost;
		e[i].a--;
		e[i].b--;
		e[i].cost = p - e[i].cost;
	}
	bool ch = false;
	for(int i = 0; i < n; i++){
		ch = false;
		for(int j = 0; j < m; j++){
			if(d[e[j].a] < INT_MAX){
				if(d[e[j].b] > d[e[j].a] + e[j].cost){
					d[e[j].b] = d[e[j].a] + e[j].cost;
					ch = true;
				}
			}
		}
		if(!ch) break;
	}
	bool neg = false;
	if(ch){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(d[e[j].a] < INT_MAX){
					if(d[e[j].b] > d[e[j].a] + e[j].cost){
						d[e[j].b] = INT_MIN + 2*1e5;
						if(e[j].b == n-1) neg = true;
					}
				}
			}
		}
	}
	
	if(neg || d[n-1] == INT_MAX) cout << -1;
	else cout << (d[n-1] < 0 ? -d[n-1] : 0);
	cout << "\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
struct Edge{
	long long to,cost,dis;//used in state is cur_v,cur_money,distance with node 1
};
vector<Edge> g[55];
long long c[55],d[55],dp[55][2550],maxv=2500;
struct cmp{
	bool operator()(const Edge a,const Edge b)const{
		return a.dis>b.dis;
	}
};
priority_queue<Edge,vector<Edge>,cmp> pq;
int main(){
	long long i,j,n,m,s,u,v,a,b;
	scanf("%lld%lld%lld",&n,&m,&s);
	for(i=0;i<m;i++){
		scanf("%lld%lld%lld%lld",&u,&v,&a,&b);
		g[u].emplace_back((Edge){v,a,b});
		g[v].emplace_back((Edge){u,a,b});
	}
	for(i=1;i<=n;i++)	
		scanf("%lld%lld",&c[i],&d[i]);
	for(i=0;i<55;i++)
		for(j=0;j<2550;j++)
			dp[i][j]=100000000000000000;
	s=min(s,maxv);
	pq.push({1,s,0});
	dp[1][s]=0;
	while(pq.size()){
		auto x=pq.top();
		pq.pop();
		if(dp[x.to][x.cost]<x.dis)//notice
			continue;
		if(dp[x.to][min(x.cost+c[x.to],maxv)]>x.dis+d[x.to]){
			dp[x.to][min(x.cost+c[x.to],maxv)]=x.dis+d[x.to];
			pq.push({x.to,min(x.cost+c[x.to],maxv),dp[x.to][min(x.cost+c[x.to],maxv)]});
		}
		for(auto y:g[x.to]){
			if(x.cost<y.cost)
				continue;
			if(dp[y.to][x.cost-y.cost]>x.dis+y.dis){
				dp[y.to][x.cost-y.cost]=x.dis+y.dis;
				pq.push({y.to,x.cost-y.cost,dp[y.to][x.cost-y.cost]});
			}
		}
	}
	for(i=2;i<=n;i++)
		printf("%lld\n",*min_element(dp[i],dp[i]+maxv));
}

Measured memory_bytes: 6996
/* ファイル名：ITP1_5_B.c	*/
/* 内容：たてH cm よこ W cm の枠を描く		*/
/* 		 枠の端は'#'で、枠の中は'.'で描く	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:たてH cm よこ W cm の枠を描く	*/
int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	int H;	/* たて	*/
	int W;	/* よこ	*/
	
	/*処理*/
	int i;	/* ループ用変数1	*/
	int j;	/* ループ用変数2	*/
	
	/* 無限ループ	*/
	while(1){
		scanf("%d %d",&H,&W);	/* たてとよこを取得	*/
		
		/* たてとよこに0が入力された場合	*/
		if((H == 0) 
		&& (W == 0)){
			break;	/* 処理を終了する*/
		}
		/* たてとよこに0以外が入力された場合 */
		else{
			/* たての長さだけループ	*/
			for(i = 0; i < H; i++){
				/* 枠の上端か下端を出力するとき	*/
				if((i == 0)
				|| (i == (H - 1))){
					/* よこの長さだけループ	*/
					for(j = 0; j < W; j++){
						printf("#");	/* '#' を出力		*/
					}
				}
				/* 枠の上端か下端以外を出力するとき	*/
				else{
					/* よこの長さだけループ	*/
					for(j = 0; j < W; j++){
						/* 枠の右端か左端を出力するとき*/
						if((j == 0)
						|| (j == (W - 1))){
							printf("#");	/* '#' を出力		*/
						}
						/* 枠の中を出力するとき*/
						else{
							printf(".");	/* '.' を出力		*/
						}
					}
				}
				
				printf("\n");/* 行の最後で改行を出力	*/
			}
			
			printf("\n");/* 次のデータセットの出力の為改行	*/
		}
	}
	return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>

int main()
{
    int A, B;
    scanf("%d", &A);
    scanf("%d", &B);
    
    if ((A == 1 && B == 2) || (A == 2 && B == 1)) {
        printf("3");
    }
    if ((A == 1 && B == 3) || (A == 3 && B == 1)) {
        printf("2");
    }
    if ((A == 2 && B == 3) || (A == 3 && B == 2)){
        printf("1");
    }

    return 0;

}

Measured memory_bytes: 1644
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include<array>

int main() {
	::std::array<usize, 4> cnt = {}, ans = { 1,1,2,2 };
	for (const auto i : rep<>(0, 3)) {
		usize a, b;
		::std::cin >> a >> b;
		--a;
		--b;
		++cnt[a];
		++cnt[b];
	}
	::std::sort(cnt.begin(), cnt.end());
	::std::cout << (cnt == ans ? "YES" : "NO") << ::std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

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


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

const int M=1000000007;
int n,c[55][55],f[55][105];
int main(){
	scanf("%d",&n);
	for(int i=0;i<=n;i++){
		c[i][0]=c[i][i]=1;
		for(int j=1;j<i;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%M;
	}
	f[1][0]=f[1][1]=1;
	for(int i=1;i<n;i++)for(int j=0;j<=i*2;j++)if(f[i][j]){
		int p=j-i;
		for(int k=0;k+i<=n;k++)for(int l=0;k+l+i<=n;l++){
			if((k+l+p)%2)continue;
			if(p<-(k+l)||p>k+l)continue;
			if(k+l==0)continue;
			f[i+k+l][(p+k-l)/2+(i+k+l)]=(f[i+k+l][(p+k-l)/2+(i+k+l)]+f[i][j]*1ll*c[i+k][k]%M*c[i+k+l][l])%M;
		}
	}
	printf("%d\n",f[n][n]);
	return 0;
}

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


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> stu(N, vector<int>(2));
    vector<vector<int>> cp(M, vector<int>(2));
    rep(i, N)cin >> stu[i][0] >> stu[i][1];
    rep(i, M)cin >> cp[i][0] >> cp[i][1];
    rep(i, N){
        int minDist = 1001001001;
        int ans = 0;
        rep(j, M){
            int dist = abs(stu[i][0] - cp[j][0]) + abs(stu[i][1] - cp[j][1]);
            if(dist < minDist){
                minDist = dist;
                ans = j;
            }
        }
        cout << ans + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
using namespace std;

struct Info
{
    int num;
    int p;
    int y;
    int order;

    Info(int input_num, int input_p, int input_y, int input_order) {
        num = input_num;
        p = input_p;
        y = input_y;
        order = input_order;
    }

};

bool cmp_year(const Info &a, const Info &b) {
    return a.y < b.y;
}

bool cmp_num(const Info &a, const Info &b) {
    return a.num < b.num;
}

// void viewer(const Info &a) {
//     cout << "num: " << a.num << ", p: " << a.p << ", y: " << a.y << ", order: " << a.order << endl;
// }


string make_code(int x) {
    ostringstream sout;
    sout << setfill('0') << right << setw(6) << to_string(x);
    string s = sout.str();
    return s;
}


int main() {

    int N, M;
    cin >> N >> M;

    vector<Info> info;
    int count[100010] = {0};
    int P, Y;
    for (int i=0; i<M; i++) {
        cin >> P >> Y;
        info.push_back(Info(i, P, Y, -1));
    }

    // for (int i=0; i<M; i++) {
    //     viewer(info[i]);
    // }
    // cout << "-----------------------------------------" << endl;

    sort(info.begin(), info.end(), cmp_year);

    // for (int i=0; i<M; i++) {
    //     viewer(info[i]);
    // }
    // cout << "-----------------------------------------" << endl;

    string ans[100010];
    for (int i=0; i<M; i++) {
        count[info[i].p]++;
        info[i].order = count[info[i].p];
    }

    sort(info.begin(), info.end(), cmp_num);

    // for (int i=0; i<M; i++) {
    //     viewer(info[i]);
    // }
    // cout << "-----------------------------------------" << endl;

    for (int i=0; i<M; i++) {
        cout << make_code(info[i].p) << make_code(info[i].order) << endl;
    }

    return 0;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
    
}

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

using ll = long long;
vector<ll> v;
int s[200005];
ll mn[200005], mx[200005];
ll mn2[200005], mx2[200005];

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i ++) cin >> s[i];
	ll add = 0;
	ll sum = 0;
	for(int i = 0; i < n; i ++){
		add += s[i];
		sum += s[i];
		v.push_back(sum + add);
		int t = lower_bound(v.begin(), v.end(), add) - v.begin();
		if(t == 0){
			
		}
		else if(t == v.size()){
			t --;
		}
		else {
			if(abs(v[t - 1] - add) < abs(v[t] - add)) t --;
		}
		mn[i] = (sum + abs(v[t] - add)) / 2, mx[i] = (sum - abs(v[t] - add)) / 2;
		if(mn[i] > mx[i]) swap(mn[i], mx[i]);
	}
	v.clear();
	add = 0; sum = 0;
	ll ans = 1e18;
	for(int i = n - 1; i >= 0; i --){
		add += s[i];
		sum += s[i];
		v.push_back(sum + add);
		int t = lower_bound(v.begin(), v.end(), add) - v.begin();
		if(t == 0){
			
		}
		else if(t == v.size()){
			t --;
		}
		else {
			if(abs(v[t - 1] - add) < abs(v[t] - add)) t --;
		}
		mn2[i] = (sum + abs(v[t] - add)) / 2, mx2[i] = (sum - abs(v[t] - add)) / 2;
		if(mn2[i] > mx2[i]) swap(mn2[i], mx2[i]);
		ll rlt_max = max(mx2[i], mx[i - 1]);
		ll rlt_min = min(mn2[i], mn[i - 1]);
		ans = min(ans, rlt_max - rlt_min); 
	}
	cout << ans << '\n';
	
}


Measured memory_bytes: 8944
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;

int main(){
    string s;cin >> s;
    vector<int> a(3);
    for(auto &i:s){
        if(i=='a'){
            a[0]++;
        }else if(i=='b'){
            a[1]++;
        }else if(i=='c'){
            a[2]++;
        }
    }
    sort(a.begin(),a.end());
    cout << (a[2]-a[0]<=1?"YES":"NO") << endl;
}

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

using namespace std;

pair<int,vector<int>> dp[10001];

int main(){
   int N,M;
   cin >> N >> M;
   int num[] = {2,5,5,4,5,6,3,7,6};
   bool can_use[9];
   memset(can_use, false,sizeof(can_use));
   for(int i=0;i<M;i++){
      int n;
      cin >>n;
      can_use[n-1]=true;
   }
   for(int i=0;i<=N; i++){
      dp[i].first = 0;
      dp[i].second.clear();
   }
   dp[0].first=0;
   dp[0].second = vector<int>(9,0);
   for(int i=0;i<=N;i++){
      if(dp[i].second.size()!=0){
         for(int j=0;j<9; j++){
            if(can_use[j]){
               vector<int> v = dp[i].second;
               v[8-j]++;
               dp[i+num[j]]=max(dp[i+num[j]], make_pair(dp[i].first+1, v));
            }
         }
      }
   }
   for(int i=0; i<9; i++){
      for(int j=0;j<dp[N].second[i];j++){
         cout << 9-i ;
      }
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main{
  static String[] zero = {"00000", "0000", "000", "00", "0"};
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    
    int[][] val = new int[M][3];
    for(int i = 0; i < M; i++){
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      val[i][0] = a;
      val[i][1] = b;
      val[i][2] = i;
    }
    Arrays.sort(val, (a, b) -> Integer.compare(a[1], b[1]));
    
    String[] ans = new String[M];
    int[] count = new int[N+1];
    for(int i = 0; i < M; i++){
      StringBuilder sb = new StringBuilder();
      int a = val[i][0];
      count[a]++;
      
      if(a < 10){
        sb.append(zero[0]);
        sb.append(a);
      }else if(a < 100){
        sb.append(zero[1]);
        sb.append(a);
      }else if(a < 1000){
        sb.append(zero[2]);
        sb.append(a);
      }else if(a < 10000){
        sb.append(zero[3]);
        sb.append(a);
      }else if(a < 100000){
        sb.append(zero[4]);
        sb.append(a);
      }else{
        sb.append(a);
      }
      
      int b = count[a];
      if(b < 10){
        sb.append(zero[0]);
        sb.append(b);
      }else if(b < 100){
        sb.append(zero[1]);
        sb.append(b);
      }else if(b < 1000){
        sb.append(zero[2]);
        sb.append(b);
      }else if(b < 10000){
        sb.append(zero[3]);
        sb.append(b);
      }else if(b < 100000){
        sb.append(zero[4]);
        sb.append(b);
      }else{
        sb.append(b);
      }
      
      ans[val[i][2]] = (new String(sb));
    }
    
    for(int i = 0; i < M; i++){
     System.out.println(ans[i]); 
    }
  }
}

Measured memory_bytes: 86420
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  int N;
  cin>>N;
  for(double h=1;h<=3500;h++){
    for(double n=1;n<=3500;n++){
      double w=(N*h*n)/(4*h*n-N*n-N*h);
      if(1<=w&&w<=3500&&w == ll(w)){
	cout<<h<<" "<<n<<" "<<w<<endl;
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define mod (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


void solve();

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


void solve() {
    int n;
    cin >> n;
    map<pii, int> mp;
    rep3(i, 1, n + 1) {
        string s = to_string(i);
        mp[pii(s[0] - '0', s[sz(s) - 1] - '0')]++;
    }
    
    ll ans = 0;
    rep3(i, 1, 10) rep3(j, 1, 10) {
        ans += 1LL * mp[pii(i, j)] * mp[pii(j, i)];
    }
    cout << ans << endl;
}


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n,k;cin>>n>>k;
  vector<int> a(n+1);
  rep(i, n) {
    cin>>a[i+1];
  }
  dump(a);
  vi b = vi(a);
  vi c(n+1);
  rep(i, 1, n+1){
    b[i] += b[i-1];
    c[i] = (b[i]-i+2*k)%k;
  }
  dump(b);
  dump(c);

  map<int, int> d;
  rep(i, n+1){
    d[c[i]]++;
  }

  int ans = 0;
  map<int, int> cnt;

  cnt[0] += 1;
  rep(i, 1, n+1){
    if (i>=k) cnt[c[i-k]]--;

    ans += cnt[c[i]];
    dump(i, cnt, c[i], cnt[c[i]], ans);
    cnt[c[i]]++;
  }
  cout << ans << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 29952
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      String a = sc.next();
      String []b  = a.split(""); 
      if(b[a.length()-1].equals("s")){
      	System.out.println(a+"es");
      }else{
      	System.out.println(a+"s");
      }
    }
}

Measured memory_bytes: 38520
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ull num;
    cin>>num;

    if(num&1){
        cout<<0<<"\n";
        return 0;
    }

    ull c=0,m=5;
    while(m<=num){
        ull n = num/m;
        n/=2;
        c+=n;
        m*=5;
    }

    cout<<c<<"\n";
    return 0;
}


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

using namespace std;

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

    string a = "";
    for(int i=0;i<x.size();i++){
        a += x[i];
        if(a[a.size()-1] == 'T' && a[a.size()-2] == 'S'){
            a.pop_back();
            a.pop_back();
        }
    }
    cout << a.size();
}

Measured memory_bytes: 1336
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <string.h>
     
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
     
    const double EPS = 1e-8;
     
    int main()
    {
		string w;

		ll size,a[26]={};

		bool H=true;
		
		cin >> w;

		size=w.size();

		for(int i=0;i<26;i++){
			for(int j=0;j<size;j++){
				if(w[j]=='a'+i){
					a[i]++;
				}
			}
		}

		for(int i=0;i<26;i++){
			if(a[i]%2!=0){
				H=false;
				break;
			}
		}

		if(H==false){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}

		return 0;
    }

Measured memory_bytes: 256