akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

let (w,h,n) = ParseInt3 <| Console.ReadLine()
ReadLinesN n
|> Seq.map ParseInt3
|> Seq.fold (fun (l,b,r,t) (x,y,a) ->  match a with
                                        | 1 -> (max x l,b,r,t)
                                        | 2 -> (l,b, min x r,t)
                                        | 3 -> (l,max b y,r,t)
                                        | _ -> (l,b,r,min y t)) (0, 0, w, h)
|> (fun (x0,y0,x1,y1) -> if (x0 < x1) && (y0 < y1) then (x1 - x0) * (y1 - y0) else 0)
|> printfn "%A"


Measured memory_bytes: 16348
#include<stdio.h>
#include<algorithm>
using namespace std;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int m[8][8];
int tmp[8][8];
int H,W;
void bfs(int a,int b){
	tmp[a][b]=1;
	for(int i=0;i<4;i++){
		if(a+dx[i]<0||a+dx[i]>=H||b+dy[i]<0||b+dy[i]>=W)continue;
		if(!tmp[a+dx[i]][b+dy[i]])bfs(a+dx[i],b+dy[i]);
	}
}
int tr,tc;
int rem;
int ABS(int a){return max(a,-a);}
int deg[8][8];
int kp[8][8];
int dfs(int a,int b){
	if(ABS(tr-a)+ABS(tc-b)>rem)return 0;
	m[a][b]=1;
	rem--;
	if(rem==0){
		for(int i=0;i<4;i++)if(a+dx[i]==tr&&b+dy[i]==tc)return 1;
		return 0;
	}
	bool yet=true;
	for(int i=0;i<4;i++){
		if(0<=a+dx[i]&&a+dx[i]<H&&0<=b+dy[i]&&b+dy[i]<W&&!m[a+dx[i]][b+dy[i]]){
			deg[a+dx[i]][b+dy[i]]--;
		}
	}
	for(int i=0;i<4;i++){
		if(0<=a+dx[i]&&a+dx[i]<H&&0<=b+dy[i]&&b+dy[i]<W&&!m[a+dx[i]][b+dy[i]]){
			if(!kp[a+dx[i]][b+dy[i]]&&deg[a+dx[i]][b+dy[i]]==1){
				if(dfs(a+dx[i],b+dy[i]))return 1;
				yet=false;break;
			}
		}
	}
	if(yet)
	for(int i=0;i<4;i++){
		if(0<=a+dx[i]&&a+dx[i]<H&&0<=b+dy[i]&&b+dy[i]<W&&!m[a+dx[i]][b+dy[i]]){
			if(dfs(a+dx[i],b+dy[i]))return 1;
		}
	}
	m[a][b]=0;
	rem++;
	for(int i=0;i<4;i++){
		if(0<=a+dx[i]&&a+dx[i]<H&&0<=b+dy[i]&&b+dy[i]<W&&!m[a+dx[i]][b+dy[i]]){
			deg[a+dx[i]][b+dy[i]]++;
		}
	}
	return 0;
}
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a){
		H=a;W=b;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&m[i][j]);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)tmp[i][j]=m[i][j];
		int rk=0;
		int sa=0;
		rem=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)deg[i][j]=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(!m[i][j]){
			for(int k=0;k<4;k++)if(0<=i+dx[k]&&i+dx[k]<a&&0<=j+dy[k]&&j+dy[k]<b&&!m[i+dx[k]][j+dy[k]])deg[i][j]++;
			if((i+j)%2)sa++;
			else sa--;
			rem++;
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(!tmp[i][j]){
				tr=i;tc=j;
				bfs(i,j);
				rk++;
			}
		}
		if(rk!=1||sa){
			printf("No\n");
			continue;
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)kp[i][j]=0;
		for(int i=0;i<4;i++)if(0<=tr+dx[i]&&tr+dx[i]<a&&0<=tc+dy[i]&&tc+dy[i]<b)kp[tr+dx[i]][tc+dy[i]]=1;
		if(dfs(tr,tc))printf("Yes\n");
		else printf("No\n");
	}
}

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

int main() {
  int N;
  cin >> N;
  for (int i=0;i<N;i++){
    string S;
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
   break;
    }
    if (i == N-1) {
      cout << "Three" << endl;
    }
    }
}

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

A = list(map(int, input().split()))
"""
if N == 1:
    if A[0] % M == 0:
        print(1)
        exit()
"""

ans = 0
cum = [0] * N
cum[0] = A[0]

from collections import defaultdict
d = defaultdict(int)

d[cum[0] % M] += 1
for i in range(1,N):
    cum[i] = cum[i-1] + A[i]
    d[cum[i] % M] += 1


from operator import mul
from functools import reduce

def cmb(n,r):
    if n < r:
        return 0
    r = min(n-r,r)
    if r == 0: return 1
    # reduceは第一引数で与えた関数を第二引数のiterbleのそれぞれで実行した結果をもどす
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

ans = 0
d[0] += 1
for i in d.keys():
    #print(i,d[i])
    ans += cmb(d[i], 2)           

print(ans)


Measured memory_bytes: 16324
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    mp::int128_t h,w;
    cin >> h >> w;
    if(h==1 || w==1){
        cout << 1 << endl;
        return 0;
    }
    if(h%2==0 && w%2==0) cout << ((h)/2)*w << endl;
    else if(h%2==0 && w%2==1) cout << ((h)/2)*w << endl;
    else if(h%2==1 && w%2==0) cout << ((w)/2)*h << endl;
    else cout << ((h*w)+1)/2 << endl;
}


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

using namespace std;

int main()
{
  string s1;
  cin>>s1;
  long sum=0;
  for(int i=0;i<s1.size();i++)
  {
      sum+=(s1[i]-'0');
      
  }
  if(sum%9==0)
    cout<<"Yes";
    else
       cout<<"No";
}

Measured memory_bytes: 3700
import collections

N, M = map(int, input().split())

route = {}

for i in range(M):
    A, B = map(int, input().split())

    if not A in route:
        route[A] = [B]
    else:
        route[A].append(B)

    if not B in route:
        route[B] = [A]
    else:
        route[B].append(A)

check = {
    1: 0,
}

queue = collections.deque()
queue.append(1)
result = {}

while queue:
    value = queue.popleft()
    for i in route[value]:
        if not i in check:
            queue.append(i)
            check[i] = check[value] + 1
            result[i] = value

if len(result) == N-1:
    print('Yes')
    for i in range(2, N+1):
        print(result[i])
else:
    print('No')


Measured memory_bytes: 56796
#include <stdio.h>

int main(void)
{
    char s[11];

    int i, len, len_max;

    scanf("%s", s);

    len = 0;
    len_max = 0;
    for(i=0;i<11;i++){
        if(s[i] == 'A'){
            len = len + 1;
        }else if(s[i] == 'C'){
            len = len + 1;
        }else if(s[i] == 'T'){
            len = len + 1;
        }else if(s[i] == 'G'){
            len = len + 1;
        }else{
            len = 0;
        }
        if(len > len_max){
            len_max = len;
        }
    }

    printf("%d", len_max);

    return 0;
}

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

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

  	int a;	
  
    cin >> a;

    string s;
 
  	cin >> s;
  
    if (a>=3200) {
        cout << s;
    } else {
        cout << "red";
    }

    return 0;

}


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

int main(){
    ios::sync_with_stdio(false);
    int n,a,b,ans=100000;
    cin >> n;
    for(int i=1;i<n;i++){
        int sum=0;
        a=i;b=n-i;
        while(a!=0){
            sum+=a%10;
            a/=10;
        }
        while(b!=0){
            sum+=b%10;
            b/=10;
        }
        ans=min(ans,sum);
    }
    cout << ans;
}

Measured memory_bytes: 256
string=input()
serch=input()
new_string=string*2
answer=0
for s in range(len(new_string)):
    if new_string[s]==serch[0]:
        if new_string[s:s+len(serch)]==serch:
            answer+=1
if answer>0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5560
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (int)(a); v < (int)(b); ++v)
#define FORE(v, a, b) for(int v = (int)(a); v <= (int)(b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}

int n;
vector< int > a;

int rec(int x, int y, int i){
	if(i == n) return abs(x - y);
	
	return min(rec(x + a[i], y, i + 1), rec(x, y + a[i], i + 1));
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(cin >> n, n){
		a.RS(n);
		REP(i, n){
			cin >> a[i];
		}
		
		cout << rec(0, 0, 0) << endl;
	}
	
	return 0;
}

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 123;
const int M = 1e6 + 123;
const double pi = 3.14159265359;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

void solve(){
    int x;
    cin >> x;
    cout << 10-x/200;
}

int main(){
    #ifdef KAZAKH
    //    freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
import java.awt.Point;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		InputStream in = System.in;
		Scanner scanner = new Scanner(in);
		LinkedList<String> ans = new LinkedList<String>();
		while(true) {
			int num = scanner.nextInt();
			if(num == 0)
				break;
			LinkedList<Point> data = new LinkedList<Point>();
			// 0番目の四角形
			Point zero = new Point(0, 0);
			data.add(zero);
			for(int i=0; i < num - 1; i++) {
				Point cur = data.get(scanner.nextInt());
				int dir = scanner.nextInt();
				Point tmp = new Point(cur);
				switch (dir) {
				case 0:
					tmp.translate(-1, 0);
					break;
				case 1:
					tmp.translate(0, -1);
					break;
				case 2:
					tmp.translate(1, 0);
					break;
				case 3:
					tmp.translate(0, 1);
					break;
				default:
					break;
				}
				data.add(tmp);
			}
			int minX, minY, maxX, maxY;
			minX = minY = maxX = maxY = 0;
			for(Point val : data) {
				if(val.x < minX)
					minX = val.x;
				if(val.y < minY)
					minY = val.y;
				if(maxX < val.x)
					maxX = val.x;
				if(maxY < val.y)
					maxY = val.y;
			}
			int width = maxX - minX + 1;
			int height = maxY - minY + 1;
			ans.add(width + " " + height);
		}
		for(String val : ans) {
			System.out.println(val);
		}
	}

}

Measured memory_bytes: 35652
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;
#define mp(a, b) make_pair(a, b)

bool cmp(const P& a, const P&b){
  if (a.second == 0 || b.second == 0) return false;
  return a.second < b.second;
}

int main(){
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int a = A%10, b = B%10, c = C%10, d = D%10, e = E%10;
  vector<P> v{mp(A,a), mp(B,b), mp(C,c), mp(D,d), mp(E,e)};
  sort(v.begin(), v.end(), cmp);
  int ans = 0, i = 0;
  for (auto& x : v){
    if (i == 0){
      ans += x.first;
    }else{
      if (x.second == 0) ans += x.first;
      else ans += (x.first/10+1)*10;
    }
    ++i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

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

    string S; cin >> S;
    rep(i,SZ(S)){
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 256
N=int(input())
A=[int(a) for a in input().split()]
S=[0]
for i in range(N):
  S.append(S[-1]+A[i])
S.sort()
last=S[0]
n=1
ans=0
for i in range(1,N+1):
  if S[i]==last:
    n+=1
  else:
    last=S[i]
    ans+=n*(n-1)//2
    n=1
  
ans+=n*(n-1)//2
print(ans)



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

int main() {
  string s;
  cin >> s;
  bool ans = true;
  if (s[2] != s[3]) ans = false;
  if (s[4] != s[5]) ans = false;
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;
typedef long long ll;

struct RollingHash{ //ローリングハッシュ法
private:
    const int mod1 = 1031326447, mod2 = 993766717;
    const int base1 = 281, base2 = 383;
    vector<long long> hash1, hash2, pow1, pow2;
public:
    string str;
    RollingHash(const string& s) : str(s) { //初期化
        int sz = (int)s.size();
        hash1.assign(sz + 1, 0); hash2.assign(sz + 1, 0);
        pow1.assign(sz + 1, 1); pow2.assign(sz + 1, 1);
        for(int i = 0; i < sz; i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    inline pair<long long, long long> get(int l, int r){ //[l, r)
        long long res1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
        long long res2 = ((hash2[r] - hash2[l] * pow2[r - l]) % mod2 + mod2) % mod2;
        return { res1, res2 };
    }
    inline void add_str(const string& s){ //string型を連結
        int ns = (int)str.size(), ms = (int)s.size();
        str += s;
        hash1.resize(ns + ms + 1); hash2.resize(ns + ms + 1);
        pow1.resize(ns + ms + 1); pow2.resize(ns + ms + 1);
        for(int i = ns; i < ns + ms; i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i - ns]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i - ns]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    inline void add_char(const char& c){ //char型を連結
        str += c;
        hash1.push_back((hash1.back() * base1 + c) % mod1);
        hash2.push_back((hash2.back() * base2 + c) % mod2);
        pow1.push_back((pow1.back() * base1) % mod1);
        pow2.push_back((pow2.back() * base2) % mod2);
    }
    inline void add_rh(const RollingHash& rh){ //rhを連結
        add_str(rh.str);
    }
    inline size_t size(){ //strのsizeを返す
        return str.size();
    }
};

int main(){

    int N;
    cin >> N;

    string S;
    cin >> S;
    RollingHash rh(S);

    auto check = [&](int d){
        map<pair<ll, ll>, vector<int>> mp;
        for(int i = 0; i + d <= N; i++){
            mp[rh.get(i, i + d)].push_back(i);
        }
        for(auto v : mp){
            if(v.second.back() - v.second.front() >= d){
                return true;
            }
        }
        return false;
    };

    int l = 0, r = (int)S.size();
    while(r - l > 1){
        int m = (l + r) / 2;
        if(check(m))l = m;
        else r = m;
    }

    cout << l << endl;
    return 0;

}

Measured memory_bytes: 896
N = int(input())
def divisor_all(n): # 約数全列挙
    l = [1,n]
    for i in range(2,int(pow(n,1/2))+1):
        if n % i == 0:
            if i == n//i:
                l.append(i)
            else:
                l.append(i)
                l.append(n//i)
    l.sort()
    return l # list
L = divisor_all(N)
ans = 10**12
for i in range(len(L)):
    ans = min(ans,(L[i]+N//L[i]))
print(ans-2)

Measured memory_bytes: 39280
// AOJ 1211: Trapezoids
// 2017.10.14 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 81000
/* UNION-FIND library */
int p[MAX], rank[MAX];
void make_set(int x) { p[x] = x, rank[x] = 0; }
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

char map[1000][82];
int mk[1000][82], tr[MAX][2];
int sz;
int mv[8][2] = {{-1,-1},{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1}};

int s[500], ss;
int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int h, w, i, r, c, r2, c2, f, t = 0;
	char buf[10];

	while (fgets(buf, sizeof(buf), stdin) && *buf != '0') {
		h = atoi(buf); sz = 0;
		for (w = 0, r = 0; r < h; r++) {
			memset(map[r], 0, 81);
			fgets(map[r], 81, stdin);
			for (c = 0; ; c++) {
				if (map[r][c] < ' ') { if (c > w) w = c; break;	}
				if (map[r][c] == '*') mk[r][c] = sz, make_set(sz++);
			}
		}

		for (r = 0; r < h; r++) for (c = 0; c < w; c++) if (map[r][c] == '*') {
			for (i = 0; i < 8; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (r2 >= 0 && r2 < h && c2 >= 0 && c2 < w && map[r2][c2] == '*')
					union_set(mk[r][c], mk[r2][c2]);
			}
		}

		memset(tr, 0, sizeof(tr));
		for (ss = 0, r = 0; r < h; r++) for (c = 0; c < w; c++) if (map[r][c] == '*') {
			i = find_set(mk[r][c]);
			if (!tr[i][0]) s[++ss] = 0, tr[i][0] = ss;
			if (!tr[i][1]) tr[i][1] = 1 + c;
			else if (map[r][c+1] != '*') s[tr[i][0]] += c - tr[i][1] + 2, tr[i][1] = 0;
		}
		qsort(s+1, ss, sizeof(int), cmp);

		if (t) puts("----------"); else t = 1;
		for (f = 1, i = 2; i <= ss; i++) {
			if (s[i] == s[i-1]) f++;
			else printf("%d %d\n", s[i-1], f), f = 1;
		}
		printf("%d %d\n", s[i-1], f);
    }
    return 0;
}

Measured memory_bytes: 2520
#include <iostream>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    int n;
    stack<int> stk;
    char s[100];
    int p, front = 0, end = 0;

    scanf("%d %s", &n, s);

    for (int i=0; i<n; i++) {
        p = (s[i] == '(') ? 0 : 1;

        if (p == 0) {
            stk.push(1);
        }
        else {
            if (!stk.empty()) stk.pop();
            else {
                front++;
            }
        }
    }

    while (!stk.empty()) {
        end++;
        stk.pop();
    }

    for (int i=0; i<front; i++) cout << '(';
    cout << s;
    for (int i=0; i<end; i++) cout << ')';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
vector<int> vec;
int main()
{
	while(1)
	{
		double p,q,r;
		vec.clear();
		int x,y,z;
		cin >> x >> y >> z;
		if(x==0&&y==0&&z==0)break;
		vec.pb(x);
		vec.pb(y);
		vec.pb(z);
		sort(vec.begin(),vec.end());
		p=((double)vec[0])/2.0;
		q=((double)vec[1])/2.0;
		r=sqrt(p*p+q*q);
		int m;
		cin >> m;
		for(int i=0;i<m;i++)
		{
			int t;
			cin >> t;
			if(r<t)
			{
				cout << "OK" << endl;
			}
			else
			{
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <math.h>
 
int dp[3005][3005];
 
int main(){
 
	int A,B,C,D,E,F;
 
	scanf("%d %d %d %d %d %d",&A,&B,&C,&D,&E,&F);
 
	int i,j;
 
	dp[0][0]=1;
 
	for(i=0;i<=3000;i++){
		for(j=0;j<=3000;j++){
			if(dp[i][j]==1){
				if(i+(100*A)+j<=F){
					dp[i+(100*A)][j]=1;
				}
				if(i+(100*B)+j<=F){
					dp[i+(100*B)][j]=1;
				}
				if(i+C+j<=F){
					dp[i][j+C]=1;
				}
				if(i+D+j<=F){
					dp[i][j+D]=1;
				}
			}
 
		}
	}
 
 
	int water=0;
	int sugar=0;
 
	for(i=0;i<=3000;i++){
		for(j=0;j<=3000;j++){
			if(j<=(int)floor((double)i*E/100.0) && dp[i][j]==1){
				if((i+j)*sugar<=(water+sugar)*j){
					water=i;
					sugar=j;
				}
			}
		}
	}
 
	printf("%d %d\n",water+sugar,sugar);
 
	return 0;
}

Measured memory_bytes: 28800
import math
n,k = map(int,input().split())
mod = 10**9+7
red = n-k
def combination(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)

for i in range(1,k+1):
    print(combination(red+1,i)*combination(k-1, i-1)%mod if red+1>=i else 0)

Measured memory_bytes: 3316
A, B, C = map(int, input().split())

K = int(input())

while True:
  if B <= A:
    B *= 2
    K -= 1
  else:
    break
    
while True:
  if C <= B:
    C *= 2
    K -= 1
  else:
    break

if K >= 0:
  print('Yes')
else:
  print('No')

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    int i = 1;
    bool single = true;
    s += '?';

    while(i <= n){
        if(single && s[i] == s[i-1]) {
            i++;
            single = false;
            cnt++;
        }
        else single = true, cnt++;
        i++;
    }

    cout << cnt << endl;

    return 0;
}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s,t;
    in>>s>>t;
    int n=s.length();
    vector<vector<int>> S(26),T(26);
    fr(i,n) S[s[i]-'a'].emplace_back(i);
    fr(i,n) T[t[i]-'a'].emplace_back(i);
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    puts(S==T?"Yes":"No");
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,M;
  cin >> N >> M;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vi sum(N+1,0);
  map<int,int> mp;
  rep(i,N) {
    sum[i+1] = (sum[i] + A[i]) % M;
  }
  ll ans = 0;
  rep(i,N+1) {
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3968
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) (a).begin(), (a).end()

int h, w;
int da[81][81];
bitset<8000> dp[81][81];

int main(){
    cin >> h >> w;
    rip(i, h + 1, 1){
        rip(j, w + 1, 1){
            cin >> da[i][j];
        }
    }
    int b;
    rip(i, h + 1, 1){
        rip(j, w + 1, 1){
            cin >> b;
            da[i][j] = abs(da[i][j] - b);
        }
    }
    dp[0][1].set(0, 1);
    dp[1][0].set(0 ,1);
    rip(i, h + 1, 1){
        rip(j, w + 1, 1){
            dp[i][j] |= (dp[i - 1][j] << da[i][j]);
            dp[i][j] |= (dp[i][j - 1] << da[i][j]);
            dp[i][j] |= (dp[i - 1][j] >> da[i][j]);
            dp[i][j] |= (dp[i][j - 1] >> da[i][j]);
            rip(k ,da[i][j], 0){
                dp[i][j][abs(k - da[i][j])] = (dp[i][j][abs(k - da[i][j])] | (dp[i - 1][j][k] | dp[i][j - 1][k]));
            }
        }
    }
    int ans = 0;
    /*rip(i, h + 1, 0){
        rip(j ,w + 1, 0){
            if(j == w){
                cout << dp[i][j] << endl;
            }
            else{
                cout << dp[i][j] << ' ';
            }
        }
    }*/
    while(!dp[h][w][ans]){
        ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,m;
    cin>>n;
    string s;
    cin>>s;
    ll count=0;
    for(i=1;i<n;i++) if(s[i]!=s[i-1]) count++;
    cout<<count+1;
}

Measured memory_bytes: 3760
H, W = gets.split.map(&:to_i)

S = []
H.times{ S.push( gets.chomp.split )}

a = [*'A'.."Z"]

S.each_with_index do |r,i|
  r.each_with_index do |s,j|
    puts "#{a[j]}#{i+1}" if s == "snuke"
  end
end
    
  

Measured memory_bytes: 1788
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();

    let mut count = 0;
    for i in 0..s.len() {
        if s[i] != t[i] {
            count += 1;
        }
    }

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

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 3988
A,B = map(int,input().split())
xor = []
if B-A<=8:
    ans = 0
    for i in range(A,B+1):
        ans^=i
else:
    while True:
        if A%4 == 0:
            break
        else:
            xor.append(A)
        A+=1

    while True:
        if B%4 == 3:
            break
        else:
            xor.append(B)
        B-=1

    ans = 0
    while xor:
        ans^=xor.pop()
print(ans)


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

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

Node *root, *NIL;

void insert(int key)
{
	Node *y = NIL;
	Node *x = root;
	Node *z;
	z = (Node *)malloc(sizeof(Node));
	z->key = key, z->left = NIL, z->right = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;

	if (y == NIL)
		root = z;
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
}

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

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

Node *find(int key)
{
	Node *x = root;
	while (x != NIL && key != x->key)
	{
		if (key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	return x;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string order;
		cin >> order;
		if (order == "insert")
		{
			int key;
			cin >> key;
			insert(key);
		}
		else if (order == "print")
		{
			inOrder(root);
			cout << endl;
			preOrder(root);
			cout << endl;
		}
		else if (order == "find")
		{
			int key;
			cin >> key;
			Node *x = find(key);
			if (x == NIL) cout << "no" << endl;
			else cout << "yes" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 21828
N = int(input())
s_dict = {}
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for _ in range(N):
  s_list = list(input())
  s_list.sort()
  S = ''.join(s_list)
  if S in s_dict:
    s_dict[S] += 1
  else:
    s_dict[S] = 1
ans = 0
for value in s_dict.values():
  if value > 1:
    ans += cmb(value, 2)
print(ans)
    

Measured memory_bytes: 18444
#include<iostream>
#include<cstdio>
#include<cstring>

bool judge(int m,int a,int b)
{
	if(m>b+a/2)return 0;
	else if(m<b+(a!=0))return 0;
	else return 1;
}

int n,m,a,b;

int main()
{
	scanf("%d",&n);
	a=b=0,m=-1;
	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		if(m==-1)m=x,a++;
		else if(x==m)a++;
		else if(x==m-1)b++;
		else if(x==m+1 && !b)m=x,b=a,a=1;
		else {printf("No\n");return 0;}
	}
	if(judge(m,a,b) || (!b && judge(m+1,0,a)))printf("Yes\n");
	else printf("No\n");

	return 0;
}


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

void solve(){
	int h, w, k;
	cin >> h >> w >> k;
	long long cnt = 0;
	vector<string> a(h);
	for(int i = 0; i < h; i++) cin >> a[i];
	for(int i = 0; i < (1 << h); i++){
		for(int j = 0; j < (1 << w); j++){
			int black = 0;
			//cout << i << ' ' << j << '\n';
			for(int k = 0; k < h; k++){
				for(int l = 0; l < w; l++){ 
					//cout << (i & (1 << k)) << ' ' << (j & (1 << l)) << ' ' << a[k][l] << '\n'; 
					if(!(i & (1 << k)) && !(j & (1 << l)) && a[k][l] == '#') black++;
				}
			}
			//cout << black << '\n';
			if(black == k) cnt++;
		}
	}
	cout << cnt << '\n';
}

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

	int t = 1;
	while(t--) solve();
}

Measured memory_bytes: 3652
n, m = gets.chomp.split.map(&:to_i)
l_max = 1
r_min = n
m.times do
  l, r = gets.chomp.split.map(&:to_i)
  l_max = l if l_max < l
  r_min = r if r_min > r
end

puts([0, r_min - l_max + 1].max)

Measured memory_bytes: 1788
n, m = gets.split.map(&:to_i)
relations = []
m.times do
  a, b = gets.split.map(&:to_i)
  relations << a
  relations << b
end
buckets = Array.new(n, 0)
relations.each do |r|
  buckets[r-1] += 1
end
puts buckets


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int GCD[205][205];
int main() {
    int K;
    for(int i = 1; i <= 200; i++)
        for(int j = 1; j <= 200; j++)
            GCD[i][j] = gcd(i, j);
    cin >> K;
    long long sum = 0;
    for(int i = 1; i <= K; i++)
        for(int j = 1; j <= K; j++)
            for(int k = 1; k <= K; k++)
                sum += (long long)GCD[GCD[i][j]][k];
    cout << sum << endl;
  	return 0;
}


Measured memory_bytes: 3796
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> d(n);
	for(int i=0;i<n;++i) cin>>d[i];
	int ans=0;
	int num[110]={0};
	for(int i=0;i<n;++i){
		num[d[i]]++;
	}
	for(int i=1;i<=100;++i){
		if(num[i]) ++ans;
	}
	cout << ans << endl;
	return 0;		
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep (i, 0, n) cin >> a[i];
    rep (j, 0, k) {
        int l[500000] = {};
        rep (i, 0, n) {
            l[max (1, i + 1 - a[i])]++;
            l[i + 2 + a[i]]--;
        }
        int cnt = 0;
        rep (i, 0, n) {
            if (i == 0) a[i] = l[i + 1] + l[i];
            else
                a[i] = a[i - 1] + l[i + 1];
            if (a[i] == n) cnt++;
        }
        if (cnt == n) break;
    }
    rep (i, 0, n) cout << a[i] << " ";
}

Measured memory_bytes: 6312
<?php
# 入力部
// fscanf(STDIN, "%s %s", $s, $t);
// fscanf(STDIN, "%d %d", $n, $m);
// fscanf(STDIN, "%s", $u);
// fscanf(STDIN, "%d %d", $k, $x);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $r);
// fscanf(STDIN, "%f", $n);
fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%c", $c);
// fscanf(STDIN, "%s", $s2);
// fscanf(STDIN, "%d %d %d", $a, $b, $c);


# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// $arr = array("SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN");
// for ($i = 0; $i <= count($arr); $i++) {
//   if ($arr[$i] == $s) {
//     break;
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
// $r = "Yes";
// if ($s == "AAA" || $s == "BBB") {
//   $r = "No";
// }
// if ($n % 2 == 0) {
//   $r = $n / 2 / $n;
// } else {
//   $r = ($n + 1) / 2 / $n;
// }
// if ($n < 10) {
//   $r += (10 - $n) * 100;
// }
// $arr = array($a, $b, $c);
// $arr = array_unique($arr);
// if (count($arr) == 2) {
//   $r = "Yes";
// } else {
//   $r = "No";
// }
// if ($s == $u) {
//   $a--;
// } else {
//   $b--;
// }
// for ($i = 0; $h > 0; $i++) {
//   $h -= $a;
// }
// $r = "No";
// if ($n == $m) {
//   $r = "Yes";
// }
// $r = "win";
// if ($a + $b + $c >= 22) {
//   $r = "bust
// ";
// }
// $arr = array(1, 2, 3);
// unset($arr[$a - 1]);
// unset($arr[$b - 1]);
// $arr = array_values($arr);
// if ($n < 10 && $m < 10) {
//   $r = $n * $m;
// } else {
//   $r = -1;
// }
switch ($s) {
  case "Sunny":
    $r = "Cloudy";
    break;
  case "Cloudy":
    $r = "Rainy";
    break;
  case "Rainy":
    $r = "Sunny";
    break;
}

# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
// echo json_encode($arr) . "\n";
// echo $arr[0] . "\n";
// echo $i + 1 . "\n";
echo $r . "\n";
// echo ++$c . "\n";
// echo $a . " " . $b . "\n";
// echo $t . $s . "\n";


Measured memory_bytes: 16036
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll x;
  cin>>x;
  ll a = 100;
  ll cnt = 0;
  while(a<x){
    double tmp = (double)a * 1.01;
    a=(ll)tmp;
    cnt++;
  }
  print(cnt);
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int prime[10000];

int main() {
  int i, k, v, n, p1, q1;
  for(i = 2; i <= 10000; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= 10000; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= 10000; k += i) {
        prime[k] = 0;
      }
    }
   }
  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    while(1){
      if(prime[n] == 1){
        if(prime[n - 2] == 1){
          p1 = n - 2;
          q1 = n;
          break;
        }else n--;
      }else n--;
    }
    printf("%d %d\n", p1, q1);
  }
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <unordered_map>
#include <array>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <random>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
int N;
int A[MAX_N];
int C[MAX_N+2];

int main() {
  cin >> N;
  rep(i, N) cin >> A[i];
  
  for (int i = 0; i < N; ++i) {
    C[A[i]]++;
  }

  int ans = 0;
  for (int i = 0; i <= MAX_N; ++i) {
    int tmp = 0;
    if (i-1 >= 0) tmp += C[i-1];
    if (i+1 <= MAX_N) tmp += C[i+1];
    tmp += C[i];
    ans = max(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int N, Q, M, t, n, d;
  while (cin >> N >> Q, N||Q){
    vector<int> D(100,0);
    d = 0;
    n = 0;
    for (int i = 0; i < N; ++i){
      cin >> M;
      for (int j = 0; j < M; ++j){
	cin >> t;
	D[t-1] += 1;
      }
    }
    for (int i = 0; i < 100; ++i){
      if (D[i] > n){
	n = D[i];
	d = i;
      }
    }
    if (n >= Q) cout << d+1 << endl;
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 3100
#include <iostream>

int main()
{
	int a, b;
	while(std::cin>>a>>b)
	{
		int c = a+b;
		int d=0;
		if(c==0)
			d=1;
		else
		while(c>0)
			d++,
			c/=10;
		std::cout <<d <<std::endl;
	}
	return 0;
}

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

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

    int N;
    cin >> N;
    const int mod = 1e9 + 7;

    int dp[101][4][4][4] = {0};

    // 1文字目は前に3つTがある "TTT*" とみなして問題ない。
    // dp[0][3][3][3]は、長さ0の文字列のうち、
    // 最後から3番目の文字が3(T), 最後から2番目の文字が3(T),
    // 最後から1番目の文字が3(T)である個数を表す。
    dp[0][3][3][3] = 1;

    for (int len = 0; len < N; len++)
    {
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    // 条件に当てはまるものがなければcontinue
                    if (dp[len][i][j][k] == 0)
                    {
                        continue;
                    }

                    // 新しく文字を追加
                    for (int a = 0; a < 4; a++)
                    {
                        if (j == 0 && i == 1 && a == 2)
                        {
                            continue;
                        }
                        if (j == 0 && i == 2 && a == 1)
                        {
                            continue;
                        }
                        if (j == 1 && i == 0 && a == 2)
                        {
                            continue;
                        }
                        if (k == 0 && i == 1 && a == 2)
                        {
                            continue;
                        }
                        if (k == 0 && j == 1 && a == 2)
                        {
                            continue;
                        }

                        dp[len + 1][a][i][j] += dp[len][i][j][k];
                        dp[len + 1][a][i][j] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                ans += dp[N][i][j][k];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]
x = c[0][2] - c[0][1]
y = c[0][1] - c[0][0]
ans = 'Yes'
for i in range(1, 3):
  if c[i][2] - c[i][1] != x or c[i][1] - c[i][0] != y:
    ans = "No"
    break

print(ans)


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

public class Main{

	public static void main(String[] args) {
		InputReader reader = new InputReader(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];

		for (int i = 0; i < M; i++) {
			a[i] = reader.nextInt();
			b[i] = reader.nextInt();
		}

		int[] queryAppearCount = new int[N];

		for (int i = 0; i < M; i++) {
			queryAppearCount[a[i] - 1]++;
			queryAppearCount[b[i] - 1]++;
		}

		String res = "YES";
		for (int i = 0; i < N; i++) {
			if (queryAppearCount[i] % 2 == 1) {
				res = "NO";
				break;
			}
		}

		System.out.println(res);

	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

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

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

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

Measured memory_bytes: 44760
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll s[200009],x[200009];
ll L, n, ans;
ll solve() {
    for (ll i = 0; i < n; i++)
        s[i+1] = s[i] + x[i];
    /*
    x1 x2 x3 x4 x5
    
    */
    for (ll i = 0; i < n; i++)
        if (2 * (i + 1) <= n)
            ans = max(ans, x[i] + 2 * (s[i] + L * (i + 1) - (s[2*i+2] - s[i+1])));
        else
            ans = max(ans, x[i] + 2 * (s[i] - s[2*i + 1 - n] + L * (n - i - 1) - (s[n] - s[i+1])));
}
main() {
    cin >> L >> n;
    for (ll i = 0; i < n; i++)
        cin >> x[i];
    ans = max(x[n-1], L - x[0]);
    solve();
    reverse(x, x+n);
    for(int i = 0; i < n; i++)
        x[i] = L - x[i];
    solve();
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int a,b,x;
    while(~scanf("%d %d %d",&a,&b,&x))
    {
        if(a+b>=x&&x>=a)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 3000;
int N;
double p[MAX_N];
double dp[MAX_N][MAX_N]; // dp[i][j] := i番目までからj個オモテが出る確率。

int main() {

  cin >> N;
  rep(i, 1, N) cin >> p[i];
  
  dp[0][0] = 1;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= i; ++j) {
      dp[i][j] = dp[i-1][j] * (1.0-p[i]);
      if (j > 0) {
        dp[i][j] += dp[i-1][j-1] * p[i];
      }
    }
  }

  double ans = 0;
  for (int i = N/2+1; i <= N; ++i) {
    ans += dp[N][i];
  }

  printf("%.14lf\n", ans);

  return 0;
}



Measured memory_bytes: 68992
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int n, m;
char s[20];
long long ha[100010];
int main(){
    int i, j, k;
    cin >> n;
    for(i = 1; i <= n; ++i){
        scanf("%s",s+1);
        int len = strlen(s+1);
        sort(s+1,s+1+len);
        for(j = 1; j <= len; ++j){
            ha[i] = (ha[i]*13331+s[j]-96)%9223372036854775807;
        }
    }
    sort(ha+1, ha+1+n);
    long long ans = 0;
    long long sb = -1;
    long long cnt = 0;
    for(i = 1; i <= n; ++i){
        if(sb == ha[i])cnt++;
        else{
            ans += cnt*(cnt-1)/2;
            sb = ha[i];
            cnt = 1;
        }
    }
    ans += cnt*(cnt-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int main(){
	int n;cin>>n;
	string s;cin>>s;
	int len=s.length();
	s=" "+s;
	if(len<=n){
		for(int i=1;i<len+1;i++){
			cout<<s[i];
		}
	}else{
		for(int i=1;i<=n;i++){
			cout<<s[i];
		}
		cout<<"...";
	}
}


Measured memory_bytes: 3564