akhauriyash/Code-Regression huggingface dataset:
#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>
#include <numeric>
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 = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

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

void solve() {
    int n; cin >> n; if (n == 0) exit(0);
    map<string, vector<string>> mp;
    map<string, int> deg;
    string pp;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        string p, t;
        bool c = false;
        for (int i = 0; i < s.size(); i++) {
            if (!c) {
                if (s[i] == ':') c = true;
                else p += s[i];
            }
            else {
                if (s[i] == ',' or s[i] == '.') {
                    mp[p].emplace_back(t);
                    t.clear();
                }
                else {
                    t += s[i];
                }
            }
        }
        if (i == 0) pp = p;
    }
    queue<string> q;
    q.emplace(pp);
    set<string> st;
    set<string> used;
    while (!q.empty()) {
        string s = q.front();
        q.pop();
        if (!mp.count(s)) {
            st.emplace(s);
        }
        else {
            for (auto& p : mp[s]) {
                if (used.find(p) != used.end()) continue;
                used.emplace(p);
                q.emplace(p);
            }
        }
    }
    cout << st.size() << "\n";
}
int main()
{
    
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int kkt = 89;
    while (kkt) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3284
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    boolean tmp = true;
    int i = 0;

    while(tmp == true){
      int x = sc.nextInt();
      if(x == 0){
        tmp = false;
        break;
      }

      i += 1;
      System.out.println("Case " + i + ": " + x);
    }
  }
}



Measured memory_bytes: 41352
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    double ans = 0;
    vector<int> per;
    rep(i, n) per.push_back(i);

    double m = 0;
    do{
        m++;
        rep(i, n-1){
            double x_2 = (x[per[i]] - x[per[i+1]]) * (x[per[i]] - x[per[i+1]]);
            double y_2 = (y[per[i]] - y[per[i+1]]) * (y[per[i]] - y[per[i+1]]);
            ans += sqrt(x_2 + y_2);
        }
    }while(next_permutation(all(per)));

    cout << setprecision(9) << ans/m << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){
  int p,i,j,sosu=0,x;
  scanf("%d",&p);
  sosu=p;
  for(i=0;i<p;++i){
    scanf("%d",&x);
    for(j=2;j*j<=x;j++){
      if(x%j==0){
      sosu--;
      break;
    }
  }
}
printf("%d\n",sosu);
return 0;
}


Measured memory_bytes: 2112
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        int max = -1;
        for(int i=0;i<n-1;i++){
            max = Math.max(a[i+1]-a[i],max);
        }
        max = Math.max(k-a[n-1]+a[0],max);
        System.out.println(k-max);

    }

}


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

public class MainClass
{
	public static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] rt = Input();
		int[] d= new int[n];
		for(int i = 0; i < n; i++)
		{
			d[i]= int.Parse(rt[i]);
		}
		Array.Sort(d);
		
		int half = n/2;
		Console.WriteLine(d[half]-d[half-1]);
	}

	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

	
}



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

int main(){
  // start process
  int n;
  int i,j;
  cin >> n;
  vector<int> h(n);
  for(i=0; i<n; i++){
    cin >> h[i];
  }
  int counter = 1;
  for(i=1; i<n; i++){
    for(j=0; j<i; j++){
      if(h[i]<h[j]){
        break;
      }
      if(j==i-1){
        counter++;
      }
    }
  }
  cout << counter << endl;
  // end process
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main (String[] args) throws Exception {
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    String [] st = new String[n];
    //boolean ans = true;
    
    for(int i=0; i<n; i++){
      st[i] = sc.next();
      }
      
    
 
    for(int i=0; i<n-1; i++){
        if(st[i+1].charAt(0)!=st[i].charAt(st[i].length()-1)){
          //ans =false;
          System.out.println("No");
          System.exit(0);
        }
        //if(i==n-1)break;
        for(int j=i+1; j<n; j++){
          //System.out.println(st[i] +" " +st[j]);
          if(st[i].equals(st[j])){
            //ans =false;
          System.out.println("No");
          System.exit(0);
        }
      }
    }
    
    
    
      System.out.println("Yes");


  }
}

Measured memory_bytes: 22740
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		string[]a = new string[N];
		string ans = "Yes";
		for(var i=0;i<N;i++){
			string str2 = Console.ReadLine();
			a[i] = str2;
			for(var j=0;j<i;j++){
				if(a[j] == a[i]){
					ans = "No";
					break;
				}
			}
			if(i>=1){
				if(a[i-1].Substring(a[i-1].Length-1,1) != a[i].Substring(0,1)){
					ans = "No";
				}
			}
			if(ans == "No"){
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int N,A[100010];
  cin >> N;
  rep(i,N){
    cin >> A[i];
  }
  ll ans=0,cnt=0;
  rep(i,N){
    if(A[i]!=0){
      cnt+=A[i];
    }else{
      ans+=cnt/2;
      cnt=0;
    }
  }
  ans+=cnt/2;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>

using namespace std;


#define INF pow(10, 9)
// typedef priority_queue<tuple<int,int,int>, vector< tuple<int, int, int> >, greater< tuple<int, int, int> > > PQ;

typedef long long int ll;




int main(void)
{

    int S;
    cin >> S;

    int Len_Max = S/3;
    int dp[Len_Max][S];
    int div = pow(10, 9)+7;

    for(int k=0; k<S; k++)
    {
        dp[0][k] = 1; // 1項だけ
    }

    for(int i=1; i<Len_Max; i++)
    {
        dp[i][0] = dp[i-1][0];
        for(int k=1; k<S; k++)
        {
            dp[i][k] = (dp[i][k-1]+dp[i-1][k])%div;
        }

    }

    if(S < 3)
    {
        cout << 0 << endl;
    }
    else
    {
        int comb = 0;
        int v = S;
        for(int Len=1; Len<=Len_Max; Len++)
        {
            v -= 3;
            comb = (comb+dp[Len-1][v])%div;
        }
        cout << comb <<endl;
    }





    return 0;
}


Measured memory_bytes: 8816
//
// Created by Huang,Zhiqiang on 2018/6/24.
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int n, k;
int a[100005];

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ans = 1;
    int rest = n - k;
    if (rest % (k - 1) == 0) ans += rest / (k - 1);
    else ans += rest / (k - 1) + 1;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int dbl[114514][19];
int x[114514];
int main()
{
	int n,l,q,a,b;
	scanf("%d",&n);
	rep(i,n) scanf("%d",&x[i]);
	scanf("%d",&l);
	int now=0;
	rep(i,n){
		while(now<n-1 && x[now+1]<=x[i]+l) now++;
		dbl[i][0]=now;
	}
	dbl[n-1][0]=dbl[n][0]=n;
	rep(i,19) dbl[n][i]=n;
	rep(i,18) rep(j,n) dbl[j][i+1]=dbl[dbl[j][i]][i];
	//rep(j,3) rep(i,n) cout<<i<<' '<<j<<' '<<dbl[i][j]<<endl;
	scanf("%d",&q);
	//cout<<q<<endl;
	rep(i,q){
		scanf("%d %d",&a,&b);
		if(a>b) swap(a,b);a--;b--;
		int ret=1;
		//cout<<a<<' '<<b<<endl;
		for(int i=18;i>=0;i--){
			if(dbl[a][i]<b) a=dbl[a][i],ret+=(1<<i);
		}
		printf("%d\n",ret);
	}
}


Measured memory_bytes: 8576
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            StringBuffer t = new StringBuffer();
            String s = sc.next();
            while (n-- > 0) {
                t = new StringBuffer();
                for (int i = 0; i < s.length(); i++) {
                    int c = 1;
                    char a = s.charAt(i);
                    while (i + 1 < s.length() && a == s.charAt(i + 1)) {
                        c++;
                        i++;
                    }
                    t.append(c + "" + a);
                }
                s = t.toString();
            }
            System.out.println(t);
        }

    }
}



Measured memory_bytes: 38940
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int n, q;
string s;
char t[200001];
char d[200001];

bool cangoal(int start, int goal)
{
	int now = start;
	for(int i = 0; i < q; i++){
		if(t[i] == s[now]){
			if(d[i] == 'L') now--;
			else now++;
			if(now == goal) return true;
			if(now == -1 || now == n) return false;
		}
	}
	return false;
}


int solve(int goal)
{
	int l = -1;
	int r = n;
	while(r - l > 1){
		int m = (l + r) / 2;
		if(cangoal(m, goal)){
			if(goal == -1) l = m;
			else r = m;
		} else {
			if(goal == -1) r = m;
			else l = m;
		}
	}
	if(goal == -1) return r;
	return l;
}

int main()
{
	cin >> n >> q >> s;
	for(int i = 0; i < q; i++){
		cin >> t[i] >> d[i];
	}

	int l = solve(-1);
	int r = solve(n);
	// (-1, l)と(r, n)がゴールできる範囲
	// つまり、ゴールできないのは[l, r]
	cout << max(0, r - l + 1) << endl;
}

Measured memory_bytes: 900
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0]*Q
C = [0]*Q
for i in range(Q):
    B[i],C[i] = map(int, input().split())
    
cnt = [0]*(10**5+3)
for i in A:
    cnt[i]+=1
ans = sum(A)
for i in range(Q):
    ans += (C[i]-B[i])*cnt[B[i]]
    print(ans)
    cnt[C[i]] += cnt[B[i]]
    cnt[B[i]] = 0

Measured memory_bytes: 22180
S = input()
N = len(S)

ans = 0
for i in range(N+1):
    for j in range(i+1, N+1):
        l = 0
        for c in 'ACGT':
            l += S[i:j].count(c)
        if l == j - i:
            ans = max(ans, l)
print(ans)

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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	LL n, d;
	cin>>n>>d;
	d*=d;
	LL x, y;
	int w = 0;
	for(int i=0; i<n; i++) {
		cin>>x>>y;
		LL z = x*x + y*y;
		if(z <= d)
			w++;
	}
	cout<<w;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	vector<int> c(m);
	rep(i,m){
		cin >> a.at(i) >> b.at(i) >> c.at(i);
		a.at(i)--;
		b.at(i)--;
	}
	int MAX=1000000000;
	vector<vector<int>> dist(n,vector<int>(n));
	rep(i,n){
		rep(j,n){
			dist[i][j]=MAX;
		}
		dist[i][i]=0;
	}
	rep(i,m){
		dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
		dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
	}
	rep(k,n){
		rep(i,n){
			rep(j,n){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	
	int ans=m;
	rep(i,m){
		bool flg=false;
		rep(j,n){
			if(dist[j][a[i]]+c[i]==dist[j][b[i]]) flg=true;
		}
		if(flg) ans--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]

x = 0
y = 0
for i in range(n):
    t = l[i][0]
    x = l[i][1]
    y = l[i][2]
    d = x + y
    if d <= t and (d - t) % 2 == 0:
        continue
    else:
        print('No')
        quit()
print('Yes')


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

public class Program {
    static Dictionary<int, List<int>> nodes;

    public static void Main() {
        Console.ReadLine();
        var tArr = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        var m = int.Parse(Console.ReadLine());
        var allScore = tArr.Sum();

        for(int i = 0; i< m; i++) {
            var drink = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            var score = allScore - tArr[drink[0]-1] + drink[1];
            Console.WriteLine(score);
        }   
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0,i=1;
	cin>>n;
	while(i<n+1)
	{
		int size = trunc(log10(i)) + 1;
		if(size%2==1)
		++ans;
		++i;
	}
	cout<<ans;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
#include<vector>
//#include<string>
//#include<sstream>
using namespace std;

#define ll long long
const int mod = 1e9 + 7;
const int maxn = 1e3 + 10;
int num[maxn];
int n, x;
ll  ans = 1;

int main(){
	cin >> n;
	for (int i = 2; i <= n; ++i){
		x = i;
		for (int j = 2; j <= x; ++j)
		{
			while (x%j == 0){ num[j]++; x /= j; }
		}
		if (x != 1)num[x]++;
	}
	for (int i = 1; i <= n; ++i)
	{
		if (num[i])ans = (ans*((num[i] + 1) % mod)) % mod;
	}
	cout << ans << endl;
}

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

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

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

    if(b-a == c-b) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

#define MAX_N 100005

int parent[MAX_N];
int ran[MAX_N];

void init(int n){
    int i;
    rep(i,n){
        parent[i]=i;
        ran[i]=0;
    }
}

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

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

struct edge{ int u,v,cost;};

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

edge es[2*MAX_N];
int v,e=0;

int kruskal(){
    sort(es,es+e,comp);
    init(v);
    int res=0,i;
    rep(i,e){
        edge e=es[i];
        if(find(e.u) != find(e.v)){
            unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}

int main(void) {
    int i,j;
    int n;
    cin>>n;
    v=n;

    vector<pair<pii,int> > p(n);
    rep(i,n)cin>>p[i].first.first>>p[i].first.second,p[i].second=i;

    sort(all(p));
    rep(i,n-1){
        es[e].u=p[i].second;
        es[e].v=p[i+1].second;
        es[e].cost=min(abs(p[i].first.first-p[i+1].first.first), abs(p[i].first.second-p[i+1].first.second));
        e++;
    }
    rep(i,n)swap(p[i].first.first,p[i].first.second);
    sort(all(p));
    rep(i,n-1){                 
         es[e].u=p[i].second;              
         es[e].v=p[i+1].second;
         es[e].cost=min(abs(p[i].first.first-p[i+1].first.first), abs(p[i].first.second-p[i+1].first.second));
         e++;
    }

    cout<<kruskal()<<endl;
}



Measured memory_bytes: 4480
def calc(pat,S):
    ans = 0
    n = int(S[0])
    for i in range(len(S)-1):
        if pat[i] == '0':
            n = n*10+int(S[i+1])
        else:
            ans += n
            n = int(S[i+1])
    ans += n
    return ans

S = input()
SList=[ int(S[i]) for i in range(len(S))]

n = len(S)-1
binformat = '0'+str(n)+'b'

ans = 0
for i in range(2**n):
    pat = format(i,binformat)
    ans += calc(pat,SList)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N;
  cin >> N;
  auto did = mvec<bool>(N);
  auto uvw = mvec<P>(N,0);
  rep(i, 0, N-1){
    ll u, v, w;
    cin >> u >> v >> w;
    uvw[u-1].push_back(P(v-1,w%2));
    uvw[v-1].push_back(P(u-1,w%2));
  }
  auto ans = mvec<bool>(N);
  auto func = [&](auto& func, ll u) -> void{
    for(auto&& i : uvw[u]){
      auto& v = i.first;
      auto& w = i.second;
      if(w) ans[v] = !ans[u];
      else ans[v] = ans[u];
      if(did[v]==0){
        did[v] = 1;
        func(func, v);
      }
    }
  };
  func(func, 0);
  for(auto&& i : ans){
    cout << i << rt;
  }
}

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

using namespace std;

int main() {
    char str[4];
    scanf("%s", str);   

    if(strcmp(str, "AAA") == 0
      || strcmp(str, "BBB") == 0) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Process{
	int time;
	String name;
	public Process(String name,int time){
		this.time = time;
		this.name = name;
	}
}

class Queue{
	private Process[] queArray;
	private int front;
	private int rear;
	private int maxSize;
	private int nItems;
	
	public Queue(int size){
		maxSize = size;
		queArray = new Process[maxSize];
		front = 0;
		rear = -1;
		nItems = 0;
	}
	public void insert(Process p){
		if(rear == maxSize -1) rear = -1;
		queArray[++rear] = p;
		nItems++;
	}
	public Process remove(){
		Process temp = queArray[front++];
		if(front == maxSize) front = 0;
		nItems--;
			return temp;
	}
	public boolean isEmpty(){
		//return (rear+1==front || (front+maxSize-1==rear));
		return (nItems == 0);
	}
}

 class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int q = in.nextInt();
		Queue que = new Queue(n);
		int finTime = 0;
		for(int i = 0;i<n;i++){
			que.insert(new Process(in.next(),in.nextInt()) );
		}
		
		while(!que.isEmpty()){
			Process remove = que.remove();
			int c = Math.min(q, remove.time);
			remove.time -= c;
			finTime += c;
			if(remove.time>0){
				que.insert(remove);
			}else{
				System.out.println(remove.name+ " " +finTime);
			}
	}

	}
}

Measured memory_bytes: 73808
import sys
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    N = int(input())
    H = list(map(int, input().split()))

    dp = [float("inf")] * (N)
    dp[0] = 0

    for i in range(1, N):
        if i > 1:
            dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
        else:
            dp[i] = dp[i-1] + abs(H[i] - H[i-1])
    print(dp[N-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 51536
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 2010
#define MOD 1000000007
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,k,mx,f[MAX][MAX];
int jc[MAX*MAX],jv[MAX*MAX],inv[MAX*MAX];
int C(int n,int m){return 1ll*jc[n]*jv[m]%MOD*jv[n-m]%MOD;}
int main()
{
	n=read();k=read();mx=n*k;
	if(k==1){puts("1");return 0;}
	jc[0]=jv[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=mx;++i)jc[i]=1ll*jc[i-1]*i%MOD;
	for(int i=2;i<=mx;++i)inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;
	for(int i=1;i<=mx;++i)jv[i]=1ll*jv[i-1]*inv[i]%MOD;
	f[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=i;++j)
		{
			add(f[i][j],f[i-1][j]);
			if(j)add(f[i][j],1ll*f[i][j-1]*(n-j+1)%MOD*C((n-i)+(n-j+1)*(k-1)-1,k-2)%MOD);
		}
	printf("%d\n",f[n][n]);
	return 0;
}


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

ans_l = 0
ans_r = n
for _ in range(m):
    l, r = map(int, input().split())
    ans_l = max(ans_l, l)
    ans_r = min(ans_r, r)
print(max(0,ans_r-ans_l+1))


Measured memory_bytes: 3060
def main():
    N,M=map(int,input().split())
    a=[0]*M
    b=[0]*M
    r=[0]*M
    for i in range(M):
        a[i],b[i]=map(int,input().split())
        r[i]=[a[i],b[i]]
    r.sort(key=lambda x:x[1])
    point=float("-inf")
    pyout=0
    for fight in r:
        if fight[0]>point:
            point=fight[1]-1
            pyout+=1
    print(pyout)
if __name__=='__main__':
    main()


Measured memory_bytes: 22820
fun main(args: Array<String>) {
    val n = readLine()?.toLong() ?: return
    if (n % 2L == 1L) {
        println("0")
    } else {
        var d = 5L
        var total = 0L
        while (d <= n) {
            total += (n / d) / 2
            d *= 5L
        }
        println(total.toString())
    }
}

Measured memory_bytes: 31588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(x) (x).begin (),(x).end()
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define endl "\n"
#define si set<ll>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define M 1000000007LL

void solve()
{
    ll n; cin>>n; bool flag=false;
    while(n>0)
    {
        if(n%10==7) flag = true;
        n/=10;
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
}

int main()
{
    SPEED;
    ll t = 1;

   // cin>>t;

    while(t--) solve();

   return 0;
}


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

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a.at(i);
	}
	int max=0,b,sum=0,fl=1;
	for(int j=0;j<n;j++){
		for(int i=0;i<n;i++){
			if(max<a.at(i)){
				max=a.at(i);
				b=i;
				
			}
		}
		a.at(b)=0;
		if(fl==1){
			sum+=max;
		}else{
			sum-=max;
		}
		fl=-fl;
		max=0;
	}
	if(sum<0){
		sum=-sum;
	}
	cout<<sum<<endl;
}
		

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a)
double kitaichi(int i){
  double x= i+1;
  x=x*i/2;
  return x/=i;
}
int main(){
  ios::sync_with_stdio(false);
  //std::cout<<std::fixed<<std::setprecision(10);
  cin.tie(nullptr);
  int a,b;
  cin>>a;
  int ans =0;
  vi x={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};
  cout<<x[a-1]<<endl;


}

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

constexpr int64_t mod = 998244353;

int main() {
  string s;
  int k;
  cin >> s >> k;
  int len = s.size();
  vector<int> v;
  int m = 0;
  for (char c : s) {
    if (c == '0') {
      v.push_back(m);
      m = 0;
    } else {
      m++;
    }
  }
  int n = v.size();
  k = min(k, len - n);
  vector dp(n + 1, vector(k + 1, vector(k + 1, 0L)));
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = j; l <= k; l++) {
        dp[i][j][l] %= mod;
        for (int x = 0; l + x <= k; x++) {
          dp[i+1][j][l+x] += dp[i][j][l];
        }
        for (int x = 1; x <= v[i]; x++) {
          if (j + x > k) break;
          dp[i+1][j+x][l] += dp[i][j][l];
        }
      }
    }
  }
  int64_t ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= m; j++) {
      if (i + j > k) break;
      ans += dp[n][i][i+j];
      ans %= mod;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 30804
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll const MAX_N = 100000;
vector<ll> prime;	//i番目の素数
bool is_prime[MAX_N + 1];	//is_prime[i]がtrueならばiは素数

							//n以下の素数の数を返す
void sieve(ll n) {
	REP(i, n + 1) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	FOR(i, 2, n + 1) {
		if (is_prime[i]) {
			prime.push_back(i);
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
}

int main() {
	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else if (a + b < c + d) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
    int a,b;
    string op;
    cin>>a>>op>>b;
    if(op[0]=='+') cout<<a+b<<endl;
    else cout<<a-b<<endl;
}

Measured memory_bytes: 3544
n = list(map(int,input().split()))

order = input()
a1,a2,a3,a4,b1,b2 = 1,5,6,2,3,4

#print(a1,a2,a3,a4,b1,b2)
#print(order)
for i in order:
  if i == 'N':
    a_1 = a4
    a_2 = a1
    a_3 = a2
    a_4 = a3
    b_1 = b1
    b_2 = b2
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    #print(a1,a2,a3,a4,b1,b2)
  elif i == 'S':
    a_1 = a2
    a_2 = a3
    a_3 = a4
    a_4 = a1
    b_1 = b1
    b_2 = b2
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    #print(a1,a2,a3,a4,b1,b2)
  elif i == 'E':
    a_1 = b2
    a_2 = a2
    b_1 = a1
    a_3 = b1
    b_2 = a3
    a_4 = a4
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    #print(a1,a2,a3,a4,b1,b2)
  else:
    a_1 = b1
    b_1 = a3
    a_3 = b2
    b_2 = a1
    a_2 = a2
    a_4 = a4
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    #print(a1,a2,a3,a4,b1,b2)
    
print(n[int(a1)-1])


Measured memory_bytes: 5612
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

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

  str s;
  cin >> s;
  ll count = 0;
  vll number(N);
  rep(i,0,N){
    if(i > 0){
      if(s[i-1] == 'A' && s[i] == 'C'){
          count++;
      }
    }
    number[i] = count;
  }

  rep(i,0,Q){
    ll l,r;
    cin >> l >> r;
    print(number[r-1]-number[l-1]);
  }

 return 0;
}


Measured memory_bytes: 1792
import Data.List (foldl')
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

solve :: B.ByteString -> Int -> B.ByteString
solve s k = S.toAscList go !! (k-1) where
  go = foldl' go' S.empty [1..k]
  go' substrs p = foldl' go'' substrs [0..max (B.length s - p) 0] where
    go'' substrs i
      | not (S.null substrs) && S.size substrs >= k && S.findMax substrs < sub = substrs
      | otherwise = S.insert sub substrs
      where
        sub = B.take p $ B.drop i s

main = do
  s <- B.getLine
  k <- (fst . (\(Just x) -> x) . B.readInt) <$> B.getLine
  B.putStrLn $ solve s k



Measured memory_bytes: 3068
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(
    n: usize,
    );
    let mut ans: usize = 0;
    for i in 1..=n{
        ans += if i % 3 != 0 && i % 5 != 0 { i } else {0};
    }
    println!("{}", ans);
}


Measured memory_bytes: 2096
def nCk(n, k, mod=10 ** 9 + 7):
    def xgcd(a, b):
        if b == 0:
            return (a, 1, 0)
        g, x, y = xgcd(b, a % b)
        return (g, y, x - (a // b) * y)
    p, q = 1, 1
    for i in range(n - k + 1, n + 1):
        p = (p * i) % mod
    for i in range(2, k + 1):
        q = (q * i) % mod
    return p * (xgcd(q, mod)[1] % mod) % mod


X, Y = map(int, input().split())

b = (2 * X - Y) // 3
a = (-X + 2 * Y) // 3

if (X + Y) % 3 != 0 or a < 0 or b < 0:
    print(0)
else:
    print(nCk(a + b, a))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n, m;
    cin>>n>>m;
    ll ans = 0;
    ans += n * (n - 1) / 2;
    ans += m * (m - 1) / 2;
    cout<<ans<<endl;
}

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

int main() {
	vector<double>v;
	vector<double>::iterator pv=v.begin();
	double d;
	while (cin >> d) {
		v.push_back(d);
	}
	sort(v.begin(), v.end());
	int z = v.size();
	double a = v[z - 1];
	double b = v[0];
	double c = a - b;
	cout << c << endl;
	return 0;
}

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

int n;
vector<int> a;

// kを増やすべきかどうか
bool check(int x, int k){
    if (n-k <= n/2) return false;
    if (n-k*2-1 < 0) return false;
    return abs(a[n-k*2-1]-x) <= abs(a[n-k-1]-x);
}

int main(void){
    int q;
    cin >> n >> q;
    a.resize(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1), t_sum(n+1);
    rep(i,n){
        sum[i+1] = sum[i] + a[i];
        if (i % 2 != n % 2) {
            t_sum[i+1] = t_sum[i] + a[i];
        } else {
            t_sum[i+1] = t_sum[i];
        }
    }
    rep(_,q){
        int x;
        cin >> x;
        int l = 0, r = 1e9;
        while (l + 1 < r) {
            int m = (l+r)/2;
            if (check(x, m)) l = m;
            else r = m;
        }
        int k = r;
        cout << sum[n]-sum[n-k] + t_sum[max(n-2*k,0)]<< endl;
    }

    return 0;
}


Measured memory_bytes: 3712
N, X, Y = map(int, input().split())

ans = [0] * (N-1)
for i in range(1,N+1):
	for j in range(i+1, N+1):
		k = min(j-i, abs(X-i) + abs(Y-j) + 1)
		ans[k-1] += 1

for i in range(N-1):
	print(ans[i])



Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,M,ans=0; cin>>N>>M;
  vector<ll> H(N+1,0);
  vector<vector<ll>> P(N+1,vector<ll>(0,0));
  for(int i=1; i<=N; i++) cin>>H[i];
  for(int i=0; i<M; i++){
    ll a,b; cin>>a>>b;
    P[a].emplace_back(b);
    P[b].emplace_back(a);
  }
  for(int i=1; i<=N; i++){
    ll sz=P[i].size();
    if(sz==0){
      ans++;
      continue;
    }
//    cout<<"i:"<<i<<" sz:"<<sz<<endl;
    for(int j=0; j<sz; j++){
      ll k=P[i][j];
//      cout<<"j:"<<j<<" H[i]:"<<H[i]<<" H[k]:"<<H[k]<<endl;
      if(H[i]<=H[k]) break;
      if(j==sz-1) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9780
using System;

public class C
{
    public const int INF = 999999999;
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var bx = new int[n]; var by = new int[n];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var id = int.Parse(line[0]) - 1;
                bx[id] = int.Parse(line[1]);
                by[id] = int.Parse(line[2]);
            }
            var dp = new double[n, n];
            var next = new int[n, n];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                {
                    next[i, j] = j;
                    if (i == j) dp[i, j] = 0;
                    else
                    {
                        var t = checkBuilding(bx, by, i, j);
                        dp[i, j] = t == -1 ? C.INF : Math.Sqrt(t);
                    }
                }
            goWarshall(dp, next);
            var m = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < m; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var s = int.Parse(line2[0]) - 1;
                var g = int.Parse(line2[1]) - 1;
                putAnswer(dp, next, s, g);
            }
        }
    }
    public static void putAnswer(double[,] dp, int[,] next, int s, int g)
    {
        if (s == g) { Console.WriteLine(s + 1); return; }
        if (next[s, g] == g && dp[s, g] > 50d) { Console.WriteLine("NA"); return; }
        Console.Write("{0} ", s + 1);
        while (true)
        {
            var ns = next[s, g];
            if (ns == g) { Console.WriteLine(g + 1); break; }
            else Console.Write("{0} ", ns + 1);
             s = ns;
        }
    }
    public static int checkBuilding(int[] bx, int[] by, int a, int b)
    {
        var w = (bx[a] - bx[b]) * (bx[a] - bx[b]) + (by[a] - by[b]) * (by[a] - by[b]);
        return w <= 2500 ? w : -1;

    }
    public static void goWarshall(double[,] dp, int[,] next)
    {
        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                {
                    if (dp[j, i] + dp[i, k] < dp[j, k])
                    {
                        dp[j, k] = dp[j, i] + dp[i, k];
                        next[j, k] = next[j, i];
                    }
                }
    }
}

Measured memory_bytes: 9276
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

long long ct, n;

void solve(long long x, long long a, long long b, long long c) {
	if (x > n) return;
	if ((a > 0) && (b > 0) && (c > 0)) ct++;
	solve(x * 10 + 3, a + 1, b, c);
	solve(x * 10 + 5, a, b + 1, c);
	solve(x * 10 + 7, a, b, c + 1);
}

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

	cin >> n;
	ct = 0;
	solve(0, 0, 0, 0);

	cout << ct << "\n";
	
	return 0;
}


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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    cout << ((N + 110) / 111) * 111;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
n=int(input())
a=[int(i) for i in input().split()]
s=sum(a)

def rec(i,num):
    if num==0:
        return True
    if i>=n or num<0 or num>s:
        return False
    res=rec(i+1,num) or rec(i+1,num-a[i])
    return res

q=int(input())
m=[int(i) for i in input().split()]
for i in m:
    print("yes" if rec(0,i) else "no")


Measured memory_bytes: 5636
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn main() {
    from_line!(input: String);
    let s: &str = &input[5..];

    println!("2018/{}", s);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
long long fa[MAXN],a[MAXN],b[MAXN],cnt[MAXN],ans[MAXN];
long long find1(long long v)
{
    return fa[v]=fa[v]==v?v:find1(fa[v]);
}
void merge1(long long x,long long y)
{
    long long a1=find1(x);
    long long b1=find1(y);
    fa[a1]=b1;
    cnt[b1]+=cnt[a1];
}
int main()
{

    long long n,m;
    cin>>n>>m;
    for(long long i=0;i<n;i++)
    {
        fa[i]=i;
        cnt[i]=1;
    }
    for(long long i=0;i<m;i++)
        cin>>a[i]>>b[i];
    ans[m-1]=n*(n-1)/2;
    for(long long i=m-1;i>0;i--)
    {
        long long x=find1(a[i]);
        long long y=find1(b[i]);
        if(x!=y)
        {
            ans[i-1]=ans[i]-cnt[x]*cnt[y];
            merge1(x,y);
        }
        else
            ans[i-1]=ans[i];
    }
    for(long long i=0;i<m;i++)
        cout<<ans[i]<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

int main() {
    string s;

    cin >> s;

    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 3592
def x(p0, p1):
    d = abs(p0 - p1)
    if d > 2:
        return []
    elif d == 2:
        return [(p0 + p1) / 2]
    else:
        m = (p0 + p1) / 2
        v = m - p0
        w = complex(v.imag, -v.real)
        l = abs(w)
        h = (1 - l ** 2) ** .5 * w / l
        return [m + h, m - h]

for e in iter(input, '0'):
    n = int(e)
    P = [complex(*map(float, input().split(','))) for _ in [0] * n]
    Q = []
    for i in range(n):
        for j in range(i + 1, n):
            Q += x(P[i], P[j])
    print(max([sum(1.02 >= abs(q - p) for p in P) for q in Q] + [1]))


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

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  string res = "No";
  for (int i = 0; i < S.size(); ++i) {
    for (int j = 0; j < T.size(); ++j) {
      int t = (T.size() - 1 - i + j) % T.size();
      if (S[j] != T[t]) break;
      if (j == T.size() - 1) res = "Yes";
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int prime[100002];
  prime[1] = 0;
  for(int i = 2; i <= 100001; i++) prime[i] = 1;
  for(int i = 2; i <= 100001; i++){
    if(prime[i]){
      for(int j = 2; i * j <= 100001; j++){
        prime[i * j] = 0;
      }
    }
  }
  
  int counter[100001];
  counter[0] = 0;
  for(int i = 1; i <= 100000; i++){
    counter[i] = counter[i - 1];
    if(prime[i] && prime[(i + 1) / 2]){
      //2より大きい偶数は前を満たさず, 2は後を満たさない
      counter[i]++;
    }
  }
  
  int Q;
  fscanf(stdin, "%d", &Q);
  for(;Q-->0;){
    int l, r;
    fscanf(stdin, "%d %d", &l, &r);
    fprintf(stdout, "%d\n", counter[r] - counter[l - 1]);
  }
  
  return 0;
}

Measured memory_bytes: 1408
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.xml
Imports System.xml.Linq

Module Module1
  const PI as double  = 3.1415926535897931
	public sub main()

		dim N as string = Console.ReadLine()
		dim num as integer = convert.toint32(N)
		dim result as double = num * 2.0 * PI

		console.writeLine(result.tostring())
	  
	end sub 
End Module

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n*(n - 1)/2 + m*(m - 1)/2);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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,k;
  cin >> n >> k;

  set<int> s;
  rep(i,n) s.emplace(i+1);
  rep(i,k){
    int d;
    cin >> d;
    rep(di,d){
      int a;
      cin >> a;
      s.erase(a);
    }
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 3628