akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define SZ(a) (int)(a.size())
#define PB push_back
#define LL long long
#define X first
#define Y second
const int mod = 1000 * 1000 * 1000 + 7;
int add(int a , int b)
{
	return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a , int b)
{
	return a - b < 0 ? a - b + mod : a - b;
}
int mult(int a , int b)
{
	return a * (LL)b % mod;
}
set<int> rows[100005];
int p[100005];
int sz[100005];
int find(int u)
{
	return p[u] = u == p[u] ? u : find(p[u]);
}
void unite(int u , int v)
{
	u = find(u) , v = find(v);
	if(u == v)
		return;
	if(rows[u] > rows[v])
		swap(u , v);
	sz[u] += sz[v];
	p[v] = u;
	for(auto x : rows[v])
		rows[u].insert(x);
}
int main()
{
	for(int i = 0; i <= 100000; i++)
	{
		p[i] = i;
		sz[i] = 1;
	}
    //getFacts();
	int N;
	cin >> N;
	vector<pair<int , int> > v(N);
	for(auto &x : v)
		cin >> x.X >> x.Y;
	sort(v.begin() , v.end());
	for(int i = 0; i < SZ(v); i++)
	{
		int comp = find(v[i].Y);
			rows[comp].insert(v[i].X);
		if(i && v[i].X == v[i - 1].X)
			unite(v[i].Y , v[i - 1].Y);	
	}
	LL ans = 0;
	for(int i = 0; i <= 100000; i++)
		if(find(i) == i)
			ans += SZ(rows[i]) * (LL)sz[i];
	cout << ans - N;
    return 0;
}


Measured memory_bytes: 24320
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n, 0);

    for (int i = 0; i < q; ++i) {
        int inp; cin >> inp;
        inp--;
        a[inp]++;
    }

    for (int i = 0; i < n; ++i) {
        if (k - q + a[i] > 0) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];
    c[n - 1] = 0;
    s[n - 1] = f[n - 1] = 1;

    rep(i, n - 1)
    {
        int ans = 0;
        for (int j = i; j < n - 1; ++j)
        {
            int t;
            if (ans % f[j] != 0)
                t = ans / f[j] + 1;
            else
                t = ans / f[j];
            ans = max(s[j], t * f[j]);
            ans += c[j];
        }

        cout << ans << endl;
    }
    cout << 0 << endl;
}

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

class G
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];
		var es = new int[h[1]].Select(_ => Read()).ToArray();

		var map = Array.ConvertAll(new int[n], _ => new List<int>());
		var map_r = Array.ConvertAll(new int[n], _ => new List<int>());
		foreach (var e in es)
		{
			map[e[0]].Add(e[1]);
			map_r[e[1]].Add(e[0]);
		}

		var u = new bool[n];
		var order = new List<int>();
		var gs = new List<List<int>>();
		List<int> lg = null;

		Action<int> Dfs = null;
		Dfs = v =>
		{
			u[v] = true;
			foreach (var nv in map[v]) if (!u[nv]) Dfs(nv);
			order.Add(v);
		};
		for (int v = 0; v < n; v++) if (!u[v]) Dfs(v);

		Action<int> Dfs_r = null;
		Dfs_r = v =>
		{
			u[v] = true;
			foreach (var nv in map_r[v]) if (!u[nv]) Dfs_r(nv);
			lg.Add(v);
		};
		Array.Clear(u, 0, n);
		order.Reverse();
		foreach (var v in order) if (!u[v]) { gs.Add(lg = new List<int>()); Dfs_r(v); }

		Console.WriteLine(gs.Count);
		Console.WriteLine(string.Join("\n", gs.Select(g => string.Join(" ", g.Prepend(g.Count)))));
	}
}


Measured memory_bytes: 185976
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
ull h0,w0,ANS[1000000],h,w;
ull ans(ull r){
    ull s[3];
    s[0]=h*r;
    w-=r;
    if(h>w){ull t=w;w=h;h=t;}
    if(h%2==0||w%2==0){
        s[1]=w*h/2;
        s[2]=w*h/2;
    }else{
        s[1]=h*(ull)(w/2);
        s[2]=h*w-s[1];
    }
    sort(s,s+3);
    return s[2]-s[0];
}
int main(){
    cin>>h0>>w0;
    h=h0;w=w0;
    //if(h0%3==0||w0%3==0)cout<<0<<endl;
   // else{
        for(ull i=0;i<w0;i++){
            h=h0;w=w0;
            ANS[i]=ans(i);
        }
        sort(ANS,ANS+w0);
        ull a1=ANS[0];
        for(ull i=0;i<h0;i++){
            h=w0;w=h0;
            ANS[i]=ans(i);
        }
        sort(ANS,ANS+h0);
        ull a2=ANS[0];
        cout<<((a1<a2)?a1:a2)<<endl;
    //}
    return 0;
}


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

#define ll long long
#define sz(x) (int)x.size();

using namespace std;

const int N=105;
int n;
int p[N],s[N],a[N];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		p[i]+=p[i-1]+a[i];
	}
	for(int i=n;i>=1;i--){
		s[i]+=s[i+1]+a[i];
	}
	int ans=1e9;
	for(int i=1;i<=n;i++){
		ans=min(ans,abs(s[i+1]-p[i]));
	}
	cout<<ans;

}

Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val (N, value) = readLine()!!.split(" ").map(String::toInt)
    for (n10000 in 0..N) {
        for (n5000 in 0..(N - n10000)) {
            val n1000 = N - n10000 - n5000
            if (n10000 * 10000 + n5000 * 5000 + n1000 * 1000 == value) {
                print("$n10000 $n5000 $n1000")
                return
            }
        }
    }
    print("-1 -1 -1")
}

Measured memory_bytes: 37892
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << setprecision(15);

    int64_t n;
    cin >> n;
    vector<int64_t> a(n);
    for (int64_t i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int64_t i, j, k;
    auto imax = n - 3;
    auto jmax = n - 2;
    auto kmax = n - 1;
    int64_t count = 0;
/*      for (i = 0; i <= imax; ++i) {
        j = i + 1;
        k = j + 1;
        while (j <= jmax && k <= kmax) {
            cerr << a[i] << "," << a[j] << "," << a[k];
            if (a[i] + a[j] > a[k]) {
                cerr << ": OK" << endl;
                count++;
                k++;
            } else {
                cerr << ": NG" << endl;
                j++;
                k = j + 1;
            }
        }
    }
 */
    for (i = 0; i <= imax; ++i) {
        for (j = i + 1; j <= jmax; ++j) {
            for (k = j + 1; k <= kmax; ++k) {
                //cerr << a[i] << "," << a[j] << "," << a[k];
                if (a[i] + a[j] > a[k]) {
                    //cerr << ": OK" << endl;
                    count++;
                } else {
                    //cerr << ": NG" << endl;
                    break;
                }
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>
#include <cstdio>
 
using namespace std;
typedef long long ll;

int N, M;
struct info_t {
    int L;
    int R;
    int D;
} I[200001];

int parent[100001];
int rnk[100001];
int valuedifftoparent[100001];

int find(int x) {
    if (parent[x] == x) {
        return x;
    } else {
        int p = parent[x];
        parent[x] = find(p);
        valuedifftoparent[x] += valuedifftoparent[p];
        return parent[x];
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

void unite(int x, int y, int diff_xtoy) {
    if (same(x, y)) return;
    diff_xtoy += valuedifftoparent[y] - valuedifftoparent[x];
    x = parent[x];
    y = parent[y];

    if (rnk[x] < rnk[y]) {
        parent[x] = y;
        valuedifftoparent[x] = diff_xtoy;
    } else {
        parent[y] = x;
        valuedifftoparent[y] = - diff_xtoy;
        if (rnk[x] == rnk[y]) rnk[x] ++;
    }
}

bool solve() {
    for (int i = 0; i < N; i ++) {
        parent[i] = i;
        rnk[i] = 0;      
        valuedifftoparent[i] = 0;
    }
    for (int i = 0; i < M; i ++) {
        int l = I[i].L;
        int r = I[i].R;
        int d = I[i].D;
        if (same(l, r)) {
            if (valuedifftoparent[r] - valuedifftoparent[l] != d) {
                return false;
            }
        } else {
            unite(l, r, -d);
        }
    }
    for (int i = 0; i < N; i ++) {
        if (abs(valuedifftoparent[i]) >= 1000000000) {
            return false;
        } 
    }
    return true;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i ++) {
        cin >> I[i].L >> I[i].R >> I[i].D;
        I[i].L --;
        I[i].R --;
    }
    if (solve()) cout << "Yes" << endl; else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int t[100005];
map<int,int> m1;
vector<int> v1,v2;//after,count

int main(){
	int n,m,q;
	int i,j,k;
	int a,b,c;
	cin>>n>>m>>q;
	for(i=0;i<q;i++){
		cin>>t[i];
	}
	v2.push_back(n);
	for(i=q-1;i>=0;i--){
		if(m1.find(t[i])==m1.end()){
			m1[t[i]]=v2.size();
			v1.push_back(t[i]);
			v2.push_back(0);
		}
		b=m1[t[i]];
		if(v2[b-1]>0)v2[b]++,v2[b-1]--;
	}
	for(i=1;i<=m+1;i++){
		if(m1.find(i)!=m1.end())continue;
		m1[i]=v1.size();
		v1.push_back(i);
		break;
	}
	int s=v2.back();
	for(i=v1.size()-1;i>=0;i--){
		if(v1[i-1]>v1[i])break;
		s+=v2[i-1];
	}
	if(s==n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 6128
#include <iostream>
#include <string>
#include <queue>
using namespace std;

class DoubleArray {
    int X,Y;
    int *top;
    public:
    DoubleArray(int *p,int x,int y);
    int *operator[](int i);
    int getx();
    int gety();
};

DoubleArray::DoubleArray(int *p,int x,int y){
    top = p;
    X = x;
    Y = y;
}

int *DoubleArray::operator[](int i){
    return top + Y*i;
}
int DoubleArray::getx(){
    return X;
}
int DoubleArray::gety(){
    return Y;
}

int calc(DoubleArray &map){
    int i,j,a=0;
    int x = map.getx();
    int y = map.gety();
    queue<int> q;
    for(i=0;i<x;i++){
        for(j=0;j<y;j++){
            if(map[i][j]==2){
                q.push(i);
                q.push(j);
                a=1;
                map[i][j]=0;
            }
        }
    }
    while(!q.empty()){
        i=q.front();
        q.pop();
        j=q.front();
        q.pop();
        if(i>0) if(map[i-1][j]==1){
            q.push(i-1);
            q.push(j);
            a++;
            map[i-1][j]=0;
        }
        if(j>0) if(map[i][j-1]==1){
            q.push(i);
            q.push(j-1);
            a++;
            map[i][j-1]=0;
        }
        if(i<x-1) if(map[i+1][j]==1){
            q.push(i+1);
            q.push(j);
            a++;
            map[i+1][j]=0;
        }
        if(j<y-1) if(map[i][j+1]==1){
            q.push(i);
            q.push(j+1);
            a++;
            map[i][j+1]=0;
        }
    }
    return a;
}

int main(){
    int i,j,x,y,a[10000],b = 0;
    string s;
    char c;
    for(b=0; b<10000; b++){
        cin >> x;
        cin >> y;
        if(x==0&&y==0) break;
        if(x>20) x=20;
        if(y>20) y=20;
        if(x<1||y<1) continue;
        int m[x][y];
        DoubleArray map(&m[0][0],x,y);
        for(j=0;j<y;j++){
            cin >> s;
            for(i=0;i<x;i++){
                c = s[i];
                if(c=='#') map[i][j]=0;
                if(c=='.') map[i][j]=1;
                if(c=='@') map[i][j]=2;
            }
        }
        a[b] = calc(map);
    }
    for(i=0;i<b;i++){
        cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n = int(input())
s = input().split()
s = set(s)
if len(s) == 3:
    print("Three")
else:
    print("Four")
    

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
int pow10[]={(int)1e0,(int)1e1,(int)1e2,(int)1e3,(int)1e4,
	(int)1e5,(int)1e6,(int)1e7,(int)1e8,(int)1e9};

inline char getres(lint x){
	printf("? %lld\n",x);
	fflush(stdout);
	char c;
	while((c=getchar())!='Y'&&c!='N');
	return c;
}

int main(){
	if(getres(1e10)=='Y'){
		int l=0,r=9,mid;
		while(l!=r){
			mid=(l+r)>>1;
			if(getres(2*pow10[mid])=='Y') r=mid;
			else l=mid+1;
		}
		printf("! ");
		putchar('1');
		while(l--) putchar('0');
		puts("");
		fflush(stdout);
	}
	else{
		int len;
		{
			int l=0,r=9,mid;
			while(l!=r){
				mid=(l+r+1)>>1;
				if(getres(pow10[mid])=='N') r=mid-1;
				else l=mid;
			}
			len=l;
		}
		if(len==9){
			printf("! %d\n",(int)1e9);
			fflush(stdout);
			return 0;
		}
		int l=pow10[len],r=pow10[len+1]-1,mid;
		while(l!=r){
			mid=(l+r)>>1;
			if(getres(mid*10ll)=='Y') r=mid;
			else l=mid+1;
		}
		printf("! %d\n",l);
		fflush(stdout);
	}
	return 0;
}


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

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

    rep(i, 2001){
        rep(j, 2001){
            int tmp = y - i*10000 -j*5000;
            if(tmp>=0){
                int k = tmp/1000;
                if(i+j+k==n){
                    printf("%d %d %d\n", i, j, k);
                    return 0;
                }
            }
        }
    }
    printf("%d %d %d\n", -1, -1, -1);
    return 0;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
 
int main(){
    long k,l;
    cin >> k;
    cin >> l;
  	if(k == 1 || l == 1)
    {
	    cout << 1;
      
    }
  	else if(k*l % 2==0)
    {
	    cout << k*l / 2;
    }
  	else
    {
	    cout << k*l/2+1;
    }
    return 0;
}

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

using namespace std;

int main() {
  unsigned int n;
  uint64_t l[100] = {2, 1};
  std::cin >> n;
  for (uint8_t i = 2; i <= n; i++) {
    l[i] = l[i-1] + l[i-2];
  }
  std::cout << l[n] << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


ll N;
vector<PLL> V;


ll solve(ll a, ll b){
    int da = 0;
    int db = 0;
    while(a!=0){
        da++;
        a/=10;
    }
    while(b!=0){
        db++;
        b/=10;
    }
    
    return max(da, db);
}



int main() {
    cin >> N;
    for(ll i=1; i*i<=N; i++){
        if(N%i==0){
            V.push_back(PLL(i, N/i));
        }
    }
    
    ll ans = 1e10;
    for(auto p:V){
        ans = min(ans, solve(p.first, p.second));
    }

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


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

typedef long long ll;

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

    for(int i=0;;i++){
        int x,y;
        cin >> x >> y;
        if(x==0 && y==0) break;
        cout << min(x,y) << ' ' << max(x,y) << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
    int n ;
    cin>>n ;
    string a , b , c ;
    cin>>a>>b>>c ;
    int ans = 0 ;
    for(int i = 0 ; i < n ; ++i)
    {
        if(a[i] != b[i] && b[i] != c[i] && a[i] != c[i])
            ans += 2 ;
        else if(a[i] == b[i] && b[i] == c[i] && a[i] == c[i])
            continue;
        else
            ans++;
    }
    return cout<<ans<<"\n" , 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
// const int INF = 1e18+10;

/*----------------------------------------------*/
vi to[200200];
vi cnt(200200,0);
void dfs(int v,int p){
  int c=0;
  for(auto u:to[v]){
    if(u==p) continue;
    dfs(u,v);
    c++;
  }
  cnt[v]=c;
  return;
}

signed main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int a;
    cin>>a;
    a--;
    to[a].pb(i+1);
    to[i+1].pb(a);
  }
  dfs(0,-1);
  rep(i,n) cout<<cnt[i]<<endl;


  return 0;
}


Measured memory_bytes: 27456
##### 解けた #####

import numpy as np

w=np.asarray(list(input()))
NGflag=False

for u in np.unique(w): # 各ユニークワードについて
    if len(np.where(w==u)[0])%2==1: # 奇数個の場合、ダメ
        NGflag=True

if NGflag==True: # ダメな場合
    print("No")
else: # よい場合
    print("Yes")

Measured memory_bytes: 12504
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

int gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

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

	cin >> N;
	vector<int>v(N);
	for (auto& i : v)cin >> i;
	vector<int>st(N);
	st[0] = v[0];
	for (int i = 1; i < N; i++) {
		st[i] = gcd(st[i - 1], v[i]);
	}
	vector<int>rev(N);
	rev.back() = v.back();
	for (int i = N - 2; i >= 0; i--) {
		rev[i] = gcd(rev[i + 1], v[i]);
	}
	int ans = max(rev[1], st[N - 2]);
	for (int i = 0; i + 2 < N; i++) {
		ans = max(ans, gcd(st[i], rev[i + 2]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a;
  cin>>a;
  	int c =1;
  
  	for(int i=1;i<10;i++){
    	for(int j=1;j<10;j++){
        	if(i*j==a){
            	cout<<"Yes";
              c=0;
              break;
            } 
        }
        if(c==0) break;
    }
  if(c==1) cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fr(i,n) for (int i=0;i<n;i++)
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void pre() {
}
void solve() {
	int n;
	cin >> n;
	cout << 2 * PI*n << endl;
}
signed main()
{
	fastio;
	cout << fixed << setprecision(3);
	//clock_t begin = clock();
	//pre();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


Measured memory_bytes: 3808
#include <iostream>

int main() {
    int r, g, b;
    std::cin >> r >> g >> b;

    int num = b + (10 * g) + (100 * r);
    if (num % 4) {
        std::cout << "NO\n";
    } else {
         std::cout << "YES\n";
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int N, M;
ll x[1005], y[10005], z[10005];
ll ans = -100000000000000000;

int main(void) {
    cin >> N >> M;
    rep(i, 0, N) scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);

    for (int i=0; i<(1<<3); i++) {
        ll X = 1, Y = 1, Z = 1, sum = 0;
        vector<ll> v;
        if ((i>>0)&1) X = -1;
        if ((i>>1)&1) Y = -1;
        if ((i>>2)&1) Z = -1;
        rep(j, 0, N) v.pb(x[j]*X+y[j]*Y+z[j]*Z);
        sort(v.bg, v.en, greater<ll>());
        rep(j, 0, M) sum += v[j];
        ans = max(ans, sum);
    }

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

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main() {
	int n, k, r = 1;
	
	scanf("%d", &n); getchar();
	scanf("%d", &k);
	
	for(int i = 0; i < n; i++) {
		if(r*2 < r+k) r *= 2;
		else r += k;
	}
	
	printf("%d\n", r);
	return 0;
}

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

int N;
vector<string> name;
Graph G;

void dfs(int v, int depth) {
  cout << string(depth, '.') << name[v] << endl;
  for(int i = 0; i < G[v].size(); ++i) {
    dfs(G[v][i], depth+1);
  }
}

int main() {
  cin >> N;
  name = vector<string>(N);
  G = Graph(N);
  for(int i = 0; i < N; ++i) {
    int par; cin >> par; --par;
    cin >> name[i];
    if(par != -1) G[par].push_back(i);
  }
  dfs(0, 0);
  return 0;
}

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

int main() {
  int n, a, b;
  cin>>n>>a>>b;
  if (a > n - b + 1) {
    cout<<-1<<endl;
    return 0;
  }
  if (a > 1 && (n - b - 1) / (a - 1) + 1 > b) {
    cout<<-1<<endl;
    return 0;
  }
  vector<int> v;
  for (int i=b; i>0; --i) {
    v.push_back(i);
  }
  int used = b;
  for (int i=1; i<a; i++) {
    int len = (n - used - 1) / (a - i) + 1;
    for (int j=len; j>0; j--) {
      v.push_back(used+j);
    }
    used += len;
  }
  for (int i=0; i<n; i++) {
    cout<<v[i];
    if (i != n - 1) {
      cout<<" ";
    }
  }
  cout<<endl;
}

Measured memory_bytes: 3440
eval"H,W,K="+`tr \\  ,`
c=[]
b=->i{i<1?1:c[i]||=b[i-2]+b[i-1]}
d={}
f=->i,j{
  j<1||j>W ? 0 :
  i==0 ? j==1 ? 1 : 0 :
  d[[i,j]]||=
    (f[i-1,j]*b[j-2]*b[W-j-1]+f[i-1,j-1]*b[j-3]*b[W-j-1]+f[i-1,j+1]*b[j-2]*b[W-j-2])%(10**9+7)
}
p f[H,K]


Measured memory_bytes: 4184
#include <iostream>
#include <utility>
#include <vector>
#include <set>

using namespace std;

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

  vector<set<unsigned>*> S;
  vector<bool> P;
  
  for (unsigned m=0; m<M; ++m) {
    unsigned k;
    cin >> k;
    S.push_back(new set<unsigned>);
    for (int kk=0; kk<k; ++kk) {
      unsigned s;
      cin >> s;
      S.back()->insert(--s);
    }
  }

  for (unsigned m=0; m<M; ++m) {
    unsigned p;
    cin >> p;
    P.push_back(p==1);
  }

  unsigned count = 0;
  for (unsigned c=0; c<(1<<N); ++c) {
    bool all_on = true;
    for (int m=0; all_on && m<M; ++m) {
      unsigned switch_count = 0;
      for (int n=0; n<N; ++n) {
	bool on = (c&(1<<n))!=0;
	if (on && S[m]->count(n)==1) {
	  ++switch_count;
	}
      }
      if (switch_count%2 != P[m])
	all_on = false;
    }
    if (all_on)
      ++count;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
int main()
{
    ll n,d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        ll x, y;
        cin >> x >> y;
        double dis = sqrt(x*x+y*y);
        if (dis <= d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int kazu[] = new int[n];
        for (int i = 0; i < n; i++) {
            kazu[sc.nextInt() - 1] += 1;
        }
        Arrays.sort(kazu);

        int sum = 0;
        for (int i = 0; i < n - k; i++) {
            sum += kazu[i];
        }
        System.out.println(sum);
    }
}

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

int main() {
  int X, a, b;
  cin >> X;
  a = X/500;  //aは500円玉の枚数
  b = (X - a*500)/5;
  
  cout << a*1000 + b*5 << endl;
}

  
  
 

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    vector<int> a(n),b(n);
    REP(i, n) {
        cin >> a[i] >> b[i];
    }
    lint ans=0;

    IREP(i,n){
        lint ai=a[i], bi=b[i];
        ai += ans;
        if(ai%bi!=0){
            ans += bi - (ai % bi);
        }
    }


    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] ST = br.readLine().split(" ") ; 
		int Sx = Integer.parseInt(ST[0]);
		int Sy = Integer.parseInt(ST[1]);
		int Tx = Integer.parseInt(ST[2]);
		int Ty = Integer.parseInt(ST[3]);
		
		String ans = "";
		//1往復目
		for(int firstR = 0; firstR<Tx-Sx; firstR++) {
			ans+="R";
		}
		for(int firstU = 0; firstU<Ty-Sy; firstU++) {
			ans+="U";
		}
		for(int firstL = 0; firstL<Tx-Sx; firstL++) {
			ans+="L";
		}
		for(int firstD = 0; firstD<Ty-Sy; firstD++) {
			ans+="D";
		}
		
		//2往復目
		ans+="D";
		for(int secondR = 0; secondR<Tx+1-Sx; secondR++) {
			ans+="R";
		}
		for(int secondU = 0; secondU<Ty+1-Sy; secondU++) {
			ans+="U";
		}
		ans += "L";
		ans += "U";
		for(int secondL = 0; secondL<Tx+1-Sx; secondL++) {
			ans+="L";
		}
		for(int secondD = 0; secondD<Ty+1-Sy; secondD++) {
			ans+="D";
		}
		ans+="R";
		
		System.out.println(ans);	
		
	}
}


Measured memory_bytes: 53352
#include <iostream>

long compute(long x)
{
    if (x % 4 == 0) {
        return x;
    } else if (x % 4 == 1) {
        return 1;
    } else if (x % 4 == 2) {
        return 1 ^ x;
    } else { // x % 4 == 3
        return 0;
    }
}

int main()
{
    long A, B;

    std::cin >> A >> B;

    long ans = compute(A - 1) ^ compute(B);
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
def calc_loop_cost(loop, min_w):
    if len(loop) == 1:
        return 0
    elif len(loop) == 2:
        return loop[0] + loop[1]
    else:
        cost1 = sum(loop) + (len(loop) - 2) * min(loop)
        cost2 = sum(loop) + min(loop) + (len(loop) + 1) * min_w
        return min(cost1, cost2)

n = int(input())
org_list = [int(s) for s in input().split()]
sorted_list = sorted(org_list)
check_list = [False] * n
loop_list = []
for i in range(n):
    if check_list[i]:
        continue

    loop = []
    check_list[i] = True
    loop.append(org_list[i])
    next_idx = sorted_list.index(org_list[i])
    while next_idx != i:
        check_list[next_idx] = True
        loop.append(org_list[next_idx])
        next_idx = sorted_list.index(org_list[next_idx])

    loop_list.append(loop)

min_w = sorted_list[0]
cost_sum = 0
for lp in loop_list:
    cost_sum += calc_loop_cost(lp, min_w)

print(cost_sum)


Measured memory_bytes: 5724
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for (int i = n - m; i >= 0; --i) {
        bool ok = true;
        rep(j, m) {
            if (s[i+j] != t[j] && s[i+j] != '?') {
                ok = false;
                break;
            }
        }
        if (ok) {
            rep(j, m) {
                s[i+j] = t[j];
            }
            rep(j, n) {
                if (s[j] == '?') cout << 'a';
                else             cout << s[j]; 
            }
            cout << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    CIN(A,B,C,K);
    int max_num=max({A,B,C});
    int sum=A+B+C-max_num+max_num*pow(2,K);
    printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

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

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

    int ans = 1;
    ans += (k - b - 1) / (a - b) * 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(){
    ll K, N;
    cin >> K >> N;

    vl A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);

    ll da = 0;
    ll db = 0;
    vl D(N+1);
    D.at(0) = A.at(0);
    ll max = D.at(0);
    ll point = N-1;
    for(ll i=1; i<N; i++){
        D.at(i) = A.at(i) - A.at(i-1);
        if(max <= D.at(i)){
            max = D.at(i);
            point = i;
        }
    }
    D.at(N) = K - A.at(N-1);

    for(ll i=0; i<=N; i++){
        if(i != 0 and i != N){
            da += D.at(i);
        }
        if(i != point){
            db += D.at(i);
        }
    }
    cout << min(da, db) << endl;

}

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

int main() {
	int N;
	cin >> N;
	vector<int> Q(N);
	for (int i = 0; i < N; i++) {
		int P;
		cin >> P;
		Q[P - 1] = i;
	}
	int ans = 0, before = Q[0], num = 1;
	for (int i = 1; i < N; i++) {
		if (before < Q[i]) num++;
		else {
			ans = max(ans, num);
			num = 1;
		}
		before = Q[i];
	}
	ans = max(ans, num);
	cout << N - ans << endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
typedef struct point{int x,y;}point;
int main(){
    point con[200],sky[1000];
    int m,n,i,j,k,flag;
    while (1) {
        scanf("%d",&m);
        if (m==0) {
            return 0;
        }
        for (i=0; i<m; i++) {
            scanf("%d %d",&con[i].x,&con[i].y);
        }
        scanf("%d",&n);
        for (i=0; i<n; i++) {
            scanf("%d %d",&sky[i].x,&sky[i].y);
        }
        for (i=0; i<n; i++) {
            for (j=1; j<m; j++) {
                flag=0;
                for (k=0; k<n; k++) {
                    if (sky[k].x==sky[i].x+con[j].x-con[0].x&&sky[k].y==sky[i].y+con[j].y-con[0].y) {
                        flag=1;
                        break;
                    }
                }
                if (!flag) {
                    break;
                }
            }
            if (flag) {
                printf("%d %d\n",sky[i].x-con[0].x,sky[i].y-con[0].y);
                break;
            }
        }
    }
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define eps 1e-9
#define pi acos(-1)
#define nmax 1000000
#define f(c,a,b) for(int c=a; c<=b; c++)

using namespace std;
typedef double db;
struct P{
    db x, y;
    P(){}
    P(db x, db y) : x(x) , y(y) {}
    P operator - (P a){ return P(x-a.x, y-a.y); }
    db times(P a){ return x*a.y-y*a.x; }
    P operator * (db a){ return P(x*a, y*a); }
    P operator + (P a){ return P(x+a.x, y+a.y); }
    void pri(){ printf("%.10lf %.10lf\n", x, y); }
}po[nmax];
P pa[nmax];
typedef P V;
int n;

int sign(db x){ return x<-eps ? -1 : x>eps; }

db area(int n, P po[]){
    db ans = 0;
    f(i,0,n) ans += (po[i]-po[0]).times(po[(i+1)%(n+1)]-po[0]);
    return ans/2.0;
}

P isLL(P p1, P q1, P p2, P q2){
    //p1.pri(); q1.pri(); p2.pri(); q2.pri();
    P tmp=p1+(q1-p1)*( (q2-p1).times(p2-q2)/(q1-p1).times(p2-q2) );
    //cout<<"test   ";
    //tmp.pri();
    return tmp;
}

db convexcut(P p, P q){//p->q  右边舍弃
    int al = -1;
    f(i,0,n-1){
        int t1 = sign( (q-p).times(po[i]-p) );
        int t2 = sign( (q-p).times(po[(i+1)%n]-p) );
        //cout<<t1<<' '<<t2<<endl;
        if(t1 >= 0) pa[++al] = po[i];
        if(t1*t2 < 0) pa[++al] = isLL(po[i],po[(i+1)%n],p,q);  
        //pa[al].pri();
    }
    return area(al,pa);
}

int main(){
    //freopen("owo.in","r",stdin);
    cin >> n;
    f(i,0,n-1) scanf("%lf%lf", &po[i].x, &po[i].y);
    int q;
    cin >> q;
    while(q--){
        P in1, in2;
        scanf("%lf%lf%lf%lf", &in1.x, &in1.y, &in2.x, &in2.y);
        printf("%.8f\n", convexcut(in1, in2) );
    }
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re register
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 2000+7;
/*
int head[M],cnt=1;
void init(int n){cnt=1;for(int i=0;i<=n;i++)head[i]=0;}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
const int mod=1e9+7;
ll qpow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ans;
}
ll dp[M];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	cin>>n;
  	dp[3]=1;
  	dp[4]=1;
  	dp[5]=1;
  	dp[6]=2;
  	
  	for(int i=7;i<=n;i++)dp[i]=(dp[i-1]+dp[i-3])%mod;
  	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    ll n;
    cin>>n;
    vll a(n);
    rep(i,0,n)cin>>a[i];
    ll mod=1e9+7;
    sort(a.begin(),a.end());
    bool check=true;
    if(n%2){
        for(ll i=0;i<(n-1)/2;i++){
            ll left=i*2+1;
            if(a[left]==a[left+1])continue;
            else {
                check=false; break;
            }
        }
    }
    else {
        for(ll i=0;i<n/2;i++){
            ll left=i*2;
            if(a[left]==a[left+1])continue;
            else {
                check=false; break;
            }
        }
    }
    if(check){
        ll ans;
        if(n%2){
            ans=modpow(2,(n-1)/2,mod);
        }
        else {
            ans=modpow(2,n/2,mod);
        }
        cout<<ans<<endl;
    }
    else {
        cout<<0<<endl;
    }
    return 0;
}




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

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

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

  string ans1, ans2, in;
  map<string, int> gedo;
  while (cin >> in) {
    if (ans2.size() < in.size()) ans2 = in;
    gedo[in]++;
  }

  int tm = 0;
  for (auto it = gedo.begin(); it != gedo.end(); ++it)
    if (tm < (*it).second) {
      ans1 = (*it).first;
      tm = (*it).second;
    }

  cout << ans1 << " " << ans2 << endl;

  return 0;
}

Measured memory_bytes: 3080
#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(){
  int N;
  cin >> N;
  vector<vector<int>> to(N),cost(N);//隣接行列とコストの行列を作る
  rep(i,N-1){
    int a,b,w;
    cin >> a >> b >> w;
    a--;b--;
    to[a].push_back(b);cost[a].push_back(w);
    to[b].push_back(a);cost[b].push_back(w);
  }
  vector<int> ans(N,-1);
  queue<int> q;
  ans[0]=0;q.push(0);//木の根を0とする
  while(!q.empty()){
    int v=q.front();q.pop();
    rep(i,to[v].size()){
      int u=to[v][i];
      int w=cost[v][i];
      if(ans[u]!=-1) continue;//色が塗られていた時
      ans[u]=(ans[v]+w)%2;//色を塗る
      q.push(u);
    }
  }
  rep(i,N) cout << ans[i] << endl;
  return 0;
}

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

int main() {
    int n,a;
    int count=0;
    cin >> n >> a;
    count+=n%500;
    //cout << count <<" "<< a << endl;
    if (count<=a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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


int main()
{
    int n;
    cin >> n;
    int o=0,yon=0,ni=0;
    rep(i,n)
    {
        int a;
        cin >> a;
        if(a%2==1)o++;
        if(a%4!=0&&a%2==0)ni++;
        if(a%4==0)yon++;
    }
    if(yon>=o||(ni==0&&yon+1==o))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;

int main() {
    int N;
    cin >> N;
    vi A(N), x(N);
    ll Asum = 0, sumexcN = 0;
    rep(i, N) {
        cin >> A[i];
        Asum += A[i];
        if(i % 2 == 0 && i != N - 1) sumexcN += A[i];
    }

    x[N-1] = Asum/2 - sumexcN;
    repr(i,N-1) {
        x[i] = A[i] - x[i+1];
    }
    rep(i,N) {
        x[i] *= 2;
        cout << x[i] << " ";
    }

    return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  int N;
  cin >> N;
  vint A;
  rep(i, N) {
    int a; cin >> a;
    if(A.empty() || A.back() != a) A.push_back(a);
  }
  if(N == 1) {
    cout << 1 << endl;
    return 0;
  }
  if(A[A.size()-2] < A[A.size()-1]) A.push_back(A[A.size()-1]+1);
  else A.push_back(A[A.size()-1]-1);
  bool up = A[0] < A[1];
  int cnt = 1;
  reps(i, 1, A.size()) {
    //cout<<i<<" "<<up<<" "<<A[i-1]<<" "<<A[i]<<endl;
    if(up) {
      if(A[i-1] > A[i]) i++, cnt++, up = A[i-1] < A[i];
    } else {
      if(A[i-1] < A[i]) i++, cnt++, up = A[i-1] < A[i];
    }
  }
  cout << cnt << endl;

  return 0;
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    vi a(n + 1);
    map<int,int> mp;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        ans += mp[i - a[i]];
        mp[i + a[i]] ++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 27468
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

double x[1010], y[1010];
int main()
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    cout << fixed << setprecision(7);

    long double n;
    while (cin >> n)
    {
        if (n == -1)
            break;
        long double x[101000];
        long double t = n;
        x[1] = t / 2.0;
        int idx = 2;
        while (1)
        {
            x[idx] = x[idx - 1] - (x[idx - 1] * x[idx - 1] * x[idx - 1] - n) / (3 * (x[idx - 1] * x[idx - 1]));

            if (abs(x[idx] * x[idx] * x[idx] - n) < 0.00001 * n)
                break;
            idx++;
        }
        cout << x[idx] << endl;
    }
    return 0;
}


Measured memory_bytes: 3196