akhauriyash/Code-Regression huggingface dataset:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

abc  =[list(sr()) for i in range(3)]
for a in abc:
    a.reverse()
dic = {'a':0, 'b':1, 'c':2}
now = dic[abc[0].pop()]

while True:
    if abc[now]:
        now = dic[abc[now].pop()]
    else:
        if now == 0:
            print('A')
        elif now == 1:
            print('B')
        else:
            print('C')
        break

Measured memory_bytes: 77212
#include <iostream>

#include <vector>

#include <algorithm>

#include <sstream>

#include <string>

#include <cmath>

#include <list>

#include <set>
#include <cstdlib>
using namespace std;

int in() {int x; cin >> x; return x;}

template <typename T> class SegTree

{

public:

	int n;

	T T_max;

	vector<T> dat;

	SegTree(int n_, T t_max)

	{

		int n = 1;

		T_max = t_max;

		while (n < n_)n *= 2;

		for (int i = 0; i < 2 * n - 1; i++)dat.push_back(t_max);

	}

	void update(int k, T a)

	{

		k += n - 1;

		dat[k] = a;

		while (k > 0)

		{

			k = (k - 1) / 2;

			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);

		}

	}



	//[a,b)

	T query(int a, int b)

	{

		return _query(a, b, 0, 0, n);

	}



private:

	T _query(int a, int b, int k, int l, int r)

	{

		if (r <= a || b <= l)return T_max;

		if (a <= l && r <= b)return dat[k];

		else

		{

			T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);

			T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);

			return min(vr, vl);

		}

	}

};

int main()
{
	string a = " abcdefghijklmnopqrstuvwxyz.?! ";
	string b;
	while (cin >> b)
	{
		string ans;
		if (b.size() % 2)
		{
			cout << "NA" << endl;
			continue;
		}
		for (int i = 0; i < b.size(); i += 2)
		{
			int A = b[i] - '0';
			int B = b[i + 1] - '0';
			if (A < 0 || A > 6)
			{
				ans = "NA";
				break;
			}
			if (B < 0 || B > 5)
			{
				ans = "NA";
				break;
			}
			A--;
			int C = A * 5 + B;
			if (C > 30 || C <= 0)
			{
				ans = "NA";
				break;
			}
			ans += a[C];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1196
import math
import sys

X = int(input())
LIM = 100004 # 100003が素数
num = [0] * LIM
num[0] = 1
num[1] = 1
if X == 2:
    print(X)
else:
    for i in range(2,X):
        if num[i] == 0:
            k = i
            cnt = 1
            while k <= LIM-1:
                num[k] = 1
                cnt += 1
                k = i*cnt
                #print(k)



    S = X
    while num[S] == 1:
        S += 1 

    print(S)


Measured memory_bytes: 3828
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}


use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::collections::HashMap;

pub trait BinarySearch<T> {
  fn lower_bound(&self, x: &T) -> usize;
  fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
  fn lower_bound(&self, x: &T) -> usize {
    let mut low = 0;
    let mut high = self.len();

    while low != high {
      let mid = (low + high) / 2;
      match self[mid].cmp(x) {
        Ordering::Less => {
          low = mid + 1;
        }
        Ordering::Equal | Ordering::Greater => {
          high = mid;
        }
      }
    }
    low
  }
  fn upper_bound(&self, x: &T) -> usize {
    let mut low = 0;
    let mut high = self.len();

    while low != high {
      let mid = (low + high) / 2;
      match self[mid].cmp(x) {
        Ordering::Less | Ordering::Equal => {
          low = mid + 1;
        }
        Ordering::Greater => {
          high = mid;
        }
      }
    }
    low
  }
}

fn main() {
  let n = read::<i64>();
  let mut middle_map: BTreeMap<i64, i64> = BTreeMap::new();

  let mut top_vec = vec![];
  let mut bottom_vec = vec![];

  for _ in 0..n {
    let a = read::<usize>();
    top_vec.push(a);
  }

  for _ in 0..n {
    let b = read::<i64>();
    *middle_map.entry(b).or_insert(0) += 1;
  }

  for _ in 0..n {
    let c = read::<usize>();
    bottom_vec.push(c);
  }

  top_vec.sort();
  bottom_vec.sort();
  let mut ans = 0;

  for (k, v) in middle_map.iter() {
    ans += top_vec.lower_bound(&(*k as usize)) as i64
      * *v
      * (n - bottom_vec.upper_bound(&(*k as usize)) as i64);
  }

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

Measured memory_bytes: 8572
#include <iostream>
#include <string.h>

using namespace std;
string s;
int main(){
	ios::sync_with_stdio(false);
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
	cout<<"Yes"<<endl;
	else {
		cout<<"No"<<endl;
	}
		return 0;
}

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

using namespace std;

void t(int a[],int b[],int c[]) {
	for (int i = 0; i < 7; i++) {
		if (a[i] != c[i]) {
			a[i] = c[i];
			b[i] = 1;
		} else {
			b[i] = 0;
		}
	}
	return;
}

int main() {
	int k,n;

	while (1) {
		int a[7] = {0};
		int b[7];
		cin >> n;
		if (n == -1) {
			break;
		} else {
			for (int j = 0; j < n; j++) {
				cin >> k;
					if (k == 0) {
						int c[] = {1,1,1,1,1,1,0};
						t(a,b,c);
					} else if (k == 1) {
						int c[] = {0,1,1,0,0,0,0};
						t(a,b,c);
					} else if (k == 2) {
						int c[] = {1,1,0,1,1,0,1};
						t(a,b,c);
					} else if (k == 3) {
						int c[] = {1,1,1,1,0,0,1};
						t(a,b,c);
					} else if (k == 4) {
						int c[] = {0,1,1,0,0,1,1};
						t(a,b,c);
					} else if (k == 5) {
						int c[] = {1,0,1,1,0,1,1};
						t(a,b,c);
					} else if (k == 6) {
						int c[] = {1,0,1,1,1,1,1};
						t(a,b,c);
					} else if (k == 7) {
						int c[] = {1,1,1,0,0,1,0};
						t(a,b,c);
					} else if (k == 8) {
						int c[] = {1,1,1,1,1,1,1};
						t(a,b,c);
					} else {
						int c[] = {1,1,1,1,0,1,1};
						t(a,b,c);
					}
				
					for (int i = 6; i >= 0; i--) {
						cout << b[i];
					}
					cout << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b; cin >> a >> b;
	cout << (a * 3 + b) / 2;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int n,m;
	cin >> n >> m;
	long long a[55],b[55],c[55],d[55];
	for(int i=1;i<=n;i++)
		cin >> a[i-1] >> b[i-1];
	for(int i=1;i<=m;i++)
		cin >> c[i-1] >> d[i-1];
	
	for(int i=1;i<=n;i++)
	{
		int ans=0;
		long long ansdis=5000000009;
		for(int j=1;j<=m;j++)
		{
			long long dis=abs(a[i-1]-c[j-1])+abs(b[i-1]-d[j-1]);
			if(dis<ansdis)
			{
				ansdis=dis;
				ans=j;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<string> W(N);
    for (int i = 0; i < N; i++)cin >> W[i];

    set<string> S;
    for (int i = 0; i < N; i++)S.insert(W[i]);


    bool good = true;
    if (S.size() != N) { good = false; }
    for (int i = 0; i < N - 1; i++) if (W[i].back() != W[i + 1].front()) good = false;

    cout << (good ? "Yes" : "No") << endl;

}















































Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<cstdlib>

struct Node{
  int key;
  Node *next,*prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur=nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}

void init(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}

void printList(){
  Node *cur=nil->next;
  int isf=0;
  while(1){
    if(cur==nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int Key){
  deleteNode(listSearch(Key));
}

void insert(int key){
  Node *x=(Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(int i=0; i<n; i++){
  scanf("%s%d",com,&key);
  if(com[0]=='i'){insert(key);np++;size++;}
  else if(com[0]=='d'){
    if(strlen(com)>6){
      if(com[6]=='F') deleteFirst();
      else if(com[6]=='L') deleteLast();
    }else{
      deleteKey(key); nd++;
    }
    size--;
  }
  }
  printList();
  return 0;
}


Measured memory_bytes: 33836
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    cout<<s[0]<<s.length()-2<<s[s.length()-1];
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline


def knapsack(N, weight):
    dp = [0] * (weight + 1)
    for _ in range(N):
        v, w = map(int, readline().split())
        ww = w
        while ww <= weight:
            dp[ww] = max(dp[ww], dp[ww - w] + v)
            ww += 1
    return dp[-1]

if __name__ == "__main__":
    n_goods, weight = map(int, input().split())
    print(knapsack(n_goods, weight))




Measured memory_bytes: 5724
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef pair<ii, ii> pii;

int main(int argc, char ** argv) {
	int N;
	scanf("%d", &N);
	vector<bool> num(101, 0);
	REP(i, 1, 9) REP(j, 1, 9)
		num[i*j] = true;
	printf("%s\n", num[N] ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());

		if (a > 999) {
			System.out.println("ABD");
		} else {
			System.out.println("ABC");
		}

	}

}


Measured memory_bytes: 20948
def calculate(num,i):
		num.sort(reverse=True)
		if num[0] == num[3]:
			return "NA"
		L = num[0] * 1000 + num[1] * 100 + num[2] * 10 + num[3]
		S = num[3] * 1000 + num[2] * 100 + num[1] * 10 + num[0]
		new_N = L - S
		if new_N == 6174:
			return i + 1
		input_str = "%04d" % new_N
		return calculate(map(int,input_str),i+1)
ans = []
while(1):
	input_str = raw_input()
	if input_str == '0000':
		break
	elif input_str == '6174':
		ans.append(0)
	else:
		num = map(int,input_str)
		ans.append(calculate(num,0))
for value in ans:
	print value

Measured memory_bytes: 4316
#include<stdio.h>
int main(){
  int A,B;
  scanf("%d %d",&A,&B);
  for(int i =1;i<=3;i++){
    if((A*B*i)%2 == 1){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}

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

typedef unsigned long long int ull;

int main() {
  ull N, array[5];
  cin >> N;
  
  for (int i = 0; i < 5; ++i) {
    cin >> array[i];
  }
  
  sort(array, array+5);
  
  cout << (N - 1) / array[0] + 5 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int main() {
	ll a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
}



Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};const deduplicate=(a:number[])=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn(),index=0,ma=0
  for(let i=1;i<=n;i++){
    let m=i,c=0
    while(m%2==0&&m!=0){
      m/=2
      c++
    }
    if(ma<=c){
      index=i
      ma=c
    }
  }
  to(index)
}
main()


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long INF = 1e7;
const long long N = 1e6 + 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;

ll T = 1, n, q, m, b, ans, a, cnt;
string s;
char c, g;
vector < ll > v, v1;
set< char > st;
deque<char> D;
int main(){
    TIME
    cin >> a >> b;
    for( ll i = 1; i <= 1e5; i ++ )
    {
        if ( int(i * 0.08) == a and int(i * 0.1) == b )
            return cout << i, 0;
    }
    cout << -1;

}


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

int main() {
	string S;
	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		if (i % 2 == 0) {
			if (S[i] == 'L') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (S[i] == 'R') {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
# ABC158 C - Tax Increase
a,b = map(int,input().split())
import math
c=10000
for i in range(1200):
    if math.floor(i*0.08)==a and math.floor(i*0.10)==b:
        c = min(c,i)
if c==10000:
    print(-1)
    exit()
print(c)   

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  set<string> st;
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin>>s;
    st.insert(s);
  }
  cout<<st.size();
}

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

int n,arr[109],dp[109][2];

int call(int pos,int lst)
{
    if(pos==n+1)return 0;
    if(dp[pos][lst]!=-1)return dp[pos][lst];
    int ret=1e7;
    if(lst)
    {
        ret=min(1+call(pos+1,1),call(pos+1,0));
        return dp[pos][lst]=ret;
    }
    ret=1+call(pos+1,1);
    if(arr[pos]!=arr[pos-1])ret=min(ret,call(pos+1,0));
    return dp[pos][lst]=ret;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>arr[i];
    memset(dp,-1,sizeof dp);
    int ans=call(1,1);
    cout<<ans<<endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define dump(x) cerr << #x << " = " << (x) << endl

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

    if (a == b)
        cout << c << endl;
    else if (a == c)
        cout << b << endl;
    else
        cout << a << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

int main (){
    int N;
    scanf("%d",&N);
    std::vector<int> L(N);
    for (int i = 0; i < N; i++){
        scanf("%d",&L[i]);
    }
    int count=0;
    std::sort(L.begin(),L.end());
    for (int i = 0; i < N; i++){
    for (int j = i+1; j < N; j++){
    for (int k = j+1; k < N; k++){
        if(L[k]<L[i]+L[j]) count++;
        else break;
    }
    }
    }
    printf("%d",count);
}


Measured memory_bytes: 256
from collections import deque
from copy import deepcopy

N, M = map(int, input().split())
paths = [[] for n in range(N)]
def add_paths(a, b):
    paths[a - 1].append(b - 1)
    paths[b - 1].append(a - 1)

for i in range(M):
    a, b = map(int, input().split())
    add_paths(a, b)
route = deque([(0, paths[0], [False for n in range(N)])])
ans = 0
while len(route) > 0:
    vertex, path, visited = route.pop()
    visited[vertex] = True
    for i in path:
        if visited[i] != True:
            route.append((i, paths[i], deepcopy(visited)))
    if visited.count(False) == 0:
        ans += 1
print(ans)

Measured memory_bytes: 3436
#include<stdio.h>

int fib[50];

int solve(int n){
	if(fib[n]==0) fib[n]=solve(n-1)+solve(n-2);
	return fib[n];
}

int main(){
	fib[0]=fib[1]=1;
	int n;	scanf("%d",&n);

	printf("%d\n",solve(n));

	return 0;
}



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

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;


    int ans = max(A, B);
    ans = max(ans, C);

    if( ans == A ) ans = A*pow(2, K) + B + C;
    else if( ans == B ) ans = A + B*pow(2, K) + C;
    else if( ans == C ) ans = A + B + C*pow(2, K);


    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[500];
int b[500];
int dp[500][500];
//iからjまで連結させるときのコスト
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i > 0) b[i] += b[i - 1];
		b[i] += a[i];
	}
	for (int k = 1; k < n; k++) {
		for (int i = 0; i < n; i++) {
			//iからi+kまで
			int j = i + k;
			if (j >= n) break;
			int sum = Inf;
			for (int z = i; z < j; z++) {
				sum = min(sum, dp[i][z] + dp[z + 1][j]);
			}
			sum += b[j] - (i == 0 ? 0 : b[i - 1]);
			dp[i][j] = sum;
		}
	}
	cout << dp[0][n - 1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int N;
vector<vector<int>> G;
map<pair<int, int>, int> mp;
vector<int> ans;

void dfs(int cur, int color, int prv){
    int c = 0;
    for(int nxt : G[cur]){
        if(nxt == prv) continue;
        c++;
        if(c == color) c++;
        ans[mp[make_pair(cur, nxt)]] = c;
        dfs(nxt, c, cur);
    }
}

int main(){
    cin >> N;
    G.resize(N);
    ans.resize(N-1);
    REP(i, N-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        mp[make_pair(a, b)] = i;
        mp[make_pair(b, a)] = i;
    }
    dfs(0, 0, -1);


    cout << *max_element(ans.begin(), ans.end()) << endl;
    REP(i, N-1)
        cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define rrep(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef long long ll;
typedef pair<ll, int> P;
typedef set<int> S;

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

__attribute__((constructor)) void init()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main()
{
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define N 10000000
using namespace std ;
long long int NOD[10000001] ;
void generateNOD()
{
    long long int i,j;
    for( i = 1; i <= N; i++)
    {
        for(j = i; j <= N; j += i)
        {
            NOD[j] += 1;
        }
    }
}
int main()
{
    long long int i,n,c= 0;
    generateNOD() ;
    cin >> n ;
    for( i = 1 ; i <= n ; i++)
    {
        c+= i*NOD[i] ;
    }
    cout <<c<<endl;
    return 0;

}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

const int MAX = 510000;


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

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

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    ll N, M, K; cin >> N >> M >> K;
    ll ans=0;
    COMinit();
    for(int d=1; d<=N-1; d++){
        ans=(ans+d*(N-d)%MOD*M%MOD*M%MOD*COM(N*M-2, K-2)%MOD)%MOD;
    }
    for(int d=1; d<=M-1; d++){  
        ans=(ans+d*(M-d)%MOD*N%MOD*N%MOD*COM(N*M-2, K-2)%MOD)%MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	int n;
	cin >> n;
	vi a(n);
	In(a);

	sort(ASC(a));
	cout << a.back() - a.front() << endl;
}

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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    if(m == 0){
        cout << 0 << " " << 0;
        return 0;
    }
    vector<tuple<ll,ll,string>> ps(m);
    for(ll i = 0;i < m;i++){
        cin >> get<0>(ps[i]) >> get<2>(ps[i]);
        get<1>(ps[i]) = i;
    }
    sort(ps.begin(),ps.end());

    ll cnt = 0,ac = 0, wa = 0, twa = 0;
    vector<ll> t;
    t.push_back(get<0>(ps[0]));
    for(ll i = 1;i < m;i++){
        if(get<0>(ps[i - 1]) != get<0>(ps[i])){
            t.push_back(get<0>(ps[i]));
        }
    }
    for(ll i = 0;i < m;i++){
        while(t[cnt] < get<0>(ps[i])){
            cnt++;
            twa = 0;
        }
        if(t[cnt] == get<0>(ps[i]) && get<2>(ps[i]) == "AC"){
            cnt++;
            ac++;
            wa += twa;
            twa = 0;
        }
        else if(t[cnt] == get<0>(ps[i])){
            twa++;
        }
        if(cnt == t.size()){
            break;
        }
    }
    
    cout << ac << " " << wa;

    return 0;
}

Measured memory_bytes: 8440
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << C << " " << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int R;
    cin >> R;

    if(R < 1200){
        cout << "ABC" << endl;
    }

    if(R >= 1200 && R < 2800){
        cout << "ARC" << endl;
    }

    if(R >= 2800){
        cout << "AGC" << endl;
    }

}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;

void main(){

    int n = to!int(chomp(readln()));

    for(int j=0;j<n;j++){
	auto s = chomp(readln());
	int[] m;
	for(int i=0;i<8;i++){
	    m ~= to!int(s[i]-'0');
	}
	sort!("a > b")(m);
	long ma;
	for(int i=0;i<8;i++){
	    ma += m[i] * pow(10,(7-i));
	}
	sort(m);
	long mi;
	for(int i=0;i<8;i++){
	    mi += m[i] * pow(10,(7-i));
	}
	writeln(ma-mi);

    }

}

Measured memory_bytes: 2440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,pair<int,int>> P;
int main(){
  int N;
  cin>>N;
  vector<P> A(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    A[i] = {a + b,{a,b}};
  }
  sort(A.begin(),A.end(),greater<P>());
  ll ans = 0;
  for(int i=0;i<N;i++){
    if(i%2) ans -= A[i].second.second;
    else ans += A[i].second.first;
  }
  cout<<ans<<endl;
  return 0;
}


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


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; ++i) {
        cin >> a[i];
    }
    for(int i=0; i<N-1; ++i) {
        for(int j=i+1; j<N; ++j) {
            if(a[i] < a[j]) {
                int k;
                k = a[i];
                a[i] = a[j];
                a[j] = k;
            }
        }
    }

    int Alice=0, Bob=0;
    for (int n=0; n<N; n++) {
        if(n%2) {
            Bob += a[n];
        } else {
            Alice += a[n];
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(n // 2)
    exit(0)

x = Counter(v[::2]).most_common()
y = Counter(v[1::2]).most_common()

if x[0][0] == y[0][0]:
    if len(x) == 1:
        d = x[0][1] + y[1][1] 
    elif len(y) == 1:
        d = x[1][1] + y[0][1]
    else:
        d = max(x[0][1] + y[1][1], x[1][1] + y[0][1]) 
else:
    d = x[0][1] + y[0][1]

print(n - d)


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

template <typename Abelian>
struct BITRangeAdd {
  BITRangeAdd(int n_, const Abelian UNITY = 0) : n(n_), UNITY(UNITY) {
    ++n;
    dat_const.assign(n, UNITY);
    dat_linear.assign(n, UNITY);
  }

  void add(int left, int right, Abelian val) {
    if (right < ++left) return;
    for (int i = left; i < n; i += i & -i) {
      dat_const[i] -= val * (left - 1);
      dat_linear[i] += val;
    }
    for (int i = right + 1; i < n; i += i & -i) {
      dat_const[i] += val * right;
      dat_linear[i] -= val;
    }
  }

  Abelian sum(int idx) {
    Abelian res = UNITY;
    for (int i = idx; i > 0; i -= i & -i) res += dat_linear[i];
    res *= idx;
    for (int i = idx; i > 0; i -= i & -i) res += dat_const[i];
    return res;
  }

  Abelian sum(int left, int right) {
    if (right <= left) return UNITY;
    return sum(right) - sum(left);
  }

  Abelian operator[](const int idx) { return sum(idx, idx + 1); }

private:
  int n;
  const Abelian UNITY;
  vector<Abelian> dat_const, dat_linear;
};

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n); REP(i, n) cin >> a[i], --a[i];
  BITRangeAdd<ll> bit(m + 1);
  ll ans = 0;
  REP(i, n - 1) {
    if (a[i] < a[i + 1]) {
      ans += a[i + 1] - a[i];
      bit.add(a[i] + 2, a[i + 1] + 1, 1);
      bit.add(a[i + 1] + 1, a[i + 1] + 2, -((a[i + 1] + 1) - (a[i] + 2)));
    } else {
      ans += m - a[i] + a[i + 1];
      bit.add(a[i] + 2, m, 1);
      bit.add(m, m + 1, -max(m - (a[i] + 2), 0));
      // REP(j, m + 1) cout << bit[j] << " \n"[j == m];
      bit.add(0, 1, max(m - (a[i] + 2), 0));
      bit.add(a[i + 1] + 1, a[i + 1] + 2, -max(m - (a[i] + 2), 0));
      bit.add(a[i] + 1 == m ? 1 : 0, a[i + 1] + 1, 1);
      bit.add(a[i + 1] + 1, a[i + 1] + 2, -((a[i + 1] + 1) - (a[i] + 1 == m ? 1 : 0)));
    }
  }
  vector<ll> imos(m + 1);
  REP(i, m + 1) imos[i] = bit[i];
  FOR(i, 1, m + 1) imos[i] += imos[i - 1];
  // REP(i, m + 1) cout << imos[i] << " \n"[i == m];
  cout << ans - *max_element(ALL(imos)) << '\n';
  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

bool is_prime(int k)
{
    for(int j=2;j*j<=k;j++){
        if(k%j==0) {
            return false;
        }
    }
    return true;
}

int main()
{
	stringstream ss;
    // 入力
    ll D,G;

    cin>>D>>G;
    G/=100;

    ll p[D+1],c[D+1];
    ll pmin=0;
    REP(i,D){
        cin>>p[i]>>c[i];
        c[i]/=100;
        pmin+=p[i];
    }
    int all[D+1];

    FOR(i,0,pow(2,D)-1){
        REP(j,D){
            all[j] = (i & (int)pow(2,j-1))/(int)pow(2,j-1);
            // cout<<all[j];
        }
        // cout<<endl;
        REP(j,D){
            if(!all[j]){
                ll pttot=0;
                ll ptot=0;
                REP(k,D){
                    pttot+=all[k]*(p[k]*k+c[k]);
                    ptot+=p[k]*all[k];
                }
                FOR(l,0,p[j]-1){
                    if(ptot+l<pmin && G<=pttot+l*j){
                        pmin=ptot+l;
                        // cout<<pmin<<endl;
                    }
                }
            }
        }
    }


    cout<<pmin<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y;
	char	str[256];
	double  ans;
	
	scanf("%d", &n);

	for(i=1;i<=9;i++) {
		for(j=1;j<=9;j++) {
			if (n == (i*j)) {
				printf("Yes\n");
				return 0;
			}
		}
	}

	printf("No\n");

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

vector<LL> A[4];

int main() {
  int n,w;
  S2(n,w);
  int s = 0;
  rep(i,0,n) {
    int w,v;
    S2(w,v);
    if(!i) {
      s = w;
    }
    A[w - s].push_back(v);
  }
  rep(i,0,4) {
    sort(all(A[i]));
    reverse(all(A[i]));
    rep(j,1,A[i].size()) {
      A[i][j] += A[i][j-1];
    }
  }
  LL ans = 0;
  rep(i,0,A[0].size()+1) rep(j,0,A[1].size()+1) rep(k,0,A[2].size()+1) {
    LL tmp = i * 1LL * s + j * 1LL * (s + 1) + k * 1LL * (s + 2);
    if(tmp > w) continue;
    LL idx = (w - tmp) / (s + 3);
    LL val = 0;
    if(idx > A[3].size()) {
      if(A[3].size()) val = A[3].back();
    } else {
      if(idx) val = A[3][idx-1];
    }
    ans = max(ans, (i?A[0][i-1]:0) + (j?A[1][j-1]:0) + (k?A[2][k-1]:0) + val);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,R = inpl()

if N >= 10:
    print(R)
else:
    print(R + 100*(10-N))


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

int n;
char s[111];

int main() {
	scanf("%d%s", &n, s);
	
	bool chk = true;
	if(n%2) chk = false;
	else {
		for(int i=0,j=n/2;chk && j<n;i++, j++)
			if(s[i]!=s[j]) chk = false;
	}
	puts(chk ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  int N;
  cin >> N;
  cout << (N) * (N + 1) / 2 << endl;
}


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

using namespace std;

int main(){
    long double n,m,d,now;
    cin >> n >> m >> d;
    if(d==0){
        cout << setprecision(20) << (m-1)/n << endl;
    }else{
        cout << setprecision(20) << 2*(n-d)*(m-1)/n/n << endl;
    }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, k;
    cin >> n >> k;
    int32 a[n];
    REP(i,n)cin >> a[i];
    vector<int32> lessCnt(2,0);
    REP(i,n-1){
        FOR(j,i+1,n){
            if(a[i] < a[j]){
                lessCnt[0]++;
            }else if(a[i] > a[j]){
                lessCnt[1]++;
            }
        }
    }
    int64 ans = ((k - 1) * k / 2 % MOD * lessCnt[0] % MOD + (k + 1) * k / 2 % MOD * lessCnt[1] % MOD) % MOD;
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
import math

class Prime:
    seeds = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    def decompose(self, n):
        ps_max = self.seeds[-1]
        primes = {}
        setdef = primes.setdefault

        for p in self.seeds:
            while n % p == 0:
                setdef(p, 0)
                primes[p] += 1
                n //= p

        p = ps_max
        while p <= math.sqrt(n):
            if n % p == 0:
                setdef(p, 0)
                primes[p] += 1
                n //= p
            p += 2
        if n > 1:
          setdef(n, 1)

        return primes

prime = Prime()
 
a, b = map(int, input().split())
primes = prime.decompose(prime.gcd(a, b))
 
print(len(primes) + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
string s;
int main()
{
    long long int t,n,i,j,a,b,d,e,k=1,m,c=0;
    cin >> s;
    a= pow(2, s.length() - 1);
    reverse(s.begin(), s.end());
    for(i=1; i<=a; i++)
    {
        k = 1;
        for(j=0; j<s.length()-1; j++)
        {
            c+= (s[j] - '0') * k;
            if((i>>j) & 1)
            {
                k=1;
            }
            else
            {
                k*=10;
            }
        }

        c+= (s[s.length() - 1] - '0') * k;
    }

    cout << c<< endl;
    return 0;
}

Measured memory_bytes: 4024
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;

int main(void){

  int n;
  cin>>n;
  int a[109];
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  int max = a[0];
  int temp;
  int sum=0;

    sort(a,a+n,greater<int>());

  for(int i=0;i<n;i++){
      if(i%2==0)sum+=a[i];
      else sum-=a[i];
  }
  cout<<sum<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N, M, D;
    double x;
    cin >> N >> M >> D;
    x = 2 * (M - 1) * (N - D);
    x = x / N / N;
    if(D == 0){
        x = x / 2;
    }

    printf("%24.16lf\n", x);

}


Measured memory_bytes: 3728
def run_length_compress(string):
    """文字列をランレングス圧縮する
    例) string = "aabccaaabb" -> [(2, a), (1, b), (2, c), (3, a), (2, b)]
    """
    string = string + "@" # string中に絶対に現れない文字を番兵とする
    n = len(string)

    begin = 0
    end = 1
    cnt = 1
    ans = []
    while True:
        if end >= n:
            break
        if string[begin] == string[end]:
            end += 1
            cnt += 1
        else:
            ans.append((cnt, string[begin]))
            begin = end
            end = begin + 1
            cnt = 1

    return ans

n = int(input())
s = input()
ans = run_length_compress(s)
print(len(ans))

Measured memory_bytes: 45680
n = int(input())
a = [int(input()) for i in range(n)]
i = 1
count = 0
btn = {1}
if 2 not in a:
  print(-1)
  exit()
while(1):
  i = a[i-1]
  count += 1
  if i in btn:
    print(-1)
    break
  if i == 2:
    print(count)
    break
  btn.add(i)


Measured memory_bytes: 13200