akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){

int N, M, a, b, i;

cin >> N >> M;

int c[N];

for(i = 0; i < N + 1; i++){
    c[i] = 0;
}

for(i = 0; i < M; i++){
    
    cin >> a >> b;
    
    c[a] = c[a] + 1;
    
    c[b] = c[b] + 1;
    
}

for(i = 1; i <= N; i++){
    cout << c[i] << endl;
}
    
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  string s;
  int P=0;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='p') {
      P++;
    }
  }
  cout << s.size()/2-P << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

/*!* [fenwick] *!*/
/*+* フェニック木
     長さNの配列の部分和と更新をO(log N)で行う *+*/
template <typename T, typename F = function<T(T, T)>>
struct Fenwick {
    int N;
    vector<T> array;
    const F f;
    const T id;
    Fenwick() {}
    Fenwick(int len, const F f, const T &id) : N(len), f(f), id(id) {
        array.assign(N, id);
    }
    inline int LSB(int x) { return x & (-x); }
    void update(int i, T val) {
        for (; i < N; i += LSB(i + 1)) {
            array[i] = f(array[i], val);
        }
    }
    // sum of the elements [0:i]
    T sum(int i) {
        T s = id;
        for (i++; i; i -= LSB(i)) {
            s = f(s, array[i - 1]);
        }
        return s;
    }
};

int main() {
    using R = tuple<int, int, int>;
    int N, Q;
    cin >> N >> Q;
    
    vector<int> C(N);
    vector<R> range(Q); // (r: 右端, l: 左端, j: 区間番号)

    for(int &c : C) cin >> c;
    for(int j = 0; j < Q; j++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        range[j] = make_tuple(r, l, j);
    }
    
    sort(WHOLE(range));

    auto add = [](int x, int y) -> int { return x + y; };
    Fenwick<int, decltype(add)> tree(N, add, 0);
    map<int, int> pos; // 色 -> 最右の位置

    vector<int> ans(Q);
    int q = 0;
    for(int i = 0; i < N; i++) {
        int c = C[i];
        if(pos.count(c)) {
            tree.update(pos[c], -1);
        }
        tree.update(i, 1);
        pos[c] = i;
        while(q < Q && get<0>(range[q]) <= i) {
            int l, r, j;
            tie(r, l, j) = range[q];
            ans[j] = tree.sum(r) - tree.sum(l - 1);
            q++;
        }
    }
    for(int x : ans) cout << x << endl;
    return 0;
}

Measured memory_bytes: 38916
n, m = map(int, input().split())
mod = 10**9+7
facs = [1] * (n-m+1)
invs = [1] * (n-m+1)
nfac = 1
for i in range(1, n-m+1):
    nfac = nfac * i % mod
    facs[i] = nfac
    invs[i] = pow(facs[i], mod-2, mod)

ans = 1
start = 0
def steps(start, end):
    t = end - start
    pat = 0
    for j in range(t//2+1):
        pat += (facs[t-j] * invs[j] * invs[t-j-j]) % mod
    return pat%mod

for i in range(m):
    a = int(input())
    end = a-1
    if start == end+1:
        print(0)
        break
    # startからendまで行く方法
    ans *= steps(start, end)
    ans %= mod
    start = a+1
else:
    ans *= steps(start, n)
    ans %= mod
    print(ans)


Measured memory_bytes: 76792
X, Y, A, B, C = map(int, input().strip().split())
p = list(map(int, input().strip().split()))
q = list(map(int, input().strip().split()))
r = list(map(int, input().strip().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p=p[:X]
q=q[:Y]

lst=p+q+r
lst.sort(reverse=True)

ans=sum(lst[:X+Y])
print(ans)

Measured memory_bytes: 22560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

ll MOD = 2019;

ll mpow(ll a, ll n) {  // a^n (mod MOD)
    // 二分累乗法 O(log n)
    ll ans = 1;
    while (n != 0) {
        if (n & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ans;
}

int main() {
    ll ans = 0;
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    ll l = S.size();
    vi A(2019);
    A[0] = 1;
    ll r = 0;
    for (ll i = 0; i < l; i++) {
        r += (S[i] - '0') * mpow(10, i);
        r %= 2019;
        ans += A[r];
        A[r]++;
        // cout << i+1 << ' ' << S[i] << ' ' << r << endl;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3740
#include<iostream>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,m;
    int ans=0;
    cin >> n >> m;
    ans += n*(n-1)/2;
    ans += m*(m-1)/2;
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
N,K,Q = [int(i) for i in input().split()]
ppl = [0]*(N + 1)
for _ in range(Q):
    A = int(input())
    if A == 1:
        ppl[1] += 1
        if N != 2:
            ppl[-1] -= 1
    elif A == N:
        ppl[0] += 1
        if N != 2:
            ppl[-2] -= 1
    else:
        ppl[0] += 1
        ppl[A-1] -= 1
        ppl[A] += 1
        ppl[-1] -= 1
ans = ["Yes"] * N
ans[0] = "Yes" if ppl[0] < K else "No"
for i in range(1,N):
    ppl[i] += ppl[i-1]
    if ppl[i] >= K:
        ans[i] = "No"
print("\n".join(ans))

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

typedef long long int ll;
const ll MOD = 998244353;
int num[7];

int T[3][4] = {{6, 4, 2, 0}, {5, 4, 1, 0}, {3, 2, 1, 0}};

ll ans = 1;

int main() {
    int n;
    string s;
    cin >> n >> s;
    num[0] = n;
    for (int i = 1; i < 8; i++)
        num[i] = 0;

    for (int i = 0; i < 3 * n ; i++) {
        int stat, p;
        if (s[i] == 'R')
            stat = 0, p = 1;
        else if (s[i] == 'G')
            stat = 1, p = 2;
        else
            stat = 2, p = 4;
        for (int j = 0; j < 4; j++) {
            int mask = T[stat][j];
            if (num[mask] > 0) {
                ans = ans * num[mask] % MOD;
                num[mask]--, num[mask + p]++;
                break;
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 900
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))

using namespace std;


int main(){
    int H,W;
    cin >> H >> W;
    long **t=new long*[H];
    for(int i=0;i<H;i++){
        t[i]=new long[W];
        for(int j=0;j<W;j++){
            char c;
            cin >> c;
            if(i==0 && j==0){ t[0][0]=1; continue; }
            if(c=='.'){
                t[i][j] = ((i>0)?t[i-1][j]:0) + ((j>0)?t[i][j-1]:0);
                t[i][j] %= 1000000007;
            }
            else{
                t[i][j]=0;
            }
        }
    }
    
    
    cout<<t[H-1][W-1];
    
    for(int i=0;i<H;i++){
        delete[] t[i];
    }
    delete[] t;
    return 0;
}


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

int main(){

  int K, S;
  cin >> K >> S;

  int x = 0;
  int y = 0;
  int z = 0;

  int ans = 0;

  for(int i = 0 ; i <= K ; ++i){
    for(int j = i ; j <= K ; ++j){
      if(i + j >= S - K && i + j <= S){
        ans++;
        if(i != j) ans++;
        // cout << i << "\t" << j << "\t" << S-(i + j) << "\t" << ans << endl;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = str(input())

score = 0
for i in range(2**(len(N)-1)):
    Ni = '0' * (len(N)-len(format(i, 'b'))-1) + format(i, 'b') + '0'
    l = list()
    buff = str()
    for n, ni in zip(N, Ni):
        buff += n
        if ni == '1':
            l.append(int(buff))
            buff = str()

    l.append(int(buff))
    score += sum(l)

print(score)

Measured memory_bytes: 3064
n = input()
n = [int(n[i:i + 1]) for i in range(4)]
for i in range(1 << 3):
  sum = n[0]
  for j in range(3):
    if ((i >> j) & 1) == 1:
      sum += n[j +  1]
    else:
      sum -= n[j + 1]
  if sum == 7:
    print(n[0], end = '')
    for j in range(3):
      if((i >> j) & 1) == 1:
        print('+', end = '')
      else:
        print('-', end = '')
      print(n[j + 1], end = '')
    print('=7')
    exit()

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    rep(h, H) cin >> a[h];
    vector<bool> allwhiteH(H, false);
    vector<bool> allwhiteW(W, false);
    rep(h, H) {
        int index = a[h].find("#");
        if (index == string::npos) {
            allwhiteH[h] = true;
        }
    }
    rep(w, W) {
        bool allwhiteflag = true;
        rep(h, H) {
            if (a[h][w] == '#') allwhiteflag = false;
        }
        if (allwhiteflag) allwhiteW[w] = true;
    }

    rep(h, H) {
        if (!allwhiteH[h]) {
            rep(w, W) {
                if (!allwhiteW[w]) {
                    cout << a[h][w];
                }
            }
            cout << endl;
        }
    }
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3664
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	string s,t; cin>>s>>t;
	For(i,0,n-1) cout<<s[i]<<t[i];
	cout<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,q;
  int s[100000]={0},t[50000]={0};
  int i;
  int cnt=0;
  int min,max,mid,tar;
	
  //min=0;
  //max=n-1;
	
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }
	
  for(i=0;i<q;i++){
    tar=t[i];
    min=0;
    max=n-1;
    while(min<=max){
      mid=(min+max)/2;
      if(s[mid]==t[i]){
	cnt++;
	break;
      }else if(s[mid]<t[i]){
	min=mid+1;
      }else if(s[mid]>t[i]){
	max=mid-1;
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2436
N,K = map(int,input().split())
S = list(map(int,input().split()))

D = [0] * K

for i in range(K-1):
    D[i] = S[i+1] - S[i]

D[-1] = (N - S[-1]) +S[0]
print(sum(D) - max(D))

Measured memory_bytes: 77620
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    nl = len(str(n))

    from collections import deque
    que = deque()

    selec = [3,5,7]
    que.append(0)
    ans = 0
    swi = False
    while que:
        a = que.popleft()
        sa = str(a)
        #print(a,sa,n)
        for i in range(3):
            que.append(a*10 + selec[i])
        if a > n:
            break
        elif (not swi) and sa.count('5') >= 1 and sa.count('7') >= 1 and sa.count('3') >= 1:
            swi = True
            ans += 1
        elif sa.count('5') >= 1 and sa.count('7') >= 1 and sa.count('3') >= 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
  main()


Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int main()
{
	int A,B;
	cin>>A>>B;
	int fd=-1;
	for(int v=B*10;;v++)
	{
		if((v/10)>B)break;
		if((v*2/25)==A)
		{
			fd=v;
			break;
		}
	}
	cout<<fd;
	return 0;
}

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



int main() {
	int n;
	string s;
	cin >> n >> s;

	if (n < 3200) {

		cout << "red" << endl;
	}

else cout << s << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include<cstring>
#include<iostream>
#include<stack>
#include<queue>
#include<functional>
#include<set>
#include<vector>
#include<map>
#include<stdlib.h>
#define ll long long
using namespace std;
int a[1000];
int main(){
	int n,i,j,sum1=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	if(n%2==0){
		for(i=0;i<n;i=i+2){
			sum1=sum1-a[i]+a[i+1];
		}
	}
	else{
		sum1=a[0];
		for(i=1;i<n;i=i+2){
			sum1=sum1-a[i]+a[i+1];
		}
	}
	printf("%d\n",sum1);
} 

Measured memory_bytes: 256
pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: usize = rd.get();
    let a: Vec<i64> = (0..n).map(|_| rd.get()).collect();

    let mo = 1_000_000_000 + 7;
    let mut s = a[0];
    let mut ans = 0;
    for i in 1..n {
        ans = ans + s * a[i] % mo;
        ans = ans % mo;
        s = s + a[i];
        s = s % mo;
    }
    println!("{}", ans);
}

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

using namespace std;
const long long mod = 1e9+7;

int main(){
  int N, M;
  cin >> N >> M;
  vector<bool> check(N+1, true);
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    check[a] = false;
  }

  vector<long long int> dp(N+1);
  dp[0] = 1;
  for (int i = 0; i < N; i++){
    for (int j = i+1; j <= min(N, i+2); j++){
      if (check[j]){
        dp[j] += dp[i];
        dp[j] %= mod;
      }
    }
  }

  cout << dp[N] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  string s, t;
  cin >> s >> t;

  vector<vector<ll>> a(26, vector<ll>(0));
  for (int i = 0; i < (int)s.size(); i++){
    a[s[i] - 'a'].emplace_back(i);
  }


  ll snum = 1, id = -1, ok = 1;
  for (int i = 0; i < (int)t.size(); i++){
    int n = a[t[i] - 'a'].size();
    if (n == 0){
      ok = 0;
      break;
    }
    if (a[t[i] - 'a'][n - 1] <= id){
      snum += 1;
      id = a[t[i] - 'a'][0];
    }
    else {
      int l = -1, r = n - 1, mid;
      while (l + 1 < r){
        mid = (l + r)/2;
        if (a[t[i] - 'a'][mid] <= id){
          l = mid;
        }
        else
          r = mid;
      }
      id = a[t[i] - 'a'][l + 1];
    }
  }

  if (ok)
    cout << (snum - 1)*s.size() + id + 1 << endl;
  else
    cout << -1 << endl;

  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 1724
#include<stdio.h>
#include<algorithm>
using namespace std;
int l1[110000];
int r1[110000];
int l2[110000];
int r2[110000];
int segtree[524288];
int dp[110000];
int query(int a,int b,int c,int d,int e){
	if(d<a||b<c)return 0;
	if(c<=a&&b<=d)return segtree[e];
	return max(query(a,(a+b)/2,c,d,e*2),query((a+b)/2+1,b,c,d,e*2+1));
}
void update(int a,int b){
	a+=262144;
	while(a){
		segtree[a]=max(segtree[a],b);
		a/=2;
	}
}
pair<int,pair<int,int> >ev[210000];
int z[210000];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d%d%d",l1+i,r1+i,l2+i,r2+i);
		z[i*2]=r2[i];
		z[i*2+1]=l2[i];
		ev[i*2]=make_pair(l1[i],make_pair(i,0));
		ev[i*2+1]=make_pair(r1[i],make_pair(i,1));
	}
	std::sort(z,z+a*2);
	std::sort(ev,ev+a*2);
	for(int i=0;i<a*2;i++){
		int at=ev[i].second.first;
		if(ev[i].second.second==0){
			int pos=lower_bound(z,z+a*2,l2[at])-z;
			dp[at]=query(0,262143,0,pos,1)+1;
		}else{
			int pos=lower_bound(z,z+a*2,r2[at])-z;
			update(pos,dp[at]);
		}
	}
	int ret=0;
	for(int i=0;i<a;i++)ret=max(ret,dp[i]);
	printf("%d\n",ret);
}

Measured memory_bytes: 8332
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    int x[100002];
    for(int i = 0; i < n; i++) cin >> x[i];
    ll k = 0;
    ll ans = 1;
    for(int i = 0; i < n; i++){
        k++;
        ans = (ans * k) % MOD;
        if(k * 2 - 1 > x[i]) k--;
    }
    cout << ans << endl;
}

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

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, A);
    CIN(int, B);

    cout << min(N*A,B) << "\n";
    return 0;
}

Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			char[] s = sc.next().toCharArray();
			int[][] a = new int[3][3];
			for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) {
				int k = 0;
				if (s[i * 3 + j] == 'o') k = 1;
				if (s[i * 3 + j] == 'x') k = 2;
				a[i][j] = k;
			}
			System.out.println(solve(a));
		}
	}
	char solve(int[][] a) {
		char[] s = {'d', 'o', 'x'};
		for (int side = 1; side <= 2; side++) {
			for (int i = 0; i < 3; i++) {
				if (a[i][0] == side && a[i][1] == side && a[i][2] == side) return s[side];
				if (a[0][i] == side && a[1][i] == side && a[2][i] == side) return s[side];
			}
			if (a[0][0] == side && a[1][1] == side && a[2][2] == side) return s[side];
			if (a[0][2] == side && a[1][1] == side && a[2][0] == side) return s[side];
		}
		return 'd';
	}
}

Measured memory_bytes: 17140
import java.util.Scanner; 
class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String input = sc.next();
      if(Character.isLowerCase(input.charAt(0))){
         System.out.println("a");
      } else {
         System.out.println("A");
      }
   }
}

Measured memory_bytes: 35628
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string b) {
  if (b == "A") {
    cout << "T" << endl;
    return;
  }
  if (b == "T") {
    cout << "A" << endl;
    return;
  }
  if (b == "C") {
    cout << "G" << endl;
    return;
  }
  if (b == "G") {
    cout << "C" << endl;
    return;
  }
}

int main() {
  std::string b;
  std::cin >> b;
  solve(b);
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if( n == 0 ) break;
			int[][] dp = new int[n+1][n+1];
			int max = 0;
			for(int i=1;i<=n;i++) {
				String line = sc.next();
				for(int j=1;j<=n;j++) if( line.charAt(j-1) == '.' ) {
					dp[i][j] = min( min(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1] ) + 1;
					max = max(max, dp[i][j]);
				}
			}
			System.out.println(max);
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  int stock = 0, ans = 0;
  rep(i, s.size()) {
    if (s[i] == 'g' && stock > 0) ans++, stock--;
    else if (s[i] == 'g') stock++;
    else if (s[i] == 'p' && stock > 0) stock--;
    else ans--, stock++;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 512
#set 
h,w = gets.chomp.split(" ").map(&:to_i)

line = Array.new(h)
squeares = Array.new(h) {Array.new(w, 0)}
answers = Array.new(h) {Array.new(w, 0)}

(0 .. h - 1).each do |i|
    line[i] = gets.chomp
    (0 .. w - 1).each do |j|
        squeares[i][j] = line[i].split("")[j]
    end
end

#main
(0 .. h - 1).each do |i|
    (0 .. w - 1).each do |j|
        if squeares[i][j] == '#' then
            answers[i][j] = squeares[i][j]
            (i - 1 .. i + 1).each do |k|
                (j - 1 .. j + 1).each do |l|
                    if k >= 0 && k < h && l >= 0 && l < w then
                        if k == i && l == j then
                            next
                        else
                            if answers[k][l] != '#' then
                                answers[k][l] = (answers[k][l].to_i + 1).to_s
                            end
                        end
                    end
                end
            end
        end
    end
end

(0 .. h - 1).each do |i|
    print ("#{answers[i].join}\n")
end

Measured memory_bytes: 4476
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
// struct edge { int u, v; ll w; };

int INF = INT_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int N;
vector<int> G[100010];
int sz[100010], dep[100010];
int M = 1;
int id[100010], par[100010];

void dfs_sz(int u, int p) {
	sz[u] = 1;
	for (int v: G[u]) {
		if (v == p) continue;
		dfs_sz(v, u);
		sz[u] += sz[v];
	}
}

void dfs_dep(int u, int p) {
	for (int v: G[u]) {
		if (v == p) continue;
		dep[v] = dep[u] + 1;
		dfs_dep(v, u);
	}
}

void dfs_hl(int u, int p) {
	int x, ma = 0;
	for (int v: G[u]) {
		if (v == p) continue;
		if (sz[v] > ma) {
			x = v;
			ma = sz[v];
		}
	}
	for (int v: G[u]) {
		if (v == p) continue;
		if (v == x) id[v] = id[u];
		else {
			id[v] = M;
			par[M] = u;
			M++;
		}
		dfs_hl(v, u);
	}
}

int main() {
	cin >> N;
	for (int u = 0; u < N; u++) {
		int k; scanf("%d", &k);
		while (k--) {
			int v; scanf("%d", &v);
			G[u].push_back(v);
			G[v].push_back(u);
		}
	}
	dfs_sz(0, N);
	dep[N] = -1;
	dfs_dep(0, N);
	par[0] = N;
	dfs_hl(0, N);
	int Q; cin >> Q;
	while (Q--) {
		int u, v; scanf("%d%d", &u, &v);
		while (id[u] != id[v]) {
			int U = par[id[u]], V = par[id[v]];
			if (dep[U] > dep[V]) u = U;
			else v = V;
		}
		printf("%d\n", dep[u] < dep[v] ? u : v);
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string S;cin>>S;

    bool ok=true;
    if(S[0]!='A')ok=false;
    if(count(S.begin()+2,S.end()-1,'C')!=1)ok=false;
    int latte=0;
    rep(i,S.size())if(isupper(S[i]))latte++;
    if(latte!=2)ok=false;
    if(ok)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<=b;i++)
#define fore(i,a) for(auto &i:a)


using namespace std;
typedef long long ll;

const int MOD = 1e9 + 7;
string S;

void add(ll &a, ll b) {
	a += b;
	if (a >= MOD)a -= MOD;
}

//i番目までみた時の、状態j
//j=0 ""
//j=1 A
//j=2 AB
//j=3 ABC

ll dp[210000][4];

int main() {

	cin >> S;
	memset(dp, 0, sizeof(dp));

	dp[0][0] = 1;

	//Sを1文字ずつみていく。
	for (int i = 0; i < S.size(); ++i) {
		//Siを使わない。
			//Si=?でないならそのままiの状態をi+1へそのまま引き継ぐ。
			//Si=?ならiの状態の3倍してi+1に引き継ぐ
		for (int j = 0; j <=3; ++j) {
			if (S[i] != '?') {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = dp[i][j] * 3 % MOD;
			}
		}

		//Siを使う。

		//状態0はAか？がくれば状態1に遷移する。
		if (S[i] == 'A' || S[i] == '?') add(dp[i + 1][1], dp[i][0]);

		//状態1はBか？がくれば状態2に遷移する。
		if (S[i] == 'B' || S[i] == '?') add(dp[i + 1][2], dp[i][1]);

		//状態2はCか？がくれば状態3に遷移する。
		if (S[i] == 'C' || S[i] == '?') add(dp[i + 1][3], dp[i][2]);
	}
	
	cout << dp[S.size()][3] << endl;
}

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

sort(_num1, _num2)
const void* _num1;
const void* _num2;
{
	long long num1 = *(const long long*)_num1;
	long long num2 = *(const long long*)_num2;
	if (num1 < num2)
		return -1;
	if (num1 > num2)
		return 1;
	if (num1 == num2)
		return 0;
}

main(void) {
	unsigned N = 0;
	scanf("%u", &N);
	long long* llarray = malloc(sizeof(long long) * N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &llarray[i]);
	}
	qsort((void*)llarray, N, sizeof(long long), sort);
	for (int i = 0; i < N; i++) {
		if (llarray[i] == llarray[i + 1]) {
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define For( i, j, k ) for( int i = j; i <= k; ++i )
using std::cin;
using std::cout;
using std::pair;
using std::vector;
const int N = 1e5 + 1;
long long ans = 1e18, tmp;
int n, a[ N ];
long long s[ N ];
int main( )
{
 cin >> n;
 For( i, 1, n )
  cin >> a[ i ];
 For( i, 1, n )
 {
  s[ i ] = s[ i - 1 ] + a[ i ];
  if( i & 1 )
  {
   if( s[ i ] >= 0 )
    tmp += s[ i ] + 1, s[ i ] = -1;
  }
  else
  {
   if( s[ i ] <= 0 )
    tmp += 1 - s[ i ], s[ i ] = 1;
  }
 }
 ans = std::min( ans, tmp );
 tmp = 0;
 For( i, 1, n )
 {
  s[ i ] = s[ i - 1 ] + a[ i ];
  if( !( i & 1 ) )
  {
   if( s[ i ] >= 0 )
    tmp += s[ i ] + 1, s[ i ] = -1;
  }
  else
  {
   if( s[ i ] <= 0 )
    tmp += 1 - s[ i ], s[ i ] = 1;
  }
 }
 ans = std::min( ans, tmp );
 cout << ans;
 return 0;
}

Measured memory_bytes: 4740
//Rafiqul Islam, MBSTU,ICT

#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test ;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
#define endl "\n"
#define all(v) v.begin(),v.end()

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const ll mod = 1e9 + 7;;
const ll maxn = 1e6+5;

ll power(ll x, unsigned long long y)
{
    ll res = 1;     // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x)%mod;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x)%mod;  // Change x to x^2
    }
    return res%mod;
}
ll modOp(ll a, ll b)
{
    ll c = a % b;
    if (c < 0)
        c += b;
    return c;
}
ll iv[maxn + 1];
void mod_inv()
{
    iv[1] = 1;
    for(ll i = 2 ; i <= maxn ; i++ )
    {

        iv[i] = (mod - mod/i * iv[mod%i]%mod)%mod;
        //cout << iv[i] << endl;
    }
}

ll Logn(ll n, ll base)
{
    return (n > base - 1) ? 1 + Logn(n / base, base) : 0;
}
vector<vector<int>> adj;
vector<int>sub_tree_size;
vector<array<int,2>> edge;
void dfs(int child, int parant)
{
    sub_tree_size[child] = 1;
    for(int x: adj[child])
    {
        if(x == parant)
            continue;

        dfs(x,child);
        sub_tree_size[child] += sub_tree_size[x];
    }

}


void run_case()
{
    int n;
    cin >> n;
    ll dp[n+10];
    memset(dp,0,sizeof(dp));
    dp[0] = 1;
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = 3 ; j <= i; j++)
            if(i-j>=0)
                dp[i] = modOp(dp[i]+dp[i-j], mod);
        //cout << dp[i] << endl;
    }
    cout << dp[n] << endl;



}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    run_case();
    //main();
    return 0;
}


Measured memory_bytes: 3652
#define taskname ""
#include <bits/stdc++.h>

using namespace std;

const int maxN = 101;
const int maxD = 101;

int n, d, x;
int a;
int fr[maxD];
int res = 0;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    memset(fr, 0, sizeof(fr));
    cin >> n >> d >> x;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a;
        for (int j = 1; j <= d; j += a)
        {
            ++fr[j];
        }
    }
    for (int i = 1; i <= d; ++i)
    {
        res += fr[i];
    }
    res += x;
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,flag=0;
    scanf("%d",&k);
    int a,b;
    scanf("%d %d",&a,&b);
    int h=a/k;
    if(k*(h+1)<=b||k*h>=a)
        flag=1;
    if(flag)
        printf("OK\n");
    else
        printf("NG\n");
}



Measured memory_bytes: 3760
hoge = input().split()
W = int(hoge[0])
H = int(hoge[1])
x = int(hoge[2])
y = int(hoge[3])
r = int(hoge[4])

if (x + r) <= W and (y + r) <= H and (x - r) >= 0 and (y + r) >= 0:
 print('Yes')
else:
 print('No')

Measured memory_bytes: 7680
#include <stdio.h>

typedef struct post_t_tag {
	char message[64];
	struct post_t_tag* next;
	struct post_t_tag* reply_begin;
	struct post_t_tag* reply_end;
} post_t;

int n;
post_t posts[2000];

void print_data(const post_t* post, int level) {
	const post_t* current;
	int i;
	for (i = 0; i < level; i++) putchar('.');
	puts(post->message);
	for (current = post->reply_begin; current != NULL; current = current->next) {
		print_data(current, level + 1);
	}
}

int main(void) {
	int i;
	if (scanf("%d", &n) != 1) return 1;
	for (i = 0; i < n; i++) {
		int k;
		if (scanf("%d", &k) != 1) return 1;
		if (scanf("%63s", posts[i].message) != 1) return 1;
		posts[i].next = posts[i].reply_begin = posts[i].reply_end = NULL;
		if (k > 0) {
			k--;
			if (posts[k].reply_end == NULL) {
				posts[k].reply_begin = posts[k].reply_end = &posts[i];
			} else {
				posts[k].reply_end->next = &posts[i];
				posts[k].reply_end = &posts[i];
			}
		}
	}
	print_data(&posts[0], 0);
	return 0;
}

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


int gcd(int p, int q){
    if(p % q == 0){
        return q;
    }else {
        return gcd(q, p % q);
    }
}


int main(){
    int k,ans = 0;
    std::cin >> k;

    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int h = 1; h <= k; h++){
                ans  = ans + gcd(gcd(i,j), h);
            }
        }
    }
    std::cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 998244353;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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 a, long long b) {
    return a * b / gcd(a, b);
}
//繋がっている頂点,.secondが辺の番号
vector<vector<P>> Edge(100005);
vector<int> connectedEdge(100005,0);
vector<int> ans(100005);
vector<bool> seen(100005,false);

//colorは前の隣接辺の色

void bfs(int start){
    queue<P> Q;
    //secondはその頂点の前の隣接辺の色
    Q.push(make_pair(start,-1));
    while(!Q.empty()){
        P p = Q.front();Q.pop();
        int V = p.first;int C = p.second;
        seen.at(V) = true;
        int now = 1; //←一頂点ごとに見ていくのでとりあえず1で初期化
        for(P U : Edge.at(V)){
            int to = U.first;
            if(seen.at(to)) continue;
            seen.at(to) = true;
            if(C == now) now++; //同頂点・隣接辺の色と同じ場合は1色足す
            ans.at(U.second) = now;
            Q.push(make_pair(to,now));
            now++;
        }
    }
}

int main() {
    int N;cin >> N;
    for(int i = 0;i<N-1;i++){
        int a,b;cin >> a >> b;
        a--;b--;
        Edge.at(a).push_back(make_pair(b,i));
        Edge.at(b).push_back(make_pair(a,i));
    }
    int MAXedge = 0;
    int s = 0;
    for(int i = 0;i<N;i++) {
        int e = Edge.at(i).size();
        connectedEdge.at(i) = e;
        if(MAXedge < e) s = i;
        MAXedge = max(MAXedge,e);
    }

    bfs(0);

    cout << MAXedge << endl;
    for(int i = 0;i<N-1;i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 7424
/***************************************************************
	File name: A.cpp
	Author: ljfcnyali
	Create time: 2019年09月01日 星期日 19时57分31秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i ) 
#define mem(a) memset ( (a), 0, sizeof ( a ) ) 
#define str(a) strlen ( a ) 
typedef long long LL;

char s[4][4];

int main()
{
    scanf("%s", s[1]);
    scanf("%s", s[2]);
    int ans = 0;
    REP(i, 0, 2) if ( s[1][i] == s[2][i] ) ++ ans;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	const ll mod = 1000000007;

	ll N;
	string S1, S2;
	std::cin >> N;
	std::cin >> S1 >> S2;
	char cur1 = S1[0];
	char cur2 = S2[0];
	ll ans = 3;
	if (cur1 != cur2) {
		ans *= 2;
	}
	rep(i, 1, N) {
		if (S1[i] != cur1) {

			if (S1[i] != S2[i] && cur1 != cur2) {
				ans *= 3;
				ans %= mod;
			}
			else if (S1[i] != S2[i] || cur1==cur2) {
				ans *= 2;
				ans %= mod;
			}

			cur1 = S1[i];
			cur2 = S2[i];
		}
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000;
int main(){
  int N;
  cin >> N;
  vector<long long> x(N), y(N);
  for (int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
  }
  vector<pair<long long, int>> a(N);
  for (int i = 0; i < N; i++){
    a[i] = make_pair(x[i] + y[i], i);
  }
  vector<pair<long long, int>> b(N);
  for (int i = 0; i < N; i++){
    b[i] = make_pair(x[i] - y[i], i);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  long long ans = 0;
  int p1 = a[0].second;
  int q1 = a[N - 1].second;
  ans = max(ans, abs(x[q1] - x[p1]) + abs(y[q1] - y[p1]));
  int p2 = b[0].second;
  int q2 = b[N - 1].second;
  ans = max(ans, abs(x[q2] - x[p2]) + abs(y[q2] - y[p2]));
  cout << ans << endl;
}

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

int main(){

	int  i,j;
	int 	x,y,a,b,c;
	int N,M,A[110];
	long long sum=0;
	scanf("%d",&N);
	
	for(i=0;i<3;i++){
		M = N%10;
		if(M==7){
			printf("Yes\n");
			return 0;
		}
		N/=10;
		
	}
	
	printf("No\n");
 return 0;
 }

Measured memory_bytes: 1660
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    val a: Int = sc.nextLine().toInt
    sc.nextLine().toInt
    sc.nextLine().toInt
    sc.nextLine().toInt
    val e: Int = sc.nextLine().toInt
    val diff: Int = sc.nextLine().toInt

    if ((e - a) > diff) {
      println(":(")
    } else {
      println("Yay!")
    }
  }

}

Measured memory_bytes: 27448
//>> OI Solution Info <<//
// Version: 2
// State: Progress
// Problem: Snuke Numbers
// ID: ---
// Time: ---
// Timeline:
//   --- ~ --- Initialize
// Review:
//   ---
//>> End <<//
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 y_0
#define y1 y_1
#define yn y_n
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int getS(long long x){
	int res=0;
	while(x>0){
		res+=x%10;
		x/=10;
	}
	return res;
}

long long getNext(long long x){
	long long sig=10;
	while(true){
		long long y=x;
		y-=y%sig;
		y+=sig-1;
		if(y*getS(x)>=x*getS(y))break;
		sig*=10;
		x=y;
	}
	return x;
}

int main(){
	int k;
	long long num=1;
	scanf("%d",&k);
	for(int i=0;i<k;i++){
		printf("%lld\n",num);
		num=getNext(num+1);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n;cin >> n;
    map<int,int> mp;
    rep(i, n) {
        int a;cin >> a;
        mp[a]++;
    }
    ll ans = 1;
    /*rep(i, n) {
        cout << i <<":" << mp[i] << endl;
    }*/
    rep1(i, n-1) {
        if(mp[i]!=0&&mp[i]!=2) {
            cout << 0 << endl;
            // cout << "error" << endl;
            return 0;
        }
        if(mp[i]!=0)ans*=mp[i];
        ans%=mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8296
(function(input) {
    var p = parse(input);
    p = p.map(function(e) { return e.map(Number); });
    var i = p.shift();
    var n = i[0];
    var m = i[1];
    var l = i[2];

    var a = p.slice(0, n);
    var b = p.slice(n, n + m);

    var c = array(n, l);
    for (var i = 0; i < n; i++) {
        for (var j = 0; j < l; j++) {
            c[i][j] = 0;
            for (var k = 0; k < m; k++) {
                c[i][j] += a[i][k]* b[k][j];
            }
        }
    }
    console.log(build(c));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function parse(str, sep, ter) {
    sep = sep || ' ';
    ter = ter || '\n';
    str = str.replace(/\n$/, '');
    var a = str.split(ter);
    for (var i = 0; i < a.length; i++) {
        a[i] = a[i].split(sep);
    }
    return a;
}

function build(a, sep, ter) {
    sep = sep || ' ';
    ter = ter || '\n';
    var lines = [];
    for (var i = 0; i < a.length; i++) {
        lines.push(a[i].join(sep));
    }
    return lines.join(ter);
}

function array(i, j) {
    var a = [];
    for (var n = 0; n < i; n++) {
        a.push(Array(j));
    }
    return a;
}

Measured memory_bytes: 12128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;

int main(){
    long n;
    cin >> n;
    vector<long> vec(n+10,0);
    long now;//現在地
    cin >> now;
    long d=0;//何回飛べるか
    long a=0;//vector in
    for (long i=1;i<n;i++){
        long e;
        cin >> e;
        if(i<n-1){
        if(now>=e) {
            now=e;
            d++;
        }
        else {
            now=e;
            vec.at(a)=d;
            d=0;
            a++;
        }
        }
        else {
            if(now>=e) {
                now=e;
                d++;
                vec.at(a)=d;
                d=0;
                a++;
            }
            else {
                now=e;
                vec.at(a)=d;
                d=0;
                a++;
            }
        }
    }
    sort(vec.begin(),vec.end(),greater<long>());
    cout << vec.at(0) << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define INT_INF (2 * 1e9)
#define LL_INF  (2LL * 1e18)
#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#endif
 
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9 + 7;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }

void solve()
{
	int n, m;
	bool good[200];

	cin >> n >> m;

	for(int i = 1; i <= m; ++i)
		good[i] = true;

	for(int i = 0; i < n; ++i)
	{
		bool appeared[200];

		for(int j = 1; j <= m; ++j)
			appeared[j] = false;

		int k;
		cin >> k;

		for(int j = 0; j < k; ++j)
		{
			int val;
			cin >> val;

			appeared[val] = true;
		}

		for(int j = 1; j <= m; ++j)
			good[j] &= appeared[j];
	}

	int ans = 0;

	for(int j = 1; j <= m; ++j)
		ans += good[j];


	cout << ans << endl;
}

int main(int argc, char** argv)
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256