akhauriyash/Code-Regression huggingface dataset:
object Main extends Runnable {
  
  def main(args: Array[String]): Unit = {
    new Thread(null, Main, "", 16 * 1024 * 1024).start()
  }

  override def run(): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val P = new Array[(Int, Int)](N)
    (0 until N) foreach { i =>
      val x, y = sc.nextInt()
      P(i) = (x, y)
    }

    val routes = P.permutations.map { routes =>
      routes.sliding(2).map { route =>
        Math.sqrt(Math.pow(route(0)._1 - route(1)._1, 2) +
          Math.pow(route(0)._2 - route(1)._2, 2))
      }. sum
    }. toList
    println(routes.sum / routes.length)
  }
  
}

Measured memory_bytes: 80052
n, m = map(int, input().split())

x = n - 2
if x < 0:
    x = 0

y = m - 2
if y < 0:
    y = 0

if n == 1 and m == 1:
    print(1)
elif n == 1 and m > 1:
    print(y)
elif n > 1 and m == 1:
    print(x)
else:
    print(x * y)


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int arr[105];
int ans[105];
int main() {
  int n;
  cin >> n;
  string f;
  for (int i = 1; i <= n; i++){
    cin >> arr[i];
  }

  int r = n;
  int cntr = 1;
  while (r > 0){
    int flag = -1;
    for (int i = r; i >= 1; i--){
      if (arr[i] == i){
        flag = i;
        break;
      }
    }
    if (flag == -1){
      cout << "-1" << endl;
      return 0;
    }
    ans[cntr] = flag;
    cntr++;
    for (int i = flag; i < r; i++){
      arr[i] = arr[i+1];
    }
    r--;
  }

  for (int i = n; i >= 1; i--){
    cout << ans[i] << endl;
  }

}

Measured memory_bytes: 3576
import sys
read = sys.stdin.buffer.read#全部読み込むやつ
readline = sys.stdin.buffer.readline#1行読み込むやつ
readlines = sys.stdin.buffer.readlines#リストで読み込むらしい

H,N,*A = map(int,read().split())
S = sum(A)
if H <= S:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 52796
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++){
		 int n,x,t1;
		 cin >> n >> x >> t1;
		 cout << ((n + x - 1) / x) * t1 << "\n";
	 }
}


Measured memory_bytes: 3632
#include<cstdio>
const int N=1e5+5,M=3e5+5;
int n,m,i,ans,he[N],f[N];
struct edge{int l,to;}e[M];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
void write(int x){if (x>9) write(x/10);putchar(x%10+48);}
void add(int x,int k){for (;x<=n;x+=x&-x) f[x]+=k;}
int ask(int x){int k=0;for (;x;x-=x&-x) k+=f[x];return k;}
int main(){
	for (m=read(),n=read(),i=1;i<=m;i++){
		int l=read(),r=read();
		e[i].l=he[r-l+1];he[r-l+1]=i;e[i].to=l;
	}
	for (int x=1;x<=n;x++){
		for (ans=m,i=x;i<=n;i+=x) ans+=ask(i);
		write(ans);putchar('\n');
		for (i=he[x];i;i=e[i].l)
			m--,add(e[i].to,1),add(e[i].to+x,-1);
	}
}

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

const int r = 3001;
int dp[r][r];
string a, b;

int solve(int i, int j) {
    if (i == a.size() || j == b.size())
        return 0;
    if (dp[i][j] != -1)
        return dp[i][j];
    if (a[i] == b[j])
        return dp[i][j] = 1 + solve(i + 1, j + 1);
    return dp[i][j] = max(solve(i + 1, j), solve(i, j + 1));
}

void build(int i, int j) {
    if (i == a.size() || j == b.size())
        exit(0);
    if (a[i] == b[j]) {
        cout << a[i];
        build(i + 1, j + 1);
    }
    if (dp[i + 1][j] >= dp[i][j + 1])
        build(i + 1, j);
    else
        build(i, j + 1);
}
int main() {
    memset(dp, -1, sizeof dp);
    cin >> a >> b;
    solve(0, 0);
    build(0, 0);
    return 0;
}


Measured memory_bytes: 35840
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[][] a = new int[N][N];
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) a[i][j] = scanner.nextInt();

    long[] dp = new long[1 << N];
    for (int i = 1; i < (1 << N); i++) {
      int msb = msb(i);
      dp[i] = dp[i ^ (1 << msb)];

      int k = i;
      int j = 0;
      while (k > 0) {
        if (k % 2 == 1) dp[i] += a[msb][j];
        k >>= 1;
        j++;
      }
    }

    for (int i = 1; i < (1 << N); i++)
      for (int j = i; j > 0; j = (j - 1) & i)
        dp[i] = Math.max(dp[i], dp[j] + dp[i ^ j]);

    System.out.println(dp[(1 << N) - 1]);
  }

  private static int msb(int n) {
    int i = -1;
    while (n > 0) {
      n /= 2;
      i++;
    }
    return i;
  }
}


Measured memory_bytes: 22996
// Problem : D - Sum of Large Numbers
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;


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

    long n, k;
    cin >> n >> k;
    
    long long ans = 0;
    long long const m = pow(10, 9) + 7;
       
    
    long long sLeft = 0, sRight = 0;
    for (long i = 1; i <= n+1; i++) {
        sLeft = sLeft + i;
        sRight = sRight + n + 2 - i;
        if (i >= k) {
            ans = (ans + sRight - sLeft + 1) % m;
        } 
    }
    cout << ans;
            
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int a,b,c,x=0,y=0;
    char g,m;
    while(cin>>a>>g>>b>>m>>c){
        if(c*c==a*a+b*b){
            x++;
        }else if(a==b){
            y++;
        }
    }
    cout<<x<<endl<<y<<endl;
    return 0;
}

Measured memory_bytes: 3056
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        long[] p = {in.nextLong(), in.nextLong(), in.nextLong()};
        String t = in.next();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = p["spr".indexOf(t.charAt(i))];
        }
        long ans = 0;
        boolean[] used = new boolean[n];
        for (int i = 0; i < n; i++) {
            if (i < k) {
                used[i] = true;
                ans += a[i];
            } else if (t.charAt(i) != t.charAt(i - k) || !used[i - k]) {
                used[i] = true;
                ans += a[i];
            }
        }
        out.println(ans);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 26580
#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.at(i);
   }
   sort(A.begin(), A.end());
   bool flag = true;
   for (int i=0; i<N-1; i++){
      if (A.at(i) == A.at(i+1)){
         flag = false;
         break;
      }
   }
   if (flag)
      cout << "YES" << endl;
   else
      cout << "NO" << endl;

}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long x = sc.nextLong();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}

		long count = 0;
		for (int i = 1; i < n; i++) {
			long sum = a[i] + a[i - 1];
			long k = Math.max(0, sum - x);
			count += k;
			a[i] = Math.max(0, a[i] - k);
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 47412
#include<iostream>
using namespace std;
long long a,b;
main(){
    cin>>a>>b;
    if(a*b<=0){
        cout<<"Zero"<<endl;
        return 0;
    }
    if(a>0 and b>0){
        P:
        cout<<"Positive"<<endl;
        return 0;
    }
    if((b-a)%2==0){
        cout<<"Negative"<<endl;
        return 0;
    }
    else goto P;

}

Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");
  var a = input[1].split("");
  var b = input[2].split("");
  var c = input[3].split("");
  var sum = a.length*2;
  for(var i=0;i<a.length;i++){
    var x = 0;
    if(a[i]==b[i]) x++;
    if(c[i]==b[i]) x++;
    if(a[i]==c[i]) x++;
    if(x == 3) sum -= 2;
    else if(x == 1) sum--;
  }
  console.log(sum);
  }Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

ll n, W;
ll w[110], v[110];
vector<vector<ll> > dp(110,vector<ll>(100010,-1));
ll rec(ll i, ll j){
    if (dp.at(i).at(j) != -1)
    {
        return dp.at(i).at(j);
    }
    
    ll res = 0;
    if(i == n){
        res = 0;
    }else if(j < w[i]){
        res = rec(i + 1, j);
    }else{
        res = max(rec(i + 1,j),rec(i + 1,j - w[i]) + v[i]);
    }
    //cout << "res" << i << ',' << j << "=" << res << endl;
    return dp.at(i).at(j) = res;
}

int main() {
    cin >> n >> W;
    for (size_t i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    
    cout << rec(0,W) << endl;

    return 0;
}

Measured memory_bytes: 90116
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,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 ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let s=[ssin(),ssin(),ssin()].sort()
  out(s[0]=='a'&&s[1]=='b'&&s[2]=='c'?'Yes':'No')
}
main()

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt, num = 0;
  cin >> n;
  for (int i = 1; i <= n; i += 2) {
    cnt = 0;
    for (int j = 1; j <= n; j++) {
      if (i % j == 0) {
        cnt++;
      }
    }
    if (cnt == 8) {
      num++;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

const int maxn = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    while (cin >> n) {
        vector<pair<int,int>>v;
        f (n) {
            int x, y;
            cin >> x >> y;
            v.pb({x, y});
        }
        v.pb({2e9+5,0});
        sort(all(v));
        int dp[n + 5] = {};
        dp[n] = 1;
        stack<int>st;
        st.push(n);
        for (int i = n - 1 ; i >= 0 ; i--) {
            dp[i] = dp[i + 1];
            while (v[i].F + v[i].S > v[st.top()].F) {
                st.pop();
            }
            dp[i] += dp[st.top()];
            dp[i] %= mod;
            st.push(i);
        }
        cout << dp[0] << '\n';
    }
}

Measured memory_bytes: 3056
import sys
 
a = list(map(int,input().split()))
H = a[0]
W = a[1]
board = [["d" for j in range(W+2)] for i in range(H+2)]
for i in range(H):
    temp = input()
    for j in range(W):
        board[i+1][j+1] = temp[j]
 
 
for i in range(1, H+1):
    for j in range(1, W+1):
        if board[i][j] == "#" and board[i][j-1] != "#" and board[i][j+1] != "#" and board[i-1][j] != "#" and board[i+1][j] != "#":
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 3064
#
# abc177 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1000 15 80"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2000 20 100"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10000 1 1"""
        output = """No"""
        self.assertIO(input, output)


def resolve():
    D, T, S = map(int, input().split())
    if S*T >= D:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16252
#include<stdio.h>

int main () {

   int s[10001] = {0};
   int t[501] = {0};
   int x, y, i, j;
   int count = 0;

   scanf("%d", &x);

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

   scanf("%d", &y);

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

   for(i = 0; i < y; i++){
      for(j = 0; j < x; j++){
         if(s[j] == t[i]){
            count++;
            break;
         }
      }
   }

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

   return 0;

}

Measured memory_bytes: 1884
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>

using namespace std;

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

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

  array<vector<int>, 26> count;
  for(auto& v : count) v.resize(n);
  for(int i = 0; i < n; i++){
    for(char c : S[i]){
      count[c - 'a'][i]++;
    }
  }

  array<int, 26> result;
  transform(count.begin(), count.end(), result.begin(), [](vector<int> const& v){return *std::min_element(v.begin(), v.end());});
  for(int i = 0; i < 26; i++) while(result[i]--) cout << (char)('a' + i);
  cout << endl;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std;
typedef long long ll;
const ll M=998244353;
int n,i,j,m;
ll p[5000005],inv[5000005],ans;
ll C(ll n,ll m)
{
	if(n<m)
		return 0;
	return p[n]*inv[m]%M*inv[n-m]%M;
}
ll qpow(ll a,ll b)
{
	ll s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		s=s*s%M;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d %d",&n,&m);
	p[0]=p[1]=inv[1]=1;
	for(i=2;i<=m*3+n;i++)
	{
		p[i]=p[i-1]*i%M;
		inv[i]=(M-M/i)*inv[M%i]%M;
	}
	inv[0]=1;
	for(i=2;i<=m*3+n;i++)
		inv[i]=inv[i]*inv[i-1]%M;
	ans=C(m*3+n-1,n-1)-C(m+n-2,n-1)*n%M;
	for(i=m+1;i<=m*3&&i<=n;i++)
		if((m*3-i)%2==0)
			ans=(ans-C(n,i)*C(n+(m*3-i)/2-1,n-1))%M;
	cout<<(ans%M+M)%M;
}


Measured memory_bytes: 41216
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    if(n<1000) {
        cout<<(1000-n)<<'\n';
        return 0;
    }
    else { //>=1000
        int temp = n/1000;
        if(n%1000==0) {
            cout<<0<<'\n';
            return 0;
        }
        else {
            temp++;
            int res = (temp*1000-n);
            cout<<res<<'\n';
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
int main(void){
    
    int n,l;
    scanf("%d %d",&n,&l);
    
    int i,k,a=0;
    int dif = 10000;
    
    for(i=1;i<n+1;i++) a += l+i-1;
    for(i=1;i<n+1;i++){
        
        k = abs(l+i-1);
        if(dif > k) dif = k;

    }
    
    if(a>0) printf("%d\n",a-dif);
    else printf("%d\n",a+dif);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    BeatMeScanf;
    //freopen("G:/C++/in.txt", "r", stdin);
    //freopen("G:/C++/out.txt", "w", stdout);

    int n;
    cin>>n;
    vector<int>p;
    for(int i = 0; i<n; i++)
    {
        int temp;
        cin >> temp;
        p.push_back(temp);
    }

    int cnt = 0;
    int m = p[0];

    for(int i = 0; i<n; i++)
    {
        if(p[i]<=m)
        {
            cnt++;
            m = p[i];
        }
    }
    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int a[3][3];
    rep(i, 3)rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    int b[n];
    rep(i, n) cin >> b[i];
    bool a2[3][3];
    rep(i, 3)rep(j, 3) a2[i][j] = false;
    rep(i, n){
        rep(j, 3)rep(k, 3){
            if (a[j][k] == b[i]){
                a2[j][k] = true;
            }
        }
    }
    // 横
    rep(i, 3){
        rep(j,3){
            if (a2[i][j] == false){
                break;
            }
            if(j == 2){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    // 縦
    rep(j, 3){
        rep(i, 3){
            if (a2[i][j] == false){
                break;
            }
            if(i == 2){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    // 斜め
    rep(i, 3){
        if (a2[i][i] == false){
            break;
        }
        if(i == 2){
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(i, 3){
        if (a2[i][2-i] == false){
            break;
        }
        if(i == 2){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

const ll M = 1000000007;

ll pow_mod(ll n, ll p, ll m)
{
    if (p == 1)
        return n % m;
    if (p % 2 == 0)
    {
        ll t = pow_mod(n, p / 2, m);
        return (t * t) % m;
    }
    else
        return (pow_mod(n, p - 1, m) * n) % m;
}

ll comb_mod(ll n, ll k, ll m)
{
    ll x = 1;
    for (ll i = n; i > n - k; i--)
    {
        x *= i;
        x %= m;
    }
    ll y = 1;
    for (ll i = k; i > 0; i--)
    {
        y *= i;
        y %= m;
    }
    return (x * pow_mod(y, m - 2, m)) % m;
}

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

    ll res = (pow_mod(2, n, M) - 1) % M;
    res = (res + M - comb_mod(n, a, M)) % M;
    res = (res + M - comb_mod(n, b, M)) % M;
    cout << res << endl;
}

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

const ll mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int N;
ll DP[maxn][2];
vector<int> g[maxn];

void DFS(int v , int p){
    DP[v][0] = DP[v][1] = 1;
    for(int u : g[v]){
        if(u != p){
            DFS(u , v);
            DP[v][0] = (DP[v][0] * (DP[u][0] + DP[u][1]) % mod) % mod;
            DP[v][1] = DP[v][1] * DP[u][0] % mod;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    if(N == 1){
        cout << 2 << endl;
        return 0;
    }
    for(int i = 1; i <= N - 1; ++i){
        int x , y; cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int start = 1;
    for(; start <= N; ++start){
        if(g[start].size() == 1){
            break;
        }
    }
    DFS(start , -1);
    cout << (DP[start][0] + DP[start][1]) % mod << endl;
}


Measured memory_bytes: 15104
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 0
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n a
x1 ... xn

n 50
a 50
xi 50
 */
int n,a,x[50];
ll dp[51][51][2501];

int main(){
  cin>>n>>a;
  REP(i,n){
    cin>>x[i];
  }

  dp[0][0][0] = 1;
  REP(i,n){
    REP(j,n+1){
      LOG("i=%2d, j=%2d|",i,j);
      REP(k,n*a+1){
        if(j>0 && k>= x[i]){
          dp[i+1][j][k] = dp[i][j][k] + dp[i][j-1][k-x[i]];
        } else {
          dp[i+1][j][k] = dp[i][j][k];          
        }
        LOG("%3lld ",dp[i+1][j][k]);
      }
      LOG("\n");
    }
  }

  ll ans=0;
  FOR_IN(j,1,n+1){
    ans += dp[n][j][j*a];
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 50048
import sys
input = sys.stdin.readline
N = int(input())
S = list(input())[: -1]
mod = 10 ** 9 + 7
dp = [[0] * N for _ in range(N)]
for j in range(N): dp[0][j] = 1

for i in range(N - 1):
  if S[i] == "<":
    for j in range(N - i - 1):
      dp[i + 1][j] += dp[i][j]
      dp[i + 1][j] %= mod
    for j in range(N - i - 2):
      dp[i + 1][j + 1] += dp[i + 1][j]
      dp[i + 1][j + 1] %= mod
  else:
    for j in range(1, N - i):
      dp[i + 1][j - 1] += dp[i][j]
      dp[i + 1][j - 1] %= mod
    for j in range(N - 1, 0, -1):
      dp[i + 1][j - 1] += dp[i + 1][j]
      dp[i + 1][j - 1] %= mod
print(dp[-1][0])

Measured memory_bytes: 113756
//LETS START AGAIN
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define F first 
#define S second
#define int long long int
set<int> st;
int n;
void solve(int num)
{
    if(num<=n)
    {
        int temp = num;
        map<int,int> mp;
        while(temp!=0)
        {
            mp[temp%10]++;
            temp = temp/10;
        }
        if(mp[3] && mp[5] && mp[7])
            st.insert(num);
    }
    else return ;
    int n1 = num*10+3;
    int n2 = num*10+5;
    int n3 = num*10+7;
    solve(n1);
    solve(n2);
    solve(n3);
    return ;
} 
signed main() 
{ 
    fast;
    cin>>n;
    solve(3);
    solve(5);
    solve(7);
    cout<<st.size();
} 



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

signed main() {
	int n ; cin >> n;
	int pos[n];
	for(int i =  0; i < n ; i ++ ) {
		int x ; cin >> x;
		--x;
		pos[x] = i;
	}
	int ans = 0;
	multiset<int> mm = {-1 , -1 , n , n};
	for(int i = n -1 ; i >= 0 ; i --) {
		mm.insert(pos[i]);
		auto it = mm.find(pos[i]);
		auto l1 = *prev(it) , l2 = *prev(prev(it));
		auto r1 = *next(it) , r2 = *next(next(it));
		if(l1 != -1)
			ans += (i + 1) * (l1 - l2) * (r1 - pos[i]);
		if(r1 != n)
			ans += (i + 1)*(r2 - r1) * (pos[i] - l1);
	}
	cout << ans;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100005];
	scanf("%s",s);
	int n=strlen(s);
	int i;
	int g,p;
	g=p=0;
	int ans=0;
	for(i=0;i<n;i++)
	{
		if(s[i]=='g')
		{
			if(p+1<=g)
			{
				p++;
				ans++;
			}
			else
				g++;
		}
		else
		{
			if(p+1<=g)
				p++;
			else
			{
				g++;
				ans--;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

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

  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }

  each(i, 20) {
    ull count = i + 1;
    ull mouse = ((a-1) * count) + 1;
    if (mouse >= b) {
      cout << count << endl;
      return 0;
    } else {
      continue;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  ll K, X;
  cin >> K >> X;
  FOR(i, max(-1000000LL, X - K + 1), min(1000001LL, X + K)) {
    cout << i << " ";
  }
  return 0;
}

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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    if (k <= a){
        cout << k << endl;
    }
    else if (k <= a + b){
        cout << a << endl;
    }
    else{
        cout << a - (k - a - b) << endl;
    }
    
    return 0;
}

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

typedef pair <int, int> ii;

const int Maxm = 100005;

int n;
int a[Maxm];
int freq[Maxm];
ii best[2][2];

void Get(int from)
{
    fill(freq, freq + Maxm, 0);
    for (int i = from; i < n; i += 2)
        freq[a[i]]++;
    for (int i = 1; i < Maxm; i++)
        if (ii(freq[i], i) > best[from][0])
            best[from][1] = best[from][0], best[from][0] = ii(freq[i], i);
        else if (ii(freq[i], i) > best[from][1])
            best[from][1] = ii(freq[i], i);
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    Get(0); Get(1);
    int res = 0;
    if (best[0][0].second == best[1][0].second)
        res = max(best[0][0].first + best[1][1].first,
                  best[0][1].first + best[1][0].first);
    else res = best[0][0].first + best[1][0].first;
    printf("%d\n", n - res);
    return 0;
}


Measured memory_bytes: 1024
s = raw_input().split(' ')
a = []
op = []
for i in xrange(3):
    if i%2 == 0:
        a.append(int(s[i]))
    else:
        if s[i]=='-':
            op.append(-1)
        else:
            op.append(1)
print a[0]+a[1]*op[0]

Measured memory_bytes: 2568
MOD = 1000003
MAX = MOD
fact = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
invfact = [0 for i in range(MAX)]

def comb_build(n):
  fact[0] = inv[0] = invfact[0] = 1
  fact[1] = inv[1] = invfact[1] = 1
  for i in range(2, n):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = inv[MOD%i]*(MOD-MOD//i)%MOD
    invfact[i] = invfact[i-1]*inv[i]%MOD

def nCk(n, k):
  if n<k or n<0 or k<0:
    return 0
  return (((fact[n]*invfact[k])%MOD)*invfact[n-k])%MOD

comb_build(MAX)

q = int(input())
for i in range(q):
  x, d, n = list(map(int, input().split()))
  if x==0 or d==0:
    print(pow(x, n, MOD))
    continue

  x = x*pow(d, MOD-2, MOD)%MOD
  if x+n-1>=MOD:
    print(0)
  else:
    ans = pow(d, n, MOD)*fact[x+n-1]*invfact[x-1]%MOD
    print(ans)

Measured memory_bytes: 132856
N=int(input())
X = list(map(int, input().split()))
X.sort()
p = X[0]
min_power = float('inf')
while p <= X[-1]:
  power = 0
  for x in X:
    power += pow((x-p),2)
  min_power = min(min_power, power)
  p += 1
print(min_power)

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, v[25],c[25];
    cin >> n;
    int ans=0;
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++) cin>>c[i];
    for(int i=0;i<n;i++) {
        if(v[i]>c[i]) ans+=v[i]-c[i];
    }
    
    cout<<ans<<endl;
}

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

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while( x != NIL ){
        y = x;
        if(z->key > x->key){
            x = x->right;
        }else{
            x = x->left;
        }
    }
    z->parent = y;
    if(y == NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u){
    if(u == NIL) return;
    cout <<  " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int m, i, x;
    string s;
    cin >> m;
    for(i = 0; i < m; i++){
        cin >> s;
        if(s == "insert"){
            cin >> x;
            insert(x);
        }else if(s == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
            
        }
    
    }
    

    return 0;
}


Measured memory_bytes: 26580
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = INF
    for ave in range(-100, 101):
        s = 0
        for a in A:
            s += (a - ave) ** 2
        ans = min(ans, s)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4072
/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH RANJAN******************************************************
***********************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<n;i++)
#define frs(i,a,b) for(int i = a;i<b;i++)
#define meme(a,b) memset(a,b,sizeof(a)); //works only for 0 and -1
void solve(){
int x,n;
cin>>x>>n;
int arr[n];
fr(i,n)cin>>arr[i];
sort(arr,arr+n);
int k = 0;
while(1){
int x1 = x+k;
int x2 = x-k;
if(binary_search(arr,arr+n,x2)==false){cout<<x2;return;}
if(binary_search(arr,arr+n,x1)==false){cout<<x1;return;}
k++;
}
}
int main(){
  fast();
// int t;cin>>t;
// while(t--){
    solve();
// }
 return 0;
}


Measured memory_bytes: 3616
#include <cstdio>

int main() {
  int N, Y;
  scanf("%d %d", &N, &Y);

  for (int i = 0; i <= N; ++i)
    for (int j = 0; j <= N; ++j) {
      int k = N - (i+j);
      if (k < 0) break;
      if (i + 5*j + 10*k == Y/1000)
        return !printf("%d %d %d\n", k, j, i);
    }
  puts("-1 -1 -1");
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);

	for (i = 1; i <= n; i++) {
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1, tail = n + 1;

	while (head != tail) {
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if (u.t > 0)enqueue(u);
		else {
			printf("%s %d\n", u.name, elaps);
		}
	}
	return 0;
}

Measured memory_bytes: 12820
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if n%(min([a,b,c,d,e]))==0:
    res=4+ n//(min([a,b,c,d,e]))
else:
    res=5+ n//(min([a,b,c,d,e]))
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n,a[200005];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<n;i++)
        if(a[i]==a[i+1])
        {
            cout<<"NO";
            return 0;
        }
    cout<<"YES";
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int i,N,K;
  char S[11],a;
  scanf("%d",&N);
  scanf("%s",&S);
  scanf("%d",&K);
  for(i=0;i<N;i++){
    a=S[K-1];
    if(S[i]!=a){
      S[i]='*';
    }
  }
    printf("%s",S);
  return 0;
}


Measured memory_bytes: 128
#dp[i]:i+1桁目-n桁目で1桁の数字は/2桁の数字は/何通りあるか
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        t1 = n-1
        u1 = n-1
        for t in range(n):
            if i == int(s[t]):
                t1 = t
                break
        for u in range(t1+1,n):
            if j == int(s[u]):
                u1 = u
                break
        if int(s[t1]) == i and int(s[u1]) == j and t1<u1:
            #print(i,j,k,t1,u1,v1)
            ans += len(set(s[u1+1:]))
print(ans) 
            
    


Measured memory_bytes: 67452
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
const LL INF = 999999999999;

int main(){
    int n;
    cin >> n;
    char now, next;
    cin >> now;
    rep(i, n-1){
        cin >> next;
        if(now == 'T' && next == 'F'){
            now = 'F';
        }else{
            now = 'T';
        }
    }
    cout << now << endl;

}



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

int main(){
	string S, S1, S2;
	int count1 = 0, count2 = 0;

	cin >> S;

	S1 = S;
	// 0 first
	for(int i = 0; i < S1.size()-1; ++i){
		if(i%2 == 0){
			if(S1[i] == '0'){
				if(S1[i+1] == '0'){
					S1[i+1] = '1';
					count1++;
				}
			}else{
				S1[i] = '0';
				count1++;
			}
		}else{
			if(S1[i] == '1'){
				if(S1[i+1] == '1'){
					S1[i+1] = '0';
					count1++;
				}
			}else{
				S1[i] = '1';
				count1++;
			}
		}
	}

	S2 = S;
	// 1 first
	for(int i = 0; i < S2.size()-1; ++i){
		if(i%2 == 0){
			if(S2[i] == '1'){
				if(S2[i+1] == '1'){
					S2[i+1] = '0';
					count2++;
				}
			}else{
				S2[i] = '1';
				count2++;
			}
		}else{
			if(S2[i] == '0'){
				if(S2[i+1] == '0'){
					S2[i+1] = '1';
					count2++;
				}
			}else{
				S2[i] = '0';
				count2++;
			}
		}
	}

	cout << min(count1, count2) << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>

#include <fstream>

#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#include <algorithm>
#include <iomanip>
#include <cmath>
#include <random>
#include <cstdlib>
#include <ctime>
#include <utility>

using namespace std;

ifstream in("input.txt");
ofstream out("output.txt");

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define F first
#define S second
#define forcin(n, a) for(int i = 0; i < n; ++i) {cin >> a[i];}
#define forcout(n, a) for(int i = 0; i < n; ++i) {cout << a[i] << " ";}
#define PI acos(-1)
#define forup(st, fin) for(int i = st; i < fin; ++i)
#define fordown(st, fin) for(int i = st; i >= fin; --i)
#define reverse_all(v) reverse(v.begin(), v.end())
#define sort_all(v) sort(v.begin(), v.end())
#define sort_allr(v) sort(v.rbegin(), v.rend())

///#define cin in
///#define cout out
///#define int long long

const ll MAXL = 1e18;
const int N = 10005000;
const int MAXN = 1e9 + 7;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    int n;
    cin >> n;
    if (n < 1000) {
        cout << "ABC\n";
    } else {
        cout << "ABD\n";
    }
    return 0;
}

/*

 */

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

int main() {
  string S;
  cin >> S;
  
  bool ans = false;
  for (int i = 0; i < S.size(); i++) {
    for (int j = i; j < S.size(); j++) {
      string sub = S.substr(0, i) + S.substr(j);
      if (sub == "keyence") {
        ans = true;
        break;
      }
    }
  }

  cout << (ans ? "YES" : "NO") << endl;
}

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

int main(){
  int k;
  int list[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> k;
  cout << list[k - 1] << endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            string sA = System.Console.ReadLine().Trim();
            string sB = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<string> sC = new List<string>() { "1", "2", "3"};
            sC.Remove(sA);
            sC.Remove(sB);

            // 出力
            System.Console.WriteLine("{0}", sC[0].ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13152
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
#include<deque>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define sint(n) scanf("%d",&n)
#define sintt(n,m) scanf("%d%d",&n,&m)
#define sinttt(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define MAX 1000000000
#define end(a,b) if(a==b)break;

using namespace std;

deque<int> kazu;

void saiki(int n,int am){
	
	if(am==0){
		int mini=MAX;
		int flg=1;
		rep(i,kazu.size()){
			if(mini<kazu[i]){
				flg=0;break;
			}
			mini=kazu[i];
		}
		if(flg==1){
			rep(i,kazu.size()-1){
				printf("%d ",kazu[i]);
			}printf("%d\n",kazu[kazu.size()-1]);
		}
		return;
	}
	
	int mino=am;
	if(kazu.size()>0){
		mino=min(am,kazu[kazu.size()-1]);
	}
	for(int i=mino-1;i>=0;i--){
		kazu.push_back(i+1);
		saiki(i+1,am-(i+1));
		kazu.pop_back();
	}
}

int main(){
	
	while(1){
		int n;
		sint(n);
		end(n,0);
		saiki(0,n);
	}
}

Measured memory_bytes: 0
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define in inline
#define reg register
#define int long long
#define MAX 20030813
using namespace std;
namespace qwq{
	in void read(int &o) {
		o=0;
		int w=1;
		char c=getchar();
		while(c<'0'||c>'9') {
			if(c=='-')w*=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9') {
			o=(o<<3)+(o<<1)+(c^48);c=getchar();
		}
		o*=w;
	}
	void write(int x){
	   	if(x<0)putchar('-'),x=-x;
    	if(x>9)write(x/10);
		putchar(x%10+48);
	}
	void Write(int x) {
		write(x);putchar(' ');
	}
	in int max(int x,int y){return x>y?x:y;}
	in int min(int x,int y){return x<y?x:y;}
}
using namespace qwq;

string s;
int k,num=0,ans=0,last=0;
int vis=0,viss=0,check=0;

signed main(){
	cin>>s>>k;
	if(s.length()==1){
		cout<<k/2<<endl;
		return 0;
	}	
	for(int i=0;i<s.length();i++){
		if(s[i]==s[0]) vis++;
		else break;
	}
	if(vis==s.length()){
		cout<<(k*s.length())/2;
		return 0;
	}
	for(int i=s.length()-1;i>=0;i--){
		if(s[i]==s[s.length()-1]) viss++;
		else break;
	}
	for(int i=0;i<s.length()-1;i++){
		if(s[i]==s[i+1])s[i+1]='-',num++;
	}
	if(s[0]==s[s.length()-1]){
		last=1;
		if((vis+viss)%2==1) check=1;
	}
	if(check){
		cout<<num*k<<endl;
		return 0;
	}
	else ans=(num*k+last*(k-1));
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

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

    string ans = "";
    for(char c='a'; c<='z'; c++){
        int cnt = 100;
        for(int i=0; i<N; i++){
            int tmp = 0;
            for(int j=0; j<s[i].size(); j++) if(s[i][j] == c) tmp++;
            cnt = min(cnt, tmp);
        }
        for(int i=0; i<cnt; i++) ans += c;
    }

    cout << ans << endl;

}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


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

	
	if(s[2]==s[3] && s[4]==s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;




}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int a[50];
signed main() {
  int N, P;
  while (cin>>N>>P, N+P!=0) {
    for (int i = 0; i < N; i++) a[i] = 0;
    int q = P;
    int i = -1;
    while (a[i] != P) { 
      i++;
      if (i >= N) i=0;
      if (q == 0) {
        q += a[i];
        a[i] = 0;
      } else {
        q--;
        a[i]++;
      }
    }
    cout << i << endl;
  }
}



Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;cin>>N;
    int ans,maximum,minmum=0;
    vector<int> A(N);
    maximum=0;
    minmum=10e9;

    for(int i=0;i<=N-1;i++){
        cin>>A[i];
        maximum= max(maximum,A[i]);
        minmum=min(minmum,A[i]);
    }

    ans=maximum-minmum;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import fractions

N = int(input())
A = list(map(int, input().split()))
L = [0] * (N+1)
R = [0] * (N+2)
M = [0] * (N+1)

for i in range(1, N+1):
  L[i] = fractions.gcd(L[i-1], A[i-1])
  R[N-i+1] = fractions.gcd(R[N-i+2], A[N-i])

for i in range(1, N+1):
  M[i] = fractions.gcd(L[i-1], R[i+1])
print(max(M[1:]))
    


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

string s;

bool check(int erase){
  int n=s.size();
  rep(i,(n-erase)/2){
    if(s.at(i)!=s.at(i+(n-erase)/2)) return false;
  }
  return true;
}

int main(){
  
  cin >> s;
  bool notfound=true;
  int erase=0;
  while(notfound){
    erase+=2;
    if(check(erase)) notfound=false;
  }

  cout << s.size()-erase;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int gcd(int a, int b){
	int c=min(a,b), d=max(a,b);
	return d%c==0 ? c : gcd(c,d%c);
}

int main(){
	int a,b,k; cin>>a>>b>>k;
	int g=gcd(a,b);
	vector<int> div;
	double d;
	for(int i=1; i<=g; i++){
		d=g/i;
		if(g == d*i){ div.push_back(i); }
	}

	cout<<div[div.size()-k]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long i,j,n,a,b,c,k;
int main()
{
  cin>>k;
  for(a=1;a<=k;a++){
    for(b=1;b<=k;b++){
      for(c=1;c<=k;c++)i=__gcd(a,b),j+=__gcd(c,i);
    }
  }
  cout<<j<<endl;
}

Measured memory_bytes: 3636
x,n = map(int,input().split())
p = list(map(int,input().split()))
now = 99999
ans = -200
ls = [(i+1) for i in range(-1000,1001)]
for i in range(len(p)):
    ls.remove(p[i])
k = []
for i in range(len(ls)):
    if abs(ls[i]-x) < now:
        now = abs(ls[i]-x)
        ans = ls[i]
print(ans)

Measured memory_bytes: 9220
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

A.sort()
table = [0 for i in range(10**6 + 1)] # 約数のテーブル

cc = collections.Counter(A)


cnt = 0
for a in A:
    if table[a] == 0:
        for i in range(10 ** 6):
            if a * i > 10 ** 6:
                break
            table[a * i] = 1
        if cc[a] == 1:
            cnt += 1


print(cnt)
    

Measured memory_bytes: 45976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC142A
{
    class Program
    {
        static void Main(string[] args)
        {
            double n = double.Parse(Console.ReadLine());
            if (n % 2 == 0)
            {
                Console.WriteLine((n / 2) / n);
            }
            else
            {
                Console.WriteLine(((n - 1) / 2 + 1) / n);
            }
        }
    }
}


Measured memory_bytes: 13140