akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int X[1100], Y[1100];

std::string f(int x, int y){
    std::string instruction = "";

    for(int i=30;i>=0;--i){
        int sum = y + x, diff = y - x;
        int d = 1 << i;

        if(sum > 0 && diff > 0){
            instruction += "U";
            y -= d;
        }else if(sum < 0 && diff < 0){
            instruction += "D";
            y += d;
        }else if(sum < 0 && diff > 0){
            instruction += "L";
            x += d;
        }else{
            instruction += "R";
            x -= d;
        }
    }

    return instruction;
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> X[i] >> Y[i];
    }

    int LSB = (X[0] + Y[0]) & 1;

    for(int i=1;i<N;++i){
        if(((X[i] + Y[i]) & 1) != LSB){
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    if(LSB == 1){
        constexpr int M = 31;

        std::cout << M << std::endl;

        for(int i=M-1;i>=0;--i){
            std::cout << (1 << i) << " \n"[i == 0];
        }

        for(int i=0;i<N;++i){
            std::cout << f(X[i], Y[i]) << std::endl;
        }
    }else{
        constexpr int M = 32;

        std::cout << M << std::endl;

        for(int i=M-2;i>=0;--i){
            std::cout << (1 << i) << " ";
        }
        std::cout << 1 << std::endl;
        
        for(int i=0;i<N;++i){
            std::cout << f(X[i] - 1, Y[i]) << "R" << std::endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+5;
int a[N],b[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    long long s=0;
    for(int i=0; i<n; i++)
        cin>>b[i];
    for(int i=0; i<n; i++)
    {
        if(a[i]>b[i])
            s-=a[i]-b[i];
        else s+=(b[i]-a[i])/2;
    }
    if(s>=0)
        printf("Yes");
    else printf("No");
    return 0;
}


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

int main() {
  
  int A, B; cin >> A >> B;
  
  int upperLimit = 100 * 100 / 8;
  
  for (int i = 1; i <= upperLimit; i++) {
    
    int before = i * 8 / 100;
    int after = i * 10 / 100;
    
    if (before == A && after == B) {
      cout << i << endl;
      return 0;
    }
    
  }
  
  cout << -1 << endl;
  
}

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

int main(){
    int b1[3][11],b2[3][11],b3[3][11],b4[3][11];
    for(int i=0;i<4;i++){
        for(int j=0;j<12;j++){
            b1[i][j]=b2[i][j]=b3[i][j]=b4[i][j]=0;
        }
    }
    int n,b,f,r,v;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        switch(b){
            case 1:
                b1[f][r]+=v;
                break;
            case 2:
                b2[f][r]+=v;
                break;
            case 3:
                b3[f][r]+=v;
                break;
            case 4:
                b4[f][r]+=v;
                break;
        }
    }
    for(int i=1;i<=4;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                switch(i){
                    case 1:
                        printf(" %d",b1[j][k]);
                        break;
                    case 2:
                        printf(" %d",b2[j][k]);
                        break;
                    case 3:
                        printf(" %d",b3[j][k]);
                        break;
                    case 4:
                        printf(" %d",b4[j][k]);
                        break;
                }
            }
            printf("\n");
        }
        if(i!=4)printf("####################\n");
    }
}


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

typedef pair<int,int> P;

const int dx[] = { 0, 1, 0,-1, 1, 1,-1,-1};
const int dy[] = { 1, 0,-1, 0, 1,-1, 1,-1};
int h, w;
vector<vector<int> > islands(50, vector<int>(50));

void bfs (int i, int j) {
    queue<P> q;
    q.push(P(i,j));
    while (q.size()) {
        const P p = q.front();
        q.pop();
        for (int i = 0; i < 8; i++) {
            int x = p.first + dx[i], y = p.second + dy[i];
            if (0 <= x && x < w && 0 <= y && y < h && islands[x][y]) {
                islands[x][y] = 0;
                q.push(P(x,y));
            }
        }
    }
}

int main ()
{
    while (cin >> h >> w, (h || w)) {
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                cin >> islands[i][j];
            }
        }

        int count = 0;
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                if (islands[i][j] == 1) {
                    count++;
                    islands[i][j] = 0;
                    bfs(i, j);
                }
            }
        }
        cout << count << endl;
    }


    return 0;
}

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

struct union_find {
	vector<ll> p;
	union_find(ll n) {
		p = vector<ll>(n,-1);
	}

	ll find(ll x) {
		if (p[x] < 0)
			return x;
		else {
			p[x] = find(p[x]);
			return p[x];
		}
	}

  	bool unite(ll x, ll y) {
    	ll xp = find(x);
		ll yp = find(y);
    	if (xp == yp)
			return false;
    	if (p[xp] > p[yp])
			swap(xp,yp);
    	p[xp] += p[yp];
		p[yp] = xp;
    	return true;
  	}

  	ll size(ll x) {
		return -p[find(x)];
	}
};

int main() {
	ll n,m; cin>>n>>m;
	vector<ll> a(m),b(m);
	union_find uf(n+1);
	for (ll i=0; i<m; i++)
		cin>>a[i]>>b[i];
	vector<ll> ans(m);
	ll current = n*(n-1)/2;
	for (ll i=m-1; i>=0; i--) {
		ans[i]=current;
		if (uf.find(a[i]) != uf.find(b[i])) {
			ll xa = uf.size(a[i]), xb = uf.size(b[i]);
			current += xa*(xa-1)/2 + xb*(xb-1)/2;
 
			uf.unite(a[i],b[i]);
			ll x = uf.size(a[i]);
			current -= x*(x-1)/2;
		}
		uf.unite(a[i],b[i]);
	}

	for (ll i : ans) cout << i << endl;
	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <cmath>

#define PI 3.14159265

using namespace std;

void func_A() {

    double r;
    cin >> r;

    cout << 2 * PI * r;
}

void func_B() {

    long long n;
    long long m;
    cin >> n >> m;
    vector<long long> a(m);
    for (int i = 0; i < m; ++i) cin >> a[i];

    for (int i = 0; i < m; ++i) {
        n -= a[i];
        if (n < 0) {
            cout << -1;
            return;
        }
    }

    cout << n;
}

void func_C() {

    long long n;
    cin >> n;
    vector<long long> a(n-1);
    for (int i = 0; i < n-1; ++i) cin >> a[i];

    vector<long long> buka(n);
    for (int i = 0; i < n-1; ++i) buka[i] = 0;

    for (int i = 0; i < n-1; ++i) ++buka[a[i] - 1];
    
    for (int i = 0; i < n; ++i) cout << buka[i] << "\n";


}

int main() {

    func_A();
    //func_B();
    //func_C();

    return 0;
}


Measured memory_bytes: 3816
#include<stdio.h>

int main(void)
{
    int x[4];
    int y[4];

    scanf("%d %d %d %d", &x[0], &y[0], &x[1], &y[1]);
    x[2] = x[1] - (y[1]-y[0]);
    y[2] = y[1] + (x[1]-x[0]);
    x[3] = x[2] - (x[1]-x[0]);
    y[3] = y[2] - (y[1]-y[0]);
    printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int q=stdIn.nextInt();
		ArrayList<Integer> list=new ArrayList<Integer>();
		for(int i=0;i<q;i++) {
			int a=stdIn.nextInt();
			if(a!=2) {
				int b=stdIn.nextInt();
				if(a==1) 
					System.out.println(list.get(b));
				else
					list.add(b);
			}
			else
				list.remove(list.size()-1);
		}
	}
}



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

int n;
vector<vector<P>> y(20, vector<P>(0));

int solve(){
  int ret = 0;
  for(int S = 0; S < (1 << n); S++){
    int cnt = __builtin_popcount(S);
    rep(i, n){
      if((S & (1 << i)) == 0) continue;
      for(P x : y.at(i)){
        bool flag = S & (1 << x.first);
        //cerr << flag << x.second << endl;
        if(flag ^ x.second) cnt = 0;
      }
    }//cerr << endl;
    ret = max(cnt, ret);
  }
  return ret;
}
      
int main(){
  cin >> n;
  rep(i, n){
    int a; cin >> a;
    rep(j, a){
      int sino, alice;
      cin >> sino >> alice;
      sino--;
      y.at(i).push_back(P(sino, alice));
    }
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,x,y;
    double z;
    scanf("%d %d",&a,&b);
    x=a/b;
    y=a%b;
    z=(double)a/b;
    printf("%d %d %lf\n",x,y,z);
    return 0;
}


Measured memory_bytes: 2112
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
//const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
//約数の列挙O(√n)
vector<ll>divisor(ll n){
  vector<ll>res;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(n/i);
    }
  }
  return res;
}
ll factorial(ll x){
  if(x==0)return 1;
  return x*factorial(x-1)%MOD;
}

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

ll comb(ll n, ll r){
  ll res=1;
    for(ll i=0;i<r;i++){
      res*=n-i;
      res%=MOD;
    }
  res*=modpow(factorial(r),MOD-2,MOD);
  res%=MOD;
  return res;
}

int main(){
  ll n,m;cin>>n>>m;
  vl a(n),b(m);
  vl count(n*m);
  vl gyou(n*m,-1);
  vl retu(n*m,-1);
  rep(i,n){
    cin>>a[i];a[i]--;count[a[i]]++;
    gyou[a[i]]=1;
  }
  rep(i,m){
    cin>>b[i];b[i]--;count[b[i]]++;
    retu[b[i]]=1;
  }
  rep(i,n*m){
    if(count[n*m]>2){
      cout<<0<<endl;
      return 0;
    }
  }
  ll black=0;
  ll ans=1;
  for(ll i=n*m-1;i>=0;i--){
    if(count[i]==2){
      rep(j,m){
        if(b[j]>i)black++;
      }
      rep(j,n){
        if(a[j]>i)black++;
      }
    }
    else if(count[i]==1){
      ll d=0;
      if(gyou[i]>0){
        rep(j,m){
          if(b[j]>i)d++;
        }
      }
      else {
        rep(j,n){
          if(a[j]>i)d++;
        }
      }
      if(d==0){
        //cout<<i<<endl;
        cout<<0<<endl;
        return 0;
      }
      ans*=d;
      ans%=MOD;
      black+=d-1;
    }
    else {
      if(black<=0){
        //cout<<i<<endl;
        cout<<0<<endl;
        return 0;
      }
      ans*=black;
      ans%=MOD;
      black--;
    }
    //cout<<black<<endl;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;

vector<ll> ans;

void recur(ll i,vector<ll> cost,vector<vector<ll>> &arr,ll N,ll M,ll X){
    if(i<N){
        vector<ll> temp_cost=cost;
        forn(j,M+1){
            cost[j]+=arr[i][j];
        }
        bool exist=false;
        for1n(j,M){
            if(cost[j]<X){
                exist=true;
                break;
            }

        }
        if(exist){
            recur(i+1,cost,arr,N,M,X);
            recur(i+1,temp_cost,arr,N,M,X);
        }
        else{
            ans.push_back(cost[0]);
            recur(i+1,temp_cost,arr,N,M,X);
        }


    }


}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {

       ll N,M,X;
       cin>>N>>M>>X;
       vector<ll> cost(M+1,0);
       vector<vector<ll>> arr(N,vector<ll>(M+1,0));
       forn(i,N) forn(j,M+1) cin>>arr[i][j];
       recur(0,cost,arr,N,M,X);
       if(ans.size()==0){
        cout<<-1;
        return 0;
       }
       cout<<*min_element(ans.begin(),ans.end());


    }



    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<map>

using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, int> m;
    for(int i=0; i<N; i++) {
        int tmp;
        cin >> tmp;
        if(m.count(tmp)==0) {
            m[tmp]=1;
        } else {
            m[tmp]++;
        }
    }
    int ans=0;
    for(int i=1; i<100000; i++) {
        ans = max(ans, m[i]+m[i-1]+m[i-2]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  map<long long,bool> mp;
  long long N;
  cin >> N;
  long long ans = 0;
  for(long long i=0; i<N; i++){
    long long A;
    cin >> A;
    if(mp[A] == false){
      mp[A] = true;
    }
    else{
      mp[A] = false;
    }
    if(mp[A] == true){
      ans++;
    }
    else{
      ans--;
    }
  }
  cout << ans << endl;
}


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

vector< int > numbers;

bool prime(int n)
{
  for(int i = 2; i * i <= n; i ++)
    if(n % i == 0)
      return 0;
  return 1;
}

int main()
{
  ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

  for(int i = 3; i <= 55555; i ++)
  {
    if(prime(i) && i % 10 == 1)
      numbers.push_back(i);
  }

	int n;
  cin >> n;
  for(int i = 0; i < n; i ++)
    cout << numbers[i] << ' ';
	return 0;
}


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

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

    int tmp = 0;
    for(int i=0; i<N; i++){
        tmp++;
        if(tmp % 100 == 0) tmp++;
    }
    cout << tmp;

    for(int i=0; i<D; i++)
        cout << "00";
    
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


def call(n):
  for i in range(1,n+1):
    if i % 3 == 0:
      print(" " + str(i), end="")
    else:
      x = i
      while(x > 0):
        if x % 10 == 3:
          print(" " + str(i), end="")
          break
        else:
          x //= 10
  print()


N = int(input())
call(N)


Measured memory_bytes: 5888
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3
3
1
2"# => r#"2"#,

r#"4
3
4
1
2"# => r#"-1"#,

r#"5
3
3
4
2
4"# => r#"3"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        a: [usize; n],
    }
    let mut ans = -1;

    let mut l = vec![false; n];
    l[0] = true;
    let mut cnt = 0;

    let mut i = 0;
    for _ in 0..n {
        l[i] = false;
        i = a[i] - 1;
        l[i] = true;

        cnt += 1;
        if i == 1 && l[i] {
            ans = cnt;
            break;
        }
    }

    ans.to_string()
}

Measured memory_bytes: 6396
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 998244353;
typedef long long LL;

// ----------- VECTOR ------------
template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
// ----------- VECTOR ------------

vector<LL> fact, finv, inv;

void init_nCk(int N) {
  fact.resize(N + 1);
  finv.resize(N + 1);
  inv.resize(N + 1);
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= N; i++) {
    fact[i] = fact[i - 1] * i % kMod;
    inv[i] = kMod - inv[kMod % i] * (kMod / i) % kMod;
    finv[i] = finv[i - 1] * inv[i] % kMod;
  }
}

LL nCk(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * (finv[k] * finv[n - k] % kMod) % kMod;
}

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

  if (N == 1) {
    cout << M << endl;
    return 0;
  }

  vector<LL> f(N);
  f[0] = M;
  for (LL i = 1; i < N; ++i) {
    f[i] = (M-1)*f[i-1] % kMod;
  }


  init_nCk(N);

  LL sum = 0;
  for (int k = 0; k <= K; ++k) {
    LL v = f[N-k-1] % kMod;
    LL c = nCk(N-1, k) % kMod;
    v = (v * c) % kMod;
    sum = (sum + v) % kMod;
  }
  cout << sum << endl;
}


Measured memory_bytes: 9444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String[] pa = a.split("");
		for(int i=0;i<pa.length;i++){
			if(pa[i].equals("9")){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <sstream>
using namespace std;
int main(){
	string n,s;
	cin>> n;
	int q=0;
	while (cin>> s){
		for (int i=0;i<s.size();i++){
			if (s[i]<97){
				s[i]=s[i]+32;
			}
		}
		if (s==n){
			q++;
		}
	}
	cout<< q<< endl;
}

Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
				int i = 1;
		while (true) {
			int x = sc.nextInt();
			if (x == 0) {
				break;
			} else {
				System.out.println("Case " + i + ": " + x);
				i++;
			}
		}
	}
}


Measured memory_bytes: 43020
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

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

signed main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for( int i = 0; i < H; i++ ) cin >> S[i];

  int ans = 0;
  vector<vector<bool>> seen(H, vector<bool>(W, 0));
  for( int h = 0; h < H; h++ ){
    for( int w = 0; w < W; w++ ){
      if( S[h][w] == '.' ) continue;
      if( seen[h][w] ) continue;
      int kuro = 0;
      int siro = 0;

      //BFS
      queue<pair<int, int>> que;
      seen[h][w] = 1;
      que.push({h, w});
      while( !que.empty() ){
        int x = que.front().first;
        int y = que.front().second;
        que.pop();
        if( S[x][y] == '#' ) kuro++;
        else siro++;
        for (int direction = 0; direction < 4; ++direction) {
          int next_x = x + dx[direction];
          int next_y = y + dy[direction];
          if (next_x < 0 || next_x >= H || next_y < 0 || next_y >= W) continue;
          if( seen[next_x][next_y] ) continue;
          if( S[x][y] != S[next_x][next_y] ){
            que.push({next_x, next_y});
            seen[next_x][next_y] = 1;
          }
        }
      }

      ans += kuro*siro;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

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

	for(int j = 0;j < n;j++){
		cin >> s;
		int num[26] = {};

		for(int i = 0;i < s.size();i++)num[s[i]-'a'] ++;

		for(int i = 0;i < 26;i++)t[i] = min(t[i],num[i]);
	}

	for(int j = 0;j < 26;j++){
		for(int i = 0;i < t[j];i++)cout << (char)('a'+j);
	}
	cout <<endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Data.List
import Data.Char
import Data.Monoid
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.IntSet as IntSet
import qualified Data.IntMap as IntMap

mergeSortBy :: (U.Unbox a) => (a -> a -> Ordering) -> U.Vector a -> U.Vector a
mergeSortBy !cmp !vec = doSort vec
  where
    doSort vec | U.length vec <= 1 = vec
               | otherwise = let (xs, ys) = U.splitAt (U.length vec `quot` 2) vec
                             in merge (doSort xs) (doSort ys)
    merge xs ys = U.create $ do
      let !n = U.length xs
          !m = U.length ys
      result <- UM.new (n + m)
      let loop !i !j
            | i == n = U.copy (UM.drop (i + j) result) (U.drop j ys)
            | j == m = U.copy (UM.drop (i + j) result) (U.drop i xs)
            | otherwise = let !x = xs U.! i
                              !y = ys U.! j
                          in case cmp x y of
                               LT -> do UM.write result (i + j) x
                                        loop (i + 1) j
                               EQ -> do UM.write result (i + j) x
                                        UM.write result (i + j + 1) y
                                        loop (i + 1) (j + 1)
                               GT -> do UM.write result (i + j) y
                                        loop i (j + 1)
      loop 0 0
      return result

spanWithLimit :: (U.Unbox a) => Int -> (a -> Bool) -> U.Vector a -> (U.Vector a, U.Vector a)
spanWithLimit !limit !f !vec | U.length vec <= limit = U.span f vec
                             | otherwise = U.splitAt (count 0) vec
  where count !i | i == limit || not (f (vec U.! i)) = i
                 | otherwise = count (i + 1)

main = do
  [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  -- as: a が小さい順にソートする
  as <- mergeSortBy compare . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  -- bc: c が大きい順にソートする
  bc <- fmap (U.toList . mergeSortBy (\(b,c) (b',c') -> compare c' c <> compare b b')) $ U.replicateM m $ do
    [b,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (b,c)
  let f !s !cards [] = s + U.sum cards
      f !s !cards ((!b,!c):xs) = let (d1, d2) = spanWithLimit b (< c) cards
                                 in if U.null d1 then s + U.sum cards else f (s + U.length d1 * c) d2 xs
  print $ f 0 as bc


Measured memory_bytes: 10108
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] c = new char[n];
		c = sc.next().toCharArray();
		int count = 0;
		int r = 0;
		for(int i = 0; i < n; i++) {
			if(c[i]=='R')r++;
		}
		for(int i = 0; i < r; i++) {
			if(c[i]=='W')count++;
		}
		System.out.println(count);
    }
}

Measured memory_bytes: 41032
int main(void){
  int a,b=0;
  
  scanf("%d",&a);
  
  while(500<=a){
    a -= 500;
    b += 1000;
  }
  
  while(5<=a){
    a -= 5;
    b += 5;
  }
  
  printf("%d",b);
}
    

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
	  String S = scan.next();
      String T = scan.next();
      int A = scan.nextInt();
      int B = scan.nextInt();
      String U = scan.next();
      
      if(U.equals(S)){
        A = A-1;
      }else if(U.equals(T)){
        B = B-1;
      }
      
      System.out.println(A+" "+B);
      
    }
}

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

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

using namespace std;

int main(){
  int n;cin>>n;
  map<char, int> m;
  rep(i,n){
    char t;cin>>t;
    m[t]++;
  }

  if(m.size()==3){
    cout<<"Three";
  }else{
    cout<<"Four";
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  double sum = 0.0;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
    cin >> v[i];    
    sum += v[i];
  }
  int e = round(sum/N);
//  cout << e << endl;
  int Ans = 0;
  for (int i = 0; i < N; i++){
    Ans += (v[i]-e)*(v[i]-e);
  }
  cout << Ans << endl;
  return 0;  
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b;
    cin >> a >> b;
    int ans = a+b;
    if (ans>=10) {
        cout << "error" << endl;
        return 0;
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(){
    int count[26];
    for(int i=0;i<26;i++){
        count[i] = 0;
    }

    string s;
    cin >> s;

    for(int j=0;j<s.size();j++){
        count[s[j] - 'a']++;
    }

    string ans = "yes";
    for(int i=0;i<26;i++){
        if(count[i] > 1){
            ans = "no";
            break;
        }
    }

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


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

const int mod = 1e9 + 7;

long long solve(vector<int>& a, int n, int k) {
	long long res = 1;
	
	if (a[n-1] == 0 && k%2) {
		return 0;
	}
	
	if (a[n-1] < 0 && k%2) {
		for (int i = n-1; i >= n-k; i--) {
			res = (res*a[i]) % mod;
		}
		return (res + mod) % mod;
	}
	
	if (a[n-1] > 0 && k%2) {
		res = a[n-1];
		--n; --k;
	}
	
	// k is even
	k /= 2;
	int l = 0, r = n-1;
	while (k--) {
		long long left = 1LL * a[l] * a[l+1], right = 1LL * a[r] * a[r-1];
		if (left > right) {
			res = (res*(left%mod))%mod;
			l += 2;
		} else {
			res = (res*(right%mod))%mod;
			r -= 2;
		}
	}
	return (res + mod) % mod;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	
	cout << solve(a, n, k) << endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 3648
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };

    let n = sc.read();
    let mut ab = vec![];
    for _ in 0..n {
        let a: i64 = sc.read();
        let b: i64 = sc.read();
        ab.push((a + b, a, b));
    }
    ab.sort();
    ab.reverse();

    let mut first = 0;
    let mut second = 0;
    for i in 0..n {
        let (_, a, b) = ab[i];
        if i % 2 == 0 {
            first += a;
        } else {
            second += b;
        }
    }

    println!("{}", first - second);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_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: 9336
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool used[210];
bool graph[100][100];

int main() {
	ll n, a[1001], b[1001];
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i] >> b[i];
	}
	ll c = a[0], d = b[0];
	for (int i = 1;i < n;i++) {
		int f = 0, g = 0;
		if (c%a[i] != 0)f++;
		if (d%b[i] != 0)g++;
		ll e = max(c / a[i] + f, d / b[i] + g);
		c = e*a[i], d = e*b[i];
	}
	std::cout << c + d << std::endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		boolean through = true;
		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			if (i + 1 != p) {
				count++;
			}
		}
		if (count == 0 || count == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++) 
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
//#define x first
//#define y second

using namespace std;
int x,y,n,m,a,b;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m>>x>>y;
	rep(i,n)
	{
		cin>>a;
		if(a>x) x=a;
	}
	rep(i,m)
	{
		cin>>b;
		if(b<y) y=b;
	}
	if(x<y) cout<<"No War"<<endl;
	else cout<<"War"<<endl;
	return 0;}

Measured memory_bytes: 256
n = int(input())
vac = []
for i in range(n):
    arr =  [int(x) for x in input().strip().split()]
    vac.append(arr)
dp = [[None, None, None] for _ in range(n)]
dp[0] = vac[0]
for i in range(1,n):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2])+vac[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2])+vac[i][1]
    dp[i][2] = max(dp[i-1][1], dp[i-1][0])+vac[i][2]

print(max(dp[n-1]))


Measured memory_bytes: 44144
# 190503 B
if __name__ == "__main__":
    N,K = list(map(int,input().split()))
    d = []
    A = [0] * N
    for i in range(K):
        tmpd = (int(input()))
        tmpa = (list(map(int,input().split())))
        for j in range(tmpd):
            A[tmpa[j]-1] =+ 1
    emptycnt = 0
    for i in range(N):
        if A[i] == 0:
            emptycnt = emptycnt + 1
    print(emptycnt)



Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

string S;

int main(){

    cin >> S;
    int ans = 100000000;
    
    REP(i,S.size()-2){
        int t = (S[i]-'0') * 100 + (S[i+1]-'0') * 10 + (S[i+2]-'0');
        ans = min(ans,abs(t-753));
    }

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


Measured memory_bytes: 256
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var x = lines[0].split(" ").map(value => Number(value));
    console.log(Math.ceil((x[0] + x[1]) / 2))

});

Measured memory_bytes: 7628
N = int(input())
S1 = input()
S2 = input()
mod = 1000000007
j = 0
if S1[0] == S2[0]:
    ans = 3
else:
    ans = 6
while 1:
    if S1[j] == S2[j]:
        j += 1
        if j >= N:
            break
        ans = ans*2
    else:
        j += 2
        if j >= N:
            break
        if S1[j] != S2[j]:
            ans = ans*3
print(ans%mod)


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 1; i < N; i++ {
		x := getInt() - 1
		a[x]++
	}
	for i := 0; i < N; i++ {
		out(a[i])
	}
}


Measured memory_bytes: 6188
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

int dp[1001][1001];

int main(){
	int n,W,v[1000],w[1000],c=0,ans,we;
	for(;;){
		scanf("%d",&W);
		if(!W)break;
		scanf("%d",&n);
		ans=0;
		we=1023;
		rep(i,n)scanf("%d,%d",v+i,w+i);
		rep(i,W+1)dp[i][0]=0;
		rep(i,n)dp[0][i]=0;
		rep(i,W+1)rep(j,n){
			if(i>=w[j])dp[i][j+1]=max(dp[i][j],dp[i-w[j]][j]+v[j]);
			else dp[i][j+1]=dp[i][j];
			ans=max(ans,dp[i][j+1]);
		}
		for(int i=0;i<=W&&we==1023;i++)rep(j,n+1)if(dp[i][j]==ans){we=i;break;}
		printf("Case %d:\n%d\n%d\n",++c,ans,we);
	}
	return 0;
}

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

int main() {
	int n,x,y,ans;
	ans = 0;
	y = 0;
	cin >> n;
	int a[100];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int j = 0; j < n; j++) {
		if (a[j] > y) {
			ans += a[j];
			if (j == 0) {

			}
			else {
				ans -= a[j - 1];
			}
			x = j;
			y = a[j];
		}
		if(a[j] < y) {
			y = a[j];
		}
	}
	cout << ans << endl;
	return 0;
}

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

long long gcd(long long a, long long b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}

long long lcm(long long x, long long y) {
	return x * y / gcd(x, y);
}

long long calc(long long N) {
	long long ret = 1;
	for (long long i = 2; i*i <= N; i++) {
		int m = 0;
		while (N%i == 0) { // 素数で割り切れなくなるまで割っていく
			m++;//割った個数を配列に足す
			N /= i;
		}
		if (0 != m) {
			ret++;
		}
		if (1 == N) {
			break;
		}
	}
	if (1 != N) {
		ret++;
	}

	return ret;
}

int main() {
	long long A, B;
	cin >> A >> B;
	long long GCD = gcd(A, B);
	cout << calc(GCD)<< endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 1;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> n;
	m = 100;
	do{
      m+=(m/100);
      if(m>=n){cout<<cnt;return 0;}
    }while(cnt++);
	//cout << ans << endl;
}


Measured memory_bytes: 3600
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int[] xs) {

    int[int] freq(int start) {
        int[int] d;
        for (int i = start; i < xs.length; i += 2) {
            d[xs[i]]++;
        }
        return d;
    }

    int m = cast(int) xs.length / 2;

    auto a = freq(0);
    auto b = freq(1);

    int[][] aa, bb;
    foreach (k, v; a) {
        aa ~= [m - v, k];
    }
    aa ~= [m, -1];
    foreach (k, v; b) {
        bb ~= [m - v, k];
    }
    bb ~= [m, -2];

    aa.sort();
    auto a2 = aa.take(2);

    bb.sort();
    auto b2 = bb.take(2);

    int ans = int.max;
    for (int i = 0; i < a2.length; i++) {
        for (int j = 0; j < b2.length; j++) {
            if (a2[i][1] != b2[j][1]) {
//                writeln("a ", a2[i][0], " ", a2[i][1]);
//                writeln("b ", b2[j][0], " ", b2[j][1]);
                ans = min(ans, a2[i][0] + b2[j][0]);
            }
        }
    }
    return ans;
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}


Measured memory_bytes: 15808
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;

int swap(int a,int b) {
	int tmp;
	tmp = a;
	a = b;
	b = tmp;
}
signed main() {
	int N,M;
	cin >> N >> M;
	vector<tuple<int,int,int>> vec(M + 1);
	for(int i = 1;i < M + 1;i++) {
		int A,B;
		cin >> A >> B;
		vec.at(i) = make_tuple(A,B,i);
	}
	get<0>(vec.at(0)) = 0;
	sort(vec.begin(),vec.end());
	int A = 1;
	for(int i = 1;i < M + 1;i++) {
		if(get<0>(vec.at(i - 1)) != get<0>(vec.at(i))) {
			A = 1;
		}
		get<1>(vec.at(i)) = A;
      	A++;
	}
	for(int i = 1;i < M + 1;i++) {
		int tmp = get<0>(vec.at(i));
		get<0>(vec.at(i)) = get<2>(vec.at(i));
		get<2>(vec.at(i)) = tmp;
	}
	sort(vec.begin(),vec.end());
	for(int i = 1;i < M + 1;i++) {
		int X = get<2>(vec.at(i));
		int Y = get<1>(vec.at(i));
		string S1 = to_string(X);
		string S2 = to_string(Y);
		for(int j = S1.size();j < 6;j++) {
			S1.insert(0,"0");
		}
		for(int j = S2.size();j < 6;j++) {
			S2.insert(0,"0");
		}
		cout << S1 << S2 << endl;
	}
}

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

string s;
void weather_forecast(){
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }
    else if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }
    else{
        cout << "Sunny" << endl;
    }
}

int main(){
    weather_forecast();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,m,a,b,c;
string s,t;

int main() {
  cin >> n;
  int t[100005],x[100005],y[100005];
  rep(i,n) cin >> t[i] >> x[i] >> y[i];
  int d; bool ok=true;
  rep(i,n){
    d=x[i]+y[i];
    if(d>t[i]) ok=false;
    if((d+t[i])&1) ok=false;
  }
  cout << (ok ? "Yes" : "No" ) << endl;
} 

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	int z=0;
	map<int,int> m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		m[a[i]]++;
		if(a[i] != 0) z=1;
	}
	if(z==0){
		cout<<"Yes";
		return 0;
	}
	if(m.size()==2){
		if(m.count(0)==0){
			cout<<"No"; return 0;
		}
		if(m[0] != n/3) {
			cout<<"No"; return 0;
		}
		cout<<"Yes";
		return 0;
	}
	if(n%3!=0 || m.size() !=3){
		cout<<"No"; return 0;
	}
	int b[3];
	int l=0;
	for(auto x : m){
		if(x.second != n/3){
			cout<<"No"; return 0;
		}
		b[l++]=x.first;
	}
	if(b[0]!=(b[1]^b[2]) || b[1]!=(b[0]^b[2]) || b[2]!=(b[1]^b[0])) cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 4224
#include <stdio.h>

int main(void)
{
	int c[3][3] = { '\0' };
	int i = 0, j = 0;
	int flg = 0;

	for (i = 0; i <= 2; i++) {
		for (j = 0; j <= 2; j++) {
			scanf("%d", &c[i][j]);
		}
	}

	//printf("%d\n", c[0][2]);

	for (i = 0; i+1 <= 2; i++) {
		for (j = 0; j + 1 <= 2; j++) {
			if (c[i][j] - c[i][j+1]==c[i+1][j]-c[i+1][j+1]) {
				flg = flg + 1;
				if (c[i][j] - c[i + 1][j] == c[i][j + 1] - c[i + 1][j + 1]) {
					flg = flg + 1;
				}
			}
		}
	}

	if (flg == 8) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
a = [0 for i in range(N)]
b = [0 for i in range(N)]
for i in range(N):
	a[i], b[i] = map(int, input().split())
c = [0 for i in range(M)]
d = [0 for i in range(M)]
for i in range(M):
	c[i], d[i] = map(int, input().split())

ans = [1 for i in range(N)]
for i in range(N):
	for j in range(M):
		if abs(a[i]-c[j])+abs(b[i]-d[j]) < abs(a[i]-c[ans[i]-1])+abs(b[i]-d[ans[i]-1]):
			ans[i] = j+1

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

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
static const int N=100;

int main(){
  int MA[N][N];
  int n, u, k, v;

  cin >> n;

  for(int i=0; i<n; i++)
  {
    for(int j=0; j<n; j++) MA[i][j]=0;
  }

  for(int i=0; i<n; i++)
  {
    cin >> u >> k;
    u--;
    for(int j=0; j<k; j++)
    {
      cin >> v;
      v--;
      MA[u][v]=1;
    }
  }

  for(int i=0; i<n; i++)
  {
    for(int j=0; j<n; j++)
    {
      if(j) cout << " ";
      cout << MA[i][j];
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,A,B,C;
ll l[10];
ll bit[10];
ll ans=INF;

int main(){

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

cin>>N>>A>>B>>C;
rep(i,N) cin>>l[i];
rep(i1,4){
	rep(i2,4){
		rep(i3,4){
			rep(i4,4){
				rep(i5,4){
					rep(i6,4){
						rep(i7,4){
							rep(i8,4){
								bit[0]=i1;
								bit[1]=i2;
								bit[2]=i3;
								bit[3]=i4;
								bit[4]=i5;
								bit[5]=i6;
								bit[6]=i7;
								bit[7]=i8;
								ll a=0; ll acost=0;
								ll b=0; ll bcost=0;
								ll c=0; ll ccost=0;
								rep(k,N){
									if(bit[k]==0){
										a+=l[k];
										acost++;
									}
									if(bit[k]==1){
										b+=l[k];
										bcost++;
									}
									if(bit[k]==2){
										c+=l[k];
										ccost++;
									}
								}
								if(acost==0||bcost==0||ccost==0) continue;
								ll cost=0;
								cost+=abs(A-a);
								cost+=abs(B-b);
								cost+=abs(C-c);
								cost+=10*(acost-1);
								cost+=10*(bcost-1);
								cost+=10*(ccost-1);
								ans=min(ans,cost);
							}
						}
					}
				}
			}
		}
	}
}
cout<<ans<<endl;

}
    


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

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	for (ll i = a; i <= b; ++i) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}


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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    queue<int> que;
    que.push(3);
    que.push(5);
    que.push(7);
    while (que.front() <= 1000000000)
    {
        que.push(10 * que.front() + 3);
        que.push(10 * que.front() + 5);
        que.push(10 * que.front() + 7);
        if (que.front() <= N)
        {
            bool three = false;
            bool five = false;
            bool seven = false;
            while (que.front() > 0)
            {
                int rem = que.front() % 10;
                if (rem == 3)
                {
                    three = true;
                }
                else if (rem == 5)
                {
                    five = true;
                }
                else
                {
                    seven = true;
                }
                que.front() /= 10;
            }
            if (three && five && seven)
            {
                ans++;
            }
        }
        que.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    long long int n,h;
    cin>>n>>h;
    vector<int> a(n);
    vector<int> b(n);
    int amax=0;
    for(long long int i=0; i<n; i++){
        cin>>a.at(i)>>b.at(i);
        amax=max(amax,a.at(i));
    }
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    
    long long int ans=0;
    long long int count=0;
    while(count<n){
        if(b.at(count)>=amax){
            ans++;
            h-=b.at(count);
            count++;
        }else{
            break;
        }
        if(h<=0) break;
    }
    if(h<=0) h=0;
    if(h%amax==0){
        ans+=h/amax;
    }else{
        ans+=h/amax;
        ans++;
    }
    cout<<ans<<endl;
}


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

ans = 0
dp = dict()

for i in range(n):
    a_p = a[i] + i+1
    a_m = i+1 -a[i]
    if a_p in dp:
        dp[a_p] = dp[a_p] + 1
    else:
        dp[a_p] = 1
    if a_m in dp:
        ans = ans + dp[a_m]


print(ans)

Measured memory_bytes: 40512