akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    int n;
    double sum;
    scanf("%d",&n);
    sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
            continue;
        else
            sum=sum+i;
    }
    printf("%.0f\n",sum);
    return 0;
}


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

Measured memory_bytes: 596
#include <stdio.h>

int main(){
    int num, angka1, angka2, angka3;
    scanf("%d", &num);

    angka1 = num/100;
    angka2 = (num - angka1 * 100)/10;
    angka3 = num % (angka1 * 100 + angka2 * 10);
if(angka1 == 7 || angka2 == 7 || angka3 == 7){
    puts("Yes");
} else{
    puts("No");
}
    return 0;
}

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

int main(){
    int N, K;  cin >> N >> K;
    string S; cin >> S;
    vector<int> a;
    a.push_back(0);
    for(int i=0; i<N; i++){
        int cnt = 0;
        int j = i;
        while(S[j]==S[i]){
            cnt += (S[i]=='1' ? 1:-1);
            j++;
        }
        a.push_back(cnt);
        i = j-1;
    }
    
    int n = a.size();
    vector<int> suma(n,0);
    for(int i=0; i<n; i++){
        suma[i] = abs(a[i]);
        if(i>0) suma[i] += suma[i-1];
    }

    int ans = 0;
    for(int start=1; start<n; start++){
        int end;
        if(a[start] > 0)
            end = min(n-1, start + 2*K);
        else
            end = min(n-1, start + 1 + 2*(K-1));
        
        ans = max(ans, suma[end]-suma[start-1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const ull B = 1e9+7;

ull StoH(string a){
  ull res=0;
  for(int i=0;i<a.size();i++)res=res*B+a[i];
  return res;
}

vector<bool> search(string &a,string &key){
  vector<bool> res(a.size(),0);
  ull klen=key.size(),h=StoH(a.substr(0,klen)),target=StoH(key),t=1;
  for(int i=0;i<klen;i++) t*=B;
  for(int i=klen;i<a.size();i++){
    if(h==target) res[i-klen]=1;
    h = h*B+a[i]-a[i-klen]*t;
  }
  if(h==target) res[a.size()-klen] = 1;
  return res;
}

int n,m,len;
string e[12];
vector<bool> es[12];
bool used[12],mem[1<<12];

bool check(int idx,int sta){
  if(sta==(1<<n)-1) return 1;
  if(mem[sta])return 0;
  mem[sta]=1;
  
  for(int i=0;i<n;i++){
    if(used[i]||!es[i][idx])continue;
    used[i]=1;
    if(check(idx+e[i].size(),sta+(1<<i))) return 1;
    used[i]=0;
  }
  return 0;
}

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;

    len=0;
    for(int i=0;i<n;i++)cin>>e[i],len+=e[i].size();
  
    string mp;
    for(int i=0;i<m;i++){
      string tmp;
      cin>>tmp;
      mp+=tmp;
    }

    for(int i=0;i<n;i++)es[i]=search(mp,e[i]);
    int ans=0;
    for(int i=0;i<mp.size()-len+1;i++){
      memset(used,0,sizeof(used));
      memset(mem,0,sizeof(mem));
      if(check(i,0)) ans++;
    }
    cout<<ans<<endl;
  }  
  return 0;
}

Measured memory_bytes: 3176
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Maybe (isNothing)

main :: IO ()
main = do
  (n : m : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . negate . sum . toList . f m . fromList . map negate $ as

f :: Int -> PH Int -> PH Int
f 0 h = h
f m h = let (x, h') = uncons h in f (pred m) . insert (x `quot` 2) $ h'

newtype PH a = PH {unPH :: Maybe (PH' a)}
data PH' a = PH' a [PH' a]
merge' :: Ord a => PH' a -> PH' a -> PH' a
merge' u@(PH' x us) v@(PH' y vs) = if y > x then PH' x (v : us) else PH' y (u : vs)
isEmpty :: PH a -> Bool
isEmpty = isNothing . unPH
empty :: PH a
empty = PH Nothing
insert :: Ord a => a -> PH a -> PH a
insert = merge . PH . Just . flip PH' []
singleton :: Ord a => a -> PH a
singleton x = insert x empty
merge :: Ord a => PH a -> PH a -> PH a
merge (PH Nothing) v = v
merge u (PH Nothing) = u
merge (PH (Just u')) (PH (Just v')) = PH . Just $ merge' u' v'
uncons :: Ord a => PH a -> (a, PH a)
uncons = \u -> case u of
  (PH (Just (PH' x us))) -> (,) x .  foldl merge empty . map (PH . Just) . ((maybe id (:)) <$> fst <*> snd) . foldl step (Nothing, []) $ us
  where
    step (Nothing, vs) u = (Just u, vs)
    step (Just v, vs) u = (Nothing, merge' v u : vs)
fromList :: Ord a => [a] -> PH a
fromList xs = foldl merge empty . map singleton $ xs
toList :: Ord a => PH a -> [a]
toList (PH Nothing) = []
toList u = let (x, u') = uncons u in x : toList u'

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 39676
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define MAXN 5000
#define Fi first
#define Se second
int h,w;
int a[MAXN+5][MAXN+5];
vector < pair<int,int> > Ans;
vector < pair<int,int> > As2;
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
        scanf("%d",&a[i][j]);
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w-1;j++)
        if(a[i][j]%2==1)
        {
            a[i][j]-=1,
            a[i][j+1]+=1;
            Ans.push_back(make_pair(i,j));
            As2.push_back(make_pair(i,j+1));
        }
        if(i!=h&&a[i][w]%2==1)
        {
            a[i][w]-=1,a[i+1][w]+=1;
            Ans.push_back(make_pair(i,w));
            As2.push_back(make_pair(i+1,w));
        }
    }
    printf("%d\n",Ans.size());
    for(int i=0;i<Ans.size();i++)
    {
        printf("%d %d %d %d\n",Ans[i].Fi,Ans[i].Se,As2[i].Fi,As2[i].Se);
    }
}


Measured memory_bytes: 13036
x=input()
x0=x.split()
a1=int(x0[0])
a2=int(x0[1])
a3=int(x0[2])
a4=int(x0[3])
a5=int(x0[4])
if a1==0:
    print(1)
if a2==0:
    print(2)
if a3==0:
    print(3)
if a4==0:
    print(4)
if a5==0:
    print(5)

Measured memory_bytes: 9204
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
  int i, n, score[1000];
  double alpha = 0, m = 0;

  while(1){
    cin >> n;
    if(n == 0) break;
    else{
      for(i = 0; i < n; i++){
        cin >> score[i];
        m += score[i];
      }
      m = m / n;
      for(i = 0; i < n; i++){
        alpha += pow(score[i] - m, 2.0);
      }
      alpha = sqrt(alpha / n);
    }
    cout << fixed << setprecision(8) << alpha << endl;
    alpha = 0;
    m = 0;
  }
  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;

int n;
void dfs(string s, char mx){
  if(s.length() == n){
    cout << s << '\n';
    return;
  }
  for(char c = 'a'; c <= mx + 1; c++){
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}

int main(){
  cin >> n;
  dfs("", 'a' - 1);
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef struct{
  int num;
  char name;
  int win;
  int lose;
  int drow;
}TEAM;
main(){
  int n;
  TEAM team[15];
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin>>team[i].name;
      team[i].win=0;
      team[i].lose=0;
      team[i].drow=0;
      team[i].num=i;
      int a;
      for(int j=0;j<n-1;j++){
	cin>>a;
	if(a==0){
	  team[i].win++;
	}
	else if(a==1){
	  team[i].lose++;
	}
	else{
	  team[i].drow++;
	}
      }
    }
    for(int i=1;i<n;i++){
      for(int j=i;j>0;j--){
	if(team[j].win>team[j-1].win||(team[j].win==team[j-1].win&&team[j].lose<team[j-1].lose)||(team[j].win==team[j-1].win&&team[j].lose==team[j-1].lose&&team[j].num<team[j-1].num)){
	  TEAM temp;
	  temp=team[j];
	  team[j]=team[j-1];
	  team[j-1]=temp;
	}
      }
    }
    for(int i=0;i<n;i++){
      cout<<team[i].name<<endl;
    }
  }
}
    

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


using namespace std;

int main()
{

	int A1, A2, A3;
	int maxD = 0;
	int ans = 0;
	int D12, D23, D13;

	cin >> A1 >> A2 >> A3;

	D12 = abs(A1 - A2);
	ans += D12;
	maxD = max(maxD, D12);
	
	D13 = abs(A1 - A3);
	ans += D13;
	maxD = max(maxD, D13);

	D23 = abs(A2 - A3);
	ans += D23;
	maxD = max(maxD, D23);

	ans -= maxD;

	printf("%d", ans);

    return 0;
}



Measured memory_bytes: 256
#!python
# -*- coding: utf-8 -*-

from itertools import product


def main():
    S = input()
    ANS = 0
    for c in product(('+', ''), repeat=len(S) - 1):
        shiki = S[0]
        for i in range(1, len(S)):
            shiki += c[i - 1] + S[i]
        ANS += eval(shiki)
    print(ANS)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N,M,V,P = map(int,input().split())
A = sorted(list(map(int,input().split())))
B = A[:N-P+1]

S = [0]
for i in range(N-P+1):
    S.append(S[-1]+B[i])

ans = P-1

for i in range(N-P+1):
    if B[i]+M-B[-1]<0:
        continue
    if B[i]*(N-P-i)-(S[-1]-S[i+1])+M*(N-P)>=max(M*(V-P),0):
        ans += 1

print(ans)

Measured memory_bytes: 14480
<?php
$n = trim(fgets(STDIN));
$values = explode(' ', trim(fgets(STDIN)));
$costs = explode(' ', trim(fgets(STDIN)));

$result = 0;
for ($i = 0; $i < $n; $i++) {
	if ($values[$i] - $costs[$i] > 0) {
      	$result += $values[$i] - $costs[$i];
    }
}

echo $result, PHP_EOL;

Measured memory_bytes: 4728
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		String S_a=sc.next();	//aのカード
		String S_b=sc.next();	//bのカード
		String S_c=sc.next();	//cのカード

		char winner='A';	//勝者(初期設定をAとする)

		int card_a=S_a.length();	//aのカード枚数
		int card_b=S_b.length();	//bのカード枚数
		int card_c=S_c.length();	//cのカード枚数

		int i_a=0,i_b=0,i_c=0;	//ターン
		int next=0;

		if(S_a.charAt(i_a)=='a'){
			card_a--; next=1; i_a++;
		}else if(S_a.charAt(i_a)=='b'){
			card_b--; next=2; i_b++;
		} else if(S_a.charAt(i_a)=='c'){
			card_c--; next=3; i_c++;
		}

		while(true){
			//各文字列のi番目の文字に対応する人のカードの数を減らす
			if(next==1) {
				card_a--;
				if(card_a==-1) break;
				next=check(S_a.charAt(i_a));
				i_a++;
			}else if(next==2){
				card_b--;
				if(card_b==-1) break;
				next=check(S_b.charAt(i_b));
				i_b++;
			}else if(next==3){
				card_c--;
				if(card_c==-1) break;
				next=check(S_c.charAt(i_c));
				i_c++;
			}
		}

		if(card_b==-1) winner='B';
		else if(card_c==-1) winner='C'; 

		//結果を出力
		System.out.println(winner);
	}

	public static int check(char check_letter){
		int next=0;
		if(check_letter=='a') next=1;
		else if(check_letter=='b') next=2;
		else if(check_letter=='c') next=3;
		return next;
	}
} 

Measured memory_bytes: 21844
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))+[0]
left=[0]*(n+1)
right=[0]*(n+1)
for i in range(1,n):
    left[i]=gcd(left[i-1],a[i-1])
for i in range(n,0,-1):
    right[i-1]=gcd(right[i],a[i])
ans=[gcd(right[i],left[i]) for i in range(n)]
print(max(ans))

Measured memory_bytes: 16140
#include <stdio.h>


int main() 
{


  int a,b,c;

  int temp;



  scanf("%d",&a);

  scanf("%d",&b);

  scanf("%d",&c);



  
if(a > b){

    temp = a;
    
a = b;
    
b = temp;

  }


  
if(b > c){

    temp = b;
   
 b = c;
    
c = temp;
  
}

  
if(a > b){

    temp = a;
    
a = b;
    
b = temp;

  }



  printf("%d %d %d\n",a,b,c);



  return 0;

}


Measured memory_bytes: 2100
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ');
   let S = xs.toString();
   
   let count = 0;
   let ans = 0;
   
   for(let i=0; i<S.length; i++){
      if(S.charAt(i)=='B'){
      count++;
      //console.log(count);
      }else{
      ans += count;
       //console.log(ans); 
      }
   }
    console.log(ans);
 

}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7628
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#define f first
#define s second
#define MOD 1000000007
#define ll long long
#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < columns))
#define mx 6e5 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//#include<bits/stdc++.h>
const int maxn = 20005;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    fast;
   // cout<<"DFGHJ"<<endl;
    int n;
    string s;
    cin>>n>>s;
    int c =0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A')
        {
            if(s[i+1]=='B' && s[i+2]=='C')
                c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        C: usize,
        D: [[usize; C]; C],
        c: [[usize1; N]; N],
    }

    let mut counts = vec![vec![0; 3]; C];
    for x in 0..N {
        for y in 0..N {
            counts[c[x][y]][(x+y+2)%3] += 1;
        }
    }

    let mut min = std::usize::MAX;
    for c0 in 0..C {
        for c1 in 0..C {
            if c1 == c0 {
                continue
            }
            for c2 in 0..C {
                if c2 == c1 || c2 == c0 {
                    continue
                }
                let mut sum = 0;
                let cc = [c0, c1, c2];
                for ind in 0..3 {
                    for c3 in 0..C {
                        sum += D[c3][cc[ind]]*counts[c3][ind];
                    }
                }
                min = cmp::min(min, sum);
            }
        }
    }

    println!("{}", min);

            
}


Measured memory_bytes: 6396
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N, K = Scanner.map_int()
    M = [False for _ in range(N)]
    for _ in range(K):
        D = Scanner.int()
        A = Scanner.map_int()
        for a in A:
            M[a - 1] = True
    print(sum([not m for m in M]))


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10740
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

template <typename QvQ> inline QvQ Min(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max(QvQ a,QvQ b){if(a>b) return a;return b;}

#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f

#define ll long long
#define rei register int
#define inv inline void

#define bl putchar(' ')
#define ed putchar('\n')

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

template <typename QvQ>inv read(QvQ &x)
{
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
#define MAXN 200005
int n;
char a[MAXN];
string dq;
int main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	int ans=1,fl=0;
	for(rei i=2;i<=n;++i)
	{
		if(fl) a[i]='9',fl=0;
		if(a[i]!=a[i-1]) ++ans;
		else fl=1;
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 384
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};



int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(n);
    vector<int> r(n);
    for (int i=0; i<q; ++i){
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }
    vector<int> ac(n, 0);
    for (int i=1; i<n; ++i){
        if(s[i-1] == 'A' && s[i] == 'C'){
            ac[i] = ac[i-1] + 1;
        }
        else {
            ac[i] = ac[i-1];
        }
    }
    int ans;
    for (int query=0; query<q; ++query){
        cout << (ac[r[query]] - ac[l[query]]) << endl;
    }
    return 0;
}

Measured memory_bytes: 2240
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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; }

typedef long long ll;
using namespace std;

int main() {
    
    vector<int> n(4, 0);
    REP(i, 4) cin >> n[i];
    sort(ALL_OF(n));
    if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
}

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


int main(){
    int n,k;cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    int ans=0;
   for(int i=0;i<=min(n,k);i++){
        for(int a=0;a<=i;a++){
            int b=i-a;
            priority_queue <int> neg;
            int aa=0;
            for(int z=0;z<a;z++){
                aa+=v[z];
                if(v[z]<0)neg.push(-v[z]);
            }
            for(int z=0;z<b;z++){
                aa+=v[n-1-z];
                if(v[n-1-z]<0)neg.push(-v[n-1-z]);
            }
            for(int z=0;z<k-a-b;z++){
                if(neg.empty())break;
                aa+=neg.top();
                neg.pop();
            }
            ans=max(ans,aa);
        }
    }
   
    cout<<ans;
}

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

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	int coin = 0;
	for (int i = 0; i < 2; i++) {
		if (A >= B) {
			coin += A;
			A--;
		}
		else {
			coin += B;
			B--;
		}
	}
	cout << coin << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(int argc,char const *argv[])
{
  int N;
  scanf("%d",&N);
  int t=0;
  int x=0;
  int y=0;
  int t1,x1,y1,tg,xg,yg;
  int i;
  for(i=0;i<N;i++){
    scanf("%d%d%d",&t1,&x1,&y1);
    tg=t1-t;xg=x1-x;yg=y1-y;
    if(tg<xg+yg || (tg-xg-yg)%2!=0){
      printf("No");
      return (0);
    }
    t=t1;x=x1;y=y1;
  }
  printf("Yes");
  return (0);
}

Measured memory_bytes: 128
import numpy as np


def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def lcm_base(x, y):
    return x*y // gcd(x, y)

N = int(input())
T = sorted([int(input()) for _ in range(N)])

ans = 1
for t in T:
    ans = lcm_base(ans,t)
print(ans)


Measured memory_bytes: 12140
s = input()
for i in range(len(s)):
	if (i + 1) & 1:
		if s[i] not in ('R', 'U', 'D'):
			print('No')
			exit()
	else:
		if s[i] not in ('L', 'U', 'D'):
			print('No')
			exit()
print('Yes')

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    ll mid = 0;
    REP(i, 0, n){
        mid = mid ^ lis[i];
    }
    REP(i, 0, n){
        cout << (mid ^ lis[i]) << " ";
    }
}

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

using namespace std;

int dp[101][101],a[100];


int main(){
  int T;
  cin>>T;
  while(T--){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
      cin>>a[i];

    memset(dp,0,sizeof(dp));
    int ans=0;
    for(int i=1;i<n;i++){
      for(int j=0;j<n;j++){
	for(int k=j;k<j+i;k++){
	  ans=max(ans,dp[j][(j+i)%n]=max(dp[j][(j+i)%n],dp[j][k%n]+dp[(k+1)%n][(j+i)%n]+abs(a[j]-a[(k+1)%n])));
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
long long n;
int main()
{
    while(~scanf("%lld",&n))
    {
        if(n%2==0)
            printf("%lld\n",n);
        else
        {
            printf("%lld\n",2*n);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;
int N,L;



bool cmp(const P &p,const P &q){
  return p.F >= q.F;
}


int main(){

  while(cin >> N >> L){
   
    int *a = new int[N];
    int *tm = new int[N]; 
    deque<int> perm;
    
    vector<P> pres;
    rep(i,N){
      cin >> a[i];
      tm[i] = -1;
      pres.pb(P(a[i],i));
    }
    sort(all(pres),cmp);
   
    rep(i,N)
      perm.push_back(pres[i].S);
      
    int mex = 0;
    while(!perm.empty()){
      int pos = perm.front(); perm.pop_front();
     
      if(pos == 0 || pos == N-1){
	int Le = pos == 0?a[pos+1]:a[pos-1];
	int lorr = pos==0?pos+1:pos-1; 
	if(Le > a[pos]){	 
	  assert(tm[lorr] != -1);
	  tm[pos] = (L-a[pos])+tm[lorr];
	}
	else if(Le < a[pos]){
	  tm[pos] = (L-a[pos]);
	}
	else assert(false);
      }
      else {
	if(a[pos-1]  < a[pos] && a[pos] > a[pos+1]){
	  tm[pos] = (L-a[pos]); 
	}
	else if(a[pos-1] > a[pos] && a[pos] < a[pos+1]){
	  assert(tm[pos+1] != -1 && tm[pos-1] != -1);
	  tm[pos] = max(tm[pos+1],tm[pos-1]) + (L-a[pos]);
	}
	else{
	  if(a[pos-1] > a[pos]){
	    assert(tm[pos-1] != -1);
	    tm[pos] = (L-a[pos]) + tm[pos-1];
	  }
	  else if(a[pos+1] > a[pos]){
	    assert(tm[pos+1] != -1);
	    tm[pos] = (L-a[pos]) + tm[pos+1];
	  }
	  else assert(false);
	}
      }      
      mex = max(tm[pos],mex);
    }    

    cout << mex << endl;

    delete [] a;
    delete [] tm;
  }
    
return 0;
}

Measured memory_bytes: 3088
import sys
from heapq import heappush, heappop

inf = 1<<30

def solve():
    N, M, s = map(int, sys.stdin.readline().split())
    Adj = [[] for i in range(N)]

    for i in range(M):
        ui, vi, ci = map(int, sys.stdin.readline().split())
        Adj[ui].append((vi, ci))

    d = dijkstra(N, Adj, s)

    for di in d:
        print(di if di < inf else 'INF')

def dijkstra(N, Adj, s):
    d = [inf] * N
    p = [-1] * N
    fixed = [False] * N
    d[s] = 0
    p[s] = s
    pq = [(0, s)]

    for i in range(N - 1):
        while pq:
            di, v = heappop(pq)

            if not fixed[v] and di == d[v]:
                break

        fixed[v] = True

        for u, c in Adj[v]:
            if d[v] + c < d[u]:
                d[u] = d[v] + c
                p[u] = v
                heappush(pq, (d[u], u))

    return d

if __name__ == '__main__':
    solve()

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

int main() {
  int H,W;
  cin >> H >> W;
  
  for(int i=0;i < W + 1;i++){
    cout << "#";
  }
  cout << "#" << endl;
  
  for(int i=0;i < H;i++){
    cout << "#";
    vector<char> a(W);
    for(int j=0;j < W;j++){
      cin >> a.at(j);
      cout << a.at(j);
    }
    cout << "#" << endl;
  }
    
  for(int i=0;i < W + 1;i++){
    cout << "#";
  }
  cout << "#" << endl;
}


Measured memory_bytes: 256
k = int(input())


#print(k)
val = input()

a = int(val.split(" ")[0])
b = int(val.split(" ")[1])
# print(a + "and" + b)

result = 0

for i in range(a, b+1):
    if i%k == 0: result += 1

if result == 0:
    print("NG")
else: print("OK")

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int issq(ll x){
	ll t=sqrtl(x);
	if (t*t==x) return 1;
	if ((t-1)*(t-1)==x) return 1;
	if ((t+1)*(t+1)==x) return 1;
	return 0;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int f1=0;
	map<ll, ll> h;
	for (int i=0;i<n;i++){
		ll s;
		cin>>s;
		for (ll d=2;d*d*d<=s;d++){
			while (s%(d*d*d)==0){
				s/=(d*d*d);
			}
		}
		if (s==1){
			f1=1;
		}
		else{
			h[s]++;
		}
	}
	ll v=0;
	if (f1) v++;
	vector<ll> ps;
	for (int i=2;i<=10000;i++){
		int f=0;
		for (int p:ps){
			if (p*p>i) break;
			if (i%p==0){
				f=1;
				break;
			}
		}
		if (!f) ps.push_back(i);
	}
	for (auto t:h){
		vector<pair<ll, int> > ds;
		ll k=t.F;
		for (ll p:ps){
			while (k%p==0){
				if (ds.size()>0&&ds.back().F==p) ds.back().S++;
				else ds.push_back({p, 1});
				k/=p;
			}
			if (p*p*p>k) break;
		}
		if (k>1&&k<=1000000) {
			for (ll p:ps){
				while (k%p==0){
					if (ds.size()>0&&ds.back().F==p) ds.back().S++;
					else ds.push_back({p, 1});
					k/=p;
				}
				if (p*p>k) break;
			}
			if (k>1) ds.push_back({k, 1});
		}
		else if(k>1){
			if (!issq(t.F)){
				v+=h[t.F];
			}
			else {
				ll ss=sqrtl(t.F);
				if (h[ss]==0) v+=h[t.F];
			}
			continue;
		}
		ll o=1;
		ld oo=1;
		for (auto d:ds){
			if (d.S==1) {
				o*=d.F*d.F;
				oo*=(ld)((ld)d.F*(ld)d.F);
			}
			else{
				o*=d.F;
				oo*=(ld)(d.F);
			}
		}
		if (oo>1e15){
			v+=h[t.F];
		}
		else if (o>t.F){
			v+=max(h[o], h[t.F]);
		}
		else{
			if (h[o]==0) v+=h[t.F];
		}
	}
	cout<<v<<endl;
}

Measured memory_bytes: 10624
package main

import "fmt"

func main() {

	var group int
	var i int = 0
	var lower [100100]int
	var uper [100100]int
	var score int = 0

	// get group
	fmt.Scan(&group)

	// get lower - uper+1
	for ; i < group; i++ {
		fmt.Scan(&lower[i])
		fmt.Scan(&uper[i])
		score += uper[i] - lower[i] + 1

	}
	// score
	fmt.Println(score)

}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int j = 0;
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			int subsum = 0;
			j = i;
			while (j>0) {
				subsum +=j%10;
				j = j/10;
			}
			if (a <= subsum && subsum <= b) {
				sum += i;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 23508
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<int> T(N);
    int sum=0;
    for(int i=0;i<N;i++){
        cin >> T[i];
        sum += T[i];
    }
    int M; cin >> M;
    for(int i=0;i<M;i++){
        int p; cin >> p; p--;
        int x; cin >> x;
        cout << sum-T[p]+x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int N,K;
long long ans=0;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d",&N,&K);
	if(K==0)ans=1ll*N*N;
	else {
		for(int b=K+1;b<=N;b++) {
			int x1=b-K;
			int x2=N/b;
			int k=N-x2*b;
			if(k>=K)ans+=k-K+1;
			ans+=x1*x2;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<cmath>
#include<unordered_set>
#define P pair<int,int>//cost to
#define int long long
using namespace std;

vector<P>r[100000];
int m[100000];
void DFS(int n, int p) {
	for (P b : r[n]) {
		if (b.second != p) {
			m[b.second] = m[n] + b.first;
			DFS(b.second, n);
		}
	}
}
signed main() {
	int n; cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		r[a].push_back({ c,b });
		r[b].push_back({ c,a });
	}
	int q, k; cin >> q >> k;
	k--;
	DFS(k, k);
	for (int i = 0; i < q; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		cout << m[x] + m[y] << endl;
	}
}


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

typedef long long lli;

lli ind[10];

lli pow(lli x, lli n) {
  lli res = 1LL;
  for(int i = 0; i < n; ++i) res *= x;
  return res;
}

void make() {
  ind[0] = 1;
  for(int i = 1; i <= 9; ++i) {
    ind[i] = ind[i-1] + 9LL * pow(10, i-1) * i;
  }
}

int getLength(int x) {
  if(x == 0) return 1;
  for(int i = 1; ; ++i) {
    if(x < pow(10, i)) return i;
  }
}

string toString(int x) {
  if(x == 0) return "0";
  string res = "";
  while(x != 0) {
    res += '0' + (x % 10);
    x /= 10;
  }
  reverse(res.begin(), res.end());
  return res;
}

void solve(int n, int k) {
  int p = upper_bound(ind, ind+10, (lli)n) - ind;
  int d = (n-ind[p-1])%p;
  int s = pow(10, p-1) + (n-ind[p-1])/p;

  string str = "";
  for(int j = s; str.size() < k+20; ++j) str += toString(j);
  cout << str.substr(d, k) << endl;
}

int main() {
  make();
  int N, K;
  while(cin >> N >> K && (N || K)) {
    solve(N, K);
  }
  return 0;
}

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

int func(int choco, int d){
  int ret=1;
  for(int i = 1; i < d; i++){
	if(i * choco + 1 <= d){
      ret++;
    }
  }
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n,d,x;
  cin>>n>>d>>x;
  int a[n];
  rep(i,n) cin >> a[i];
  int sum = 0;
  rep(i,n) sum += func(a[i],d);
  cout << sum + x << endl;
}


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

int main(void){
  char s[100000];
  int c=0, r, l;
  scanf("%s",s);
  r = strlen(s)-1;  l=0;
  while(l<=r){
    while(s[l]=='x'){
      if(s[r]=='x'){r--;  l++;}
      else{c++; l++;}
    }
    while(s[r]=='x'){
      c++; r--;
    }
    if(s[l]!=s[r]) break;
    else{l++; r--;}
  }
  if(l<=r) printf("-1\n");
  else printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int A ,B;
    char op;

    //空白区切りで入力
    scanf("%d %c %d" ,&A ,&op ,&B);

    switch (op){
        case '+':
            printf("%d\n" ,A+B);
            break;
    
        case '-':
            printf("%d\n" ,A-B);
            break;
    }
    
    return 0;
    
}

Measured memory_bytes: 128
N, Y = map(int, input().split())

def check(N, Y):
    for a in range(N+1):
        for b in range(N-a+1):
            c = N-a-b
            if 10000*a + 5000*b + 1000*c == Y:
                return "{} {} {}".format(a,b,c)
    return False

result = check(N,Y)
if result:
    print(result)
else:
    print("-1 -1 -1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int MAX = 1e6 + 10;
typedef long long i64;
using namespace std;
const double EPS = 1e-6;



vector<int> g[MAX];
int mark[MAX];
int dfs(int v, int p){
	int grundy= 0;
	for(auto nv: g[v]){
		if(nv == p)continue;
		int cur = dfs(nv, v);
		grundy ^= cur;
	}
	
	return grundy + 1;
}
int main() {

    #ifdef LOCAL_DEBUG
    freopen ("data.in", "r", stdin );
    //freopen ("data.out", "w", stdout );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    #define endl '\n'


	int n; cin >> n;
	for(int i = 0; i < n - 1; i++){
		int a, b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int ans = 0;
	for(auto v: g[1]){
		int cur = dfs(v, 1);
		ans ^= cur;
	}

	if(ans == 0)cout << "Bob" << endl;
	else cout << "Alice" << endl;






}



Measured memory_bytes: 33408
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    if (a * b % 2 == 0) {
        puts("Even");
    } else {
        puts("Odd");
    }

    return 0;
}


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

using namespace std;

int main(){
    int n;
    vector<int> h;
    vector<int> dp;

    cin>>n;
    h.resize(n);
    dp.resize(n);

    for(int i=0; i<n; i++){
        cin>>h[i];
        dp[i]=1e9;
    }

    dp[0]=0;
    for(int i=0; i<n; i++){
        if(i+1<n){
            dp[i+1]=min(dp[i+1],abs(h[i]-h[i+1])+dp[i]);
        }
        if(i+2<n){
            dp[i+2]=min(dp[i+2],abs(h[i]-h[i+2])+dp[i]);
        }
    }

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

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int X = l[0], Y = l[1], Z = l[2], K = l[3];

            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var B = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var C = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var AB = new long[X*Y];
            var count = 0;
            for (var i = 0; i < X; i++)
            {
                for (var j = 0; j < Y; j++)
                {
                    AB[count] = A[i] + B[j];
                    count++;
                }
            }

            AB = AB.OrderByDescending(d => d).ToArray();
            Array.Resize(ref AB, K);

            var ans = new long[K * Z];
            count = 0;
            for (var i = 0; i < K; i++)
            {
                for (var j = 0; j < Z; j++)
                {
                    ans[count] = AB[i] + C[j];
                    count++;
                }
            }

            Array.Sort(ans);
            Array.Reverse(ans);
            //ans = ans.OrderByDescending(e => e).ToArray();
            for (var i = 0; i < K; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }
    }
}


Measured memory_bytes: 61284
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 1000009;
const int MOD = 1e9 + 7;
string MP[maxn];
vector<vector<int>> U,D,L,R,V;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n,m,k,x1,x2,y1,y2;
  cin>>n>>m>>k;
  cin>>x1>>y1>>x2>>y2;
  x1--;y1--;x2--;y2--;
  for(int i=0;i<n;++i)cin>>MP[i];
  U.assign(n,vector<int>(m));
  D.assign(n,vector<int>(m));
  R.assign(n,vector<int>(m));
  L.assign(n,vector<int>(m));
  V.assign(n,vector<int>(m,-1));
  auto in=[&](int x,int y){
    return x>=0&&x<n&&y>=0&&y<m;
  };
  auto work=[&](int x,int y,int dx,int dy,vector<vector<int>> &X,vector<pair<int,int>> &quee){
    int inx=x,iny=y;
    for(int j=1;j<=k;++j){
      x+=dx;y+=dy;
      if(!in(x,y))break;
      if(MP[x][y]=='@')break;
      if(V[x][y]==-1){
        X[x][y]=k-j;
        V[x][y]=V[inx][iny]+1;
        quee.emplace_back(x,y);
      }else if(V[x][y]==V[inx][iny]){
        if(X[x][y]>=k-j){
          break;
        }else{
          if(!in(x+dx*X[x][y],y+dy*X[x][y]))break;
          if(X[x+dx*X[x][y]][y+dy*X[x][y]]==0&&V[inx][iny]==V[x+dx*X[x][y]][y+dy*X[x][y]]){
            j+=X[x][y];
            X[x+dx*X[x][y]][y+dy*X[x][y]]=k-j;
          }
        }
      }else if(V[x][y]<V[inx][iny]){
        break;
      }
    }
  };
  vector<pair<int,int>> que;
  que.emplace_back(x1,y1);
  V[x1][y1]=0;
  for(int i=0;i<Sz(que);++i){
    int x=que[i].first,y=que[i].second;
    work(x,y,+1,0,D,que);
    work(x,y,-1,0,U,que);
    work(x,y,0,+1,R,que);
    work(x,y,0,-1,L,que);
  }
  cout<<V[x2][y2]<<'\n';
  return 0;
}


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


int main(){
	int n,x,a,b,sum,count=0;
	
	cin>>n>>a>>b;
	for(int i=1;i<n+1;i++){
		sum=0;
		x=i;
		while(x!=0){
			sum+=x%10;
			x/=10;
		}
		if(a<=sum&&sum<=b)
			count+=i;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
$adj = Array.new(n+1).map{[]}
$used = Array.new(n+1,true)
m.times do
  a,b = gets.split.map(&:to_i)
  $adj[a] << b
  $adj[b] << a
end

def dfs(stack)
  loop do
    b = false
    f = stack[-1]
    $adj[f].each do |a|
      if $used[a]
        $used[a] = false
        stack.push(a)
        b = true
        break
      end
    end
    next if b
    break
  end
  return stack
end
$used[1] = false
s = dfs([1])
t = dfs([1])
puts (s+t).size-1,(s.reverse[0..-2]+t).join(" ")

Measured memory_bytes: 14312
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;


int main(){
  
  ll m,n; cin>>m>>n;
  if(m==1&&n==1){
    cout<<1<<endl;
  }
  else if(m==1||n==1){
    cout<<n+m-1-2<<endl;
  }
  else cout << m*n-(2*(m+n)-4)<<endl;
  
  
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n+100; ++i) {
        if ((i * 108) / 100 == n) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << ":("
         << "\n";
    return 0;
}

Measured memory_bytes: 256
Q = int(input())
mod = int(1e+6 + 3)

def doubling(n, m):
  y = 1
  p = n
  while m != 0:
    if m % 2 == 1:
      y *= p
      y %= mod
    m //= 2
    p *= p
    p %= mod
  return y

def inved(s):
  x, y, u, v, k, l = 1, 0, 0, 1, s, mod
  while l != 0:
    x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
    k, l = l, k % l
  return x % mod

frac = [1 for _ in range(mod+1)]
invf = [1 for _ in range(mod+1)]
invf[mod] = 0
for i in range(mod):
  frac[i+1] = (frac[i] * (i+1)) % mod
invf[mod-1] = inved(frac[mod-1])
for i in range(mod-1, 0, -1):
  invf[i-1] = (invf[i] * i) % mod

for i in range(Q):
  x, d, n = map(int, input().split())
  if x == 0:
    print(0)
  else:
    if d == 0:
      print(doubling(x, n))
    else:
      if n >= mod:
        print(0)
      else:
        xinvd = x * inved(d) - 1
        xinvd %= mod
        if xinvd + n >= mod:
          print(0)
        else:
          dn = doubling(d, n)
          print((dn * frac[xinvd + n] * invf[xinvd]) % mod)


Measured memory_bytes: 208332
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  int n;
  vector<long long> odds, evens, out_v;
  cin >> n;
  for (int i=1;i<=n;i++) {
    long a;
    cin >> a;
    if (i%2==1) {
      odds.push_back(a);
    } else {
      evens.push_back(a);
    }
  }
  if (n % 2==1) {
    reverse(odds.begin(), odds.end());
    odds.insert(odds.end(), evens.begin(), evens.end());
    for (int i=0;i<n-1;i++) {
      cout << odds[i] << " ";
    }
    cout << odds[n-1] << endl;
  } else {
    reverse(evens.begin(), evens.end());
    evens.insert(evens.end(), odds.begin(), odds.end());
    for (int i=0;i<n-1;i++) {
      cout << evens[i] << " ";
    }
    cout << evens[n-1] << endl;
  }
}


Measured memory_bytes: 4700
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		int r = s.nextInt();
		int D = s.nextInt();
		int x = s.nextInt();

		for (int i = 1; i <= 10; i++) {
			x = r * x - D;
			System.out.println(x);
		}

	}
}

Measured memory_bytes: 23764