akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

bool mat[40][40];


int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; ++i) {
        int k, f;
        cin >> k;
        while(k--) {
            cin >> f;
            mat[i][f] = true;
        }
    }

    int cnt = 0;
    for (int i = 1; i <= m; ++i) {
        bool flag = true;
        for (int j = 0; j < n; ++j) 
            if ( !mat[j][i] ) flag = false;
        if (flag) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b =map(int, input().split())
s =input()
ca = 0
cb = 0
for i in s:
    if i=='a' and ca+cb<a+b:
        ca+=1
        print('Yes')
    elif i=='b' and ca+cb<a+b and cb<b:
        cb+=1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4016
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<string> v(n);
    for (auto &&i : v) {
        cin >> i;
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v.size() << "\n";
    return 0;
}

Measured memory_bytes: 9600
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, i, tmp;
    int[] p, l;
    long res1, res2;
    n = sc.nextInt();
    p = new int[n]; l = new int[n];
    for(i = 0;i < n;i++)p[i] = sc.nextInt();
    for(i = 0;i < n;i++)l[i] = sc.nextInt();
    res1 = solve(n, p, l);
    for(i = 0;i < n / 2;i++){
      tmp = p[i]; p[i] = p[n - 1 - i]; p[n - 1 - i] = tmp;
      tmp = l[i]; l[i] = l[n - 1 - i]; l[n - 1 - i] = tmp;
    }
    res2 = solve(n, p, l);
    if(res1 > res2 && res2 != -1)res1 = res2;
    out.println(res1);
    sc.close();
  }
  private static long solve(int n, int[] p, int[] l){
    long res;
    long[] s = new long[n];
    int i;
    s[0] = p[0];
    for(i = 1;i < n;i++)s[i] = p[i] + s[i - 1];
    res = count(s, 0, n);
    for(i = 0;i < n - 1;i++)s[n - 1 - i] -= s[n - 2 - i];
    for(i = 0;i < n;i++)if(s[i] < (long)l[i])return -1;
    return res;
  }
  private static long count(long[] c, int l, int r){
    int m;
    if(l + 1 >= r){
      if(l < r)return 0;
      return 1;
    }else{
      m = (l + r) / 2;
      return (count(c, l, m) + count(c, m, r) + merge(c, l, m, r));
    }
  }
  private static long merge(long[] c, int l, int m, int r){
    int nl, nr;
    int i, j, k;
    long infi = Long.MAX_VALUE;
    long[] cl, cr;
    long count;
    nl = m - l; nr = r - m;
    cl = new long[nl + 1]; cr = new long[nr + 1];
    for(i = 0;i < nl;i++)cl[i] = c[l + i];
    for(i = 0;i < nr;i++)cr[i] = c[m + i];
    cl[nl] = infi; cr[nr] = infi;
    i = 0; j = 0; count = 0;
    for(k = l;k < r;k++){
      if(cl[i] < cr[j])c[k] = cl[i++];
      else{
        c[k] = cr[j++]; count += (nl - i);
      }
    }
    return count;
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 103240
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import defaultdict
from bisect import *
mod = 10**9+7

N, K, S = map(int, input().split())
if S == 10**9:
    A = [S]*K + [1]*(N-K)
else:
    A = [S]*K + [S+1]*(N-K)
print(*A)


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

int main(){
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

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

int main(){
	int a[3001],b[3001];
	int i=0;
	
do{
	
	scanf("%d%d",&a[i],&b[i]);
i++;

		
}while(a[i-1]!=0||b[i-1]!=0);
i=0;
while(a[i]!=0||b[i]!=0){
	if(a[i]>b[i]){
		
		printf("%d %d\n",b[i],a[i]);
		
		
	}else{
		
		
		printf("%d %d\n",a[i],b[i]);
		
		
		
	}
	i++;
	
	
	
	
}
	return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#define LL long long
#define M 100005
using namespace std;
const LL mod=1e9+7;
int n,K;
struct edge{
	int to,fr;
}E[M<<1];
int tote,lst[M];
void addedge(int a,int b){
	E[++tote]=(edge){b,lst[a]};
	lst[a]=tote;
}
LL Pow(LL x,int n){
	LL res=1;
	while(n){
		if(n&1)res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}return res;
}
LL fac[M],inv[M];
void init(){
	int ed=M-1;
	fac[0]=1;
	for(int i=1;i<=ed;i++)fac[i]=fac[i-1]*i%mod;
	inv[ed]=Pow(fac[ed],mod-2);
	for(int i=ed-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
LL C(int a,int b){
	if(a<b)return 0;
	return fac[a]*inv[a-b]%mod;
}
LL dfs(int v,int f){
	LL res=1;
	int all=K-1-(f>0),son=0;
	for(int i=lst[v];i;i=E[i].fr){
		int u=E[i].to;
		if(u==f)continue;
		son++;
		res=res*dfs(u,v)%mod;
	}
	res=res*C(all,son)%mod;
	return res;
}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1,a,b;i<n;i++){
		scanf("%d%d",&a,&b);
		addedge(a,b);addedge(b,a);
	}
	init();
	printf("%lld\n",1LL*K*dfs(1,0)%mod);
	return 0;
}

Measured memory_bytes: 9600
n, k = map(int, input().split())
S = list(input())

cnt = 0

if len(S) == 1:
    print(0)
    exit()

if S[0] == 'R' and S[1] == 'R':
    cnt += 1

if S[-1] == 'L' and S[-2] == 'L':
    cnt += 1


for i in range(1, n - 1):
    lft = S[i - 1]
    rgt = S[i + 1]
    me = S[i]
    if lft == me == 'L':
        cnt += 1

    if rgt == me == 'R':
        cnt += 1

ans = min(cnt + 2 * k, n - 1)

print(ans)


Measured memory_bytes: 49648
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> ans;
  ans.push_back(0);
  int x = 0;
  for (int i = 0; i < n; i++) {
	if (s[i] == 'I') {
	  x++;
	}
	if (s[i] == 'D') {
	  x--;
	}
	ans.push_back(x);
  }
  sort(ans.begin(), ans.end());
  cout << ans.back() << endl;
  return 0;
}



Measured memory_bytes: 256
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const adjLists = Array.from(Array(n), () => []);
  lines.forEach((l, i) => l.split(' ').splice(2).forEach(e => adjLists[i].push(e-1)));

  const d = [], f = [];
  dfs(adjLists, d, f);
  for (let i = 0; i < n; i++) {
    console.log(i + 1, d[i], f[i]);
  }
})();

function dfs(adjLists, d, f) {
  const WHITE = 0, GRAY = 1, BLACK = 2;
  const size = adjLists.length;
  const color = Array.from(adjLists, () => WHITE);

  let time = 0;
  function visit(u) {
    color[u] = GRAY;
    d[u] = ++time;
    adjLists[u].forEach(v =>color[v] === WHITE && visit(v));
    color[u] = BLACK;
    f[u] = ++time;
  }
  adjLists.forEach((e, u) => color[u] === WHITE && visit(u));
}



Measured memory_bytes: 16572
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

linev (x1,y1) (x2,y2) (x,y) = (y2-y1)*x - (x2-x1)*y - x1*y2 + x2*y1

f p1 p2 p3 p = f1 p1 * f1 p > 0 && f2 p2 * f2 p > 0 && f3 p3 * f3 p > 0
  where
    f1 = linev p2 p3
    f2 = linev p3 p1
    f3 = linev p1 p2

main = map (map (apply2 (,)) . splitRec 2 . map readDouble . words) . lines <$> getContents >>= mapM_ (putStrLn . cond "YES" "NO" . apply4 f)
    


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int n,a[1000010],b[1000010], c[1000010],dp[1000010][5];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    for(int i=2;i<=n;i++)
    {
        dp[i][1]+=max(dp[i-1][2],dp[i-1][3])+a[i];
        dp[i][2]+=max(dp[i-1][1],dp[i-1][3])+b[i];
        dp[i][3]+=max(dp[i-1][1],dp[i-1][2])+c[i];
    }
    cout<<max(dp[n][3],max(dp[n][1],dp[n][2]));
    return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const int SIZE = 200024;
int N, Q;
int p[SIZE];
long long cnt[SIZE];
long long sum[SIZE];

long long Solve(int t) {
  if (t == 1) return cnt[1];
  if (sum[t] < 0) {
    sum[t] = Solve(p[t]) + cnt[t];
  }
  return sum[t];
}

int main() {
  while (cin >> N >> Q) {
    memset(cnt, 0, sizeof(cnt));
    memset(sum, -1, sizeof(sum));
    for (int i = 0; i < N-1; ++i) {
      int a, b;
      cin >> a >> b;
      p[b] = a;
    }
    for (int i = 0; i < Q; ++i) {
      int t, x;
      cin >> t >> x;
      cnt[t] += x;
    }
    for (int i = 1; i <= N; ++i) {
      if (i != 1) cout << " ";
      cout << Solve(i);
    }
    cout << endl;
  }
}


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

int main()
{
    int N;
    cin >> N;
    int ans = 100;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        int j = 0;
        while (!(A & 1))
        {
            A = A >> 1;
            j++;
        }
        if (j < ans)
        {
            ans = j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/* ex2_1
    riverstone*/
 
#include<stdio.h>
#include <stdlib.h>

#define LIM 100001 //limit of num
int min(int a, int b);

 
int main(void){
    int i;
    int num, depth[LIM];//variable for N and matrix for depths
    int dp[LIM]={0};//matrix for Dynamic Programming

    //input
    scanf("%d", &num);
    for (i = 0; i < num; i++){
        scanf("%d", &depth[i]);
    }
    
    //initialization
    dp[0] = 0;
    dp[1] = abs(depth[0] - depth[1]);

    //Dynamic Programming
    for (i = 2; i < num; i++){
        dp[i]=min(abs(depth[i] - depth[i - 2]) + dp[i - 2], abs(depth[i] - depth[i - 1]) + dp[i - 1]);
    }
    printf("%d\n", dp[num-1]);//output the result
    return 0;
}

//min funciton
int min(int a, int b) {
    if (a < b)
        return a;
    else
        return b;
}

Measured memory_bytes: 896
s = input()
s = s.split()
n = int(s[0])
k = int(s[1])

if n==1:
  print(k)
elif n==2:
  print(k*(k-1))
else:
  ans = k
  for i in range(n-1):
    ans = ans*(k-1)
  print(ans)


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

int main(){
  int64_t a, b;
  cin >> a >> b;
  
  if(a < b){
    int64_t tmp = a;
    a = b;
    b = tmp;
  }
  
  int64_t r = a % b;
  while(r > 0){
    a = b;
    b = r;
    r = a % b;
  }
  int64_t gcd = b;
  
  map< int64_t, int64_t > ret;
  for(int64_t i = 2; i * i <= b; i++) {
    while(b % i == 0) {
      ret[i]++;
      b /= i;
    }
  }
  if(b != 1){
    ret[b] = 1;
  }
  cout << ret.size()+1 << endl;   
}

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

int main(void)
{
  int n;
  int a[10001]={0};
  int tmp;

  scanf("%d",&n);

  for(int i=1;i<100;i++)
  {
    for(int j=i;j<100;j++)
    {
      for(int k=j;k<100;k++)
      {
        tmp = i*i + j*j + k*k + i*j + j*k + k*i;
        if(tmp>10000) break;
        else if(i==j && j==k && k==i) a[tmp]++;
        else if(i==j && i!=k) a[tmp]+=3;
        else if(j==k && j!=i) a[tmp]+=3;
        else a[tmp]+=6;
      }
    }
  }

  for(int i=1;i<=n;i++)
  {
    printf("%d\n",a[i]);
  }

  return 0;
}

Measured memory_bytes: 1720
#include<iostream>

using namespace std;

int main(){

int W=0,H=0,x=0,y=0,r=0;

cin >> W >> H >> x >> y >> r;

if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){

cout << "Yes" << endl;
}

else{
cout << "No" << endl;
}

return 0;

}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{

     public static void main(String []args){
        long X,K,D;
        Scanner sc = new Scanner(System.in);
        
        X = sc.nextLong();
        K = sc.nextLong();
        D = sc.nextLong();
        
        
        long Xa = Math.abs(X);
        long ans = 0;
        
        long n = Xa / D;
        
        if(n >= K) {
            ans = Xa - K*D;
            
        }
        
        else {
            /*if((Xa - n*D) > -(Xa-(n+1)*D)) {
                if((K-(n+1))%2==0)
                    ans = -(Xa-(n+1)*D);
                else
                    ans = (Xa - n*D);
            }
            else {
                if((K-(n))%2==0)
                    ans = (Xa - n*D); 
                else
                    ans = -(Xa-(n+1)*D);
                
            }*/
            if ((K-n)%2==0) {
                ans = Xa - n*D;
            }
            else {
                ans = -(Xa - (n+1)*D);
                
            }
        }    
        //ans *=  (X<0?-1:1);
        System.out.println(ans);
         
     }
}

Measured memory_bytes: 35816
using System;
        using System.Linq;
        using System.Collections.Generic;
        using static System.Math;

            public class Program
    {
        public static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            int answer = 0;

            for (int i = 1; i <= input; i++)
            {
                int count = 0;
                for (int j = 1; j <= input; j++)
                {
                    if (i % j == 0) count++;
                }

                if (count == 8) answer++;
                i++;
            }

            Console.WriteLine(answer);
        }
    }

Measured memory_bytes: 13140
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

extern crate itertools;
use itertools::Itertools;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        r: [(usize1, usize1, usize, usize); q],
    }

    let ans = (1..=m)
        .combinations_with_replacement(n)
        .map(|combi| {
            r.iter()
                .filter(|(a, b, c, _)| combi[*b] - combi[*a] == *c)
                .map(|(_, _, _, d)| d)
                .sum::<usize>()
        })
        .max()
        .unwrap();
    
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=2e12;
ll cnt=0;
#define max 100005
#define nil -1

vector<int> pre,in,post;
int key=0;
int n;

void sort(int l,int r){
  if(l>=r)return;
  int root=pre.at(key++);
  int m=distance(in.begin(),find(in.begin(),in.end(),root));
  sort(l,m);
  sort(m+1,r);
  post.push_back(in.at(m));
}

void solve(){
  sort(0,pre.size());
  rep(i,n){
    if(i)cout<<" ";
    cout<<post[i];
  }
  cout<<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    int q;
    rep(i,n){
      cin>>q;
      pre.push_back(q);
    }
    rep(i,n){
      cin>>q;
      in.push_back(q);
    }
    solve();

   return 0;
}



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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0, r = 0;
    rep(i, N) {
        if (A[i] == 0) {
            r = 0;
        } else {
            ans += (r + A[i]) / 2;
            r = (r + A[i]) % 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
program disjoint_set_of_common_divisors
    implicit none
    integer(8):: a, b
    integer(8):: gcd
    integer(8):: i,j,count=0_8
    logical:: divided

    read*,a,b
    gcd = calc_gcd(a,b)
    
    do i=2_8, nint(sqrt(dble(gcd)))
        divided=.false.
        do while(mod(gcd,i)==0_8)
            gcd=gcd/i
            divided=.true.
        end do
        if (divided) count=count+1_8
    end do

    if (gcd > 1_8) count=count+1_8

    print*,count+1_8

contains
recursive function calc_gcd(a,b) result(ret)
    integer(8)::a,b,ret
    
    if (mod(a,b)==0_8) then
        ret = b
        return
    end if

    ret = calc_gcd(b,mod(a,b))

end function
end program disjoint_set_of_common_divisors

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<P> a(n),b(m);
  rep(i,n) cin>>a[i].fi>>a[i].se;
  rep(i,m) cin>>b[i].fi>>b[i].se;
  rep(i,n){
    ll cnt=inf;
    ll ans;
    rep(j,m){
      if(cnt>abs(a[i].fi-b[j].fi)+abs(a[i].se-b[j].se)){
        ans=j+1;
        cnt=abs(a[i].fi-b[j].fi)+abs(a[i].se-b[j].se);
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define EPS 1e-10
#define INF 1e18
#define mod 1000000007
#define PI acos(-1.0L)
#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 ALL(n) begin(n),end(n)
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
int main(void){
    int n;
    cin >> n;
    n %= 10;
    if(n == 2 or n == 4 or n == 5 or n == 7 or n ==9)cout << "hon" << endl;
    else if(n == 0 or n == 1 or n == 6 or n == 8)cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin>>n; 
    map<string,int> m;
    int val=0;
    for(int i=0;i<n;++i)
    {
    	string s; cin>>s;
    	m[s]++;
    	val=max(val,m[s]);
    }
    vector<string> v;
    for(auto it=m.begin();it!=m.end();++it)
    {
    	if(it->second==val)v.push_back(it->first);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();++i)cout<<v[i]<<endl;
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  int T, A; cin >> T >> A;
  int H[1010];
  for (int i = 0; i < N; i++) cin >> H[i];
  int ans = 0;
  double sa = 1e9;
  for (int i = 0; i < N; i++) {
    if (abs(1.0*A - (1.0*T - H[i]*0.006)) < sa) {
      sa = abs(1.0*A - (1.0*T - H[i]*0.006));
      ans = i;
    }
  }
  cout << ans+1 << endl;
}


Measured memory_bytes: 256
import sys
n=int(input())
p1=0
p2=0
for i in range(n):
    x=input().split()
    if x[0]>x[1]:
        p1+=3
    elif x[0]<x[1]:
        p2+=3
    else:
        p1+=1
        p2+=1
print(p1,p2)



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

public class Main {
  public static void main(String... args) {
    BufferedReader br = new BufferedReader(
      new InputStreamReader(System.in));

    try {
      int n = Integer.parseInt(br.readLine());
      String[] dishes = br.readLine().split(" ");
      String[] points = br.readLine().split(" ");
      String[] bonuses = br.readLine().split(" ");
      int total = 0;
      int nowDish = 0;
      int nowDishPoint = 0;
      int postDish = 0;
      int postDishBonus = 0;

      for(int i = 0; i < n; i++) {
        nowDish = Integer.parseInt(dishes[i]);
        nowDishPoint = Integer.parseInt(points[nowDish - 1]);
        
        if(nowDish > 1) {
          postDishBonus = Integer.parseInt(bonuses[nowDish - 2]);
        }

        if(i == 0 || nowDish != postDish + 1) {
          total += nowDishPoint;
        } else {
          total += nowDishPoint + postDishBonus;
        }

        if(i < n - 1) {
          postDish = nowDish;
        }
      }
      System.out.println(total);
      br.close();
    } catch(IOException e) {
      e.printStackTrace();
    }
  }
}

Measured memory_bytes: 21076
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] s = new int[w];
		for (int i = 0; i < w; i++) {
			s[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String line = sc.next();
			String[] ss = line.split(",");
			int a = Integer.parseInt(ss[0]) - 1;
			int b = Integer.parseInt(ss[1]) - 1;
			int c = s[a];
			s[a] = s[b];
			s[b] = c;
		}
		for (int i = 0; i < w; i++) {
			System.out.println(s[i]);
		}
	}
}

Measured memory_bytes: 26264
N, M = gets.split.map(&:to_i)

a = gets.split.map(&:to_i)
a.sort!.reverse!

#数字iを構成するマッチの本数b[i]とする 1-index
b = [0,2,5,5,4,5,6,3,7,6]

#使う数字をたかだか4種類に削減
if a.include?(5)
  [2,3].each do |i|
    a.delete(i)  if a.include?(i)
  end
end

if a.include?(9) && a.include?(6)
  a.delete(6)
end

if (a.include?(1) || a.include?(7)) && a.include?(9)
  a.delete(9)
end

if a.include?(1) && a.include?(4)
  a.delete(4)
end

#DPで解く
#dp[i] = ちょうどi本使うときに達成可能な桁数の最大値
dp = Array.new(N+1)
dp[0] = 0

1.upto(N) do |i|
  max = -Float::INFINITY
  0.upto(a.length-1) do |j|
    next if i-b[a[j]] < 0
    tmp = dp[i-b[a[j]]]
    max = tmp if tmp > max
  end
  dp[i] = 1 + max
end

#最適解の復元
cur = N

while cur != 0 do
  0.upto(a.length-1) do |i|
    next if cur-b[a[i]] < 0
    if dp[cur] == 1 + dp[cur - b[a[i]]]
      print a[i]
      cur -= b[a[i]]
      break
    end
  end
end

puts "\n"


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    vector<long long> B(N - 1); for (int i = 0; i < N - 1; i++) cin >> B[i];

    long long ans = B[N - 2];
    for (int i = N - 2; i > 0; i--) {
        ans += min(B[i], B[i - 1]);
    }
    ans += B[0];

    cout << ans << endl;

    return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);

LL N;
vector<LL> A;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	A.push_back(0);
	for(int i=0; i<N; i++){
		LL a;
		cin >> a;
		A.push_back(a);
	}

	LL ans = 0;
	for(int i=1; i<=N; i++){
		if(A[i] == 0){
			continue;
		}
		LL u = A[i]/2;
		ans += u;
		if((A[i] % 2) == 0){
			A[i] = 0;
		}
		else{
			A[i] = 1;
			if(i - 1 >= 1 && A[i-1] == 1){
				A[i-1] = 0;
				A[i] = 0;
				ans++;
			}
			else if(i + 1 <= N && A[i+1] > 0){
				A[i+1]--;
				A[i] = 0;
				ans++;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4224
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
  int d1, d2;
  scanf("%d %d %d", &n, &d1, &d2);
  vector<P> v1, v2;
  for(int i=0; i<2*n; i++){
    for(int j=0; j<2*n; j++){
      if(i*i+j*j==d1){
        if(i>0 && j>0){
          v1.push_back(P(i, j));
          v1.push_back(P(i, -j));
          v1.push_back(P(-i, j));
          v1.push_back(P(-i, -j));
        }else if(i==0){
          v1.push_back(P(0, j));
          v1.push_back(P(0, -j));
        }else{
          v1.push_back(P(i, 0));
          v1.push_back(P(-i, 0));
        }
      }else if(i*i+j*j==d2){
        if(i>0 && j>0){
          v2.push_back(P(i, j));
          v2.push_back(P(i, -j));
          v2.push_back(P(-i, j));
          v2.push_back(P(-i, -j));
        }else if(i==0){
          v2.push_back(P(0, j));
          v2.push_back(P(0, -j));
        }else{
          v2.push_back(P(i, 0));
          v2.push_back(P(-i, 0));
        }
      }
    }
  }
  vector<int> a1[400000], a2[400000];
  for(int x=0; x<2*n; x++){
    for(int y=0; y<2*n; y++){
      for(int i=0; i<v1.size(); i++){
        int s=v1[i].first, t=v1[i].second;
        if(x+s>=0 && x+s<2*n && y+t>=0 && y+t<2*n){
          a1[x*2*n+y].push_back((x+s)*2*n+y+t);
        }
      }
      for(int i=0; i<v2.size(); i++){
        int s=v2[i].first, t=v2[i].second;
        if(x+s>=0 && x+s<2*n && y+t>=0 && y+t<2*n){
          a2[x*2*n+y].push_back((x+s)*2*n+y+t);
        }
      }
    }
  }
  int e1[400000]={};
  for(int i=0; i<4*n*n; i++){
    if(e1[i]>0) continue;
    e1[i]=1;
    vector<int> v;
    v.push_back(i);
    while(!v.empty()){
      int x=v.back();
      v.pop_back();
      for(int j=0; j<a1[x].size(); j++){
        int y=a1[x][j];
        if(e1[y]==0){
          if(e1[x]==1){
            e1[y]=2;
          }else{
            e1[y]=1;
          }
          v.push_back(y);
        }
      }
    }
  }
  int count1=0;
  for(int i=0; i<4*n*n; i++){
    if(e1[i]==1) count1++;
  }
  int p1;
  if(count1>=2*n*n){
    p1=1;
  }else{
    p1=2;
  }
  int e2[400000]={};
  for(int i=0; i<4*n*n; i++){
    if(e1[i]!=p1) continue;
    if(e2[i]>0) continue;
    e2[i]=1;
    vector<int> v;
    v.push_back(i);
    while(!v.empty()){
      int x=v.back();
      v.pop_back();
      for(int j=0; j<a2[x].size(); j++){
        int y=a2[x][j];
        if(e1[y]!=p1) continue;
        if(e2[y]==0){
          if(e2[x]==1){
            e2[y]=2;
          }else{
            e2[y]=1;
          }
          v.push_back(y);
        }
      }
    }
  }
  int count2=0, p2;
  for(int i=0; i<4*n*n; i++){
    if(e2[i]==1) count2++;
  }
  if(count2>=n*n){
    p2=1;
  }else{
    p2=2;
  }
  int c=0;
  for(int i=0; i<4*n*n; i++){
    if(c>=n*n) break;
    if(e2[i]==p2){
      int x=i/(2*n), y=i%(2*n);
      printf("%d %d\n", x, y);
      c++;
    }
  }
	return 0;
}


Measured memory_bytes: 99576
#include <iostream>
#include <string>
#include <sstream>
#include <istream>
#include <vector>
using namespace std;

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

	int nowA;
	int prevA = 0;
	int startA;

	int maxDiff = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> nowA;
		if(i ==0){
			startA = nowA;
		}

		int diffA = nowA - prevA;
		if (maxDiff < diffA)
		{
			maxDiff = diffA;
		}

		if(i == N-1){
			diffA = (K - nowA) + startA;
			if (maxDiff < diffA)
			{
				maxDiff = diffA;
			}
		}
		prevA = nowA;
	}
	

	cout << K- maxDiff << endl;
	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  int accm = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    accm += A[i];
  }
  
  sort(A.begin(), A.end());
  accm -= A[N-1]/2;
  cout << accm;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll a[200005];
    int main()
    {
        fastread;
        ll n,i,j,k,l,m;
        cin>>n>>k;
        for(i=1;i<=n;i++)
        cin>>a[i];
        sort(a+1,a+n+1);
        ll sum=0;
        for(i=1;i<=n-k;i++){
        	sum+=a[i];
		}
		cout<<sum<<endl;
    	return 0;
    }

Measured memory_bytes: 1792
//
// Created by yuu on 2019-04-13.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <cstdlib>
#include <typeinfo>


using namespace std;


int main(void){
    string str;
    cin>>str;

    int ans1 = 0;
    int ans2 = 0;

    int zero_one[100010] = {};
    int one_zero[100010] = {};

    for (int i = 0; i < 100010; ++i) {
        if(i%2==0){
            one_zero[i]=1;
        }else{
            zero_one[i]=1;
        }
    }

    for (int j = 0; j < str.length(); ++j) {
        if(one_zero[j] != (int)(str[j]-'0')) {
            ans1++;
        }else{
            ans2++;
        }
    }

    cout<<min(ans1,ans2)<<endl;

    return 0;
}

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

int main(){

	int n,a,b,c,d,ans,i0,i1,i2=0;
	string hoge[]={"+","-"};
	cin >> n;
	a=n/1000;
	n=n%1000;
	b=n/100;
	n=n%100;
	c=n/10;
	n=n%10;
	d=n;
	for (i0=0;i0<2;i0++){
		for (i1=0;i1<2;i1++){
			for (i2=0;i2<2;i2++){
				if (i0==0){
					ans=a+b;
				}else{
					ans=a-b;
				}
				if (i1==0){
					ans=ans+c;
				}else{
					ans=ans-c;
				}
				if (i2==0){
					ans=ans+d;
				}else{
					ans=ans-d;
				}
				if (ans==7){
					goto end;
				}

			}
		}
	}
end:
	cout << a << hoge[i0] << b << hoge[i1] << c << hoge[i2] << d << "=7" << endl;
}


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

lst_A = []

lst_A.append(s)

flg = "false"

while 1:

    if s % 2 == 0:
        s = int(s / 2)

    else:
        s = s * 3 + 1

    for i in range(len(lst_A)):

        if lst_A[i] == s:
            flg = "true"
            break

    if flg == "true":
        break

    lst_A.append(s)

print(len(lst_A) + 1)






Measured memory_bytes: 2940
#include <stdio.h>
int main() {
	int a[2][100];
	int u[100], s[100];
	int n, ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < n; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	u[0] = a[0][0];
	s[n - 1] = a[1][n - 1];
	for (int i = 1; i < n; i++)
	{
		u[i] = u[i - 1] + a[0][i];
		s[n - 1 - i] = s[n - i] + a[1][n - 1 - i];
	}
	for (int i = 0; i < n; i++)
	{
		if (ans < u[i] + s[i]) {
			ans = u[i] + s[i];
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		int[] primeNumList = new int[100000];
		primeNumList[0] = -1;
		for(int i = 0; i < primeNumList.length; i++) {
			if(primeNumList[i] == -1) continue;
			for(int j = i + i + 1; j < primeNumList.length; j += (i + 1)) {
				primeNumList[j] = -1;
			}
		}
		
		/*
		for(int i = 0; i < 20; i++) {
			if(primeNumList[i] != -1) System.out.print((i + 1) + " ");
		}
		System.out.println();
		*/
		
		int[] susum = new int[50000];
		susum[0] = 0;
		susum[1] = 1;		
		for(int i = 2; i < susum.length; i++) {
			susum[i] = susum[i-1];
			if(primeNumList[2 * i] != -1 && primeNumList[i] != -1) susum[i]++;
		}
		
		/*
		for(int i = 0; i < 10; i++) {
			System.out.print(susum[i] + " ");
		}
		System.out.println();
		*/
		
		
		int Q = in.nextInt();
		
		for(int i = 0; i < Q; i++) {
			int L = in.nextInt();
			int R = in.nextInt();
			if(L == 1) System.out.println(susum[(R - 1) / 2]);
			else System.out.println(susum[(R - 1) / 2] - susum[((L - 1) / 2) - 1]);
		}
	}
}

Measured memory_bytes: 67204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 1e7 + 10;
int n;
ll f[N];
int prime[N];
bool is_prime[N];
int sieve(int n) {
	int p = 0;
	memset(is_prime, true, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}
ll ans;
int main() {
	scanf("%d", &n);
	int p = sieve(n);
	f[1] = 1;
	ans = 1;
	for (int i = 2; i <= n; i++) {
		int t = i;
		for (int j = 0; j < p && 1ll * prime[j] * prime[j] <= t; j++) {
			if (t%prime[j] != 0)continue;
			int cnt = 0;
			while (t%prime[j] == 0) {
				cnt++;
				t /= prime[j];
			}
			f[i] *= (cnt + 1);
			f[i] += cnt;
		}
		if (t != 1)f[i] *= 2, f[i]++;
		ans += 1ll * i*(f[i]+1);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 94300
h1, m1, h2, m2, k = map(int, input().split())
if h1 > h2:
    h2 += 24
elif h1 == h2:
    if m1 > m2:
        h2 += 24
print((h2 - h1) * 60 + (m2 - m1) - k)


Measured memory_bytes: 9168
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

ll h,w,n;
map<pair<ll,ll>,bool> f;
vector<pair<ll,ll> >v;
set<pair<ll,ll> >s;

int calc(int x,int y){
    int c=0;
    FOR(i,-1,2){
        FOR(j,-1,2){
            if(x+i<1 || x+i>h || y+j<1 || y+j>w){
                return 0;
            }
            if(f[mp(x+i,y+j)]){
                c++;
            }
        }
    }
    s.insert(mp(x,y));
    return c;
}

int main(){
    IOS

    cin>>h>>w>>n;
    FOR(i,0,n){
        int x,y;
        cin>>x>>y;
        f[mp(x,y)]=1;
        v.pb(mp(x,y));
    }
    ll ans[10];
    FOR(i,0,10){
        ans[i]=0;
    }
    FOR(p,0,n){
        FOR(i,-1,2){
            FOR(j,-1,2){
                int x=v[p].F,y=v[p].S;
                if(s.find(mp(x+i,y+j))!=s.end()){
                    continue;
                }
                ans[calc(x+i,y+j)]++;
            }
        }
    }
    ll sum=0;
    FOR(i,1,10){
        sum+=ans[i];
    }
    ans[0]=(h-2)*(w-2)-sum;
    FOR(i,0,10){
        cout<<ans[i]<<endl;
    }
  
    cerr<<"Time: "<<1.0/CLOCKS_PER_SEC<<" ms"<<endl;
    return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> sunuke(n);
    for (int i = 0; i < n; i++){
        sunuke[i] = 0;
    }
    int d;
    int s;
    for (int i = 0; i<k; i++){
        cin >> d;
        for (int j = 0; j < d; j++){
            cin >> s;
            sunuke[s-1]++;  
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (sunuke[i] == 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
int x,rev=0;
cin>>n;
int m=n;
do{
    x=n%10;
    rev=(rev*10)+x;
    n=n/10;
}while(n!=0);
if(m==rev){
    cout<<" Yes ";
}
else{
    cout<<" No";
}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin>>S;
    cout<<S.substr(0,3)<<"\n";
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[100005],f[100005];
int main()
  {int n,k;
    cin >> n >> k;
   int i,Min = 0x7fffffff,num = 0;
   memset(a,0,sizeof(a));
   memset(f,0,sizeof(f));
   for(i = 1;i <= n;i ++)
          {cin >>a[i];Min = min(a[i],Min);
          }
   for(i = 1;i <= n;i ++)
   {  if(a[i] != Min)f[num]++;
      else num++;
   }
   int cnt = 0;
   if(a[n] == Min)num--;
   for(i = 0;i <= num;i ++)
   {
    while(f[i] > 0)
        {   cnt ++;
            f[i] -= k-1;
        }
    if(f[i] < 0)
       f[i+1] += f[i];
   }
   cout<<cnt<<endl;
  }


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll inf = 1000000007;

int N,M,R,a,b,c;
int r[8];
ll d[201][201];
void do_wf(){
  for (int k = 1; k <= N; k++){
    for (int i = 1; i <= N; i++) { 
      for (int j = 1; j <= N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
  cin >>N>>M>>R;
  REP(i,R){ cin >>r[i];} sort(r,r+R);
  FILL2(d,N+1,N+1,inf);
  REP(i,M){
    cin >> a>> b>> c;
    d[a][b] = c;
    d[b][a] = c;
  }
  do_wf();
  
  ll ans = inf-1;
  do {
    ll t = 0;
    REP(i,R-1){
      t += d[ r[i] ][ r[i+1] ];
      if(t>=ans){break;}
    }
    if(t<ans){ ans = t;}
  } while (next_permutation(r,r+R));
  cout << ans <<"\n";
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        Node root = null;
        for (int i = 0; i < m; i++) {
            String cmd = scanner.next();
            if ("insert".equals(cmd)) {
                Node node = new Node(scanner.nextInt());
                if (root == null) {
                    root = node;
                    continue;
                }
                insert(root, node);
            } else {
                StringBuilder sb = new StringBuilder();
                root.inOrder(sb);
                sb.append("\n");
                System.out.print(sb.toString());
                sb = new StringBuilder();
                root.preOrder(sb);
                sb.append("\n");
                System.out.print(sb.toString());
            }
        }

    }

    private static void insert(Node root, Node node) {
        Node parent = root;
        while (true) {
            if (node.key < parent.key) {
                if (parent.left == null) {
                    parent.left = node;
                    break;
                }
                parent = parent.left;
            } else {
                if (parent.right == null) {
                    parent.right = node;
                    break;
                }
                parent = parent.right;
            }
        }
    }

    private static class Node {
        int key;
        Node parent;
        Node left;
        Node right;

        private Node(int key) {
            this.key = key;
        }

        private void inOrder(StringBuilder sb) {
            if (left != null) {
                left.inOrder(sb);
            }
            sb.append(" " + String.valueOf(key));
            if (right != null) {
                right.inOrder(sb);
            }
        }

        private void preOrder(StringBuilder sb) {
            sb.append(" " + String.valueOf(key));
            if (left != null) {
                left.preOrder(sb);
            }
            if (right != null) {
                right.preOrder(sb);
            }
        }
    }
}

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

struct Node {
	int ID;
	int d;
	bool visited;
	bool operator<(const Node& rhs) {return this->ID < rhs.ID;}
	bool operator>(const Node& rhs) {return this->ID > rhs.ID;}
	bool operator<=(const Node& rhs) {return this->ID <= rhs.ID;}
	bool operator>=(const Node& rhs) {return this->ID >= rhs.ID;}
	bool operator==(const Node& rhs) {return this->ID == rhs.ID;}
	bool operator!=(const Node& rhs) {return this->ID != rhs.ID;}
};

void BFS(std::vector<int>* adjlist, Node* nodes, std::queue<int> que)
{	
	nodes[que.front()].d = 0;
	
	while (!que.empty()) {
		int id = que.front(); que.pop();
		for (std::vector<int>::iterator it = adjlist[id].begin(); it != adjlist[id].end(); ++it) {
			if (!nodes[*it].visited) { 
				que.push(*it);
				nodes[*it].d = nodes[id].d + 1;
				nodes[*it].visited = true;
			}
		}
	}
}

int main()
{
	int n; std::cin >> n;
	
	std::vector<int>* adjlist = new std::vector<int>[n];
	Node* nodes = new Node[n];
	
	std::queue<int> que;
	
	for (int i=0; i<n; i++) {
		nodes[i].visited = false; nodes[i].d = -1;
	}
	
	for (int i=0; i<n; i++) {
		int x;
		int deg;
		std::cin >> x >> deg;
		nodes[i].ID = x-1;
		for (int j=0; j<deg; j++) {
			int y;
			std::cin >> y;
			adjlist[x-1].push_back(y-1);
		}
	}
	
	std::sort(nodes, nodes + n);
	

	que.push(0); nodes[0].visited = true;
	BFS(adjlist, nodes, que);
	
	
	
	for (int i=0; i<n; i++) {
		std::cout << nodes[i].ID + 1 << " " << nodes[i].d << std::endl;
	}
	
	delete[] adjlist;
	delete[] nodes;
	
	return 0;
}



Measured memory_bytes: 3156
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a=0, b = 0,c,d, n, k;
string s, t;


int main()
{
	cin >> n;
	vector<int> a(n); map<int, int> x;
	rep(i, n)
	{
		cin >> a[i]; x[a[i]]++;
	}
	auto begin = x.begin(), end = x.end(); int cnt = 0;
	for (auto z = begin; z != end; z++)
	{
		if ((z->second % 2) == 1)
			cnt++;
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 5376
s = input()
k = int(input())

prev = ""
count1 = 0
count2 = 0
count3 = 0
flag = 0
for i in s:
    if flag == 1:
        prev = i
        flag = 0
        continue
    if prev == i:
        count1 += 1
        flag = 1
    prev = i



for i in s:
    if flag == 1:
        prev = i
        flag = 0
        continue
    if prev == i:
        count2 += 1
        flag = 1
    prev = i

for i in s:
    if flag == 1:
        prev = i
        flag = 0
        continue
    if prev == i:
        count3 += 1
        flag = 1
    prev = i

if k % 2 == 1:
    ret = count1 + (k-1) // 2 * (count2 + count3)
else:
    ret = count1 + ((k-1)//2+1) * count2 + (k-1)//2 * count3

print(ret)


Measured memory_bytes: 3064
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        String S  = sc.next();
        String T  = sc.next();
        char[] s = S.toCharArray();
        char[] t = T.toCharArray();
        
      
        if(S.equals(T)){
          System.out.println("No");
          return;
        }else if(T.contains(S) && S.length() < T.length()){
          System.out.println("Yes");
          return;
        }
      
        for(int i = 0; i < s.length; i++){
          for(int j = 0; j < t.length; j++){
            if(s[i] < t[j]){
              System.out.println("Yes");
              return;
            }
          }
        }
      
       
        System.out.println("No");
	}
}

Measured memory_bytes: 35564
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

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

Measured memory_bytes: 256