akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int command_num;
	int i;
	char command[100];
	int top,bottom,north,south,east,west;
	int temp;
	while(1) {
		scanf("%d",&command_num);
		if(command_num==0)break;
		top=1;north=2;west=3;
		bottom=6;south=5;east=4;
		for(i=0;i<command_num;i++) {
			scanf("%s",command);
			switch(command[0]) {
				case 'n':
					temp=north;
					north=top;
					top=south;
					south=bottom;
					bottom=temp;
					break;
				case 's':
					temp=south;
					south=top;
					top=north;
					north=bottom;
					bottom=temp;
					break;
				case 'w':
					temp=west;
					west=top;
					top=east;
					east=bottom;
					bottom=temp;
					break;
				case 'e':
					temp=east;
					east=top;
					top=west;
					west=bottom;
					bottom=temp;
					break;
			}
		}
		printf("%d\n",top);
	}
	return 0;
}

Measured memory_bytes: 0
w=input()
s=[0]*123
for i in range(len(w)):
    s[ord(w[i-1])]+=1
c=1
for i in range(97,97+26):
    if s[i]%2==1:
        c=0
        break
if c==1:
    print("Yes")
else:
    print("No")


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

int sum(int x){
      int sum = 0;
      while(x > 0){
            sum += x % 10;
            x /= 10;
      }
      return sum;
}

int main(){
      int n,a,b;cin >> n >> a >> b;
      int ans = 0;
      for(int i = 1;i <= n;i++){
            int t = sum(i);
            if(t >= a && t <= b)ans += i;
      }
      cout << ans;
}

Measured memory_bytes: 256
N = gets.to_i
as = N.times.map{gets.to_i}.sort
bs = N.times.map{gets.to_i}.sort
ranges = N.times.map{|i| [as[i], bs[i]].sort}.sort
MOD = 10**9+7

ans = 1
queue = []
N.times do |i|
    queue.push(ranges[i][1])
    queue.shift while ranges[i][0] > queue[0]
    ans = ans * queue.length % MOD
end
puts ans

Measured memory_bytes: 12512
N = int(input())
S = input()

passwords = [str(i).zfill(3) for i in range(1000)]
ans = 0

for pw in passwords:
    S_copy = S
    FLG = True
    for digit in pw:
        if digit not in S_copy:
            FLG = False
            break
        else:
            index = S_copy.find(digit)
            S_copy = S_copy[index+1:]
    if FLG:
        ans += 1

print(ans)

Measured memory_bytes: 3188
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);

    long h = sc.nextLong();
    long count = 0;
    long n = h;
    long a = 1;


    for (int i = 1;n>0;i++ ) {
      if (n>1) {
        n=n/2;
        a = a*2;
        count+=2*a;
      }
      if (n==1) {
        n=0;

      }
    }

    System.out.println(count/2+1);
  }
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    long long ans;
    if(X/D > K){
        ans = X - K*D;
    } else {
        ll times = X/D;
        K -= times;
        X -= times*D;
        if(K%2 == 1) ans = abs(X - D);
        else ans = X;
    }
    cout << ans << '\n';
    return 0;
}
//Saw a part of the editorial

Measured memory_bytes: 3644
x = int(input())
dp = [False] * (x + 1)
dp[0] = True

items = [100, 101, 102, 103, 104, 105]
for i in items:
    for j in range(x + 1):
        if j + i >= x + 1:
            break
        dp[j + i] |= dp[j]
if dp[x]:
    print(1)
else:
    print(0)

Measured memory_bytes: 66936
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
remain = sum(A)
depth = 0
end = 1  # 現時点の深さの頂点の最大値
answer = 0
for i, a in enumerate(A):
    answer += end
    if end < a:
        print(-1); exit()
    end -= a
    remain -= a
    end *= 2
    end = min(remain, end)

print(answer)


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

int main() {
  string s,t,copy;
  cin>>s>>t;
  if(s.size()<t.size()){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  for(int i=s.size()-t.size();i>=0;i--){
    copy=s.substr(i,t.size());
    int x=0;
    for(int j=0;j<copy.size();j++){
      if(copy[j]!='?'&&copy[j]!=t[j]){
        x++;
      }
    }
    if(x==0){
      for(int j=0;j<s.size();j++){
        if(j>=i&&j<i+t.size()){
          s[j]=t[j-i];
        }
      }
      for(int j=0;j<s.size();j++){
        if(s[j]=='?'){
          cout<<'a';
        }
        else{
          cout<<s[j];
        }
      }
      cout<<endl;
      return 0;
    }
  }
  cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		for(;k > 0; k--) {
			int d = sc.nextInt();
			for(; d > 0; d--) {
				int x = sc.nextInt();
				if(!list.contains(x)) {
					n --;
					list.add(x);
				}
			}
		}
		if(n>=0) {
			System.out.println(n);
		}else {
			System.out.println(0);
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 33912
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	l := -1
	m := map[int]int{}
	var ans cint
	ans = cint(n + 1)
	for r := 0; r < n; r++ {
		if aa[r] <= k {
			m[aa[r]]++
		}
		for r > l && len(m) >= k {
			ans.minAs(cint(r - l))
			l++
			if m[aa[l]] > 0 {
				m[aa[l]]--
				if m[aa[l]] == 0 {
					delete(m, aa[l])
				}
			}
		}
	}
	if ans == cint(n+1) {
		fmt.Fprintln(writer, 0)
		return
	}
	fmt.Fprintln(writer, ans)
}

type cint int64

func (ct *cint) minAs(x cint) *cint {
	*ct = ct.min(x)
	return ct
}
func (ct *cint) maxAs(x cint) *cint {
	*ct = ct.max(x)
	return ct
}
func (ct cint) min(x cint) cint {
	if ct > x {
		return x
	}
	return ct
}
func (ct cint) max(x cint) cint {
	if ct < x {
		return x
	}
	return ct
}



Measured memory_bytes: 8736
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

char ch[100000];
int n, len, cnt = -1;
char ans[1000000];

int main() {
  scanf("%s", ch);
  len = strlen(ch);
  scanf("%d", &n);
  for(int i = 0; i < len; i += n)
    ans[++cnt] = ch[i];
  printf("%s\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    string s[n];
    rep(i,n)cin >> s[i];
    sort(s,s+n);

    int ma = 1;
    int tmp = 1;
    srep(i,1,n){
        if(s[i] == s[i-1]){
            tmp++;
        }else{
            tmp = 1;
        }
        ma = max(ma, tmp);
    }

    tmp = 0;
    rep(i,n){
        if(i == 0){
            tmp = 1;
        }else if(s[i] == s[i-1]){
            tmp++;
        }else{
            tmp = 1;
        }
        if(tmp == ma)cout << s[i] << endl;
    }
    
    return 0;
}
 
 


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


int main(){
    string S;
    cin >> S;
    int ans = 1;
    for (int i = 1; i < S.size(); i++)
    {
        if(S[i] == S[i-1]){
            i += 2;
            if(i == S.size()) ans++;
            else if(i == S.size() + 1) continue;
            else ans += 2;
        }
        else ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define fr(i,a,b) for(int i(a),end##i(b);i<=end##i;i++)
#define fd(i,a,b) for(int i(a),end##i(b);i>=end##i;i--)
using namespace std;
const int maxn=500+5;
int a[maxn],s[maxn];
int n,T;
int p[200];
void insert(int x){
	fd(i,63,0){
		if((x>>i)&1){
			if(!p[i]){
				p[i]=x;
				return ;
			}
			else x^=p[i];
		}
	}
}
bool check(int x){
	fd(i,63,0){
		if((x>>i)&1)x^=p[i];
	}
	return !x;
}
signed main(){
	scanf("%lld",&T);
	while(T--){
		memset(p,0,sizeof(p));	
		scanf("%lld",&n);
		fr(i,1,n)scanf("%lld",&a[i]);
		fr(i,1,n)scanf("%1lld",&s[i]);
		fd(i,n,1){
			if(s[i]){
				if(!check(a[i]))goto NO;
			}
			else{
				insert(a[i]);	
			}
		}
		printf("0\n");
		continue;
		NO:;
		printf("1\n");
	}
	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;cin >> n >> a >> b;
	vector<ll> A(n);
	rep(i,n) cin >> A.at(i);
	ll l=0,r=1000000000;
	while(r-l>1){
		ll k=l+(r-l)/2,sum=0;
		rep(i,n){
			if(A.at(i)-b*k>0){
				if((A.at(i)-b*k)%(a-b)==0) sum+=(A.at(i)-b*k)/(a-b);
				else sum+=(A.at(i)-b*k)/(a-b)+1;
			}
		}
		if(sum<=k) r=k;
		else l=k;
	}
	cout << r << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int k, t;
    cin >> k >> t;

    priority_queue<int> prQ;
    rep(i, t) {
        int a;
        cin >> a;
        prQ.push(a);
    }

    while(prQ.size() >= 2) {
        int x = prQ.top();  // xはprQの一番大きい要素
        prQ.pop();
        int y = prQ.top();  // yはprQの二番目に大きい要素
        prQ.pop();
        x--;  y--;
        if(x > 0) {
            prQ.push(x);
        }
        if(y > 0) {
            prQ.push(y);
        }
    }

    int ans = 0;
    if(prQ.size() == 1) {
        int x = prQ.top();
        ans = x-1;
    }

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

Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int p[33][214514]={};
signed main(){
    int n;cin>>n;
    int a,b;
    int ans=0;
    rep(i,1,n){
        int count=0;
        a=n-i;b=i;
        while(a){
            count+=(a%10);a/=10;
        }while(b){
            count+=(b%10);b/=10;
        }
        if(i==1)ans=count;
        else ans=min(ans,count);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
O = input()
E = input()
ans = ''
k = len(O)
l = len(E)
if k == l:
  for i in range(k):
    ans += O[i]+E[i]
else:
  for i in range(k-1):
    ans += O[i]+E[i]
  ans += O[k-1]
print(ans)

Measured memory_bytes: 3064
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ 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" ) } ; }
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 ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;

fn main() {
    input! {
        n: usize,
        v: [u64;n],
        c: [u64;n],
    }

    let mut ans = 0;

    for i in 0..n {
        if v[i] > c[i] {
            ans += v[i] - c[i];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#頭おかしくなりそうｗ
#大体考え方は合ってるはずだけどクラス分けするのめんどくさい
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]
M = int(input())
d = []
q = []
for i in range(M):
    a, b = map(int, input().split())
    d.append(a)
    q.append(b)

    
now = 1
score = 0

decrease = 0


for i,z in enumerate(t):
    score += s[i][z - 1]

def change():
    ret = 0
    contest = [0] * 26
    date = [D * (1 + D) // 2] * 26
    for i, z in enumerate(t):
        date[z - 1] -= (D - i) * (i -contest[z-1]+ 1)
        contest[z - 1] = i + 1
    for i, z in enumerate(date):
        ret += c[i] * z
    return ret


for i, z in zip(d, q):
    score -= s[i - 1][t[i - 1] - 1]
    score += s[i - 1][z - 1]
    t[i - 1] = z
    decrease = change()
    print(score-decrease)

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

int s[100005];

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",s+i);
  int ans = 0;
  if(s[1] == 1) {
    swap(s[1],s[2]);
    ans++;
  }
  for(int i=2;i<=n;i++) {
    if(s[i] == i) {
      swap(s[i], s[i+1]);
      ans++;
    }
  }
  printf("%d\n",ans);
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
  int w,s;
  for(;;){
    scanf("%d",&w); if(w==-1)break;
    s=1150;
    while(w>30)s+=160,w--;
    while(w>20)s+=140,w--;
    while(w>10)s+=125,w--;
    printf("%d\n",4280-s);
  }
  return 0;
}

Measured memory_bytes: 0
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    real a = A.map!(x => 1.0 / x).sum();
    writefln("%.10f", 1 / a);
}


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

int main() {
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for (int i = 0; cin >> ch; i++) {
    if (ch == '\\') {
      S1.push(i);
    } else if (ch == '/' && S1.size() > 0) {
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while (S2.size() > 0 && S2.top().first > j) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  while (S2.size() > 0) {
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++) {
    cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
    string s, t;
    //int i = 0, j = 1;
    int ans = 1000,ans_buf = 0;
    cin >> s >> t;
    if(s.find(t) != string::npos)cout << "0" << endl;
    else{
        for(int i = 0; i <= s.length() - t.length(); i++){
            ans_buf = 0;
            for(int j = 0; j < t.length(); j++){
                if(s[i+j] != t[j])ans_buf++;
            }
            if(ans > ans_buf)ans = ans_buf;
        }
        cout << ans << endl;

    }

    return 0;
}

Measured memory_bytes: 3600
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

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

    int ans = 1;
    for (int i = 0; i < n; i++) {
        ans = min(ans * 2, ans + k);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if(a==0){
    cout << "1" << endl;
  }
  if(b==0){
    cout << "2" << endl;
  }
  if(c==0){
    cout << "3" << endl;
  }
  if(d==0){
    cout << "4" << endl;
  }
  if(e==0){
    cout << "5" << endl;
  }
}

Measured memory_bytes: 3564
#include<iostream>
#include<string.h>
int main()
{
    char a[11] = {'\0'};
    char b[12]={'\0'};
    char c[11]={'\0'};
    std::cin>>a>>b;
    for(int i=0;i<strlen(b)-1;i++){
        c[i]=b[i];
    }
    if(strcmp(a,c)){
        std::cout<<"No"<<std::endl;
    }
    else{
        
        std::cout<<"Yes"<<std::endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  
  long long N,count,A[100],B[100];
  
  cin >> N;
  rep(i,N-1){
    cin >> B[i];
  }
  A[0]=B[0];
  A[N-1]=B[N-2];
  
  for (int i = 1; i < N-1; i++){
    if ( B[i-1]>=B[i]){
      A[i] = B[i];
    }
    if ( B[i-1]<B[i]){
      A[i] = B[i-1];
    }
  }
  rep(i,N){
    count += A[i];
  }
  cout << count << endl;
}

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

using namespace std;

int main() {
		string S;
		cin >> S;
		if((S[0] =='1' && S[1] > '2') || (S[0] > '1') || (S[0] == '0' && S[1] == '0')) {
				if((S[2] == '1' && S[3] > '2') || (S[2] > '1') || (S[2] == '0' && S[3] == '0')) {
						cout << "NA" << endl;
				} else {
						cout << "YYMM" << endl;
				}
		} else {
				if((S[2] == '1' && S[3] > '2') || (S[2] > '1') ||  (S[2] == '0' && S[3] == '0')) {
						cout << "MMYY" << endl;
				} else {
						cout << "AMBIGUOUS" << endl;
				}
		}
		return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 1000000007
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<string>s(n+1);
	vector<string>anss;
	rep(i, 0, n)cin >> s[i];
	s[n] = "zzzzzzzzzzz";
	sort(s.begin(), s.end());
	int x=1,ans = 0;
	bool flag = false;
	rep(i, 1, n+1) {
		if (s[i] != s[i - 1]) {
			if (ans == x) {
				anss.push_back(s[i - 1]);
				flag = true;
			}
			if (ans > x) {
				x = ans;
				while (!anss.empty())anss.erase(anss.begin());
				anss.push_back(s[i-1]);
				flag = true;
			}
			ans = 0;
			continue;
		}
		ans++;
	}
	if (!flag)rep(i, 0, n)cout << s[i] << endl;
	else for (auto t : anss)cout << t << endl;
}



Measured memory_bytes: 11472
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();
		
		int count = 0;
		
		for(int i = 0; i *R<=N; i++){
			for(int j = 0; i * R + j * G <=N; j++){
				if((N - (i * R + j * G)) % B ==0) {
					count ++;
				}
			}
		}
		System.out.println(count);
	}
}

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

using namespace std;

int main(){
	string x;
	
	while(1){
		cin >> x;
		if(x == "0") break;
		int n = 0;
		for(int i = 0;x[i];i++){
			n += x[i] - '0';
		}
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut it = s.split_whitespace();
	let s: Vec<_> = it.next().unwrap().chars().collect();
	let t: Vec<_> = it.next().unwrap().chars().collect();
	let mut ans = std::usize::MAX;
	for i in 0..=s.len() - t.len() {
		let cnt = t.iter().zip(s[i..].iter()).filter(|(&t, &s)| s == t).count();
		if ans > t.len() - cnt {
			ans = t.len() - cnt;
		}
	}
	println!("{}", ans);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define FBO find_by_order
#define OOK order_of_key
#define mset(m,v) memset((m),(v),sizeof(m))
#define inrep int TC;cin>>TC;while(TC--)
#define cppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PI 3.1415926535897932384626433832795028841971693993751
#define trace1(x) cerr<<#x<<": "<<x<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n"
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// SOLUTION

int main() {
	cppio;
	int n;
	cin >> n;
	bool ok = true;
	int t, x, y;
	int cx = 0, cy = 0, pt = 0;
	while(n--) {
		cin >> t >> x >> y;
		int dst = abs(x - cx) + abs(y - cy);
		int tst = t - pt;
		if(tst < dst) ok = false;
		if(dst < tst && ((tst&1) && (~dst&1) || ((~tst&1) && (dst&1)))) ok = false;
		cx = x; cy = y;
		pt = t;
	}
	if(ok) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [10**9+1]*N
dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        if i+k >= N:
            continue
        dp[i+k] = min(dp[i]+abs(h[i+k]-h[i]), dp[i+k])

print(dp[N-1])

Measured memory_bytes: 52448
import math
N = int(input())
S = input()
if N % 2 == 1:
    print("No")
    exit()

S_fommer = S[:math.floor(N/2)]
S_latter = S[math.ceil(N/2):]

if S_fommer == S_latter:
    print("Yes")
else:
    print("No")

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

int main(){
  long long N, M;
  cin >> N >> M;
  vector<pair<long long,long long>> D(N);
  for(int i=0; i<N; i++){
    cin >> D[i].first >> D[i].second;
  }
  sort(D.begin(),D.end());
  long long ans=0;
  for(int i=0; i<N; i++){
    if(D[i].second<=M){
      ans+=D[i].first*D[i].second;
      M-=D[i].second;
    }
    else{
      ans+=D[i].first*M;
      break;
    }
  }
  cout << ans << endl;
}

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

ll sub(ll A, ll B){
    if(A == 0 || B == 0 || A == B){
        return 0;
    }

    ll ans = 0;
    if(B >= 2 * A){
        ans = ((B - A) / A) * 2 * A;
        ans += sub(A, A + B % A);
    }else{
        if(A % (B - A) == 0){
            ans = (A / (B - A)) * 3 * (B - A) - (B - A);
        }else{
            ans = (A / (B - A)) * 3 * (B - A) + (A % (B - A)) * 2;
        }
        ans += sub(A % (B - A), B - A);
    }
    return ans;
}

void solve(long long N, long long X){
    ll ans = 0;
    if(N <= 2 * X){
        if(X % (N - X) == 0){
            ans = 3 * X;
        }else{
            ans = (X / (N - X)) * 3 * (N - X) + 2 * (X % (N - X)) + (N - X);
        }
        ans += sub(X % (N - X), N - X);
    }else{
        ans = N + X + sub(X, N - X);
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    solve(N, X);
    return 0;
}


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

using namespace std;

template <class T>
class Queue{
  //メンバ関数
public:
  struct Node{
    Node* prev; //前のノードへのポインタ
    Node* next; //後のノードへのポインタ
    T value; //このノードに格納されているデータ
  };
private:
  Node* top;
  Node* end;
  int max;
  int element_num;
public:
  Queue(int num);
  T dequeue();
  void enqueue(T val);
  bool isEmpty();
  bool isFull();
};

template <class T>
Queue<T>::Queue(int num){
  top = end = nullptr;
  max = num;
  element_num = 0;
}

template <class T>
T Queue<T>::dequeue(){
  if(isEmpty()){
    printf("This Queue is empty.\n");
    //return nullptr;
    //部分型を考えるとTにできることが全部できるものでないと返り値としては適切でない。それにnullptrはもちろんポインタ限定なので無理かな。
    exit(1);
  }
  T out = top->value;
  top = top->next;
  if(element_num > 1){
    delete top->prev;
    top->prev = nullptr;
  }
  else{//要素が1個の時
    delete end;
    end = nullptr;
  }
  element_num--;
  return out;
}

template <class T>
void Queue<T>::enqueue(T val){
  if(isFull()){
    printf("This Queue is full.\n");
    return;
  }
  Node* next_end = new Node;
  next_end->value = val;
  next_end->next = nullptr;
  next_end->prev = end;
  if(isEmpty()){
    top = next_end;
  }
  else{
    end->next = next_end;
  }
  end = next_end;
  element_num++;
  return;
}

template <class T>
bool Queue<T>::isEmpty(){
  if(element_num == 0) return true;
  return false;
}

template <class T>
bool Queue<T>::isFull(){
  if(element_num == max) return true;
  return false;
}

//以下問題に固有の部分

//名前と時間を持つ構造体
typedef struct Process{
  string name;
  int time;
} process;

int main(){
  int n,q;
  cin >> n;//プロセス数
  cin >> q;//OSが作業させてくれる時間(1回あたり)quantum
  process* pr = new process[n];
  Queue<process>* queue = new Queue<process>(n);
  for(int i = 0; i < n; i++){
    cin >> pr[i].name;
    cin >> pr[i].time;
    queue->enqueue(pr[i]);
  }
  int elapsed_time = 0; //経過時間

  while(!(queue->isEmpty())){
    process tmp = queue->dequeue();
    if( 0 < tmp.time & tmp.time <= q){
      elapsed_time += tmp.time;
      tmp.time = 0;
      printf("%s %d\n",tmp.name.c_str(),elapsed_time);
    }
    else{//今回では終わらない時
      elapsed_time += q;
      tmp.time -= q;
      queue->enqueue(tmp);
    }
  }

  return 0;
}



Measured memory_bytes: 8744
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<fstream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
#define PI 3.14159265358979
using namespace std;

typedef vector<vector<int> > vtype;
typedef long long ll;

int main()
{
	//ios::sync_with_stdio(false);
	int n = 0;
	cin >> n;
	map<string, int> m1;
	map<int, string> m2;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		m1[s] += 1;
	}
	int max1 = 0;
	for(auto i = m1.begin(); i != m1.end(); ++i)
		if(max1 < i->second)
			max1 = i->second;
	for(auto i = m1.begin(); i != m1.end(); ++i)
		if(max1 == i->second)
			cout << i->first << endl;
    return 0;
}















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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool p = false;
  if (a + b == c) p = true;
  if (b + c == a) p = true;
  if (c + a == b) p = true;
  if (p) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 3556
import fractions

N,K=map(int,input().split())
A=list(map(int,input().split()))

A=list(set(A))
N=len(A)
A.sort()

g=A[0]
for i in range(N-1):
    g=fractions.gcd(g,A[i+1])

if K%g==0 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
print(ans)

Measured memory_bytes: 16312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double d =0.0;
		for (int i=0;i<n;i++) {
			int temp = sc.nextInt();
			d+=((double)1/(double)temp);
		}
		System.out.println((double)1/d);

	}
}

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

struct res{
  int num;
  string name;
  int score;
};

int main(){
  	int n;cin>>n;
	struct res shop[n];
  	struct res hozon;
  	for(int i=0;i<n;i++){
      shop[i].num=i+1;
      cin>>shop[i].name;
      cin>>shop[i].score;
    }
  	for(int k=0;k<n;k++){
      for(int i=0;i<n-1;i++){
        if(shop[i].name>shop[i+1].name){
          hozon=shop[i];
          shop[i]=shop[i+1];
          shop[i+1]=hozon;   
        }else if(shop[i].name==shop[i+1].name){
          if(shop[i].score<shop[i+1].score){
            hozon=shop[i];
          	shop[i]=shop[i+1];
          	shop[i+1]=hozon;
          }
        }
      }
    }
  	for(int i=0;i<n;i++){
      cout<<shop[i].num<<endl;
    }
  	
  return 0;
}

Measured memory_bytes: 256
using System;

class MainClass
{
    
    public static void Main(string[] args)
    {


        long N = long.Parse(Console.ReadLine());
        string[] s1 = Console.ReadLine().Split(' ');
        string[] s2 = Console.ReadLine().Split(' ');
        long[] a = new long[N];
        long[] b = new long[N];
        long countA = 0;
        long countB = 0;



        for (int i = 0; i < N; i++)
        {

            a[i] = long.Parse(s1[i]);
            b[i] = long.Parse(s2[i]);

        }

        for (int i = 0; i < N;i++)
        {

            if(a[i] == b[i])
            {
                continue;
            }
            else if(a[i]>=b[i])
            {
                countB += a[i] - b[i];
            }
            else if((b[i]-a[i])%2 == 0)
            {
                countA += (b[i] - a[i]) / 2;
            }
            else
            {
                countA += (b[i] - a[i]) / 2 + 1;
                countB += 1;
            }

        }

        if(countB <= countA)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

        //string[] s1 = Console.ReadLine().Split(' ');
        //long x = long.Parse(s1[0]);
        //long y = long.Parse(s1[1]);


        //if(x == y)
        //{
        //    Console.WriteLine("-1");
        //}
        //else if(x%y == 0)
        //{
        //    Console.WriteLine("-1");
        //}
        //else
        //{
        //    Console.WriteLine(x);
        //}

        //Console.WriteLine("Yes");
        //Console.WriteLine("No");

    }

}


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

using namespace std;

const int MAX = 1e+5;

int h, w, d;
int a[MAX][2];
int sum[MAX];
int q, l, r;

inline int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

int main() {
	scanf("%d %d %d", &h, &w, &d);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int x;			
			scanf("%d", &x);
			a[x][0] = i;
			a[x][1] = j;
		}
	}
	sum[0] = 0;
	for (int i = 1; i <= d; i++) {
		sum[i] = 0;
	}
	for (int i = d + 1; i <= h * w; i++) {
		sum[i] = sum[i - d] + abs(a[i][0] - a[i - d][0]) + abs(a[i][1] - a[i - d][1]);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d %d", &l, &r);
		printf("%d\n", sum[r] - sum[l]);
	}
	return 0;
}

Measured memory_bytes: 2176
main = do
    [a,b] <- map read . words <$> getLine :: IO [Int]
    let ans | a <= 0 && b >= 0 = "Zero"
            | a > 0 = "Positive"
            | b < 0 = if even (b - a - 1) then "Positive" else "Negative"
    putStrLn ans

Measured memory_bytes: 3792
from math import factorial
n = int(input())
s = [input() for i in range(n)]
d = {}
for i in s:
    x = "".join(sorted(list(i)))
    if x not in d:
        d[x] = 1
    else:
        d[x] += 1
ans = 0
for i in d:
    if d[i] >= 2:
        ans += factorial(d[i]) // (factorial(d[i]-2)*2)
print(ans)

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

int main() {
    int n, d;
    cin >> n >> d;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i) >> y.at(i);
    }
    two_sat ts(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (abs(x.at(i) - x.at(j)) < d) ts.add_clause(i, false, j, false);
            if (abs(x.at(i) - y.at(j)) < d) ts.add_clause(i, false, j, true);
            if (abs(y.at(i) - x.at(j)) < d) ts.add_clause(i, true, j, false);
            if (abs(y.at(i) - y.at(j)) < d) ts.add_clause(i, true, j, true);
        }
    }
    if (not ts.satisfiable()) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        auto p = ts.answer();
        for (int i = 0; i < n; i++) {
            if (p[i]) {
                cout << x.at(i) << endl;
            } else {
                cout << y.at(i) << endl;
            }
        }
    }
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;

int main() {
  ll x;
  ll depo = 100;
  ll cnt = 0;
  cin >> x;
  while(depo < x) {
    cnt++;
    depo+= depo*0.01;
  }
  cout << cnt << endl;;
}


Measured memory_bytes: 3636
#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, m, i, j, ans = 0;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++)
    {
        cin >> x[i];
    }
    
    sort(x.begin(), x.end());
    vector<int> dis(m - 1);
    for (int i = 0; i < m - 1; i++)
    {
        dis[i] = abs(x[i] - x[i + 1]);
    }

    sort(dis.begin(), dis.end());
    for (int i = 0; i < (m - 1) - (n - 1); i++)
    {
        ans += dis[i];
    }
    
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long int;
constexpr ll M = LLONG_MAX;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

void solve() {
    int n;
    cin >> n;

    cout << sum_1(n) - 3*sum_1(n/3) - 5*sum_1(n/5) + 15*sum_1(n/15) << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

int main()
{
  int N, K;
  std::cin >> N >> K;
  std::vector<int> vh(N, 0);
  for (int i = 0; i < N; ++i) std::cin >> vh[i];

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (vh[i] >= K) cnt++;
  }

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


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

#define debug(x) cerr<<#x<<"="<<x<<endl;
#define m(a,b) memset(a,b,sizeof(a))
typedef long long ll;

int main(){
	int a,b;
	cin>>a>>b;
	if (b<10){
		int ans=a*10+b;
		int c=(int)sqrt(ans);
		if (c*c!=ans)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}
	else if(b<99){
		int ans=a*100+b;
		int c=(int)sqrt(ans);
		if (c*c!=ans) cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}
	else{
		int ans=a*1000+b;
		int c=(int)sqrt(ans);
		if (c*c!=ans) cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;

	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define Maxn 10000000
#define Mod 998244353
int n;
int ksm(int a,int b){
	int ans=1;
	while(b){
		if(b&1){
			ans=1ll*ans*a%Mod;
		}
		b>>=1;
		a=1ll*a*a%Mod;
	}
	return ans;
}
int frac[Maxn+5],inv[Maxn+5];
void init(){
	frac[0]=1;
	for(int i=1;i<=n;i++){
		frac[i]=1ll*frac[i-1]*i%Mod;
	}
	inv[n]=ksm(frac[n],Mod-2);
	for(int i=n-1;i>=0;i--){
		inv[i]=1ll*inv[i+1]*(i+1)%Mod;
	}
}
int C(int n,int m){
	return 1ll*frac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
int main(){
	scanf("%d",&n);
	init();
	int ans=ksm(3,n);
	for(int i=(n>>1)+1;i<=n;i++){
		ans-=C(n,i)*2ll%Mod*ksm(2,n-i)%Mod;
		ans=(ans+Mod)%Mod;
	}
	printf("%d\n",ans);
	return 0;
}


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

int n, k, h[100005], dp[100005];

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	cin >> h[1];
	for (int i = 1; i <= n; i++) {
		dp[i] = 2e9;
	}
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		cin >> h[i];
		for (int j = min(i - 1, k); j >= 1; j--) {
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n];
	return 0;
}


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

using namespace std;

int main () {
	int n, c = 0;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 1; i < n - 1; i++) {
		if (
			p[i - 1] <= p[i] && p[i] <= p[i + 1] ||
			p[i + 1] <= p[i] && p[i] <= p[i - 1]
		) {
			c++;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;

	return true;
}

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

	vector<ll> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	int sol = 0;

	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			for (int k = j + 1; k < n; ++k) {
				if (v[i] == v[j] || v[i] == v[k] || v[j] == v[k]) continue;
				ll m = max({v[i], v[j], v[k] });
				ll sum = v[i] + v[j]+ v[k];

				if (m < sum - m) ++sol;
			}
		}
	}

	std::cout << sol << '\n';

	return 0;
}

Measured memory_bytes: 3596
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    A, B, C = sorted(lr())
    if A == B and B < C:
        print('Yes')
    elif A < B and B == C:
        print('Yes')
    else:
        print('No')
resolve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)
#define endl "\n"
#define ios std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

ll dp[105][100005],wht[105],val[105];

int main(){
	ios;
	ll n,w;
	cin>>n>>w;

	F(i,0,100) F(j,1,100000) dp[i][j]=1e18;

	F(i,1,n) cin>>wht[i]>>val[i];

	F(i,1,n){
		F(j,1,100000){
			if(j-val[i]>=0){
				dp[i][j]=min(dp[i-1][j-val[i]]+wht[i],dp[i-1][j]);
			}
			else dp[i][j]=dp[i-1][j];
		}
	}

	for(int i=100000;i>=0;i--) if(dp[n][i]<=w) out(i);
}

Measured memory_bytes: 80128
#prime_divisionを用いた。
require "prime"
x = gets.chomp.to_i
x.downto (1) do |i|
    ans = i.prime_division
    size = ans.size
    count = 0
    if size == 1 && ans[0][1] != 1 && x >= 4
        puts i
        break
    elsif size >= 2 
        count = 0
        me = ans[0][1] 
        ans.each do |i|
            if me == i[1] && me != 1 
                count += 1
            end
        end
        if count == size
            puts i
            break
        end
    elsif x < 4
        puts "1"
        break
    end
end


Measured memory_bytes: 14364
x = int(input())
def isPrime(n):
 cnt = 0
 for i in range(1, n + 1):
  if n % i == 0:
   cnt += 1
 if cnt == 2:
  return True
 else:
  return False
   
while True:
 if isPrime(x):
  print(x)
  break
 else:
  x += 1








Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// 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 $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")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input!{ l: usize }
    let mut pool = Vec::new();
    let mut tmp = l;
    for i in (0 .. 19).rev() {
        if tmp == 1 {
            pool.push((i, i + 1, 0));
            continue;
        }
        pool.push((i, i + 1, tmp / 2));
        pool.push((i, i + 1, 0));
        if tmp % 2 == 1 {
            pool.push((0, i + 1, tmp - 1));
        }
        tmp /= 2;
    }
    puts!("{} {}\n", 20, pool.len());
    for (u, v, w) in pool {
        puts!("{} {} {}\n", u + 1, v + 1, w);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>//coded by Nurstan ^_^

#define ll long long
#define pb push_back

#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define all(x) x.begin(), x.end()
#define F first
#define S second

// fixed << setprecision
// next_permutation(a, a + n)
// set <int> :: iterator it = x.begin(); it != x.end(); it ++

using namespace std;

inline void boost(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main(){
	boost();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int a[n * 2];
	for(int i = 0; i < n * 2; i ++) {
		cin >> a[i];
	}
	ll sum = 0;
	sort(a, a + n * 2);
	for(int i = 0; i < n * 2 - 1; i += 2) {
		sum += min(a[i], a[i + 1]);
	}
	cout << sum;	
	exit(0);
}



Measured memory_bytes: 256