akhauriyash/Code-Regression huggingface dataset:
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
//#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int N;

    cin >> N;
    string S[N];
    string S2[N];
    int P[N];
    for( int ni = 0 ; ni < N ; ni++ ){
        cin >> S[ni];
        S2[ni]=S[ni];
        cin >> P[ni];
    }
    sort(S2,S2+N);

    int maxv;
    int nmax;
    for( int ni = 0 ; ni <N ; ni++ ){
        maxv = -1;
        nmax = 0; 
        for( int n1 = 0 ; n1 < N ; n1++ ){
            if(S[n1]==S2[ni]){
                if(maxv < P[n1]){
                    maxv = P[n1];
                    nmax = n1;
                }
            }
        }
        cout << nmax+1 << endl;
        P[nmax]=-1;
    }
    
    


}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

const int MAXN = 2000 + 10;
int N, K;
vector<int> A[MAXN];
int ans;

inline int Dfs( int x, int p, int t, int y ) {
	register int i;
	int res = 1;
	if(t != y)
		for( i = 0; i < (int) A[x].size(); ++i )
			if(A[x][i] != p)
				res += Dfs(A[x][i], x, t + 1, y);
	return res;
}

int main() {
	register int i, j; int x, y;
	scanf( "%d%d", &N, &K );
	for( i = 1; i < N; ++i )
		scanf( "%d%d", &x, &y ),
		A[--x].push_back(--y), A[y].push_back(x);
	if(K & 1)
		for( i = 0; i < N; ++i )
			for( j = 0; j < (int) A[i].size(); ++j )
				ans = max( ans, Dfs( i, A[i][j], 0, K >> 1 ) + Dfs( A[i][j], i, 0, K >> 1 ) );
	else
		for( i = 0; i < N; ++i )
			ans = max( ans, Dfs( i, -1, 0, K >> 1 ) );
	printf( "%d\n", N - ans );
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

#define N 100

static
int map[ N + 1 ][ N + 1 ];
static
int w, h;
static
int sc;
static
int xg, yg;

int dfs (
  int x,
  int y
  )
{
#if 0
  int res;
#endif

  if ( x < 1 || x > w || y < 1 || y > h ) return ( 0 );  
  if ( map[ x ][ y ] != sc )  return ( 0 );
  if ( x == xg && y == yg )   return ( 1 );

  map[ x ][ y ] = -1;
#if 0
  res = dfs ( x + 1, y )
     || dfs ( x, y + 1 )
     || dfs ( x - 1, y )
     || dfs ( x, y - 1 );
  map[ x ][ y ] = sc;

  return ( res );
#endif
  return ( dfs ( x + 1, y )
        || dfs ( x, y + 1 )
        || dfs ( x - 1, y )
        || dfs ( x, y - 1 ) );
}

int main (
  void
  )
{
  for ( ; ; )
  {
    int xs, ys;
    int n;

    scanf ( "%d%d", &w, &h );
    if ( w == 0 && h == 0 ) break;

    scanf ( "%d%d%d%d%d", &xs, &ys, &xg, &yg, &n );
    memset ( map, 0, sizeof ( map ) );

    while ( n-- )
    {
      int c, d, x, y;

      scanf ( "%d%d%d%d", &c, &d, &x, &y );
      map[ x ][ y ] =
      map[ x ][ y + 1 ] =
      map[ x + 1 ][ y ] =
      map[ x + 1 ][ y + 1 ] = c;
      if ( d )
      {
        map[ x ][ y + 2 ] =
        map[ x ][ y + 3 ] =
        map[ x + 1 ][ y + 2 ] =
        map[ x + 1 ][ y + 3 ] = c;
      }
      else
      {
        map[ x + 2 ][ y ] =
        map[ x + 2 ][ y + 1 ] =
        map[ x + 3 ][ y ] =
        map[ x + 3 ][ y + 1 ] = c;
      }
    }

    sc = map[ xs ][ ys ];
    puts ( dfs ( xs, ys ) ? "OK" : "NG" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = sc.nextInt();
	static int[] p = new int[N];
	static {
		Arrays.setAll(p, i->sc.nextInt());
	}
	public static void main(String[] args) {
		Arrays.sort(p);
		int ans = 0;
		for (int i = 0; i < p.length; i++) {
			if (i == p.length - 1) {
				ans += p[i]/2;
			} else {
				ans += p[i];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 27088
X,K,D = map(int, input().split())

if abs(X)//D > K:
    if X < 0:
        X += D*K
    if X > 0:
        X -= D*K

else:
    K -= abs(X)//D
    
    if X < 0:
        X += D*(abs(X)//D)
    if X > 0:
        X -= D*(abs(X)//D)
        
    if X == 0:
        if K%2 == 0:
            X = 0
        else:
            X = D
    else:
        if K%2 == 0:
            X = X
        else:
            if X > 0:
                X -= D
            else:
                X += D

print(abs(X))

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

using namespace std;
int main(void){
    int a,b,c,x,y;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> x;
    std::cin >> y;
    if(a + b > 2 * c){
        if(x > y){
            if(a > 2 * c){
                std::cout << x * 2 * c << std::endl;
            } else {
                std::cout << (y * 2 * c) + ((x - y) * a) << std::endl;
            }
        } else {
            if(b > 2 * c){
                std::cout << y * 2 * c << std::endl;
            } else {
                std::cout << (x * 2 * c) + ((y - x) * b) << std::endl;
            }
        }
    } else {
        std::cout << (a * x) + (b * y) << std::endl;
    }
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.chomp.split.map(&:to_i)
sum = 0
counts = [0] * (N+1)

A.each {|a| counts[a] ||= 0; counts[a] += 1}
(1..N).each {|i| sum += (counts[i] * (counts[i]-1) / 2)}
(1..N).each {|j| puts sum - (counts[A[j-1]]-1)}

Measured memory_bytes: 25220
#include<stdio.h>
int main(){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(x-r>=0&&y-r>=0&&x+r<=W&&y+r<=H)
printf("Yes\n");
else 
printf("No\n");
return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;



int main() {
	int n, i;
	cin >> n>> i;
	cout << n - i + 1 << endl;
	return 0;
}

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

int main()
{
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; x <= k; ++x)
  {
    for (int y = 0; y <= k; ++y)
    {
      int z = s - x - y;
      if (z <= k & 0 <= z) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define en "\n"
#define MOD 1000000007
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t=1;
	//cin >> t;
	while (t--) {
		int n,q;
		cin>>n>>q;
		int x;
		int count=0;
		for(int i=0;i<q;i++){
			cin>>x;
			count+=x;
		}	
		if(count>n){
			cout<<-1<<endl;
		}
		else{
			cout<<abs(count-n)<<endl;
		}
	}
	return 0;
}

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

using namespace std;

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

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"

int get(int a) {
	int res = 0;
	while(a % 2 == 0) {
		++res;
		a /= 2;
	}
	return res;
}

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	ll a, b, c;
	cin >> a >> b >> c;

	int k = 0;
	while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0 && k < 1000000) {
		ll aa = b / 2 + c / 2;
		ll bb = a / 2 + c / 2;
		ll cc = a / 2 + b / 2;
		a = aa;
		b = bb;
		c = cc;
		++k;
	}

	if (k == 1000000) {
		puts("-1");
		return 0;
	}

	cout << k << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    ll h,w;
    std::cin >> h>>w;
    if(h==1||w==1){
        std::cout << 1 << std::endl;
        exit(0);
    }
    ll ans=w/2*h;
    //std::cout << ans << std::endl;
    if(w%2==1){
        ans+=h/2;
        if(h%2==1)ans++;
    }
    std::cout << ans << std::endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 998244353
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
// #define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/

void solve(){
    vi v(26, 0);
    string s, t;
    int ans = 0;
    cin >> s >> t;
    rep(i, 0, s.size()){
        ans += s[i] != t[i];
    }
    cout << ans;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3748
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){

  int N,t[100001]={},x[100001]={},y[100001]={};
  cin>>N;
  for(int i=1;i<N+1;i++)scanf("%d%d%d",&t[i],&x[i],&y[i]);
  for(int i=0;i<N;i++){
    int a=t[i+1]-t[i];
    int l=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if((a-l)%2==1||a<l){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1408
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
#define MAXN 100000
int dx[MAXN+10],dy[MAXN+10];
int p[MAXN+10];
bool b[MAXN+10];
int c[MAXN+10];
void solve(long long N, vector<long long> x, long long M, long long K, vector<long long> a){
	for(int i=1; i<N; ++i) {
		dx[i]=x[i]-x[i-1];
		p[i]=i;
	}
	for(int i=0; i<M; ++i) {
		swap(p[a[i]],p[a[i]-1]);
	}
	memset(b,true,sizeof(b));
	for(int i=1; i<N; ++i) {
		if (!b[i]) continue;
		int len=0;
		for(int y=p[i]; b[y]; y=p[y]) {
			b[y]=false;
			c[++len]=y;
		}
		int t=K%len;
		for(int j=1; j<=len; ++j) {
			dy[c[j]]=dx[c[(j+t-1)%len+1]];
		}
	}
	LL ans=x[0];
	for(int i=1; i<=N; ++i) {
		cout<<ans<<'\n';
		ans+=dy[i];
	}
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long N;
	long long K;
	long long M;
	scanf("%lld",&N);
	vector<long long> x(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&x[i]);
	}
	scanf("%lld",&M);
	vector<long long> a(M-1+1);
	scanf("%lld",&K);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, x, M, K, a);
	return 0;
}




Measured memory_bytes: 6016
s = int(input())
n = 10**5
mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1]
for i in range(2, n+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod%i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

def comb(n, r):
    if r<0 or r>n:
        return 0
    return g1[n] * g2[r] * g2[n-r] % mod

ans = 0
for i in range(1, n):
    tmp = s-3*i
    if tmp<0:
        break
    ans += comb(tmp+i-1, i-1)
    ans %= mod
print(ans)

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

using namespace std;

class CrossSectionDiagram {
public:
    CrossSectionDiagram(string diagram) : diagram_(diagram), totalArea(0) {}
    void solve() {
        size_t current = 0;
        while (current < diagram_.size()) {
            current = findStart(current);
            if (current == string::npos) {
                break;
            }
            size_t end = findEnd(current);
            if (end != string::npos) {
                int area = getArea(current, end);
                areas.push_back(area);
                totalArea += area;
                current = end + 1;
            }
            else {
                ++current;
            }
        }

        cout << totalArea << endl;
        cout << areas.size();
        for (int i : areas) {
            cout << " " << i;
        }
        cout << endl;
    };
private:
    size_t findEnd(int start) {
        int depth = 0;
        size_t current = start;
        while (current < diagram_.size()) {
            switch (diagram_[current]) {
            case '\\':
                ++depth;
                break;
            case '/':
                --depth;
                break;
            default:
                break;
            }
            if (depth == 0) {
                return current;
            }
            ++current;
        }
        return string::npos;
    }
    size_t findStart(int start) {
        size_t current = start;
        while (current < diagram_.size()) {
            if (diagram_[current] == '\\') {
                return current;
            }
            ++current;
        }
        return string::npos;
    }
    int getArea(size_t start, size_t end) {
        int depth = 0;
        int area = 0;
        for (size_t i = start; i <= end; ++i) {
            switch (diagram_[i]) {
            case '\\':
                ++area;   // 2倍の値とする
                area += (depth * 2);
                ++depth;
                break;
            case '/':
                ++area;
                --depth;
                area += (depth * 2);
                break;
            case '_':
                area += (depth * 2);
                break;
            default:
                break;
            }
        }
        return area/2;
    }
    string diagram_;
    vector<int> areas;
    int totalArea;
};

int main()
{
    string str;
    cin >> str;
    //string str{ "\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\" };

    CrossSectionDiagram aCrossSectionDiagram(str);
    aCrossSectionDiagram.solve();
}



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


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

  int n = (b - 1) / (a - 1) ;
  auto res = (b - 1) % (a - 1) ;
  if ( res > 0 ) ++n ;

  cout << n ;
  return 0 ;
}



Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
def run_length_encode(s):
    count = 1
    code = []
    target = s[0]
    for i in range(1, len(s)):
        if target == s[i]: count += 1
        else:
            code.append((target, count))
            target = s[i]
            count = 1
    code.append((target, count))
    return code

N = iin()
abc = [iln() for _ in range(N)]
dp = [[0 for _ in range(3)] for _ in range(N+1)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k: continue
            dp[i+1][j] = max(dp[i+1][j], dp[i][k]+abc[i][j])
print(max(dp[N]))

Measured memory_bytes: 100180
H, W, M = map(int, input().split())

hc = [0] * H
wc = [0] * W
d = {}
for _ in range(M):
    h, w = map(lambda x: int(x) - 1,input().split())
    hc[h] += 1
    wc[w] += 1
    d[(h, w)] = 1

maxh = max(hc)
maxw = max(wc)

result = maxh + maxw - 1
wi = [i for i in range(W) if wc[i] == maxw]
for h in [i for i in range(H) if hc[i] == maxh]:
    for w in wi:
        if (h, w) not in d:
            result = maxh + maxw
            break
print(result)


Measured memory_bytes: 85456
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n;
  cin >> n;
  ul d[n];
  for (ul i = 0; i < n; ++i) cin >> d[i];
  ul m;
  cin >> m;
  ul t[m];
  for (ul i = 0; i < m; ++i) cin >> t[i];
  ul piv_d = 0, piv_t = 0;
  sort(d, d+n);
  sort(t, t+m);
  while (piv_t<m) {
    while (piv_d<n && t[piv_t]!=d[piv_d]) piv_d++;
    if (piv_d==n) {cout << "NO" << endl; return 0;}
    piv_d++; piv_t++;
  }
  cout << "YES" << endl;
  return 0;
}


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

int main() {
  int s, w;
  cin >> s >> w;
  if (s <= w) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}

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

int main()
{
    long long a,b,d=0;
    cin>>a>>b;
    for(int i=1; i<=1250; i++)
    {
        double x=i,y=i;
        x=x*(0.08);
        y=y*(0.1);
        int p=x,q=y;
        if(p==a && q==b)
        {
            d=1;
            cout<<i<<endl;
            break;
        }
    }
    if(!d) cout<<-1<<endl;
    return 0;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	for(int i=0,x;i<5;++i){
		cin>>x;
		if(x==0)
			cout<<i+1<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3588
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      String s;
      s=sc.next();
      int a=0, b=0;

      for(int i=0; i<s.length(); i++){
        if(s.charAt(i)=='0'){
          a++;
        }else{
          b++;
        }
      }

      System.out.println(Math.min(a, b)*2);
    
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 25064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
int main ()
{
	int a,b;
	scanf("%d %d",&a,&b);
	int i;
	int s[100];
	int sum = 0;
	for ( i = 1; i <= a; i++)
	{
		scanf("%d",&s[i]);
		}
		sort(s+1,s+1+a);
		for (i = a-b+1; i <= a; i++)
			sum = sum + s[i];
			printf("%d",sum);

	}

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


int main() {

  string S, T;
  cin >> S >> T;

  int A, B;
  cin >> A >> B;

  string U;
  cin >> U;

  if (U == S) {
    A--;
  }

  if (U == T) {
    B--;
  }

  cout << A << " " << B << endl;

  return 0;

}

Measured memory_bytes: 256
#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(){
    int x,n;cin >> x >> n;
    vector<int> p(110,0);
    rep(i,n){
        int a;cin >> a;
        p[a] = 1;
    }
    rep(i,100){
        int tp = x+i;
        int tm = x-i;
        if(p[tm]==0){
            cout << tm << endl;
            return 0;
        }
        if(p[tp]==0){
            cout << tp << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cstdio>
#include<cmath>

using namespace std;

const int INF = (1<<25);
const int MAX = 10001;
int N,M;
double ans;

struct Pile{
  int x,y;
  Pile(){}
  Pile(int x,int y):x(x),y(y){}
};

struct State{
  int pos;
  double t;
  State(){}
  State(int pos, double t):pos(pos),t(t){}
  bool operator < (const State& s) const { return t < s.t;}
};

vector<int> Edge[MAX];
vector<Pile> P;
double T[MAX];
bool used[MAX];

void init(){
  fill(T,T+MAX,-1);
  fill(used,used+MAX,false);
  for(int i = 0; i < MAX; i++) Edge[i].clear();
  P.clear();
  ans = 0;
}

double getDis(int p, int q){
  return sqrt((P[p].x-P[q].x)*(P[p].x-P[q].x)+(P[p].y-P[q].y)*(P[p].y-P[q].y));
}

void input(){
  for(int i = 0; i < N; i++){
    Pile in;
    cin >> in.x >> in.y;
    P.push_back(in);
  }

  for(int i = 0; i < M; i++){
    int p,q;
    cin >> p >> q;
    p--;
    q--;
    Edge[p].push_back(q);
    Edge[q].push_back(p);
    ans += getDis(p,q);
  }
}


void prim(int start){
  priority_queue<State> Q;
  Q.push(State(start,0));
  T[start] = 0;

  while(!Q.empty()){
    State now = Q.top();
    Q.pop();
     
    if(used[now.pos]) continue;
    used[now.pos] = true;

    ans -= now.t;


    for(int i = 0; i < (int)Edge[now.pos].size(); i++){
      int nex = Edge[now.pos][i];
      if(T[nex] < getDis(now.pos,nex)){
	T[nex] = getDis(now.pos,nex);
	Q.push(State(nex,getDis(now.pos,nex)));
      }
    }
  }
}

void solve(){

  for(int i = 0; i < N; i++){
    if(!used[i]) prim(i);
  }


  printf("%.3f\n",ans);
}

int main(){
  
  while(cin >> N >> M && N+M){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 2340
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
#include<vector>
#include<queue>
#include<bits/stdc++.h>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<x<<" "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+5;
void FAST(){ios::sync_with_stdio(false);cin.tie(0);}
const ll mod =  1e9+7;

int n, m, k;
ll sum[N];

void solve()
{
    scanf("%d%d", &n, &k);

    for(ll i = 1; i <= n; ++i)
        sum[i] = (sum[i-1]+i)%mod;
    ll ans = 0;
    for(int i = k-1; i <= n; ++i)
    {
        ans += ((sum[n]-sum[n-i-1])-(sum[i])+1);
        ans = (ans+mod)%mod;
    }
    printf("%lld\n", ans);

}


int main()
{
//    int _; scanf("%d", &_); while(_--)
//    while(~scanf("%d%d", &n, &d))
//    while(~scanf("%lld", &n))
    solve();
    return 0;
}


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

typedef pair<int, int> P;

int N, M, H, K;
int S[2010];
vector<P> V[2010];
int A[100010], B[100010];
int R[10010], R2[10010];
int HS[2010][2010], TS[2010][2010];

int f(int x, int h, int s) {
  auto it = lower_bound(V[x].begin(), V[x].end(), P(h+1, 0));
  if (it == V[x].end()) return x;
  P p = *it;
  int d = p.second, nh = p.first;
  HS[x][nh] = s;
  return TS[d][nh] = f(d, nh, s);
}

int main() {
  while (cin >> N >> M >> H >> K) {
    if (N == 0 && M == 0 && H == 0 && K == 0) break;
    for (int i=1; i<=N; i++) cin >> S[i];
    for (int i=0; i<M; i++) A[i] = 0, B[i] = 0;
    for (int i=0; i<M; i++) {
      cin >> A[i] >> B[i];
    }
    for (int i=1; i<=N; i++) V[i].clear();
    for (int i=0; i<M; i++) {
      V[A[i]].push_back(P(B[i], A[i]+1));
      V[A[i]+1].push_back(P(B[i], A[i]));
    }
    for (int i=1; i<=N; i++) sort(V[i].begin(), V[i].end());
    for (int i=1; i<=N; i++) R[i] = f(i, 0, i);
    int m = 0;
    for (int i=1; i<=K; i++) m += S[R[i]];

    for (int i=0; i<M; i++) {
      int a = A[i], b = B[i];
      for (int j=1; j<=N; j++) R2[j] = R[j];
      R2[HS[a][b]] = TS[a][b];
      R2[HS[a+1][b]] = TS[a+1][b];
      int sum = 0;
      for (int j=1; j<=K; j++) sum += S[R2[j]];
      m = min(m, sum);
    }
    cout << m << "\n";
  }
  return 0;
}

Measured memory_bytes: 21708
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int N;
	int K;
	cin >> N >> K;

	vector<int> p(N, 0);
	for (int i = 0; i < p.size(); i++) {
		cin >> p[i];
	}

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

	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += p[i];
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 3632
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;
#define int long long

// https://ja.wikipedia.org/wiki/%E4%BD%99%E5%BC%A6%E5%AE%9A%E7%90%86
constexpr double lawOfCosinesA(double b, double c, double alpha) {
    return sqrt(b * b + c * c - 2 * b * c * cos(alpha));
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

    int a, b, h, m;
    cin >> a >> b >> h >> m;

    const double h_angle = (h / 12.0 + m / 60.0 / 12.0) * 2 * M_PI,
                 m_angle = m / 60.0 * 2 * M_PI;
    const double angle = abs(h_angle - m_angle);

    const double ans = lawOfCosinesA(a, b, angle);
    cout << ans << endl;
}


Measured memory_bytes: 4212
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] line2 = line.split(" ");
        int row = Integer.parseInt(line2[0]);
        int column = Integer.parseInt(line2[1]);
        int[][] vec1= new int[row][column];
        int[] vec2 = new int[column];
        for(int j=0;j<row;j++) {
            String v = br.readLine();
            String[] v_ary = v.split(" ");
            for(int i=0;i<column;i++) {
                vec1[j][i] = Integer.parseInt(v_ary[i]);
            }        
        }
        for(int i=0;i<column;i++) {
            String v = br.readLine();
            vec2[i] = Integer.parseInt(v);
        }
        List<Integer> result = vecMul(vec1,vec2);
        print(result,column);
    }
    static void print(List<Integer> res,int column) {
        for(int i=0;i<res.size();i++) {
            System.out.println(res.get(i));
        }    
    }
    static List<Integer> vecMul(int[][] vec1,int[] vec2) {
        List<Integer> res = new ArrayList<Integer>();
        for(int j=0;j<vec1.length;j++){
            int sum = 0;
            for(int i=0;i<vec2.length;i++) {
                sum += vec1[j][i] * vec2[i];
            }
            res.add(new Integer(sum));
        }
        return res;
    }
}

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

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

  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

void Solution()
{
    int a, b, c;
    
    while(cin>>a>>b>>c)
    {
        if(a < b && b < c) 
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl; 
        }
       
    }
}

int main()
{
    Solution();
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    long int n, x;
    cin >> n >> x;
    long int a[n];
    rep(i, n) cin >> a[i];
    long int ans = 0;
    if(a[0] > x){
        ans += a[0] - x;
        a[0] = x;
    }
    rep(i, n - 1){
        if(a[i+1] + a[i] > x){
            ans += a[i+1] + a[i] - x;
            a[i+1] = x - a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>

using namespace std;

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

const int mod = 1e9 + 7;

class Solution {
private:
    
public:
    int64 solve(int n, string& s) {
        // int64 a = 0, b = 0, c = 0, ret = 1;
        // for(const auto& cc : s) {
        //     if(cc == 'R') ++a;
        //     else if(cc == 'G') ++b;
        //     else if(cc == 'B') ++c;
        // }
        // ret = a * b * c;
        // cout << "multiply: " << ret << endl;
        int64 ret = n > 0;
        // int64 ret2 = 1;
        unordered_map<char, int64> cs;
        for(const auto& cc : s) {
            ++cs[cc];
        }
        ret = cs['R'] * cs['G'] * cs['B'];
        //for(const auto&[k, v] : cs) ret *= v;
        // cout << "dic:      " << ret2 << endl;
        
        for(int i = 0; i < n; ++i) {
            char& a = s[i];
            for(int j = i + 1; j < n; ++j) {
                char& b = s[j];
                if(a == b) continue;
                int cIdx = 2 * j - i;
                if(cIdx < n && s[cIdx] != a && s[cIdx] != b) --ret;
            }
        }
        return ret;
    }
};

int main() {
    int n;
    string s;
    cin >> n >> s;
    Solution sol;
    auto ret = sol.solve(n, s);
    cout << ret << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define Abs(x) ((x) > 0 ? (x) : -(x))
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

int sort(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int
main(int argc, char *argv[])
{
  int a, b;
  scanf("%d %d", &a, &b);
  if((a + b) % 2 == 1) printf("IMPOSSIBLE\n");
  else printf("%d\n", (a + b) / 2);

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int N = sc.nextInt();
		int S = 0;
		int M = 0;

		for (int i = 0; i < N; i++) {
			int P = sc.nextInt();
			S += P;
			M = Math.max(M, P);
		}
		int ans = S - M / 2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>

using namespace std;

int main(int argc, const char * argv[]) {
    vector<long long> a;
    unsigned long long K;
    cin >> K;
    long long i;
    for(i=1;i<10;i++) a.push_back(i);
    long long start_size = 0;
    long long end_size = a.size();
    while(true){
        if(end_size >= K) break;
        for(long long k=start_size ; k<=end_size ; k++){
            for(long long j=-1; j<=1;j++){
                long long d = a[k]%10 + j;
                if(d<0 || d>9) continue;
                a.push_back(a[k]*10+d);
            }
        }
        start_size = end_size + 1;
        end_size = a.size();
    }
    
//    for(i=0;i<K;i++){
        cout << a.at(K-1) << endl;
//    }
    
    return 0;
}


Measured memory_bytes: 2420
from sys import stdin


def main():
    _ = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    a = sorted(a, reverse=True)
    Alice = [x for i, x in enumerate(a) if i % 2 == 0]
    Bob = [x for i, x in enumerate(a) if i % 2 != 0]
    print(sum(Alice) - sum(Bob))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int i,n,x[365],y[365],b[365],p[365],sum[365];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&x[i],&y[i],&b[i],&p[i]);
		sum[i] = x[i] * b[i] + y[i] * p[i];
	}
	for(i=0;i<n;i++){
		if(b[i]<5 && p[i] > 1 && sum[i] > (x[i] * 5 + y[i] * p[i]) * 0.8)
			sum[i] = (x[i] * 5 + y[i] * p[i]) * 0.8;
		else if(b[i]>=5 && p[i] < 2 && sum[i] > (x[i] * b[i] + y[i] * 2) * 0.8)
			sum[i] = (x[i] * b[i] + y[i] * 2) * 0.8;
		else if(b[i] >= 5 && p[i] >= 2)
			sum[i] = sum[i] * 0.8;
	}
	for(i=0;i<n;i++){
		printf("%d\n",sum[i]);
	}
	return 0;
}

Measured memory_bytes: 608
/*
	Code written by Talant I.D.
*/

#include <bits/stdc++.h> 

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;

#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define mp make_pair
#define mt make_tuple
#define mod 1e9+7
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define curMod 998244353

inline bool invowel(char ch){
	ch = tolower(ch);
	return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

inline bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2)
		if(n%i == 0) return false;
	return true;
}

int main(){
	do_not_disturb
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	//freopen("shuffle.in", "r", stdin);
	//freopen("shuffle.out", "w", stdout);
	
	string from, to;
	ll cnt = 0, pos = 0, i, flag = 0, j;
	cin >> from >> to;
	ll dp[ll(from.size())][26];
	map <char, ll> used;
	for(i = 0; i < from.size(); i++){
		for(j = 0; j < 26; j++){
			dp[i][j] = -1;
		}
	}
	for(auto it : from){
		used[it]++;
	}
	for(auto it : to){
		if(!used.count(it)){
			flag++;
			break;
		}
	}
	if(flag){
		cout << -1 << '\n';
		return 0;
	}
	for(i = from.size()-1; i >= 0; i--){
		if(i != from.size()-1){
			for(j = 0; j < 26; j++){
				dp[i][j] = dp[i+1][j];
			}
		}
		ll p = ll(from[i]-'a');
		dp[i][p] = i;
	}
	ll ans;
	for(i = 0; i < to.size(); i++){
		char it = to[i];
		ll p = ll(it-'a');
		if(dp[pos][p] != -1){
			ans = dp[pos][p];
			pos = dp[pos][p]+1;
			if(pos == from.size()){
				cnt++;
				pos = 0;
			}
			if(i+1 != to.size()){
				ll h = ll(to[i+1]-'a');
				if(dp[pos][h] == -1) i--;
			}
		}
		else{
			pos = 0;
			cnt++;
		}
	}
	if(pos) cnt++;
	cout << ll(from.size())*(cnt-1)+ans+1;
	
	return 0;
}


Measured memory_bytes: 20944
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int k,n;
    cin>>k>>n;
    
    vector<int> nu(n+1);
    for(int i=0;i<n;i++){
      cin>>nu[i];
    }
    nu[n]=nu[0]+k;
    
    vector<int> d(n);
    for(int i=0;i<n;i++){
      d[i]=nu[i+1]-nu[i];
    }
    sort(d.begin(),d.end());
    
    long long int ans=0;
    for(int i=0;i<n-1;i++){
      ans+= d[i];
    }
    
    //cout<<d[0]<<endl;
    cout<<ans<<endl;
}


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

#define ll long long

ll n,a,even,odd;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a%2==0) even++;
		else odd++;
	}
	if(odd%2==0) cout<<"YES";
	else cout<<"NO"<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
constexpr double pi = 3.141592653589793238462643383279;
signed main()
{
	double a, b, h, m, th;
	scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
	th = abs(30 * h - 5.5f * m) / 180 * pi;
	printf("%.10f\n", sqrt(a * a - 2 * a * b * cos(th) + b * b));
}


Measured memory_bytes: 4340
#include <iostream>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int n, need[3];
int l[8], take[4] = { 0 };
const int INF = 1e+9;

int func(int count, int score) {
    int res = INF;

    if (count == n) {
        for (int i=0; i<3; i++) {
            if (take[i] <= 0) return INF;
            score += abs(need[i] - take[i]);
        }
        return score;
    }

    for (int i=0; i<4; i++) {
        take[i] += l[count];
        if (i != 3 && take[i] > l[count])  res = min(res, func(count+1, score+10));
        else                        res = min(res, func(count+1, score));
        take[i] -= l[count];
    }

    return res;
}

int main () {

    cin >> n >> need[0] >> need[1] >> need[2];

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

    cout << func(0, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
        "sort"
)

func main(){
	v := make([]int, 3)
	for i:=0; i<3; i++{
		var a int
		fmt.Scan(&a)
		v[i] = a
	}
	sort.Ints(v)
	fmt.Println(v[0], v[1], v[2])
}


Measured memory_bytes: 1128
#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 kaibun(string &S){
    string T(S.rbegin(), S.rend());

    return S == T;
}

int main(){
    string S;
    cin >> S;
    int N = S.size();
    string S1 = S.substr(0, (N - 1) / 2);
    string S2 = S.substr((N + 1) / 2, (N - 1) / 2);

    if(kaibun(S) && kaibun(S1) && kaibun(S2)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

const long long M = 1000000007;


const int L=2e5+1;
vector<LL> vs[L];
LL x[L];
LL p[L];
vector<LL> ms;

// a>=0, b>=0, x*a+y*b=gcd>=0, a>0,b>0=>abs(y)<=a,abs(x)<=b
LL gcdex(LL a,LL b,LL& x, LL& y){
	LL ax=1,ay=0;
	LL bx=0,by=1;
	while(b){
		LL r=a/b;
		LL t=a-r*b; a=b; b=t;
		LL tx=ax-r*bx; ax=bx; bx=tx;
		LL ty=ay-r*by; ay=by; by=ty;
	}
	x=ax;
	y=ay;
	return a;
}
LL modinv(LL a, LL m){
	LL x,y;
	gcdex(a,m,x,y);
	if(x<0){
		x+=m;
	} else if(x>=m){
		x-=m;
	}
	return x;
}

int main(){
    long long N;
    scanf("%lld",&N);
	p[0]=1;
	for(LL i=1;i<=N;i++){
		p[i]=p[i-1]*i%M;
	}

    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    for(int i = 0 ; i < N ; i++){
		int c,w;
        scanf("%d",&c);
        scanf("%d",&w);
		vs[c].push_back(w);
    }
	for(int i=1;i<=N;i++){
		if(vs[i].size()==0){
			continue;
		}
		sort(vs[i].begin(),vs[i].end());
		int j=1;
		for(;j<vs[i].size();j++){
			if(vs[i][0]+vs[i][j]>X){
				break;
			}
		}
		x[i]=j;
		ms.push_back(vs[i][0]);
	}
	sort(ms.begin(),ms.end());
	LL ret=1;
	LL sum=0;
	for(int i=1;i<=N;i++){
		if(vs[i].size()==0){
			continue;
		}
		int j=x[i];
		LL f=ms[0];
		if(vs[i][0]==f){
			if(ms.size()==1||ms[0]+ms[1]>Y){
				continue;
			}
			for(;j<vs[i].size();j++){
				if(ms[1]+vs[i][j]>Y){
					break;
				}
			}
		}
		else if(vs[i][0]+ms[0]>Y){
			continue;
		}
		else {
			for(;j<vs[i].size();j++){
				if(ms[0]+vs[i][j]>Y){
					break;
				}
			}
		}
		ret*=modinv(p[j],M);
		ret%=M;
		sum+=j;
	}
	ret*=p[sum];
	ret%=M;
	cout << ret << endl;

    return 0;
}


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

int main() {
	int N,c=0,t=1;
	cin >> N;

	while(N >= t) {
		t *= 2;
		c++;
	}

	cout << pow(2,c-1) << endl;
}

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

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

	vector<int> c(m);
	for (int i=0;i<m;++i)
	{
		cin >> c[i];
	}
	sort(c.begin(),c.end());

	vector<int> dp(n+1);
	for (int i=0;i<m;++i)
	{
		int cc=c[i];
		for (int j=cc;j<=n;++j)
		{
			if (dp[j]>0)
			{
				dp[j]=min(dp[j],dp[j-cc]+1);
			}
			else
			{
				dp[j]=dp[j-cc]+1;
			}
		}
	}
	cout << dp[n] << endl;
}








Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N, W;
    int i, j;
    cin>>N>>W;
    vector<P> wv(N);
    rep(i, N) cin>>wv[i].first>>wv[i].second;

    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1));
    rep(i, N) {
        rep(j, W + 1) {
            if (j - wv[i].first < 0) {
                dp[i + 1][j] = dp[i][j];
                continue;
            }
            dp[i + 1][j] = max(dp[i][j], dp[i][j - wv[i].first] + wv[i].second);
        }
    }
    cout<<dp[N][W];
}

Measured memory_bytes: 80256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  char a[3];
  cin >> a[0] >> a[1] >> a[2];
  int ans=0;
  for(int i=0;i<3;i++){
    if(a[i]=='1') ans+=1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    S  = input()
    K = 'keyence'
    if len(S)<=7:
        if S == K:
            print('YES')
        else:
            print('NO')
    else :
        ShaveN = len(S) - 7
        for i in range(len(S) - ShaveN + 1):
            Shave = S[:i] + S[i+ShaveN:]
            if Shave == K:
                print('YES')
                return
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int res=s.length();
  res+=s[0]==s.back();
  if(res&1)cout<<"First"<<endl;
  else cout<<"Second"<<endl;
  return 0;

}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[3];
        for(int i = 0; i < 3; i++) {
            nums[i] = sc.nextInt();
        }
        int count = 0;
        while(nums[0] != nums[1] || nums[1] != nums[2]) {
            Arrays.sort(nums);
            if(nums[2] - nums[0] >= 2) {
                nums[0] += 2;
            } else {
                nums[0]++;
                nums[1]++;
            }
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));

bool prime[10000];
void era(){
    memset(prime,true,sizeof prime);
    for(ll p=2;p*p<=10000;p++){
        if(prime[p]){
            for(ll q=p*p;q<=10000;q+=p){
                prime[q]=false;
            }
        }
    }

    return;
}
ll fac[200001],finv[200001];
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=(ans*a)%MAX;
        b/=2;
        a=(a*a)%MAX;
    }
    return(ans%MAX);
}
ll inverse(ll a){
    return((power(a,MAX-2))%MAX);
}
ll ncr(ll n, ll r){
    ll p1=finv[n-r];
    ll p2=finv[r];

    return((((fac[n]*p1)%MAX)*p2)%MAX);


}
bool solve(ll n,ll arr[]){
    ll sum=0;
    for(ll i=0;i<n;i++){
        sum+=arr[i];
        if(sum<=0) return(false);
    }
    sum=0;
    for(ll i=n-1;i>=0;i--){
        sum+=arr[i];
        if(sum<=0) return(false);
    }
    return(true);
}
struct Node{
    ll l,r,w;
}arr[5001];
bool cmp(Node a,Node b){
    return(a.r<b.r);
}
int main(){
    IO
    string s;
    cin>>s;
    ll n=s.size();
    ll cnt=0;
    for(ll i=0;i+1<s.size();i++){
        if(s[i]=='W' && s[i+1]=='B') cnt++;
        else if(s[i+1]=='W' && s[i]=='B') cnt++;


    }
    cout<<cnt;
    return(0);
}

Measured memory_bytes: 512