akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n), b;
    for (int i = 0; i < n; ++i) {
        a[i] = s[i] - '0';
    }
    bool hasone = false;
    for (int i = 1; i < n; ++i) {
        b.push_back(abs(a[i] - a[i - 1]));
        if (b.back() == 1)
            hasone = true;
    }
    int ones = 0, twoes = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (b[i] == 1)
            ones += (((n - 2) & i) == i ? 1 : 0);
        else if (b[i] == 2)
            twoes += (((n - 2) & i) == i ? 1 : 0);
    }
    ones %= 2;
    twoes %= 2;
    if (hasone) {
        if (ones == 0)
            cout << 0 << "\n";
        else
            cout << 1 << "\n";
    } else {
        if (twoes == 0)
            cout << 0 << "\n";
        else
            cout << 2 << "\n";
    }
    return 0;
}

Measured memory_bytes: 11800
#!/usr/bin/env python3
from itertools import product
import sys

sys.setrecursionlimit(200000)

H, W = map(int, input().split())
S = [input() for _ in range(H)]
color = [[None] * W for _ in range(H)]
memo = [[0, 0] for _ in range(H * W + 1)]
cnt = 1


def dfs(p, c):
    x, y = p
    color[x][y] = c
    memo[cnt][c] += 1
    for dx, dy in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and color[nx][ny] is None and c != (S[nx][ny] == '#'):
            dfs([nx, ny], not c)


for i, j in product(range(H), range(W)):
    if color[i][j] is None:
        dfs([i, j], S[i][j] == '#')
        cnt += 1

ans = 0
for i in range(H * W):
    ans += memo[i][0] * memo[i][1]
print(ans)


Measured memory_bytes: 270820
import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n B.getLine >>= mapM_ B.putStrLn

solve :: [ByteString] -> [ByteString]
solve ss = let imp = M.empty :: Map ByteString Int
               mp = foldl' (\m s -> M.insertWith (+) s 1 m) M.empty ss
           in sort $
              snd $
              M.foldlWithKey' (\(ct, ls) k v ->
                                             if ct < v then (v, [k])
                                             else if ct == v then (ct, k:ls)
                                                  else (ct, ls)) (0, []) mp


Measured memory_bytes: 74748
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n<2)cout<<n<<endl;
  else if(n<4)cout<<2<<endl;
  else if(n<8)cout<<4<<endl;
  else if(n<16)cout<<8<<endl;
  else if(n<32)cout<<16<<endl;
  else if(n<64)cout<<32<<endl;
  else cout<<64<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
int main()
{
fast_io
li a,b,c;
cin>>a>>b>>c;
cout<<c<<" "<<a<<" "<<b;
  return 0;
}


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

typedef long long int lli;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, c;
    int k;

    cin >> a >> b >> c;
    cin >> k;

    int counter = 0;

    while(a >= b)
    {
        b *= 2;
        counter++;
    }

    while(b >= c)
    {
        c *= 2;
        counter++;
    }

    if(counter <= k)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
using namespace std;

int main()
{
  int n;
  cin >> n;
  getchar();
  while( n --){
    int i;
    char s[1002] = {};
    int A[1000] = {} , B[1000] = {};
    stack<int> C;
    char a, b;
    int end;
    fgets(s, 1000, stdin);
    i = 100; int k = 0;
    while(1 ) {
      a = s[k++];
      if(a  == '\n') break;
      A[i] = a - '0';
      i--;
      if(i < 20)  break;
    }
    int j = 100;
     fgets(s, 1000, stdin);
     k = 0;
    while(1) {
      b = s[k++];
      if(b == '\n') break;
      B[j] = b - '0';
      j--;
      if(j < 20)  break;

    }
    if( i < 20  || j < 20 ) {  cout << "overflow" <<endl; continue; }

    if(i > j)
      end = 101 - j;
    else
      end = 101 - i;

    A[i++] += B[j++];
  
    for(int k = 0; k <= end ; i++, j++, k++) {
      A[i] += B[j];
      A[i] += A[i - 1] / 10;
      A[i - 1] %= 10;
      C.push(A[i - 1]);
    }
    if(C.top() == 0 && C.size() != 1) {
      C.pop();
    }
    end = C.size() - 1;
    if(end > 80){
      cout << "overflow" << endl;
      continue;
    }

    for(i = 0; i < end; i++) {
      cout << C.top();
      C.pop();
    }
  
    cout << endl;
  
  }
}

Measured memory_bytes: 1212
H, W = map(int, input().split())
cost_list = [[0]*W for i in range(H)]
cost_check = [[0]*W for i in range(H)]
path_list = [] # path content
max_cost = 0 # max path cost

def path_cost(x, y):
    if path_list[x][y]=="#":
        return -1
    # cost check clear
    for i in range(H):
        for j in range(W):
            cost_check[i][j] = 0
            cost_list[i][j] = 0
    # cost calculation
    path_queue = [[x,y]]
    cost_check[x][y] = 1
    # path cost process
    while len(path_queue)>0:
        # path queue pop
        path = path_queue.pop(0)
        next_x, next_y = path[0], path[1]
        # right cost process
        if next_x+1<H:
            if path_list[next_x+1][next_y]=="." and cost_check[next_x+1][next_y]==0:
                cost_list[next_x+1][next_y] = max(cost_list[next_x+1][next_y], cost_list[next_x][next_y]+1)
                path_queue.append([next_x+1, next_y])
                cost_check[next_x+1][next_y] = 1

        # bottom cost process
        if next_y+1<W:
            if path_list[next_x][next_y+1]=="." and cost_check[next_x][next_y+1]==0:
                cost_list[next_x][next_y+1] = max(cost_list[next_x][next_y+1], cost_list[next_x][next_y]+1)
                path_queue.append([next_x, next_y+1])
                cost_check[next_x][next_y+1] = 1

        # left cost process
        if next_x-1>=0:
            if path_list[next_x-1][next_y]=="." and cost_check[next_x-1][next_y]==0:
                cost_list[next_x-1][next_y] = max(cost_list[next_x-1][next_y], cost_list[next_x][next_y]+1)
                path_queue.append([next_x-1, next_y])
                cost_check[next_x-1][next_y] = 1

        # up cost process
        if next_y-1>=0:
            if path_list[next_x][next_y-1]=="." and cost_check[next_x][next_y-1]==0:
                cost_list[next_x][next_y-1] = max(cost_list[next_x][next_y-1], cost_list[next_x][next_y]+1)
                path_queue.append([next_x, next_y-1])
                cost_check[next_x][next_y-1] = 1

    tmp_max_cost = max(sum(cost_list,[]))
    return tmp_max_cost

# input path
for i in range(H):
    path_in = input()
    path = []
    for j in range(W):
        path.append(path_in[j])
    path_list.append(path)

# cost calculation
for i in range(H):
    for j in range(W):
        max_cost = max(max_cost,path_cost(i, j))

print(max_cost)


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

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

const double EPS = 1e-8;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

int main() {
  double d;
  while(cin>>d,d) {
    double px,py,vx,vy;
    cin>>px>>py>>vx>>vy;
    P p(px,py);
    P v(vx,vy);
    double r = INF;
    int c =  ccw(P(0,0),p,v);
    if (c == 2) {
      r = abs(p);
    } else if (c == -2 || c == 0) {
      r = 2 - abs(p);
    }
    if (r <= d)
      printf("%.7lf\n", r);
    else
      cout << "impossible" << endl;
    
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int aa[50]={0};
int main()
{
	string s;
	int a,b,c,d;
	cin>>s;
	a=s[0]-'0';b=s[1]-'0';c=s[2]-'0';d=s[3]-'0';
	if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
	else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
    else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
    else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
    else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
    else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
    else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";
    else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())

diff = abs(X)

if K * D <= diff:
    if X >= 0:
        print(X - D * K)
    else:
        print(-1 * (X + D * K))

else:
    mod = diff // D
    if X >= 0:
        plus = X - D * mod
        minus = plus - D
        if (K - mod) % 2 == 0:
            print(plus)
        else:
            print(-minus)
    else:
        minus = X + D * mod
        plus = minus + D
        if (K - mod) % 2 == 0:
            print(-minus)
        else:
            print(plus)

Measured memory_bytes: 9148
def gen_d_prim(n):
    D = [0] * (n+1)
    for i in range(2, n+1):
        if D[i] > 0: continue
        for j in range(i, n+1, i): D[j] = i
    return D

def is_pairwise(A):
    D = gen_d_prim(10**6)
    past = set()
    for a in A:
        now = set()
        while a != 1:
            # 素数 D[a]: 今回は未済 & 過去で済
            if not D[a] in now and D[a] in past: return False
            now.add(D[a])
            past.add(D[a])
            a //= D[a]
    return True

def solve():
    from functools import reduce
    from math import gcd
    if is_pairwise(A): return 0
    if reduce(gcd, A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


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

using namespace std;

long long f[25000001];
long long MOD=1000000007;

long long Power(long long a, long long k)
{
    long long R=1, ss=a, t=1;
    while (k > 0)
    {
        if (k % (2*t) != 0)
        {
            k -= t;
            R *= ss;
            R %= MOD;
        }
        t *= 2;
        ss *= ss;
        ss %= MOD;
    }
    return R;
}

int main()
{
    ios::sync_with_stdio(false);
    long long r=0, K=0, S, s=0, l, d;
    cin >> S;
    long long I=floor(S/8);
    for (long long i = 1; i <= 25000000; i++)
    {
        d = log10(i) + 1;
        f[i] = d;
    }
    for (int i = 1; i < 10000000; i++)
    {
        while (s < S)
        {
            r++;
            s += f[r];
        }
        if (s == S)
        {
            K++;
        }
        s -= f[i];
    }
    K += I;
    for (int i = 1; i <= I; i++)
    {
        if (S % i == 0)
        {
            d = S / i;
            long long p = Power(10, d) - Power(10, d-1) - S/d;
            while (p < 0)
            {
                p += MOD;
            }
            K += p;
            K %= MOD;
        }
    }
    cout << K;
    return 0;
}


Measured memory_bytes: 195840
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, string).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, string).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        n: usize,
        w: usize,
        nap: [(usize, i64); n]
    }
    let mut dp: Vec<Vec<i64>> = vec![vec![0; w+1]; n + 1];
    for i in 1..n+1 {
        let (weight, value) = nap[i - 1];
        for g in 0..w+1 {
            let a = if weight <= g {dp[i-1][g-weight] + value} else {0};
            dp[i][g] = cmp::max(dp[i-1][g], a);
        }
    }

    println!("{}", dp[n][w]);
}


Measured memory_bytes: 106748
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

class UnionFind{
  vector<int> _parent, _depth, _size;
  int _count;
public:
  UnionFind(int n): _parent(n), _depth(n,1), _size(n,1), _count(n){REP(i, n) _parent[i] = i;}
  int root(int i){
    if(_parent[i] == i) return i;
    else return _parent[i] = root(_parent[i]);
  }
  bool same(int i, int j){return root(i) == root(j);}
  int merge(int i, int j){
    int ri = root(i), rj = root(j);
    if(ri == rj) return ri;
    else{
      --_count;
      if(_depth[ri] < _depth[rj]){
	_parent[ri] = rj; _size[rj] += _size[ri];
	return rj;
      }else{
	_parent[rj] = ri; _size[ri] += _size[rj];
	if(_depth[ri] == _depth[rj]) ++_depth[ri];
	return ri;
      }
    }
  }
  int size(int i){return _size[root(i)];}
  int count(){return _count;}
};


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

  int N,M;
  while(cin >> N >> M){
    vector<LLI> a(N); cin >> a;
    UnionFind uf(N);
    REP(i,M){
      int x, y; cin >> x >> y;
      uf.merge(x,y);
    }

    LLI ans = 0;
    bool no = false;

    int c = uf.count();

    if(c > 1){
      map<int, vector<LLI>> mp;

      REP(i,N){
	mp[uf.root(i)].push_back(a[i]);
      }

      vector<LLI> a2;

      for(auto &kv : mp){
	auto &v = kv.snd;
	sort(RALL(v));
	ans += v.back(); v.pop_back();
	for(auto x : v) a2.push_back(x);
      }

      int r = (c-1)*2-c;
      sort(ALL(a2));
      
      if((int)a2.size() < r){
	no = true;
      }else{
	ans += accumulate(a2.begin(), a2.begin()+r, 0LL);
      }
    }

    if(!no){
      cout << ans << endl;
    }else{
      cout << "Impossible" << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 13184
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
#define X real()
#define Y imag()
#define EPS (1e-10)
typedef complex<double> P;
typedef pair<P, P> L;

namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

P projection(P a, P b){
  return dot(a, b)/abs(b)/abs(b)*b;
}

int ccw(P a, P b, P c){
  if(cross(b-a,c-a) > EPS) return 1;
  if(cross(b-a,c-a) < -EPS) return -1;
  if(dot(b-a,c-a) < -EPS) return 2;
  if(abs(b-a) < abs(c-a) - EPS) return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}

P intersection(L a, L b){
  //テ、ツコツ、テァツつケ
  return a.first + abs(cross(b.second-b.first,a.first-b.first)/(abs(cross(b.second-b.first,a.second-b.first))+abs(cross(b.second-b.first,a.first-b.first))))*(a.second-a.first);;
}

int main(){
  int n;
  while(cin >> n, n){
    vector<L> s;
    double x1, y1, x2, y2;
    for(int i = 0; i < n; ++i){
      cin >> x1 >> y1 >> x2 >> y2;
      s.push_back(L(P(x1,y1), P(x2,y2)));
    }
    int ans = 1;
    for(int i = 0; i < n; ++i){
      L si = s[i];
      vector<P> cp;
      cp.push_back(si.first);
      cp.push_back(si.second);
      for(int j = 0; j < i; ++j){
	if(is_cross(si,s[j]))
	  cp.push_back(intersection(si,s[j]));
      }
      sort(cp.begin(), cp.end());
      for(int j = 1; j < cp.size(); ++j)
	if(abs(cp[j-1]-cp[j]) > EPS) ++ans;
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  int x,y;
  
  while(1){
    cin >> x >> y;
  if(x == 0 && y ==0)break;


  if(x <= y){
    cout << x << " " << y <<"\n";
  }
  else{ 
    cout << y << " " << x <<"\n";
  }
  }
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 2e5 + 5;
const LL maxm = LL(1e18)+5;

int main()
{
    int A = 0,B = 0;
    string s;cin >> s;
    _for(i,0,3){
        if(s[i] == 'A') A++;
        if(s[i] == 'B') B++;
    }
    if(A*B > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>Fac,Rac;void setF(int n,int mod){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%mod;Rac[n-1]=modInv(Fac[n-1],mod);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 2e3;
const int NN = N*2+1;
int n;
int c[NN][NN];
ll DP[NN][NN];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  setF(N*4, MOD);
  cin >> n;
  ll ans = 0;
  FOR(i, 0, n){
    int a, b;
    cin >> a >> b;
    ans -= comb(a*2+b*2, a*2, MOD);
    DP[N-a][N-b]++;
    c[N+a][N+b]++;
  }
  FOR(i, 0, NN)FOR(j, 0, NN){
    if(i) DP[i][j] += DP[i-1][j];
    if(j) DP[i][j] += DP[i][j-1];
    DP[i][j] %= MOD;
    ans += DP[i][j] * c[i][j] % MOD;
  }
  cout << (ans%MOD+MOD)*modInv(2, MOD)%MOD << endl;
}

Measured memory_bytes: 158976
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, M;
	cin >> N >> M;
	int left = 0, right = N;
	rep( i, 0, M ){
		int l, r;
		cin >> l >> r;
		left = max( left, l );
		right = min( right, r );
	}
	int ans = right - left + 1;
	if (ans < 0)
		ans = 0;
	cout << ans << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}


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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

 bool IsPrime(ll num){
    if (num < 2) return false;
    else 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;
}

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

    int ans = 0;
    for(int i = 0; i < n-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            ans++;
        }

    }

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

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

int main(void) {

  int fig[64];

  char buf[10];
  
  int i,j;

  while(1) {
  for(i=0;i<8;i++) {

    if(fgets(buf,sizeof(buf),stdin)==NULL) return 0;
    buf[strlen(buf)-1]='\0';

    for(j=0;j<8;j++) {

      fig[8*i+j]=(int)buf[j]-48;

    }

  }

  /*for(i=0;i<64;i++) {

    printf("%d ",fig[i]);

    }*/

  for(i=0;i<64;i++) {

    if(fig[i]==1) {

      //A or C or E or G
      if(fig[i+1]==1) {

	if(fig[i+2]==1) {
	  printf("C\n");
	  break;
	}

	else if(fig[i+10]==1) {
	  printf("E\n");
	  break;
	}

	else if(fig[i+7]==1) {
	  printf("G\n");
	  break;
	}

	else {
	  printf("A\n");
	  break;
	}

      }

      //B or D or F
      else if(fig[i+8]==1) {

	if(fig[i+16]==1) {
	  printf("B\n");
	  break;
	}

	if(fig[i+7]==1) {
	  printf("D\n");
	  break;
	}

	if(fig[i+9]==1) {
	  printf("F\n");
	  break;
	}

      }

    }

  }

  //ツ凝ウツ板陳禿づ敖氾イツづ篠つオ
  fgets(buf,sizeof(buf),stdin);
  }
  return 0;

}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
    int n;
    int flag = 0;
    scanf("%d", &n);
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i*j==n){
                flag = 1;
                goto out;
            }
        }
    }
out:
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 1664
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
//SSSTSTT --> SSSTT --> SST --> S (Keep a running counter of S's as you traverse left to right
// across given string)
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		String S = I.next();
		int ans = S.length();
		int N = ans;
		int s = 0;
		for (int i = 0; i < N; i++) {
			if (S.charAt(i)=='S') {
				s++;
				int t = 0;
				for (int next = i+1; next < N; next++) {
					if (S.charAt(next)=='T') {
						i=next-1;
						break;
					}
					s++;
				}
				for (int next = i+1; next<N; next++) {
					if (S.charAt(next)=='S') {
						i=next-1;
						break;
					}
					t++;
				}
				ans-=Math.min(s, t)*2;
				s-=Math.min(s,t);
			}
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 29584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	int Z = S.size();
	rep(i, Z) {
		if (i % 2 == 0 && S[i] == 'L') {
			cout << "No" << endl;
			return 0;
		}

		if (i % 2 != 0 && S[i] == 'R') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

//偶数距離離れてる→偶数ステップ経過したときにそこに居ることができる
//奇数距離離れてる→奇数ステップ経過したときにそこに居ることができる
//距離→マンハッタン距離を計算
int main(void) {
    int N;
    cin >> N;

    vector<int> t(N),x(N),y(N);
    rep(i, N) cin >> t[i] >> x[i] >> y[i];

    int current_x = 0;
    int current_y = 0;
    int current_time = 0;

    rep(i,N){
        int manhattan = abs(current_x - x[i]) + abs(current_y - y[i]);
        int step = abs(current_time - t[i]);

        if(manhattan > step or step%2 != manhattan%2){
            cout << "No" << endl;
            return 0;
        }

        current_x = x[i];
        current_y = y[i];
        current_time = t[i];
    }

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


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

using namespace std;

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

#define INF 2<<29
#define F first
#define S second

int n,k;
int temp;
int h[100005];
int dp[100005];

int main(){
  
  scanf("%d %d",&n,&k);
  for(int i=1;i<=n;i++){
    scanf("%d",&h[i]);
  }
  
  dp[2]=abs(h[2]-h[1]);

  for(int i=3;i<=n;i++){
    temp=INF;
    for(int j=1;j<=k;j++){
      if(i>j){
	temp=min(temp,dp[i-j]+abs(h[i]-h[i-j]));
      }
    }
    dp[i]=temp;	
  }
	
  printf("%d\n",dp[n]);

  return (0);
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) { printf("Yes\n"); }
    else { printf("No\n"); }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
ll a, b, c, d;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
int main()
{
    read(a), read(b), read(c), read(d);
    ll tmp = c * d / gcd(c, d);
    printf("%lld\n", b - a + 1 - (b / c - (a - 1) / c + b / d - (a - 1) / d - b / tmp + (a - 1) / tmp));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool isp[10000];
main()
{
    isp[0]=isp[1]=1;
    for(int i=2;i<=100;i++)
    {
        if(isp[i])continue;
        for(int j=i*i;j<=10000;j+=i)isp[j]=1;
    }
    int n;
    while(cin>>n,n)
    {
        while(isp[n]||isp[n-2])n--;
        cout<<n-2<<" "<<n<<endl;
    }
}


Measured memory_bytes: 3092
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main
{
    private static int solveAll(List<Integer> vertices, Set<int[]> nodes)
    {
        int count = 0;
        for (int[] bridge : nodes) {
            boolean result = solve(new ArrayList<>(vertices), nodes, bridge, 1);
//            System.out.println(String.format("bridge=%s, result=%s", Arrays.toString(bridge), result));
            if (!result) {
                count++;
            }
        }
        return count;
    }

    private static boolean solve(ArrayList<Integer> vertices, Set<int[]> nodes, int[] bridge, int cur)
    {
        if (!vertices.contains(cur)) {
            return false;
        }

        vertices.remove(Integer.valueOf(cur));

        if (vertices.isEmpty()) {
            return true;
        }

        for (int[] node : nodes) {
            if (Arrays.equals(node, bridge)) {
                continue;
            }

            if (node[0] == cur) {
                if (solve(vertices, nodes, bridge, node[1])) {
                    return true;
                }
            }
            else if (node[1] == cur) {
                if (solve(vertices, nodes, bridge, node[0])) {
                    return true;
                }
            }
        }

        return false;
    }

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        Set<int[]> nodes = new HashSet<>();
        for (int i = 0; i < m; i++) {
            int[] node = new int[2];
            node[0] = scanner.nextInt();
            node[1] = scanner.nextInt();
            nodes.add(node);
        }

        ArrayList<Integer> vertices = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            vertices.add(i);
        }

        System.out.println(solveAll(vertices, nodes));
    }
}



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

int main(void)
{
    for (int i = 0; i < 10000; ++i)
    {
        int x;
        cin >> x;
        if (x)
            cout << "Case " << i+1 << ": " << x << endl;
        else
            break;
    }
    
    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	int k,a,b;
	cin>>k>>a>>b;
	if(a%k==0 or b%k==0){
		cout<<"OK";
		return;
	}	
	int p=k-a%k;
	if(a+p<=b){
		cout<<"OK";
	}
	else
		cout<<"NG";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

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

const int MAX_N = 100005;
int memo[MAX_N];

int dp(int N)
{
	if (memo[N] == -1) {
		if (N < 6) {
			memo[N] = N;
		} else {
			int mn = N;
			int cur = 6;
			for (int i = 1; cur <= N; ++i) {
				mn = min(mn, dp(N-cur));
				cur *= 6;
			}
			cur = 9;
			for (int i = 1; cur <= N; ++i) {
				mn = min(mn, dp(N-cur));
				cur *= 9;
			}
			memo[N] = mn+1;
		}
	}
	//cout << N << ": " << memo[N] << endl;
	return memo[N];
}

signed main()
{
	int N;
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		memo[i] = -1;
	}
	cout << dp(N) << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define PI 3.1415926535897932384626
#define mod 1000000007
using namespace std;

int main(){
		int n;
  	cin >> n;
  	long double ans = PI*(n*2);
  	cout <<fixed << setprecision(2);
  	cout << ans <<endl;


}


Measured memory_bytes: 3800
#include <iostream>

using namespace std;

class Student
{
public:
	int middle;
	int end;
	int re;
public:
	Student()
	{
		middle = -1;
		end = -1;
		re = -1;
	}
};

int main()
{
	int sum;

	while (true)
	{
		sum = 0;
		Student student;
		cin >> student.middle >> student.end >> student.re;
		if (student.middle == -1 && student.end == -1 && student.re == -1) break;
		sum = student.middle + student.end;
		if (student.middle == -1 || student.end == -1) cout << "F" << endl;
		else if (sum >= 80) cout << "A" << endl;
		else if (sum < 80 && sum >= 65) cout << "B" << endl;
		else if (sum < 65 && sum >= 50) cout << "C" << endl;
		else if (sum < 50 && sum >= 30 && student.re < 50) cout << "D" << endl;
		else if (sum < 50 && sum >= 30 && student.re >= 50) cout << "C" << endl;
		else if (sum < 30) cout << "F" << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    cout << (char)(s[0] + 1) << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N;
    cin >> N;
    map<ll, ll> mp1, mp2;
    ll ans = 0;
    REP(i,N){
        ll A;
        cin >> A;
        ans += mp1[i-A];
        ans += mp2[i+A];
        mp1[i+A]++;
        mp2[i-A]++;
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 48956
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i = 0; i < N; i++){
    cin >> s.at(i);
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  cout << s.size();
}

Measured memory_bytes: 9580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;



int main(){
    ll N, M; cin >> N >> M;
    ll ACtime = (N-M)*100;
    ll WAtime = (M)*1900;
    ll grosstime = ACtime + WAtime;
    double prob = pow(0.5, (double)M);
    cout << (ll) ((double)grosstime / prob) << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

b=[0]*n

for i in range(n-1,-1,-1):
    if sum(b[i:n:i+1]) %2 ^ a[i]:
        b[i] = 1 


print(sum(b))
print(" ".join([str(k+1)  for k,v in enumerate(b)  if v== 1]))

Measured memory_bytes: 14744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	vector<string> g(h),ans;
	rep(i,h){
		bool flag=true;
		cin>>g[i];
		rep(j,w){
			if(g[i][j]!='.'){
				flag=false;
			}
		}
		if(flag){
			rep(j,w) g[i][j]='_';
		}
	}
	rep(j,w){
		bool flag=true;
		rep(i,h){
			if(g[i][j]=='_') continue;
			if(g[i][j]!='.'){
				flag=false;
			}
		}
		if(flag){
			rep(i,h) g[i][j]='_';
		}
	}
	rep(i,h){
		string now="";
		rep(j,w){
			if(g[i][j]!='_') now+=g[i][j];
		}
		if(now.size()) ans.push_back(now);
	}
	rep(i,ans.size()){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 256
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main{
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;
		//PrintStream out = new PrintStream("src/output.txt");

		//System.setOut(out);

		sc = new Scanner(in);

		String S = sc.next();
		boolean answer = false;

		for(int i = 0; i < S.length() - 1; i++){
			if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C'){
				answer = true;
				break;
			}
		}

		if(answer){
		System.out.println("Yes");
		}else{
			System.out.println("No");
		}

		//out.close();
	}
}

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

using namespace std;

int main(){
 string t;
  cin >> t;
  
  bool n=false,s=false,e=false,w=false;
  
  for(int i=0;i<t.length();i++){
   if(t[i]=='N') n=true;
   else if(t[i]=='S') s=true;
   else if(t[i]=='E') e=true;
    else w=true;
  }
  
  if(((n&&s)||(!n&&!s))&&((e&&w)||(!e&&!w))) cout << "Yes" << endl;
  else cout << "No" << endl;
    
  

}

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

int main(){
	

	int t = 1;
	//cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		int x = ceil((float)(a * 100) / 8);
		/*int y = floor(x * 0.1);
		if(y == b){
			cout << x;
		}
		else{
			cout << "-1";
		}*/
		int p, q;

		for(int i = x; ;++i){
			p = floor(i * 0.08);
			q = floor(i * 0.1);
			if(p != a){
				cout << "-1";
				return 0;
			}
			if(p == a && q == b){
				cout << i;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
H, W = map(int, input().split())

if H*W %3 ==0:
    print(0)
    exit()

diff_list = [W,H]

#縦→横
split1 = [W//3, W//3 + 1]
split2 = [H//2, H//2 +1]

for w in split1:
    for h in split2:
        temp = [H*w, h*(W-w), (H-h)*(W-w)]
        diff_list.append(abs(max(temp)-min(temp)))

#横→縦
if H != W:
    split1 = [H//3, H//3 + 1]
    split2 = [W//2, W//2 + 1]

    for h in split1:
        for w in split2:
            temp = [h*W, (H-h)*w, (H-h)*(W-w)]
            diff_list.append(abs(max(temp)-min(temp)))

# print(diff_list)
print(min(diff_list))


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]) {
		Scanner kb = new Scanner(System.in);
		
		int numitems = kb.nextInt(), maxw = kb.nextInt();
		int[] v = new int[numitems];
		int[] w = new int[numitems];
		
		for(int i = 0; i < numitems; i++) {
			w[i] = kb.nextInt();
			v[i] = kb.nextInt();
		}
		System.out.println(knapsack(maxw, v, w));
	}
	static long knapsack(int maxw, int[] v, int[] w) {
		long[][] cache = new long[w.length+1][maxw+1];
		
		for(int i = 1; i<= w.length; i++) {
			for(int x = 1; x <= maxw; x++) {
				if(w[i-1] > x) {
					cache[i][x] = cache[i-1][x];
				}else {
					cache[i][x] = Math.max(cache[i-1][x], cache[i-1][x-w[i-1]] + v[i-1]);
				}
			}
		}
		return cache[v.length][maxw];
		
	}
}


Measured memory_bytes: 127572
package main

import (
	"fmt"
)

func main() {
	var y, m, d int
	r := "TBD"
	fmt.Scanf("%d/%d/%d", &y, &m, &d)
	if y < 2019 {
		r = "Heisei"
	} else if y == 2019 {
		if m < 5 {
			r = "Heisei"
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 512