akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int64 n, ret = 1LL << 60;
  cin >> n;
  for (int64 i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      int64 j = n / i;
      int64 cur = j - 1 + i - 1;
      ret = min(ret, cur);
    }
  }
  cout << ret << endl;
  return 0;
}


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

using namespace std;

int main(void)
{
	int N, K;

	cin >> N;

	cin >> K;

	int odd = N % 2;
	//cout << odd;
	if (K <=(N / 2 + odd))
		cout << "YES";

	else
		cout << "NO";


}

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

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

    queue <ll> q;
    for(int i=1; i<10; i++) q.push(i);

    ll ans = 0;
    while(!q.empty()){
        ll a = q.front();
        q.pop();
        n--;
        if(n==0){
            ans = a;
            break;
        }

        ll r = a%10;
        if(r==0){
            q.push(10*a);
            q.push(10*a+1);
        }
        else if(r==9){
            q.push(10*a+8);
            q.push(10*a+9);
        }
        else{
            q.push(10*a+r-1);
            q.push(10*a+r);
            q.push(10*a+r+1);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5240
package main

import (
        "fmt"
)

var divisor[201]map[int]bool

func makeDivisor() {

        for i := 0; i <= 200; i++ {
                divisor[i] = make(map[int]bool)
        }
        for v := 1; v <= 200; v++ {
                for m := 1; v * m <= 200; m++ {
                        divisor[v*m][v] = true
                }
        }
}

func gcd(a,b,c int) int {
        max := 1
        for av, _ := range divisor[a] {
                if divisor[b][av] && divisor[c][av] && av > max {
                        max = av
                }
        }
        return max
}

func main() {
        makeDivisor()

        var K int
        fmt.Scanf("%d", &K)
        var sum uint64
        for a := 1; a <= K; a++ {
                for b := 1; b <= K; b++ {
                        for c := 1; c <= K; c++ {
                                sum += uint64(gcd(a,b,c))
                        }
                }
        }
        fmt.Printf("%v\n", sum)
}

Measured memory_bytes: 1912
#include <cstdio>
#include <map>

int main()
{
  int n;
  scanf("%d", &n);
  std::map<int, int> mp;
  for (int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    mp[a]++;
  }
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    if (mp[a]-- <= 0)
    {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleTest
{
    static partial class Program
    {
        static int max = 200;
        static int[] _gcd;

        static int Idx(int a, int b)
        {
            if (a >= b)
            {
                return (a - 1) * max + (b - 1);
            }
            return (b - 1) * max + (a - 1);
        }

        static int Gcd(int l, int r)
        {
            if (r == 0)
            {
                return l;
            }

            var idx = Idx(l, r);
            if (_gcd[idx] != 0) return _gcd[idx];

            _gcd[idx] = Gcd(r, l % r);
            return _gcd[idx];
        }

        static int Gcd(int a, int b, int c)
        {
            var g = Gcd(a, b);
            return Gcd(g,c);
        }


        static void Main(string[] args)
        {

            var n = Int();
            long sum = 0;
            _gcd = new int[max * max];
            for (int i = 1; i <= n; ++i)
                for (int j = 1; j <= n; ++j)
                    for (int k = 1; k <= n; ++k)
                    {
                        int gcd = Gcd(i, j, k);
                        sum += gcd;
                    }
            Console.WriteLine(sum);

        }

    }
    static partial class Program
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }
        public static int[] Ints()
        {
            return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }
        public static long[] Longs()
        {
            return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        }
        public static int[][] MultiInts(int num)
        {
            var result = new int[num][];
            for(int i = 0; i < num; ++i)
            {
                result[i] = Ints();
            }
            return result;
        }
        public static T[] MultiItems<T>(int num, Func<string,T> parser)
        {
            var result = new T[num];
            for(int i =0; i < num; ++i)
            {
                result[i] = parser(Console.ReadLine());
            }
            return result;
        }
    }
}


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

int main() {
	long long int N;
	long long int a;
	long long int b;
	long long int ans;

	cin >> N >> a >> b;

	if (a > b) {
		ans = 0;
	}
	else if (N == 1) {
		if (a == b) {
			ans = 1;
		}
		else {
			ans = 0;
		}
	}
	else {
		ans = (b - a)*(N - 2) + 1;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]

B1 = [0,0,0]
B2 = [0,0,0]
B3 = [0,0,0]

n = input()
N = int(n)

for i in range(N):
  B = input()
  b = int(B)
  if b == A1[0]:
    B1[0] = 1
  elif b == A1[1]:
    B1[1] = 1
  elif b == A1[2]:
    B1[2] = 1
  elif b == A2[0]:
    B2[0] = 1
  elif b == A2[1]:
    B2[1] = 1
  elif b == A2[2]:
    B2[2] = 1
  elif b == A3[0]:
    B3[0] = 1
  elif b == A3[1]:
    B3[1] = 1
  elif b == A3[2]:
    B3[2] = 1

#print(B1)
#print(B2)
#print(B3)
    
ans="No"

if B1[0]==1:
  if B1[1]==1:
    if B1[2]==1:
      ans = "Yes"
if B2[0]==1:
  if B2[1]==1:
    if B2[2]==1:
      ans = "Yes"
if B3[0]==1:
  if B3[1]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[0]==1:
  if B2[0]==1:
    if B3[0]==1:
      ans = "Yes"
if B1[1]==1:
  if B2[1]==1:
    if B3[1]==1:
      ans = "Yes"
if B1[2]==1:
  if B2[2]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[0]==1:
  if B2[1]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[2]==1:
  if B2[1]==1:
    if B3[0]==1:
      ans = "Yes"

print(ans)


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <string>
using namespace std;

string s;

void solve()
{
	const int N = s.length();
	long long ans = 0;
	int wcnt = 0;
	for(int i=N-1; i>=0;--i){
		if(s[i]=='B') ans += wcnt;
		else wcnt++;
	}
	cout << ans << endl;
}

int main()
{
	cin >> s;
	solve();
	return 0;
}

Measured memory_bytes: 640
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
signed main()
{
    fasino
    ll n,q,tmp,k;
    cin>>n;
    vector<ll> A(n);
    input(A,n);
    cin>>q;
    map<ll,ll> mp;
    set<ll> st;
    ll finalsum = 0;
    for(auto i:A){
        finalsum+=i;
        mp[i]++;
    }
    for(int i=0;i<q;i++){
        cin>>tmp>>k;
        ll ko = mp[tmp];
        ll ok = mp[k];
        finalsum += ko*k;
        finalsum -= ko*tmp;
        mp[tmp]=0;
        mp[k]+=ko;
        cout<<finalsum<<'\n';
    }
    return 0;
}

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

bool sosuu(int a){
  bool flag2=true;
  for(int i = sqrt(a);i>1;i--){
    if(a%i==0){
      flag2=false; break;
    }
  }
  return flag2;
}

int main() {
  int x,a;
  cin >> x;
  a=x;
  bool flag=false;
  while(!flag){
    if(sosuu(a))break;
    a++;
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    int ans=0;
    for(int i=0;i<n-1;i++)cin>>a[i];
    b[0]=a[0];
    b[1]=a[0];
    for(int i=2;i<n;i++){
        if(a[i-1]<b[i-1]){
            b[i-1]=a[i-1];
            b[i]=a[i-1];
        }
        else {
            b[i]=a[i-1];
        }

    }
    for(auto x:b)ans+=x;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	long long pow[610] = {}; 
	long long mod = 998244353; 
	pow[0] = 1; 
	for(int i = 1; i < 605; i++) pow[i] = pow[i-1] * 2 % mod; 
	int N, M; cin >> N >> M; 
	bool A[310][310] = {}; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> A[i][j]; 
		}
	}
	int p = -1; 
	for(int j = 0; j < M; j++){
		for(int i = p + 1; i < N; i++){
			if(A[i][j]){
				swap(A[i], A[p + 1]); 
				p++; 
				for(int k = 0; k < N; k++){
					if(k == p) continue; 
					if(A[k][j]){
						for(int l = 0; l < M; l++) A[k][l] ^= A[p][l]; 
					}
				}
			}
		}
	}
	p++; 
	cout << (pow[p] + mod - 1) * pow[N + M - p - 1] % mod << "\n"; 
}

Measured memory_bytes: 384
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int Mult(int x,int y){long z=x*y-(long)((long double)x/MOD*y+1e-8)*MOD;return z;}
static inline void Radix(int A[],const int N)
{
  int temp[200001];
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,N)u[A[i]>>8*k&255]++;
    rep(i,255)u[i+1]+=u[i];
    rep(i,N){temp[--u[A[N-1-i]>>8*k&255]]=A[N-1-i];}k++;
    rep(i,N)v[temp[i]>>8*k&255]++;
    rep(i,255)v[i+1]+=v[i];
    rep(i,N)A[--v[temp[N-1-i]>>8*k&255]]=temp[N-1-i];
  }
}
int main()
{
  int N=IN(),K=IN(),m=0,p=0,z=0,accum=1,A[200000];long one=0,another=0;
  rep(i,N){A[i]=IN();if(A[i]>0)p++;else if(A[i]<0)m++;else z++;}
  Radix(A,N);
  if(K==N){if(z){return puts("0"),0;}else{rep(i,K){accum=Mult(accum,A[i]);}K=0;}}
  if(m+p<K)return puts("0"),0;
  if(!p&&K&1){if(z){return puts("0"),0;}else rep(i,K){accum=Mult(accum,A[N-1-i]);}K=0;}
  p+=z,m=p;
  if(K&1){K--;accum=Mult(accum,A[--p]);}
  while(K)
  {
    K-=2,one=1l*A[p-1]*A[p-2],another=1l*A[m]*A[m+1];
    if(p>1&&m<N-1&&one>another){accum=Mult(accum,one%MOD),p-=2,one=1l*A[p-1]*A[p-2];continue;}
    if(p>1&&m<N-1&&one<another){accum=Mult(accum,another%MOD),m+=2,another=1l*A[m]*A[m+1];continue;}
    if(p>1){accum=Mult(accum,one%MOD),p-=2,one=1l*A[p-1]*A[p-2];continue;}
    if(m<N-1){accum=Mult(accum,another%MOD),m+=2,another=1l*A[m]*A[m+1];continue;}
  }
  return printf("%d\n",accum<0?accum+MOD:accum),0;
}

Measured memory_bytes: 3160
#include<stdio.h>
#include<string.h>
int main ()
{
	char a,b,p[10]={0},q[10]={0};
  int n,m,i;
  scanf("%d%d",&n,&m);
  a='0'+n;
  b='0'+m;
 for(i=0;i<n;i++)
    q[i]=b;
 for(i=0;i<m;i++)
    p[i]=a;
 if(strcmp(p,q)>=0)
     printf("%s",q);
 else
	 printf("%s",p);
  return 0;
}

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

class Main{

    public static int digits(int x)
    {
        int n =0;

        while(x>0)
        {
            x=x/10;
            n++;
        }

        return n;
    }

    public static void main(String[] args)  throws IOException {
        // write your code here

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int t = Integer.parseInt(reader.readLine());

        //int dig = digits(t);

        int ct=0;

        for(int i=1;i<=t;i++)
        {
            int dig = digits(i);

            if(dig%2!=0)
            {
                ct++;
            }
        }

        System.out.println(ct);

    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define int long long
#define ss second
#define ff first
using namespace std;
const int M = 1000000007;

int mod(int x, int m = M){
    x %= m;
    return x < 0 ? x+m : x;
}


signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, k, x, ans = 0;
    cin>>n>>m>>k;

    vector<int> a(n+1,0), b(m+1,0);

    for(int i=1; i<=n; i++){
        cin>>x;
        a[i] = a[i-1] + x;
    }

    for(int i=1; i<=m; i++){
        cin>>x;
        b[i] = b[i-1] + x;
    }

    int j = m;
    for(int i=0; i<=n; i++){
        if(a[i] > k) break;
        
        while(m >= 0 && b[j] > k-a[i]) j--;

        ans = max(ans,i+j);
    }
    
    cout<<ans<<endl;

}

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

int main(void){
   int N;
   cin>>N;
   vector<long long> A(N);
   for(int i=0;i<N;i++){
      cin>>A[i];
   }
   vector<long long> sum(N+1,0);
   sum[0]=0;
   for(int i=0;i<N;i++){
      sum[i+1]=sum[i]+A[i];
   }
   long long ans=2500000000;
   for(int i=1;i<=N;i++){
      long long temp=0;
      temp=abs(sum[N]-2*sum[i]);
      ans=min(temp,ans);
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 6424
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

int F(ll A,ll B) {
  stringstream ss;
  ss << A << " " << B;
  string s,t;
  ss >> s >> t;
  return max(s.size(),t.size());
}

int main() {
  ll n;
  cin >> n;
  int mini = INT_MAX;
  for(ll i=1;i<=sqrt(n)+10LL;++i) {
    if( n % i == 0 ) {
      mini = min(mini,F(i,n/i));
    }
  }
  cout<< mini << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

int dp[3][100];


// int money(int kab){
// }

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> is_high(n);
  rep(i, n) cin >> v[i];
  dp[0][0] = 1000;
  dp[1][0] = 1000;
  dp[2][0] = 1000;
  // for (int i = 0; i < n; ++i) {
  //   int maxv = max({dp[0][i-1], dp[0][i-1], dp[2][i-1]});
  //   dp[0][i] = maxv;
  //   dp[1][i] =
  // }

  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      if(v[i] == v[j]) continue;
      if(v[i] > v[j]) is_high[i] = 1;
      else is_high[i] = -1;
      break;
    }
  }

  ll money = 1000;
  ll kabu = 0;
  for (int i = 0; i < n; ++i) {
    if(is_high[i] == -1){
      kabu += money / v[i];
      money %= v[i];
    }else if(is_high[i] == 1 || i == n-1){
      money += kabu * v[i];
      kabu = 0;
    }
  }

  cout << money << endl;

}


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

char s[200100];
int val[200100], n, f[200100], p[26][200100], cnt[26];
long long ans;

void Add(int x) {
	for(; x <= n; x += -x & x)
		val[x]++;
}

int Query(int x) {
	int ans = 0;
	for(; x; x -= -x & x)
		ans += val[x];
	return ans;
}

int main(void) {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) 
		p[s[i] - 'a'][++cnt[s[i] - 'a']] = i;
	int odd = 0;
	for(int i = 0; i < 26; i++)
		if(cnt[i] & 1) ++odd;
	if(odd > 1) return printf("-1") * 0;
	for(int i = 0; i < 26; i++)
		for(int j = 1; j <= cnt[i]; j++)
			f[p[i][j]] = p[i][cnt[i] - j + 1];
	for(int i = n; i >= 1; i--) {
		ans += n - i - Query(f[i]);
		Add(f[i]);
	}
	printf("%lld\n", ans / 2);
	return 0;
}

Measured memory_bytes: 20352
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=3005;
const int mod=1e9+7;
const int two=5e8+4;
int n,q,a[MN],X[MN],Y[MN];
int f[MN][MN];
inline ll qpow(ll a,ll b){
	reg ll res=1;
	while(b){
		if(b&1)res=res*a%mod;
		a=a*a%mod;b>>=1;
	}
	return res;
}
int main(){
	scanf("%d%d",&n,&q);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	for(reg int i=1;i<=q;i++)scanf("%d%d",X+i,Y+i);
	for(reg int i=1;i<=n;i++)
		for(reg int j=1;j<=n;j++)
			if(a[i]>a[j])f[i][j]=1;
	for(reg int i=1;i<=q;i++){
		f[X[i]][Y[i]]=f[Y[i]][X[i]]=1ll*(f[X[i]][Y[i]]+f[Y[i]][X[i]])*two%mod;
		for(reg int j=1;j<=n;j++){
			if(j==X[i]||j==Y[i])continue;
			f[X[i]][j]=f[Y[i]][j]=1ll*(f[X[i]][j]+f[Y[i]][j])*two%mod;
			f[j][X[i]]=f[j][Y[i]]=1ll*(f[j][X[i]]+f[j][Y[i]])*two%mod;
		}
	}
	reg ll Ans=0;
	for(reg int i=1;i<=n;i++)
		for(reg int j=i+1;j<=n;j++)
			Ans=(Ans+f[i][j])%mod;
	printf("%d\n",1ll*Ans*qpow(2,q)%mod);
	return 0;
}

Measured memory_bytes: 35584
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int a, b, c, d;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b>>c>>d;
    if(a!=c)
    cout<<1<<"\n";
    else
    cout<<0<<"\n";
}



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

using  namespace std;
const int maxn = 1e5 + 5;
int len[maxn],ord[maxn];
vector<int> gr[maxn];
int fin[maxn];
int dfs1(int node,int anc,int lev){
    if(anc != 0) fin[node]= anc;
    ord[node] = lev;
    len[node] = lev;
    for(auto it: gr[node]){
        if(it != anc) len[node] = max(len[node],dfs1(it,node,lev+1));
    }
    return len[node];
}
int main(){
    int n,beg,tar,x,y;
    scanf("%d%d%d",&n,&tar,&beg);
    for(int i= 1; i<= n-1;i ++){
        scanf("%d%d",&x,&y);
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    dfs1(beg,0,0);
    int lev = 0,node = tar,ma = 0;
    while(ord[node] > lev){
        ma = max(ma,len[node]);
        lev++;
        node = fin[node];
    }
    printf("%d",ma - 1);






}


Measured memory_bytes: 12032
#include <iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    long long n, m, ans;
    scanf("%lld%lld", &n, &m);
    ans = 0;
    if(m >= n * 2)
    {
        ans += n;
        m -= n * 2;
        ans += m / 4;
    }else
    {
        ans += m / 2;
    }
    printf("%lld\n", ans);
    return 0;
}


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

std::string s;
int main()
{
    std::cin >> s;
    auto size = s.size();
    if (size == 2)
        std::cout << s << std::endl;
    else
    {
        std::reverse(s.begin(), s.end());
        std::cout << s << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;

struct edge {
    int dir;
    int id;
};

vector<vector<edge>> graph;
vector<int> ans;

void dfs(int now, int before = -1, int bcolor = -1) {
    int color = 1;
    for (auto& to : graph[now]) {
        if (to.dir == before) continue;
        if (bcolor == color) color++;
        ans[to.id] = color;
        color++;
        dfs(to.dir, now, ans[to.id]);
    }
    
}

int main() {
    int n; cin >> n;
    graph.resize(n);
    ans.resize(n-1);
    for (int i = 0; i < n-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back((edge) {b, i});
        graph[b].push_back((edge) {a, i});
    }
    
    dfs(0);
    
    int mx = 0;
    for (int i = 0; i < n-1; i++)
    {
        mx = max(mx, ans[i]);
    }

    cout << mx << endl;

    for (int i = 0; i < n-1; i++)
    {
        cout << ans[i] << endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 8320
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<sstream>
#include<bitset>
using namespace std;
#define INF (1<<29)
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<int,P> PP;
struct edge{
  int t,c;
  edge(int t,int c) : t(t),c(c) {}
};
vector<edge> G[500];
int m,n,k,d;
int H[8];
int getid(string s){
  int id;
  if(s[0]=='H'){
    id = 0;
  } else if(s[0]=='C'){
    stringstream ss;
    ss << s.substr(1);
    ss >> id;
  } else if(s[0]=='L'){
    stringstream ss;
    ss << s.substr(1);
    ss >> id;
    id+=6;
  } else {
    id = 300;
  }
  return id;
}
int h[500][1<<6];
int solve(){
  priority_queue<PP,vector<PP>,greater<PP> > q;
  for(int i=0;i<500;i++)
    for(int j=0;j<(1<<6);j++)
      h[i][j]=INF;
  h[0][0]=0;
  q.push(PP(0,P(0,0)));
  while(!q.empty()){
    PP p = q.top(); q.pop();
    int id = p.S.F;
    int st = p.S.S;
    int c = p.F;
    //cout << id <<" "<< bitset<10>(st)<<" " << c << "\n";
    //sleep(1);
    for(int i=0;i<(int)G[id].size();i++){
      //  cout << G[id][i].t <<" "<< G[id][i].c*k << "\n";
      if( 1<=G[id][i].t && G[id][i].t<=6 ){
	int nst = (1<<(G[id][i].t-1)) | st;
	if( (1<<(G[id][i].t-1)) & st ) continue;
	if( G[id][i].c*k + c + H[G[id][i].t] < h[G[id][i].t][nst] ){
	  h[G[id][i].t][nst] = G[id][i].c*k + c + H[G[id][i].t]; 
	  q.push( PP(G[id][i].c*k + c + H[G[id][i].t],
		     P(G[id][i].t,nst) ) );
	}
      } else {
	if( G[id][i].c*k + c < h[G[id][i].t][st] ){
	  h[G[id][i].t][st] = G[id][i].c*k + c;
	  q.push( PP(G[id][i].c*k + c,
		     P(G[id][i].t, st) ) );
	}
      }
    }
  }
  int ret = INF;
  for(int i=0;i<(1<<6);i++)
    ret = min(ret,h[300][i]);
  return ret;
}
int main(){
  while(1){
    cin >> m >> n >> k >> d;
    if(!m && !n && !k && !d) break;
    for(int i=0;i<500;i++) G[i].clear();
    for(int i=1;i<=m;i++){
      cin >> H[i];
      H[i]*=-1;
    }
    for(int i=0;i<d;i++){
      string a,b;
      int c;
      cin >> a >> b >> c;
      int ida = getid(a);
      int idb = getid(b);
      //cout << ida << " " << idb <<" "<< endl;
      G[ida].push_back( edge(idb,c) );
      G[idb].push_back( edge(ida,c) );
    }
    cout << solve() << "\n";
  }
}

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

//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int a,b,c;
  str ans="No";
  cin >> a >> b >> c;
//  vi cd(n);
  if(a==b&&b==c) ans="Yes";
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long LL;
#define N 120000

LL n,sl,sr,ans,l[N],r[N],len[N];
priority_queue<LL> L;
priority_queue<LL,vector<LL>,greater<LL> > R;

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i){scanf("%lld%lld",l+i,r+i); len[i]=r[i]-l[i];}
	L.push(r[1]); R.push(r[1]);
	for (LL i=2;i<=n;++i){
		sl-=len[i-1]; sr+=len[i];
		LL lp=L.top()+sl,rp=R.top()+sr;
		if (r[i]>=lp&&r[i]<=rp){
			L.push(r[i]-sl); R.push(r[i]-sr);
		}
		if (r[i]>rp){
			ans+=r[i]-rp; R.pop(); L.push(rp-sl);
			R.push(r[i]-sr); R.push(r[i]-sr);
		}
		if (r[i]<lp){
			ans+=lp-r[i]; L.pop(); R.push(lp-sr);
			L.push(r[i]-sl); L.push(r[i]-sl);
		}
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i, m, n) for(int i=(m);i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
typedef pair<Pip, char> Pic;

typedef vector<int> Vi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};


int main()
{
  int n;

  while( cin >> n, n ) {
    priority_queue<Pic> q;

    Rep(i, n) {
      char c;
      int win = 0, los = 0;
      cin >> c;
      
      Rep(j, n-1) {
	int a;
	cin >> a;
	if( a == 0 ) win++;
	else if( a == 1 ) los++;
      }

      q.push( Pic(Pip(win, Pii(-los, -i)), c) );
    }

    while( !q.empty() ) {
      cout << q.top().sc << endl;
      q.pop();
    }

  }

}

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

vector<int>pes,color,ces,sz;
vector<ll>points;

void dfs(int u, int z){
	color[u]=z;
	sz[color[u]]++;
	points[color[u]]+=ces[u];
	int v = pes[u];
	if(color[v]==-1)dfs(v,z);
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;ll k;
	cin>>n>>k;
	pes=ces=sz=vector<int>(n+1);
	color.resize(n+1,-1);
	points.resize(n+1);

	for(int i=1;i<=n;i++){
		cin>>pes[i];
	}
	for(int i=1;i<=n;i++){
		cin>>ces[i];
	}
	int z = 0;
	for(int i=1;i<=n;i++){
		if(color[i]==-1){
			dfs(i,++z);
		}
	}
	ll ans=-1e10;
	for(int i =1;i<=n;i++){
		int u=i;
		ll tmp=0;
		for(int len=1;len<=sz[color[i]];len++){
			if(len>k)break;

			u=pes[u];
			tmp+=ces[u];
			ans=max(ans,tmp);
			ll foo=(k-len)/sz[color[i]];
			ans=max(ans,tmp+foo*points[color[i]]);
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
  string w; cin>>w;
  int n = w.size();
  VI s(26,0);
  rep(i,n){
    s[w[i]-'a']++;
  }
  rep(i,26){
    if(s[i]%2) return cout<<"No"<<endl,0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
s = raw_input()
def solve(s):
	n = len(s)
	states = [[0, 0]]
	while len(states) > 0:
		state, i = states.pop()
		if i > n:
			print "what"
			continue
		if i == n:
			return "YES"
		if state == 1:
			if n - i >= 2 and s[i: i+2] == "er":
				states.append([0, i+2])
		if state == 2:
			if n - i >= 1 and s[i:i+1] == "r":
				states.append([0, i+1])
		if n - i >= 5:
			cs = s[i: i + 5]
			if cs == "dream":
				states.append([1, i+5])
			elif cs == "erase":
				states.append([2, i+5])
	return "NO"
 
print solve(s)

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t, u;
    int A, B;
    cin >> s >> t >> A >> B >> u;
    if(u == s) cout << A - 1 << " " << B << endl;
    else cout << A << " " << B - 1 << endl;
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    lli g[n][n];
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        cin >> g[i][j];
      }
    }
    bool dummy[n][n];
    fill(&dummy[0][0], &dummy[n - 1][n - 1] + 1, false);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        for (int k = 0; k < n; ++k) {
          if (i == k || j == k) continue;
          dummy[i][j] = dummy[i][j] || (g[i][j] == g[i][k] + g[k][j]);
        }
      }
    }

    const lli inf = 1LL << 60;
    lli h[n][n];
    fill(&h[0][0], &h[n - 1][n - 1] + 1, inf);
    lli sum = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        unless (dummy[i][j]) {
          h[i][j] = g[i][j];
          sum += h[i][j];
        }
      }
    }

    bool f = true;
    for (int i = 0; i < n; ++i) {
      f = f && (g[i][i] == 0);
      for (int j = 0; j < n; ++j) {
        f = f && (g[i][j] == g[j][i]);
      }
    }
    for (int k = 0; k < n; ++k) {
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
          h[i][j] = min(h[i][j], h[i][k] + h[k][j]);
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        f = f && (g[i][j] == h[i][j]);
      }
    }
    if (!f) cout << -1 << endl;
    else cout << sum / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);



int main() {
  int k,a,b; cin >> k >> a >> b;
  int ans = 0;
  for (int i= a; i <= b; i++) {
    if (i%k == 0) ans++;
  }
  if (ans > 0) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lb long double
#define pb push_back
#define qwerty1 first
#define qwerty2 second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < int , int >

using namespace std;

const int N = 100005;
const int M = 1000000007;
const lb PI = acos(-1);

int n;
int a[N] , l[N] , r[N];

int main()
{
    ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);

    int i;

    cin >> n;

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

    l[1] = a[1];

    for(i = 2 ; i <= n ; i++)
        l[i] = __gcd(l[i - 1] , a[i]);

    r[n] = a[n];

    for(i = n - 1 ; i >= 1 ; i--)
        r[i] = __gcd(r[i + 1] , a[i]);

    int ans = max(r[2] , l[n - 1]);

    for(i = 2 ; i < n ; i++)
        ans = max(ans , __gcd(l[i - 1] , r[i + 1]));

    cout << ans;

    return 0;
}


Measured memory_bytes: 1408
while True:
    H, W = [int(x) for x in input().split(" ")]
    if H == W == 0:
        break
    for i in range(H):
        if (i + 1) % 2 == 1:
            print( "#." * (W // 2) + "#" * (W % 2))
        else:
            print(".#" * (W // 2) + "." * (W % 2))
    print("")

Measured memory_bytes: 7624
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int k;
    cin >> k;
    if(k % 2 == 1){
        cout << ((k+1)/2)*(k-(k+1)/2) << endl;
    } else {
        cout << (k/2)*(k/2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n==1||n==2||n==3||n==5||n==6||n==9||n==10||n==13||n==17)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 384
from fractions import gcd
a, b, c, d = [int(item) for item in input().split()]
c_div = b // c - (a-1) // c
d_div = b // d - (a-1) // d
lcm = c * d // gcd(c, d)
cd_div = b // lcm - (a-1) // lcm 
print(b - a + 1 - c_div - d_div + cd_div)

Measured memory_bytes: 5048
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

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

	int S[n];
	for (int i = 0; i < n; ++i) {
		int v;
		scanf("%d", &v);
		S[i] = v;
	}

	int q;
	scanf("%d", &q);
	int Q[q];
	for (int i = 0; i < q; ++i) {
		int v;
		scanf("%d", &v);
		Q[i] = v;
	}

	int cnt = 0;
	for (int i = 0; i < q; ++i) {
		int left = 0;
		int right = n;
		while (left < right) {
			int mid = (left + right) / 2;
			if (S[mid] == Q[i]) {
				++cnt;
				break;
			} else if (S[mid] > Q[i]) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
int a[100010];

int main(void) {
	cin >> N;
	reps(i, 1, N + 1) cin >> a[i];
	int cnt = 0;
	int now = 1;
	while(cnt++ <= N) {
		now = a[now];
		if(now == 2) break;
	}
	if(now == 2) printf("%d\n", cnt);
	else printf("-1\n");
	return 0;
}

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

int cal(int u, int v) {
    int res = 0;
    while(u) {
        res += u % 10;
        u /= 10;
    }
    while(v) {
        res += v % 10;
        v /= 10;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 1e9;
    for (int i = 1; i < n; i++) {
        ans = min(ans, cal(i, n - i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int mx=k,mn=0;
  int mid=(mx+mn+1)/2;
  while(mx>mn){
    
    //cout<<mx<<" "<<mn<<endl;
    int sum=0;
    int num=mid;
    rep(i,n){
      if(num==1){
	sum++;
	break;
      }
      sum+=num;
      num/=2;
      
    }
    //cout<<"   "<<sum<<endl;
    if(sum>k) mx=mid-1;
    else mn=mid;
    mid=(mx+mn+1)/2;
  }
  cout<<mid<<endl;

  return 0;
}



Measured memory_bytes: 3212
#include <stdio.h>
int main(void)
{
	int a,b,c,i,d=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			d++;
		}
	}
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 2764
#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++)

bool check(int j, string s)
{
    rep(k, (j - 1) / 2)
    {
        if (s[k] != s[j - 1 - k])
            return false;
    }
    return true;
}

int main()
{
    int a, b;
    cin >> a >> b;
    int result = 0;
    rep2(i, a, b + 1)
    {
        string s = to_string(i);
        int j = 0;
        while (s[j] != '\0')
            j++;
        if (check(j, s))
            result++;
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#ifndef HOME
	#pragma GCC target("avx")
	#pragma GCC optimize("Ofast")
	#pragma GCC optimize("unroll-loops")
	#pragma comment(linker, "/stack:200000000")
	#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

#define MAX(a, b) __builtin_ia32_pmaxsd128(a, b)
#define MIN(a, b) __builtin_ia32_pminsd128(a, b)

#include <bits/stdc++.h>
#include <immintrin.h>
using namespace std;

using namespace __gnu_cxx;
using namespace __gnu_pbds;

template <class key_type>
using superTree = tree<key_type, null_type, less<key_type>, 
					   rb_tree_tag, tree_order_statistics_node_update>;
using v4si = int __attribute__ ((vector_size(16)));

const int MOD = 1000000007;

inline int _(int x, int y) {
	x += y;
	if (x >= MOD) { return x - MOD; }
	if (x < 0)    { return x + MOD; }
	return x; }

inline void __(int &x, int y) {
	x = _(x, y); }

/*
 * TO DO:
 *	
 * - long long instead of int
 * - bigger array sizes
 * - array / list instead of map / set
 * - can bruteforce with tricks pass system tests? 
 *
 * - NEVER STOP THINKING / CODING !!!
 */

const int DIM = 200005;

int fth[DIM], csz[DIM], dp[DIM], ans[DIM]; bool oki[DIM];
vector<int> edg[DIM]; deque<tuple<int, int, int>> que;

void dfs(int x, int f) {
	fth[x] = f;
	for (int y : edg[x]) {
		if (y != f) {
			dfs(y, x); } } }

void dfs1(int x, int xx, int ft) {
	if (x >= fth[xx]) {
		que.push_back(make_tuple(x, fth[xx], ft)); return; }
	++csz[xx];
	for (int y : edg[x]) {
		if (y == fth[x]) {
			continue; }
		if (y > fth[xx]) {
			que.push_back(make_tuple(y, fth[xx], ft)); }
		else {
			dfs1(y, xx, ft); } } }

void dfs2(int x, int xx) {
	if (x >= fth[xx]) {
		return; }
	csz[x] = csz[xx]; 
	ans[x] = ans[fth[xx]] + csz[x] - dp[xx];
	for (int y : edg[x]) {
		if (y != fth[x] and y < fth[xx]) {
			dfs2(y, xx); } } }

void dfs3(int x, int xx, int v) {
	++dp[xx];
	for (int y : edg[x]) {
		if (y != fth[x] and y < v) {
			dfs3(y, xx, v); } } }

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif		
	int n; cin >> n;
	for (int i = 1; i < n; ++i) {
		int x, y; cin >> x >> y;
		edg[x].push_back(y);
		edg[y].push_back(x); }
	dfs(1, 0); 
	for (int x : edg[1]) {
		que.push_back(make_tuple(x, 1, x)); }
	for (; que.size(); que.pop_front()) {
		int x, ls, ft; tie(x, ls, ft) = que.front();
		oki[x] = true;
		dfs3(x, x, ls);
		ans[x] = ans[fth[x]] + dp[x];
		for (int y : edg[x]) {
			if (y == fth[x]) {
				continue; }
			if (y < ls)
				dfs3(y, y, ls);  
			dfs1(y, y, ft); 
			dfs2(y, y); } }
	for (int i = 2; i <= n; ++i) {
		cout << ans[i] << " "; }
	return 0; }


Measured memory_bytes: 34304
#include<bits/stdc++.h>
using namespace std;
int a[55],b[55],c[55],d[55];
int n,m,q;
int ans;
int dat[12];
void dfs(int ind , int pre){
	if(ind == n){
		int cnt = 0;
		for(int i=0;i<q;i++){
			if(dat[b[i] - 1] - dat[a[i] - 1] == c[i]) cnt+=d[i];
		}
		ans = max(ans , cnt);
	}
	else{
		for(int i = pre;i<=m;i++){
			dat[ind] = i;
			dfs(ind + 1 , i);
		}
	}
}
int main(){
	cin>>n>>m>>q;
	for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(0,1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
import java.math.BigInteger
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {

    println(if (readLn().toCharArray().asSequence().toSet().size >= 2) "Yes" else "No")
}


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

using namespace std;

int fib(int n) {
    return n <= 1 ? 1 : fib(n - 1) + fib(n-2);
}

int dp[1000];

int fibMemoR(int n){
    if(n <= 1) return dp[n] = 1;
    if(dp[n])return dp[n];
    return dp[n] = fibMemoR(n-1) + fibMemoR(n-2);
}

int fibdp(int n){
    vector<int> dpv(n);
    dpv[0] = dpv[1] = 1;
    for (int i = 2; i < n; ++i)dpv[i] = dpv[i-1] + dpv[i-2];
    return dpv[n-1];
}

int fibloop(int n){
    int fib,fib2;
    fib = fib2 = 1;
    for (int i = 2; i < n; ++i){
        int tmp = fib;
        fib = fib + fib2;
        fib2 = tmp;
    }
    return fib;
}

int main(){
    //freopen("in", "r", stdin);
    int n;
    cin >> n;
    cout << fibloop(n+1) << endl;
    return 0;
}

Measured memory_bytes: 3092
alp = [chr(ord('a') + i) for i in range(26)]
L = [float('inf')]*26
n = int(input())
S = []
ans = ''
for i in range(n):
  S.append(input())
for j in range(n):
  for k in range(26):
    if S[j].count(alp[k]) <= L[k]:
      L[k] = S[j].count(alp[k])
for l in range(26):
  if L[l] != 0:
    for m in range(L[l]):
      ans += alp[l]
print(ans)

Measured memory_bytes: 3064
A, B, K = map(int, input().split())

def main():
    cnt = 0
    for x in range(min(A, B), 0, -1):
        if A%x==0 and B%x==0:
            cnt += 1
            if cnt == K:
                print(x)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  int N, M;
  cin >> N >> M;

  vector<ll> lst(M);
  vector<ll> pri(M);

  int tblsiz = 1LL << N;
  vector<ll> dp(tblsiz, LONG_LONG_MAX/2);

  for (int i = 0; i < M; i++) {
    cin >> pri[i];
    ll lstsiz;
    cin >> lstsiz;
    ll flag = 0;
    for (int j = 0; j < lstsiz; j++) {
      ll tmp;
      cin >> tmp;
      flag |= (1LL << (tmp-1));
    }
    lst[i] = flag;
  }

  dp[0] = 0;
  for (int i = 0; i < tblsiz; i++) {
    for (int j = 0; j < M; j++) {

      ll update = i | lst[j];
      dp[update] = min(dp[update], dp[i] + pri[j]);
    }
  }

  ll ans = dp[tblsiz-1];
  if (dp[tblsiz - 1] == LONG_LONG_MAX/2) ans = -1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split(" "))

o = [0]*(100001)
for i in range(N):
    a,b = map(int,input().split(" "))
    o[a] += b

for i in range(100001):
    a = min(K,o[i])
    if a == K:
        print(i)
        exit()
    K -= a

Measured memory_bytes: 5748
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long int64;
const int kMaxN = 2e5+10;
const int kMod = 1e9+7;

int c[kMaxN], w[kMaxN], reach[kMaxN];
int64 fac[kMaxN], invfac[kMaxN];
vector<vector<int>> B;

int64 lgpow(int64 a, int b) {
	if (b == 0) {
		return 1;
	}

	int64 x = lgpow(a, b>>1);
	if (b&1)
		return x*x%kMod*a%kMod;
	return x*x%kMod;
}

void solve() {

	int n, x, y;

	cin >> n >> x >> y;

	fac[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fac[i] = fac[i-1] * i % kMod;	
	}
	for (int i = 0; i <= n; ++i) {
		invfac[i] = lgpow(fac[i], kMod-2);
	}

	B.resize(n+1);

	for (int i = 1; i <= n; ++i) {
		cin >> c[i] >> w[i];

		B[c[i]].push_back(w[i]);
	}

	for (int i = 1; i <= n; ++i) {
		sort(B[i].begin(), B[i].end());	
	}

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

	int minb = 0;

	for (int i = 1; i <= n; ++i) {
		if (B[i].empty()) {
			continue;
		}
		if (minb == 0) {
			minb = i;
		}

		reach[i] = 1;

		for (int j = 1; j < B[i].size(); ++j) {
			if (B[i][0] + B[i][j] <= x) {
				reach[i] = j+1;
			}
		}

		// cout << i << " " << reach[i] << "\n";
	}

	int totalReach = minb;

	for (int i = 1; i <= n; ++i) {
		if (B[i].empty() || i == minb)
			continue;
		if (B[minb][0] + B[i][0] <= y) {
			totalReach = i;

			for (int j = reach[minb]; j < B[minb].size(); ++j) {
				if (B[i][0] + B[minb][j] <= y) {
					reach[minb] = j+1;
				}
			}
		}

		for (int j = 1; j < B[i].size(); ++j) {
			if (B[minb][0] + B[i][j] <= y) {
				if (j+1 > reach[i]) {
					reach[i] = j+1;
				}
			}
		}
	}

	// cout << totalReach << "\n";

	int64 ans = 1;
	int total = 0;

	for (int i = 1; i <= n; ++i) {
		if (i <= totalReach) {
			ans = ans * invfac[reach[i]] % kMod;
			total += reach[i];
		}
	}
	ans = ans * fac[total] % kMod;

	cout << ans << "\n";
}

void reset() {
}

int main() {
	int tests = 1;
	for (;tests; --tests) {
		solve();
		reset();
	}
}

Measured memory_bytes: 14720
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = map(int, input().split())
M = 10**9+7
nums = [0]*(k+1) # gcd==kなる数列の個数
for i in range(k, 0, -1):
    nums[i] = pow(k//i, n, M)
    for j in range(2*i, k+1, i):
        nums[i] -= nums[j]
    nums[i] %= M
ans = sum(i*item for i,item in enumerate(nums))%M
print(ans)

Measured memory_bytes: 74612