akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, maxHonest = 0; cin >> N;
  vector<vector<pair<ll, ll>>> xy(N, vector<pair<ll, ll>>(0));
  rep(i, 0, N) {
  	ll A; cin >> A;
    rep(j, 0, A) {
      	ll x, y; cin >> x >> y;
      	x--;
    	xy[i].emplace_back(x, y);
    } 
  }
  vector<ll> honest(N);
  ll pcMax = (1 << N);
  rep(i, 0, pcMax) {
    ll pc = i, h = 0;
    bool unkind = 0;
  	rep(j, 0, N) {
    	honest[j] = pc % 2;
      	pc /= 2;
      	if (honest[j]) h++; 
    }
    rep(j, 0, N) {
    	if (honest[j]) {
        	for(auto k : xy[j]) {
            	if (k.second != honest[k.first]) {
                	unkind = 1;
                }
            }
        }
    }
    if (!unkind && maxHonest < h) {
    	maxHonest = h;
    }
  }
  cout << maxHonest << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	long long int valor = 0;
	vector<int> vi;
	cin >> n;
	for(int i = 1; i <= n;i++){
		if(i%3 != 0 && i%5!=0 && i%15!=0 )
			vi.push_back(i);
	}
	for(int i = 0; i < vi.size();i++){
		valor+=vi[i];
	}
	cout << valor << endl;
}

Measured memory_bytes: 7268
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int c[10][1010];
const ll INF = 1e18;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
  int H,W,k;
  cin >> H >> W >> k;
  vector<string> s(H);
  rep(i,H)cin >> s[i];
  ll ans = INF;
  rep(h,1<<(H-1)){
    vi id(H);
    int g = 0;
    rep(i,H){
      id[i] = g;
      if(h>>i&1)g++;
    }
    g++;
    Fill(c,0);
    rep(i,H)rep(j,W)c[id[i]][j]+=(s[i][j]-'0');
    ll cnt = g-1;
    vi now(g+1,0);
    auto add = [&](int w){
      rep(i,g)now[i]+=c[i][w]; 
      rep(i,g)if(now[i] > k) return false;
      return true;
    };
    rep(w,W){
     if(!add(w)){
       cnt++;
       now = vi(g);
       if(!add(w)){
         cnt = INF;
         break;
       }
     } 
    }
    mins(ans,cnt);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

vector<vector<int>> g;

void dfs(int now,int par,vector<int> &dep){
    if(par==-1) dep[now]=0;
    else dep[now]=1-dep[par];
    for(auto nex:g[now]){
        if(nex==par) continue;
        dfs(nex,now,dep);
    }
}

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

  int N;
  cin>>N;
  g.resize(N);
  rep(i,N-1){
      int a,b;
      cin>>a>>b;
      a--;b--;
      g[a].push_back(b);
      g[b].push_back(a);
  }

  vector<int> dep(N,0);
  dfs(0,-1,dep);

  int one=0,two=0;
  for(int i=0;i<N;i++){
      if(dep[i]==0) two++;
      else one++;
  }

  vector<int> ans(N,0);
  if(one<=N/3){
      int o=N/3+(N%3==0?0:1);
      int t=N/3+(N%3==2?1:0);
      for(int i=0;i<N;i++){
          if(dep[i]==1) ans[i]=3;
          else if(o>0){
              ans[i]=1;
              o--;
          }else if(t>0){
              ans[i]=2;
              t--;
          }
      }
      for(int i=0;i<N;i++) if(ans[i]==0) ans[i]=3;
  }else if(two<=N/3){
      int o=N/3+(N%3==0?0:1);
      int t=N/3+(N%3==2?1:0);
      for(int i=0;i<N;i++){
          if(dep[i]==0) ans[i]=3;
          else if(o>0){
              ans[i]=1;
              o--;
          }else if(t>0){
              ans[i]=2;
              t--;
          }
      }
      for(int i=0;i<N;i++) if(ans[i]==0) ans[i]=3;
  }else{
      int o=N/3+(N%3==0?0:1);
      int t=N/3+(N%3==2?1:0);
      for(int i=0;i<N;i++){
          if(dep[i]==1&&o>0){
              ans[i]=1;
              o--;
          }else if(dep[i]==0&&t>0){
              ans[i]=2;
              t--;
          }
      }
      for(int i=0;i<N;i++) if(ans[i]==0) ans[i]=3;   
  }

  int o=1,t=2,r=3;
  for(int i=0;i<N;i++){
      if(ans[i]==1){
          ans[i]=o;
          o+=3;
      }else if(ans[i]==2){
          ans[i]=t;
          t+=3;
      }else{
          ans[i]=r;
          r+=3;
      }
  }

  rep(i,N) cout<<ans[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
const ll mod = 1000000007;
ll beki(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = beki(10, N);
    ans -= beki(9, N);
    ans -= beki(9, N);
    ans += beki(8, N);
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double A, B, X;
  cin >> A >> B >> X;
  double res;
  if (X > A * A * B / 2) {
    X = A * A * B - X;
    res = atan(2 * X / A / A / A);
  } else {
    res = atan(A * B * B / 2 / X);
  }
  cout << fixed << setprecision(10) << res / 2 / M_PI * 360 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
}

int main()
{
	long long r, d, x;
	cin >> r >> d >> x;
	for (int i = 1; i <= 10; i++)
	{
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define LL long long
const int mod = 1e9 + 7;
LL dp[66][2][2],L, R; 

LL dfs(int x, bool Left, bool Right, bool zero) {
    if(x < 0) return 1; 
    if(dp[x][Left][Right] >= 0 && !zero) 
        return dp[x][Left][Right]; 
    LL ans = 0;
    int l = 0, r = 1; 
    if(Left) l = L >> x & 1; 
    if(Right) r = R >> x & 1; 
    for(int i = l ; i <= 1 ; i++) {
        for (int j = i ; j <= r ; j++) {
            if (j == 1 && zero) {
                if(i == 1) ans += dfs(x-1, Left && i == l, Right && j == r, zero && j == 0); 
            }
            else ans += dfs(x-1, Left && i == l, Right && j == r, zero && j == 0); 
        }
    }
    ans %= mod; 
    if(!zero) dp[x][Left][Right] = ans; 
    return ans; 
}
int main() {
    scanf("%lld%lld",  & L,  & R); 
    memset(dp, -1, sizeof(dp)); 
    printf("%lld \n", dfs(60, 1, 1, 1)); 
    //system("pause");
    return 0; 
}

Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::*;
use std::collections::BinaryHeap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let (n, m) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };

  let mut g: Vec<Vec<((usize, u64))>> = vec![vec![]; n];
  for _ in 0..m {
    let t: Vec<usize> = read_vec();
    g[t[0] - 1].push((t[1] - 1, 1));
  }

  let d = dijkstra_to_goal(n, &g, 0, n-1);
  if d == 2 {
    println!("POSSIBLE");
  } else {
    println!("IMPOSSIBLE");
  }
}



// 単一始点から全てのノードへの最短経路超を探索
fn dijkstra_to_goal(n: usize, adj_list: &Vec<Vec<(usize, u64)>>, start: usize, goal: usize) -> u64 {
  let mut dist = vec![std::u64::MAX; n];
  let mut p_queue: BinaryHeap<(i64, usize)> = BinaryHeap::new();

  //init
  dist[start] = 0;
  p_queue.push((0, start));

  while !p_queue.is_empty() {
    // 起点となるノード
    let (cost, now)
      = match p_queue.pop() {
        None => break,
        Some(e) => (-e.0 as u64, e.1),
      };

      if now == goal {
        break;
      }

    // 繋がっているノードを探索
    for &edge in &adj_list[now] {
      let next = edge.0;
      let weight = edge.1;

      if dist[next] > weight + cost {
        p_queue.push((-((weight + cost) as i64), next));
        dist[next] = weight + cost;
      }
    }

  }

  dist[goal]
}


Measured memory_bytes: 22780
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;

int main(){

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

	int ans = 0;
	rep(i, n){
		if(a[i] == b[i] and b[i] == c[i])ans += 0;
		if(a[i] == b[i] and b[i] != c[i])ans += 1;
		if(a[i] == c[i] and b[i] != c[i])ans += 1;
		if(b[i] == c[i] and a[i] != b[i])ans += 1;
		if(a[i] != b[i] and b[i] != c[i] and a[i] != c[i])ans += 2;
	}

	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(m)]
    guki=list(map(int,input().split()))
    ans=0
    for i in range(2 ** n):
        cnt=[0]*m
        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):
                for k in range(m):
                    if j+1 in l[k][1:]:
                        cnt[k]+=1
        check = 0
        for x in range(m):

            if cnt[x]%2==guki[x]:
                check+=1
        if check==m:
            ans+=1
    print(ans)

resolve()

Measured memory_bytes: 42096
//https://atcoder.jp/contests/abc123/tasks/abc123_a
#include<bits/stdc++.h>
using namespace std;
#define aakriti long long int
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        aakriti a, b, c, d, e, k ;
        cin >> a >> b >> c >> d >> e >> k ;
        if(e - a > k or e - b > k or e - c > k or e - d > k)
        cout << ":(\n";
        else
        {
                cout << "Yay!\n";
        }
         
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,a=0,i;
	char s[100000];
	scanf("%d %s",&n,&s);
	for(i=0;i<n;i++){
		if(s[i]!=s[i+1]) a++;
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 1824
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner cin=new Scanner(System.in);
		
		while(true) {
			int H=cin.nextInt(),W=cin.nextInt();
			if(H==0 && W==0)break;
			for(int i=0;i<H;i++) {
				for(int j=0;j<W;j++)System.out.print('#');
				System.out.print("\n");
			}
			System.out.print("\n");
		}

	}

}



Measured memory_bytes: 39428
function Main(input){
	var flag = false;
	input = input.split(" ").map(Number);
	for(var i=0;i<=input[0];i++){
		for(var j=0;j<=input[1];j++){
			if(i*input[1]+j*input[0]-i*j*2==input[2]){
				flag = true;
				break;
			}
		}
	}
	console.log(flag?"Yes":"No");
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 20808
#include<bits/stdc++.h>
#define ll 	 long long
#define pb push_back
#define mp make_pair
using namespace std;


int main()
{

ll n,m,sum=0, i, j, k; cin>>n>>m;
ll a[100009], b[100009];

for( i=0; i<n; i++) cin>>a[i]>>b[i], sum+=b[i];

ll dp[sum+9];
dp[0]=0;
   for( i=1;i<=sum;i++){
       dp[i]=1e18;
   }



for(i=0; i<n; i++)
{
	for( j= sum; j>=b[i]; j--)
	{
		
		dp[j]= min(dp[j],dp[j-b[i]]+a[i]);
	
	}
}

for( i= sum; i>=0; i--)
{
	if(dp[i]<=m)
	{
		cout<<i<<endl;
		break;
	}
}

     return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n, flag = 0;
    cin >> n;
    while (n) {
        if (n % 10 == 7) {
            flag = 1;
            break;
        }
        n /= 10;
    }
    cout << (flag == 1 ? "Yes" : "No");
    return 0;
}


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

using Edge = pair<int,int>;
using Graph = vector<vector<int> >;

Graph G;

vector<int> res;
vector<int> tmp;

//ツリー探索pはvの親。vをcに塗る
void dfs(int v, int c){
    res[v] = tmp[v] + c;
    for(auto e : G[v]){
        //if(e.first == p) continue;//子から親へ逆流を防ぐ
        dfs(e,res[v]);
    }
}

int main(){
    int N,Q;cin >> N >> Q;
    G.resize(N+1);
    for(int i = 0; i < N-1 ; i++){
        int u,v,w;cin >> u >> v;
        u--;v--;
        G[u].push_back(v);
        //G[v].push_back(u);
    }
    res.assign(N,0);
    tmp.assign(N,0);
    for(int i = 0; i < Q ; i++){
        int p,x;cin >> p >> x;
        p--;
        tmp[p] += x;
    }
    dfs(0,0);

    for(auto v : res)cout << v << " ";
    cout << "\n";

    return 0;
}

Measured memory_bytes: 21120
typedef int ll;
#include <bits/stdc++.h>
using namespace std;
// 出典：https://qiita.com/drken/items/cce6fc5c579051e64fab
template<class Abel> struct UnionFind {vector<int> par;vector<int> rank;vector<Abel> diff_weight;UnionFind(int n = 1, Abel SUM_UNITY = 0) {init(n, SUM_UNITY);}void init(int n = 1, Abel SUM_UNITY = 0) {par.resize(n); rank.resize(n); diff_weight.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);diff_weight[x] += diff_weight[par[x]];return par[x] = r;}}Abel weight(int x) {root(x);return diff_weight[x];}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y, Abel w) {w += weight(x); w -= weight(y);x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y), w = -w;if (rank[x] == rank[y]) ++rank[x];par[y] = x;diff_weight[y] = w;return true;}Abel diff(int x, int y) {return weight(y) - weight(x);}};

int main() {
    ll n;
    std::cin >> n;
    vector<tuple<ll,ll,ll>> edges;
    vector<tuple<ll,ll,ll>> xys(n);
    for (int i = 0; i < n; i++) {
        ll x,y;
        std::cin >> x>>y;
        xys[i] = make_tuple(i,x,y);
    }
    
    sort(xys.begin(),xys.end(), [](auto a, auto b){
        return get<1>(a) < get<1>(b); 
    });
    
    for (int i = 0; i < n-1; i++) {
        edges.push_back(make_tuple(get<0>(xys[i]), get<0>(xys[i+1]),get<1>(xys[i+1])-get<1>(xys[i])));
    }
    
    sort(xys.begin(),xys.end(), [](auto a, auto b){
        return get<2>(a) < get<2>(b); 
    });
    
    for (int i = 0; i < n-1; i++) {
        edges.push_back(make_tuple(get<0>(xys[i]), get<0>(xys[i+1]),get<2>(xys[i+1])-get<2>(xys[i])));
    }
    
    UnionFind<ll> uf(n);
    
    sort(edges.begin(),edges.end(),[](auto a, auto b){
        return get<2>(a) < get<2>(b);
    });
    
    ll res = 0;
    for (auto e : edges) {
        if( !uf.issame(get<0>(e),get<1>(e)) ){
            res += get<2>(e);
            uf.merge(get<0>(e),get<1>(e),0);
        }
    }
    
    std::cout << res << std::endl;
}


Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if(n == 1)
    {
        cout << "Hello World";
    }
    else
    {
        int a,b;
        cin >> a >> b;
        cout << a + b;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<long long int, long long int> P;

int main() {

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

	long long int ans = 1;

	vector<long long int> aa;

	for (long long int i = 1; i*i <= m; i++) {
		if (m % i == 0) {
			aa.push_back(i);
			aa.push_back(m / i);
		}
	}

	sort(aa.rbegin(), aa.rend());

	for (long long int i = 0; i < aa.size(); i++) {
		if (m / aa[i] >= n) {
			ans = aa[i];
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)

using namespace std;

char ch[10100];
int cnt_J=0,cnt_I=0;

int search_JOI(){
    cnt_J=0;
    REP(i,10001){
        if(ch[i]=='J')
            if(ch[i+1]=='O'&&ch[i+2]=='I'&&i+1<=10000&&i+2<=10000)cnt_J++;
            if(ch[i]==0)break;
    }
    return 0;
}

int search_IOI(){
    cnt_I=0;
    REP(i,10001){
        if(ch[i]=='I'&&ch[i+2]=='I'&&i+1<=10000&&i+2<=10000)
            if(ch[i+1]=='O'&&ch[i+2]=='I')cnt_I++;
            if(ch[i]==0)break;
    }
    return 0;
}

int main(){
    while(1){
        REP(i,10000)ch[i]=0;
        if(scanf("%s",&ch)==EOF)break;
        search_JOI();
        search_IOI();
        cout<<cnt_J<<endl;
        cout<<cnt_I<<endl;
    }
    return 0;
}

Measured memory_bytes: 1168
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import qualified Data.Map.Strict as M

main = abc163c

abc163c = do
    [n] <- getIntList
    as <- getIntList
    let m = genMap (VU.fromList (map fromIntegral as)) M.empty :: M.Map Int Int
    mapM_ (print . getValue m) [1 .. fromIntegral n]

genMap vu m
    | VU.length vu == 0 = m
    | otherwise = if M.member (VU.head vu) m
                  then genMap (VU.tail vu) (M.update (\x -> Just (x+1)) (VU.head vu) m)
                  else genMap (VU.tail vu) (M.insert (VU.head vu) 1 m)

getValue m k
    | M.member k m = m M.! k
    | otherwise = 0

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 23864
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb push_back

typedef long long ll;
const int N = 3000;
const ll mod = 1000000007;
vector<int> edge[N];
vector<int> redge[N];
int component[N];
vector<int> node;
bool vis[N];
int order;

void dfs(int now){
  if (vis[now])return;
  vis[now]=true;
  rep(i,(int)edge[now].size()){
    dfs(edge[now][i]);
  }
  node.pb(now);
}

void dfs(int now,int cmp){
  if (vis[now])return;
  vis[now]=true;
  component[now]=cmp;
  rep(i,(int)redge[now].size()){
    dfs(redge[now][i],cmp);
  }
}

int scc(int n){
  node.clear();
  rep(i,n)vis[i]=false;
  rep(i,n){
    if (!vis[i])dfs(i);
  }
  reverse(node.begin(),node.end());
  rep(i,n)vis[i]=false;
  int comp=0;
  rep(i,n){
    int now=node[i];
    if (!vis[now])dfs(now,comp),comp++;
  }
  return comp;
}


ll solve(int n){
  ll cnt[n];
  vector<int> cedge[n];
  vector<int> rcedge[n];
  int m=scc(n);
   //new graph
  rep(i,n){
    int now=i;
    rep(j,(int)edge[i].size()){
      int next=edge[i][j];
      if (component[now] != component[next]){
	cedge[  component[now]].pb(component[next]);
	rcedge[component[next]].pb(component[now]);
      }
    }
  }

  rep(i,m){
    sort(cedge[i].begin(),cedge[i].end());
    cedge[i].erase(unique(cedge[i].begin(),cedge[i].end()),
		   cedge[i].end());
    sort(rcedge[i].begin(),rcedge[i].end());
    rcedge[i].erase(unique(rcedge[i].begin(),rcedge[i].end()),
		    rcedge[i].end());
  }

  rep(i,m){
    int now = i;
    //bend now
    cnt[now]=1;
    rep(i,(int)rcedge[now].size()){
      cnt[now]=(cnt[rcedge[now][i]]*cnt[now])%mod;
    }
    //do not bend now 
    cnt[now]=(cnt[now]+1)%mod;
  }

  ll ret=1;
  rep(i,m){
    if (cedge[i].size() == 0){
      ret=(ret*cnt[i])%mod;
    }
  }
  return ret;
}

main(){
  int n,m;
  while(cin>>n>>m && n){
    rep(i,n)edge[i].clear(),redge[i].clear();
    rep(i,m){
      int f,t;
      cin>>f>>t;
      edge[f-1].pb(t-1);
      redge[t-1].pb(f-1);
    }
    cout << solve(n) << endl;
  }
  return false;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){

  int a[100],t,i,j,length,flag,count=0;
  
  scanf("%d",&length);
  
  for(i=0;i<length;i++)
    scanf("%d",&a[i]);
  
  flag = 1;
  while (flag){
    flag = 0;

    for(j=length-1;j>0;j--)
      {
	if(a[j]<a[j-1]){
	  t = a[j];
	  a[j] = a[j-1];
	  a[j-1]=t;
	  flag = 1;
	  count++;
	    }
      }
  }
  for(j=0;j<length;j++){
    
    printf("%d",a[j]);
    if(j != length-1)
      printf(" ");
  }
  printf("\n");
    
  printf("%d\n",count);

  return 0;
}



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

namespace ABC168_B
{
    class Program
    {
        static void Main(string[] args)
        {
            // 出力文字
            string output = string.Empty;

            // 桁数を入力
            int k = int.Parse(Console.ReadLine());

            // 文字を入力
            string s = Console.ReadLine();

            // 桁数チェック
            if (s.Length > k)
            {
                // 指定桁数オーバーの場合、切り取り
                output = s.Substring(0, k) + "...";
            }
            else
            {
                output = s;
            }

            // 出力
            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 27516
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    char grid[][] = new char [H][W];
    for(int i=0; i<H; i++){
      //for(int j=0; j<W; j++){
        grid[i]=sc.next().toCharArray();
      //}
    }
    
    int cnt[][] = new int [H][W];
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        if(grid[i][j] == '#'){
          cnt[i][j] = -1;
          continue;
        }
        if(j-1>=0 && grid[i][j-1] == '#'){
          cnt[i][j]++;
        }//left
        if(j+1<W && grid[i][j+1] == '#'){
          cnt[i][j]++;
        }//right
        if(i-1>=0 && grid[i-1][j] == '#'){
          cnt[i][j]++;
        }//up
        if(i+1<H && grid[i+1][j] == '#'){
          cnt[i][j]++;
        }//down
        if(i-1>=0 && j-1>=0 && grid[i-1][j-1] == '#'){
          cnt[i][j]++;
        }//left-up
        if(i-1>=0 && j+1<W && grid[i-1][j+1] == '#'){
          cnt[i][j]++;
        }//right-up
        if(i+1<H && j+1<W && grid[i+1][j+1] == '#'){
          cnt[i][j]++;
        }//left-down
        if(i+1<H && j-1>=0 && grid[i+1][j-1] == '#'){
          cnt[i][j]++;
        }//right-down
      }
    }
    String ans = "";
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        if(cnt[i][j]==-1){
          ans += '#';
        }else {
          ans += cnt[i][j];
        }
      }
      System.out.println(ans);
      ans = ""; 
    }
  }
}
    

Measured memory_bytes: 39480
#!/usr/bin/python3

#標準出力からの読み込み
input_a = input()
input_b = input()
k = int(input_a)
a = int(input_b.split(" ")[0])
b = int(input_b.split(" ")[1])

#判定ロジック
if b//k - a//k > 0:
    print("OK")
elif b//k - a//k == 0 and (b%k == 0 or a%k == 0):
    print("OK")
else:
    print("NG")


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

int main(void){
    int n; cin >> n;
    vector<ll>a(n),b(n),c(n);
    for(int i=0;i<n;i++) cin >> a[i];sort(a.begin(),a.end());
    for(int i=0;i<n;i++) cin >> b[i];sort(b.begin(),b.end());
    for(int i=0;i<n;i++) cin >> c[i];sort(c.begin(),c.end());
    ll ans=0;
    for(int i=0;i<n;i++){
        auto Iter_a = lower_bound(a.begin(),a.end(),b[i])-a.begin();
        auto Iter_c = c.end()-upper_bound(c.begin(),c.end(),b[i]);
        ans += Iter_a*Iter_c;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n;
    string s;
    int count=0;
    char c='0';
    cin>>n>>s;
    
    for(char sc : s){
        if(c!=sc)count++;
        c=sc;
    }
    cout<<count<<endl;
    return 0;
    
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

int n;
LL K;
const int maxn = 2e5 + 5;
LL A[maxn];
pair<LL, int> pre[maxn];
int c[maxn];

int sum(int p){
    int res = 0;
    for(int i = p;i > 0;i -= i & -i){
        res += c[i];
    }
    return res;
}

void add(int p, int v){
    for(int i = p;i < maxn;i += i & -i){
        c[i] += v;
    }
}


int main(){
    cin >> n;
    cin >> K;
    for(int i = 1;i <= n;i++){
        scanf("%lld", &A[i]);
        A[i] -= K;
    }
    pre[0] = make_pair(0, 0);
    for(int i = 1;i <= n;i++){
        pre[i].first = pre[i - 1].first + A[i];
        pre[i].second = i;
    }
    sort(pre, pre + 1 + n);
    LL ans = 0;
    for(int i = 0;i <= n;i++){
        ans += sum(pre[i].second + 1);
        add(pre[i].second + 1, 1); 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
N = int(input())
A = list(map(int, input().split()))

def ischeck(amount, target):
    for i in range(30):
        a = (amount >> i) & 1
        b = (target >> i) & 1
        if a & b:
            return False
    return True

ans = 0
tmp = A[0]
r = 0
for l in range(N):
    if r == l:
        tmp = A[l]
        r += 1
    while r < N and ischeck(tmp, A[r]):
        tmp += A[r]
        r += 1
    ans += (r - l)
    tmp -= A[l]

print(ans)


Measured memory_bytes: 77900
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let a: usize = sc.read();
        let b: usize = sc.read();
        graph[a].push(b);
        graph[b].push(a);
    }

    if let Some(root) = (0..n).find(|&i| graph[i].len() >= 3) {
        let (ans, _) = calc(root, root, &graph);
        println!("{}", ans);
    } else {
        println!("1");
    }
}

fn calc(v: usize, p: usize, graph: &Vec<Vec<usize>>) -> (usize, bool) {
    let children: Vec<usize> = graph[v].iter().cloned().filter(|&next| next != p).collect();
    match children.len() {
        0 => (1, true),
        1 => calc(children[0], v, graph),
        _ => {
            let mut one_line = false;
            let mut sum = 0;
            for next in children.into_iter() {
                let (next_count, is_line) = calc(next, v, graph);
                sum += next_count;
                one_line |= is_line;
            }
            (sum - if one_line { 1 } else { 0 }, false)
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main()
{
  string s; cin >> s;
  bool a=false, b=false, c=false, d=false;
  for (auto v:s) {
    if (v == 'N') a = true;
    if (v == 'S') b = true;
    if (v == 'E') c = true;
    if (v == 'W') d = true;
  }
  if (!(a^b) && !(c^d)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        for(int i = 0; i < s.length(); i+=2){
            char c = s.charAt(i);
            System.out.print(c);
        }
    }
}


Measured memory_bytes: 30712
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
void io(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int main()
{
	io();
	ll n;
	cin>>n;
	ll sum=0;
	sum+=1000*(n/500);
	n-=500*(n/500);
	//cout<<sum<<endl;
	sum+=5*(n/5);
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int a,b;
signed main(){
    cin>>a>>b;
    for(int i=0;i<=10000;i++){
        if(i*2/25==a&&i/10==b){
            cout<<i<<endl;
            return 0;
        }
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
const int MAXN = 200005;
long long suma[MAXN], sumb[MAXN];
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        cin >> suma[i];
        suma[i] += suma[i - 1];
    }
    for (int i = 1; i <= m; i++) {
        cin >> sumb[i];
        sumb[i] += sumb[i - 1];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (k < suma[i])
            break;
        int index = upper_bound(sumb + 1, sumb + m + 1, k - suma[i]) - sumb;
        ans = max(ans, i + (--index));
    }
    for (int i = 1; i <= m; i++) {
        if (k < sumb[i])
            break;
        int index = upper_bound(suma + 1, suma + n + 1, k - sumb[i]) - suma;
        ans = max(ans, i + (--index));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6736
N, A, B = map(int, input().split())

if (A-B)%2 == 0:
    ans = abs(A-B)//2
else:
    d1 = min(A, B) - 1
    r1 = max(A, B) - d1 - 1
    a1 = (r1-1)//2 + 1 + d1

    d2 = N- max(A, B)
    r2 = min(A, B) + d2 + 1
    a2 = (N - r2)//2 + 1 + d2
    ans = min(a1, a2)

print(ans)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
import bisect

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort();B.sort();C.sort()
#print(A)
#print(B)
#print(C)
Bok = []
for b in B:
  temp = bisect.bisect_left(A,b) #1indexでの位置
  Bok.append(temp) #個数なのでindexで持つ
SB = [0]
for i in range(N):
  temp = SB[-1]+Bok[i]
  SB.append(temp)
#print(SB)
ans = 0
for c in C:
  temp = bisect.bisect_left(B,c) #1indexでの位置
  #print(temp,SB[temp])
  ans += SB[temp]
print(ans)

Measured memory_bytes: 104836
#include <iostream>
using namespace std;
 
int main()
{
    string trip;

    cin >> trip;

    int distN = 0;
    int distS = 0;
    int distE = 0;
    int distW = 0;
    for(int loop = 0; loop < trip.length(); ++loop) {
        if('N' == trip.at(loop)) {
            ++distN;
        }
        if('S' == trip.at(loop)) {
            ++distS;
        }
        if('W' == trip.at(loop)) {
            ++distW;
        }
        if('E' == trip.at(loop)) {
            ++distE;
        }
    }

    if(0 != distN) {
        if(0 == distS) {
            cout << "No";
            return 0;
        }
        if (0 != distE && 0 != distW) {
        	cout << "Yes";
            return 0;
        } else if (0 == distE && 0 == distW){
        	cout << "Yes";
            return 0;
        } else {
            cout << "No";
            return 0;
        }
    }
 
    if(0 != distS) {
        if(0 == distN) {
      	    cout << "No";
            return 0;
        }
        if (0 != distE && 0 != distW) {
        	cout << "Yes";
       	    return 0;
        } else if (0 == distE && 0 == distW){
        	cout << "Yes";
       	    return 0;
        } else {
            cout << "No";
       	    return 0;
        }
    }

    if(0 != distE) {
        if(0 == distW) {
      	    cout << "No";
       	    return 0;
        }
        if (0 != distN && 0 != distS) {
        	cout << "Yes";
       	    return 0;
        } else if (0 == distN && 0 == distS){
        	cout << "Yes";
       	    return 0;
        } else {
            cout << "No";
       	    return 0;
        }
    }

    if(0 != distW) {
        if(0 == distE) {
      	    cout << "No";
       	    return 0;
        }
        if (0 != distN && 0 != distS) {
        	cout << "Yes";
       	    return 0;
        } else if (0 == distN && 0 == distS){
        	cout << "Yes";
       	    return 0;
        } else {
            cout << "No";
       	    return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
if(s.size()%2==0&&s.at(0)==s.at(s.size()-1))
cout<<"First"<<endl;
else if(s.size()%2==1&&s.at(0)==s.at(s.size()-1))
cout<<"Second"<<endl;
else if(s.size()%2==1)
cout<<"First"<<endl;
else
cout<<"Second"<<endl;}


Measured memory_bytes: 512
n = int(input())
ans = 0

for i in range(1, n + 1):
    count = 0
    if i % 2 == 0:
        continue
    for j in range(1, i + 1):
        if i % j == 0:
            count += 1
    if count == 8:
        ans += 1

print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#define N 1001
 
char x[N], y[N];
int n, dp[N][N], h, w;
 
main(){
  int t, i, j;
  scanf("%d", &n);
  getchar();
  for(t=0;t<n;t++){
    scanf("%s%s", x, y);
    h = strlen(y);
    w = strlen(x);
    for(i=0;i<=h;i++) dp[i][0] = 0;
    for(i=0;i<=w;i++) dp[0][i] = 0;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
        dp[i][j] = dp[i-1][j-1];
        if(y[i-1] == x[j-1]) dp[i][j]++;
        if(dp[i][j] < dp[i-1][j]) dp[i][j] = dp[i-1][j];
        if(dp[i][j] < dp[i][j-1]) dp[i][j] = dp[i][j-1];
      }
    }
    printf("%d\n", dp[h][w]);
  }
  return 0;
}


Measured memory_bytes: 5708
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int64

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let XYC = readInts()
let X, Y = XYC.[0], XYC.[1]
let p = readInts()
let q = readInts()
let r = readInts() |> Array.sortDescending

let pTopX = p |> Array.sortDescending |> Array.take (int X)
let qTopY = q |> Array.sortDescending |> Array.take (int Y)

Array.concat [pTopX; qTopY; r]
|> Array.sortDescending
|> Array.take (int (X+Y))
|> Array.sum
|> printfn "%d"


Measured memory_bytes: 38896
#include <iostream>
#include <vector>
#include <map>
using ll = long long int;
using namespace std;
int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    vector<int> A(N);
    ll s = 0;
    map<ll, ll> mp;
    mp[s]++;

    for(ll i=0; i<N; i++) cin >> A[i];

    for(ll j=0; j<N; j++){
        s += A[j];
        ans += mp[s];
        mp[s]++;
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int h, ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> h;
    if (h >= K) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

#define ll long long
using namespace std;

const int N = 3005;
string s, t;
int n, m;
int dp[N][N], trans[N][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s >> t;
    n = s.length(), m = t.length();
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(s[i - 1] == t[j - 1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
                trans[i][j] = 0;
            }else {
                dp[i][j] = dp[i - 1][j];
                trans[i][j] = 1;
                if(dp[i][j - 1] > dp[i][j]) {
                    dp[i][j] = dp[i][j - 1];
                    trans[i][j] = 2;
                }
            }
        }
    }
    string ans = "";
    while(n > 0 && m > 0) {
        switch(trans[n][m]) {
            case 0:
                ans.push_back(s[n - 1]);
                n--; m--;
                break;
            case 1:
                n--;
                break;
            case 2:
                m--;
                break;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 3;
	if (a == b || b == c | a == c) {
		ans = 2;
	}
	if (a == b && b == c) {
		ans = 1;
	}
	cout << ans << endl;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
from operator import itemgetter
N, M = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(M)]
INF = -float("inf")
dist = [INF]*N
dist[0] = 0
d_tmp = 0

for abci in abc:
    if dist[abci[0]-1] != INF and dist[abci[1] - 1] < dist[abci[0] - 1] + abci[2]:
         dist[abci[1] - 1] = dist[abci[0] - 1] + abci[2]

d_tmp = dist[-1]
for abci in abc:
    if dist[abci[0]-1] != INF and dist[abci[1] - 1] < dist[abci[0] - 1] + abci[2]:
         dist[abci[1] - 1] = dist[abci[0] - 1] + abci[2]    


print(dist[-1]) if d_tmp == dist[-1] else print("inf")

Measured memory_bytes: 3572
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define Di 3.1415926
#include<math.h>
#include<string>
#include<stack>
#define INF 0x3f3f3f3f
using namespace std;
ll  gcd(ll a,ll b)
{
    return a%b? gcd(b,a%b):b;
}
struct Node
{
    int t;
    char a[102];
}s[102];
bool cmp(Node a,Node b)
{
    return strcmp(a.a,b.a)<0;
}
int main()
{    int m,n,i,j;
     cin>>m>>n;
     for(i=0;i<m;i++)
     {
         cin>>s[i].a;
         s[i].t=i+1;
     }
     sort(s,s+m,cmp);
   /*  for(i=0;i<m-1;i++)
     {
         for(j=0;j<m-1-i;j++)
         {
             if(strcmp(s[i].a,s[j].a))
             {
                 int t=s[i].t;
                 s[i].t=s[j].t;
                 s[j].t=t;
             }
         }
     }*/
    // sort(s,s+m,cmp);
     for(i=0;i<m;i++)
     {
         cout<<s[i].a;
     }
     cout<<endl;

 return 0;
}


Measured memory_bytes: 256
from copy import deepcopy
N, M = map(int, input().split())
G = [[float('inf')] * N for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    G[a][b] = c
    G[b][a] = c


Shortest = deepcopy(G)
for k in range(N):
    for i in range(N):
        for j in range(N):
            Shortest[i][j] = min(Shortest[i][j], Shortest[i][k] + Shortest[k][j])


ans = 0
for i in range(N):
    for j in range(N):
        if G[i][j] == float('inf'):
            continue
        if G[i][j] != Shortest[i][j]:
            ans += 1

print(ans // 2)


Measured memory_bytes: 3992
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A <= 8 &&  B <= 8) {
      System.out.println("Yay!");
    } else {
      System.out.println(":(");
    }
  }
}

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

int main(){
	int n,k; cin>>n>>k;
	vector<int> v(n);
	rep(i,n) cin>>v[i];
	sort(all(v));
	int mx, mn, ans=1e9+7;
	rep(i,n-k+1){
		mn=v[i]; mx=v[k-1+i];
		ans=min(ans,mx-mn);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3696
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
class ParseError {};
struct Result{
  ll value;
  int p;
  Result(ll value, int p) : value(value), p(p) {}
};
void skip(const string& s, Result& r, char expected){
  if(s[r.p] == expected){
    r.p++;
  }else {
    cerr << "try to skip'" << expected << "' but this char is '" << s[r.p] << "'." << endl;
    assert(false);
  }
}
Result expression(const string& s, int p, const int MOD);
Result term(const string& s, int p, const int MOD);
Result factor(const string& s, int p, const int MOD);
map<pair<int, int>, int > inv_dict;
int inverse(int x, const int MOD){
  pair<int, int> state = make_pair(x, MOD);
  if(inv_dict.count(state)) return inv_dict[state];
  int res = 1;
  REP(iter, MOD - 2) res = (res * x) % MOD;
  return inv_dict[state] = res;
}
Result expression(const string& s, int p, const int MOD){
  Result r = term(s, p, MOD);
  while(s[r.p] == '+' || s[r.p] == '-'){
    Result r_ = term(s, r.p + 1, MOD);
    if(s[r.p] == '+'){
      r.value = (r.value + r_.value) % MOD;
    }else{
      r.value = (r.value - r_.value + MOD) % MOD;
    }
    r.p = r_.p;
  }
  return r;
}
Result term(const string& s, int p, const int MOD){
  Result r = factor(s, p, MOD);
  while(s[r.p] == '*' || s[r.p] == '/'){
    Result r_ = factor(s, r.p + 1, MOD);
    if(s[r.p] == '*'){
      r.value = (r.value * r_.value) % MOD;
    }else{
      if(r_.value == 0) throw ParseError();
      r.value = (r.value * inverse(r_.value, MOD)) % MOD;
    }
    r.p = r_.p;
  }
  return r;
}
Result factor(const string& s, int p, const int MOD){
  if(s[p] == '('){
    Result r = expression(s, p + 1, MOD);
    skip(s, r, ')');
    return r;
  }else{
    int val = 0;
    while(isdigit(s[p])){
      val = val * 10 + s[p++] - '0';
    }
    return Result(val, p);
  }
}
int main(){
  string line;
  while(getline(cin, line)){
    if(line == "0:") break;
    REP(i, line.size()) if(line[i] == ':') line[i] = ' ';
    stringstream ss(line);
    string mod_str;
    ss >> mod_str;
    string expr, s;
    while(ss >> s) expr += s;
    int mod;
    sscanf(mod_str.c_str(), "%d", &mod);
    try{
      int val = expression(expr, 0, mod).value;
      printf("%s = %d (mod %d)\n", expr.c_str(), val, mod);
    }catch(...){
      cout << "NG" << endl;
    }
  }
  return 0;
}

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

int main()
{
  int n,a=0;
  char s[200100];

  scanf("%d",&n);
  scanf("%s",s);

  int i=0,nd[200000];
  int nn = 0;
  while(i<n)
    {
      nd[nn] = 0;
      while(i<n&&s[i] == '.')
	{
	  i++; nd[nn]++;
	}
      nn++;
       nd[nn] = 0;
      while(i<n&&s[i] == '#')
	{
	  i++; nd[nn]++;
	}
      nn++;
    }
  
  for(i=0;i<nn;i+=2)
    a += nd[i];
  int b= a;
  
  for(i=0;i<nn;i++)
    {
      if(i%2==0)
	b -= nd[i];
      else
	b += nd[i];
      if( b< a)
  	a=b;
    }

  printf("%d\n",a);
  

  return 0;
}

Measured memory_bytes: 1152
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    N = int(readline())
    L = [0]*(N+1)
    L[0]=2
    L[1]=1
    for i in range(2,N+1):
        L[i] = L[i-1] + L[i-2]
    print(L[N])




if __name__ == '__main__':
    main()

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

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  int ans= r*100+g*10+b;
  if(ans%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 256
(defparameter *a* (read))
(defparameter *b* (read))
(defparameter *c* (read))

(defun f (a b c)
  (let ((lst (sort (list a b c) #'>)))
    (+ (* (first lst) 10) (second lst) (third lst))))

(princ (f *a* *b* *c*))

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

int main(void){
	int x[10000],y[10000];
	int t;
	int i;
	for(i=0;i<10000;i++){
		cin>>x[i]>>y[i];
		if(x[i]==0&&y[i]==0){
			break;
		}else if(x[i]>y[i]){
			t=x[i];
			x[i]=y[i];
			y[i]=t;
		}
	}
	
	for(int n=0;n<i;n++)cout<<x[n]<<" "<<y[n]<<endl;
	
	return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT32_MAX;
ll i;


int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}


Measured memory_bytes: 256