akhauriyash/Code-Regression huggingface dataset:
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int ans = 0;
    reverse(s.begin(), s.end());
    auto eq = [&](int len) {
        string r = s.substr(0, len);
        reverse(r.begin(), r.end());
        return r == t.substr(0, len);
    };
    for (int len = 1; len <= n; ++len) {
        if (eq(len))
            ans = len;
    }
    cout << n + n - ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <bitset>
#include <set>

using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define repe_r(i,s,n)for(int i = n;i>=s;i--)

vector<pair<ll, ll>> v;
int main() {
	ll n, m; cin >> n >> m;
	rep(i, 0, n) {
		ll x, y; cin >> x >> y;
		v.push_back({ x,y });
	}
	sort(v.begin(), v.end());

	ll price = 0;
	for (vector<pair<ll, ll>>::iterator it = v.begin(); it != v.end(); it++) {
		if (m > it->second) {
			m -= it->second;
			price += it->first*it->second;
		}
		else {
			price += it->first*m;
			m = 0;
			break;
		}
	}
	cout << price << endl;
	return 0;
}

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

int main(){
  const int Nbit= 200000;
  const int Nab= 26;

  string S,T;
  cin >> S >> T;
  int Nstr= S.size();

  unordered_set<bitset<Nbit>> freq1;
  unordered_set<bitset<Nbit>> freq2;
  for(char c='a'; c<='z'; c++){
    bitset<Nbit> pos1;
    bitset<Nbit> pos2;
    for(int i=0; i<Nstr; i++){
      if(S.at(i)==c) pos1.set(i);
      if(T.at(i)==c) pos2.set(i);
    }

    freq1.insert(pos1);
    freq2.insert(pos2);
  }

  if(freq1==freq2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1544
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,k;
    cin>>n;
    long long a[n+1]={};
    long long b[n+1]={};
    long long c[n+1]={};
    long long counter=0;
    for(long long i=0;i<n;i++){
    cin>>k;
    a[k]++;
    c[i]=k;}
    for(long long i=1;i<=n;i++){
    if(a[i]>=1)
    b[i]=a[i]*(a[i]-1)/2;
    else{b[i]=0;}
    counter+=b[i];}
    for(long long i=0;i<n;i++){
    if(a[c[i]]>=3){k=counter-b[c[i]]+(a[c[i]]-2)*(a[c[i]]-1)/2;
    cout<<k<<endl;}
    else if(a[c[i]]==2){k=counter-1;
    cout<<k<<endl;}
    else{
    cout<<counter<<endl;}}}
    

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ND = Io.ReadList<int>();
            var N = ND[0];
            var D = ND[1];

            var xyList = Io.ReadListRepeat<long>(N);

            var DD = (long)D * (long)D;
            var count = 0;
            foreach (var xy in xyList)
            {
                var dis = xy[0] * xy[0] + xy[1] * xy[1];
                if (dis <= DD)
                {
                    count++;
                }
            }

            Io.Write(count);
        }

        class Io
        {
            public static string Read()
            {
                return Console.ReadLine();
            }

            public static IEnumerable<string> ReadRepeat(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read());
            }

            public static T Read<T>()
            {
                return (T)Convert.ChangeType(Read(), typeof(T));
            }

            public static IEnumerable<T> ReadRepeat<T>(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read<T>());
            }

            public static string[] ReadList(char devide = ' ')
            {
                return Read().Split(devide);
            }

            public static T[] ReadList<T>(char devide = ' ')
            {
                return ReadList(devide)
                    .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                    .ToArray();
            }

            public static IEnumerable<string[]> ReadListRepeat(int count, char devide = ' ')
            {
                return Enumerable.Range(0, count).Select(_ => ReadList(devide));
            }

            public static IEnumerable<T[]> ReadListRepeat<T>(int count, char devide = ' ')
            {
                return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
            }

            public static void Write<T>(T value)
            {
                Console.WriteLine(value.ToString());
            }
        }
    }
}


Measured memory_bytes: 41552
s = int(input())
mod = 10**9 + 7
if(s < 3):
    print(0)
    exit()

## nCkのmodを求める関数
# テーブルを作る(前処理)
max_n = 10000
fac, finv, inv = [0]*max_n, [0]*max_n, [0]*max_n

def comInit(max_n):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max_n):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max_n)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 0
for x in range(1,s//3 + 1):
    y = s - 3*x
    ans += com(x+y-1,y)
    ans %= mod
print(ans)

Measured memory_bytes: 64500
#include <iostream>

typedef long long ll;

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

  ll ans = k;
  for (ll i = 0; i < n - 1; i++) {
    ans *= k - 1;
  }
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll X;
  cin >> X;
  ll ans = 0;
  long double y = 100;
  for (int i = 0; i < 10000; i++) {
    y = y + floor(y * 0.01);
    if (y >= X) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const long long inf = 1e9+7;
const long long mod = 1e9+7;

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

    if(s[s.size()-1]=='s'){
        s.push_back('e');
    }

    s.push_back('s');

    cout<<s<<endl;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    transform(t.begin(), t.end(), t.begin(), [](char c) {
        if (c == '?') {
            return 'D';
        } else {
            return c;
        }
    });

    cout << t << endl;
}

Measured memory_bytes: 3724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 107
	// https://atcoder.jp/contests/abc107/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int i = sc.nextInt();
		
		System.out.println(n - i + 1);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 21204
#include <cstdio>
#include <cstring>
using namespace std;
int n,a[200010],t=-1;
long long k;
int vis[200010];
int dfs2(int x,long long s){
	if(s==0)return x;
	return dfs2(a[x],s-1);
}
int dfs1(int x){
	++t;
	if(t==k)return x;
	if(vis[x]!=-1){
		long long ans1=(k-vis[x])%(t-vis[x]);
		if(ans1==0)ans1+=t-vis[x];
		return dfs2(x,ans1);
	}else{
		vis[x]=t;
		return dfs1(a[x]);
	}
}
int main(){
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%d",a+i);
	}
	memset(vis,-1,sizeof(vis));
	printf("%d\n",dfs1(1));
	return 0;
}


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

int main(){  
    ll H;  cin >> H;
    ll p = 0;
    for(int i=0; i<50; i++){
        ll low = pow(2, i);
        ll high = 2*low;
        if(low <= H && H < high){
            cout << high - 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
H,W = map(int,input().split())
a = [0]*H
for i in range(H):
    a[i]=list(map(int, input().split()))

ans_array = []
ans_cnt = 0
for i in range(H):
    for j in range(W):
        if a[i][j]%2 == 0:
            continue
        else:
            if i !=H-1: 
                if j==W-1:
                    ans_array.append([i,j,i+1,j])
                    # print("1")
                    ans_cnt += 1
                    a[i+1][j]+=1

                else:
                    if a[i][j+1]%2==0:
                        ans_array.append([i,j,i+1,j])
                        # print("2")
                        ans_cnt += 1
                        a[i+1][j]+=1
                    else: 
                        ans_array.append([i,j,i,j+1])
                        # print("3")
                        ans_cnt += 1
                        a[i][j+1]+=1
            else:
                if j==W-1:
                    continue
                else:
                    ans_array.append([i,j,i,j+1])
                    # print("4")
                    ans_cnt += 1
                    a[i][j+1]+=1
                    
                        


print(ans_cnt)
for i in range(len(ans_array)):
    print(ans_array[i][0]+1,ans_array[i][1]+1,ans_array[i][2]+1,ans_array[i][3]+1)



                    
                    

                


Measured memory_bytes: 26280
N,A,B = map(int,input().split())
S = input()
total = A+B
for i in range(N):
    if S[i]=='c':
        print('No')
    elif total>0:
        if S[i] == 'a':
            print('Yes')
            total = total-1
        elif S[i] =='b' and B>0:
            print('Yes')
            total = total-1
            B = B-1
        else:
            print('No')
    else:
        print('No')


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

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

	int div;
	int count = 0;

	for (int i = A;; i--)
	{
		if (A%i == 0 && B%i == 0)
			count++;

		if (count == K)
		{
			div = i;
			break;
		}
	}
	cout << div;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

//Z-algorithm
//res[i] := 自分自身と[i,|S|)の最長共通接頭辞の長さ
void z_algorithm(const std::string& str, std::vector<int>&res)
{
	int len = str.length();
	res.resize(len);
	res[0] = len;
	int i = 1, j = 0;
	while (i < len)
	{
		while (i + j < len && str[j] == str[i + j])
			++j;
		res[i] = j;
		if (j == 0)
		{
			++i;
			continue;
		}
		int k = 1;
		while (i + k < len && k + res[k] < j)
			res[i + k] = res[k], ++k;
		i += k, j -= k;
	}
}

string S;
LL L, R;

struct alpha
{
	LL cnt[26];
	alpha()
		:cnt()
	{}
	alpha(const string& s)
		:cnt()
	{
		for (char c : s)cnt[c - 'a']++;
	}
	alpha operator+(const alpha& other)
	{
		alpha ret = *this;
		for (int i = 0; i < 26; ++i)ret.cnt[i] += other.cnt[i];
		return ret;
	}
	alpha operator-(const alpha& other)
	{
		alpha ret = *this;
		for (int i = 0; i < 26; ++i)ret.cnt[i] -= other.cnt[i];
		return ret;
	}
	alpha operator*(const LL& mult)
	{
		alpha ret = *this;
		for (int i = 0; i < 26; ++i)ret.cnt[i] *= mult;
		return ret;
	}
	void print()
	{
		for (int i = 0; i < 26; ++i)cout << cnt[i] << " \n"[i == 25];
	}
	inline LL size()
	{
		LL res = 0;
		for (int i = 0; i < 26; ++i)res += cnt[i];
		return res;
	}
};

int main(void)
{
	cin >> S;
	cin >> L >> R;
	--L;
	S.erase(S.size() / 2, S.size() / 2);
	int N = S.size();
	vector<int>res;
	z_algorithm(S, res);
	int period = N;
	for (int i = 1; i < N; ++i)
	{
		if (res[i] + i == N)
		{
			period = i;
			break;
		}
	}
	if (N % period == 0)
	{
		//周期がぴったり
		string perstr = S.substr(0, period);
		alpha A(perstr);
		std::function<alpha(LL)>F = [&](LL x)
		{
			alpha ret = A * (x / period);
			alpha mod = alpha(S.substr(0, x % period));
			ret = ret + mod;
			return ret;
		};
		alpha ans = F(R) - F(L);
		ans.print();
	}
	else
	{
		//周期に余りがある
		alpha X(S);
		alpha A(S.substr(0, period));
		std::function<alpha(LL)>F = [&](LL x)
		{
			vector<alpha>len = { A,X };
			while (len.back().size() <= x)
			{
				len.push_back(len.back() + len[len.size() - 2]);
			}
			alpha ans;
			for (int i = len.size() - 2; i >= 0; --i)
			{
				if (x - len[i].size() >= 0)
				{
					x -= len[i].size();
					ans = ans + len[i];
				}
			}
			alpha rem(S.substr(0, x));
			ans = ans + rem;
			return ans;
		};
		alpha ans = F(R) - F(L);
		ans.print();
	}
	return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define max1 100005
#define siz 100000
#define mod 998244353
#define inf 1e18+5
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
#define jam(x) cout<<"Case #"<<x<<": "
typedef pair<ll,ll> pr;
vector<ll> dp(max1,-1);
vector<vector<ll> > adj(max1,vector<ll>() );
ll dfs(ll x)
{
  if(dp[x]!=-1)
  {
    return dp[x];
  }
  ll cnt=0;
  for(ll i=0;i<adj[x].size();i++)
  {
    cnt=max(cnt,dfs(adj[x][i]));
  }
  //cout<<x<<" "<<cnt<<endl;
  return dp[x]=cnt+1;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  ll n,m;
  cin>>n>>m;
  for(ll i=0;i<m;i++)
  {
    ll u,v;
    cin>>u>>v;
    adj[u].push_back(v);
  }
  ll ans=0;
  for(ll i=1;i<=n;i++)
  {
    if(dp[i]==-1)
    {
      dp[i]=dfs(i);
      ans=max(ans,dp[i]);
    }
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 8576
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    */
	int m; scanf("%d", &m);
	while (m--) {
		string s;
		set<string> st;
		cin >> s;
		st.emplace(s);
		for (int i = 1; i < (ll)s.size(); i++) {
			string t1, t2, t3, t4;
			string t5, t6, t7, t8;
			string tmp1 = s.substr(0, i);
			string tmp2 = s.substr(i, s.size());
			t1 = tmp1 + tmp2;
			t5 = tmp2 + tmp1;
			reverse(tmp2.begin(), tmp2.end());
			t2 = tmp1 + tmp2;
			t6 = tmp2 + tmp1;
			reverse(tmp1.begin(), tmp1.end());
			t4 = tmp1 + tmp2;
			t7 = tmp2 + tmp1;
			reverse(tmp2.begin(), tmp2.end());
			t3 = tmp1 + tmp2;
			t8 = tmp2 + tmp1;
			st.emplace(t1);
			st.emplace(t2);
			st.emplace(t3);
			st.emplace(t4);
			st.emplace(t5);
			st.emplace(t6);
			st.emplace(t7);
			st.emplace(t8);
		}
		printf("%d\n", (int)st.size());
	}
	return 0;
	/*
		おまじないを使ったらscanfとprintf関連注意！！！！！！！！！！！！
	*/
}



Measured memory_bytes: 3376
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_easy_linear_programming(void) {
	long long a, b, c, k;
	cin >> a >> b >> c >> k;

	long long sum = 0;

	if (k >= a) {
		sum = a;
		k -= a;
	}
	else {
		sum += k;
		cout << sum << endl;
		return;
	}
	if (k >= b) {
		k -= b;
	}
	else {
		cout << sum << endl;
		return;
	}

	sum += (-1) * k;

	cout << sum << endl;


}
int main()
{
    b_easy_linear_programming();

    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int I,O,T,J,L,S,Z;

void solve(int _t) {
    cin>>I>>O>>T>>J>>L>>S>>Z;
    int ans = 0;
    {
        ans += O;
        ans += I/2*2;
        ans += J/2*2;
        ans += L/2*2;
    }
    {
        int cnt = 0;
        if (I&&J&&L) {
            cnt += 3;
            I--;
            J--;
            L--;
        }
        cnt += O;
        cnt += I/2*2;
        cnt += J/2*2;
        cnt += L/2*2;
        chmax(ans,cnt);
    }
    _PN(ans);
}
EXEC(1)



Measured memory_bytes: 3536
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    string s;cin>>s;
    int ans;
    if(s=="RRR")ans=3;
    else if(s=="RRS"||s=="SRR")ans=2;
    else if(s=="RSS"||s=="SRS"||s=="SSR"|s=="RSR")ans=1;
    else ans=0;
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
import math

while True:
	n = int( input() )
	if 0 == n:
		break
	s = [ float( i ) for i in input( ).split( " " ) ]
	t = sum( s )
	m = t / n
	t = 0
	for val in s:
		t += ( val - m )**2
	print( math.sqrt( t/n ) )

Measured memory_bytes: 6840
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

void chemthan() {
    int n, a, b; cin >> n >> a >> b;
    if (a + b - 1 > n || n > (long long) a * b) {
        cout << -1 << "\n";
        return;
    }
    vector<long long> res;
    FOR(i, 1, a + 1) {
        res.pb((long long) (b - 1) * a + i);
    }
    int cnt = n - a;
    FORd(i, b - 1, 0) {
        int num = min(a, cnt - i);
        cnt -= num;
        FOR(j, 1, num + 1) {
            res.pb((long long) i * a + j);
        }
    }
    vector<long long> dc = res;
    sort(all(dc));
    FOR(i, 0, n) {
        cout << lower_bound(all(dc), res[i]) - dc.begin() + 1 << " \n"[i == n - 1];
    }
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 


Measured memory_bytes: 8300
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int V, E, r;
    cin >> V >> E >> r;
    vector<vector<pair<int, int>>> g(V);
    for (int i = 0; i < E; i++)
    {
        int s, t, d;
        cin >> s >> t >> d;
        g[s].emplace_back(t, d);
    }

    vector<int> dist(V, -1);
    dist[r] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.emplace(0, r);
    while (!pq.empty())
    {
        pair<int, int> p = pq.top();
        pq.pop();
        for (auto v : g[p.second])
        {
            if (dist[v.first] == -1)
            {
                dist[v.first] = dist[p.second] + v.second;
                pq.emplace(dist[v.first], v.first);
            }
            else if (dist[v.first] <= dist[p.second] + v.second)
            {
                continue;
            }
            else
            {
                dist[v.first] = dist[p.second] + v.second;
                pq.emplace(dist[v.first], v.first);
            }
        }
    }
    for (int i = 0; i < V; i++)
    {
        if (dist[i] == -1)
        {
            cout << "INF" << endl;
        }
        else
        {
            cout << dist[i] << endl;
        }
    }
}


Measured memory_bytes: 12912
#include <bits/stdc++.h>
using namespace std;
string S;
void solve()
{
    if (S[0]=='Y'&&S[1]=='A'&&S[2]=='K'&&S[3]=='I') cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>S)
        solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
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; }
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);

ll Pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n&1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

ll x[200010] = {}, y[200010] = {};

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

    x[1] = 0;
    y[1] = n;
    for(int i = 2; i <= n; i++){
        x[i] = x[i-1]-1+i;
        y[i] = y[i-1]+n+1-i;
    }
    
    ll sum = 0;
    for(ll i = k; i <= n+1; i++){
        ll mi = x[i],ma = y[i];
        (sum += ma-mi+1) %= MOD;
        //cout << ma-mi+1 << endl;
    }
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 6700
n = gets.chomp.to_i
a = []
sum = 0

a[0] = gets.chomp.to_i
if a[0] != 0
  printf("-1\n")
  exit
end

(1...n).each do |i|
  a[i] = gets.chomp.to_i
  if a[i] == a[i-1] + 1
    sum += 1
  elsif a[i] < a[i-1] + 1
    sum += a[i]
  else
    printf("-1\n")
    exit
  end
end

printf("%d\n",sum)

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

class Program
{
    public static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = s[0];
        int k = s[1];
        List<int> h = new List<int>();
        for (int i = 0; i < n; i ++) h.Add(int.Parse(Console.ReadLine()));
        h.Sort();
        int ans = h[k-1]-h[0];
        for (int i = 1; i < n-k+1; i ++) {
            int tmp = h[i+k-1] - h[i];
            if(tmp<ans) ans = tmp;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 16224
q=[];$<.map{|l|l.split.permutation{|a,b|b&&(q[a.to_i]||=[])<<b.to_i}};h=->i,r{c=0;q[i].map{|j|j!=r&&c+=h[j,i]};c^1};puts h[1,1]<1?:Second: :First

Measured memory_bytes: 30716
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
	ll a,b;
	cin>>a>>b;
	ll c=(a*b)/gcd(a,b);
	cout<<c;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // in
            for (int i = 0; i < 5; i++) {
                int in = Integer.parseInt(sc.next());
                if (in == 0) {
                    System.out.println(i + 1);
                    break;
                }
            }
        }
    }
}


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

struct UnionFind {
    vector < int > par;
    vector < int > siz;

    UnionFind(int n): par(n), siz(n, 1) {
        for(int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x){ 
        if(par[x] == x) return x;else return par[x] = root(par[x]);
    }

    int size(int x){ return siz[root(x)];}

    bool same(int x, int y){ return root(x) == root(y); }
    bool unite(int x, int y){
        if((x=root(x))==(y=root(y))) return false;
        if( siz[y] > siz[x] ) swap(x,y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
};


int main(){

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

    int n,q;
    cin>>n>>q;
    int com,x,y;

    UnionFind uf(n);
    for(int i=0; i<q; ++i){
        cin>>com>>x>>y;

        if(com == 0)
            uf.unite(x,y);
        else{
            if(uf.same(x,y)) cout<<1<<'\n';
            else cout<<0<<'\n';
        }
    }
    return 0;
}


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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if (x - r < 0 || x + r > W) cout << "No" << endl;
    else if (y - r < 0 || y + r > H) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,l;
    cin>>n>>l;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int lp=0,res=0;
    for(int i=0;i<n-1;i++){
        if(a[i]+a[i+1]>lp){
            lp=a[i]+a[i+1];
            res=i+1;
        }
    }
    if(lp<l)cout<<"Impossible"<<endl;
    else{
        cout<<"Possible"<<endl;
        for(int i=1;i<res;i++)cout<<i<<endl;
        for(int i=n-1;i>=res;i--)cout<<i<<endl;
    }
}

Measured memory_bytes: 1664
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<set>
#define inf 0x3f3f3f3f
typedef long long ll;

const int maxn=1e5+5;

using namespace std;

int a[40]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d\n",a[n-1]);
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
anser=0
for i in range(n):
    a=list(map(int,input().split()))
    ans=0
    for j in range(m):
        ans+=a[j]*b[j]
    ans+=c    
    if ans>0:
        anser+=1
print(anser)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;


int main(){
  int n;
  cin>>n;
  ll a[MAX];
  rep(i,n)cin>>a[i];
  ll ans[MAX];
  ans[0]=0;
  rep(i,n){
    if(i%2==0)ans[0]+=a[i];
    if(i%2==1)ans[0]-=a[i];
  }
  for(int i=2; i<2*n; i+=2){
    ans[i%n]=ans[(i-2)%n]+2*a[(i-1)%n]-2*a[(i-2)%n];
  }
  rep(i,n)cout<<ans[i]<<" ";
}

Measured memory_bytes: 2816
#include <iostream>

using namespace std;

int main()
{
  int N;
  int Y=0;
  cin >> N;
  int V[N],C[N];
  for(int i=0;i<N;i++) cin >> V[i];
  for(int i=0;i<N;i++) cin >> C[i];
  for(int i=0;i<N;i++){
    if(V[i]>C[i]){
      Y += V[i]-C[i];
    }
  }
  cout << Y << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python

import sys

def main(argv):
    n = sys.stdin.readline().rstrip()

    while n:
        result = -1
        n = int(n)
        count = [0 for i in range(0, int(n / 2))]
        if n % 2 != 0:
            count.append(0)
        a = [int(i) for i in raw_input().split()]
        for a_i in a:
            index, reminder = divmod(a_i, 2)
            if reminder == n % 2 or index >= len(count):
                result = 0
                break
            else:
                count[index] += 1

        if result < 0:
            if n % 2 != 0:
                if count[0] != 1:
                    result = 0
                else:
                    for c in count[1:]:
                        if c != 2:
                            result = 0
                            break
                    if result != 0:
                        result = 2 ** (len(count) - 1)
            else:
                for c in count:
                    if c != 2:
                        result = 0
                        break
                if result != 0:
                    result = 2 ** len(count)
        print result % ((10 ** 9) + 7)

        n = sys.stdin.readline().rstrip()

if __name__ == "__main__":
    main(sys.argv)

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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"

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

    // cout<<fixed<<setprecision(15);

    ll n;
    cin>>n;

    ll a[n];

    for(ll i = 0 ; i < n ; i++)
    {
        cin>>a[i];
    }

    ll cnt = 0;

    for(ll i = 1 ; i < n - 1 ; i++)
    {
        vector<ll> v;

        v.pb(a[i-1]);
        v.pb(a[i]);
        v.pb(a[i+1]);

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

        if(v[1] == a[i])
        {
            cnt++;
        }

    }

    cout<<cnt<<endl;

}

Measured memory_bytes: 256
#define REPI(i, n) for (int i = 0; i < n; i++)
#define REPD(i, n) for (int i = n; i > 0; i--)

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int x[n], X[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    X[i] = x[i];
  }
  sort(X, X + n);
  int a = X[n / 2 - 1], b = X[n / 2];
  for (int i = 0; i < n; i++) {
    if (x[i] < b)
      cout << b << endl;
    else
      cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int m1, d1, m2, d2;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> m1 >> d1 >> m2 >> d2;
    if (m2 != m1) cout << 1;
    else cout << 0;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    char c, s[105], t[105];
    int i, j, k, flag;
    flag = 0;
    scanf("%s", &s);
    scanf("%s", &t);
    k = strlen(s);
    for (i = 0; i < k; i++)
    {
        if (strcmp(s, t) == 0)
        {
            flag = 1;
            break;
        }
        c = s[k - 1];
        for (j = k - 2; j >= 0; j--)
            s[j + 1] = s[j];
        s[0] = c;
    }
    if (flag == 0)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int MAX_N = 100;

int main()
{
    vector<int> a;
    int c;
    //vector<int> data(123);  //  int 型で、初期要素数 123 の動的配列 data の宣言
    //vector<int> data(10, 5);      //  要素数10、全ての要素の値5 で初期化


    for (int i = 0; i < 3; i++)
    {
        cin >> c;
        a.push_back(c);
    }

    sort(a.begin(),a.end()); //昇順ソート
    //sort(a.begin(),a.end(),greater<int>()); //降順ソート

    if (a[0]==a[1] && a[1]!=a[2])
    {
        cout << "Yes" << endl;
    }else if (a[0]!=a[1] && a[1]==a[2])
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;

    }

    return 0;
}

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

#define MAX_N 12000

int prime[MAX_N];
bool is_prime[MAX_N + 1];


void prime_generate(){
	int p = 0;
	for(int i = 0; i <= MAX_N; i++) is_prime[i] = true;

	is_prime[0] = is_prime[1] = false;

	for(int i = 2; i <= MAX_N; i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2 * i; j <= MAX_N; j += i) is_prime[j] = false;
		}
	}
}

void solve(int n){
	int p1 = -1, p2 = -1;

	for(int i = 0; prime[i+1] <= n; i++){
		if(prime[i+1] - prime[i] == 2){
			if(p1 <= prime[i]){
				p1 = prime[i];
			}
			if(p2 <= prime[i+1]){
				p2 = prime[i+1];
			}
		}
	}
	cout << p1 << " " << p2 << endl;
}

int main(){
	prime_generate();

	int n;
	while(cin >> n,n){
		solve(n);
	}
}

Measured memory_bytes: 1176
#include<stdio.h>
#define max(a,b) ((a>b)?(a):(b))
char a[3001], b[3001], ans[3001];
int dp[3001][3001], n, m, prev[3001][3001];

int main() {
	scanf("%s", a+1);
	scanf("%s", b+1);
	for( n=1; a[n+1]; ++n );
	for( m=1; b[m+1]; ++m );
	for( int i=1; a[i]; ++i )
		for( int j=1; b[j]; ++j )
			if( a[i] == b[j] )
				dp[i][j] = dp[i-1][j-1] + 1, prev[i][j] = 3;
			else
				if( dp[i][j-1] < dp[i-1][j] )
					dp[i][j] = dp[i-1][j], prev[i][j] = 2;
				else
					dp[i][j] = dp[i][j-1], prev[i][j] = 1;
	for( int i=n, j=m, x; i && j; ) {
		if( a[i] == b[j] )
			ans[dp[i][j]] = a[i];
		if( prev[i][j] == 3 )
			--i, --j;
		else if( prev[i][j] == 2 )
			--i;
		else if( prev[i][j] == 1 )
			--j;
	}
	printf("%s\n", ans+1);
}


Measured memory_bytes: 70528
import statistics

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

Ai_i = [0 for i in range(len(A))]

for i in range(len(A)):
    Ai_i[i] = A[i] - (i+1)

bs = [int(statistics.median(Ai_i))]
abss_ls = [ 0 for i in range(len(bs)) ]

for i in range(len(bs)):
    for j in range(len(Ai_i)):
        abss_ls[i] += abs(Ai_i[j] - bs[i])

min_abs = min(abss_ls)
print(min_abs)


Measured memory_bytes: 27240
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);

    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }


    return 0;
    }

Measured memory_bytes: 580
#include<cstdio>

int main() {
  int n;
  scanf("%d", &n);
  int A;
  int sum[n] = {};
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &A);
    sum[(A - 1)] = sum[(A - 1)] + 1;
  }
  for (int i = 0; i < n - 1; i++) {
    printf("%d\n", sum[i]);
  }
  printf("%d\n", 0);
  return 0;
}

Measured memory_bytes: 2500
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int INFTY=2e9+1;
const int N=110000;

int t[N];

int main() {
    int i, n, c, k, ans=0, deadline=INFTY, w=0;
    scanf("%d%d%d", &n, &c, &k);
    for(i=0; i<n; i++) scanf("%d", &t[i]);
    sort(t, t+n);

    for(i=0; i<n; i++) {
        if(t[i]>deadline || w==c) {
            ans++;
            w=0;
            deadline=INFTY;
        }
        w++;
        deadline=min(deadline, t[i]+k);
    }
    if(w) ans++;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

/** テヲツ閉ーテ・ツシツ湘」ツつ、テ」ツδ?」ツδャテ」ツδシテ」ツつソ */
static const char *p;

static int expression ( );

static int
factor (
  void
  )
{
  int res = 0;

  if ( *p == '(' )
  {
    ++p;
    res = expression ( );
    ++p;
  }
  else while ( isdigit ( *p ) )
  {
    res = res * 10 + ( *( p++ ) - '0' );
  }

  return ( res );
}

static int
term (
  void
  )
{
  int res = factor ( );

  for ( ; ; )
  {
    switch ( *p )
    {
      case '*':
        ++p;
        res *= factor ( );
        break ;
      case '/':
        ++p;
        res /= factor ( );
        break ;
      default:
        return ( res );
    }
  }
}

static int
expression (
  void
  )
{
  int res = term ( );

  for ( ; ; )
  {
    switch ( *p )
    {
      case '+':
        ++p;
        res += term ( );
        break ;
      case '-':
        ++p;
        res -= term ( );
        break ;
      default:
        return ( res );
    }
  }
}

/** テヲツ閉ーテ・ツシツ銃xpr テ」ツつ津ィツィツ暗ァツョツ療」ツ?凖」ツつ凝ッツシツ?*/
static int
calculate (
  const char *expr
  )
{
  p = expr;

  return
  expression ( );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  /** ティツィツ暗ァツョツ療・ツッツセティツアツ。テ」ツ?ョテヲツ閉ーテ・ツシツ?*/
  char expr[ 128 ];
  /** テ・ツ?・テ・ツ環崚」ツ?ョテ・ツ?凝ヲツ閉ー */
  int n;

  scanf ( "%d", &n );
  while ( n-- )
  {
    scanf ( " %s", expr );

    printf ( "%d\n", calculate ( expr ) );
  }

  return ( EXIT_SUCCESS );
}

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const int mod = 1e9+7;
int n;
char mat[310][310];

int main(){
	cin >> n;
	forn(i) {
		cin >> mat[i];
	}
	ll ans = 0LL;
	forn(A) {
		for (int i = 1; i < n;i++) {
			for (int j = 0; j < i;j++) {
				if (mat[(i+A)%n][j] != mat[(j+A)%n][i]) {
					goto next;
				}
			}
		}
		ans += n;
		next:;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
if n==1:
    b=a
elif n==2:
    b[1]=a[1]
    b[0]=(a[0]-b[1])%2
    
elif n==3:
    b[1]=a[1]
    b[2]=a[2]
    b[0]=(a[0]-b[1]-b[2])%2
else:
  i=2
  while n/i>=1:
      for k in range((n//i)+1,n//(i-1)+1):
          j=2
          b[k-1]=a[k-1]
          while j*k-1<n:
              b[k-1]=(b[k-1]-b[j*k-1])%2
              j+=1
      i+=1
  j=1
  b[0]=a[0]
  while j*1<n:
      b[0]=(b[0]-b[j*1])%2
      j+=1
num=sum(b)
print(num)
for i in range(n):
    if b[i]==1:
        print(i+1)

    

Measured memory_bytes: 63608
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int min(int a, int b){
	if(a<b)return a;
	else return b;
}

ll gcd(ll a, ll b){
	if(b == 0)return a;
	return gcd(b,a%b);
}


int main(void){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll len=b+1-a;
	ll lcm=c*d/gcd(c,d);
	ll w1=len/c, w2=len/d, w3=len/lcm;

	if((a-1)%c+len%c>c-1 )w1++;
	if((a-1)%d+len%d>d-1 )w2++;
	if((a-1)%lcm+len%lcm>lcm-1)w3++;
	cout<<len-(w1+w2-w3)<<endl;
	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int n, i;
	char s[100000];
	scanf("%s", s);
	
	int x=0, y=0, ans;
	for(i=0; i<strlen(s); i++){
		if(i%2==0 && s[i]=='1'){x++;}
		else if(i%2!=0 && s[i]=='0'){x++;}
		else{y++;}
	}
	
	if(x>y) ans=y;
	else ans=x;
	
	printf("%d", ans);
	
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  if((n % 10 == 9) || (n / 10 == 9)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int S;
	int h;
	int m;
	int s;
	
	scanf("%d", &S);
	
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;
	
	printf("%d:%d:%d\n",h , m, s);
	
	return (0);
}

Measured memory_bytes: 592