akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	static ArrayList<Integer> ans = new ArrayList<>();
	static int l;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		if (str.length == 2) {
			if (str[0].equals(str[1])) {
				System.out.println((1) + " " + (2));
				return;
			}
		} else {
			for (int i = 0; i < str.length - 3; i++) {
				if (str[i].equals(str[i + 1]) || str[i].equals(str[i + 2]) || str[i + 1].equals(str[i + 2])) {
					System.out.println((i + 1) + " " + (i + 3));
					return;
				}
			}
		}
		System.out.println("-1 -1");

		/*
		 * String str[] = br.readLine().split(" "); int n = Integer.parseInt(str[0]); l
		 * = Integer.parseInt(str[1]);
		 * 
		 * int a[] = new int[n]; str = br.readLine().split(" ");
		 * 
		 * for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(str[i]); }
		 * 
		 * int min = 0; int minN = 0;
		 * 
		 * for (int i = 0; i < n - 1; i++) { int sum = a[i] + a[i + 1]; if (sum >= l) {
		 * System.out.println("Possible"); for (int j = 0; j < i; j++) {
		 * System.out.println(j + 1); } for (int j = n - 2; j > i; j--) {
		 * System.out.println(j + 1); } System.out.println(i + 1); System.exit(0); } }
		 * 
		 * System.out.println("Impossible");
		 */
	}
	/*
	 * static boolean isPossible(int a[], int add) { int min = Integer.MAX_VALUE;
	 * int minN = 0; int sum = 0;
	 * 
	 * if (a.length == 1) return true;
	 * 
	 * for (int i = 0; i < a.length; i++) { if (min >= a[i]) { min = a[i]; minN = i;
	 * } sum += a[i]; }
	 * 
	 * if (sum < l) return false;
	 * 
	 * int lSum = 0; int rSum = 0;
	 * 
	 * int lSize = 0; int rSize = 0;
	 * 
	 * if (minN == 0) minN = 1;
	 * 
	 * for (int i = 0; i < minN; i++) { lSum += a[i]; lSize++; }
	 * 
	 * for (int i = minN; i < a.length; i++) { rSum += a[i]; rSize++; }
	 * 
	 * // System.out.println(lSize + " " + rSize);
	 * 
	 * if ((rSum < l && rSize > 1) || (lSum < l && lSize > 1)) return false;
	 * 
	 * int lA[]; int rA[];
	 * 
	 * lA = new int[lSize]; rA = new int[rSize]; System.arraycopy(a, 0, lA, 0,
	 * lSize); System.arraycopy(a, minN, rA, 0, rSize);
	 * 
	 * ans.add(minN + add);
	 * 
	 * // System.out.println(minN + " " + lSum + " " + rSum);
	 * 
	 * if (isPossible(lA, 0) && isPossible(rA, minN + add)) return true; return
	 * false; }
	 */
}


Measured memory_bytes: 29268
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>

typedef long long ll;
const int N = 1e5 + 9;

int n, a[N], t[N];
ll f[N << 2], INF;

void addmin(ll &x, ll y) {
	x = std::min(x, y);
}

ll dfs(int st) {
	if (st == 0) return 0;
	if (f[st] != INF) return f[st];
	for (int i = 0; i < 16; ++i) if ((st >> i) & 1)
		for (int j = 0; j < 16; ++j) if (((st >> j) & 1) && i != j) {
			int st_ = st ^ (1 << (i ^ j)) ^ (1 << i) ^ (1 << j);
			if (st >> (i ^ j) & 1)
				addmin(f[st], dfs(st_) + 2);
			else
				addmin(f[st], dfs(st_) + 1);
		}
	return f[st];
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		++u, ++v;
		a[u] ^= w, a[v] ^= w;
	}
	ll ans = 0;
	int st = 0;
	for (int i = 1; i <= n; ++i) t[a[i]]++;
	for (int i = 1; i < 16; ++i) {
		ans += t[i] / 2;
		st |= (1 << i) * (t[i] & 1);
	}
//	printf("%d\n", st);
	memset(f, 0x3f, sizeof f);
	INF = f[0];
	f[0] = 0;
	printf("%lld\n", dfs(st) + ans);
	return 0;
}

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

using namespace std;

int main()
{   
    int a, b, c, d;
    
    cin >> a >> b >> c >> d;
    
    if(abs(a - c) <= d) puts("Yes");
    else if(abs(a - b) <= d && abs(b - c) <= d) puts("Yes");
    else puts("No");
    
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n;
  cin >> n;

  cout << n * n * n << "\n";
}

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

if B - A <= 2 or K - 1 < A:
    print(K + 1)
else:
    if (K - A + 1) % 2 == 0:
        print(A + (B - A) * ((K - A + 1) // 2))
    else:
        print(1 + A + (B - A) * ((K - A + 1) // 2))

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

int main()
{
  long long n, m;
  cin >> n >> m;
  atcoder::dsu uf(n);
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.merge(a, b);
  }
  auto groups = uf.groups();
  cout << groups.size() - 1 << endl;
}

Measured memory_bytes: 8924
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	int X = s.nextInt();
	int T = s.nextInt();
	
	if(N%X == 0){
		System.out.println(T*(N/X));
	}else{
		System.out.println(T*(N/X+1));
	}
	

    
  }
}

Measured memory_bytes: 35592
#include<stdio.h>
#define MAX 100000
#define INF 1000000000

typedef struct card{
  char s;
  int v;
}Card;

void merge(Card A[],int l,int m,int r){
  Card R[MAX/2+2],L[MAX/2+2];
  int i,j,k;
  int n1,n2;
  n1 = m - l;
  n2 = r - m;

  for(i=0;i<n1;i++){
    L[i] = A[l+i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[m+i];
  }
  L[n1].v = INF;
  R[n2].v = INF;
  i = 0;
  j = 0;

  for(k=l;k<r;k++){
    if(L[i].v <= R[j].v){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}


void mergeSort(Card A[],int l,int r){
  int m;
  if(l + 1 < r){
    m = (l+r)/2;
    mergeSort(A,l,m);
    mergeSort(A,m,r);
    merge(A,l,m,r);
  }
}

int partition(Card A[],int p,int r){
  Card tmp,x;
  int i,j;

  x = A[r];
  i = p - 1;
  for(j=p;j<r;j++){
    if(A[j].v <= x.v){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;

  return i + 1;
}
void quickSort(Card A[],int p,int r){
  int q;
  if(p<r){
    q = partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}


int main(){
  int i,j,n,v,stable = 0;
  Card A[MAX],B[MAX];
  char s;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&s,&v);
    A[i].s = B[i].s = s;
    A[i].v = B[i].v = v;
  }

  mergeSort(A,0,n);
  quickSort(B,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].s != B[i].s) stable = 1;
  }

  if(stable == 0)printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].s,B[i].v);
  }
  return 0;
}

Measured memory_bytes: 2948
#include<iostream>
using namespace std;
int main(void)
{
	int i,n,answer=0;
	char s[51];
	cin>>n>>s;
	for(i=0;i<n-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			answer++;
		}
	}
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val lines = readLine()!!.split(" ").map {it.toInt()}

    val res1 = lines[0] * 2 - 1
    val res2 = lines[0] + lines[1]
    val res3 = lines[1] * 2 - 1

    print(arrayListOf(res1, res2, res3).max())
}

Measured memory_bytes: 37820
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}
long comb(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
using namespace std;
/*int main(){
    int n;std::cin >> n;
    int keta=0;
    while(true){
        keta++;
        if(n/10==0)break;
        n=n/10;
    }
    keta=keta-1;
    if(n>=7)n=3;
    else if(n>=5)n=2;
    else if(n>=3)n=1;
    int k=0;
    for(int i=3;i<=keta;i++){
        k+=comb(i-1,2);
        std::cout << k << std::endl;
    }std::cout << k << std::endl;
    k+=n*(keta);
    
    std::cout << k << std::endl;
    
}


*/
int main(){
  int n;
  std::cin >> n;
  std::vector<string> a(n);
  rep(i,n)std::cin >> a[i];
  rep(i,n-1){
      char usiro=a[i].at(a[i].size()-1);
      char mae=a[i+1].at(0);
      if(usiro!=mae){
          std::cout << "No" << std::endl;
          return 0;
      }
      for(int j=i+1;j<n;j++){
          if(a[i]==a[j]){
          std::cout << "No" << std::endl;
          return 0;
      }
      }
  }
  std::cout << "Yes" << std::endl;
}










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

int main(){
  int N;
  int d[110];
  cin >> N;
  for (int i=0;i<=N;++i) cin >> d[i];
  
  int num[110]={0};
  for (int i=0;i<N;++i){
    num[d[i]]++;
  }
  int res =0;
  for (int i=1;i<=100;++i){
    if (num[i]>0){
      ++res;
    }
  }
  cout << res <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

#define mod 1000000007

using namespace std;

typedef long long ll;

void printv(vector<vector<ll>> v) {
    ll i, j;

    for (i = 0; i < v.size(); i++) {
        for (j = 0; j < v.front().size(); j++) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<ll>> A(H + 1, vector<ll>(W + 2, 0));
    ll h, x;
    ll X, Y, Z;
    int Fibo[] = {1, 1, 2, 3, 5, 8, 13, 21, 34};

    A[0][1] = 1;
    for (h = 0; h < H; h++) {
        for (x = 1; x <= W; x++) {
            // X
            if (x == W) {
                X = Fibo[(W - 1 - 2) + 1];
            }
            else {
                X = Fibo[(x - 1 - 2) + 1] * Fibo[(W - x - 1) + 1];
            }

            // Y
            if (x == 1 || x == W) {
                Y = Fibo[(W - 1 - 1) + 1];
            }
            else {
                Y = Fibo[(x - 1 - 1) + 1] * Fibo[(W - x - 1) + 1];
            }
            
            // Z
            if (x == 1) {
                Z = Fibo[(W - 1 - 2) + 1];
            }
            else {
                Z = Fibo[(x - 1 - 1) + 1] * Fibo[(W - x - 2) + 1];
            }

            A[h + 1][x] += Y * A[h][x];
            A[h + 1][x] %= mod;
            A[h + 1][x - 1] += X * A[h][x];
            A[h + 1][x - 1] %= mod;
            A[h + 1][x + 1] += Z * A[h][x];
            A[h + 1][x + 1] %= mod;

        }
    }
    // printv(A);

    cout << A[H][K] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	ll k,x,i,j,l,m;
	cin>>k>>x;
	i=x-k+1;
	for(j=0;j<2*k-1;j++)
	{
		cout<<i<<" ";
		i++;
	}
	//cout<<"\n";
	return 0;
}
	


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

int main(){
    string t;
    cin>>t;
    if(t[0]=='?'){
    if(t[1]=='D')
        t[0]='P';
    else
        t[0]='D';
     }  
    for(int i=1;i<t.length();i++)
    {
        if(t[i]=='?'){
            if(t[i-1]=='P')
                t[i]='D';
            else if(t[i+1]=='D' &&  t[i+1]=='D')
                 t[i]='P';
            else  if(t[i-1]=='D' && (t[i+1]=='P' || i==t.length()-1 || t[i+1]=='?'))
                t[i]='D';
            
            
           }
   }
    cout<<t;               
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll n,k;
  cin >> n >> k;
  n %= k;
  ll ans = min(n,k-n);
  cout << ans << endl;
  return 0;
}


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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int point[3];
	int n;
	int ave;
	int me_ave;
	bool has100point;

	while( true )
	{
		n = in();
		if( n == 0 )break;
		for(int i = 0; i < n; i++)
		{
			ave = me_ave = 0;
			has100point = false;
			for(int j = 0; j < 3; j++)
			{
				point[j] = in();
				if( point[j] == 100 )has100point = true;
			}
			ave = (point[0] + point[1] + point[2]) / 3;
			me_ave = (point[0] + point[1]) / 2;
			if( has100point || me_ave >= 90 || ave >= 80 )
			{
				puts("A");
			}
			else if( ave >= 70 || (ave >= 50 && (point[0] >= 80 || point[1] >= 80)) )
			{
				puts("B");
			}
			else
			{
				puts("C");
			}
		}
	}
	return (0);
}

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

using namespace std;

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

  string tmp;
  long long int cnt[5] = {};
  for(int i = 0; i < N; i++) {
    cin >> tmp;
    if(tmp[0] == 'M') cnt[0]++;
    else if(tmp[0] == 'A') cnt[1]++;
    else if(tmp[0] == 'R') cnt[2]++;
    else if(tmp[0] == 'C') cnt[3]++;
    else if(tmp[0] == 'H') cnt[4]++;
  }

  long long int ans = 0;
  int I[] = {4,4,4,4,4,4,3,3,3,2};
  int J[] = {3,3,3,2,2,1,2,2,1,1};
  int K[] = {2,1,0,1,0,0,1,0,0,0};
  
  for(int t = 0; t < 10; t++) {
    int i = I[t], j = J[t], k = K[t];
    ans += cnt[i] * cnt[j] * cnt[k];
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n, t = gets.split(" ").map{|v|
	v.to_i
}

a = gets.split(" ").map{|v|
	v.to_i
}

num = 0
@min = 1000000000 + 1
margin = 0
a.each { |pre|
	if (pre - @min > margin)
		margin =  pre - @min
		num = 1
	elsif (pre - @min == margin)
		num += 1
	end
	
	if (pre < @min )then
		@min = pre
	end
	
}

puts num


Measured memory_bytes: 8588
/** 半径 r の円の面積と円周の長さを求めるプログラムを作成して下さい。
 */

/*sucannerクラス使うためにインポート*/
import java.util.Scanner;
class Main{
	//プログラムのエントリポイント
	public static void main(String[] args){
		//入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		//数字を１つうけとる
		double dbr = sc.nextDouble();
		//mathクラスから円周率を変数dbensuuに入れる
		double dbensyuu = Math.PI;
		//結果表示
		//表示時、浮動小数は5桁までに設定して表示
		System.out.printf("%.5f  %.5f" ,  dbr * dbr * dbensyuu , (dbr + dbr) * dbensyuu);
	}
}

Measured memory_bytes: 18952
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int[] abc = new int[3];
      	for(int i = 0; i < 3; i++){
        	abc[i] = sc.nextInt();
        }
      	Arrays.sort(abc);
      	System.out.println(abc[0]+abc[1]);
    }
}

Measured memory_bytes: 35660
#include <stdio.h>
#include <algorithm>
using namespace std;

long long L; int N,X[200200]; long long P[200200],Q[200200],SP[200200],SQ[200200];

int main()
{
#ifdef __LOCAL
	freopen ("input.txt","r",stdin);
#endif

	scanf ("%lld %d",&L,&N);
	for (int i=1;i<=N;i++){
		scanf ("%d",&X[i]);
		SP[i] = X[i];
		SQ[i] = L - X[i];
	}

	for (int i=1;i<=N;i++){
		P[i] = P[i-1] + SP[i];
	}
	
	for (int i=N;i>=1;i--){
		Q[i] = Q[i+1] + SQ[i];
	}

	long long ans = 0;
	for (int i=0;i<=N;i++){
		int l = i, r = N - i;
		int m = (l < r ? l : r);

		long long s = (P[i] - P[i-m]) * 2 + (Q[i+1] - Q[i+1+m]) * 2 - min(SP[i],SQ[i+1]);
		if (ans < s)
			ans = s;

		if (l > r){
			long long s = (P[i] - P[i-r-1]) * 2 - SP[i] + (Q[i+1] - Q[i+1+r]) * 2;
			if (ans < s)
				ans = s;
		}

		if (l < r){
			long long s = (P[i] - P[i-l]) * 2 + (Q[i+1] - Q[i+1+l+1]) * 2 - SQ[i+1];
			if (ans < s)
				ans = s;
		}
	}

	printf ("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 7168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = Long.parseLong(sc.next());
		long count = x / 11 * 2;
		long sum = count / 2 * 11;
		if (sum < x) {
			sum += 6;
			count++;
			if (sum < x) {
				sum += 5;
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23636
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, P = iim()
    S = list(map(int, input().rstrip()))

    if P == 2 or P == 5:
        cnt = 0
        for i, si in enumerate(S):
            if si % P == 0:
                cnt += i + 1
        print(cnt)
        return

    T = [0] * P
    T[0] = 1

    ss, p10 = 0, 1
    for s1 in S[::-1]:
        ss += p10 * s1
        ss %= P
        T[ss] += 1
        p10 = 10 * p10 % P

    ans = 0
    for i in T:
        ans += i*(i-1)//2
    print(ans)

if __name__ == "__main__":
    resolve()


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

int main(){
	int n;
	cin >> n;
	
	int ans=0;
	for(int i=1; i<n+1; i++){
        int res=i/10;
      	int cnt=1;
		while(res>0){
			res /=10;
			cnt++;
		}
		if(cnt%2!=0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
int size,posA,posB;
cin >> size >> posA >> posB;
if((posA-posB)%2==0){
cout << "Alice";
}
else{cout << "Borys";}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> vec;
    for(int i = 1; i <= n; i++) vec.push_back(i);
    do
    {
        for(int i = 0; i < n; i++)
        {
            if(i > 0) cout << " " << vec[i];
            else cout << vec[i];
        }
        cout << endl;
    }
    while(next_permutation(vec.begin(), vec.end()));
    return 0;
}




Measured memory_bytes: 3216
h,w=map(int,input().split())
g=[input() for _ in range(h)]
from collections import *
def bfs(x,y):
  d=[[-1]*w for _ in range(h)]
  d[x][y]=0
  q=deque([(x,y)])
  while q:
    tx,ty=q.popleft()
    for dx,dy in [(1,0),(0,1),(-1,0),(0,-1)]:
      nx,ny=tx+dx,ty+dy
      if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and d[nx][ny]<0:
        r=d[nx][ny]=d[tx][ty]+1
        q.append((nx,ny))
  return r
print(max(bfs(x,y) for x in range(h) for y in range(w) if g[x][y]=='.'))

Measured memory_bytes: 9236
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
	int n; cin >> n; int x[n], y[n], xy[2]={0,0};
	for(int i=0; i<n; i++) {
		cin >> x[i] >> y[i];
		xy[(x[i]+y[i])%2]=1;
	}
	if (xy[0] && xy[1]) {cout << -1 << endl; return 0;}
	vector<int> v;
	if (xy[0]) v.push_back(1);
	for(int i=1<<30; i>0; i>>=1) {
		v.push_back(i);
	}
	cout << v.size() << endl;
	for(int i=0; i<v.size(); i++) {
		cout << v[i] << " ";
	} cout << endl;
	for(int i=0; i<n; i++) {
		int xx=0, yy=0;
		for(int j=0; j<v.size(); j++){
			if (abs(x[i]) > abs(y[i])) {
				if (x[i] > 0) {x[i]-=v[j]; cout << "R";}
				else {x[i]+=v[j]; cout << "L";}
			} else {
				if (y[i] > 0) {y[i]-=v[j]; cout << "U";}
				else {y[i]+=v[j]; cout << "D";}
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 888
// みなさん私はカーティキー・シャルマです。LNMIITで勉強しています。私は2年目で、コロナパンデミックが発
// 生しています。世界は終わりそうだ。だから私はそれを最大限に生きたいと思っています。それはつまり、コー
// ドを最大限に意味しているのです。私の好きなアニメは「キメツノヤイバ」で、私の一番の男の子はゼニツで、
// 私の一番の女の子はネズコです。私の好きな呼吸スタイルは息吹です。私の最高の悪魔の血の芸術は、
// ククシボによって使用される月の息です。ムーザンは亡くなり、今ではタンジローがポップの新しい魔王です。
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, k;
      cin >> n >> k;
      map <lld, lld> count;
      for(lld i = 0; i < k; i++){
      	lld d;
      	cin >> d;
      	for(lld j = 0; j < d; j++){
      		lld r;
      		cin >> r;
      		count[r]++;
      	}
      }
      lld c = 0;
      for(lld i = 1; i<=n; i++){
      	if (count[i]==0){
      		c++;
      	}
      }
      cout << c;
      return 0;
}

Measured memory_bytes: 3668
n = int(input())
a = 0
w = 0
t = 0
r = 0
for i in range(n):
  s = input()
  if s == 'AC':
    a+=1
  elif s =='WA':
    w +=1
  elif s =='TLE':
    t +=1
  else:
    r+=1
print('AC x '+str(a))
print('WA x '+str(w))
print('TLE x '+str(t))
print('RE x '+str(r))

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define int long long
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

using Graph=vector<vector<int>>;

class StronglyConnectedComponents
{
 private:
    int N;
    Graph G,revG;
    vector<bool> visited;
    vector<int> vs,comp;
 public:
    StronglyConnectedComponents(Graph G):N(G.size()),G(G),visited(N,false),comp(N){
        revG.resize(N);
        for(int i=0;i<N;i++){
            for(int j:G[i]) revG[j].push_back(i);
        }
        for(int i=0;i<N;i++){
            if(!visited[i]) dfs(i);
        }
        fill(visited.begin(),visited.end(),false);
        int k=0;
        for(int i=N-1;i>=0;i--){
            if(!visited[vs[i]]) dfs(vs[i],k++);
        }
    }
    void dfs(int v){
        visited[v]=true;
        for(int u:G[v]) if(!visited[u]){
            dfs(u);
        }
        vs.push_back(v);
    }
    void dfs(int v,int k){
        visited[v]=true;
        comp[v]=k;
        for(int u:revG[v]) if(!visited[u]){
            dfs(u,k);
        }
    }
    bool same(int a,int b){ return comp[a]==comp[b]; }
};

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

    int N,M; cin>>N>>M;
    Graph G(N);
    for(int i=0;i<M;i++){
        int a,b; cin>>a>>b;
        G[a].push_back(b);
    }
    StronglyConnectedComponents scc(G);
    int Q; cin>>Q;
    while(Q--){
        int a,b; cin>>a>>b;
        cout<<scc.same(a,b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 5744
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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






int main(void) {
	int N,K;
	cin >> N;
	cin >> K;
	int res = 0;
	for (int i=0; i<N; i++ ) {
		int x;
		cin >> x;
		res += min(x, K-x) * 2 ;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

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

  int limit = (a > b ? a : b);
  int count = 0;
  int ans;

  for(int i = limit; i > 0; i--){
    if ((a % i == 0) && (b % i == 0)) {
      count++;
    }
    if (count == k) {
      ans = i;
      break;
    }

  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#coding: utf-8
import numpy as np

n, m = map(int, raw_input().split())
a = np.zeros((n, 2), dtype=np.uint64)
for i in np.arange(n):
    a[i] = np.array(map(int, raw_input().split()))

a = a[np.argsort(a[:,0])]

cost = 0L
for i in np.arange(n):
    if(a[i][1] < m):
        cost += a[i][0] * a[i][1]
        m -= a[i][1]
    else:
        cost += a[i][0] * m
        print(long(cost))
        exit()



Measured memory_bytes: 14472
nkq = list(map(int, input().split()))
n, k, q = nkq[0], nkq[1], nkq[2]
attendees = dict()
for i in range(n):
    attendees[i] = 0

respondents = [int(input()) for i in range(q)]

for r in respondents:
    r_index = r - 1
    attendees[r_index] += 1

for i, p in attendees.items():
    point = p + k - q
    if point > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 17172
import java.util.Scanner;

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

        String s = sc.next();
        String t = sc.next();
        int n = s.length();

        for (int st = 0; st < n; st++) {
            boolean ok = true;

            for (int i = 0; i < n; i++) {
                if (s.charAt(i) != t.charAt((i+st)%n)) {
                    ok = false;
                }
            }

            if (ok) {
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 21844
package main

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

// input に使うやつ
var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

// string から int へ
func atoi(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}

// 一つの文字を int として読み込み
func readInt() int {
	return atoi(readLine())
}

// 複数の文字を int のスライスとして読み込み
func readInts() []int {
	in := readLine()
	ins := strings.Split(in, " ")
	out := make([]int, len(ins))
	for i, v := range ins {
		out[i] = atoi(v)
	}
	return out
}

// sortしたスライスを返す
func sorted(a []int) []int {
	b := make([]int, len(a))
	copy(b, a)
	sort.Ints(b)
	return b
}

// 逆順のsort
func reverse(a []int) []int {
	b := make([]int, len(a))
	copy(b, a)
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	return b
}

func main() {
	n := readInts()
	a := n[0]
	b := n[1]
	c := n[2]

	ans := c - (a - b)
	if ans > 0 {
		fmt.Println(ans)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  while (n != 0) {
    ans++;
    n /= m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)
l = [0 for i in range(26)]
if N < 26:
    for i in range(N):
        l[ord(S[i])-97] += 1
    for i in range(26):
        if l[i] == 0:
            print(S+str(chr(i+97)))
            break
elif S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
else:
    m = 0
    for i in reversed(range(26)):
        if m > ord(S[i])-97:
            id = i
            break
        m = ord(S[i])-97
    for i in range(id,26):
        l[ord(S[i])-97] += 1
    for i in range(len(l)):
        if l[i] == 1 and ord(S[id])-97 < i:
            s = chr(i+97)
            break
    print(S[:id]+str(s))


Measured memory_bytes: 3064
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    S=input()

    dayOfweek=['SUN','MON','TUE','WED','THU','FRI','SAT']

    for i, day in enumerate(dayOfweek):
        if day==S:
            print(7-i)
            break


# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc146","a",main)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    char n[3];
    scanf("%s",n);
    for(int i = 0;i<3;i++){
        if(n[i] == '1'){
            n[i] = '9';
        }else if(n[i] == '9'){
            n[i] = '1';
        }
    }
    printf("%s",n);
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();

		long top = N;
		long sum = 0;
		for (long i = 1; i <= N; i++) {
			long bottom = N / (i + 1);
			if (top == bottom) {
				break;
			}

			for (long j = top; j > bottom; j--) {
				long mod = N % j;
				if (mod == i) {
					sum += j;
				}
				if (mod >= i) {
					break;
				}
			}
			top = bottom;
		}
		System.out.println(sum);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public char nextChar() throws IOException {
			return (char) skip();
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {

  int a;
  int b;
  int c;
  cin >>a>>b>>c;
  int x=a+b;
  int y=a+c;
  int z=b+c;
  int w=min(min(x,y),z);
  cout << w << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    for(int i = 0; i < 3000; i++){
        int a,b;
        cin >> a >> b;
        
        if(a == 0 && b == 0){
            break;
        }
        else{
            cout << min(a, b) << " " << max(a, b) << endl;
            }
    }
    
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
using namespace std;
typedef long long LL;
const LL mod = (1e9 + 7);

int pos[200005], len, nn = 0;
bool vis[27];
char ch[200005], ans[200005];


int main()
{
    scanf("%s", ch + 1);
    len = strlen(ch + 1);
    pos[++pos[0]] = len + 1;
    for(int i = len;i >= 1;i--)
    {
        int a = ch[i] - 'a';
        if(!vis[a])
            vis[a] = 1, nn++;
        if(nn == 26)
        {
            pos[++pos[0]] = i;
            mem(vis, 0);
            nn = 0;
        }
    }
    nn = 0;
    int l = 0;
    for(int i = pos[0];i >= 1;i--)
    {
        mem(vis, 0);
        for(int j = l + 1;j <= pos[i] - 1;j++)
            vis[ch[j] - 'a'] = 1;
        int tmp = 0;
        while(vis[tmp])
            tmp++;
        ans[nn++] = tmp + 'a';
        if(i != 1)
        {
            for(int j = pos[i];j <= pos[i - 1] - 1;j++)
            {
                if(ch[j] == ans[nn - 1])
                {
                    l = j;
                    break;
                }
            }
        }
    }
    printf("%s\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int a, b;
  cin >> a >> b;
  if ((a * b) & 1) cout << "Yes" << endl;
  else cout << "No" << endl;

  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	re ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
ll n,ans; 
vector<ll> a;
int main()
{
	cin>>n;
	a.push_back(1);
	ll k=n-1;
	for(re ll i=2;i*i<=k;i++)
	{
		if(k%i==0)
		{
			a.push_back(i);
			if(i*i!=k)
			{
				a.push_back(k/i);
			}
		}
	}
	a.push_back(k);
	for(re ll i=2;i*i<=n;i++)
	{
		for(ll j=n;j>0&&(j%i==0);j/=i)
		{
			ll x=j/i;
			if(x%i==1)
			{
				a.push_back(i);
				break;
			}
		}
	}
	a.push_back(n);
	sort(a.begin(),a.end());
	a.erase(unique(a.begin(),a.end()),a.end());
	ans=a.size()-1;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
const double PI = (acos(-1));
const long long MOD = pow(10, 9) + 7;
long long kaizyou(int N);
long long POW(int J);

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

    int num = 0;

    const int Max = sqrt(1.0 * N) + 1;

    int A = 1, B = 1, C = 1;
    double D = 0;

    while (A < N)
    {
        while (B < N)
        {
            if (A * B < N)
            {
                D = N - A * B;
                if (D >= 1)
                {
                    num++;
                }
            }
            else
            {
                break;
            }

            B++;
        }

        A++;
        B = 1;
    }

    cout << num;

}


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

using namespace std;
vector<int>dsu;

int parent(int a){
    if(dsu[a] == a) return a;
    return dsu[a] = parent(dsu[a]);
}


void join(int a, int b){
    int pa = parent(a);
    int pb = parent(b);
    dsu[pa] = pb;
}

int main(){
    int n, m, a, b;
    scanf("%d %d", &n, &m);
    vector<int>p(n);
    dsu = vector<int>(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &p[i]);
        p[i]--;
    }

    for(int i = 0; i < n; i++) dsu[i] = i;
    for(int i = 0; i < m; i++){
        scanf("%d %d", &a, &b);
        --a; --b;
        join(a,b);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += parent(p[i]) == parent(i); 
    }

    printf("%d\n", ans);
}   

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

string FILENAME = "template";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;

#define forl(V, N) for(int V = 0; V < N; V++)
#define forll(V, S, E) for(int V = S; V < E; V++)
#define fore(V, N) for(auto &V:N)
#define print(X) cout << X
#define println(X) cout << X << endl
#define rem(X) X.top(); X.pop()
#define graph unordered_map<int, vector<int>>
#define vi vector<int>
#define pb push_back
#define ll long long

int main() {
    int N;
    cin >> N;
    unordered_map<int, vector<vector<int>>> TT;
    forl(i, N) {
        int A;
        cin >> A;
        vector<vi> temp;
        forl(j, A) {
            int x, tl;
            cin >> x >> tl;
            temp.pb({x-1, tl});
        }
        TT[i] = temp;
    }
    int sol = 0;
    for(int bt = 1; bt < pow(2, N); bt++) {
        bool good = true;
        forl(i, N) {
            if(!(bt & (1 << i))) continue;
            fore(V, TT[i]) {
                if(((bt & (1 << V[0])) == 0) ^ V[1] == 0) good = false;
            }
        }
        if(good) {
            int tmp = bt, ttcount = 0;
            while(tmp != 0) {
                ttcount += tmp & 1;
                tmp = tmp >> 1;
            }
            sol = max(sol, ttcount);
        }
    }
    println(sol);
}

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

int a,b;
int main(){
  cin>>a>>b;
  if(a==1 && b==1){
    cout<<"Draw"<<endl;
    return 0;
  }else if(b==1){
    cout<<"Bob"<<endl;
    return 0;
  }else if(a==1){
    cout<<"Alice"<<endl;
    return 0;
  }

  if(a>b){
    cout<<"Alice"<<endl;
  }else if(a<b){
    cout<<"Bob"<<endl;
  }else{
    cout<<"Draw"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
H = I()
def monster(n):
    if n == 1:
        return 1
    return 1 + 2*(monster(n//2))
print(monster(H))


Measured memory_bytes: 10464
#include <stdio.h>

int main()
{
    int		a, b, n;
    int		asum, bsum;

    while(1)
    {
	scanf("%d", &n);
	if (n == 0)
	{
	    break;
	}
	asum = bsum = 0;
	for(int i = 0; i < n; i++)
	{
	    scanf("%d %d\n", &a, &b);
	    if (a > b)
	    {
		asum += a + b;
	    }else if (a < b ){
		bsum += a + b;
	    }else{
		asum += a;
		bsum += b;
	    }
	}
	printf("%d %d\n", asum, bsum);
    }
}

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

typedef long long LL;

typedef vector<int> VI;
typedef vector<VI> VVI;

typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

typedef vector<double> VD;
typedef vector<VD> VDD;

typedef vector<string> VS;
typedef vector<VS> VVS;

typedef vector<bool> VB;
typedef vector<VB> VVB;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define RANGE(x, y, maxX, maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && y < (maxY))
#define REP(i, init, N) for (int i = (init); i < (int)(N); i++)

const int INF = 0x3f3f3f3f;
const int DX[] = {-1,0,1,-1,1,-1,0,1};
const int DY[] = {1,1,1,0,0,-1,-1,-1};

int N, M, A, B, C, T;
VVI ss0;

VVI multi(VVI &a, VVI &b) {
    VVI c(N, VI(N));
    REP(i, 0, N) REP(k, 0, N) REP(j, 0, N) {
        (c[i][j] += a[i][k] * b[k][j] % M) %= M;
    }
    return c;
}

VI multi(VVI &a, VI &b) {
    VI c(N);
    REP(i, 0, N) {
        REP(j, 0, N) {
            (c[i] += a[i][j] * b[j]) %= M;
        }
    }
    return c;
}

VVI power_multi(VVI a, int p) {
    VVI res = ss0;

    while (p > 0) {
        if (p & 1) res = multi(res, a);
        a = multi(a, a);
        p >>= 1;
    }

    return res;
}

VI solve(VI &ss) {
    ss0 = VVI(N, VI(N));
    REP(i, 0, N) {
        ss0[i][i] = 1;
    }

    VVI ks(N, VI(N));

    VI abc({A, B, C});

    REP(i, 0, N) {
        REP(j, -1, 2) {
            int k = i + j;
            if (k < 0 || N <= k) continue;

            ks[i][k] = abc[j + 1];
        }
    }

    VVI ks2 = power_multi(ks, T);

    return multi(ks2, ss);
}

int main(void) {
    while (cin >> N >> M >> A >> B >> C >> T, N) {
        VI ss(N);
        for (auto &s : ss) {
            cin >> s;
        }

        VI ans = solve(ss);
        REP(i, 0, ans.size()) {
            cout << ans[i] << (i == (int)ans.size() - 1 ? '\n' : ' ');
        }
    }
    

    return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N, M;
    cin >> N >> M;
    vi cnts(N, 0);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        cnts[a]++; cnts[b]++;
    }

    rep(i, N) {
        if(cnts[i]%2) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int inf = 10000000;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  string ans;
  cin >> N >> K; 
  if((K-1)*2+1 <= N){
    ans = "YES";
  }else{
    ans = "NO";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def GCD(a,b):
    if min(a,b)==0:
        return max(a,b)
    else:
        return GCD(min(a,b),max(a,b)%min(a,b))

def _LCM(a,b):
    return a*b//GCD(a,b)

def LCM(array):
    lcm=1
    for i in array:
        lcm=_LCM(lcm,i)
    return lcm

while True:
    n=int(input())
    if n==0:
        break

    d=[]
    v=[]
    for i in range(n):
        _d,_v=[int(j) for j in input().split(" ")]
        d.append(_d)
        v.append(_v)

    V=1
    for i in range(n):
        V=V*v[i]
    array=[d[i]*V//v[i] for i in range(n)]
    lcm=LCM(array)
    for i in range(n):
        print(lcm*v[i]//(V*d[i]))



Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	int x;
	cin>>x;
	if(x>=30)cout<<"Yes";
	else cout<<"No";
}

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


Measured memory_bytes: 3580
#!/usr/bin/env python3
def main():
    S = input()[::-1]

    counts = [0] * 2019
    counts[0] = 1
    res, digit = 0, 1
    for i in S:
        res += int(i) * digit
        res %= 2019
        digit *= 10
        digit %= 2019
        counts[res] += 1

    ans = 0
    for i in counts:
        ans += i * (i - 1) // 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9300
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long A[N+1],B[N+1],answer=0;
  A[0] = 0;
  B[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    B[i] = B[i-1]^A[i];
    A[i] += A[i-1];
  }
  for (int r = 1, l = 1; r <= N; r++) {
    while (A[r]-A[l-1] != (B[r]^B[l-1]) && l++);
    answer += r-l+1;
  }
  cout << answer;
}

Measured memory_bytes: 6684
group1 = [1, 3, 5, 7, 8, 10, 12]
group2 = [4, 6, 9, 11]

x, y = map(int, input().split())
if x in group1 and y in group1: print('Yes')
elif x in group2 and y in group2: print('Yes')
else: print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;
int ans[200005];
int main() {
  int n,q;
  cin>>n>>q;
  vector<int> e[200005];
  int e_p[200005];
  int a,b;
  for (int i=0; i<n-1; i++) {
    cin>>a>>b;
    e[a-1].push_back(b-1);
    e_p[b-1]=a-1;
  }
  int x,p;
  for (int i=0; i<q; i++) {
    cin>>p>>x;
    p--;
    ans[p]+=x;
  }
  cout<<ans[0];
  for (int i=1; i<n; i++) {
    ans[i]+=ans[e_p[i]];
    cout<<' '<<ans[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 14848