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

const int maxn = 105;
const LD PI = acos(-1);
LD x[maxn], y[maxn], low0, high0, low1, high1, a;
int n;

int main() {
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%Lf%Lf", &x[i], &y[i]);
	for (int i=1; i<=n; i++) {
		low0 = -PI; low1 = 0;
		high0 = 0; high1 = PI;
		for (int j=1; j<=n; j++)
			if (i != j) {
				a = atan2((x[j] - x[i]), -(y[j] - y[i]));
				if (a >= 0) {
					low1 = max(low1, a);
					high0 = min(high0, a - PI);
				}
				else {
					low0 = max(low0, a);
					high1 = min(high1, a + PI);
				}
			}
		printf("%.16Lf\n", (max(LD(0), high0 - low0) + max(LD(0), high1 - low1)) / (2 * PI));
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

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 main() {
    input!{
        s: chars,
    }
    let mut num = 0;
    for ch in s {
        match ch {
            '+' => num += 1,
            '-' => num -= 1,
            _ => break,
        }
    }
    println!("{}", num);
}


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

int main() {

    string S;
    cin >> S;
    
    int ans = 0;
    
    if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R') ans++;
    if (S[0] == 'R' and S[1] == 'R') ans++;
    if (S[1] == 'R' and S[2] == 'R') ans++;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}

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

int main() 
{ 
    fast_io
    go();
    int n,k;cin>>n>>k;
    vi v(n);
    for0(i,n)
    {
      cin>>v[i];
    }
    sort(v.begin(),v.end());
    intt sum=0;
    for0(i,k)
    {
      sum+=v[i];
    }
    cout << sum <<endl;
} 

/*!
    You are under no obligation to be the same person you were a minute ago,
    You have the right to grow !
*/




















Measured memory_bytes: 3648
#include <iostream>
#include <numeric>
#include <algorithm>

using namespace std;

int main(void) {
	long long int K;
	long long int answer = 0;

	scanf("%Ld", &K);
	for(int a = 1; a <= K;a++) {
		for(int b = 1; b <= K; b++) {
			for(int c = 1;c <= K; c++) {
              answer += __gcd(__gcd(a,b),c);
			}
		}
	}
	printf("%Ld\n", answer);
	return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>
#include<stdlib.h>


int main(void){
  int N,a[100], i, j, tmp, A = 0, B = 0;

  scanf("%d", &N);
  
  for( i=0; i<N; i++){
    scanf("%d", &a[i]);
  }

  for(i=0; i<N-1; i++){
    for(j=N-1; j>i; j--){
      if(a[j-1] > a[j]){
	tmp = a[j-1];
	a[j-1] = a[j];
	a[j] = tmp;
      }
    }
  }

  for(i=0; i<N; i++){
    if(i%2 == 0 ){
      A += a[i];
    }else{
      B += a[i];
    }
  }

  printf("%d", abs(A-B) );
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

/*

 */

int const MaxSize = 1e5 + 5;
int N, K; //, A[MaxSize]

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);

	cin >> N >> K;

	int i1 = 0;

	LP(i, 0, N)
	{
		int ai;
		cin >> ai;

		if (ai == 1)
			i1 = i;
	}

	int leftC = 0;

	if (i1 > 0) {
		leftC = i1 / (K - 1);

		if (i1 % (K - 1))
			leftC++;
	}

	i1 = (K - 1) * leftC;

	int rightC = 0;

	if (i1 < N - 1) {
		rightC = (N - 1 - i1) / (K - 1);

		if ((N - 1 - i1) % (K - 1))
			rightC++;
	}

	//cout << leftC << " " << i1 << " " << rightC << endl;

	cout << leftC + rightC << endl;
	return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

int n, q, sum[N], cnt = 0, num[N][26][26];
string s[N];

struct Trie {
    int child[26], total;
    bool id;
    Trie() {
        memset(child, 0, sizeof(child));
        total = id = 0;
    }
}trie[4 * N];

void update(string t) {
    int p = 0;
    for(int i = 0; i < t.length(); i++) {
        if(!trie[p].child[t[i] - 'a'])
            trie[p].child[t[i] - 'a'] = ++cnt;
        p = trie[p].child[t[i] - 'a'];
    }
    trie[p].total = trie[p].id = 1;
}

void prep(int p) {
    for(int i = 0; i < 26; i++) {
        if(!trie[p].child[i]) continue;
        prep(trie[p].child[i]);
        trie[p].total += trie[ trie[p].child[i] ].total;
    }
}

void travel(int id, string s) {
    int p = 0;
    for(int i = 0; i < s.length(); i++) {
        int c = s[i] - 'a';
        for(int j = 0; j < 26; j++) {
            if(j == c) continue;
            if(!trie[p].child[j]) continue;
            num[id][c][j] += trie[ trie[p].child[j] ].total;
        }
        p = trie[p].child[c];
        sum[id] += trie[p].id;
    }
}

int main() {
    cin.tie(0), ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> s[i];
        update(s[i]);
    }
    prep(0);
    for(int i = 1; i <= n; i++)
        travel(i, s[i]);
    cin >> q;
    while(q--) {
        int id; string t;
        cin >> id >> t;
        int ans = sum[id];
        for(int i = 0; i < t.length(); i++) {
            for(int j = 0; j < i; j++)
                ans += num[id][t[i] - 'a'][t[j] - 'a'];
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 314620
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template<class T>
T gcd(T a, T b){
	if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b, a%b);
}

int main(){
	ll n, m;
	string s, t;
	cin >> n >> m >> s >> t;
	for(ll i=0; i<n; i++){
		if(i*m%n==0 && i*m/n<m){
			if(s[i]!=t[i*m/n]){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << n*m/gcd(n,m) << endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
  int i, j, k;
  int a, b, c, x, sum;
  int cnt = 0;
  scanf("%d%d%d%d", &a, &b, &c, &sum);
  for( i = 0; i <= a; i++){
    for( j = 0; j <= b; j++){
      for( k = 0; k <= c; k++){
        x = i * 500 + j * 100 + k * 50;
        if( x == sum ) cnt++;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}

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

using namespace std;
typedef pair<int,int> P;
#define mp make_pair

map <P,int> ans;

int N, K, L;
int p[200002];
int ran[200002];
int A[200001];
int B[200001];

void init(int n) {
  for(int i = 0; i < n; i++) {
    p[i] = i;
    ran[i] = 0;
  }
}

int Find (int x) {
  if(p[x] == x) return x;
  return p[x] = Find(p[x]);
}

void Union(int x, int y) {
  int a = Find(x);
  int b = Find(y);
  if(a == b) return;
  
  else if(ran[a] > ran[b]) {
    p[a] = b;
  }
  else {
    p[b] = a;
    if(ran[a] == ran[b]) ran[b]++;
  }
  return;
}
    
int main() {
cin >> N >> K >> L;

  init(N);
  
  for(int i = 0; i < K; i++) {
    int p,q;
    cin >> p >> q;
    p--; q--;
    Union(p,q);
  }

  for(int i = 0; i < N; i++) A[i] = Find(i);


  
  init(N);
  
  for(int i = 0; i < L; i++) {
    int r,s;
    cin >> r >> s;
    r--; s--;
    Union(r,s);
  }

  for(int i = 0; i < N; i++) B[i] = Find(i);

  for(int i = 0; i < N; i++) {
    ans[mp(A[i],B[i])]++;
  }

  for(int i = 0; i < N; i++) {
    cout << ans[mp(A[i],B[i])] <<endl;
  }
}


Measured memory_bytes: 15104
#include <algorithm>
#include <iostream>
#include <list>
using namespace std;

int check_digit(int num) {
  int digit = 0;
  while (true) {
    num /= 10;
    digit++;
    if (num <= 0) {
      break;
    }
  }
  return digit;
}

int digit_count(int a, int b) {
  int digit;
  digit = check_digit(a + b);
  return digit;
}

int main(int argc, char const *argv[]) {
  int a, b;
  list<int> ls;
  while (!(std::cin >> a >> b).eof()) {
    ls.push_back(digit_count(a, b));
  }

  list<int>::iterator it = ls.begin();
  while (it != ls.end()) {
    cout << *it << endl;
    it++;
  }
}



Measured memory_bytes: 2964
#include<stdio.h>
int main()
{
  int a,b,c,d,low,hig;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a>c) low=a;
   else   low=c;
  if(b>d) hig=d;
   else   hig=b;
   if(low<hig) printf("%d\n",hig-low);
    else        printf("0\n");

   return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

//AtCoder Beginner Contest 153
//A - Serval vs Monster
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		sc.close();

		long ans = (H / A);
		if (H % A != 0) {
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
def gcd(x, y):
    if x < y:
        buf = x
        x = y
        y = buf
    while y > 0:
        r = x % y
        x = y
        y = r
    return x
    

if __name__ == "__main__":
    x, y = map(int, input().split())
    print(gcd(x, y))
    


Measured memory_bytes: 5600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[] = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        int x = Integer.parseInt(str[2]);
        int[] c = new int[n];
        int[][] a = new int[n][m];

        for (int i = 0; i < n; i++) {
            str = br.readLine().split(" ");
            c[i] = Integer.parseInt(str[0]);
            for (int j = 0; j < m; j++) {
                a[i][j] = Integer.parseInt(str[j+1]);
            }
        }

        long ans = Long.MAX_VALUE;

       loop1: for (int i = 0; i < Math.pow(2,n); i++) {
            boolean ok = true;
            long res = 0;
           loop2: for (int k = 0; k < m; k++) {
                long sum = 0;
                for (int j = 0; j < n; j++) {
                    if ((1&i >> j) == 1) {
                        res += c[j];
                        sum += a[j][k];
                    }
                    // System.out.println(sum);
                }
                if (sum < x) {
                    ok = false;
                    break loop2;
                }
                // System.out.println();
            }
            // System.out.println(res/m);
            if (ok) {
                ans = Math.min(ans,res/m);
            }
        }

        if (ans == Long.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 32916
// ProblemURL : https://atcoder.jp/contests/abc068/tasks/arc079_a
// ---------------------------------------------
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	isConnectedTo1 := make([]bool, n)
	isConnectedToN := make([]bool, n)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if a == 1 {
			isConnectedTo1[b] = true
		} else if b == n {
			isConnectedToN[a] = true
		}
	}

	ans := "IMPOSSIBLE"
	for i := range isConnectedTo1 {
		if isConnectedTo1[i] && isConnectedToN[i] {
			ans = "POSSIBLE"
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <stdio.h>

// Aとnpから塗り方の総数のmod 1000000007を出力
int f(int np, char *A) {
	unsigned int ans;
	if (A[0] == 't') ans = 3;
	else ans = 6;
	for (int i = 1; i < np; i++) {
		if (A[i] == 't') {
			if (A[i-1] == 't') ans *= 2;
			else ;
		} else {
			if (A[i-1] == 't') ans *= 2;
			else ans *= 3;
		}
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int ans;
	int N;
	scanf("%d", &N);
	char S1[N+1];
	scanf("%s", S1);
	
	// A はドミノの配置パターンを表す('t' が縦，'y'が横)
	char A[N];
	// np はパターンの数
	int np = 0;
	for (int i = 0; S1[i] != '\0'; i++) {
		if (S1[i] == S1[i+1]) {
			A[np] = 'y';
			np++;
			i++;
		} else {
			A[np] = 't';
			np++;
		}
	}
	
	ans = f(np, A);

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

	return 0;
}

Measured memory_bytes: 256
# n=int(input())
# a,b=map(int,input().split())
# l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
s = input()

month = int(s[5:7])
if month < 4:
    ans = 'Heisei'
elif month == 4:
    day = int(s[8:])
    if day <= 30:
        ans = 'Heisei'
else:
    ans = 'TBD'
print(ans)


Measured memory_bytes: 9108
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    b.append(list(map(int,input().split())))
an=sorted(a, key=lambda x:-x[1])
bn=sorted(b)#, key=lambda x:(x[0],x[1]))
count=0
for i in range(len(bn)):
    for j in range(len(an)):
#        print(an[j],bn[i])
        if bn[i][0]>an[j][0] and bn[i][1]>an[j][1]:
            count+=1
            an.pop(j)
            break
 
print(count)

Measured memory_bytes: 3064
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b, c, d; cin >> a >> b >> c >> d;

  int t = c/b + (c%b!=0);
  int o = a/d + (a%d!=0);


  cout << (t <= o ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3640
def binarySearch(A, key):
    left = 0
    right = len(A)
    while left < right:
        mid = (left + right) // 2
        if A[mid] == key:
            return mid
        elif A[mid] > key:
            right = mid
        else:
            left = mid + 1
    return "NOT_FOUND"

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

C = 0
for i in T:
    if binarySearch(S, i) != "NOT_FOUND":
        C += 1
print(C)


Measured memory_bytes: 16716
#include <stdio.h>

int main(void)
{
 int data;
 int h, m, s;

 scanf("%d", &data);

 h = data / 3600;
 data = data % 3600;
 m = data / 60;
 s = data % 60;

 printf("%d:%d:%d\n", h, m, s);

 return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
const int N=100000+10;
int n,k,a[N];
int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int r=0;
	for(int i=1;i<=n;i++)r=gcd(r,a[i]);
	int mx=*max_element(a+1,a+1+n);
	if(k<=mx && (mx-k)%r==0) return !printf("POSSIBLE\n");
	printf("IMPOSSIBLE\n");
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	int a[n];
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if(((sum * 1.0) / (4 * m)) <= (a[i] * 1.0)) {
			cnt++;
		}
	}
	if (cnt >= m) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){

    char s[100001];
    scanf("%s",s);
    int g=0;
    int p=0;
    int score=0;

    int i=0;
    while(s[i]!='\0'){
        if(s[i]=='g'){
            if(p<g){
                p++;
                score++;
            }
            else{
                g++;
            }
        }
        else{
            if(p<g){
                p++;
            }
            else{
                g++;
                score--;
            }
        }
        i++;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int u;
    if (h>=w){
        u=h;
    }
    else {
        u=w;
    }
    int ans=0;
    if (n%u==0){
        ans=n/u;
    }
    else {
        ans=n/u+1;
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
flag = 0
for i, s in enumerate(S):
  if i % 2 == 0:
    if s not in ['R', 'U', 'D']:
      flag = 1
      break
  else:
    if s not in ['L', 'U', 'D']:
      flag = 1
      break
print('Yes' if flag == 0 else 'No')

Measured memory_bytes: 2940
n = int(input())
a = list(map(lambda x: int(x) % (10**9+7), input().split()))
tsum = 0
isum = 0
for i in range(n):
    isum = (isum + a[i]) % (10**9+7)
for i in range(n-1):
    isum += (10**9+7) - a[i]
    tsum += (isum * a[i]) % (10**9+7)
print(tsum%(10**9+7))

Measured memory_bytes: 31544
a, b = map(int, input().split())
f = [['#' for _ in range(100)] for _ in range(50)] + \
    [['.' for _ in range(100)] for _ in range(50)]

for i in range(a-1):
    h = (i // 50) * 2
    w = (i % 50) * 2
    f[h][w] = '.'

for i in range(b-1):
    h = -((i // 50) * 2 + 1)
    w = (i % 50) * 2
    f[h][w] = '#'

print(100, 100)
for line in f:
    print(''.join(line))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    map<string, string> mp;
    mp["Sunny"] = "Cloudy";
    mp["Cloudy"] = "Rainy";
    mp["Rainy"] = "Sunny";
    cin >> S;
    cout << mp[S] << endl;
}

Measured memory_bytes: 3528
from collections import defaultdict
from itertools import product

h, w, n = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(n)]

board = defaultdict(int)

for a, b in A:
    for dx, dy in product((-1, 0, 1), repeat=2):
        board[(a+dx, b+dy)] += 1

ans = [0] * 10
ans[0] = (h-2) * (w-2)

for k, v in board.items():
    if 1 < k[0] < h and 1 < k[1] < w:
        ans[0] -= 1
        ans[v] += 1

for a in ans:
    print(a)

Measured memory_bytes: 185040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int N, D;
    cin>>N>>D;

    int kansi = D*2+1;

    if(N%kansi == 0){
        cout<<N/kansi<<endl;
        return 0;
    }else{
        cout<<N/kansi+1<<endl;
        return 0;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int arr[x];
	for (int i = 0 ; i < x ; i++)
	{
		cin >> arr[i];
	}
	sort (arr , arr + x);
	int a = x / 2;
	cout << arr[a] - arr[a - 1];
}

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

using namespace std;

typedef vector<vector<int> > MAT;

int M;

MAT make_mat(int x){
  return MAT(x,vector<int>(x));
}

MAT operator*(const MAT &a,const MAT &b){
  const int n=a.size();
  MAT r=make_mat(n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
	r[i][j]=(r[i][j]+a[i][k]*b[k][j])%M;
      }
    }
  }
  return r;
}

MAT pow(MAT m,int x){
  const int n=m.size();
  MAT r=make_mat(n);
  for(int i=0;i<n;i++){
    r[i][i]=1;
  }
  for(;x;x>>=1,m=m*m){
    if(x%2){
      r=r*m;
    }
  }
  return r;
}

int main(){
  for(int n,a,b,c,t;cin>>n>>M>>a>>b>>c>>t,n;){
    MAT m=make_mat(n);
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	m[i][j]=(i-1==j)?a:
	  (i==j)?b:
	  (i+1==j)?c:0;
      }
    }
    m=pow(m,t);
    vector<int> s(n);
    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    for(int i=0;i<n;i++){
      int ans=0;
      for(int j=0;j<n;j++){
	ans=(ans+m[i][j]*s[j])%M;
      }
      cout<<ans<<((i==n-1)?'\n':' ');
    }
  }
}

    

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(0);
    cin.tie(0);

    long long H;
    cin >> H;

    int cnt = 0;
    while(1){
        if(H == 0) break;
        H /= 2;
        cnt++;
    }
    cout << (long long) pow(2, cnt) - 1;
    
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))


ans = 0
for i in range(2**n):
    s = 0
    for j in range(m):
        c = 0
        for k in range(len(ks[j])-1) :
            if ((i >> (ks[j][k+1]-1)) & 1) :
                c += 1
        if c % 2 == p[j]:
            s += 1
    if s == m :
        ans += 1

print(ans)


Measured memory_bytes: 9224
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
const int N=100+5;
char s[100+10];
char ans[][10]={
	"No\n",
	"Yes\n"
};
struct DICE{
	int u,s,e,w,n,d;
	DICE (int u=0,int s=0,int e=0,int w=0,int n=0,int d=0):u(u),s(s),e(e),w(w),n(n),d(d){}
	DICE fW(){
		DICE tmp;
		tmp.s=this->s;
		tmp.n=this->n;
		tmp.e=this->d;
		tmp.w=this->u;
		tmp.u=this->e;
		tmp.d=this->w;
		return tmp;
	}
	DICE fS(){
		DICE tmp;
		tmp.s=this->u;
		tmp.n=this->d;
		tmp.e=this->e;
		tmp.w=this->w;
		tmp.d=this->s;
		tmp.u=this->n;
		return tmp;
	}
	DICE fE(){
		DICE tmp;
		tmp.s=this->s;
		tmp.n=this->n;
		tmp.e=this->u;
		tmp.w=this->d;
		tmp.d=this->e;
		tmp.u=this->w;
		return tmp;
	}
	DICE fN(){
		DICE tmp;
		tmp.s=this->d;
		tmp.n=this->u;
		tmp.e=this->e;
		tmp.w=this->w;
		tmp.d=this->n;
		tmp.u=this->s;
		return tmp;
	}
	int right(int t,int f){
		if(t==this->u)
		{
			if(f==this->s)return this->e;
			else if(f==this->e)return this->n;
			else if(f==this->n)return this->w;
			else if(f==this->w)return this->s;
			else return -1;
		}
		else if(t==this->s){
			DICE tmp=(*this).fN();
			return tmp.right(t,f);
		}
		else if(t==this->e){
			DICE tmp=(*this).fW();
			return tmp.right(t,f);
		}
		else if(t==this->n){
			DICE tmp=(*this).fS();
			return tmp.right(t,f);
		}
		else if(t==this->w){
			DICE tmp=(*this).fE();
			return tmp.right(t,f);
		}
		else if(t==this->d){
			DICE tmp=(*this).fE().fE();
			return tmp.right(t,f);
		}
		else return -1;
		}
};
DICE A[N];
bool check(DICE x,DICE y){
	int ax[]={
		x.s,x.e,x.n,x.w
	};
	int ay[]={
		y.s,y.e,y.n,y.w
	};
	if(x.u==y.u){
		if(x.d==y.d){
			int cnt=0;
			while(cnt<=4){
				while(ax[cnt]!=ay[0]&&cnt<=4)
					cnt++;
				int i=0;
				while(ax[(i+cnt)%4]==ay[i]&&i<=4)
					i++;
				if(i==4)return 1;
				cnt++;
			}
			
		}
	}
	return 0;
}
bool sovle(DICE x,DICE y){
	if(check(x,y))return 1;
	if(check(x.fE(),y))return 1;
	if(check(x.fW(),y))return 1;
	if(check(x.fN(),y))return 1;
	if(check(x.fS(),y))return 1;
	if(check(x.fS().fS(),y))return 1;
	return 0;
}
int main()
{
//#ifdef DEBUG
//	freopen("in", "r", stdin);
////	freopen("out", "w", stdout);
//#endif
	int n;scanf("%d", &n);
	int t=0;
	int a[6];
	bool flag=1;
	for(int i=0;i<6;i++){
		scanf("%d", &a[i]);
	}
	A[0]=DICE(a[0],a[1],a[2],a[3],a[4],a[5]);
	t++;
	while(t<n){
	for(int i=0;i<6;i++){
		scanf("%d", &a[i]);
	}
	A[t]=DICE (a[0],a[1],a[2],a[3],a[4],a[5]);
	for(int i=0;i<t;i++)
	{
		if(sovle(A[i],A[t])){flag=0;
//			cout<<i<<' '<<t<<endl;
		}
	}
	t++;
	}
	printf("%s", ans[flag]);
//	printf("%s", ans[solve(dice,dice2)]);
//	DICE I
//	scanf("%s", s);
//	int len=strlen(s);
//	for(int i=0;i<len;i++){
//		switch(s[i]){
//			case'S':dice=dice.fS();break;
//			case'E':dice=dice.fE();break;
//			case'W':dice=dice.fW();break;
//			case'N':dice=dice.fN();break;
//		}
//	}
//	printf("%d\n", dice.u);
//
	return 0;
}
//aoj1_11_a.cc

//AC

Measured memory_bytes: 1188
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 

int main(){
    int n,m; cin >> n >> m;
    priority_queue<pair<int, int>> q;
    
    rep(i, n){
        int a; cin >> a;
        q.push(make_pair(a, 1));
    }
    
    rep(i, m){
        int b,c; cin >> b >> c;
        q.push(make_pair(c, b));
    }
    ll ans = 0;
    rep(i, n){
        auto P = q.top();
        ans += P.first;
        q.pop();
        if(P.second > 1){
            P.second--;
            q.push(P);
        }
    }
    cout << ans << endl;
    
    
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

ll combi(ll a, ll b) {
    ll ret = 1;
    vector<bool> x(b,false),y(a-b,false);
    for (int i = 1;i <= a;++i) {
        ret *= i;
        for (int j = 0;j < b;++j) if (!x[j] && ret%(j+1) == 0) {
            ret /= j+1;
            x[j] = true;
        }
        for (int j = 0;j < a-b;++j) if (!y[j] && ret%(j+1) == 0) {
            ret /= j+1;
            y[j] = true;
        }
    }
    return ret;
}

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for (int i = 0;i < n;++i) cin >> v[i];
    sort(v.begin(),v.end());
    ll sum = 0;
    for (int i = 0;i < a;++i) sum += v[n-1-i];
    double z = (double)sum/a;
    cout << setprecision(12) << z << endl;
    ll mn = v[n-a];
    int x = 0,y = 0;
    for (int i = 0;i < a;++i) if (mn == v[n-1-i]) x++;
    for (int i = 0;i < n;++i) if (mn == v[i]) y++;
    ll ans = 0;
    for (int i = a;i <= b;++i) {
        if (a-x+y < i) break;
        ans += combi(y,x+i-a);
        if (v[n-1] != v[n-a]) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
S = list(input())
ans = 0
rsp = ['']*n
for i, op in enumerate(S):
    if op=='r': me, pt = 'p', p
    elif op=='s': me, pt = 'r', r
    else: me, pt = 's', s
    if i-k>=0 and rsp[i-k]==me: me, pt = '', 0
    ans+=pt
    rsp[i] = me
print(ans)

Measured memory_bytes: 4916
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll INF = LLONG_MAX;
ll memo[100001],h[100001];

ll dp(ll i){
	if(i == 1) return 0;
	if(i< 1) return INF;
	if(memo[i]!=-1) return memo[i];
	memo[i] = min( (i-1>=1) ? dp(i-1)+abs(h[i]-h[i-1]) : INF,
				(i-2>=1) ? dp(i-2)+abs(h[i]-h[i-2]) : INF);
	return memo[i];
}

int main() {
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		memo[i] = -1;
	}
	ll ans = dp(n);
	cout<<ans<<"\n";
	return 0;
}

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

const int MAX_N = 1e5 + 5;
int n, ans;
int Arr[MAX_N];
unordered_map <int, int> cnt[2][2], Mark;
unordered_map <int, int>::iterator it;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &Arr[i]);
		cnt[0][i & 1][Arr[i]]++;
		Mark[Arr[i]]++;
	}

	sort(Arr, Arr + n);
	for (int i = 0; i < n; i++)
		cnt[1][i & 1][Arr[i]]++;

	for (it = Mark.begin(); it != Mark.end(); it++)
		ans += abs(cnt[0][0][it->first] - cnt[1][0][it->first]);

	printf("%d", ans >> 1);
	return 0;
}

Measured memory_bytes: 17108
#include <bits/stdc++.h>
using namespace std;
#define ll double
#define endl '\n'

int main() {

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

    ll a,b,h,m;
    cin>>a>>b>>h>>m;

    ll pi=acos(-1);
    ll min=m*6;
    ll hr=h*30+m/2;
    ll angle=fabs(min-hr);
    if(angle>180)
    angle=360-angle;
    ll val=pi/180.0;
    ll res=cos(val*angle);
    ll ans=sqrt(a*a+b*b-res*2*a*b);
    cout<<fixed<<setprecision(10)<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4180
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, D;
    cin >> N >> D;
    
    vector<vector<ll> > X;
    rep(i, N){
        vector<ll> inp;
        rep(i, D){
            ll x;
            cin >> x;
            inp.pb(x);
        }
        X.pb(inp);
    }
    
    
    ll ans = 0 ;
    for(ll i= 0 ; i <N; i++){
        for(ll j = i+1; j < N; j++){
            ll distdist = 0;
            rep(k, D){
                distdist += (X[i][k]-X[j][k]) * (X[i][k]-X[j][k]);
            }
            ll dist = sqrt(distdist);
            if(dist * dist == distdist) ans ++;
        }
    }
    
    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s1 = scanner.nextLine();
		String s2 = scanner.nextLine();
		
		char[] check = s2.toCharArray();
		char[] reverse = new char[s2.length()];
		
		for (int i = 0; i < reverse.length; i++) {
			reverse[i] = check[check.length-i-1];		
		}
		String rString = new String(reverse);
		if (rString.equals(s1)) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
		
		scanner.close();
	}
}


Measured memory_bytes: 23636
H,W=map(int,input().split())
a=[list(input()) for i in range(H)]
X=[0 for i in range(W)]
Y=[0 for i in range(H)]
for i in range(H):
    flag=0
    for j in range(W):
        if a[i][j]=="#":
            flag=1
            break
    if flag==0:
        Y[i]=1
for j in range(W):
    flag=0
    for i in range(H):
        if a[i][j]=="#":
            flag=1
            break
    if flag==0:
        X[j]=1
for i in range(H):
    st=""
    if Y[i]==1:
        continue
    for j in range(W):
        if X[j]==0:
            st+=a[i][j]
    print(st)



Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int a, b;
    cin >> a >> b;
    if(a>b){
        cout << a-1 << endl;
    }else{
        cout << a << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
from bisect import bisect_right, bisect_left
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    d = deque()
    for a in A:
        t = bisect_right(d, a)
        if t == 0:
            d.appendleft(a)
            continue
        if d[t-1] == a:
            t = bisect_left(d, a)
        if t == 0:
            d.appendleft(a)
        else:
            d[t-1] = a
    print(len(d))

if __name__ == '__main__':
    main()


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

int main(){
  int n;
  cin >> n;
  
  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data[i];
  }
  
  sort(data.begin(), data.end());
  
  cout << data[n-1] - data[0] << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = set()
for i in range(n,0,-1):
    count = 0
    for j in range(1,n//i+1):
        if i*j in ans:
            count += 1
    if count % 2 != a[i-1] :
        ans.add(i)
print(len(ans))
print(" ".join(map(str,ans))) 


Measured memory_bytes: 21480
#include <iostream>
using namespace std;
int par[100010],o[100010];

int find(int pos){
  if(o[pos]) return pos;
  return find(par[pos]);
}

int main(){
  while(1){
    int n,q;
    cin>>n>>q;
    if(!n&&!q)break;
    for(int i=0;i<=n;i++) o[i]=0;
    for(int i=2;i<=n;i++) cin>>par[i];
    
    o[1]=1;
    long long ans=0;
    while(q--){
      char ch;int idx;
      cin>>ch>>idx;
      if(ch=='M') o[idx]=1;
      if(ch=='Q')ans+=find(idx);
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1936
#include <bits/stdc++.h>
using namespace std;
int n, c, z, f[100020];
pair<int, int> x[100020], y[100020];
pair<int, pair<int, int> > a[200020];
int F(int x) {
	return f[x] != x ? f[x] = F(f[x]) : x;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &x[i].first, &y[i].first);
		x[i].second = y[i].second = i;
		f[i] = i;
	}
	sort(x, x + n);
	sort(y, y + n);
	for (int i = 1; i < n; i++) {
		a[c++] = {x[i].first - x[i - 1].first, {x[i].second, x[i - 1].second}};
		a[c++] = {y[i].first - y[i - 1].first, {y[i].second, y[i - 1].second}};
	}
	sort(a, a + c);
	for (int i = 0; i < c; i++) {
		if (F(a[i].second.first) != F(a[i].second.second)) {
			f[F(a[i].second.first)] = F(a[i].second.second);
			z += a[i].first;
		}
	}
	printf("%d\n", z);
	return 0;
}

Measured memory_bytes: 4480
#include <iostream>

int main() {
    int a;
    int b;
    std::cin >> a >> b;
    int diff = a - b;

    std::cout << "a";

    if (diff < 0) {
        std::cout << " < ";
    } else if (diff == 0) {
        std::cout << " == ";
    } else {
        std::cout << " > ";
    }

    std::cout << "b" << std::endl;
    
    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    string s;
    cin >> s;

    rep(i, 0, s.size()) {
        if ((i % 2 == 1 && s[i] == 'R') || (i % 2 == 0 && s[i] == 'L')) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		scanf("%d", &n);
		vector<P>v;
		rep(i, n) {
			string l;
			int p, a, b, c, d, e, f, s, m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			int time = a + b + c + (d + e)*m;
			int shu = f*m*s - p;
			v.push_back({ (double)shu / (double)time,l });
		}
		sort(v.begin(), v.end(), [](P a, P b) {
			if (a.first == b.first) {
				transform(a.second.begin(), a.second.end(), a.second.begin(), ::tolower);
				return a.second < b.second;
			}
			return a.first > b.first;
		});
		rep(i, n) {
			cout << v[i].second << endl;
		}
		cout << "#" << endl;
	}
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG


void dfs (ll keta , ll n , vector<ll> &a){
    if(keta==11){
        return;
    }

    a.push_back(n);
    for(int i=-1;i<2;i++){
        int res=n%10;
        if(res+i>=0&&res+i<=9) {
            
            dfs(keta+1,n*10+res+i,a);
        }
    }
}

int main(){
    int k;
    cin>>k;
    vector<ll> a;
    rep1(i,9){
        dfs(1,i,a);
    }
    sort(a.begin(),a.end());
    cout<<a[k-1]<<endl;
}

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


int main()
    {
        set <char> st;
        
        for(int i=0;i<4;i++){
            char s;
            cin>>s;
            st.insert(s);
        }
        if(st.size()==2)
        cout<<"Yes";
        else
        cout<<"No";
        
 
        
        
    
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ab = []
for i in range(m):
	a,b = map(int, input().split())
	ab.append([a,b])
ab = sorted(ab, key=lambda x: x[1])
mn = ab[0][1]
c = 1
for i in ab:
	if i[0] >= mn:
		c += 1
		mn = i[1]
print (c)

Measured memory_bytes: 22108
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int >flag(31,1);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        int flag2[31] = {};
        for(int j = 0; j < k; j++){
            int a; cin >> a;
            flag2[a] = 1;
        }
        for(int j = 0; j < 31; j++) if(!flag2[j]) flag[j] = 0;
    }
    int ans = 0;
    for(int i = 1; i <= m; i++) if(flag[i]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int a,b;
   while(cin>>a>>b)
   {
      long long  int gcd,temp,s,t;
       s=a*b;
       if(a>=b){
       while(b!=0)
       {
           temp=b;
           b=a%b;
           a=temp;
       }
       gcd=a;
       }
       else
       {
          while(a!=0)
       {
           temp=a;
           a=b%a;
           b=temp;
       }
       gcd=b;
       }

       if(gcd>1)
       {
           t=s/gcd;
           cout<<t<<endl;
       }
       else
        cout<<s<<endl;
   }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a,b,c,x,i,j,k,count=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(i=a;i>=0;i--){
        if(500*i<=x){
            for(j=b;j>=0;j--){
                if(500*i+100*j<=x){
                    for(k=c;k>=0;k--){
                        if(500*i+100*j+50*k==x){
                            count++;
                        }
                    }
                }
            }
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b))cout<<"B"<<endl;
    else cout<<"A"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

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



int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n, q; cin >> n >> q;
    
    deque<deque<int> > dq(n);
    
    REP(i, q){
        int a, b, c; cin >> a;
        if(a==0){
            cin >> b >> c;
            dq[b].push_back(c);
        }
        if(a==1){
            cin >> b;
            if(dq[b].size()==0) continue;
            
            cout << dq[b][0] << endl;
        }
        if(a==2){
            cin >> b;
            if(dq[b].size()==0) continue;
            
            dq[b].pop_front();
        }
    }
	return 0;
}


Measured memory_bytes: 4304
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
N,K,S=map(int,input().split())
lst=[]
for i in range(K):
    lst.append(S)
for i in range(N-K):
    if S==10**9:
        lst.append(S-1)
    else:
        lst.append(S+1)
print(" ".join(map(str,lst)))


Measured memory_bytes: 66208
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(void){
	int a,b,c,d,e,f,g,h;
		cin >> a >> b >> c >> d;
	
	cout << a*b-a*d-b*c+c*d << endl;
	return 0;
}

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

left = 0
right = 1
max_length = 0

while left < N:
    if right - left > N - right:
        break
    serch_str = S[left:right]
    if serch_str in S[right:]:
        max_length = max(max_length, len(serch_str))
        right += 1
    else:
        left += 1

print(max_length)

Measured memory_bytes: 3064
#公式解法見て書いた
iN = int(input())

a6 = [0]*7
for i in range(7):
    a6[i] = 6 ** i
a6.reverse()
a9 = [0]*6
for i in range(6):
    a9[i] = 9 ** i
a9.reverse()

iAns = iN
for i in range(iN+1):
    iD = iN - i
    iC = 0
    for j in range(7):
        if i:
            iG = a6[j]
            if i >= iG:
                iC += (i // iG)
                i %=iG
    if iAns <= iC:
        continue
    for j in range(6):
        if iD :
            iG = a9[j]
            if iD >= iG:
                iC += (iD // iG)
                iD %= iG
    if iAns > iC:
        iAns = iC
print(iAns)


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> field(H);
  for (int i = 0; i < H; i++) cin >> field.at(i);
  vector<int> dx = { -1, 0, 1, -1, 1, -1, 0, 1 };
  vector<int> dy = { 1, 1, 1, 0, 0, -1, -1, -1 };
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (field.at(y).at(x) == '#') continue;
      int cnt = 0;
      for (int i = 0; i < 8; i++) {
        int x_next = x + dx.at(i);
        int y_next = y + dy.at(i);
        if (x_next < 0 || x_next >= W) continue;
        if (y_next < 0 || y_next >= H) continue;
        if (field.at(y_next).at(x_next) == '#') cnt++;
      }
      field.at(y).at(x) = char(cnt + '0');
    }
  }
  for (int i = 0; i < H; i++) cout << field.at(i) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,m,a,b,dp[20001][256],s[20000],t[16],ans,L;
void ini(void){
    for(int i=0;i<=20000;i++){
        for(int j=0;j<256;j++){
            dp[i][j]=1e9;
        }
    }
}
int main(void){
    while(1){
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    ans=1e9;
    ini();
    for(int i=0;i<m;i++){
        cin>>t[i];
    }
    for(int i=0;i<n;i++)cin>>s[i];
    dp[0][128]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=255;j++){
            if(dp[i][j]==1e9)continue;
            for(int k=0;k<m;k++){
                L=j+t[k];
                L=min(255,L);
                L=max(0,L);
                dp[i+1][L]=min(dp[i+1][L],dp[i][j]+(L-s[i])*(L-s[i]));
            }
        }
    }
    for(int i=0;i<256;i++){
        //cout<<dp[n][i]<<endl;
        ans=min(ans,dp[n][i]);
    }
    cout<<ans<<endl;
    }
}



Measured memory_bytes: 23164
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> s;
  if (s == "ABC")
  {
    cout << "ARC" << endl;
  }
  else
  {
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3656
N = int(input())
limitN = 60000
P = [0]*limitN
listP = []
for i in range(2,limitN):
    if P[i] == 0:
        listP.append(i)
        j=1
        while i*j < limitN:
            P[i*j] = 1
            j+=1
Ans = list(map(str,filter(lambda x: x%5==1,listP)))
print(" ".join(Ans[0:N]))

Measured memory_bytes: 3828