akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 200005
int n,ori_a[maxn],a[maxn << 1],b[maxn];
int nxt[maxn],s[maxn << 1],t[maxn],ls,lt;
vector <int> pos; // start
void calc_nxt(){
  nxt[0] = -1;
  int k = -1;
  for(int i = 1;i <= lt;i++){
    while(~k && t[k] != t[i - 1]) k = nxt[k];
    nxt[i] = ++k;
  }
}
void kmp(){
  int j = 0;
  for(int i = 0;i < ls;i++){
    while(~j && (j == lt || t[j] != s[i])) j = nxt[j];
    j++;
    if(j == lt) pos.push_back(i - lt + 1);
  }
}
int main(){
  n = getint();
  for(int i = 0;i < n;i++) ori_a[i] = a[i] = getint();
  for(int i = n;i < n + n;i++) a[i] = a[i - n];
  for(int i = n + n - 1;i >= 1;i--) a[i] ^= a[i - 1];
  for(int i = 0;i < n;i++) b[i] = getint();
  for(int i = n - 1;i >= 1;i--) b[i] ^= b[i - 1];
  for(int i = 1;i < n + n - 1;i++) s[ls++] = a[i];
  for(int i = 1;i < n;i++) t[lt++] = b[i];
  calc_nxt();
  kmp();
  for(int i = 0;i < (int)pos.size();i++){
    int k = pos[i], x = ori_a[k] ^ b[0];
    putint(k,' ');
    putint(x,'\n');
  }
  bufo.flush();
  return 0;
}


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

#define MAX_SIZE 500100

int T[MAX_SIZE];
int H;

void maxHeapify(int i) {
    int left = 2 * i, right = 2 * i + 1;
    int largest = i;
    if (left <= H && T[left] > T[i]) largest = left;
    if (right <= H && T[right] > T[largest]) largest = right;
    if (largest != i) {
        swap(T[largest], T[i]);
        maxHeapify(largest);
    }
    return;
}

void buildMaxHeap() {
    for (int i = H / 2; i >= 1; i--) {
        maxHeapify(i);
    }
    return;
}

void print() {
    for (int i = 1; i <= H; i++) cout << " " << T[i];
    cout << endl;
    return;
}

int main() {
    cin >> H;
    for (int i = 1; i <= H; i++) cin >> T[i];

    buildMaxHeap();

    print();

    return 0;
}


Measured memory_bytes: 4952
import sys
N,M = map(int,input().split())
X = [i for i in map(int,input().split())]
X.sort()
if M == 1 or N>=M:
  print(0)
  sys.exit(0)
res = max(X)-min(X)
Length = []
for i in range(len(X)-1):
  Length.append(X[i+1]-X[i])
Length.sort()
for i in range(N-1):
  res -= Length[len(Length)-1-i]
print(res)

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
const int INF=0x7fffffff;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
const int N=200005;
int n, a[N];
ll tot, b[N];
int main(){
	scanf("%d", &n);
	int i;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
		
	for(i=1;i<=n;i++)
	{
		if(b[i]==2) tot++;
		else if(b[i]>2) tot+=b[i]*(b[i]-1)/2;		
	}
	
	for(i=1;i<=n;i++)
		printf("%lld\n", tot-(b[a[i]]-1));
	return 0;
}

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

using namespace std;

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define MAXN 100

int main(int argc, char const *argv[])
{
	#ifdef DBG
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
	#endif

	long long num,tmp,mmin,ans;

	while( ~scanf("%lld",&num) ){
		int check = 1;
		mmin = INT_MAX;
		ans = 0;
		for(int i = 0 ; i < num ; i++ ){
			scanf("%lld",&tmp);
			if( abs(tmp) < mmin )
				mmin = abs(tmp);
			ans += abs(tmp);
			if( tmp < 0 )
				check *= -1;
		}

		if( check == -1 )
			ans -= (2*mmin);

		printf("%lld\n",ans );

	}


	return 0;
}

Measured memory_bytes: 256
from bisect import bisect
R = 1000000
p = [1]*R
p[0] = p[1] = 0
p[4::2] = [0]*len(p[4::2])
for i in xrange(3,int(R**0.5)+1,2):
    if p[i]:
        p[i*i::i] = [0]*len(p[i*i::i])
prime = [i for i in xrange(2,R) if p[i]]
while True:
    try:print bisect(prime,input())
    except:break

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

int main() {int i,j,h,w,x,y;
cin>>h>>w;
x=h+2;
y=w+2;
char a[x][y];
 for(i=1;i<x-1;i++)
    for (j=1;j<y-1;j++)
    cin>>a[i][j];
    for (i=0;i<x;i++)
    {for (j=0;j<y;j++)
    {if(i==0||i==x-1||j==0 ||j==y-1)
     cout<<'#';
     else 
     cout<<a[i][j];
    }
     printf("\n");
    }
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    
    int n = 0;
    
    int d = 1000;
    for(int i = 0;i < s.size();i++){
        n += (s[i] - '0') * d;
        d /= 10;
    }
    int a = n / 100;
    int b = n % 100;
    
    if(1 <= a && a <= 12){
        if(1 <= b && b <= 12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(1 <= b && b <= 12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <regex>
#include <sstream>
#define LL long long
using namespace std;
template <typename T>
inline void read(T &t)
{
    int f = 0, c = getchar();
    t = 0;
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        t = t * 10 + c - 48, c = getchar();
    if (f)
        t = -t;
}
template <typename T, typename... Args>
inline void read(T &t, Args &... args)
{
    read(t);
    read(args...);
}
int main(){
    string str;
    cin>>str;
    int ans=0,cnt=0;
    for(int i=0;i<str.size();i++){
        if(str[i]=='A' || str[i]=='C' || str[i] =='G' || str[i] == 'T')
            cnt++, ans = max(ans, cnt);
        else
            cnt = 0;
    }
    cout << ans;
}

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

int main() {
	int n; cin >> n;
	vector<int> y(n);
	rep(i, n) cin >> y.at(i);
	int a = 0;
	rep(i, n) {
		if (a < y.at(i)) y.at(i) = y.at(i) - 1;
		else if (y.at(i) < a) {
			cout << "No" << endl;
			return 0;
		}
		a = y.at(i);
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

















class dinic {
private:
    struct edge {
        ll to, cap, rev;
    };
    vector<vector<edge>> list;  // グラフの隣接リスト
    vector<ll> level;    // sからの距離
    vector<ll> iter;     // どこまで調べ終わったか
public:
    dinic(ll n) : list(n), level(n), iter(n){}
    
    void add_edge(ll from, ll to, ll cap){
        list[from].push_back({to, cap, (ll)list[to].size()});
        list[to].push_back({from, 0, (ll)list[from].size() - 1});
    }
    
    void bfs(ll s){
        level.assign(level.size(), -1);
        queue<ll> que;
        level[s] = 0;
        que.push(s);
        while(!que.empty()){
            ll v = que.front(); que.pop();
            for(auto &x : list[v]){
                if(x.cap > 0 && level[x.to] < 0){
                    level[x.to] = level[v] + 1;
                    que.push(x.to);
                }
            }
        }
    }
    
    ll dfs(ll v, ll t, ll f){
        if(v == t) return f;
    
        for(ll &i = iter[v]; i < list[v].size(); i++){
            edge &e = list[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                ll d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    list[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    
    ll max_flow(ll s, ll t){
        ll flow = 0;
    
        for(;;){
            bfs(s);
            if(level[t] < 0) return flow;
            
            iter.assign(iter.size(), 0);
            
            ll f;
            while((f = dfs(s, t, INF)) > 0){
                flow += f;
            }
        }
    }
};



int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> cnt(n);
    dinic dic(n);
    REP(i, m){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        cnt[a]++;
        cnt[b]++;
        dic.add_edge(a, b, 1);
        dic.add_edge(b, a, 1);
    }
    vector<ll> v;
    REP(i, n){
        if(cnt[i] % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    REP(i, n){
        if(cnt[i] >= 6){
            cout << "Yes" << endl;
            return 0;
        }
        if(cnt[i] == 4){
            v.push_back(i);
        }
    }
    if(v.size() >= 3){
        cout << "Yes" << endl;
        return 0;
    }
    if(v.size() <= 1){
        cout << "No" << endl;
        return 0;
    }
    cout << ((dic.max_flow(v[0], v[1]) == 2)? "Yes" : "No") << endl;
}

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

int main(){
  int X, N;
  cin >> X >> N;
  set<int> P;
  int k;
  for(int i=0; i<N; i++){
    cin >> k;
    P.insert(k);
  }
  for(int i=0; i<200; i++){
    if(P.count(X-i)==0){
      cout << X-i << endl;
      goto finish;
    }
    else if(P.count(X+i)==0){
      cout<< X+i << endl;
      goto finish;
    }
  }
finish: X=0;
}

Measured memory_bytes: 3636
from collections import deque

N = int(input())
R = [list(map(int,input().split())) for _ in range(N)]
B = [list(map(int,input().split())) for _ in range(N)]

graph = [[] for _ in range(2*N+2)]

for i in range(N):
    forward = [2+i,1,None]
    forward[2] = backward = [0,0,forward]
    graph[0].append(forward)
    graph[2+i].append(backward)

for i in range(N):
    forward = [1,1,None]
    forward[2] = backward = [2+N+i,0,forward]
    graph[2+N+i].append(forward)
    graph[1].append(backward)

for i in range(N):
    for j in range(N):
        if R[i][0]<B[j][0] and R[i][1]<B[j][1]:
            forward = [2+N+j,1,None]
            forward[2] = backward = [2+i,0,forward]
            graph[2+i].append(forward)
            graph[2+N+j].append(backward)

flow = 0

while True:

    queue = deque([0])
    level = [None for _ in range(2*N+2)]
    level[0] = 0

    while queue:
        node = queue.popleft()
        for adj,adjcap,_ in graph[node]:
            if adjcap>0 and level[adj] is None:
                level[adj] = level[node]+1
                queue.append(adj)

    if level[1] is None:
        break

    stack = [0]
    visited = [0 for _ in range(2*N+2)]
    visited[0] = 1
    parent = [None for _ in range(2*N+2)]
    parent[0] = 0

    while stack:
        node = stack.pop()
        for adj,adjcap,adjrev in graph[node]:
            if not visited[adj] and adjcap>0 and level[node]<level[adj]:
                visited[adj] = 1
                parent[adj] = node
                stack.append(adj)

    if visited[1]:
        flow += 1
        present = 1
        prev = parent[present]
        while present != 0:
            for g in graph[prev]:
                adj,adjcap,adjrev = g
                if adj == present:
                    g[1] = 0
                    adjrev[1] = 1
            present = prev
            prev = parent[present]

print(flow)

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n,k,q;
  cin >>n >>k >>q;
  int a[100100];
  for(int i=0; i<q; i++){
  	cin >> a[i];
  }
  vector<int> b(100100,k-q);
  for(int i=0; i<q; i++){
  	b[a[i]]++;
  }
  for(int i=1; i<=n; i++){
  	if(b[i]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, 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);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  set<string> set;

  rep(i, N){
    string str;
    cin >> str;
    set.insert(str);
  }

  cout << set.size() << endl;


  return 0;
}


Measured memory_bytes: 19204
import math
a, b, x = map(int, input().split())
h = x / (a * a)
if h == b / 2:
    answer = math.atan(a / b)
elif h < b / 2:
    answer = math.atan(2*h*a / (b * b))
else:
    if h == b:
        answer = math.pi / 2
    else:
        answer = math.atan(a / (2 * (b - h)))
print(90 - answer / math.pi * 180)

Measured memory_bytes: 3064
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertion(int A[], int n)
{
  int j, i, v;
  for(i = 2 ; i <= n ; i++)
    {
      v = A[i];
      j = i - 1;
      while(j >= 0 && A[j] > v)
	{
	  A[j + 1] = A[j];
	  j--;
	}
      A[j + 1] = v;
      trace(A, n);
    }
}

int main(){
  int n, i, j;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  /*

    your code

   */
  insertion(A, n);
  return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
    string line;
    while(cin >> line) {
        for(int i = 0; i < line.size(); ++i)
            if(line[i] == ',') line[i] = ' ';
        istringstream is(line);
        int v[5];
        for(int i = 0; i < 5; ++i) is >> v[i];

        sort(v, v+5);
        string ans;
        if(v[1]==v[2] && v[2]==v[3] && (v[0]==v[1]||v[3]==v[4])) ans = "four card";
        else if((v[0]==v[1] && (v[2]==v[3] && v[3]==v[4])) || ((v[0]==v[1] && v[1]==v[2]) && v[3]==v[4])) ans = "full house";
        else if(v[0]+1==v[1] && v[1]+1==v[2] && v[2]+1==v[3] && v[3]+1==v[4]) ans = "straight";
        else if(v[0]==1 && v[1]==10 && v[2]==11 && v[3]==12 && v[4]==13) ans = "straight";
        else if((v[0]==v[1] && v[1]==v[2]) || (v[1]==v[2] && v[2]==v[3]) || (v[2]==v[3] && v[3]==v[4])) ans = "three card";
        else if(unique(v, v+5) - v == 3) ans = "two pair";
        else if(unique(v, v+5) - v == 4) ans = "one pair";
        else ans = "null";

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

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int x, n;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cout << "Case " << i << ':' << endl;
		cin >> x;
		for (int j = 1; j <= 10; j++) {
			x = ((x*x) % 1000000) / 100;
			cout << x << endl;
		}
	}
}

Measured memory_bytes: 1160
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		try (PrintWriter out = new PrintWriter(System.out);) {

			int n = scan.nextInt();
			long[] d = new long[n];

			for (int i = 0; i < n; i++) {
				d[i] = scan.nextLong();
			}

			long ret = 0;
			for (int i = 0; i < n - 1; i++) {
				for (int j = i + 1; j < n; j++) {
					ret += d[i] * d[j];
				}
			}

			out.println(ret);
			out.flush();
		}
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  int k;
  cin >> n >> k;
  vector<int> bs(10);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    bs[d] = 1;
  }

  auto is_valid_fn = [&](int k) -> bool {
    string s = to_string(k);
    for (char c : s) {
      if (bs[c - '0']) return false;
    }
    return true;
  };

  while (true) {
    if (is_valid_fn(n)) break;
    n++;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3 + 10;
int n;
int num[N][N], pos[N][N];
int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        for(int j = 1, x; j < n; j++) {
            cin >> x;
            num[i][j] = x;
            pos[i][x] = i*n+j;
            // printf("pos[%d][%d]:%d\n", i, x, i*n+j);
        }
    }

    set<int> s, s2;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        s2.insert(pos[i][num[i][1]]);
        if(s2.count(pos[num[i][1]][i])) {
            s2.erase(pos[i][num[i][1]]);
            s2.erase(pos[num[i][1]][i]);
            s.insert(pos[i][num[i][1]]);
        }
    }
    // for(int x : s) {
    //     cout << ":" << x << endl;
    // }
    // for(int x : s2) {
    //     cout << ">" << x << endl;
    // }

    while(!s.empty()) {
        set<int> new_s;
        for(int t : s) {
            int x = t/n, y = t%n;
            int t2 = pos[num[x][y]][x];
            y++;
            if(y != n) {
                s2.insert(pos[x][num[x][y]]);
                if(s2.count(pos[num[x][y]][x])) {
                    s2.erase(pos[x][num[x][y]]);
                    s2.erase(pos[num[x][y]][x]);
                    new_s.insert(pos[x][num[x][y]]);
                }
            }
            x = t2/n; y = t2%n;
            y++;
            if(y != n) {
                s2.insert(pos[x][num[x][y]]);
                if(s2.count(pos[num[x][y]][x])) {
                    s2.erase(pos[x][num[x][y]]);
                    s2.erase(pos[num[x][y]][x]);
                    new_s.insert(pos[x][num[x][y]]);
                }
            }
        }
        ans++;
        s = new_s;
    }

    if(s2.size()) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

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

template <int Mod>
class ModInt {
 public:
  ModInt() : n_(0) {}
  ModInt(long long n) : n_(n % Mod) {
    if (n_ < 0) {
      // In C++, (-n)%m == -(n%m).
      n_ += Mod;
    }
  }
  ModInt& operator+=(const ModInt& m) {
    n_ += m.n_;
    if (n_ >= Mod) {
      n_ -= Mod;
    }
    return *this;
  }
  ModInt& operator++() { return (*this) += 1; }
  ModInt& operator-=(const ModInt& m) {
    n_ -= m.n_;
    if (n_ < 0) {
      n_ += Mod;
    }
    return *this;
  }
  ModInt& operator--() { return (*this) -= 1; }
  ModInt& operator*=(const ModInt& m) {
    n_ *= m.n_;
    n_ %= Mod;
    return *this;
  }
  ModInt& operator/=(const ModInt& m) {
    *this *= m.inverse();
    return *this;
  }
#define DEFINE_BINARY_OPERATOR(op) \
  ModInt operator op(const ModInt& m) const { return ModInt(*this) op##= m; }
  DEFINE_BINARY_OPERATOR(+)
  DEFINE_BINARY_OPERATOR(-)
  DEFINE_BINARY_OPERATOR(*)
  DEFINE_BINARY_OPERATOR(/)
#undef DEFINE_BINARY_OPERATOR
#define DEFINE_COMPARISON_OPERATOR(op) \
  bool operator op(const ModInt& m) const { return n_ op m.n_; }
  DEFINE_COMPARISON_OPERATOR(!=)
  DEFINE_COMPARISON_OPERATOR(<)
  DEFINE_COMPARISON_OPERATOR(<=)
  DEFINE_COMPARISON_OPERATOR(==)
  DEFINE_COMPARISON_OPERATOR(>)
  DEFINE_COMPARISON_OPERATOR(>=)
#undef BDEFINE_COMPARISON_OPERATOR
  ModInt pow(int n) const {
    // a * b ^ n = answer.
    ModInt a = 1, b = *this;
    while (n != 0) {
      if (n & 1) {
        a *= b;
      }
      n /= 2;
      b *= b;
    }
    return a;
  }
  ModInt inverse() const {
    // Compute the inverse based on Fermat's little theorem. Note that this only
    // works when n_ and Mod are relatively prime. The theorem says that
    // n_^(Mod-1) = 1 (mod Mod). So we can compute n_^(Mod-2).
    return pow(Mod - 2);
  }
  long long value() const { return n_; }

  static ModInt factorial(int n) {
    for (int i = factorial_.size(); i <= n; ++i) {
      factorial_.push_back(i == 0 ? 1 : factorial_.back() * i);
    }
    return factorial_[n];
  }
  static ModInt combination(int n, int k) {
    ModInt numerator;
    if (n <= 1000000) {
      numerator = factorial(n) / factorial(n - k);
    } else {
      // Sometimes n can be very large while k is still small. In that case,
      // avoid calculating n!. https://atcoder.jp/contests/abc156/tasks/abc156_d
      numerator = 1;
      for (int i = 0; i < k; ++i) {
        numerator *= (n - i);
      }
    }
    return numerator / factorial(k);
  }

 private:
  long long n_;
  static std::vector<ModInt> factorial_;
};

template<int Mod>
std::vector<ModInt<Mod>> ModInt<Mod>::factorial_;

template <int Mod>
std::ostream& operator<<(std::ostream& out, const ModInt<Mod>& m) {
  out << m.value();
  return out;
}

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

using namespace std;

using mint = ModInt<998244353>;

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

  mint cnt = 0;
  for (int k = 0; k <= K; ++k) {
    cnt += mint(M) * mint(M - 1).pow(N - 1 - k) * mint::combination(N - 1, k);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 5344
import java.util.Arrays;
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int[] S = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += (S[i] = sc.nextInt());
		}
		if (sum % 10 != 0){
			System.out.println(sum);
			return;
		}
		Arrays.sort(S);
		for (int s : S) {
			if (s % 10 != 0) {
				System.out.println(sum - s);
				return;
			}
		}
		System.out.println(0);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 24020
/*
* 多边形和圆面积并
* Complier: G++
* Create Time: 8:26 2015/10/1 星期四
*/
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;

const double pi = acos(-1.0);
const double e = exp(1.0);
const double eps = 1e-8;
const int maxn = 1005;
typedef struct point vec;  //向量vec
struct point {    //点的基本数据结构
    double x, y;
    point(double _x=0, double _y=0):
    x(_x),y(_y)
    {
    }
    point operator*(const point& i_T) const
    {
        return point(x * i_T.x, y * i_T.y);
    }
    point operator*(double u) const
    {
        return point(x * u, y * u);
    }
    bool operator==(const point& i_T) const
    {
        return x == i_T.x && y == i_T.y;
    }
    point operator/(double u) const
    {
        return point(x / u, y / u);
    }
    point operator+(const point& i_T)
    {
        return point(x + i_T.x, y + i_T.y);
    }
    point operator-(const point& i_T)
    {
        return point(x - i_T.x, y - i_T.y);
    }
    friend bool operator<(point a, point b)
    {
        return a.y == b.y ? a.x < b.x : a.y < b.y;
    }
    friend ostream& operator<<(ostream& out, point& a)
    {
        //cout << a.x << ' ' << a.y;
        printf("%.8f %.8f", a.x, a.y);
        return out;
    }
    friend istream& operator>>(istream& in, point& a)
    {
        in >> a.x >> a.y;
        return in;
    }
};
typedef struct Line Segment;   //线段Segment
struct Line {       //直线
    vec a, b;
    Line(point _a = point(), point _b = point())
        : a(_a)
        , b(_b)
    {
    }
    friend istream& operator>>(istream& in, Line& a)
    {
        cin >> a.a >> a.b;
        return in;
    }
    friend ostream& operator<<(ostream& out, Line& a)
    {
        out << a.a << ' ' << a.b;
        return out;
    }
};
double dianji(vec A, vec B) //点积
{
    return A.x * B.x + A.y * B.y;
}
int zhengfu(double d)   //判断正负
{
    if (fabs(d) < eps)
        return 0;
    if (d > 0)
        return 1;
    return -1;
}
int bijiao(double x, double y)
{
    if (fabs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}
bool pingxing(vec a,vec b)
{
    return bijiao(a.x*b.y,a.y*b.x)==0;
}
point p[1000];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        Line l1,l2;
        cin>>l1>>l2;
        if (pingxing(l1.b-l1.a,l2.b-l2.a))
            cout << "2" << endl;
        else {
            if (zhengfu(dianji(l1.b-l1.a,l2.b-l2.a))==0)
                cout << "1" << endl;
            else {
                cout << "0" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3248
A = [None]*3
for i in range(3):
  A[i] = map(int, raw_input().split())

N = input()
for _ in range(N):
  b = input()
  for y in range(3):
    for x in range(3):
      if A[y][x]==b:
        A[y][x] = 0

ans = "No"
for y in range(3):
  if A[y]==[0, 0, 0]:
    ans = "Yes"
for x in range(3):
  if [A[y][x] for y in range(3)]==[0, 0, 0]:
    ans = "Yes"
if [A[0][0], A[1][1], A[2][2]]==[0, 0, 0]:
  ans = "Yes"
if [A[2][0], A[1][1], A[0][2]]==[0, 0, 0]:
  ans = "Yes"
print ans


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

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    ll n;
    cin >> n;
    ll arr[n],i;
    for(i=0;i<n;i++)
    cin >> arr[i];
    ll dp[n+1];
    dp[0]=arr[0];
    dp[1]=abs(arr[1]-arr[0]);
    
    if(n==2){
        cout << abs(arr[0]-arr[1]) << endl;
    }
    else{
        dp[2]=min(abs(arr[2]-arr[0]),dp[1]+abs(arr[2]-arr[1]));
        for(i=3;i<n;i++)
        dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
        cout << dp[n-1] << endl;
    }
    //for(i=0;i<n;i++)
    //cout << dp[i] << " ";
    //cout << endl;
    
    
}

Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int value[1000],costs[1000];
	int store[1000],temp=0,store1[1000],temp1;
	int num=0,sum=0;
	cin>>num;
	for(int i=0;i<num;i++)
	{
		cin>>value[i];
	}
	for(int i=0;i<num;i++)
	{
		cin>>costs[i];
	}
	for(int i=0;i<num;i++)
	{
		if(value[i]-costs[i]>0)
		{
			sum+=value[i]-costs[i];
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
typedef long long ll;
ll n;
ll cost[100020][3] ;
ll dp[100020][4] ;
ll recurse(ll idx, ll type) {
  if(idx == n) return  0;
  ll &ans = dp[idx][type];
  if(ans != -1) return ans;
   ans = 0;
  if(type == 0) {
    return ans = max({cost[idx][0] + recurse(idx+1, 1), cost[idx][1] + recurse(idx+1, 2), cost[idx][2] + recurse(idx+1, 3)});
  }
  if(type == 1) {
    return ans = max({cost[idx][1] + recurse(idx+1, 2), cost[idx][2] + recurse(idx+1, 3)});
  }
  if(type == 2) {
    return ans = max({cost[idx][0] + recurse(idx+1, 1), cost[idx][2] + recurse(idx+1, 3)}) ;
  }
  else {
    return ans = max({cost[idx][0] + recurse(idx+1, 1), cost[idx][1] + recurse(idx+1, 2)}) ;
  }
}
int main(){
 IOS

  cin >> n;
  memset(dp, -1, sizeof(dp));
  for(ll i = 0; i < n; i++) {
    for(ll j = 0; j < 3; j++) cin >> cost[i][j];
  }
  ll ans = recurse(0, 0) ;
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}
int n ,k;
vector<int>vec;
int arr[100005];
int forg(int i ){
    if(i>=n) return 1e8;
    if(i==n-1) return 0;
      if(arr[i]!=-1) return arr[i];
      int mn=INT_MAX;
     for(int v=1;v<=k;v++){
          mn=min(mn,forg(i+v)+abs(vec[i]-vec[i+v]));
        //  cout<<v<<" i="<<i<<" ";

      }
        return arr[i]= mn;
 }
int main()
{   init();
    cin>>n>>k;
    vec.resize(n);
    memset(arr,-1,sizeof(arr));
    for(int i=0;i<n;i++)cin>>vec[i];
    cout<<forg(0);
    return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    double a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    double avg = double(accumulate(a, a+n, 0)) / double(n);
    int ans;
    double ans_diff = 1e10;
    for(int i=0;i<n;i++) {
        if(abs(a[i]-avg) < ans_diff) {
            ans = i;
            ans_diff = abs(a[i]-avg);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
/*3.3 hightierra*/
#include <stdio.h>
#include <math.h>
 
int main(void){
    int N,K; //変数の定義
    scanf("%d %d",&N,&K); //入力

    int i = 1; //カウンターを定義

    /*K^(i-1)<=N<K^iのとき、NはK進法でi桁*/
    while(pow((double)K,(double)i)<=N){
      	i++;
    }
    printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

LL dp[51][50*50+1][51];
int A[51];

int main() {
  int n,x;
  S2(n,x);
  rep(i,1,n+1) {
    S(A[i]);
  }

  dp[0][0][0] = 1;
  rep(i,1,n+1) dp[i][0][0] = 1;
  rep(i,1,n+1) {
    rep(j,0,n*x+1) {
      rep(k,1,i+1) {
        dp[i][j][k] = dp[i-1][j][k];
        if(j >= A[i]) {
          dp[i][j][k] += dp[i-1][j-A[i]][k-1];
        }
      }
    }
  }
  LL ans = 0;
  rep(i,1,n+1) {
    ans += dp[n][x*i][i];
    // printf("%d %lld\n",i,dp[n][x*i][i]);
  }
  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 50048
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500 + 10;
const int maxm = maxn * maxn;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii;
pii e[maxn];
int n, m;
int a[maxn], b[maxm];
queue<int> cand;
void no() { puts("No"); exit(0);}
int main()
{
	scanf("%d", &n);
	m = n * n;
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		e[i] = mp(a[i], i);
		b[a[i]] = i;
	}
	for(int i = 1; i <= m; ++i) 
		if(!b[i])
			cand.push(i); 
	sort(e + 1, e + n + 1);
	for(int i = 1; i <= n; ++i)
	{
		int res = e[i].second - 1;
		while(res--)
		{
			int x = cand.front(); cand.pop();
			if(x > e[i].first) no();
			b[x] = e[i].second;
		}
	}
	for(int i = 1; i <= n; ++i)
	{
		int res = n - e[i].second;
		while(res--)
		{
			int x = cand.front(); cand.pop();
			if(x < e[i].first) no();
			b[x] = e[i].second;
		}
	}
	puts("Yes");
	for(int i = 1; i <= m; ++i) printf("%d ", b[i]);
	puts("");
	return 0;
}
	

Measured memory_bytes: 5484
#include<iostream>

using namespace std;

int dice1[7], dice2[7], tp;

void roll(int dice[], char ch){
    switch(ch){
        case 'E': tp = dice[1]; dice[1] = dice[4]; dice[4] = dice[6]; dice[6] = dice[3]; dice[3] = tp; break;
        case 'N': tp = dice[1]; dice[1] = dice[2]; dice[2] = dice[6]; dice[6] = dice[5]; dice[5] = tp; break;
        case 'S': tp = dice[1]; dice[1] = dice[5]; dice[5] = dice[6]; dice[6] = dice[2]; dice[2] = tp; break;
        case 'W': tp = dice[1]; dice[1] = dice[3]; dice[3] = dice[6]; dice[6] = dice[4]; dice[4] = tp; break;
        case 'R': tp = dice[2]; dice[2] = dice[4]; dice[4] = dice[5]; dice[5] = dice[3]; dice[3] = tp; break;
    }
}

bool issame(int dice1[], int dice2[]){
    for(int i = 1; i <= 6; ++i) if(dice1[i] != dice2[i]) return false;
    return true;
}

int main(){
    for(int i = 1; i <= 6; ++i) cin >> dice1[i];
    for(int i = 1; i <= 6; ++i) cin >> dice2[i];
    string op("RRRRSRRRRSRRRRSRRRRSERRRRWWRRRR");
    for(int i = 0; i < op.length(); ++i){
        if(issame(dice1, dice2)) { cout << "Yes" << endl; return 0;}
        roll(dice2, op[i]);
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3212
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()));
        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)*}
    };
}

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

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        n: usize,
        a: chars,
        b: chars,
        c: chars
    }
    let mut ans = 0;
    for i in 0..n {
        if a[i] == b[i] && b[i] == c[i] {
            continue;
        } else if a[i] == b[i] || b[i] == c[i] || c[i] == a[i] {
            ans += 1;
        } else {
            ans += 2;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>

int main()
{
    int first, second;
    scanf("%2d%2d", &first, &second);

    int yymm = (1 <= second && second <= 12);
    int mmyy = (1 <= first && first <= 12);

    if(yymm && mmyy)  printf("AMBIGUOUS\n");
    if(!yymm && mmyy) printf("MMYY\n");
    if(yymm && !mmyy) printf("YYMM\n");
    if(!yymm & !mmyy) printf("NA\n");

    return 0;
}


Measured memory_bytes: 128
import math
N,K = map(int,input().split())
k = 10**9+7
for i in range(1,K+1):
  A= 1
  for j in range(i-1):
    A *= K-1-j
  A = A//math.factorial(i-1)%k
  B = 1
  if N-K-i+1>=0:
    B = math.factorial(N-K+1)//math.factorial(N-K-i+1)//math.factorial(i)%k
    print(A*B%k)
  else:
    print(0)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <deque>
using namespace std;

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

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(a-b>=0)cout<<"delicious"<<endl;
  else if(b-a<=x)cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
  return 0;
}


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

int main() {
    int n;
    string t, h;
    int tp, hp;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> t >> h;
        if (t > h) {
            tp += 3;
        } else if (t < h) {
            hp += 3;
        } else {
            tp += 1;
            hp += 1;
        }
    }
    cout << tp << ' ' << hp << endl;
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;

#if 0
  ???????????????1???????????????c++???????????????????????????????????£??????
#endif

int N,A[10010];

int min(int *A,int N){
  int minimum =A[0];
  for (int i=1;i<N;++i){
    if (minimum > A[i]){
      minimum=A[i];
    }
  }
  return minimum;
}

int max(int *A,int N){
  int maximum =A[0];
  for (int i=1;i<N;++i){
    if (maximum < A[i]){
      maximum=A[i];
    }
  }
  return maximum;
}

long long sum(int *A,int N){
  long long sum=0;
  for (int i=0;i<N;++i){
    sum+=A[i];
  }
  return sum;
}


int main(){
  cin >> N;
  for (int i=0;i<N;++i){
    cin >> A[i];
  }
  cout << min(A,N)<<' ' << max(A,N) << ' '<<sum(A,N) << endl;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef sweety_candy
	freopen("input.txt","rt",stdin);
	freopen("ouput.txt","w",stdout);
#endif	
	int k;
	cin >> k;
	int res = k/2;
	cout << ((k%2 == 0) ? res*res : (res+1) * (res));
#ifdef sweety_candy
	cout << " Time elapsed: " << 1.0*clock() / LOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll A,B,C,D;

bool canTalk(){
    return abs(A - C) <= D || (abs(A-B) <= D && abs(B - C) <= D);
}

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

    if(canTalk())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD 1000000007

int H, W, N, sy, sx;
string S, T;

int main(){
	cin >> H >> W >> N >> sy >> sx >> S >> T;
	int l = sx;
	int r = sx;
	int u = sy;
	int d = sy;
	for(int i=0; i<N; i++){
		if(S[i] == 'L') l--;
		if(S[i] == 'R') r++;
		if(S[i] == 'U') u--;
		if(S[i] == 'D') d++;
		if(l < 1 || r > W || u < 1 || d > H){
			cout << "NO" << endl;
			return 0;
		}
		if(T[i] == 'L') r = max(1, r-1);
		if(T[i] == 'R') l = min(W, l+1);
		if(T[i] == 'U') d = max(1, d-1);
		if(T[i] == 'D') u = min(H, u+1);
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 776
#include<cstdio>
#include <string.h>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

int main(){
  int n,ans=0,data,ans2=1000000001;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>data;
    if(data%ans2==0) continue;
    ans=0;ans2=1;
    while(data%2==0){
      data/=2;
      ans++;
    }
    for(int i=0;i<ans;i++){
      ans2*=2;
    }

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


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	cin >> n >> k;

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

	int ball = n;
	ball -= k;

	int ans = abs((ball + 1) - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <functional>
#include <algorithm>

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef long long ll;
typedef pair<ll, int> pli;
typedef vector<pli> vpli;
typedef priority_queue<pli, vpli, greater<pli> > pqp;

const int A = 50;

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

    int n, m, s;
    cin >> n >> m >> s;
    int p = 2 * n * A + 1;
    vp e[n*p];
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        for (int j = 0; j < p - a; j++) {
            e[u*p+j+a].push_back({b, v*p+j});
            e[v*p+j+a].push_back({b, u*p+j});
        }
    }
    for (int i = 0; i < n; i++) {
        int c, d;
        cin >> c >> d;
        for (int j = 0; j < p; j++) {
            e[i*p+j].push_back({d, i*p+min(p-1,j+c)});
        }
    }

    s = min(s, p - 1);

    ll dis[n*p];
    fill(dis, dis+n*p, 3e12);

    pqp q;
    q.push({0, s});
    dis[s] = 0;

    while (!q.empty()) {
        ll d = q.top().first;
        int x = q.top().second;
        q.pop();

        if (d != dis[x]) {
            continue;
        }

        for (pii y : e[x]) {
            if (d + y.first < dis[y.second]) {
                dis[y.second] = d + y.first;
                q.push({dis[y.second], y.second});
            }
        }
    }

    for (int i = 1; i < n; i++) {
        cout << *min_element(dis+i*p, dis+(i+1)*p) << endl;
    }

    return 0;
}


Measured memory_bytes: 31804
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, n) cin >> a[i];

	int left = 0, right = 1e9+1;
	int ans = 0;
	while(left + 1 < right) {
		int mid = (left + right) / 2;
		int now = 0;
		rep(i, n) {
			now += max(0LL, ((a[i]+mid-1) / mid - 1));
		}
		if(now <= k) right = mid, ans = mid;
		else left = mid;
		//cout << left << " " << right << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5124
s = input().strip()

old = s[0]
result = 1
two_letter = False
for c in s[1:]:
    if not two_letter and c == old:
        two_letter = True
        old = c
    else:
        result += 1
        if two_letter:
            old += c
        else:
            old = c
        two_letter = False

print(result)


Measured memory_bytes: 42716
// @author: arch_

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

int main(void) {
    int n = 0;
    array<int, 10000> x;
    while (cin >> x[n], x[n++]);
    for (int i = 0; i < n - 1; i++)
        printf("Case %d: %d\n", i + 1, x[i]);
    return 0;
}

Measured memory_bytes: 3140