akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vi a,b;
    REP(i,n){
        REP(j,i){
            if((n%2==0&&i+j==n-1)||(n%2==1&&i+j==n-2)){
                continue;
            }else{
                a.pb(i+1);
                b.pb(j+1);
            }
        }
    }
    cout<<a.size()<<endl;
    REP(i,a.size()){
        cout<<a[i]<<" "<<b[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ans = 1;
    int m;
    for (int i = 0; i < n; i++)
    {
        int arr;
        cin >> arr;
        if (i == 0) m = arr;
        else
        {
            if (m > arr)
            {
                m = arr;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
grid = [[0]*w for _ in range(h)]
cur = [0,0]
for i in range(n):
    color = str(i+1)
    remain = a[i]
    while remain > 0:
        remain -= 1
        grid[cur[0]][cur[1]] = color
        if cur[0] % 2 == 0:
            if cur[1] == w-1:
                cur[0] += 1
            else:
                cur[1] += 1
        else:
            if cur[1] == 0:
                cur[0] += 1
            else:
                cur[1] -= 1
for i in range(h):
    print(" ".join(grid[i]))

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF  = 1<<30;


struct item {
  int v, w;
  bool operator<(const item &r) const { return w < r.w; }
  void operator+=(const item &r) { w += r.w, v += r.v; }
};


vector<item> enum_powerset(const vector<item> &is) {
  vector<item> a = {{0, 0}};
  vector<item> c;
  c.reserve(1<<sz(is));
  for (auto &i : is) {
    auto b = a;
    for (auto &e : b) e += i;
    merge(all(a), all(b), back_inserter(c));
    swap(a, c);
    c.clear();
  }
  return a;
}


int solve(const vector<item> &a, const vector<item> &b, int W) {
  int ans = 0;
  int vbmax = -INF;
  auto itr = b.begin();
  for (auto &[va, wa] : a) {
    while (itr != b.end() && wa + itr->w <= W) {
      chmax(vbmax, itr->v);
      ++itr;
    }
    chmax(ans, va + vbmax);
  }
  return ans;
}


int main() {
  int n; cin >> n;
  vector<item> is(n);
  for (auto &[v, w] : is) cin >> v >> w;
  is.insert(is.begin(), {0, 0});

  const int m = 11;
  int M = 1<<m;
  chmin(M, n+1);
  vector<vector<item>> pre(M);
  pre[0] = {{0, 0}};
  rep2(i, 1, M) {
    auto a = pre[i/2];
    for (auto &e : a) e += is[i];
    merge(all(pre[i/2]), all(a), back_inserter(pre[i]));
  }
  rep(i, M) reverse(all(pre[i]));

  int q; cin >> q;
  rep(_, q) {
    int v, l; cin >> v >> l;
    vector<item> qi;
    while (v >= M) {
      qi.push_back(is[v]);
      v /= 2;
    }
    cout << solve(pre[v], enum_powerset(qi), l) << '\n';
  }
}


Measured memory_bytes: 27324
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	ss <- replicateM n getLine
	let
		inner = sum $ map countInner ss
		a = length $ filter ( uncurry (&&) . ( not . checkHead &&& checkLast ) ) ss
		b = length $ filter ( uncurry (&&) . ( checkHead &&& not . checkLast ) ) ss
		ba = length $ filter ( uncurry (&&) . ( checkHead &&& checkLast ) ) ss
	print $ inner + if
		| 0 < a && 0 < b -> 1 + ba + min a b - 1
		| a == 0 && b == 0 -> max 0 $ ba - 1
		| otherwise -> ba

countInner [_] = 0
countInner (a:b:s)
	| a == 'A' && b == 'B' = 1 + countInner (b:s)
	| otherwise = countInner (b:s)

checkHead = ( == 'B' ) . head
checkLast = ( == 'A' ) . last

Measured memory_bytes: 5500
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] c = new int[n - 1];
		int[] s = new int[n - 1];
		int[] f = new int[n - 1];
		for(int i = 0 ; i < n - 1 ; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			int time = 0;
			for(int j = i ; j < n - 1 ; j++) {
				if(time < s[j]) time = s[j];
				else if(time % f[j] == 0);
				else time = time + f[j] - time % f[j];
				time += c[j];
			}
			System.out.println(time);
		}
	}
}


Measured memory_bytes: 26596
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int N=100000+10;
long long a[N];
struct Q{
    long long val;
    int id, num;
    bool operator < (const struct Q&a)const{return val>a.val;};
};
priority_queue<Q>que;
Q tmp;
int main ()
{
    int n, ans;
    long long x;
    scanf("%d",&n);
    ans=n;
    for (int i=1; i<=n; ++i) {scanf("%lld",&x); tmp.val=x; tmp.id=i; tmp.num=1; que.push(tmp);}
    while (!que.empty()) {
        Q tmp1=que.top(); que.pop();
        if (que.empty()) break;
        Q tmp2=que.top(); que.pop();
        if (tmp1.val*2<tmp2.val) ans-=tmp1.num;
        else tmp2.num+=tmp1.num;
        tmp2.val+=tmp1.val;
        que.push(tmp2);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2420
import copy
N = input()
A = []
for val in map(int, input().split()):
    A.append(int(val))

# qwer = copy.deepcopy(A)
def asd(index):
    x = A[index]
    y = A[index+1]
    inheight = 0
    # print('A', A)
    # print(index, x, y)
    if( x > y) :
        # print('height',  x - y)
        inheight +=  x - y
        A[index+1] += inheight
    return inheight

height = 0
for index in range(len(A) - 1):
    # print(index)
    height += asd(index)
print(height)


    




Measured memory_bytes: 33296
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<vector<int> > g(n);
    for (int i = 0; i < m; ++i) {
        int v, u;
        cin >> v >> u;
        --v, --u;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        int flag = 0;
        for (auto j : g[i]) {
            if (h[i] <= h[j]) {
                flag = 1;
            }
        }
        if (flag == 0) {
            ++res;
        }
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 8792
n = gets.to_i
array = gets.split.map(&:to_i)

def choose2(n)
  n * (n-1) / 2
end

hash = {}
array.each do |e|
  if hash[e]
    hash[e] += 1
  else
    hash[e] = 1
  end
end

sum = 0
hash.each do |key, value|
  sum += choose2(value)
end

n.times do |index|
  hide = array[index]
  puts sum - (choose2(hash[hide]) - choose2(hash[hide] - 1))
end


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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

string s;

main() {
    cin >> s;
    otp(s[0])otp(s.size()-2)ct(s[s.size()-1])
}

Measured memory_bytes: 256
from heapq import heapify, heappushpop

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

former = aa[:n]
latter = [-a for a in aa[2 * n:]]
fs = sum(former)
ls = sum(latter)
heapify(former)
heapify(latter)

results = [0] * (n + 1)
results[0] = fs
results[-1] = ls

for i in range(n, 2 * n):
    a = aa[i]
    k = heappushpop(former, a)
    fs += a - k
    results[i - n + 1] += fs

for i in range(2 * n - 1, n - 1, -1):
    a = -aa[i]
    k = heappushpop(latter, a)
    ls += a - k
    results[i - n] += ls

print(max(results))


Measured memory_bytes: 38288
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int[][] abc = new int[N][3];   //a,b,cとわけるより後の処理が楽
        for(int i=0;i<N;i++){
            for(int j=0;j<3;j++){
                abc[i][j] = sc.nextInt();
            }
        }
        int[][] happiness = new int[N][3];
        for(int j=0;j<3;j++){
            happiness[0][j] = abc[0][j];    //後のforループの中に書くことももちろんできるがifをi回踏むのが感覚的に嫌なので。
        }
        for(int i=1;i<N;i++){
            for(int j=0;j<3;j++){
                happiness[i][j] = abc[i][j] + Math.max(happiness[i-1][(j+1)%3], happiness[i-1][(j+2)%3]);
            }
        }

        System.out.println(Math.max(Math.max(happiness[N-1][0], happiness[N-1][1]), happiness[N-1][2]));
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int d, A;
  vector<int> s(n + 1, 0);
  s.at(0) = 1;
  
  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> A;
      
      s.at(A)++;
    }
  }
  int count = 0;
  for (int i = 0; i < n + 1; i++) {
    if (s.at(i) == 0) {
      count++;
    }
  }
  cout << count << endl;
  
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    long A = Long.parseLong(scanner.next());
	    long B = Long.parseLong(scanner.next());

	    if (B<A) {
	    	A=A^B;
	    	B=A^B;
	    	A=A^B;
	    }
	    long r = 0;
	    long a=A;
	    long b=B;
	    while(true) {
	        long y = b%a;
	        if (y == 0) {
	        	r = a;
	        	break;
	        } else {
	        	b = a;
	        	a = y;
	        }
	    }


        System.out.print(A*B/r);
	}

}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  
  int L = to_string(N).length();
  int ans = 0;
  set<int> s = {0};
  for (int i = 0; i < L; i++) {
    set<int> tmp;
    for (auto x : s) {
      for (auto num : {3, 5, 7}) {
        if (x * 10 + num > N) continue;
        tmp.insert(x * 10 + num);
        string nxt = to_string(x * 10 + num);

        if (nxt.find('3') == string::npos) continue;
        if (nxt.find('5') == string::npos) continue;
        if (nxt.find('7') == string::npos) continue;
        ++ans;
      }
    }
    s = tmp;
  }

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


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

int main()
{
    int n,i,m=0;
    cin>>n;
    int a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]!=i)
            m++;
    }
    if(m==2 || m==0)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    return 0;
}


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

int main() {
    std::string s;

    std::cin >> s;

    int moji_cnt_s1 = 0;
    int moji_cnt_s2 = 0;

    std::string tmp_s1;
    std::string tmp_s2;
    for ( int i = 0; i < 4; i++ ) {
        if ( moji_cnt_s1 == 0 ) {
            tmp_s1 = s.substr(i, 1);
            moji_cnt_s1++;
        }
        else if ( tmp_s1 == s.substr(i, 1) ) {
            moji_cnt_s1++;
        }
        else if ( moji_cnt_s2 == 0 ) {
            tmp_s2 = s.substr(i, 1);
            moji_cnt_s2++;
        }
        else if ( tmp_s2 != s.substr(i, 1) ) {
            cout << "No" << endl;
            return 0;
        }
        else {
            moji_cnt_s2++;
        }
    }

    if ( moji_cnt_s1 == 2 & moji_cnt_s2 == 2 ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


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

struct dice
{
	int s[6], b;
	void roll(char c)
	{
		if (c == 'W')
		{
			b = s[0];
			s[0] = s[2];
			s[2] = s[5];
			s[5] = s[3];
			s[3] = b;
		}
		if (c == 'E')
		{
			b = s[0];
			s[0] = s[3];
			s[3] = s[5];
			s[5] = s[2];
			s[2] = b;
		}
		if (c == 'S')
		{
			b = s[0];
			s[0] = s[4];
			s[4] = s[5];
			s[5] = s[1];
			s[1] = b;

		}
		if (c == 'N')
		{
			b = s[0];
			s[0] = s[1];
			s[1] = s[5];
			s[5] = s[4];
			s[4] = b;
		}
		if (c == 'R')
		{
			b = s[1];
			s[1] = s[2];
			s[2] = s[4];
			s[4] = s[3];
			s[3] = b;
		}
	}
	int top()
	{
		return s[0];
	}
	int left()
	{
		return s[3];
	}
	int right()
	{
		return s[2];
	}
	int front()
	{
		return s[1];
	}
};

bool same(int a[],int b[])
{
	for (int i = 0; i < 6; i++)
		if (a[i] != b[i])return false;
	return true;
}

bool boss( dice d,dice ano )
{
	int i, j;
	for (i = 0; i < 4; i++)
	{
		ano.roll('R');
		for (j = 0; j < 4; j++)
		{
			ano.roll('N');
			if (same(d.s, ano.s))return  true;
		}
	}
	ano.roll('E');
	for (j = 0; j < 4; j++)
	{
		ano.roll('N');
		if (same(d.s, ano.s))return  true;
	}
	ano.roll('W');
	ano.roll('W');
	for (j = 0; j < 4; j++)
	{
		ano.roll('N');
		if (same(d.s, ano.s))return  true;
	}
	return false;
}

int main()
{
	dice d[100];
	int i, j, n;
	cin >> n;
	for(j=0;j<n;j++)
	{
		for (int i = 0; i < 6; i++)
		{
			cin >> d[j].s[i];
		}
	}

	bool sam = true;

	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++)
			if (boss(d[i], d[j]))sam = false;
	cout << (sam ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 3108
from collections import deque
def MAIN():
    n = int(input())
    li = [[] for _ in range(n + 1)]
    ans = [[i, -1] for i in range(n + 1)]
    ans[1][1] = 0
    for _ in range(n):
        u, k, *v = map(int, input().split())
        li[u] = v
    dp = deque([1])
    while dp:
        u = dp.popleft()
        for v in li[u]:
            if ans[v][1] == -1:
                ans[v][1] = ans[u][1] + 1
                dp.append(v)
    for d in ans[1:]:
        print(*d)
MAIN()



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

#include <math.h>
#include <stdlib.h>


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

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    string S; cin >> S;

    int cnt = 0;
    for(int i = 1; i < N; i++){
        if(S[i] == 'E') cnt++;
    }
    int ans = cnt;
    for(int i = 1; i < N; i++){
        if(S[i] == 'E') cnt--;
        if(S[i-1] == 'W') cnt++;

        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 720
N,K=map(int,input().split())
if N==0 or K==1:
    print(0)
else:
    a=N//K
    N=N-a*K
    for i in range(10**18):
        if N>abs(N-K):
            N=abs(N-K)
        else:
            print(N)  
            break

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int a,r,b,w,g;
	a = 0;
	
	scanf("%d" "%d" "%d" "%d",&r, &b, &w, &g);
	
	
	a = r + b + w + g;
	
	printf("%d\n",a);
	
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        string s;
        cin>>s;
        ll f=(s[0]-'0')*10+(s[1]-'0');
        ll n=(s[2]-'0')*10+(s[3]-'0');
        if(n<=12&&n>0){
            if(f>12||f<1)cout<<"YYMM"<<endl;
            else cout<<"AMBIGUOUS"<<endl;
        }else if(f<=12&&f>0){
            if(n>12||n<1)cout<<"MMYY"<<endl;
            else cout<<"AMBIGUOUS"<<endl;
        }else{
            cout<<"NA"<<endl;
        }
    }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

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

    if(a>b) cout << "a > b" << endl;
    else if (a<b) cout << "a < b" << endl;
    else cout << "a == b" << endl; 

    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	String b = sc.nextLine();
	System.out.println(check(b));
  }
  
  static String check(String b) {
    		switch(b) {
        case "A":
          return "T";
        case "T":
          return "A";
        case "G":
          return "C";
        case "C":
          return "G";
              default:
                break;
        }
    return null;
  }
  
}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<set>
using namespace std;
int main (){

	int n,m,stu[100];//student;
	cin >> n >> m;

	for(int i=0; i<n; i++){//左からi+1番目
		int u;
		cin >> u;
		stu[i] = u;
	}

	for(int i=1; i<=m; i++){
		for(int t = 0; t<n-1; t++){
			if(stu[t]%i > stu[t+1]%i){
				swap(stu[t],stu[t+1]);
			}
		}
	}

	for(int i=0; i<n; i++){
	cout << stu[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int, int>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
struct LazySegmentTree {
private:
	int n;
	vector<int> node, lazy;
	vector<bool> lazyFlag;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, INT_MAX);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			node[k] = lazy[k];
			if (r - l > 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return INT_MAX;
		if (a <= l && r <= b) return node[k];
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};
long long mod = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);
	int n, m;
	cin >> n >> m;
	long long dp[100004] = { 0 };
	int tmp;
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		dp[tmp] = -1;
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		if (dp[i] == -1)continue;
		if (i - 1 >= 0 && dp[i - 1] != -1) {
			dp[i] += dp[i - 1];
		}
		if (i - 2 >= 0 && dp[i - 2] != -1)dp[i] += dp[i - 2];
		dp[i] %= mod;
	}
	cout << dp[n];
}

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

int main() {
    int k; cin >> k;
    int sum = 0;
    rep(i, k) {
        rep(j, k) {
            rep(l, k) {
                sum += __gcd(__gcd(i, j), l);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3592
// abc047c
using System;

class program
{
	static void Main(String[] args)
	{
        int sp = 0;
        string input = Console.ReadLine();
        input += '\t';

        char bc = input[0];

        for(int n = 1; input[n] != '\t'; n++)
        {
            char cc = input[n];
            if(cc != bc)
            {
                bc = cc;
                sp += 1;
            }
        }

        Console.WriteLine(sp);

	}
}


Measured memory_bytes: 3288
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

bar = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
bar2num = Hash.new(0)
A.each do |n|
  b = bar[n]
  bar2num[b] = n if n > bar2num[b]
end

B = bar2num.keys.sort.reverse
B.delete(7) if B.include?(2) && B.include?(5)
B.delete(7) if B.include?(3) && B.include?(4)
B.delete(6) if B.include?(2) || B.include?(3)
B.delete(5) if B.include?(2) && B.include?(3)
B.delete(4) if B.include?(2) 
minbar = B.min
B.delete(minbar)
C = B.sort_by{|b| -bar2num[b]}.select{|b| bar2num[b] > bar2num[minbar]}

def calc(r)
  ans = []
  C.each do |b|
    if r >= b
      ans << b
      r -= b
      redo
    end
  end 
  B.each do |b|
    if r >= b   
      ans << b   
      r -= b   
      redo
    end 
  end
  r == 0 ? ans : false
end

midn = bar2num[minbar]
q, r = N.divmod minbar
10.times do 
  tmp = calc(r)
  if tmp 
    x, y = tmp.map{|b| bar2num[b]}.sort.reverse.partition{|n| n > midn}
    puts (x + Array.new(q, midn) + y).join
    break 
  end 
  q -= 1
  r += minbar 
end 


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

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    int t;
    for (int i=0;i<n;++i) {
        cin >> t;
        v.push_back(t);
    }
    int m;
    cin >> m;
    vector<pair<int, int>> d;
    int p,x;
    for (int j=0;j<m;++j) {
        cin >> p >> x;
        d.push_back(make_pair(p,x));
    }
        for (int l=0;l<(int)d.size();++l) {
            vector<int> v_tmp = v;
            v_tmp.at(d.at(l).first - 1) = d.at(l).second;
            cout << accumulate(v_tmp.begin(), v_tmp.end(),0) << endl;
            }
    
}


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

using namespace std;
typedef long long ll;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> sc(m);
    rep(i, m) cin >> sc[i].first >> sc[i].second;

    rep(i, 1000)
    {
        int keta = 1;
        int ni = i / 10;
        vector<int> d(1, i % 10);
        while (ni)
        {
            keta++;
            d.push_back(ni % 10);
            ni /= 10;
        }
        reverse(all(d));
        if (keta != n)
            continue;

        bool flag = true;

        rep(j, m)
        {
            if (d[sc[j].first - 1] != sc[j].second)
            {
                flag = false;
            }
        }

        if (flag)
        {
            cout << i << '\n';
            return 0;
        }
    }

    cout << -1 << '\n';
    return (0);
}


Measured memory_bytes: 3632
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char[] split=sc.next().toCharArray();
    
    int n=split.length;
  	long sum=0;
    for(int i=0;i<(1<<n-1);i++){
    	StringBuffer sb=new StringBuffer();
      for(int j=0;j<n;j++){
      	sb.append(split[j]);
        if((1&i>>j)==1){
        	sb.append("+");
        }
        
      }
    	String[] snum=sb.toString().split("\\+");
      for(int k=0;k<snum.length;k++){
      	sum+=Long.parseLong(snum[k]);
      }
    }
    System.out.println(sum);
  }
}


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

int main()
{
	string S;
	int cnt[256] = {};
	cin >> S;
	cnt[S[0]]++;
	cnt[S[1]]++;
	cnt[S[2]]++;
	if ( cnt['a'] > 0 && cnt['b'] > 0 && cnt['c'] > 0 ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return ( 0 );
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll arr[n][3];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<3;j++){
            cin >> arr[i][j];
        }
    }
    for(ll i=1;i<n;i++){
        for(int j=0;j<3;j++){
            arr[i][j] += max(arr[i-1][(j+1)%3],arr[i-1][(j+2)%3]);
        }
    }
    ll maxi=0;
    for(ll i=0;i<3;i++){
        maxi = max(maxi,arr[n-1][i]);
    }
    cout << maxi;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define part cout<<"------------------\n";
#define debug(x) cout<<#x<<" : "<<x<<endl;

inline LL f(LL n)
{

    return (n*(n+1))/2;
}

int main()
{
    LL n,i,j,k,t,stemp;
    cin>>n>>k;
    LL cnt=0;
    for(i=k;i<=n+1;i++)
    {
        LL add=f(n)-f(n-i)-f(i-1)+1;
       // debug(i);
        //debug(add);
       // part;
        cnt+=add;
        cnt%=(LL)(1e9+7);
    }
    cout<<cnt<<endl;



}

Measured memory_bytes: 3652
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
using namespace std;
typedef complex<double> Point;

int n;
int lx, ly, rx, ry;

double area(vector<Point> poly) {
	double ret = 0;
	for (int i = 0; i < n; i++) {
		int ni = (i + 1) % n;
		ret += poly[i].real() * poly[ni].imag() - poly[ni].real() * poly[i].imag();
	}
	ret /= 2;
	return ret;
}

int main() {
	int i;
	
	while (cin >> n) {
		if (n == 0) break;
		
		vector<Point> poly;
		for (i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			poly.push_back(Point((double)x, (double)y));
		}
		
		lx = ly = 50000;
		rx = ry = -50000;
		for (i = 0; i < 4; i++) {
			int x, y;
			cin >> x >> y;
			lx = min(lx, x);
			ly = min(ly, y);
			rx = max(rx, x);
			ry = max(ry, y);
		}
		
		vector<Point> poly2;
		for (i = 0; i < n; i++) {
			double x, y;
			x = min((double)rx, max((double)lx, poly[i].real()));
			y = min((double)ry, max((double)ly, poly[i].imag()));
			poly2.push_back(Point(x, y));
		}
		
		cout << (int)(area(poly) - area(poly2)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    int n , m;
    cin >> n;
    int t[n] , x = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> t[i];
        x += t[i];
    }
    cin >> m;
    int p[m] , b[m];
    for ( int i = 0 ; i < m ; i++ ) {
        cin >> p[i] >> b[i];
        cout << x + ( b[i] - t[p[i] - 1] ) << endl;
    }
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
int A, B, C;
cin >> A >> B >> C;

int ans = B / A;
if(C < ans) print(C);
else print(ans);

}


Measured memory_bytes: 256
def main():
    from math import hypot
    import sys
    input = sys.stdin.readline

    inf = 1 << 60

    xs, ys, xt, yt = map(int, input().split())
    N = int(input())
    N += 2

    def dist(p1, p2):
        d = hypot(p1[0] - p2[0], p1[1] - p2[1])
        return max(0, d - (p1[2] + p2[2]))

    s = (xs, ys, 0, 0)
    g = (xt, yt, 0, N - 1)
    ps = [s, g]  # x,y,r,idx
    adj = [[inf] * N for _ in range(N)]
    adj[0][N - 1] = adj[N - 1][0] = dist(s, g)
    for idx1 in range(1, N - 1):
        *p1, = map(int, input().split())  # x,y,r
        p1.append(idx1)
        for *p2, idx2 in ps:
            d = dist(p1, p2)
            adj[idx1][idx2] = adj[idx2][idx1] = d
        ps.append(p1)

    def dijkstra(s):
        from heapq import heappop, heappush

        dist = [inf] * N

        h = [(0, s)]  # c,v
        dist[s] = 0

        while h:
            c, v = heappop(h)
            if dist[v] < c: continue

            for u, dc in enumerate(adj[v]):
                nc = c + dc
                if dist[u] <= nc: continue
                dist[u] = nc
                heappush(h, (nc, u))

        return dist

    print(dijkstra(s=0)[N - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 55496
# -*- coding: utf-8 -*-
# C

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)

X = int(input())


def is_prime(n: int) -> bool:
    """
    素数判定
    >>> p = Mint()
    >>> p.is_prime(2)
    True
    >>> p.is_prime(43)
    True
    >>> p.is_prime(4)
    False
    """

    if n == 1:
        return False
    if n == 2:
        return True

    for i in range(2, n):
        if n % i == 0:
            return False
        if i * i > n:
            return True


def enumerate_prime(n: int) -> (list, dict, list):
    """
    n以下の素数を列挙する
    何で割るかを記録しておくことで、素因数分解が高速にできる
    >>> p = Mint()
    >>> p.enumerate_prime(11)
    ([2, 3, 5, 7, 11], {2: 0, 3: 1, 5: 2, 7: 3, 11: 4}, [0, 1, 2, 3, 2, 5, 3, 7, 2, 3, 5, 11])
    """

    lis_prime = [True] * (n + 1)
    lis_prime[0] = False
    lis_prime[1] = False

    primes = []
    div_prime = [i for i in range(n + 1)]
    primes_idx = {}

    cnt = 0
    for i in range(2, n + 1):
        if lis_prime[i]:
            primes.append(i)
            primes_idx[i] = cnt
            cnt += 1

            j = 2 * i
            while True:
                if j > n:
                    break
                lis_prime[j] = False
                div_prime[j] = i
                j += i

    return primes, primes_idx, div_prime


while True:
    if is_prime(X):
        print(X)
        sys.exit()
    X += 1

Measured memory_bytes: 38512
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Point> a = new ArrayList<>();
        List<Point> c = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            a.add(new Point(sc.nextInt(), sc.nextInt()));
        }

        for (int i = 0; i < n; i++) {
            c.add(new Point(sc.nextInt(), sc.nextInt()));
        }
        a.sort(Comparator.comparingInt(d -> -((Point)d).y).thenComparing(d -> ((Point)d).x));
        c.sort(Comparator.comparingInt(d -> ((Point)d).x).thenComparing(d -> ((Point)d).y));

        int sum = 0;
        for (int i = 0; i < c.size(); i++) {
            Point r = c.get(i);
            Point l = null;
            for(int j = 0;j < a.size();j++) {
                Point tmp = a.get(j);
                if( tmp.x < r.x && tmp.y < r.y) {
                    l = tmp;
                    a.remove(l);
                    break;
                }
            }
            if(l != null) {
                sum++;
            }
        }
        System.out.println(sum);
    }

    static class Point{
        int x;
        int y;
        Point(int x, int y) {
            this.y = y;
            this.x = x;
        }
    }
}


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

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< vector< int > > adjMatrix (n, vector< int > (n, 0));
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int holder;
      cin >> holder;
      adjMatrix[u-1][holder-1] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << adjMatrix[i][j];
      if (j == n-1)
	cout << endl;
      else
	cout << ' ';
    }
  }
  return 0;
}



Measured memory_bytes: 3176
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;


//---------------------------------------------------------------
template<int MOD> struct ModInt { int x;
    explicit operator bool() const { return !!x; }
    ModInt(int v = 0) : x(v % MOD) { if (x < 0) x += MOD; }
    ModInt(long long v) : x(v % MOD) { if (x < 0) x += MOD; }
    ModInt &operator+=(const ModInt &r) { if ((x += r.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt &r) { if ((x += MOD - r.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(const ModInt &r) { x = 1LL * x * r.x % MOD; return *this; }
    ModInt &operator/=(const ModInt &r) { return *this *= r.inverse(); }
    ModInt operator-() const { return x ? ModInt(MOD - x) : ModInt(x); }
    ModInt operator+(const ModInt &r) const { return ModInt(*this) += r; }
    ModInt operator-(const ModInt &r) const { return ModInt(*this) -= r; }
    ModInt operator*(const ModInt &r) const { return ModInt(*this) *= r; }
    ModInt operator/(const ModInt &r) const { return ModInt(*this) /= r; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u); } // x.pow(MOD-2)
    ModInt pow(long long k) const { ModInt r(1), a(x);
        while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
    bool operator==(const ModInt r) const { return x == r.x; }
    bool operator!=(const ModInt r) const { return x != r.x; }
    bool operator< (const ModInt r) const { return x <  r.x; }
    friend ostream& operator<<(ostream &os, const ModInt<MOD>& a) { return os << a.x; }
    friend istream& operator>>(istream &is, ModInt<MOD>& a) { return is >> a.x; }
};
template<typename T, int SZ> struct Comb { vector<T> _fac, _ifac, _inv;
    Comb() : _fac(SZ + 1), _ifac(SZ + 1), _inv(SZ + 1) {
        _fac[0] = _ifac[SZ] = _inv[0] = 1;
        for (int i = 1; i <= SZ; i++) _fac[i] = _fac[i - 1] * i;
        _ifac[SZ] /= _fac[SZ];
        for (int i = SZ - 1; i >= 0; i--) _ifac[i] = _ifac[i + 1] * (i + 1);
        for (int i = 1; i <= SZ; i++) _inv[i] = _ifac[i] * _fac[i - 1]; }
    T inv(int n) { return n < 0 ? T(0) : _inv[n]; }
    T fac(int n) { return n < 0 ? T(0) : _fac[n]; }
    T ifac(int n) { return n < 0 ? T(0) : _ifac[n]; }
    T P(int a, int b) { return (b < 0 || a < b) ? T(0) : _fac[a] * _ifac[a - b]; }
    T C(int a, int b) { return b < 0 ? T(0) : P(a, b) * _ifac[b]; }
    T H(int n, int k) { if (n < 0 || k < 0) return T(0);
        return k == 0 ? T(0) : C(n + k - 1, k); }
};
typedef ModInt<MOD> mint;
//---------------------------------------------------------------

int main() {
    int n;
    mint k;
    cin >> n >> k;
    cout << k.pow(n) << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int main(){
    int n;
    cin >> n;
    if(n==1) cout << "Hello World" << endl;
    else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}

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

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 55;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S[NMAX];
vec v;

ll ans = {};
int check(int i, int j){
  int ret = 0;
  for (int k = 0; k < 8; ++k)
  {
    int ii = i + di[k];
    int jj = j + dj[k];
    if(ii >= 0 && ii < N && jj >= 0 && jj < M && S[ii][jj] == '#')
      ret++;
  }
  return ret;
}
void solve(){
  // main algorithm
  for (int i = 0; i < N; ++i)
  {
    for (int j = 0; j < M; ++j)
    {
      if(S[i][j] == '.') S[i][j] = static_cast<char>(check(i, j) + '0');
    }
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  for (int i = 0; i < N; ++i)
  {
    printf("%s\n", S[i].c_str());
  }
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M;
  for (int i = 0; i < N; ++i)
  {
    cin >> S[i];
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

typedef struct p{ll x,y,i;}P;
int xsort(const void*a,const void*b){
	//左端が右の方にあるものが先
	P*p=(P*)a,*q=(P*)b;
	if((*p).x>(*q).x)return -1;
	return  1;
}
int ysort(const void*a,const void*b){
	//右端が左の方にあるものが先
	P*p=(P*)a,*q=(P*)b;
	if((*p).y<(*q).y)return -1;
	return  1;
}
int isort(const void*a,const void*b){
	P*p=(P*)a,*q=(P*)b;
	if((*p).i<(*q).i)return -1;
	return  1;
}

P a[100010];
int xx[100010],yy[100010];
int n;
ll f(){
	int flag[100010]={};
	//右始動
	ll tans=0,cr=0,cl=0,cp=0;
	while(1){
		while(cr<n&&flag[xx[cr]])cr++;
		if(cr==n)break;
		if(a[xx[cr]].x<=cp)break;
		tans+=a[xx[cr]].x-cp;
		cp=a[xx[cr]].x;
		flag[xx[cr]]=1;
//		printf("%d %d\n",cp,tans);
		while(cl<n&&flag[yy[cl]])cl++;		
		if(cl==n)break;
		if(a[yy[cl]].y>=cp)break;
		tans+=cp-a[yy[cl]].y;
		cp=a[yy[cl]].y;
		flag[yy[cl]]=1;
//		printf("%d %d\n",cp,tans);
	}
	tans+=llabs(cp);
//	puts("");
	return tans;
}

int main(){
	scanf("%d",&n);
	rep(i,0,n){
		int l,r;
		scanf("%d%d",&l,&r);
		a[i].i=i;
		a[i].x=l;
		a[i].y=r;
	}
	qsort(a,n,sizeof(P),xsort);
	rep(i,0,n)xx[i]=a[i].i;
	qsort(a,n,sizeof(P),ysort);
	rep(i,0,n)yy[i]=a[i].i;
	qsort(a,n,sizeof(P),isort);

    //右始動
	ll ans1=f();
	
    //反転
	rep(i,0,n){
		ll t=a[i].x;
		a[i].x=-a[i].y;
		a[i].y=-t;
	}
	qsort(a,n,sizeof(P),xsort);
	rep(i,0,n)xx[i]=a[i].i;
	qsort(a,n,sizeof(P),ysort);
	rep(i,0,n)yy[i]=a[i].i;
	qsort(a,n,sizeof(P),isort);
	
    //反転して右始動＝左始動
	ll ans2=f();
	printf("%lld",max(ans1,ans2));
}

Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h1,m1,h2,m2,k,ans;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<max(0,(h2-h1)*60+m2-m1-k);
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=(a*n)/b-a*(n/b);
    ll mx=(n/b)*b;

    mx--;
    if(mx>=0&&mx<=n)
        ans=max(ans,(a*mx)/b-a*(mx/b));
    mx+=b;
    if(mx>=0&&mx<=n)
        ans=max(ans,(a*mx)/b-a*(mx/b));
    cout<<ans;

}



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

using namespace std;

int main()
{
    //system("chcp 65001");

    int A,B,C;
    cin >> A >> B >> C;
    if (C - (A - B) >= 0)
    {
        cout << C - (A - B);
    }
    else
    {
        cout << "0";
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, x, y, c;
    String s;
    int[][] map;

    void run(){
	n = sc.nextInt();
	c = 1;
	while(c<=n){
	    System.out.println("Data "+c+":");
	    c++;

	    map = new int[9][9];
	    for(int i=1; i<=8; i++){
		s = sc.next();
		for(int k=1; k<=s.length(); k++)
		    map[i][k] = Integer.parseInt(s.substring(k-1, k));
	    }

	    //show();
	    //System.out.println("--------");

	    x = sc.nextInt();
	    y = sc.nextInt();
	    
	    solve(y, x);
	    show();
	}
    }

    void solve(int y, int x){
	map[y][x] = 0;
	for(int a=x-3; a<=x+3; a++)
	    if(a>=1 && a<=8 && map[y][a]==1)
		solve(y, a);
	for(int b=y-3; b<=y+3; b++)
	    if(b>=1 && b<=8 && map[b][x]==1)
		solve(b, x);
    }

    void show(){
	for(int i=1; i<=8; i++){
	    for(int k=1; k<=8; k++)
		System.out.print(map[i][k]);
	    System.out.println();
	}
    }
}

Measured memory_bytes: 17268
//vector には.find() がなぜかないのでアルゴリズムを使う
 
#include <iostream>
#include <vector>
#include <algorithm>
 
 
using namespace std;
 
int main() {
    int i,j;
    int n,q,C=0;
    int buf;
    vector<int> S, T;
    
    //入力
    cin >> n;
    for(i=0; i<n; i++){ cin >> buf; S.push_back(buf); }
    cin >> q;
    for(i=0; i<q; i++){ cin >> buf; T.push_back(buf); }
    
    //探索
    C=0;
    vector<int>::iterator itr;
    for(i=0; i<q; i++){
        itr = find( S.begin(),S.end() , T.at(i) );
        if( itr != S.end() ) C++;
    }
    
    cout << C << endl;
    
        return 0;
}
 

Measured memory_bytes: 1320
<?php
$S = str_split(trim(fgets(STDIN)));

$list = [];
for ($c = 'a'; strlen($c) < 2; $c++) {
    $list[$c] = 0;
}

foreach ($S as $w) {
    $list[$w]++;
}

foreach ($list as $key => $value) {
    if ($value === 0) {
        echo $key;
        exit();
    }
}

echo 'None';

Measured memory_bytes: 22140
N, K = map(int, input().split())
d = []
A = [[] for _ in range(K)]
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

import itertools
a_flattened = list(itertools.chain.from_iterable(A))
se = set(a_flattened)
print(N - len(se))


Measured memory_bytes: 67564
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n, k;
    cin >> n >> k;
    int l[50];
    for (int i = 0; i < n; i++) cin >> l[i];
    sort(l, l+n, [](int a, int b){return a > b;});
    int ans = 0;
    for (int i = 0; i < k; i++) ans += l[i];
    cout << ans << endl;
}

Measured memory_bytes: 256