akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int n, i;
    scanf("%d", &n);
    int a[n];
    
    for(i=1; i<=n; i++){
        scanf("%d", &a[n+1-i]);
    }
    
    for(i=1; i<=n; i++){
        printf("%d", a[i]);
        if(i != n)
            printf(" ");
        else printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2036
#include<iostream>
using namespace std;
string s;
int ans[1<<17];
main()
{
	cin>>s;
	int R=0,L=0;
	int p;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')
		{
			R++;
			p=i;
		}
		else if(s[i]=='L')
		{
			L++;
			if(i+1==s.size()||s[i+1]=='R')
			{
				ans[p]=ans[p+1]=(L+R)/2;
				if(L+R&1)ans[p+L%2]++;
				L=R=0;
			}
		}
	}
	for(int i=0;i<s.size();i++)cout<<ans[i]<<(i+1==s.size()?"\n":" ");
}


Measured memory_bytes: 1024
s = int(input())
A = []

def f(x):
	if x % 2 == 0:
		return x//2
	else:
		return 3*x+1

for i in range(1000000):
	if i == 0:
		A.append(s)
	X = f(A[i])
	if X in A:
		break
	A.append(X)

print(i + 2)

Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        K: usize,
    }

    let n = s.len();
    let mut dp = vec![vec![vec![0;2];4];101];
    // i桁目まで決まっていて、j個の非0を使っていて、sの桁よりも小さいことが確定しているかどうか
    dp[0][0][0] = 1;

    // 左から、0桁からn桁まで
    for i in 0..n {
        // j個の0でない数字が使える
        for j in 0..4 {
            // sの桁よりも小さいことが確定しているかどうか
            for k in 0..2 {
                // 今見ている桁の数字
                let nd = s[i].to_digit(10).unwrap();
                for d in 0..10 {
                    let ni = i + 1 as usize;
                    let mut nj = j as usize;
                    let mut nk = k as usize;
                    // 0でないので使える数が減る
                    if d != 0 {
                        nj += 1;
                    }
                    // もうこれ以上使えない
                    if nj > K {
                        continue;
                    }

                    // まだｓ以下であることが確定していない=ここまでsと一致している
                    if k == 0 {
                        // sより大きくなってしまうのでだめ
                        if d > nd {
                            continue;
                        }
                        // がs以下であることが確定
                        if d < nd {
                            nk = 1;
                        }
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }

    let ans = dp[n][K][0] + dp[n][K][1];
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
	double N;
  cin >> N;
  	double p = ceil(N/2);
  	cout << p/N << endl;
}

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

int main(){
  int n;
  cin >> n;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i*j == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]

if A[0] != 0:
    print(-1)
    exit()

for i in range(N - 1):
    if A[i] < A[i + 1] and A[i + 1] - A[i] != 1:
        print(-1)
        exit()
    if A[i] > i + 1:
        print(-1)
        exit()

ans = 0
for i in range(1, N):
    if A[i-1] >= A[i]:
        ans += A[i-1]
print(ans + A[-1])


Measured memory_bytes: 11052
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int x,a;
  cin>>x>>a;
  if(x<a)ou(0);
  if(x>=a)ou(10);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

struct info
{
    int x;
    int y;
};

int A[17];
vector<info> chart[17];

int main()
{
    int i,j;
    int N;

    scanf("%d", &N);

    for( i=1; i<=N; i++)
    {
        scanf("%d", &A[i]);
        for( j=0; j<A[i]; j++)
        {
            int x, y;
            scanf("%d %d", &x, &y);
            chart[i].push_back({ x, y});
        }
    }

    int ans = 0;
    for( i=0; i<(1<<N); i++)
    {
        int cnt = 0;
        bool flag = 0;
        for( j=0; j<N; j++)
        {
            if( (i>>j)&1 )
            {
                cnt++;
                for( auto it:chart[j+1])
                {
                    if( it.y==1 && !( ( i>>(it.x-1) )&1) || it.y==0 && ( i>>(it.x-1) )&1 )
                        flag = 1;
                }
            }
        }

        if(!flag)
        {
            // printf(">>>%d\n", i);
            ans = max( cnt, ans);
        }
    }
    printf("%d\n", ans);

    return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

bool issosu(int n){
    bool is=true;
    if(n==2)return true;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            is=false;
            break;
        }
    }
    return is;
}

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

    vector<int> cnt(1001,0);
    

    //-----------------------------------
    for(int i=2;i<=N;i++){
        if(issosu(i)){
            int k=i,x=N/i;
            while(x>0){
                cnt[i]+=x;
                k*=i;
                x=N/k;
            }
        }
    }
    ll ans=1;
    rep(i,1001){
        if(cnt[i]!=0){
            ans*=cnt[i]+1;
            ans%=mod;
        }
    }
    cout << ans <<endl;
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printdbl(a) printf("%lf\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int n, k, tmp;
    scan2Int(n,k);
    int count = 0;
    rep(i, n) {
        scanInt(tmp);
        if (tmp >= k) count += 1;
    }
    printInt(count);
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define pi 3.141592653589793
int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    double ans;
    if (a*a*b <= 2*x) {
        ans = atan2((double)2*b - 2*x/(double)(a*a), a)*180/pi;
    }else{
        //cout << (double)b << ',' << (double)2*x/(double)(a*b) << endl;
        ans = atan2((double)b, (double)2*x/(double)(a*b))*180/pi;
    }
    cout << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
using namespace std;
int read(){
	int nm=0,fh=1;char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
int n,m,ind[M],fs[M],nt[M],to[M],u,v,tmp,rt,vis[M];
void WIN(){puts("First");exit(0);}
void link(int x,int y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;}
void DP(int x,int last){
	int cnt=0,all=(last==0?0:-1),ct=0;
	for(int i=fs[x];i!=-1;i=nt[i],all++){
		if(to[i]==last) continue;
		DP(to[i],x),cnt+=(vis[to[i]]==1),ct+=(vis[to[i]]==2);
	}
	if(ct>=2) WIN();
	if(ct) vis[x]=1;
	if(cnt==all) vis[x]=2;
}
int main(){
	n=read(),memset(fs,-1,sizeof(fs));
	for(int i=1;i<n;i++){
	    u=read(),v=read();
		link(u,v),link(v,u);
		ind[u]++,ind[v]++;
	}
	DP(1,0);
	//for(int i=1;i<=n;i++) printf("X: %d    vis: %d\n",i,vis[i]);
	if(vis[1]==2) WIN();
	puts("Second");
	return 0;
}

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

int p, s, n = 0, q;
pair<int, int> t[100];
int r[101];
char c;

int main()
{
    while (1) {
        cin >> p >> c >> s;

        if (p == 0 && s == 0)
            break;

        t[n].first = s;
        t[n].second = p;
        n++;
    }

    sort(t, t + n, greater<pair<int, int> >());

    r[t[0].second] = 1;
    int j = 1;

    for (int i = 1; i < n; i++) {
        if (t[i].first < t[i - 1].first)
            j++;

        r[t[i].second] = j;
    }

    while (cin >> q)
        cout << r[q] << endl;

    return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    int b[n][3];
    for(int i=0;i<3;i++)
    {
        b[0][i]=a[0][i];
    }
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                b[i][j]=a[i][j]+max(b[i-1][1],b[i-1][2]);
            }
            if(j==1)
            {
                b[i][j]=a[i][j]+max(b[i-1][0],b[i-1][2]);
            }
            if(j==2)
            {
                b[i][j]=a[i][j]+max(b[i-1][1],b[i-1][0]);
            }
        }
    }
    int max=INT_MIN;

    for(int i=0;i<3;i++)
    {
        if(b[n-1][i]>max)
        {
            max=b[n-1][i];
        }
    }
    cout<<max<<endl;
    return 0;

    
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);

    if ( c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b) )
        printf("Yes\n");
    else
        printf("No\n");

    return EXIT_SUCCESS;
}


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

int main(){
	int h1, h2, k1, k2, a, b, c, d, hiroshi, kenjiro;
	
	cin>>h1>>h2>>k1>>k2>>a>>b>>c>>d;
	
	hiroshi = h1 * a + h2 * b;
	kenjiro = k1 * a + k2 * b;
	hiroshi += (h1 / 10) * c + (h2 / 20) * d;
	kenjiro += (k1 / 10) * c + (k2 / 20) * d;
	
	if(hiroshi == kenjiro) cout<<"even"<<endl;
	if(hiroshi < kenjiro) cout<<"kenjiro"<<endl;
	if(hiroshi > kenjiro) cout<<"hiroshi"<<endl;
	return 0;
}



Measured memory_bytes: 3104
import java.io.*;
import java.util.StringTokenizer;

public class Main {

  private void solve(InputReader in, PrintWriter out) {
    int a = in.nextInt();
    int b = in.nextInt();
    out.println(a <= 8 && b <= 8 ? "Yay!" : ":(");
  }


  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try (
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

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

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

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {

    }
  }

}


Measured memory_bytes: 23124
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return acos(-1.0);
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
double x[30]={},y[30]={},ans,ss;
double abs(double i,double e){
	if(e-i>=0) return e-i;
	return i-e;
}
double leng(double xx,double yy){
	return sqrt(pow(xx,2.0)+pow(yy,2.0));
}
int main(){
	int i=0;
	char sr;
	while(cin>>x[i]>>sr>>y[i]){
		i++;
	}
//	cout<<i<<endl;
	double a,b,c,ans=0,g,f,d;
	for(int e=1;e<=i-2;e++){
		a=leng(abs(x[0],x[e]),abs(y[0],y[e]));
		b=leng(abs(x[0],x[e+1]),abs(y[0],y[e+1]));
		c=leng(abs(x[e],x[e+1]),abs(y[e],y[e+1]));
//		cout<<a<<" "<<b<<" "<<c<<endl;
		double z=(a+b+c)/2.0;
//		cout<<sqrt(z*(z-a)*(z-b)*(z-c))<<endl;
		ans+=sqrt(z*(z-a)*(z-b)*(z-c));
	}
	printf("%lf\n", ans);
}

Measured memory_bytes: 1236
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        long n=Long.parseLong(br.readLine());
        int cntr=0;
        if(n==2)
        {
            pw.println(1);
            pw.flush();
            pw.close();
            return;
        }
        for(long i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                if(i!=n/i)
                {
                    long temp=n;
                    while(temp%i==0)
                    temp/=i;
                    if(temp==1||temp%i==1)
                    cntr++;
                    temp=n;
                    long div=n/i;
                    while(temp%div==0)
                    temp/=div;
                    if(temp==1||temp%div==1)
                    cntr++;
                }
                else
                {
                    long temp=n;
                    while(temp%i==0)
                    temp/=i;
                    if(temp==1||temp%i==1)
                    cntr++;
                }
            }
            else
            {
                if(n%i==1)
                cntr++;
                long temp=n;
                long div=n/i;
                if(div!=i)
                {
                if(temp%div==1)
                cntr++;
                else
                {
                    while(temp%div==0)
                    temp/=div;
                    if(temp==1||temp%div==1)
                    cntr++;
                }
                }
            }
        }
        pw.println(cntr+2);
        pw.flush();
        pw.close();
    }
}

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

    public class Main {

    void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] arr = new int[n];
        int[] cnt = new int[n + 1];
        for (int i = 0; i < n; ++i) {
            arr[i] = in.nextInt();
            ++cnt[arr[i]];
        }

        long sum = 0;
        for (int i = 1; i <= n; ++i) {
            sum += nc2(cnt[i]);
        }

        for (int i = 0; i < n; ++i) {
            long ans = sum - nc2(cnt[arr[i]]);
            ans += nc2(cnt[arr[i]] - 1);
            out.println(ans);
        }
    }

    public long nc2(long n) {
        return (n*(n-1)) >> 1l;
    }

    

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Main solver = new Main();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

        public InputReader(InputStream is) {
        in = new BufferedReader(new InputStreamReader(is));
        }

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

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

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


Measured memory_bytes: 51936
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EasyLinearProgramming solver = new EasyLinearProgramming();
        solver.solve(1, in, out);
        out.close();
    }

    static class EasyLinearProgramming {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int k = in.nextInt();

            int result = 0;
            if (a > 0) {
                int min = Math.min(a, k);
                k -= min;
                result += min;
            }
            if (b > 0) {
                int min = Math.min(b, k);
                k -= min;
            }
            if (c > 0) {
                int min = Math.min(c, k);
                k -= min;
                result -= min;
            }
            out.append(String.valueOf(result));
        }

    }
}



Measured memory_bytes: 35692
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
vector<P> G[400000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		ll X;
		cin >> X;
		G[i].emplace_back(i + N, X);
		G[i + N].emplace_back(i, X);
	}
	for (int i = 0; i < N - 1; i++) {
		int A, B;
		ll C;
		cin >> A >> B >> C;
		A--; B--;
		G[A].emplace_back(B, C);
		G[B].emplace_back(A, C);
	}
	vector<int> used(2 * N, 0);
	vector<ll> dist(2 * N, 0);
	priority_queue<PP, vector<PP>, greater<PP>> Q;
	int cnt = 1;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		Q.push(PP(0, P(i + N, -1)));
	}
	while (!Q.empty()) {
		PP now = Q.top(); Q.pop();
		int v = now.second.first;
		int u = now.second.second;
		if (used[v]) {
			if (used[v] > used[u]) {
				ans += dist[v] + now.first;
			}
			continue;
		}
		used[v] = cnt;
		cnt++;
		dist[v] = now.first;
		for (P p : G[v]) {
			Q.push(PP(dist[v] + p.second, P(p.first, v)));
		}
	}
	cout << ans << endl;
}

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

const long long INF = 1LL << 60;
int MOD = 1000000007;
double PI = 3.14159265358979323846;
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; }

typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)


ll modpow(ll a, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int divisors(int n) {
	int div=0;
	rep1(i, int(sqrt(n)) + 1) {
		if (n % i == 0) {
			div += 1;
			if (i != n / i) {
				div += 1;
			}
		}
	}
	return div;
}

int N;
int dp[1100000];
int ass[1100000];

int main() {

	cin >> N;

	rep1(i, 1000001) dp[i] = divisors(i);
	rep1(i, 1000001) ass[i] = ass[i - 1] + dp[i];

	cout << ass[N - 1] << endl;


}

Measured memory_bytes: 11492
while 1:
    n=int(input())
    if not n:break
    p=[(0,0)]
    b=[0,0]
    for _ in range(n-1):
        idx,d=map(int,input().split())
        b=list(p[idx])
        if d==0:
            b[0]-=1
        elif d==1:
            b[1]-=1
        elif d==2:
            b[0]+=1
        elif d==3:
            b[1]+=1
        p.append(tuple(b))
    w=len({i[0] for i in p})
    h=len({i[1] for i in p})
    print(w,h)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int k,x;
	cin>>k>>x;
	if(k*500>=x)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

vector<vector<int>> rel;
vector<bool> reach;

void dfs(int n){
    if(rel[n].size()==0) return;

    int nEdge = rel[n].size();
    for(int i=0; i<nEdge; i++){
        int nxt = rel[n][i];
        if(reach[nxt]) continue;
        reach[nxt] = true;
        dfs(nxt);
    }
}


int main(){
    int N, M;
    cin >> N >> M;
    rel = vector<vector<int>>(N+M+1, vector<int>());
    for(int i=1; i<=N; i++){
        int K;  cin >> K;
        rel[i] = vector<int>(K);
        for(int j=0; j<K; j++){
            int L;  cin >> L;
            rel[i].push_back(L+N);
            rel[L+N].push_back(i);
        }
    }

    reach = vector<bool>(N+M+1, false);
    reach[1] = true;
    dfs(1);
    for(int i=1; i<=N; i++){
        if(!reach[i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 8440
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Sarray();
            var dcts = new List<Dictionary<long, long>>();
            for (var i = 0; i < N; ++i)
                dcts.Add(primefactorize(Ai[i]));
            var maxPrms = new Dictionary<long, long>();
            foreach(var ds in dcts)
            {
                foreach(var d in ds )
                {
                    if (!maxPrms.ContainsKey(d.Key)) maxPrms[d.Key] = d.Value;
                    if (maxPrms[d.Key] < d.Value) maxPrms[d.Key] = d.Value;
                }
            }
            var lcm = 1L;
            foreach(var d in maxPrms)
                lcm = lcm * Modpow(d.Key, d.Value, Mod) % Mod;            
            var sum = 0L;
            for (var i = 0; i < N; ++i)
            {
                var t = Modinv(Ai[i], Mod) * lcm % Mod;
                sum = (sum + t) % Mod;
            }
            WriteLine(sum);
        }
        static Dictionary<long, long> primefactorize(long n)
        {
            var primes = new Dictionary<long,long>();
            for (long i = 2; i * i <= n; ++i)
            {
                var num = 0;
                while (n % i == 0)
                {
                    primes[i] = ++num;
                    n /= i;
                }
            }
            if (n != 1) primes[n] = 1;
            return primes;
        }
        static long Modpow(long a, long n, long mod)
        {
            var res = 1L;
            while (0 < n)
            {
                if (n % 2 != 0) res = res * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return res;
        }
        static long ExtGCD(long a, long b,out long x, out long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }
            long d = ExtGCD(b, a % b, out y, out x);
            y -= a / b * x;
            return d;
        }
        static long Modinv(long a, long m)
        {
            long x, y;
            ExtGCD(a, m, out x, out y);
            return (x % m + m) % m;
        }
    }
}

Measured memory_bytes: 24136
n = int(input())
S = list(range(1,14))
H = list(range(1,14))
D = list(range(1,14))
C = list(range(1,14))
marks = ['S','H','C','D']

for i in range(n):
    mark,num = input().split()
    eval(mark+'.remove(int(num))')

for m in marks:
    #print(m, eval(m))
    for i in eval(m):
        print(m, i)


Measured memory_bytes: 5600
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
using namespace std;
using ll = long long;

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i=0;i<N;i++)    par[i]=i;
    }
    int root(int x){
        if(par[x]==x)   return x;
        return par[x] = root(par[x]);
    }
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry)  return;
        par[rx] = ry;
    }
    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx==ry;
    }
};

int main(){
    int h,w;
    cin >> h >> w;
    UnionFind tree(h*w);
    char s[400][401];
    for(int i=0;i<h;i++)    cin >> s[i];
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
                if(y-1>=0&&s[y-1][x]!=s[y][x])  tree.unite(y*w+x,(y-1)*w+x);
                if(y+1<h&&s[y+1][x]!=s[y][x])   tree.unite(y*w+x,(y+1)*w+x);
                if(x-1>=0&&s[y][x-1]!=s[y][x])  tree.unite(y*w+x,y*w+x-1);
                if(x+1<w&&s[y][x+1]!=s[y][x])   tree.unite(y*w+x,y*w+x+1);
        }
    }
    map<int,ll> black,white;
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            if(s[y][x]=='.')    white[tree.root(y*w+x)]++;
            else    black[tree.root(y*w+x)]++;
        }
    }
    ll ans=0;
    for(auto e:white){
        ans+=e.second * black[e.first];
    }
    cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int n,t;
    cin>>n>>t;
    int a[n+1],b[n+1];
    long long dp1[n+10][t+10];
    long long dp2[n+10][t+10];
    rep(i,n){
        cin>>a[i+1]>>b[i+1];
    }
    rep(i,n+1){
        dp1[i][0]=0;
        dp2[i][0]=0;
    }
    rep(i,t+1){
        dp1[0][i]=0;
        dp2[n+1][i]=0;
    }
    for (int i=1;i<n+1;i++){
        for (int j=1;j<t;j++){
            if (a[i]>j){
                dp1[i][j]=dp1[i-1][j];
            }
            else{
                dp1[i][j]=max(dp1[i-1][j],dp1[i-1][j-a[i]]+b[i]);
            }

        }
    }
    for (int i=n;i>0;i--){
        for (int j=1;j<t;j++){
            if (a[i]>j){
                dp2[i][j]=dp2[i+1][j];
            }
            else{
                dp2[i][j]=max(dp2[i+1][j],dp2[i+1][j-a[i]]+b[i]);
            }
        }
    }
    long long ans=0;
    for (int i=1;i<n+1;i++){
        for (int j=0;j<t;j++){
            ans=max(ans,dp1[i-1][j]+dp2[i+1][t-1-j]+b[i]);
        }
    }
    cout<<ans<<endl;


    return 0;
} 

Measured memory_bytes: 141568
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+120;
int onright[N];

int main()
{
	int n;scanf("%d\n",&n);
	for(int i=1;i<=n;i++){
		char c=getchar();
		if(c=='E') onright[i]++;
		onright[i]+=onright[i-1];
	}
	int minn=n+1;
	onright[n+1]=onright[n];
	for(int i=1;i<=n;i++)
		minn=min(minn,(i-1-onright[i-1])+onright[n]-onright[i]);
	cout<<minn;
	return 0;

}

Measured memory_bytes: 1408
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var str=input.trim();
str=str.replace(/o+/g,0);
str=str.replace(/x+/g,1);
var a=str[0];
var b=str[str.length-1];
var ans="x";
if(a==0 && b==1)ans="o";
if(a==0 && b==0)ans="o";
if(a==1 && b==0)ans="o";
console.log(ans);

Measured memory_bytes: 7384
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

template <class T>
class CuSum {
private:
	vector<T> cusum;
public:
	// Constructors 
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)(vec.size()); i++) cusum[i + 1] = cusum[i] + vec[i];
	}
	CuSum(int N) : cusum(N + 1) {}
	void add(int i, T x) { cusum[i + 1] += x; }
	void init() { for (int i = 0; i < (int)(cusum.size()); i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r] 
	T operator()(int l, int r) {
		if (r < l || r < 0) {
			//assert(0);
			return T(0);
		}
		else return cusum[r + 1] - cusum[l];
	}
	// 0-indexed
	T operator[](int i) { return cusum[i + 1]; }
	T back() { return cusum.back(); }
};

int main() {

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

	int H, W, D;
	cin >> H >> W >> D;

	vector<vector<int>> memo(D, vector<int>(H * W / D + 1));
	int tmp;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> tmp;
			memo[tmp % D][tmp / D] = i * W + j;
		}
	}


	vector<CuSum<int>> cost(D, H*W / D);
	for (int i = 0; i < D; i++) {
		for (int j = H * W /D; j >= 1; j--) {
			memo[i][j] = abs(memo[i][j] / W - memo[i][j - 1] / W) + abs(memo[i][j] % W - memo[i][j - 1] % W);
		}
		memo[i][0] = 0;
		cost[i] = CuSum<int>(memo[i]);
	}

	int Q, L ,R;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> L >> R;
		cout << cost[L%D](L / D + 1, R / D) << "\n";
	}

	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

using namespace std;

int main(){
    int map[1001][101];
    while(true){
        int n,m,a,d,c1,c2;
        cin >> n >> m >> a;
        if(n+m+a == 0)break;
        for(int i = 0;i < 1001;i++){
            for(int j = 0;j < 101;j++){
                map[i][j] = 0;
            }
        }
        for(int i = 0;i < m;i++){
            cin >> d >> c1 >> c2;
            map[d][c1] = c2;
            map[d][c2] = c1;
        }
        for(int i = 1000;i > 0;i--){
            if(map[i][a] != 0)a = map[i][a];
        }
        cout << a << endl;
    }
}

Measured memory_bytes: 1552
//package Contest087;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String []args)
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int a =sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),x=sc.nextInt();
            int cnt = 0;
            for(int i=0;i<=a;i++)
            {
                for(int j=0;j<=b;j++)
                {
                    for(int k=0;k<=c;k++)
                    {
                        int res = (500*i)+(100*j)+(50*k);
                        if(res==x)
                            cnt++;
                    }
                }
            }
            out.println(cnt);

        out.flush();
    }
}


Measured memory_bytes: 23636
N = int(input())
S = input()

S1,S2 = S[:N],S[N:][::-1]

dic = {}
keys = []
Ans = 0

for i in range(2**N):
    red,blue,red2,blue2 = "","","",""
    # 半分ずつbit全探索
    bits = bin(2**N+i)[3:]
    for j in range(N):
        if bits[j]=="0":
            red  += S1[j]
            red2 += S2[j]
        else:
            blue += S1[j]
            blue2 += S2[j]
    # あとで数える際に使うので記録しておく
    keys.append(red2+"-"+blue2)
    # 半分全列挙
    key = red+"-"+blue
    if key not in dic.keys():
        dic[key] = 1
    else:
        dic[key] += 1

for key in keys:
    Ans += dic.get(key,0)

print(Ans)

Measured memory_bytes: 56636
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int> a(N), b(N);
    for (int &t: a)
        cin>>t;
    for (int &t: b)
        cin>>t;
    for (int i=0; i<N; i++)
        if (b[i]!=a[i] && (a[i]==0 || b[i]>(a[i]-1)/2))
        {
            cout<<-1<<endl;
            return 0;
        }
    set<int> K;
    for (int k=50; k>0; k--)
    {
        bool f = false;
        for (int i=0; i<N; i++)
        {
            long long A = 1LL<<a[i];
            for (int t=50; t>0; t--)
                if (t<k || K.count(t)>0)
                    for (int j=0; j<=51; j++)
                        if (A&1LL<<j)
                            A |= 1LL<<(j%t);
            if (!(A&1LL<<b[i]))
                f = true;
        }
        if (f)
            //cout<<k<<endl,
            K.insert(k);
    }
    long long ans = 0;
    for (int k: K)
        ans += 1LL<<k;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
	int a, b, c, n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d %d %d", &a, &b, &c);
		if(a * a + b * b == c * c || a * a + c * c == b * b || a * a == b * b + c * c){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

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

int main(){
	int N,M;
	cin >> N;
	int h[N],m[N];
	for(int i=0; i<N; i++)
		cin >>h[i]>>m[i];

	cin >> M;
	int k[M],g[M];
	for(int i=0; i<M; i++)
		cin >>k[i]>>g[i];

	int Nc=0,Mc=0,same=0;
	for(int i=0; i<N+M; i++){
		if(Nc!=N&&((h[Nc]<k[Mc]||(h[Nc]==k[Mc]&&m[Nc]<g[Mc]))||Mc==M)){//飯盛のが早いか鶴賀城がもうない
			cout << h[Nc]<<':'<<m[Nc]/10<<m[Nc]%10;
			Nc++;
			if(Nc+Mc!=N+M)
				cout<<' ';
			else
				cout <<endl;
//cout << Nc <<Mc<<m[Nc]<<g[Mc]<<endl;


		}		
		else if((h[Nc]>k[Mc]||(h[Nc]==k[Mc]&&m[Nc]>g[Mc]))||Nc==N){
			
			cout << k[Mc]<<':'<<g[Mc]/10<<g[Mc]%10;
				Mc++;

			if(Nc+Mc!=N+M)
				cout<<' ';
			else
				cout <<endl;
//cout << Nc <<Mc<<m[Nc]<<g[Mc]<<endl;
		}
		else if (h[Nc]==k[Mc]&&m[Nc]==g[Mc]){
			cout << h[Nc]<<':'<<m[Nc]/10<<m[Nc]%10;
			Nc++;	
			Mc++;
			i++;

			if(Nc+Mc!=N+M)
				cout<<' ';
			else
				cout <<endl;
//cout << Nc <<Mc<<m[Nc]<<g[Mc]<<endl;
		}		
	}

	return 0;
}
		
	

Measured memory_bytes: 1168
#include <iostream>
#define MAX 500050
using namespace std;

long long count = 0;

void Merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+10], R[n2+10];
	for (int i = 0;i < n1;i++)
	{
		L[i] = A[left+i];
	}
	for (int i = 0;i < n2;i++)
	{
		R[i] = A[mid+i];
	}
	L[n1] = 1e+9;
	R[n2] = 1e+9;
	int i = 0, j = 0;
	for (int k = left;k < right;k++)
	{
		if (L[i] <= R[j])
		{
			A[k] = L[i];
			i++;
		}
		else
		{
			A[k] = R[j];
			j++;
			count += n1 - i;
		}
	}
}

void Merge_Sort(int A[], int left, int right)
{
	if (left+1 < right)
	{
		int mid = (left + right) / 2;
		Merge_Sort(A, left, mid);
		Merge_Sort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

void Print_Array(int A[], int n)
{
	cout << A[0];
	for (int i = 1;i < n;i++)
	{
		cout << " " << A[i];
	}
	cout << endl;
}

int main ()
{
	int n;
	cin >> n;
	int S[MAX];
	for (int i = 0;i < n;i++)
	{
		cin >> S[i];
	}
	
	Merge_Sort(S, 0, n);

	cout << count << endl;
	
	return 0;
 } 


Measured memory_bytes: 4664
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}


int main()
{
    int N = inputValue();
    int d[50];
    REP(i, N){
        d[i] = inputValue();
    };
    int ans = 0;
    REP(i, N){
        FOR(j, i+1, N){
            ans += d[i] * d[j];
        };
    };

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

inline int clusters(const int height, vi & v) {
	int cls = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i] >= height) {
			if (i == 0) {
				cls += 1;
			}
			else if (v[i - 1] < height) {
				cls += 1;
			}
			else {
				continue;
			}
		}
	}

	return cls;
}

int main() {
	int N;
	cin >> N;
	vi hs(N);
	int height = 0;
	rep(i, N) {
		cin >> hs[i];
		hs[i] > height ? height = hs[i] : 1;
	}

	//上から削っていく
	int cnt = 0;
	while (height) {
		cnt += clusters(height, hs);
		height--;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>

using namespace std;

long long MOD = 1e9 + 7;

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

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

    cout << std::max(0, (a - 2 * b)) << endl;

    return 0;
}

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

using namespace std;

void solve(long long A, long long B, long long C) {
    if( A > B ) swap(A, B);
    if( B > C ) swap(B, C);
    if( A > B ) swap(A, B);
    cout << C * 10 + B + A << endl;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    solve(A, B, C);
    return 0;
}



Measured memory_bytes: 764
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h>
#include <bits/stdc++.h>
#include <math.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//b問題
//上面v[0]と前面v[1]が与えられるので、右側v[2]を答える


// 5		v[4]
//413	v[3]v[0]v[2]
// 2		v[1]
// 6		v[5]

//N
//	  v[4]				v[0]
//v[3]v[0]v[2]	→	v[3]v[1]v[2]
//	  v[1]				v[5]
//	  v[5]				v[4]

//S
//	  v[4]				v[5]
//v[3]v[0]v[2]	→	v[3]v[4]v[2]
//	  v[1]				v[0]
//	  v[5]				v[1]

//E
//	  v[4]				v[4]
//v[3]v[0]v[2]	→	v[5]v[3]v[0]
//	  v[1]				v[1]
//	  v[5]				v[2]

//W
//	  v[4]				v[4]
//v[3]v[0]v[2]	→	v[0]v[2]v[5]
//	  v[1]				v[1]
//	  v[5]				v[3]


class dice
{
public:
	explicit dice(int _dice[6])
	{
		for(int i = 0; i < 6; ++ i)
		{
			v[i] = _dice[i];
		}
	}

	void mov(char c)
	{
		int buf;
		//北方向
		if(c == 'N')
		{
			buf = v[0];
			v[0] = v[1];
			v[1] = v[5];
			v[5] = v[4];
			v[4] = buf;
		}
		else if(c == 'S')
		{
			buf = v[0];
			v[0] = v[4];
			v[4] = v[5];
			v[5] = v[1];
			v[1] = buf;		
		}
		else if(c == 'E')
		{
			buf = v[0];
			v[0] = v[3];
			v[3] = v[5];
			v[5] = v[2];
			v[2] = buf;	
		}
		else if(c == 'W')
		{
			buf = v[0];
			v[0] = v[2];
			v[2] = v[5];
			v[5] = v[3];
			v[3] = buf;				
		}
	}
// 5		v[4]
//413	v[3]v[0]v[2]
// 2		v[1]
// 6		v[5]

	int migi[5] = {1,2,4,3,1};
	//上面v[0]固定で前面v[?]が与えられるので、右側v[?]を答える
	int find_right(int front)
	{
		int res = -1;

		REP(i,4)
		{
			if(front == v[migi[i]])
			{
				res = v[migi[i+1]];
			}
		}
		return res;
	}

	//指定の値を上面
	int tadasu(int up)
	{
		
		//初期位置
		if(v[0] == up) return 0;

		string kororin = "WWNWW";
		REP(i,kororin.size())
		{
			mov(kororin[i]);
			if(v[0] == up) return 0;
		}
		return -1;
	}


	int sameDice(int in[6])
	{
		string kororin = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < kororin.size(); ++i)
		{
			mov(kororin[i]);
			for(int j = 0; j < 6; j++){
                if(in[j] != v[j])
                    break;
                if(j == 5)
                    return 0;
			}

		}

		return -1;
	}
int operator[](size_t i){return v[i];}
private:
	int v[6];
};

int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());

	//6面
	int _dice[6];
	REP(i,6)
	{
		cin >> _dice[i];
	}
	//サイコロの作成
	dice d1(_dice);


	int _dice2[6];
	REP(i,6)
	{
		cin >> _dice2[i];
	}

	//対称となる3組が一致すればよい??
	//0-5
	//1-4
	//2-3


	string res = "No";

	if(d1.sameDice(_dice2) == 0)
	{
		res = "Yes";
	}

	cout << res << endl;
    //cout << fixed << setprecision(5) << dm << endl;
	//std::printf("%.5f¥n", res);
	
	return 0;
}




Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <sstream>

using namespace std;

string swp(string s,const int&a,const int&b){swap(s[a],s[b]);return s;}

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

    string s = "01234567";

    queue<string> q;
    map<string, int> m;

    q.push(s);
    m[s] = 0;

    while (q.size()) {
        string t = q.front(); q.pop();
        int idx = t.find('0');
        string u;
        if (idx - 1 >= 0 && idx != 4) {
            u = swp(t, idx, idx - 1);
            if (m.find(u) == m.end()) {
                m[u] = m[t] + 1;
                q.push(u);
            }
        }
        if (idx + 1 < 8 && idx != 3) {
            u = swp(t, idx, idx + 1);
            if (m.find(u) == m.end()) {
                m[u] = m[t] + 1;
                q.push(u);
            }
        }
        if (idx - 4 >= 0) {
            u = swp(t, idx, idx - 4);
            if (m.find(u) == m.end()) {
                m[u] = m[t] + 1;
                q.push(u);
            }
        }
        if (idx + 4 < 8) {
            u = swp(t, idx, idx + 4);
            if (m.find(u) == m.end()) {
                m[u] = m[t] + 1;
                q.push(u);
            }
        }
    }

    string line; stringstream ss;
    while (getline(cin, line)) {
        ss << line;
        string t = "";
        for (int i = 0; i < 8; ++i) {char c;ss >> c;t += c;}
        cout << m[t] << endl;
    }
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; i++) cout << s[i];
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    string s;
    cin >> s;
    
    int n = s.length(), cnt = 0;
    FOR(i, 1, n){
        if(s[i-1]!=s[i]) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 512
/*
 * ABC96A.cpp
 *
 *  Created on: May 5, 2018
 *      Author: 13743
 */

#include<cstdio>
#include<algorithm>

using namespace std;

int a,b;

int main() {
	scanf("%d %d", &a, &b);

	if(a <= b) printf("%d\n", a);
	else printf("%d\n", a-1);

}


Measured memory_bytes: 128
#
# abc069 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """internationalization"""
        output = """i18n"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """smiles"""
        output = """s4s"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """xyz"""
        output = """x1z"""
        self.assertIO(input, output)


def resolve():
    s = input()
    print(f"{s[0]}{len(s)-2}{s[-1]}")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16252
#include <stdio.h>

int main(){
  long long int n, c;
  while(scanf("%lld", &n) && n){
    c = 0;
    while(n != 1){
      n = n % 2 == 0 ? n / 2: n * 3 + 1;
      c++;
    }

    printf("%lld\n", c);
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m,s = 0,i;scanf("%lld%lld",&m,&n);
  if(m>=n){
    printf("0\n");return 0;
  }
  ll x[n],d[n-1];
  for(i=0;i<n;i++) scanf("%lld",&x[i]);
  sort(x,x+n);
  for(i=0;i<n-1;i++) d[i] = x[i+1]-x[i];
  sort(d,d+n-1,greater<ll>());
  for(i=0;i<m-1;i++) s += d[i];
  printf("%lld\n",x[n-1]-x[0]-s);
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second

using namespace std;

int main(){

    int n = 0;
    cin >> n;

    vector<ll> s(n+1);
    s[0] = 0;
    map<ll,ll> m;
    m[0] = 1;
    for(int i=1;i<=n;i++){
        ll a;
        cin >> a;
        s[i] = s[i-1] + a;
        m[s[i]]++;
    }
    ll ans=0;
    for(auto k:m) ans += k.second*(k.second-1)/2;
    cout << ans;


    return 0;
}

Measured memory_bytes: 14336
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	char c;
int n,s=0;int A=0;
while(1){
	while(1){
scanf("%d%c",&n,&c);



	
if(n>1&&n<11)s+=n;
else if(n>10)s+=10;
else if(n==1){s+=1;A++;}
if(c=='\n')break;
}
if(s==0)break;
if(s>=22)printf("0\n");


else {
	if(A>0){
	for(int i=0;i<A;i++)
		if(s+10<=21)s+=10;
	
	}
	
	printf("%d\n",s);
}s=0;A=0;
}



return 0;
}

Measured memory_bytes: 1200