akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int a=0,b=0,c=0;
    rep(i,n){
        if(s[i]=='a')a++;
        if(s[i]=='b')b++;
        if(s[i]=='c')c++;
    }
    int mx=max({a,b,c});
    int mn=min({a,b,c});
    if(mx-mn<=1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    string s;
    cin>>s;
    map<char,int> mp;
    rep(i,0,s.size()){
        mp[s[i]]++;
        if(mp[s[i]]>1){cout<<"no"<<endl;return 0;}
    }
    cout<<"yes"<<endl;
    return 0;
}

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

int ketanowa(int n){
  int sum = 0;
  while(n>0){
  sum += n % 10;
  n /= 10;
  }
  return sum ;
}


int main() {
 int N ;
  cin >> N ;
 if ( N == 100000 || N == 10000 || N == 1000 || N == 100 || N == 10){
   cout << 10 << endl;
 }else{
  cout << ketanowa(N) << endl;
}
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		//入力されるカードセット枚数
		int request=sc.nextInt();
		for(int i=0;i<request;i++) {
			//カードの数字を入れる配列作成
			int[] num=new int[9];
			for(int j=0;j<9;j++) {
				num[j]=sc.nextInt();
			}
			//カードの色を入れる配列作成
			String[] color={sc.next(),sc.next(),sc.next(),sc.next(),sc.next(),sc.next(),sc.next(),sc.next(),sc.next()};
			int Rcount=0;
			int Gcount=0;
			int Bcount=0;
			//Redカード、Greenカード、Blueカードの枚数を調べる
			for(int j=0;j<9;j++) {
				switch(color[j]) {
				case "R":
					Rcount++;
					break;
				case "G":
					Gcount++;
					break;
				case "B":
					Bcount++;
					break;
				}
			}
			//色ごとの配列を作成（color[x]が"R"のときにnum[x]を作成した配列に入れる。GreenとBlueも同様に行う）
			//ArrayList<Integer> Rary=new ArrayList<Integer>();
			int alignedCount=0;//揃っているカードのセット数
			int[] Rary=new int[Rcount];
			int[] Gary=new int[Gcount];
			int[] Bary=new int[Bcount];
			int count=0;//Raryのインデックス番号の指定に必要
			for(int j=0;j<9;j++) {
				if("R".equals(color[j])) {
					Rary[count]=num[j];
					count++;
				}
			}
			Arrays.sort(Rary);
			//赤色のカードが3以上の時の処理
			if(Rcount>=3) {
				for(int j=0;j<Rcount-2;j++) {
					for(int k=j+1;k<Rcount-1;k++) {
						for(int l=k+1;l<Rcount;l++) {
							//連番または数が同一であり、3っつの整数の乗算が0でないときの処理
							if(((Rary[j]==Rary[k]-1 && Rary[j]==Rary[l]-2) || (Rary[j]==Rary[k] && Rary[j]==Rary[l])) && Rary[j]*Rary[k]*Rary[l]!=0) {
								alignedCount++;
								//上記の条件に一致したものを0とし、事実上除外する
								Rary[j]=0;
								Rary[k]=0;
								Rary[l]=0;
							}
						}
					}
				}
			}
			count=0;
			for(int j=0;j<9;j++) {
				if("G".equals(color[j])) {
					Gary[count]=num[j];
					count++;
				}
			}
			Arrays.sort(Gary);
			if(Gcount>=3) {
				for(int j=0;j<Gcount-2;j++) {
					for(int k=j+1;k<Gcount-1;k++) {
						for(int l=k+1;l<Gcount;l++) {
							if(((Gary[j]==Gary[k]-1 && Gary[j]==Gary[l]-2) || (Gary[j]==Gary[k] && Gary[j]==Gary[l])) && Gary[j]*Gary[k]*Gary[l]!=0) {
								alignedCount++;
								Gary[j]=0;
								Gary[k]=0;
								Gary[l]=0;
							}
						}
					}
				}
			}
			count=0;
			for(int j=0;j<9;j++) {
				if("B".equals(color[j])) {
					Bary[count]=num[j];
					count++;
				}
			}
			Arrays.sort(Bary);
			if(Bcount>=3) {
				for(int j=0;j<Bcount-2;j++) {
					for(int k=j+1;k<Bcount-1;k++) {
						for(int l=k+1;l<Bcount;l++) {
							if(((Bary[j]==Bary[k]-1 && Bary[j]==Bary[l]-2) || (Bary[j]==Bary[k] && Bary[j]==Bary[l])) && Bary[j]*Bary[k]*Bary[l]!=0) {
								alignedCount++;
								Bary[j]=0;
								Bary[k]=0;
								Bary[l]=0;
							}
						}
					}
				}
			}
			if(alignedCount==3) {
				System.out.println("1");
			}else {
				System.out.println("0");
			}
		}
	}

}



Measured memory_bytes: 28688
#排他的論理和 x^y
n=int(input())
a=list(map(int,input().split()))
k=0
for i in range(0,n-1,2):
  k=k^a[i]^a[i+1]

for i in range(n):
  print(k^a[i],end=" ")
  
  
  
  

Measured memory_bytes: 31400
#include <cstdio>
#include <utility>
#include <vector>
#include <queue>

const long long int INF = 1001001001001001001LL;
int N, Q, K;
long long int dist[100010];
std::vector< std::pair<int, int> > G[100010];

int main() {
    scanf("%d", &N);
    for(int i=0; i<N-1; i++) {
        int a, b, c; scanf("%d%d%d", &a, &b, &c);
        a--; b--;
        G[a].push_back(std::make_pair(b, c));
        G[b].push_back(std::make_pair(a, c));
    }

    scanf("%d%d", &Q, &K); K--;
    for(int i=0; i<N; i++) if(i != K) dist[i] = INF;

    std::priority_queue< std::pair<long long int, int>, std::vector< std::pair<long long int, int> >,
        std::greater< std::pair<long long int, int> > > q;
    q.push(std::make_pair(0, K));
    while(!q.empty()) {
        std::pair<long long int, int> t = q.top(); q.pop();
        int cur = t.second;
        for(auto e : G[cur]) {
            int to = e.first, cost = e.second;
            if(dist[to] > dist[cur] + cost) {
                dist[to] = dist[cur] + cost;
                q.push(std::make_pair(dist[to], to));
            }
        }
    }

    for(int i=0; i<Q; i++) {
        int x, y; scanf("%d%d", &x, &y);
        x--; y--;
        long long int ret = dist[x] + dist[y];
        printf("%lld\n", ret);
    }
}

Measured memory_bytes: 10096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int n,m;
vector<int> v[max_n];
struct Seg//min 
{
    #define lson l,mid,rt<<1
    #define rson mid+1,r,rt<<1|1
    int d[1<<20],lazy[1<<20];
    void pushup(int rt)
    {
        d[rt]=min(d[rt<<1],d[rt<<1|1]);
    }
    void pushdown(int rt,int ln=1,int rn=1)
    {
        if(lazy[rt])
        {
            d[rt<<1]+=lazy[rt]*ln;
            d[rt<<1|1]+=lazy[rt]*rn;
            lazy[rt<<1]+=lazy[rt];
            lazy[rt<<1|1]+=lazy[rt];
            lazy[rt]=0;
        }
    }
    void init(int l,int r,int rt)
    {
        d[rt]=INT_MAX,lazy[rt]=0;
        if(l==r)return;
        int mid=l+r>>1;
        init(lson),init(rson);
    }
    void ins(int x,int c,int l,int r,int rt)
    {
        if(l==r)
        {
            d[rt]=c;
            return;
        }
        int mid=l+r>>1;
        pushdown(rt);
        if(x<=mid)ins(x,c,lson);
        else ins(x,c,rson);
        pushup(rt);
    }
    void update(int L,int R,int C,int l,int r,int rt)
    {
        if(L>R)return;
        if(l>=L&&r<=R)
        {
            d[rt]+=C;
            lazy[rt]+=C;
            return;
        }
        int mid=l+r>>1;
        pushdown(rt);
        if(mid>=L)update(L,R,C,lson);
        if(mid<R)update(L,R,C,rson);
        pushup(rt);
    }
    int query(int L,int R,int l,int r,int rt)
    {
        if(L>R||L>r||R<l)return INT_MAX;
        if(l>=L&&r<=R)return d[rt];
        int mid=l+r>>1;
        pushdown(rt);
        return min(query(L,R,lson),query(L,R,rson));
    }
}Tree;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        int l,r;scanf("%d%d",&l,&r);
        v[l].push_back(r);
    }
    Tree.init(1,m+1,1);
    for(int i=1;i<=m+1;i++)Tree.ins(i,-i,1,m+1,1);
    int ans=max(n-m,0);
    for(int i=0;i<=m;i++){
        for(auto x:v[i])Tree.update(1,x,-1,1,m+1,1);
        int res=-Tree.query(i+1,m+1,1,m+1,1);
        ans=max(ans,res-i-m-1);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 16768
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		double x1,y1,x2,y2,X,Y,dis;
		String str;
		
		Scanner as = new Scanner(System.in);
		
		x1 = as.nextDouble();
		y1 = as.nextDouble();
		x2 = as.nextDouble();
		y2 = as.nextDouble();
		
		X = x1 - x2;
		Y = y1 - y2;
		
		dis = Math.sqrt((X*X)+(Y*Y));
		
		str = String.valueOf(dis);
		System.out.println(str);

	}

}

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

ll gojyo (ll s,ll t){
    ll max,ama,fb,sum=0,h;
    if(t>s){
        h=t;
        t=s;
        s=h;
    }
    fb=t;
    while(1){
        if(s%t==0&&sum==0){
            max=fb;
            break;
        }
        
        else if(s%t==0){
            max=ama;
            break;
        }
        else {
            ama=s%t;
            s=t;
            t=ama;
            sum+=1;
        }
    }
    return max;
}



int main(){
    ll a,b;
    cin >>a>>b;

    ll ans;

    ll max =gojyo(a,b);

    ans =(a*b)/max;

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

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


int main(){
    int i,k=0,n,o=0,z=0;
    char s[100010];
    scanf("%s",s);
    n=strlen(s);
    for(i=0;i<n;i++){
        if(s[i]=='0')z+=2;
        else o+=2;
    }
    if(z>o)printf("%d\n",o);
    else printf("%d\n",z);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


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

	scanf("%d%d%d%d", &a, &b, &c, &d);

	while (1) {
		c -= b;
		if (c <= 0) {
			printf("Yes\n");
			return 0;
		}
		a -= d;
		if (a <= 0) {
			printf("No\n");
			return 0;
		}
		
	}

	return 0;
}

Measured memory_bytes: 3764
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a,b = i2()
if a >= b:
	print(a + max(a-1,b))
else:
	print(b + max(a,b-1))

Measured memory_bytes: 3064
m,s,*f=10**9+7,0,1;p=->a,b{b>0?a**b[0]*p[a*a%m,b>>1]:1};eval"H,W,A,B="+`tr \\  ,`;200000.times{|i|f<<f[-1]*-~i%m};(B...W).map{|i|s+=f[H-A-1+i]*f[A+W-i-2]*p[f[H-A-1]*f[i]*f[A-1]*f[W-1-i],m-2]};p s%m

Measured memory_bytes: 21904
#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;

int main()
{
	int n, t, h, w;
	int x[100 * 100 + 1] = { 0 };

	int ans[105][105] = { 0 };
	scanf("%d %d", &h, &w);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &x[i]);
	}
	int cur = 1;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
		{
			if (x[cur] == 0)
				cur++;
			x[cur]--;
			ans[i][j] = cur;
		}

	for (int i = 0; i < h; i++)
		if(i%2==0)
			for (int j = 0; j < w; j++)
			{
				printf("%d", ans[i][j]);
				if (j < w - 1)
					printf(" ");
				else
					printf("\n");
			}
		else
			for (int j = w-1 ; j >=0; j--)
			{
				printf("%d", ans[i][j]);
				if (j > 0)
					printf(" ");
				else
					printf("\n");
			}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();

  ll a,b;
  cin>>a>>b;
  if(a==b)cout<<0;
  else if((a+b)%2==0)cout<<(a+b)/2;
  else cout<<"IMPOSSIBLE";

  return 0;
}

Measured memory_bytes: 256
// @uthor........ _|EE|_

#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define u_set unordered_set<int>
#define pb push_back
#define M 1000000007
#define endl "\n"
#define BRISK ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

signed main()
{
    BRISK;
    int n,m;
    cin>>n>>m;
    int a[n];
    double sum=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
    }
    sum = (double)sum/(4*m);
    int c=0;
    for(int i=0;i<n;i++){
      if(a[i]>=sum)c++;
    }
    if(c>=m)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    static public void main(String args[]) {
	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();

	for(int i=1; i<=n; i++) {
	    int x = i;
	    if (x % 3 == 0) {
		System.out.print(" "+i);
	    } else {
		do {
		    if (x % 10 == 3) {
			System.out.print(" "+i);
			break;
		    }
		    x /= 10;
		} while (x>0);
	    }
	}
	System.out.print("\n");
    }
}	
					    

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

int main() {
    int a,b,c,k; cin >> a >> b >> c >> k;
    if(a >= k) cout << k << '\n';
    else if(a + b >= k) cout << a << '\n';
    else cout << a - (k - a - b) << '\n';
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        String s = std.next();
        String reversed = new StringBuilder(s).reverse().toString();

        String[] texts = {"dream", "dreamer", "erase", "eraser"};
        String[] reversedText = new String[texts.length];
        for (int i = 0; i < texts.length; i++) {
            reversedText[i] = new StringBuilder(texts[i]).reverse().toString();
        }

        StringBuilder sb = new StringBuilder(reversed);
        while (sb.length() != 0) {
            boolean updated = false;
            for (int i = 0; i < reversedText.length; i++) {
                String r = reversedText[i];
                if (sb.indexOf(r) == 0) {
                    sb.delete(0, r.length());
                    updated = true;
                    break;
                }
            }

            if (!updated) {
                System.out.println("NO");
                return;
            }
        }

        System.out.println("YES");
    }
}


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

using namespace std;

int main(void){
    int n;
    cin >> n;
    long a,b;
    long asum = 0;
    long bmax = 0;
    int flag = 0;
    vector< pair<long,long>> ab(n);
    for(int i=0;i<n;i++){
        cin >> a >> b;
        ab[i] = make_pair(b,a);
        asum += a;
        if(bmax < b)bmax = b;
        if(a > b)flag = 1;
    }
    sort(ab.begin(),ab.end());
    if(asum > bmax){
        flag = 1;
    }else{
        asum = 0;
        for(int i=0;i<n;i++){
            asum += ab[i].second;
            if(asum > ab[i].first){
                flag = 1;
                break;
            }
        }
    }
    if(flag)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3328
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize1; n]
    }
    let mut w: Vec<(usize, usize)> = v.iter().cloned().enumerate().collect();
    w.sort_by_key(|x| x.1);
    let mut a = vec![0; n * n];
    let mut l = 0;
    for &(i, j) in &w {
        a[j] = i + 1;
        for _ in 0..i {
            while l < j && a[l] != 0 {
                l += 1;
            }
            if l == j {
                println!("No");
                return;
            }
            a[l] = i + 1;
        }
    }
    for i in 0..n {
        while l < n * n && a[l] != 0 {
            l += 1;
        }
        if l < w[i].1 {
            println!("No");
            return;
        }
        for _ in 0..n - w[i].0 - 1 {
            while a[l] != 0 {
                l += 1;
            }
            a[l] = w[i].0 + 1;
        }
    }
    println!("Yes");
    for i in 0..n * n - 1 {
        print!("{} ", a[i]);
    }
    println!("{}", a[n * n - 1]);
}


Measured memory_bytes: 7292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int n;
  cin >>n;
  
  cout << 3*n*n << endl;
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string A, B;
    cin >> A >> B;
    rep(i, 3) {
        if (A[i] != B[2-i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

const int mod = 1e9 + 7;

int lgp(int a, int b) {
    int res = 1;
    for(; b; b /= 2) {
        if(b & 1) {
            res =1LL*res * a % mod;
        }
        a = 1LL*a * a % mod;
    }
    return res;
}
int main() {
   // ifstream cin("data.in");
    int n, k;
    cin >> n >> k;
    vector<int>val(n);
    for(int i = 0; i < n; i++)
        cin >> val[i];

    int rez = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < i; ++j) {
            if(val[i] > val[j]) {
                int tot = (1LL * k * (k - 1) ) %mod;
                rez = (rez + tot) % mod;
            }
        }
        for(int j = i + 1; j < n; ++j) {
            if(val[i] > val[j]) {
                int tot = (1LL * k * (k + 1) ) % mod;
                rez = (rez + tot) % mod;
            }
        }
    }


    cout << (1LL * rez * lgp(2, mod - 2)) % mod;
    return 0;
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll n , a, b;
	cin >> n >> a >> b;
	ll ans = 1;
	if(n == 1){
		if(a != b){
			ans = 0 ;//要素は1個なのに、最小と最大が違うようなものは存在しない
		}
	}
	else if(n >= 2){
		if(a > b){
			ans = 0 ;
		}
		else{
			ans = (b-a)*(n-2)+1;
		}
		//最大b < 最小a となるとき、作り方は存在しないので0
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
d=deque([1,2,3,4,5,6,7,8,9])
k=int(input())
for i in range(k):
    a=d.popleft()
    b=a%10
    if b!=0:
        d.append(a*10+b-1)
    d.append(a * 10 + b)
    if b!=9:
        d.append(a * 10 + b + 1)

print(a)

Measured memory_bytes: 11956
#include <iostream>
using namespace std;
int f(int x,int y){
        return (x-y)*(x-y);
    }
int main(void){
    int n;
    cin>>n;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int ans=99999999;
    for(int k=0;k<100;k++){
        int hoge=0;
        for (int y=0;y<n;y++){
            hoge=hoge+f(x[y],k);
        }
        ans=min(ans,hoge);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>

int main()
{
    int k, a, b, i, flag;
    std::cin >> k >> a >> b;
    flag = 0;
    for(i = a; i <= b; i++){
        if(i%k==0){
            flag = 1;
            break;
        }
    }
    if(flag == 0){
        std::cout << "NG" << std::endl;
    } else {
        std::cout << "OK" << std::endl;
    }

    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = unsigned long long;
using P = pair<int, int>;

const ll LIMIT = 1'000'000'000'000'000'000;
const int LIMIT_KETA = 18;

int calcKeta(ll n) {
  int res = 0;
  while ((n / 10) != 0) {
    res++;
    n /= 10;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  ll res = 1;
  ll beforeRes = res;
  bool over = false;
  bool containZero = false;
  rep(i, n) {
    int resKeta = calcKeta(res);
    ll aa;
    cin >> aa;
    int aaKeta = calcKeta(aa);
    if (resKeta + aaKeta > LIMIT_KETA) {
      res = 0;
      over = true;
    }
    res *= aa;
    if (res > LIMIT) {
      res = 0;
      over = true;
    }
    if (res < beforeRes) {
      res = 0;
      over = true;
    }
    if (aa == 0) {
      res = 0;
      containZero = true;
      break;
    }
    beforeRes = res;
  }
  if (containZero) {
    cout << 0 << endl;
  } else if (over) {
    cout << -1 << endl;
  } else {
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

string str = "ENWS";
int main() {
  int w,h;
  while(cin>>w>>h,w||h) {
    char ba[w][h];
    REP(y,h) REP(x,w) cin >> ba[x][y];
    int res = -1;
    REP(time, 180) {
      int man = 0;
      REP(y,h) {
        //cout << endl;
        REP(x,w) {
          REP(i,4) {
            if (ba[x][y] == str[i]) {
              man++;
              REP(k,4) {
                int d = (i+3+k)%4;
                int xx = x+dx[d];
                int yy = y+dy[d];
                if (ba[xx][yy]=='X'||ba[xx][yy]=='.') {
                  ba[x][y] = str[d];
                  goto OUT;
                }
              }
            }
          }
        OUT:;
        }
      }
      char next[w][h];
      memcpy(next, ba, sizeof(ba));
      REP(x,w) {
        REP(y,h) {
          if (ba[x][y] != '.' && ba[x][y] != 'X') continue;
          REP(k,4) {
            int xx = x+dx[k];
            int yy = y+dy[k];
            if (xx<0||xx>=w||yy<0||yy>=h) continue;

            if (ba[xx][yy] == str[(k+2)%4]) {
              if (ba[x][y] == '.')
                next[x][y] = ba[xx][yy];
              else
                man--;
              next[xx][yy] = '.';
              break;
            }
          }
        }
      }
      if (man==0) {
        res = time + 1;
        break;
      }
      memcpy(ba,next,sizeof(next));
    }
    if (res>=0)
      cout << res << endl;
    else
      cout << "NA" << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int dp[3005][3005];
int N,m;
vector < pair<int,int> > v;
int func(int n, int times)
{
    if(times<=0) return 0;
    if(n < 0) return 0;
    if(dp[n][times]!=-1) return  dp[n][times];
    int ans1=0,ans2=0;
    ans1 += func(n-1,times-v[n].fr)+v[n].se;
    ans2 += func(n-1,times);

    return dp[n][times] = max(ans1,ans2);

}

bool cmp(pair <int,int> &p1, pair<int,int> &p2)
{
    if(p1.fr>p2.fr) return 1;
    if(p1.fr == p2.fr){
        if(p1.se > p2.se) return 1;
    }
    return 0;
}

int main()
{
   fast;
   memset(dp,-1,sizeof dp);
   cin >> N >> m;
   for(int i=0; i<N; i++){
      int k1,k2;
      cin >> k1 >> k2;
      v.pb({k1,k2});
   }
   sort(v.begin(),v.end(),cmp);
//   puts("");
//   for(int i=0; i<N; i++) cout << v[i].fr << " " << v[i].se << "\n";
   cout << func(N-1,m) << "\n";

   return 0;
}


Measured memory_bytes: 35712
#include<iostream>
#include<vector>
#include<limits>
#include<algorithm>

using namespace std;

const int INF = std::numeric_limits<int>::max()/10;

int main(void){
    int N, M, R;
    cin >> N >> M >> R;

    vector<int> r;
    for(int i=0; i<R; i++){
        int x;
        cin >> x;
        r.push_back(x-1);
    }

    sort(r.begin(), r.end());
    
    vector<vector<int>> v(N, vector<int>(N, INF));
    for(int i=0;i<N;i++) v[i][i] = 0;
    for(int i=0; i<M; i++){
        int A, B, C;
        cin >> A >> B >> C;
        v[A-1][B-1] =  v[B-1][A-1] = C;
    }

    vector<vector<int>> w  = v;
    for(int k=0;k<N;k++)
        for(int i=0;i<N;i++)
            for(int j=0;j<N;j++)
                w[i][j] = min(w[i][j], w[i][k]+w[k][j]);

    int ans = numeric_limits<int>::max();
    do {
        int d = 0;
        for(int i=0;i<R-1;i++){
            d += w[r[i]][r[i+1]];
        }
        ans = min(ans, d);
    } while(next_permutation(r.begin(), r.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{
 	int a,b;
 
	scanf("%d %d", &a,&b);
	
	if(a<b){
		printf("a < b\n");
	}
	
	else if(a>b){
		printf("a > b\n");
	}
	
	else if(a==b){
		printf("a == b\n");
	}	

		
   return 0;
   
}

Measured memory_bytes: 2620
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
    int N_given,W_given_total;
    cin >> N_given >> W_given_total;
    
    int w_given[N_given];
    int v_given[N_given];
    
    rep(i,N_given){
        cin >> w_given[i] >> v_given[i];
    }
    
    int w_bound = 200000;
    ll dp[N_given+10][w_bound]={0};
    
    rep(i,N_given){
        rep(j,W_given_total+1){
            if(j-w_given[i]>=0){
                chmax(dp[i+1][j],dp[i][j-w_given[i]]+v_given[i]);
            }
            chmax(dp[i+1][j],dp[i][j]);
        }
    }
    
    cout << dp[N_given][W_given_total] << endl;
    
}


Measured memory_bytes: 171904
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <utility>
using namespace std;

int solve_testcase() {
  int W, H; cin >> W >> H;
  if(W == 0 and H == 0) return 1;

  auto in_x = [&](int x) {
    return (x >= 0 and x <= H);
  };
  auto in_y = [&](int y) {
    return (y >= 0 and y <= W);
  };

  map<int, int> cmpx, cmpy;

  int N; cin >> N;
  vector<int> xl(N), yl(N), xr(N), yr(N);
  for(int i=0; i<N; i++) {
    cin >> yl[i] >> xl[i] >> yr[i] >> xr[i];
    for(int k=-1; k<=1; k++) {
      if(in_x(xl[i] + k)) cmpx[ xl[i] + k ]++;
      if(in_x(xr[i] + k)) cmpx[ xr[i] + k ]++;

      if(in_y(yl[i] + k)) cmpy[ yl[i] + k ]++;
      if(in_y(yr[i] + k)) cmpy[ yr[i] + k ]++;
    }
  }

  cmpx[0]++; cmpx[H]++;
  cmpy[0]++; cmpy[W]++;
  
  int id_x = 0, id_y = 0;
  for(auto &e : cmpx) e.second = id_x++;
  for(auto &e : cmpy) e.second = id_y++;

  int CH = cmpx[H], CW = cmpy[W];
  vector< vector<int> > sum(id_x, vector<int>(id_y));
  for(int i=0; i<N; i++) {
    sum[ cmpx[ xl[i]     ] ][ cmpy[ yl[i]     ] ]++;
    sum[ cmpx[ xl[i]     ] ][ cmpy[ yr[i]     ] ]--;
    sum[ cmpx[ xr[i]     ] ][ cmpy[ yl[i]     ] ]--;
    sum[ cmpx[ xr[i]     ] ][ cmpy[ yr[i]     ] ]++;

    // fprintf(stderr, "before\n");
    // for(int x=0; x<CH; x++) {
    //   for(int y=0; y<CW; y++) {
    // 	fprintf(stderr, "%2d ", sum[x][y]);
    //   }
    //   fprintf(stderr, "\n");
    // }
  }



  for(int i=0; i<CH; i++) {
    for(int j=1; j<CW; j++) {
      sum[i][j] += sum[i][j-1];
    }
  }
  for(int j=0; j<CW; j++) {
    for(int i=1; i<CH; i++) {
      sum[i][j] += sum[i-1][j];
    }
  }

  // fprintf(stderr, "after\n");
  // for(int i=0; i<CH; i++) {
  //   for(int j=0; j<CW; j++) {
  //     fprintf(stderr, "%2d ", sum[i][j]);
  //   }
  //   fprintf(stderr, "\n");
  // }

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

  vector< vector<bool> > used(CH, vector<bool>(CW));
  queue< pair<int, int> > que;
  int ans = 0;
  for(int i=0; i<CH; i++) {
    for(int j=0; j<CW; j++) {
      if(used[i][j] or sum[i][j] > 0) continue;
      ans++;
      que.emplace(i, j);
      used[i][j] = true;

      while(que.size()) {
	int x, y; tie(x, y) = que.front(); que.pop();
	for(int k=0; k<4; k++) {
	  int nx = x + dx[k], ny = y + dy[k];
	  if(nx < 0 or nx >= CH or ny < 0 or ny >= CW) continue;
	  if(sum[nx][ny] > 0) continue;
	  if(used[nx][ny]) continue;
	  used[nx][ny] = true;
	  que.emplace(nx, ny);
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  // freopen("/dev/null", "w", stderr);
  while(!solve_testcase());
  return 0;
}



Measured memory_bytes: 10380
#include <bits/stdc++.h>
//#define DEBUG

using namespace std;
int n, a[137510];
struct node {
    int id, point;
} node[1<<21];

void add(int id, int x)
{
    id=n-1+id;
    node[id].point+=x;

    while (id>0) {
        id=(id-1)/2;
        int c1=2*id+1, c2=2*id+2;
        if (node[c1].point>=node[c2].point)
            node[id]=node[c1];
        else
            node[id]=node[c2];
    }
}

void print()
{
#ifdef DEBUG
    int k=1;
    int x=0;
    while (true) {
        for(int i=0;i<k;++i) printf("(%d %d)", node[x+i].id, node[x+i].point);
        puts("");
        x+=k;
        k<<=1;
        if (x>=n) break;
    }
    puts("");
#endif
}

int main()
{
    int m, r, l;
    scanf("%d%d%d", &m, &r, &l);
    n=1;
    while (n<m) n<<=1;
    for(int i=0;i<m;++i) node[n-1+i].id=i;

    int pt=0;
    for(int i=0;i<r;++i) {
        int d, t, x;
        scanf("%d%d%d", &d, &t, &x);

        if (pt<t) {
            int id=node[0].id;
            a[id]+=t-pt;
        }
        add(d-1, x);
        print();
        pt=t;
    }
    print();
    a[node[0].id]+=l-pt;
#ifdef DEBUG
    for(int i=0;i<n;++i) printf("%d ", a[i]); puts("");
#endif
    printf("%d\n", 1+(max_element(a, a+n)-a));
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[200010],res[200010];
int main()
{
	cin >>n;
	for (int i=0;i<n-1;i++) cin >>a[i],res[a[i]-1]++;
	for (int i=0;i<n;i++) cout <<res[i]<<"\n";
	return 0;
}

Measured memory_bytes: 5196
// Problem : 
// 			D - Moving Piece
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int fun(vector<int> &v,int k)
{
	int end = v.size()-1, n =v.size();
	int mp[n+1];
	for(int l=1;l<=n;l++)
	{
		int curr = 0;
		for(int i=0;i<end+l;i++)
		{
			curr += v[i%n];
			if(i >= l)
				curr -=(v[i-l]);
			if(i >= l-1)
			{
				if(i==l-1)
					mp[l]=curr;
				else
					mp[l]=max(mp[l],curr);	
				//cout << mp[l] <<"\n";
			}		
		}
	}
	int ans;
	if(mp[n] > 0)
	{
		int q = k/n;
		int r = k%n;
		int curr=0,tmp = q*mp[n],rem=0;
		for(int i=1;i<=r;i++)
			rem = max(rem,mp[i]);
		tmp  += rem;
		if(q > 1)
		{
			curr = (q-1)*mp[n];
			int rem = 0;
			for(int i=1;i<=n;i++)
				rem = max(rem,mp[i]);
			curr += rem;
		}
		tmp = max(tmp,curr);
		ans = tmp;
	}
	else {
		ans = mp[1];
		for(int i=1;i<=n;i++)
		{
			//cout << mp[i] <<"\n";
			ans = max(ans,mp[i]);
		}
	}
	return ans;
}
void solve()
{
	int n,k;
	cin >> n >> k;
	vector<int> p(n),c(n),vis(n,0);
	for(auto &x:p)
	{
		cin >> x;
		x--;
	}
	for(auto &x:c)
		cin >> x;
	int ans = -mod;
	for(int i=0;i<n;i++)
	{
		if(vis[i]==0)
		{
			vector<int> tmp;
			int st = p[i];
			tmp.pb(c[i]);
			vis[i]=1;
			while(st != i)
			{
				tmp.pb(c[st]);
				vis[st] = 1;
				st = p[st];
			}
			ans = max(ans,fun(tmp,k));
		}
	}		
	cout << ans ; 
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	string S, T;
	cin >> S >> T;
	int cnt = 0;
	rep(i, 3) {
		if (S[i] == T[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

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

  int n, m;
  cin >> n >> m;

  vector<pair<int,char>> c(m);
  for (int i = 0; i < m; ++i) cin >> c[i].first >> c[i].second;

  for (int i = 0; i < 10000; ++i) {
    string s = to_string(i);
    if (s.length() > n) break;

    if (s.length() == n) {
      bool ok = true;

      for (int i = 0; i < m; ++i) {
        if (c[i].first > s.length()) {
          ok = false;
          break;
        }
        if (s[c[i].first-1] != c[i].second) ok = false;
      }

      if (ok) {
        cout << s << '\n';
        return (0);
      }
    }
  }

  cout << -1 << '\n';

  return (0);
}

Measured memory_bytes: 3656
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> da(n,vector<int>(0));
    vector<int> dp(n,0);
    vector<int> ju(n,0);
    for(int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        ju[y-1]+=1;
        da[x-1].push_back(y-1);
    }
    queue<int> q;
    for(int i=0;i<n;i++){
        if(ju[i]==0){
            q.push(i);
        }
    }
    int ans=0;
    while(!q.empty()){
        int x=q.front();
        q.pop();
        for(int i=0;i<da[x].size();i++){
            ju[da[x][i]]--;
            if(dp[da[x][i]]<=dp[x]){
                ans=max(ans,dp[x]+1);
                dp[da[x][i]]=dp[x]+1;
            }
            if(ju[da[x][i]]==0){
                q.push(da[x][i]);
            }
        }
    }
    cout << ans << endl;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

ll n,m,v,p;

int main(){
	cin >> n >> m >> v >> p;
	vector<ll>a(n);
	for(int i=0; i < n; i++)cin >> a[i];
	sort(rall(a));
	ll low = p, high = n;
	// cout << low << " " << high <<endl;
	while(low < high){
		ll mid = (low + high + 1)/2;
		ll total = 0;
		for(int i = 0; i < n; i++){
			if(i < p - 1|| i > mid - 1)total += m; // p-1位以上もしくはmid位以下の順位は自由に投票できる
			else {
				if (a[i] > a[mid - 1] + m){	//どう頑張っても無理な時
				total = -1;
				break;
				}
				total += (a[mid-1]+m)-a[i];
			}
		}
		if(total >= (ll)m*v)low = mid;
		else high = mid - 1;
		// cout << low << " " << high <<endl;
	}
	cout << low <<endl;
	
}

Measured memory_bytes: 1024
/**
 * Created by hiramekun at 20:53 on 2020-04-26.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    set<string> se;
    rep(i, n) se.insert(s[i]);
    cout << se.size() << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 25012
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
bool dfs(graph &G, vector< int > &d, int x) {
	rep(i, G[x].size()) {
		edge e = G[x][i];
		if (d[e.to] != LINF) {
			if (d[e.from] + e.d != d[e.to])
				return false;
		} else {
			d[e.to] = d[e.from] + e.d;
			if (!dfs(G, d, e.to))
				return false;
		}
	}
	return true;
}
signed main() {
	cin >> N >> M;
	graph G(N);
	rep(i, M) {
		int L, R, D;
		cin >> L >> R >> D;
		--L;
		--R;
		G[L].push_back(edge(L, R, D));
		G[R].push_back(edge(R, L, -D));
	}
	string ans = "Yes";
	vector< int > d(N, LINF);
	bool f = true;
	rep(i, N) {
		if (d[i] != LINF)
			continue;
		d[i] = 0;
		f &= dfs(G, d, i);
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(int i=0; i<n; i++)
#define rep(i,start,n) for(int i=start; i<n; i++)

signed main(){
    fast;  

    int t[3][3];
    int a[3]={0},b[3]={0};

    loop(3)
    rep(j,0,3){
    	cin>>t[i][j];
    	if(i==0)b[j]=t[i][j];
    }

    a[1]=t[1][0]-b[0];
    a[2]=t[2][0]-b[0];

    loop(3)
    rep(j,0,3){
    	if(t[i][j]!=a[i]+b[j]){
    		cout<<"No"<<endl;
    		return 0;
		}
    }

    cout<<"Yes"<<endl;
    return 0;
}


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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

const int MOD = 1e9 + 7;

bool uniq(vector<int> a) {
    set<int> st(all(a));
    return st.size() == a.size();
}

int main() {
    int N, M; cin >> N >> M;
    vector<int> a(N), b(M);
    rep(i, N) cin >> a[i], a[i]--;
    rep(j, M) cin >> b[j], b[j]--;
    if (!uniq(a) || !uniq(b)) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> row(N * M, -1), col(N * M, -1);
    rep(i, N) row[a[i]] = i;
    rep(j, M) col[b[j]] = j;
    int R = 0, C = 0, k = 0;
    ll ans = 1;
    for (int x = N * M - 1; x >= 0; x--) {
        int i = row[x], j = col[x];
        if (i >= 0 && j >= 0) {
            R++;
            C++;
        }
        if (i >= 0 && j == -1) {
            R++;
            ans = ans * C % MOD;
        }
        if (i == -1 && j >= 0) {
            C++;
            ans = ans * R % MOD;
        }
        if (i == -1 && j == -1) {
            ans = ans * (R * C - k) % MOD;
        }
        k++;
    }
    cout << ans << endl;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;
	int a; cin >> a;
	cout << a + a*a + a*a*a << endl;
	return 0;
}


Measured memory_bytes: 3628