akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using vv = vector<V<T>>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int h,w;
  cin >> h >> w;
  vector<string> mp(h);
  REP(i,h) cin >> mp[i];
  vvl dp(h,vl(w,0));
  dp[0][0] = 1;
  REP(i,w){
    if(mp[0][i]=='#') break;
    dp[0][i] = 1;
  }
  REP(i,h){
    if(mp[i][0]=='#') break;
    dp[i][0] = 1;
  }
  REP(i,h-1){
    REP(j,w-1){
      if(mp[i+1][j+1]=='#') continue;
      dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%MOD;
    }
  }
  cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>
 
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cassert>
 
using namespace std;
 
#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)
 
#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll mod = 1e9+7;

int main() {
	int N;
	string s[2];
	cin >> N;
	cin >> s[0] >> s[1];

	int i = 0;
	ll res = 1;

	if(s[0][i] == s[1][i]) {
		res = res * 3 % mod;
		i += 1;
	}
	else {
		res = res * 6 % mod;
		i += 2;
	}

	for(; i < N;) {
		if(s[0][i] == s[1][i]) {
			if(s[0][i-1] == s[1][i-1]) {
				res = res * 2 % mod;
			}
			else {
				res = res % mod;
			}
			i += 1;
		}
		else {
			if(s[0][i-1] == s[1][i-1]) {
				res = res * 2 % mod;
			}
			else {
				res = res * 3 % mod;
			}
			i += 2;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct point{
	int x;
	int y;
	int used;
}R[105],B[105];
bool cmp(point a,point b)
{
    return a.x<b.x;
}
int main()
{
	int n;
	int a,b;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d %d",&R[i].x,&R[i].y);
	for(int i=0;i<n;i++)
		scanf("%d %d",&B[i].x,&B[i].y); 
	sort(B,B+n,cmp);
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		int miny=200;
		int y=-1;
		for(int j=0;j<n;j++)
		{
			if(B[i].x>R[j].x&&B[i].y>R[j].y&&R[j].used==0)
			{
				if(B[i].y-R[j].y<miny)
				     {
				     	miny=(B[i].y-R[j].y);
				     	y=j;
					 }
			}
			
		}
		R[y].used=1;
		if(y!=-1) cnt++;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
n = int(input())
*h, = map(int, input().split())

dp = [float('inf')] * n

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

print(dp[n-1])

Measured memory_bytes: 13980
#include<stdio.h>
int main(){
	int count;
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF){
		count=0;
		a+=b;
		while(a){
			a/=10;
			count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 600
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= printRes . solve
    where
        printRes = putStrLn . unwords . map show 

solve :: [Int] -> [Int]
solve [n, a, b] = [maxv, minv]
    where
        maxv = min a b
        minv = max 0 $ a + b - n

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
import sys
sys.setrecursionlimit(100000)

def unite(i, j):
    j = get_par(j)
    par[j] = get_par(i)
    return

def get_par(p):
    if par[p] is None:
        return p
    par[p] = get_par(par[p])
    return par[p]

N = int(input())
points = []
edges = []
for i in range(N):
    x,y = map(int, input().split())
    points.append([x,y,i])
points.sort()
for i in range(N-1):
    edges.append((abs(points[i][0] - points[i+1][0]), points[i][2], points[i+1][2]))
points.sort(key=lambda x:x[1])
for i in range(N-1):
    edges.append((abs(points[i][1] - points[i+1][1]), points[i][2], points[i+1][2]))
edges.sort(key=lambda x:x[0], reverse=True)

par = [None] * N
cost = 0
count = 0
points.sort()
while count < N - 1:
    c, i, j = edges.pop()
    if get_par(i) == get_par(j):
        continue
    unite(i, j)
    cost += c
    count += 1
print(cost)


Measured memory_bytes: 48708
struct Point {
    x: f64,
    y: f64,
}

impl Point {
    fn toStr(&self) -> String {
        format!("{:.8} {:.8}", self.x, self.y)
    }
}


fn main(){
    let n = readInt();
    let a = Point { x: 0.0,   y: 0.0 };
    let b = Point { x: 100.0, y: 0.0 };
    
    println!("{}", a.toStr());
    koch(n, &a, &b);
    println!("{}", b.toStr());
}

fn readInt() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn koch(depth: i32, p1: &Point, p2: &Point) {
    let r = std::f64::consts::PI / 3.0;
    let si = r.sin();
    let co = r.cos();

    if depth == 0 {
        return;
    } else {
        let d = depth - 1;
        let s = Point{ x: (2.0 * p1.x + p2.x) / 3.0, y: (2.0 * p1.y + p2.y) / 3.0 }; 
        let t = Point{ x: (p1.x + 2.0 * p2.x) / 3.0, y: (p1.y + 2.0 * p2.y) / 3.0 };
        let u = Point{
            x: (t.x - s.x) * co - (t.y - s.y) * si + s.x,
            y: (t.x - s.x) * si + (t.y - s.y) * co + s.y
        };
        koch(d, &p1, &s);
        println!("{}", s.toStr());
        koch(d, &s, &u);
        println!("{}", u.toStr());
        koch(d, &u, &t);
        println!("{}", t.toStr());
        koch(d, &t, &p2);
    }
}


Measured memory_bytes: 5056
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) < abs(x - b)){
        cout << "A" << endl;
    }
    else {
        cout << "B" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
alf = []
while 0 < N:
    if N % 26 ==0:#Z
        alf.append('z')
        N = N//26-1
    else:
        alf.append(chr((N % 26)+96))
        N = N//26
alf.reverse()
alf = ''.join(alf)
print(alf)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar('\n')
#define enter putchar(' ')
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0){putchar('-');x = -x;}
	if(x >= 10) out(x / 10);
	putchar('0' + x % 10);
}
const int MOD = 998244353;
int N,ans;
pii S[MAXN];
int id[2][MAXN];
bool vis[MAXN];
bool cmp1(int a,int b) {
	return S[a].fi < S[b].fi;
}
bool cmp2(int a,int b) {
	return S[a].se < S[b].se;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	read(N);
	for(int i = 1 ; i <= N ; ++i) {
		read(S[i].fi);read(S[i].se);
		id[0][i] = i;id[1][i] = i;
	}
	sort(id[0] + 1,id[0] + N + 1,cmp1);
	sort(id[1] + 1,id[1] + N + 1,cmp2);
	int64 ans = 0;
	memset(vis,0,sizeof(vis));
	int p[2];p[0] = N,p[1] = 1;
	int pos = 0;int64 tmp = 0;
	if(S[id[0][N]].fi > 0) {
		vis[id[0][p[0]]] = 1;--p[0];
	 	tmp += abs(S[id[0][N]].fi - pos);
		pos = S[id[0][N]].fi;
		int cur = 1;
		while(1) {
			if(cur == 1) {
				while(p[cur] <= N && vis[id[cur][p[cur]]]) ++p[cur];
				if(p[cur] > N) break;
				if(S[id[cur][p[cur]]].se >= pos) break;
				tmp += abs(S[id[cur][p[cur]]].se - pos);
				pos = S[id[cur][p[cur]]].se;
				vis[id[cur][p[cur]]] = 1;
			}
			else {
				while(p[cur] >= 1 && vis[id[cur][p[cur]]]) --p[cur];
				if(p[cur] < 1) break;
				if(S[id[cur][p[cur]]].fi <= pos) break;
				tmp += abs(S[id[cur][p[cur]]].fi - pos);
				pos = S[id[cur][p[cur]]].fi;
				vis[id[cur][p[cur]]] = 1;
			}
			cur ^= 1;
		}
		tmp += abs(pos);
	}
	ans = max(ans,tmp);
	memset(vis,0,sizeof(vis));
	pos = 0;tmp = 0;p[0] = N;p[1] = 1;
	if(S[id[1][1]].se < 0) {
		vis[id[1][1]] = 1;++p[1];
		tmp += abs(S[id[1][1]].se - pos);
		pos = S[id[1][1]].se;
		int cur = 0;
		while(1) {
			if(cur == 1) {
				while(p[cur] <= N && vis[id[cur][p[cur]]]) ++p[cur];
				if(p[cur] > N) break;
				if(S[id[cur][p[cur]]].se >= pos) break;
				tmp += abs(S[id[cur][p[cur]]].se - pos);
				pos = S[id[cur][p[cur]]].se;
				vis[id[cur][p[cur]]] = 1;
			}
			else {
				while(p[cur] >= 1 && vis[id[cur][p[cur]]]) --p[cur];
				if(p[cur] < 1) break;
				if(S[id[cur][p[cur]]].fi <= pos) break;
				tmp += abs(S[id[cur][p[cur]]].fi - pos);
				pos = S[id[cur][p[cur]]].fi;
				vis[id[cur][p[cur]]] = 1;
			}
			cur ^= 1;
		}
		tmp += abs(pos);
	}
	ans = max(ans,tmp);
	out(ans);enter;
}


Measured memory_bytes: 1920
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n = readline() |> parseInt

  ans=any(n==i*j for i in 1:9, j in 1:9)
  println(ans ? "Yes" : "No")
end

main()


Measured memory_bytes: 123180
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		int ans = 0;
		for(int i= 0; i <= n; i++) {
			for(int j = 0; j <= n; j++) {
				int tmp = n - i*r - j*g;
				if(tmp >= 0 && tmp % b == 0) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 23252
#include<cstdio>
#include<algorithm>
using namespace std;
int N,ans=2e9,zj,w,e,W[300005],E[300005];
char S[300005];
int main()
{
	scanf("%d %s",&N,S);
	for(int i=0;i<N;i++)
	{
		if(S[i]=='W')
		w++;
		else
		e++;
		W[i+1]=w;
		E[i+1]=e;
	}
	for(int i=1;i<=N;i++)
	ans=min(W[i-1]+E[N]-E[i],ans);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>
 
int main(void)
{
 
  int a, b, c, tmp;
 
  scanf("%d%d", &a, &b);
 
 
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  
  c = a % b;
  while(c!=0){
    a = b;
    b = c;
    c = a % b;
  }
 
  
  printf("%d\n", b);
 
  return 0;
}

Measured memory_bytes: 592
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToList();
        var grouped = a.GroupBy(x => x).OrderBy(x => x.Key).ToArray();
        if (grouped.Length >= 3) goto end;
        if (grouped.Length == 2)
        {
            if (grouped[1].Key - grouped[0].Key != 1) goto end;
            int single = grouped[0].Count();
            int many = grouped[1].Count();
            int max = many / 2 + single;
            int min = 1 + single;
            if (grouped[1].Key < min || max < grouped[1].Key) goto end;
        }
        if(grouped.Length == 1)
        {
            int count = grouped[0].Count();
            int max = count / 2;
            int min = 1;
            if (grouped[0].Key != count - 1 && (grouped[0].Key < min || max < grouped[0].Key)) goto end;
        }

        Console.WriteLine("Yes");
        return;
        end:Console.WriteLine("No");
    }
}


Measured memory_bytes: 38020
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) begin(v), end(v)
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,b) FOR(i,0,b)


int n,size[100010],t[100010],temp,ans;
signed main(){
  cin>>n;
  rep(i,n)cin>>size[i];

  sort(size,size+n);

  //累積和x2の配列t[]を作る
  for(int i=0;i<n;i++){
    temp+=size[i];
    t[i]=temp*2;
  }

  //rep(i,n)cout<<t[i]<<" ";

  //cout<<endl;

  //n-1番目は最大値なので考えなくて良い
  for(int i=n-2;i>=0;i--){
    if(t[i]>=size[i+1])ans++;
    else break;
  }

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


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

typedef long long ll;

int MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    if(N%2==0) cout << N/2 << endl;
    else cout << N/2+1 << endl;
}

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

int main() {
	int N, M;
	cin >> N >> M;

	vector<long int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	vector<int> A(M);
	vector<int> B(M);

	for (int i = 0; i < M; i++) {
		cin >> A[i];
		cin >> B[i];
	}

	int output = 0;

	vector<vector<int>> graph(N + 1);
	for (int i = 0; i < M; i++) {
		graph[A[i]].push_back(B[i]);
		graph[B[i]].push_back(A[i]);
	}

	// for (int i = 1; i < N + 1; i++) {
	// 	cout << i << ":";
	// 	for (int j = 0; j < graph[i].size(); j++) {
	// 		cout << graph[i][j];
	// 	}
	// 	cout << endl;
	// }

	for (int i = 1; i < N + 1; i++) {
		bool highest = true;
		for (int j = 0; j < graph[i].size(); j++) {
			if (H[i - 1] <= H[graph[i][j] - 1]) {
				highest = false;
			}
		}
		if (highest) {
			// cout << i << endl;
			output++;
		}
	}

	cout << output << endl;

	return 0;
}

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

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

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

int main(){
	string s,t;
	cin>>s>>t;
	vector<vector<int > > dp(s.length()+1,vector<int>(t.length()+1,0));
	
	
	for(int i=1;i<=s.length();i++){
		for(int j=1;j<=t.length();j++){
			if(s[i-1]==t[j-1]){
				
				 dp[i][j] = dp[i-1][j-1] + 1;
			 }
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	//cout<<dp[s.length()][t.length()]<<endl;
	string ans="";
	int len = dp[s.length()][t.length()];
	for(int i=s.length();i>0;i--){
		for(int j=t.length();j>0;j--){
			if(dp[i][j]==len && s[i-1]==t[j-1]){
				ans = ans + s[i-1];
				len--;
				break;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
	
	
	
}


Measured memory_bytes: 35584
import sys

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

ans = 0
_find = 1
before = 0

if not 1 in set(a):
    print(-1)
    sys.exit()

for i in range(n):
    if a[i]==_find:
        ans += i-before
        _find += 1
        before = i+1

print(ans+n-before)

Measured memory_bytes: 26148
h,w=map(int,input().split())
s=[input() for i in range(h)]
for i in range(h):
  l=""
  for j in range(w):
    if s[i][j]=="#":
      l+="#"
    else:
      l+=str(sum(t[max(0,j-1):min(w,j+2)].count("#") for t in s[max(0,i-1):min(h,i+2)]))
  print(l)

Measured memory_bytes: 3316
import java.io.*;

class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		int x,y,tmp;

		do{
			String str=br.readLine();
			String[] num=str.split(" ");
			x=Integer.parseInt(num[0]);
			y=Integer.parseInt(num[1]);
			if(x>y){
				tmp=x;
				x=y;
				y=tmp;
			}
			if(x==0&&y==0){
				break;
			}
			sb.append(x).append(" ").append(y).append("\n");
		}while(x!=0||y!=0);
		System.out.print(sb);
	}
}

Measured memory_bytes: 26292
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	
	static int r,c;
	public static void main(String[] __){
		while(true){
			c=s.nextInt();
			r=s.nextInt();
			if(r+c==0) return;
			s.nextLine();
			char[][] f=REPS(r).mapToObj(v->s.nextLine().replaceAll(" ","").toCharArray()).toArray(char[][]::new);
			//Arrays.stream(f).map(String::valueOf).forEach(System.out::println);
			ArrayDeque<Point> deque=new ArrayDeque<>();
			int res=0;
			for(int i=0;i<r;i++) for(int j=0;j<c;j++) {
				if(f[i][j]=='1') {
					f[i][j]='0';
					res++;
					deque.add(new Point(i,j));
					while(!deque.isEmpty()){
						Point poll=deque.pollFirst();
						for(int d=0;d<dr.length;d++) {
							Point p=(Point)poll.clone();
							p.translate(dr[d],dc[d]);
							if(ranged(p)&&f[p.x][p.y]=='1') {
								f[p.x][p.y]='0';
								deque.add(p);
							}
						}
					}
				}
			}
			System.out.println(res);
		}
	}
	static int[] dr={0,1,1,1,0,-1,-1,-1},dc={-1,-1,0,1,1,1,0,-1};
	static boolean ranged(Point p){
		return 0<=p.x&&p.x<r&&0<=p.y&&p.y<c;
	}
}

Measured memory_bytes: 40120
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int Y, X;
    cin >> Y >> X;
    vector<vector<char>> maze(Y, vector<char>(X));
    rep(i, Y) {
        rep(j, X) { cin >> maze[i][j]; }
    }

    int sy, sx, gy, gx;
    int res = 0;
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    rep(i, Y) {
        rep(j, X) {
            if (maze[i][j] == '.')
                sy = i, sx = j;
            rep(l, Y) {
                rep(k, X) {
                    if (maze[l][k] == '.') {
                        gy = l, gx = k;
                        queue<pair<int, int>> que;
                        vector<vector<int>> dist(Y, vector<int>(X, -1));
                        dist[sy][sx] = 0;
                        que.push({sy, sx});
                        while (!que.empty()) {
                            pair<int, int> now = que.front();
                            que.pop();
                            int y = now.first, x = now.second;
                            for (int i = 0; i < 4; i++) {
                                int ny = y + dy[i];
                                int nx = x + dx[i];
                                if (nx < 0 || ny < 0 || nx >= X || ny >= Y)
                                    continue;
                                if (dist[ny][nx] != -1)
                                    continue;
                                if (maze[ny][nx] == '#')
                                    continue;
                                que.push({ny, nx});
                                dist[ny][nx] = dist[y][x] + 1;
                            }
                        }

                        res = max(res, dist[gy][gx]);
                    }
                }
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    ll s; cin >> s;
    vector <ll> ans;
    REP(i, k){
        ans.push_back(s);
    }
    ll pad;
    if (s > 1e6){
        pad = s-1;
    } else {
        pad = 1e9-1;
    }
    REP(i, n-k){
        ans.push_back(pad);
    }
    REP(i, n-1){
        cout << ans[i] <<  " ";
    }
    cout << ans[n-1] << endl;
    return 0;
}

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

int main(){
    int N;
    long long x,count=0;
    cin>>N>>x;
    long long a[N];
    cin>>a[0];
    if(a[0]>x){
        count += a[0] - x;
        a[0] = x;
    }
    for(int i=1;i<N;i++){
        cin>>a[i];
        if(a[i]+a[i-1]>x){
            count += a[i]+a[i-1] - x;
            a[i] -= a[i] + a[i-1] -x;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
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;}
constexpr int INF = 1e18;

signed main(){
	int N,K;
	cin >> N >> K;
	vector<int>a(N);
	REP(i,N){
		cin >> a[i];
	}
	int ans = INF;
	REP(i,1ll << N){
		if(__builtin_popcountll(i) != K)continue;
		int now = 0;
		int cost = 0;
		REP(j,N){
			if(i & (1ll << j)){
				cost += max(0ll,now - a[j] + 1);
				now = max(a[j],now + 1);
			}else{
				if(now >= a[j])continue;
				cost += a[j] - now;
				now = max(now,a[j]);
			}
		}
		CHMIN(ans,cost);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(){
	int sum=0;
	int tem;
	int m,s;
		for(int i=0;i<4;i++)
			cin >>tem,sum+=tem;
	m=sum/60;
	s=sum%60;
	cout << m << endl << s << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a*b) < c){
        cout<<(a*b);
    }
    else{
        cout<<c;
    }
    return 0;
}


Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    A = lmis()
    g = 0
    for a in A:
        g ^= a
    for a in A:
        print(g^a)



main()



Measured memory_bytes: 32292
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    if (n>=b){
        
        a*=(b-1);
        a/=b;
        cout << a << endl;
        return 0;
    }
    a*=n;
    a/=b;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3628
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    fun factorial(number: Int): Long {
        if (number < 2) return 0.toLong()
        if (number == 2) return 1.toLong()
        if (number == 3) return 3.toLong()

        var molecule = 1.toLong()

        for (i in number - 1..number) {
            molecule *= i
        }

        return molecule / 2.toLong()
    }
    println(factorial(n) + factorial(m))
}


Measured memory_bytes: 38312
using System;
using System.Collections.Generic;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);
            int k = int.Parse(In[1]);
            string[] In2 = Console.ReadLine().Split(' ');
            int[] A = new int[n];
            for(int i = 0; i < n; i++)
            {
                A[i] = int.Parse(In2[i]);
            }
            var SortedA=A.OrderBy(x => x).ToArray();
            int sum = 0;
            for(int i = 0; i < k; i++)
            {
                sum += SortedA[i];
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 28572
from collections import Counter

def ngram(text, n):
    return [text[i:i+n] for i in range(len(text) - n + 1)]

text = input()
k = int(input())
candidates = set()
for n in range(1,6):
    #_ = filter(lambda x:x[1] == 1,Counter(ngram(text,n)).items())
    candidates |= set(ngram(text,n))

print(sorted(list(candidates))[k-1])

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n;
    string s;
    cin >> n >> s;
    ll ans = 1;
    REP(i, 1, n) {
        if(s[i] != s[i-1]) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 512
W, H, N = map(int, input().split())

left = 0
right = W
top = 0
bottom = H

for _ in range(N):
    xi, yi, ai = map(int, input().split())
    if ai == 1:
        left = max(left, xi)
    elif ai == 2:
        right = min(right, xi)
    elif ai == 3:
        top = max(top, yi)
    elif ai == 4:
        bottom = min(bottom, yi)

        
ans = (bottom - top) * (right - left) if bottom > top and right > left else 0
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#define h 10000
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll int n, k, x, y, cnt=0,i;
	cin>>n>>k;
	for(i=0;i<n;i++) 
	{
		cin>>x>>y;
		if(sqrt((pow(x,2)+pow(y,2))*1.0)<=(k*1.0))
		cnt+=1; 
	} 
	cout<<cnt<<endl;
  return 0;
} 



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

int main() {
  int A, B,C,D;
  int R,L;
  cin >> A >> B >>C >>D;

  L=A+B;
  R=C+D;
  if (R > L) 
    cout << "Right" << endl;
  else if (R<L)
    cout<<"Left"<<endl;
  else
    cout<<"Balanced"<<endl;
}

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

#define debug_input freopen("stdin.in", "r", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORALL(i, n) for(int i = 0; i < n; i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)
#define SORT(a) sort(a.begin(), a.end())
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())
#define ALL(a) a.begin, a.end()
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
	return 0;
}

Measured memory_bytes: 3652
def water(h):
    x = min(h)
    for i in range(0,len(h)):
        h[i] -= x
        if h[i] == 0:
            p = i
    
    if h == [0]*len(h):
        return x
    elif p == len(h) - 1:
        return x + water(h[:len(h)-1])
    elif p == 0:
        return x + water(h[1:])
    else:
        return x + water(h[0:p]) + water(h[p+1:])

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

print(water(h))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
import math

def combinations_count(s, r):
    return math.factorial(s) // (math.factorial(s - r) * math.factorial(r))


result = 0
if n > 1:
    result += combinations_count(n, 2)
if m > 1:
    result += combinations_count(m, 2)

print(result)


Measured memory_bytes: 38384
"use strict"
const tan = (x) => { return Math.tan(x); }
function main(arg) {
    let [A,B,H,M] = arg.trim().split("\n")[0].split(" ").map(Number)
    const aTh = (H + M / 60) * 360 / 12
    const bTh = M * 360 / 60
    let th = Math.abs(aTh - bTh)
    // console.log(th)
    // th = 120
    console.log(solve(A,B,th))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function solve(a, b, th) {
    let c2 = Math.pow(a ,2) + Math.pow(b ,2) - 2 * a * b * Math.cos(th * (Math.PI / 180))
    return Math.sqrt(c2)
}

Measured memory_bytes: 29896
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n, a, b;
    while(cin>>n>>a>>b){
    	if(b/n-(a-1)/n>0){
    		cout<<"OK"<<endl;
    	}
    	else{
    		cout<<"NG"<<endl;
    	}
    }
  return 0;
}




Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Point { internal double x, y; }

    class Program
    {
        static void Main(string[] args)
        {
            List<Point> points = new List<Point>();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(',');

                Point p;
                p.x = double.Parse(temp[0]);
                p.y = double.Parse(temp[1]);
                points.Add(p);
            }
            Console.WriteLine(Area(points));
        }

        static double Area(List<Point> ps)
        {
            double area = 0.0;

            for (int i = 0; i < ps.Count; i++)
            {
                area += Cross(ps[i], ps[(i + 1) % ps.Count]);
            }
            return Math.Abs(area / 2);
        }

        static double Cross(Point a, Point b)
        {
            return a.x * b.y - a.y * b.x;
        }
    }
}

Measured memory_bytes: 9220
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  string s;
  cin >> s;
  string t = "keyence";
  
  for (int i = 0; i <= 7; i++) {
    bool flag = false;
    string u = t.substr(0, i);
    string v = t.substr(i, 7-i);
    if (s.substr(0, i) == u) {
      flag = true;
    }
    if (s.substr(s.size() - (7-i), 7-i) == v && flag) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int64 n,k; cin >> n >> k;
		int64 r = n - k;
		int64 nk = k;
		COMinit();
		for (int i = 1; i <= k; ++i) {
			int64 p = COM(n - k + 1, i);
			int64 q = COM(k - 1, i - 1);
			cout << (p * q) % MOD << endl;
		}
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

ll f(ll x) {
  ll res = 0;
  res = ((x + 1) / 2) % 2;
  if(x % 2 == 0) res ^= x;
  return res;
}

ll f2(ll x) {
  if(x < 0) return 0;
  ll res = 0;
  int keta = 0;
  while(x >> keta) {
    ll loop = (1LL << (keta + 1));
    ll cnt = ((x + 1) / loop) * (loop / 2);
    cnt += max(0LL, ((x + 1) % loop) - (loop / 2));
    if(cnt % 2 == 1) res += (1LL << keta);
    keta++;
  }
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (f2(b) ^ f2(a - 1)) << endl;
  //  cout << (f(b) ^ f(a - 1)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100
#define INF 0x3FFFFFFF
using namespace std;
int a[MAXN+5];
int main()
{
	int n,mn=INF,mx=-INF;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mn=min(mn,a[i]);
		mx=max(mx,a[i]);
	}
	int ans=INF;
	for(int val=mn;val<=mx;val++)
	{
		int tot=0;
		for(int i=1;i<=n;i++)
			tot+=(a[i]-val)*(a[i]-val);
		ans=min(tot,ans);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;

namespace AtCoder0106_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int a = int.Parse(input);
            List<string> list = new List<string>();

            for (int i = 0; i < a; i++)
            {
                string x = Console.ReadLine();
                if (Array.IndexOf(list.ToArray(), x) == -1)
                {
                    list.Add(x);
                }
            }
            Console.WriteLine(list.Count);
        }
    }
}

Measured memory_bytes: 13024
#include<stdio.h>
int main()
{
int n, i, a[2][100]={0}, lsum=0, rsum=0, max=0;
scanf("%d", &n);
for(i = 0; i < n; i++){
scanf("%d", &a[0][i]);
}
for(i = 0; i < n; i++){
scanf("%d", &a[1][i]);
rsum += a[1][i];
}
for(i = 0; i < n; i++){
lsum += a[0][i];
if((lsum + rsum) > max){
max = lsum + rsum;
}
rsum -= a[1][i];
}
printf("%d\n", max);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a,b;
  cin>>a>>b;

  if(a > 8 || b > 8) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

instr = input()
target = int(input())

# 部分文字列の一覧リストを作成
str_list = []
for i in range(len(instr)):

	# 開始位置はi+1以降(i > jはやる意味ない)
	for j in range(i+1, len(instr)+1):
		
		# targetよりも大きい文字数のものは処理しない
		if j-i > target:
			break

		# 候補となる部分文字列の格納
		str_list.append(instr[i:j])

# 重複削除
str_list = list(set(str_list))
# 昇順ソート
str_list.sort()

print(str_list[target-1])

Measured memory_bytes: 5068
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	int tasty = min(b, c);
	b -= tasty;
	c -= tasty;
	if (b) {
		cout << 2 * tasty + b << "\n";
	}
	else if (c) {
		if (c > a) {
			cout << 2 * tasty + min(a, c) + 1 << "\n";
		} else {
			cout << 2 * tasty + min(a, c) << "\n";
		}
	} else {
		cout << 2 * tasty << "\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
// 繰り返し二乗法
ll pow_mod(ll n,ll k,ll m){
  ll res=1;
  for(;k>0;k>>=1){
    if(k&1){
      res=(res*n)%m;
    }
    n=(n*n)%m;  
  }
  return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin >> n >> k;
    ll ans=0;
    vector<ll> a(k+1);
    for(ll i=k;i>=1;i--){
        ll num=k/i;
        a[i]=pow_mod(num,n,mod);
        for(ll j=2;j*i<=k;j++){
            a[i]=(a[i]-a[j*i]+mod)%mod;
        }
    }
    for(ll i=1;i<=k;i++){
        (ans+=i*a[i]%mod)%=mod;
    }
    cout << ans << endl;
}

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

int main(void){
    // Your code here!
    long long n;
    
    cin >> n;
    
    if(n < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    int a;
    int b;
    Scanner sc = new Scanner(System.in);
    
       
   	 a = sc.nextInt();
   	 b = sc.nextInt();
     System.out.println((b-a) * (b - a + 1) / 2 - b);
  }
}


Measured memory_bytes: 23892
#include<cstdio>
#define mod 998244353
using namespace std;

long calc(long x){
    long powx[30],pow2[30],ans=1;
    pow2[0]=1;
    powx[0]=x;
    ans=x;
    for(int i=1;i<30;i++){
        pow2[i]=pow2[i-1]*2;
        powx[i]=powx[i-1]*powx[i-1];
        powx[i]%=mod;
        if((mod-2)&pow2[i]){
            ans*=powx[i];
            ans%=mod;
        }
    }
    return ans;
}

long kai[300001],inv[300001];
int main(){
    long n,a,b,k,ans=0,x;
    kai[0]=inv[0]=1;
    scanf("%ld %ld %ld %ld",&n,&a,&b,&k);
    for(long i=1;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod;
    }
    inv[n]=calc(kai[n]);
    for(long i=n-1;i>=1;i--){
        inv[i]=inv[i+1]*(i+1);
        inv[i]%=mod;
    }
    for(long i=0;i<=n;i++){
        if((k-a*i)%b==0&&(k-a*i)/b>=0&&(k-a*i)/b<=n){
            x=kai[n];
            x*=inv[n-i];
            x%=mod;
            x*=inv[i];
            x%=mod;
            x*=kai[n];
            x%=mod;
            x*=inv[n-(k-a*i)/b];
            x%=mod;
            x*=inv[(k-a*i)/b];
            x%=mod;
            ans+=x;
            ans%=mod;
        }
    }
    printf("%ld\n",ans);
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    n %= 500;
    if(n <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

B = [abs(A[i]) if i == 0 else abs(A[i]-A[i-1]) for i in range(N)]
B.append(abs(A[N-1]))

C = [abs(A[1]) if i == 0 else abs(A[i+1]-A[i-1]) for i in range(N-1)]
C.append(abs(A[-2]))

S = sum(B)

for i in range(N):
    print(S-B[i]-B[i+1]+C[i])

Measured memory_bytes: 16152
N = int(input())
a = [0] + [int(input()) for i in range(N)]

import sys

bottom = [-1]*(N+1)
tmp = 1
point = 0

while bottom[tmp] == -1:
    bottom[tmp] = 0
    tmp = a[tmp]
    point += 1
    if tmp == 2:
        print(point)
        sys.exit()
print(-1)    

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

using namespace std;

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

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

    sort(a.begin(),a.end());

    int ans=0;
    for(int i=0;i<k;i++) ans+=a[i];

    cout << ans << endl;
}

Measured memory_bytes: 3624