akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string s; cin >> s;
  int n = s.length();
  if (s[0] == '0' || s[n - 1] == '1') {
    cout << "-1\n";
    return 0;
  }
  REP(i, n - 1) {
    if (s[i] != s[n - 2 - i]) {
      cout << "-1\n";
      return 0;
    }
  }
  cout << "1 2\n";
  int now = 1;
  FOR(i, 1, n - 1) {
    cout << now + 1 << ' ' << i + 2 << '\n';
    if (s[i] == '1') now = i + 1;
  }
  return 0;
}


Measured memory_bytes: 1616
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		StringBuilder sb = new StringBuilder();
		
		int N = sc.nextInt();
		
		for (int i = 9 ; i >= 1 ; i--) {
			if (N % i == 0) {
				N = N / i;
				break;
			}
		}
		
		if (1 <= N && N <= 9) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23124
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = null;
         int[] arr = readArr(5, infile, st);
         for(int i=0; i < 5; i++)
            if(arr[i] == 0)
            {
               System.out.println(i+1);
               return;
            }
      }
      public static int[] readArr(int N, BufferedReader infile, StringTokenizer st) throws Exception
      {
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         return arr;
      }
   }

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

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

    int num = 1;
    for (int i = 0; i < N; i++) {
        if (num <= K) num *= 2;
        else {
            num += K;
        } 
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{

    int n;
    cin >> n;
    ll ans = 1;
    rep(i, n)
    {
        ans *= (i + 1);
        ans %= MOD;
        cerr << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    for(int i=X-K+1; i<X+K; i++){
    
    System.out.print(i + " ");
    }
}
}

Measured memory_bytes: 38500
#include<iostream>
#include<cstdio>
#include<cstring>
#include <fstream>
#include<string>
#include<sstream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
#include <math.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long long int MOD = 1000000007;
const int INF = 1000000007;
const double EPS = 1e-10;
const double PI = 3.14159265359;
const int N = 100005;
//cout << fixed << std::setprecision(9)
//--------------------------

int n;
ll a[404];
ll c[404];
ll dp[404][404];

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

	for (int k = 0; k < n; k++) {
		for (int i = 0; i + k < n; i++) {
			if (k == 0) {
				dp[i][i + k] = 0;
				continue;
			}
			dp[i][i + k] = (1ll << 50);
			for (int j = i; j + 1 <= i + k; j++) {
				dp[i][i + k] = min(dp[i][i + k], dp[i][j] + dp[j + 1][i + k]);
			}
			if (i == 0) dp[i][i + k] += c[i + k];
			else dp[i][i + k] += (c[i + k] - c[i - 1]);
		}
	}

	cout << dp[0][n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1536
from collections import defaultdict
X, N = map(int, input().split())
P = [int(x) for x in input().split()]

if N == 0:
    print(X)
    exit()

d = defaultdict(bool)
for i in P:
    d[i] = True

i = 0
while True:
    if not d[X - i]:
        print(X - i)
        break
    elif not d[X + i]:
        print(X + i)
        break
    else:
        i += 1


Measured memory_bytes: 9496
dic = dict()
n , k = map(int,input().split())

for _ in range(n):
    a , b = map(int,input().split())
    dic.setdefault(a , 0)
    dic[a] += b
    
sdic = sorted(dic.items(), key = lambda x : x[0])

for i in range(n):
    k -= sdic[i][1]
    
    if k <= 0:
        print(sdic[i][0])
        break

Measured memory_bytes: 53976
def insertion_sort arr, gap
    [*1...arr.length].each do |i|
        v = arr[i]
        j = i - gap
        while (j >= 0) && (v < arr[j])
            arr[j + gap] = arr[j]
            j -= gap
            @cnt += 1
        end
        arr[j + gap] = v
    end
    arr
end

def shell_sort arr
    # 間隔：gaps = [1, 4, 13, 40, 121, 364, 1093, ... ] (gaps[i] = gaps[i-1] * 3 + 1)
    @cnt = 0; gap = 1; gaps = []
    while gap <= arr.length
        gaps << gap
        gap = gap * 3 + 1
    end

    # 間隔指定のinsertion_sortを繰り返す
    gaps.reverse.reduce arr do |acc, gap|
        insertion_sort acc, gap
    end

    # 解答の出力
    puts gaps.length
    puts gaps.reverse.join(' ')
    puts @cnt
    puts arr
end

#-- main
arr = []
gets.to_i.times { arr << gets.to_i }
shell_sort arr


Measured memory_bytes: 106356
def solve(items)
  count = 0
  return "NA" if items.all? {|x| x <= 1}
  items.each do |x|
    count += 1 if x >= 1
  end
  count + 1
end
loop do
  n = gets.to_i
  break if n == 0
  puts solve(gets.split(" ").map(&:to_i))
end

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

#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()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    vi a(n);
    map<int, int> m;
    rep(i, n) {
        cin >> a[i];
        m[a[i]] = i;
    }

    ll ans = 0;
    set<int> s = {-1, n};
    rep(i, n) {
        auto itr = s.lower_bound(m[i + 1]);
        ll r = *itr;
        itr--;
        ll l = *itr;
        // cout << i << " " << l << " " << m[i + 1] <<" " << r << endl;
        ans += (ll)(i + 1) * (m[i + 1] - l) * (r - m[i + 1]);
        s.insert(m[i + 1]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19840
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

int main() {
	lnt a,b;
	std::cin >> a >> b;
	print(a*b);
}


Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#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++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int cnt = 0;
  if((A+B)%2 == 1 && (A+C)%2 == 1){
    B++;
    C++;
    cnt++;
  }
  else if((B+C)%2 == 1 && (B+A)%2 == 1){
    C++;
    A++;
    cnt++;
  }
  else if((C+A)%2 == 1 && (C+B)%2 == 1){
    A++;
    B++;
    cnt++;
  }
  if(A >= B && A >= C){
    cnt += (A-B)/2 + (A-C)/2;
  }
  else if(B >= C && B >= A){
    cnt += (B-C)/2 + (B-A)/2;
  }
  else{
    cnt += (C-A)/2 + (C-B)/2;
  }
  cout << cnt << endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int N, X;
ll S[200];

ll dp[201][100000 + 1];

int main() {
	cin >> N >> X;
	for (int i = 0; i < N; i++)cin >> S[i];
	sort(S, S + N, greater<ll>());

	dp[0][X] = 1;
	for (int i = 0; i < N; i++) {
		for (int amari = 0; amari <= X; amari++) {
			//今見てるのを確定減少列にいれる
		//	if (amari >= S[i] ) {
				dp[i + 1][amari % S[i]] += dp[i][amari];
				dp[i + 1][amari % S[i]] %= MOD;
		//	}
			//いれない
			dp[i + 1][amari] += dp[i][amari] * (N - 1 - i);
			dp[i + 1][amari] %= MOD;
		}
	}
	ll ans = 0;

	for (int i = 0; i <= X; i++) {
		ans += i * dp[N][i];
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 156544
from collections import Counter

n, k = map(int,input().split())
a = list(map(int,input().split()))

a_count = Counter(a)

a_c = []
for i in a_count:
    a_c.append([int(i),a_count[i]])

a_c_sort = sorted(a_c,key=lambda x:x[1])

ans = 0
if k >= len(a_c_sort):
    print(0)
else:
    for i in range(len(a_c_sort)-k):
        ans += a_c_sort[i][1]
    print(ans)

Measured memory_bytes: 48176
import java.util.Scanner;
class Main{   
 public void yatary() {  
      Scanner sc = new Scanner(System.in); 
        int a; 
        int b;
        int c;
        int i;
        int x;
        int y=0;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
     for(i=a;i<=b;i++){
         x = c%i;
         if(x==0){
             y++;
     }
     }
     System.out.println(y);
     }
public static void main(String[] args){ 
    new Main().yatary();    
}
} 

Measured memory_bytes: 17324
from heapq import heappush, heappop

n,m = map(int,input().split())
heap = []

for i in map(int,input().split()):
    heappush(heap,i)

bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key = lambda x: -x[1])

for b,c in bc:
    for j in range(b):
        a = heappop(heap)
        if a < c:
            heappush(heap,c)
        
        else:
            heappush(heap, a)
            break
        
print(sum(heap))
    

Measured memory_bytes: 90520
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair
#define debug_vec(x, n) cout << (#x) << ": "; for(int i = 0; i < n; i++) cout << x[i] << (i == n - 1 ? "\n" : " ");
#define M_PI 3.14159265358979323846

typedef long long ll;
typedef long double ld;

void solve(){
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    ld ang1 = (2.0 * M_PI * h) / 12.0 + (M_PI * m) / (360.0);
    ld ang2 = (2.0 * M_PI * m) / 60.0;
    ld theta = min((2 * M_PI) - abs(ang1 - ang2), abs(ang1 - ang2));
    ld c = a * a + b * b - (2.0 * a * b * cos(theta));
    cout << fixed << setprecision(10) << sqrt(c) << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}



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

int main()
{	
	
	int n;
	while(cin>>n){
		if(n==0) return 0;
		
		int a[n], b[n];
		int a_cnt=0, b_cnt=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		for(int i=0;i<n;i++){
			if(a[i]>b[i]){
				a_cnt += a[i] + b[i];
			}else if(a[i]==b[i]){
				a_cnt += a[i]; b_cnt += b[i];
			}else{
				b_cnt += b[i] + a[i];
			}
		}
		cout<<a_cnt<<' '<<b_cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1236
import java.util.*

fun main(args: Array<String>) = FastScanner().run {
    val n = int()
    val k = long()
    val a = LongArray(n){long()}
    var g = a[0]
    for (i in 1 until a.size) g = gcd(g, a[i])
    var max = 0L
    for (i in a.indices) max = Math.max(max, a[i])
    println(if (k <= max && k % g == 0L) "POSSIBLE" else "IMPOSSIBLE")
}

fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

class FastScanner {
    private val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
}

Measured memory_bytes: 33984
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		label:while(true){
			int N = cin.nextInt();
			if(N==0){
				break;
			}
			boolean f = false;
			for(int i =0;i<12;i++){
				int a = cin.nextInt();
				int b = cin.nextInt();
				N = N - (a-b);
				if(!f&&N<=0){
					System.out.println(i+1);
					f = true;
				}
			}
			if(!f)
			System.out.println("NA");
		}
		
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(){
int n,d,x,a[100],b,i,ans=0;
scanf("%d %d %d",&n,&d,&x);
for(i=0;i<n;i++){
b=1;
scanf("%d",&a[i]);
do{
ans++;
b+=a[i];
}while(b<=d);
}
ans+=x;
printf("%d",ans);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	long int n,cnt = 0;cin >> n;
	long int monsters[n+1];
	long int heroes[n];
	for(long int i = 0;i <= n;i++)
		cin >> monsters[i];
	for(long int i = 0;i < n;i++)cin >> heroes[i];
	long int i = 0,k = 0;
	while(k < n && i <= n)
	{
		if(k == i || k + 1 ==  i)
		{
			if(monsters[i] > heroes[k])
			{
				cnt += heroes[k];
				monsters[i] -= heroes[k];
				heroes[k] -= heroes[k];
				k++;
			}
			else if(heroes[k] > monsters[i])
			{
				cnt += monsters[i];
				heroes[k] -= monsters[i];
				monsters[i] -= monsters[i];
				i++;
			}
			else if(heroes[k] == monsters[i])
			{
				cnt += heroes[k];
				heroes[k] = monsters[i] = 0;
				k++;
				i++;
			}
		}
		else
		{
			if(i > k)k++;
			else i++;
		}
	}
	cout << cnt;
	return 0;
}

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

int main(void){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x >= r && x + r <= W && y >= r && y + r <= H){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3108
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N,K = map(int,input().split())
A = np.array(input().split(), dtype=np.int64)

Acum = A.cumsum()
range_sums = Acum[:,None] - Acum[None,:] + A[None,:]

range_sums = range_sums.flatten()
range_sums = range_sums[range_sums>0]

def test(x):
    # xを部分集合に持つ値がK個以上ある
    return np.sum(range_sums & x == x) >= K

left = 0 # leftを部分集合に持つものがK個以上ある
right = 1<<40 # rightを部分集合に持つものはK個未満
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        left = mid
    else:
        right = mid
answer = left
print(answer)

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define gcd(x, y) int gcd(int x, int y) {return (y == 0) ? x : gcd(y, x % y);}
#define INF (1 << 30)

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

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int range[102];

int main() {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    range[a]++; range[b]--; range[c]++; range[d]--;
    FOR(i, 1, 102) range[i] += range[i - 1];
    int res = 0;
    rep(i, 101) if(range[i] == 2) ++res;
    printf("%d\n", res);
    return 0;
}

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

auto main() -> signed {
  int n, m, x;
  cin >> n >> m >> x;
  int V[n+1] = {0};
  for(int i=0; i<m; ++i) {
    int a;
    cin >> a;
    V[a]++;
  }

  int ans1 = 0;
  int ans2 = 0;
  int t = x;
  while(true) {
    if(t==0) break;
    if(V[t]) ans1++;
    t--;
  }
  t = x;
  while(true) {
    if(t==n) break;
    if(V[t]) ans2++;
    t++;
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<ll> t(n);
  rep(i,n) cin >> t[i];
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  ll ans = 1;

  rep(i,n) {
    ll a, b, c;
    a = ans;
    b = t[i];
    c = a % b;
    while (c != 0) {  // b = GCD
      a = b;
      b = c;
      c = a % b;
    }
    ans = ans / b * t[i];
  }

  cout << ans << endl;
  return 0;
}


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

 int main() {
   string S;
   cin >> S;
   
   bool ans = false;
   for(int i = 0; i < S.size(); i+= 2){
    // cout << S.at(i) << endl;
    if(S.at(i) == 'L'){
      ans = true;
    }   
   }
   for(int i = 1; i < S.size(); i+= 2){
    // cout << S.at(i) << endl;
    if(S.at(i) == 'R'){
      ans = true;
    }   
   }
   if(ans){
     cout << "No" << endl;
   }else{
     cout << "Yes" << endl;
   } 
 }

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

int main() {
  int N;cin>>N;
  if(N%10==9) cout << "Yes" << endl;
  else if(N >= 90 && N < 99) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
 
typedef long long ll;
typedef unsigned long long ull;
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
 
inline ll read()
{
    char c = getchar();
    ll ret = 0;
    while (c < '0' || c > '9') c = getchar();
    while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
    return ret;
}
 
#define MAXN 200005
int N;
ll arr[MAXN], K;
ull ans = 0, out;
 
ll get(ll x, int pos)
{
    return x & ((ll)1 << (pos - 1));
}
void set(ull &x, int pos)
{
    //printf("set(%lld, %d)\n", x, pos);
    x = x | ((ull)1 << (pos - 1));
}
bool flag = false;
int main()
{
    N = read(), K = read();
    int i, j;
    ll num1, choose;
    for (i = 1; i <= N; ++i) arr[i] = read();
    if (!K)
    {
        for (i = 1; i <= N; ++i) out += arr[i];
        printf("%lld\n", out);
        return 0;
    }
    //printf("%lld %lld %lld %lld\n", get(2, 2), get(15, 2), get(3, 2), get(16, 2));
    for (i = 50; i >= 1; --i)
    {
        if (((ll)1 << (i - 1)) > K) continue;
        num1 = 0;
        for (j = 1; j <= N; ++j) num1 += (bool)get(arr[j], i);
        //printf("(%d) %lld\n", i, num1);
        if (num1 * 2 >= N) choose = 0;
        else choose = 1;
        if (!flag)
        {
            if (get(K, i))
            {
                if (!choose) flag = 1;
            }
            else choose = 0;
        }
        set(ans, i);
        if (!choose) ans -= ((ll)1 << (i - 1));
        //printf("(%d, %lld)\n", i, choose);
    }
    //printf("ans=%lld\n", ans);
    //ans = 0;
    for (i = 1; i <= N; ++i) out += arr[i] ^ ans;
    printf("%lld\n", out);
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int b[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	int t=1;
	for(int i=0;i<a;i++)t*=3;
	int d=1;
	for(int i=0;i<a;i++){
		if(b[i]%2)d*=1;
		else d*=2;
	}
	t-=d;
	printf("%d\n",t);
}

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

int main() {
    
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2 == 1) {
		cout << "No" << endl;
	}
	else {
		for (int i=0; i+i < n; i++) {
			if (s[i] != s[i+n/2]) {
				cout << "No" << endl;
				exit(0);
			}
		}
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	if (ans == 1)
		ans = 10;
	printf("%d\n", ans);
	return 0;
}

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    int X,Y;
    cin >> X >> Y;
    for(int i=0;i<=X;i++){
        if(i*2 + (X-i)*4 == Y){
            cout << "Yes" << endl;
            exit(0);
        } 
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
#include <cstdlib>
#include <vector>
using namespace std;

int main(){
	int n;
	cin>>n;
	int ar[90];
	int m=0,s=0;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			ar[m]=i*j;
			m++;
		}
	}
	for(int k=0;k<90;k++){
		if(ar[k]==n){
			s=1;
		}

	}
	if(s==1){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

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

int main() {
  int n;
  cin>>n;
  if(n%2==0){
    cout<<(n-2)*n/2<<endl;
    for(int i=1;i<=n-1;i++){
      for(int j=i+1;j<=n;j++){
        if(i+j!=n+1){
          cout<<i<<" "<<j<<endl;
        }
      }
    }
    return 0;
  }
  int count=n-1;
  int vec[n];
  for(int i=1;i<n;i++){
    vec[i]=(n*(n-1)/2)-n;
  }
  for(int i=1;i<n-1;i++){
    for(int j=n-1;j>i;j--){
      if(i+j!=n){
        vec[i]-=j;
        count++;
      }
    }
  }
  cout<<count<<endl;
  for(int i=1;i<n;i++){
    cout<<i<<" "<<n<<endl;
  }
  for(int i=1;i<n-1;i++){
    for(int j=n-1;j>i;j--){
      if(i+j!=n){
        cout<<i<<" "<<j<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val data = mutableListOf<Triple<Long, Long, Long>>()
    for (i in 1..n) {
        val (a, b) = readLine()!!.split(' ').map(String::toLong)
        data.add(Triple(a + b, a, b))
    }
    data.sortBy { -it.first }
    var sum = 0L
    for (i in 1..n) {
        sum += if (i % 2 == 1L) data.first().second else -data.first().third
        data.removeAt(0)
    }
    println(sum)
}


Measured memory_bytes: 63172
def do_cd(possession, queue, k)
  #p [:cd, possession, queue, k]
  if k == 0 || possession.empty?
    possession.inject(0,:+)
  else
    possession = possession.sort
    possession.drop([possession.count { |n| n < 0 }, k].min).inject(0,:+)
  end
end

def do_b(possession, queue, k)
  #p [:b, possession, queue, k]
  if k == 0
    possession.inject(0,:+)
  else
    if queue.size == 0
      do_cd(possession, queue, k)
    else
      [do_b(possession + [queue[-1]], queue[0..-2], k - 1),
       do_cd(possession, queue, k),
       possession.inject(0,:+)].max
    end
  end
end

def do_a(possession, queue, k)
  #p [:a, possession, queue, k]
  if k == 0
    possession.inject(0,:+)
  else
    if queue.size == 0
      do_cd(possession, queue, k)
    else
      [do_a(possession + [queue[0]], queue.drop(1), k - 1),
       do_b(possession, queue, k),
       possession.inject(0,:+)].max
    end
  end
end

n, k = gets.split.map(&:to_i)
queue = gets.split.map(&:to_i)

puts do_a([], queue, k)


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

int main() {
  string s;
  int n;
  int i,j,c,k;
  string ans="Yes";
  
  cin >> s;

  n=(int)s.length();
  //条件1
  for(i=0,j=n-1;i<n/2;i++,j--) {
    if(s[i]!=s[j]) {
      ans="No";
    }
  }
  //条件２
  if(ans=="Yes") {
    for(i=0,j=((n-1)/2)-1;i<((n-1)/2)/2;i++,j--) {
      if(s[i]!=s[j]) {
      
      ans="No";
      }
    }
  }
  c=i+1;
  k=0;
  //条件3
  if(ans=="Yes") {
    for(i=((n+3)/2)-1,j=n-1;k<c;i++,j--,k++) {
      if(s[i]!=s[j]) {
        ans="No";
      }
    }
  }
  cout << ans << endl;




  return 0;
}


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

using namespace std;

int main(){

	int H,W;
	cin >> H >> W;
	
	string s[H][W];
	string temp[H];
	
	for(int i=0;i<H;i++){
		cin>>temp[i];
		int j=0;
		for(auto x:temp[i]){
			s[i][j]=x;
			j++;
		}
	}

	bool ans = true;


	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=="#"){
				bool up = false;
				bool left = false;
				bool down = false;
				bool right = false;
				if(i-1>=0){up = (s[i-1][j]=="#");}
				if(j-1>=0){left = (s[i][j-1]=="#");}
				if(i+1<H){down = (s[i+1][j]=="#");}
				if(j+1<W){right = (s[i][j+1]=="#");}
				
				if(up||left||down||right){continue;}
				else{
					//bool ans = false;
					cout << "No" <<endl;
					return 0;
				}
			}
			
		}
	}
	
	if(ans){
		cout << "Yes" <<endl;
	}

	
	return 0;

}

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

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

  if (a < b && b < c) {
  	cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>


int main(void){
    int N;
    scanf("%d",&N);
    long long int a[N],b[N];
    long long int ans=0;
    long long int min=1000000007;
    int zero=1;
    for(int i=0;i<N;i++){scanf("%lld %lld",&a[i],&b[i]);if(a[i]!=b[i])zero=0;ans+=b[i];if(a[i]>b[i]&&b[i]<min)min=b[i];}
    if(zero==1)printf("0");
    else printf("%lld",ans-min);
    return 0;
}


Measured memory_bytes: 512
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        int k = s.nextInt();
        int x = a+b;
        int y = x+c;
        if(k<a)
            System.out.println(k);
        else if(k < x)
            System.out.println(a);
        else if(k<=y)
            System.out.println(a+x-k);
    }
}


Measured memory_bytes: 35796
/*
  Input: the input contains many data sets. First line in 
each data set are two integers: N (no of intervals) and M 
(amount of funding). There will be N lines ollowing the 
first line, and each line contains two integers: Di 
(distance of interval i) and Pi (level of danger of intercal
i). Imput ends when N=0, M=0 data set appears.

  Order of computation: we can compute the order of 
computation for each data set:
	3N+2N*log2(N)+MN+N => Order=4N+MN+2N*log2(N)

  The program takes 0.29 second to solve 93 cases.
*/

#include <algorithm>
#include <iostream>
#include <utility>
#include <math.h>
using namespace std;

int N, M; // N: No of intervals, M: funding
pair<int,int> PD[10010];
int main(){
	// put in data
	while (cin >> N >> M && N){
		int d, p; // d: distance, p: lv of danger
		for (int i=0; i<N; ++i){ 
		//Order=3N
			cin >> d >> p; 
			// Not sure whether this counts as 1 or 2
			PD[i] = make_pair(p, d);
		}
	// sort
		sort(PD, PD+N, greater<pair<int, int> >()); // modified
		// Order=2N*log2(N) 
		// I doubled complexity since it is a pair (not sure as well)
	// hire guards
		int index=0;
		while (M>0 && index<N){ 
		// Worst scenario:Order=MN ???actually Pmax*N...????
			if (PD[index].second != 0){
				PD[index].second--;
				M--;
			} else {
				index++;
			}
		}
	// evaluate risk
		int result=0;
		for (int i=0; i<N; ++i){
		// Order=N
			result += PD[i].first*PD[i].second;
		}	
	cout << result << endl;
	}
}

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

int main() {
  ll h;
  cin >> h;
  ll cnt = 0;
  ll one = 1;
  ll shift = 1;
  while (true) {
    ll temp = one << shift;
    if (h < temp) {
      break;
    }
    shift++;
  }
  // cout << shift << endl;
  ll total = 0;
  rep(i, shift) {
    total += one << i;
  }
  cout << total << endl;
  return 0;
}

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

int main() {
  int N,K,x,y;
  cin >> N >> K;
  while (N>0) {
    cin >> x;
    if (x > K/2) y+=2*(K-x);
    else y+=2*x;
    N--;
  }
  cout << y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define double long double 
#define ll  long long 
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define nl "\n"
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)(x.size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define god ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//----------------------------------------------------------------------------------------------------------------------------------------------------

const double pi = 3.14159265358979323;
int mod=1000000000+7;
int modu=998244353;
const double pii=acos(-1.0);
const int INF=1e18;
const int inf=1e9;

//----------------------------------------------------------------------------------------------------------------------------------------------------

ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
bool isPrime(int n){for(int i=2;i*i<=n;i++)if(n%i==0) return false;return true;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll add(ll a, ll b){return((a % mod + b % mod) % mod);}
ll sub(ll a, ll b){return((a % mod - b % mod + mod) % mod);}
ll mul(ll a, ll b){return(((a % mod) * (b % mod)) % mod);}
ll divi(ll a, ll b){return(mul(a, powe(b, mod - 2)) % mod);}


//-------------------------------------------------------------------------------------------------------------------------------------------------------

void fun()
{
	
	//786
}

//-------------------------------------------------------------------------------------------------------------------------------------------------------

const int N = 2e5+7;

//--------------------------------------------------------------------------------------------------------------------------------------------------------

void pre()
{
	
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------
signed main() 
{
	god;
	//rko;
	fun();
	pre();
	int tttt=1; //cin>>tttt;
	while(tttt--)
	{
		int n; cin>>n;
		int sum = 0;
		map<int, int> m;
		for(int i=0;i<n;i++)
		{
			int x; cin>>x;
			m[x]++;
			sum += x;
		}
		int q; cin>>q;
		while(q--)
		{
			int a,b; cin>>a>>b;
			sum -= m[a] * a;
			sum += m[a] * b;
			m[b] += m[a];
			m.erase(a);
			cout<<sum<<nl;
		}
	}	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 7676
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct re
{
	int id;
	char name[105];
	int sc;
}a[105];
bool cmp(const re&a,const re&b)
{
	return(strcmp(a.name, b.name) < 0 || (strcmp(a.name, b.name) == 0 && a.sc > b.sc));
}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
	
		scanf("%s",&a[i].name);
		scanf("%d", &a[i].sc);
		a[i].id = i + 1;
	}
	sort(a, a + n, cmp);
	for (int i = 0; i < n; i++)
		printf("%d\n", a[i].id);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-3;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll L[110];

int main(){
   ll N;
   cin >> N;
   rep(i,N) cin >> L[i];
   ll ans = 0;
   rep(i,N-2){
      FOR(j,i+1,N-1){
         FOR(k,j+1,N){
            if(L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i] && L[i] != L[j] && L[j] != L[k] && L[i] != L[k]){
               ans++;
            }
         }
      }
   }
   cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.*;
 
public class Main {
    public static void main(String args[]) {
        
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int[] p = new int[N];
       
       
       for (int i = 0;i<N;i++) {
            p[i] = sc.nextInt();
       }
       
       int count = 0; 
       int pj = p[0]; 
       
       for(int i = 0; i < N; i++) {
             if(p[i]<=pj) {
               ++count;
               pj = p[i]; 
           }
       }
       
       System.out.println(count);
    
        
    }
    
}

Measured memory_bytes: 60268
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

n = int(rl())
li = [list(map(int, rl().split())) for _ in range(n)]
dp = np.zeros((n, 3), dtype=int)
dp[0] = li[0]

for i in range(1, n):
    a = dp[i-1][1] + li[i][0]
    b = dp[i-1][2] + li[i][0]
    dp[i][0] = max(a, b)
    a = dp[i-1][0] + li[i][1]
    b = dp[i-1][2] + li[i][1]
    dp[i][1] = max(a, b)
    a = dp[i-1][0] + li[i][2]
    b = dp[i-1][1] + li[i][2]
    dp[i][2] = max(a, b)
print(max(dp[-1]))

    



Measured memory_bytes: 41828
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b;
  cin>>a>>b;
  
  cout<<((a%500)<=b ? "Yes" : "No");

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

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

  int tp = 0; int hp = 0;
  string ts; string hs;
  for (int i = 0; i < n; i++) {
    cin >> ts >> hs;
    if (ts == hs) {
      tp++; hp++;
    } else if (ts < hs) {
      hp += 3;
    } else {
      tp += 3;
    }
  }
  printf("%d %d\n", tp, hp);
  return 0;
}



Measured memory_bytes: 3284
'''
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
'''
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n = int(readline())
  xyh = list(list(map(int, readline().split()))for _ in range(n))
  xyh.sort(key=lambda x:x[2], reverse=True)
  for cx in range(101):
    for cy in range(101):
      H = abs(xyh[0][0]-cx) + abs(xyh[0][1]-cy) + xyh[0][2]
      for i in range(n):
        if xyh[i][2] > 0:
          if abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy) + xyh[i][2] != H:
            break
        else:
          if abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy) < H:
            break
      else:
        print(cx, cy, H)
        sys.exit()
  
  
  
  
  
if __name__ == '__main__':
  main()

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

int main() {
  string c ;
  cin >> c ;
  if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o" ){
    cout << "vowel" << endl;
  }
  else {
    cout  << "consonant" << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll x;
    cin >> x;
    ll a=100, b=0;
    while(a<x){
        a *=1.01;
        b++;
    }
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 3636
// D - Prediction and Restriction
#include <bits/stdc++.h>
using namespace std;

map<char,char> win={{'r','p'},{'s','r'},{'p','s'}};
map<char,int> point={{'r',0},{'s',0},{'p',0}};

int main(){
	int N,K; string T;
	cin>>N>>K>>point['r']>>point['s']>>point['p']>>T;
	int ans = 0;
	for(int i=0; i<N; ++i){
		ans += point[win[T[i]]];
		if(i-K >= 0 && T[i-K] == T[i]){
			ans -= point[win[T[i]]];
			if(i+K < N && T[i] == T[i+K]) T[i] = win[win[T[i]]];
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 512
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String S=sc.next();
		for(int i=0;i<S.length();++i) {
			System.out.print("x");
		}
		System.out.println();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<vector<int>>v(10,vector<int>(10,0));

int top(int n) {
	while (n > 9) {
		n /= 10;
	}
	return n;
}

int main() {
	int n;
	cin >> n;
	rep(i, 1, n + 1) {
		v[top(i)][i % 10]++;
	}
	ll ans = 0;
	rep(i, 1, 10) {
		rep(j, 1, 10) {
			ans += v[i][j] * v[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;

int main(){
    string s,t; cin >> s >> t;
    s += s;
    int n = s.size(),N = t.size();

    for(int i = 0;i < n;i++){
        if(s[i] == t[0]){
            bool ok = true; int k = 0;
            for(int j = i;j < i + N;j++){
                if(s[j] == t[k]) {
                    k++;
                    continue;
                }
                ok = false;
            }if(ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)

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

    int n;
    cin >> n;

    ll a_sum = 0;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        a_sum += a[i];
    }

    ll ans;
    rep(i, n) {
        if (i == 0) {
            ans = a_sum;
            for (int j = 1; j < n; j+=2) {
                ans -= (ll)2 * a[(i+j)%n];
            }
        } else {
            ans = (ll)2 * a[i-1] - ans;
        }
        cout << ans << (i==n-1?"\n":" ");
    }
}


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

#define ll long long int
#define hell 1000000007
#define vi vector <ll>
#define pb push_back
#define pii pair<ll,ll>
#define vii vector <pii>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sep(i,a,b)  for(ll i=a-1;i>=b;i--)
#define inf (ll)(1e16)

using namespace std;

vi pre;

ll helper(vi &a,ll s,ll e,vector < vi > &dp)
{
    if(s>=e)
        return 0;
    if(dp[s][e]!=-1)
        return dp[s][e];
    ll ans,l,r;
    ans=inf;
    rep(i,s+1,e+1)
    {
        l=helper(a,s,i-1,dp);
        r=helper(a,i,e,dp);
        ans=min(ans,l+r+pre[e+1]-pre[s]);
    }
    return dp[s][e]=ans;
}

void solve()
{
    ll n;
    cin>>n;
    vi a(n);
    rep(i,0,n)
        cin>>a[i];
    vector < vi > dp(n+5,vi(n+5,-1));
    pre.resize(n+2);
    pre[0]=0;
    rep(i,1,n+1)
        pre[i]=pre[i-1]+a[i-1];
    cout<<helper(a,0,n-1,dp);
}

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


Measured memory_bytes: 1664
#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(){
	string s;
	cin >> s;
	rep(i, s.size()){
		if(s.at(i) == 'P'){
			cout << 'P';
		}else{
			cout << 'D';
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3752
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x=int(readline())

    n=x//11
    m=x%11
    if m==0: print(2*n)
    elif 1<=m<=6: print(2*n+1)
    else: print(2*n+2)

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
s = raw_input()
n = int(s)
dp = [0 for _ in range(n+1)]
dp[0] = 0
dp[1] = 1
maxl, num = 1, 1
for i in range(2, n+1):
    if i % 2 == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i/2] + 1
        if dp[i] > maxl:
            maxl = dp[i]
            num = i
print num

Measured memory_bytes: 2568
import java.util.*;
import java.math.*;
import java.text.*;

public class Main{

    public static void main(String args[]){
       Scanner sc = new Scanner(System.in);
		BigDecimal l = new BigDecimal(sc.nextLine());
		BigDecimal three = new BigDecimal("3");
		//DecimalFormat df = new decimalFormat("0.000000000000"):
		BigDecimal res = l.divide(three, 12, RoundingMode.HALF_UP).pow(3);
		
		System.out.println(res);
    }
	
	public static boolean isKai(String s){
		return s.equals(new StringBuilder(s).reverse().toString());
	}
}




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

using namespace std;

string number[10] = {"* = ****",
                     "* =* ***",
		     "* =** **",
		     "* =*** *",
		     "* =**** ",
		     " *= ****",
		     " *=* ***",
		     " *=** **",
		     " *=*** *",
		     " *=**** "};
int main(){
    string str;
    int tcase = 0;
    while( cin >> str ){
	while( str.size() < 5 ) str = "0" + str;

	if ( tcase++ ) cout << endl;
	for ( int i = 0; i < 8; i++ ){
	    for ( int j = 0; j < 5; j++ ){
		cout << number[str[j]-'0'][i];
	    }
	    cout << endl;
	}
	
    }

    return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#define ios std::ios::sync_with_stdio(false) , std::cin.tie(0) , std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,n,a) for (int i=n;i>=a;i--)
#define ll long long
#define fi first
#define se second
#define pb push_back
#define debug(x) 			  cout << #x << ": " << x << endl
#define debug2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define debug3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define debug4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
using namespace std;
template<typename T>void read(T &res){bool flag=false;char ch;while(!isdigit(ch=getchar()))(ch=='-')&&(flag=true);
for(res=ch-48;isdigit(ch=getchar());res=(res<<1)+(res<<3)+ch - 48);flag&&(res=-res);}
template<typename T>void Out(T x){if(x<0)putchar('-'),x=-x;if(x>9)Out(x/10);putchar(x%10+'0');}

const int N = 2e5 + 10;
int n,a[N],per[N],suf[N];
int main()
{
	cin >> n;
	rep(i,1,n) cin >> a[i];
	rep(i,1,n){
		per[i] = __gcd(per[i-1],a[i]);
		suf[n - i + 1] = __gcd(suf[n - i + 2],a[n - i + 1]);
	}
	int ans = 1;
	rep(i,1,n) ans = max(ans, __gcd(per[i-1],suf[i+1]));
	cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 4736