akhauriyash/Code-Regression huggingface dataset:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n, m = map(int, input().split())

data = []
for i in range(m):
    input_data = input().split()
    tmp_int = int(input_data[0]) -1
    tmp_str = str(input_data[1])
    data.append([tmp_int, tmp_str])

table_cnt = [0]*n
table_bool = [False]*n

ans_ac = 0
ans_wa = 0

for index, result in data:
    if table_bool[index] == False:
        if result == "WA":
            table_cnt[index] += 1
        else:
            table_bool[index] = True
            ans_ac += 1
            ans_wa += table_cnt[index]

print(ans_ac, ans_wa)

Measured memory_bytes: 25484
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a, b, c = MII()
    r = a%b
    ri = r
    if r == 0:
        if r == c:
            print('YES')
            return None
        else:
            print('NO')
            return None
    while r < 10**5:
        if r%b == c:
            print('YES')
            return None
        r += ri
    print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(){
	double a,b,c,d,e,f,a2,b2,c2,d2;
	double sum=0;
	cin>>a>>b>>c>>d>>e>>f;
	for(double i=0;i<=f;i+=100*a){
		for(double j=0;j<=f;j+=100*b){
			if(i+j==0) continue;
			for(double k=0;k<=f;k+=c){
				for(double l=0;l<=f;l+=d){
					if(i+j+k+l>f || (k+l)/(i+j)>(e/100)) continue;
					if((100*k+100*l)/(i*e+j*e) >= sum && (100*k+100*l)/(i*e+j*e)<=1){
						sum=(100*k+100*l)/(i*e+j*e);
						a2=i;
						b2=j;
						c2=k;
						d2=l;
					}
				}
			}
		}
	}
	cout<< a2+b2+c2+d2 << " " << c2+d2;	
}



Measured memory_bytes: 256
from collections import defaultdict
digit = []
def check(n):
	global digit
	while n:
		rem  = n%10
		for i in digit:
			if i==rem:
				return False
		n = n//10
	return True
def main():
	global digit
	n , k = map(int , input().split())
	digit = list(map(int , input().split()))
	ans = n
	while (check(n))==False:
		n = n+1
	print(n)

if __name__ =="__main__":
	main()

Measured memory_bytes: 85096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,a;
	vector<int>v,w;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
		w.push_back(a);
	}
	sort(w.begin(),w.end());
	for(int i=0;i<n;i++)
	{
		if(v[i]==w[n-1])cout<<w[n-2]<<endl;
		else cout<<w[n-1]<<endl;
	}
	return 0;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll N;
string S;
ll ans;

void solve(ll left, ll right)
{
    if(left==1 && right==0){ans++;return;}
    if(left != 1) ans += left*(left-1)*0.5;
    if(right != 1)ans += right*(right-1)*0.5;
    if(left > right)ans +=left;
    else ans+=right;
}

ll read(ll cnt)
{
    ll left=0, right=0;
    ll i;
  	bool flag=false;
    for(i=cnt;i<N;i++)
    {
        if(S[i] == '<')
        {
          	if(flag)break;
            left++;
        }
        else
        {
          	right++;
          	flag=true;
        }
    }
    solve(left, right);
    return i;
}

int main(){
    cin >> S;
    N=S.length();
    ll cnt=0;
    while(cnt != N)cnt = read(cnt);
    cout << ans << endl;
    return 0;
}

/*
int main(){
    cin >> S;
    N=S.length();
    ll a[N+100];
    REP(i,N+100)a[i]=0;
    ll cnt=1;
    for(char ch:S)
    {
        if(ch == '<')
        {
            if(a[cnt] >= a[cnt+1])a[cnt+1]=a[cnt]+1;
        }
        else
        {
          	ll i=cnt;
            while(S[i-1] != '<')
            {
              	if(a[i] <= a[i+1]){
                	a[i]=a[i+1]+1;
                  	i--;
              	}
              	else
                {
                  	break;
                }
            }
        }
        cnt++;
      	//FOR(k,1,N+2)cout << a[k] << " ";
  		//cout << endl;
    }
    ll ans=0;
  	//FOR(i,1,N+2)cout << a[i] << " ";
  	//cout << endl;
    FOR(i,1,N+2)ans+=a[i];
    cout << ans << endl;
    return 0;
}
*/

Measured memory_bytes: 900
#include <iostream>
#include <vector>

const unsigned long int modulo = 1000000007;

class Tree {
public:
    Tree(){
        this->id = ++(this->nNodes);
    }
    int getColorsMod(const unsigned long int colors, const unsigned long int depth, const unsigned long int parentId) const {
        unsigned long int tmpColors = colors;
        unsigned long int colorsMod = tmpColors % modulo;
        if(depth>0){
            tmpColors = this->nColors - 1;
        }
        for(auto &child : children){
            if(child->id != parentId){
                colorsMod *= child->getColorsMod(--tmpColors, depth+1, this->id);
                colorsMod %= modulo;
            }
        }
        return colorsMod;
    }
    void registerChild(const Tree &tree){
        this->children.emplace_back(&tree);
    }
    static void setNColors(const unsigned long int nColors){
        Tree::nColors = nColors;
    }
private:
    unsigned long int id;
    static unsigned long int nNodes;
    static unsigned long int nColors;
    std::vector<const Tree *> children;
};

unsigned long int Tree::nNodes = 0;
unsigned long int Tree::nColors = 0;

int main(int argc, char *argv[]){
    unsigned long int N, K;
    std::cin >> N >> K;

    Tree tree[N];
    Tree::setNColors(K);
    unsigned long int a,b;
    for(int i=1; i<N; ++i){
        std::cin >> a >> b;
        tree[--a].registerChild(tree[--b]);
        tree[b].registerChild(tree[a]);
    }
    std::cout << tree[0].getColorsMod(K,0,0) << std::endl;
    return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
string s;

int l[202020];
int r[202020];
int main() {
  cin >> N >> s;
  s = " " + s;
  for(int i = 1;i <= N;i++) {
    l[i] = l[i - 1] + (s[i] == '#');
  }
  for(int i = N;i >= 1;i--) {
    r[i] = r[i + 1] + (s[i] == '.');
  }
  int ans = 1e9;
  for(int i = 0;i <= N;i++) {
    ans = min(ans, l[i] + r[i + 1]);
  }
  cout << ans << endl;
}


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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef double db;
typedef pair <db, db> pdd;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;

const int INF=0x3f3f3f3f;
const int N=2e5+5;
const int OFF=(1<<20);
//#warning offset

int n;
ll c, h[N];
ll dp[N];
pll T[2*OFF];

ll f(pll a, ll x) {
    return a.X*x+a.Y;
}

ll query(int lo, int hi, int pos, int x) {
    if (lo==hi-1) return f(T[pos], x);
    ll curr=f(T[pos], x);
    int mid=(lo+hi)/2;
    if (x<mid) return min(curr, query(lo, mid, pos*2, x));
    return min(curr, query(mid, hi, pos*2+1, x));
}

void update(int lo, int hi, int pos, pll val) {
    if (f(T[pos], lo)>f(val, lo)) swap(T[pos], val);
    if (lo==hi-1) return;

    int mid=(lo+hi)/2;
    if (f(T[pos], mid)<f(val, mid)) { //sjeciste u desnoj polovici
        update(mid, hi, pos*2+1, val);
    }
    else { //sjeciste u lijevoj polovici
        update(lo, mid, pos*2, T[pos]);
        T[pos]=val;
    }
//    printf("pos == %d, (%lld, %lld)\n", pos, T[pos].X, T[pos].Y);
}

void load() {
    scanf("%d %lld", &n, &c);
    for (int i=1; i<=n; ++i) scanf("%lld", h+i);
}

void solve() {
    fill(T, T+2*OFF, mp(0, (ll)INF*INF));
    dp[1]=0;
    update(0, OFF, 1, mp(-h[1]*2, h[1]*h[1]));
    for (int i=2; i<=n; ++i) {
        dp[i]=query(0, OFF, 1, h[i])+c+h[i]*h[i];
//        printf("i: %d, dp: %lld\n", i, dp[i]);
        update(0, OFF, 1, mp(-h[i]*2, h[i]*h[i]+dp[i]));
    }
    printf("%lld\n", dp[n]);
}

int main() {
    load();
    solve();
    return 0;
}


Measured memory_bytes: 39724
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<bitset>
#include<vector>

using namespace std;

#define N 101000
#define ll long long
#define RG register

inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

int n,m,a[N<<1],ans,Mx;

inline bool Check(int mid){
	Mx=0; bool zzq=0;
	for(RG int l=(mid-1)*2+1,r=n*2;l<=r;++l,--r){
		Mx=max(Mx,a[l]+a[r]-m); if(a[l]+a[r]<m) zzq=1;
	}   return (!zzq);
}

int main(){
	n=read(),m=read();
	for(RG int i=1;i<=n<<1;++i) a[i]=read();
	sort(a+1,a+1+(n<<1));
	int l=1,r=n,pos=n+1;
	while(l<=r){
		int mid=l+r>>1;
		if(Check(mid)) pos=mid,ans=Mx,r=mid-1;
		else l=mid+1;
	}
	for(RG int l=1,r=(pos-1)*2;l<=r;++l,--r)
		ans=max(ans,a[l]+a[r]);
	printf("%d\n",ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
vector<vector<int>> A;
vector<vector<bool>> B;
const int di[] = {+1,-1, 0, 0};
const int dj[] = { 0, 0,+1,-1};

void f(int i, int j) {
	for (int k = 0; k < 4; ++ k) {
		int ii = i + di[k];
		int jj = j + dj[k];
		if (0 <= ii && ii < N && 0 <= jj && jj < N) {
			int x = A[i][j] + (B[i][j] ? 0 : 1);
			if (x < A[ii][jj]) {
				A[ii][jj] = x;
				f(ii, jj);
			}
		}
	}
}

int main() {
	cin >> N;

	A.resize(N, vector<int>(N));
	B.resize(N, vector<bool>(N));

	for (int i = 0; i < N; ++ i) for (int j = 0; j < N; ++ j) A[i][j] = min(min(i, N-1-i), min(j, N-1-j));

	int res = 0;
	for (int tt = 0; tt < N*N; ++ tt) {
		int x;
		cin >> x;
		-- x;
		int i = x / N;
		int j = x % N;
		res += A[i][j];
		B[i][j] = true;
		f(i, j);
	}
	cout << res << endl;
}


Measured memory_bytes: 27448
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<int> card(n + 1, 0);
  REP(i, m) {
    int l, r; cin >> l >> r;
    ++card[l];
    if (r < n) --card[r + 1];
  }
  FOR(i, 1, n + 1) card[i] += card[i - 1];
  int ans = 0;
  FOR(i, 1, n + 1) {
    if (card[i] == m) ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int d,g,ans=inf; cin>>d>>g;
    g/=100;
    vector<pp> q(d);
    rep(i,d){
        int p,c; cin>>p>>c;
        q[i]=mk(p,c/100);
    }
    rep(i,(1<<d)){
        int cnt=0,po=0;
        rep(j,d){
            if(i&(1<<j)){
                cnt+=q[j].first;
                po+=q[j].first*(j+1)+q[j].second;
            }
        }
        for(int j=d-1;j>=0;j--){
            if(po>=g) break;
            if(!(i&(1<<j))){
                if(g-po<=(q[j].first-1)*(j+1)){
                    cnt+=(g-po+j)/(j+1);
                    po=g;
                }
                else{
                    cnt+=q[j].first-1;
                    po+=(q[j].first-1)*(j+1);
                }
            }
        }
        if(po>=g) ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int d=100000;
	int n,i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		d*=1.05;
		if(d%1000!=0){
			d = d - d%1000 +1000;
		}
	}
	printf("%d\n",d);
	return 0;
}

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

using namespace std;

using std::cin;
using std::cout;
using std::endl;

string s[3];

// A, B, Cのカードの配列の位置
int ap, bp, cp;
int i = 0;

int game(int participant) {
  if (participant == 0) {
    ap++;
    // 勝利条件
    if (!s[participant][ap]) {
      return participant;
    } else {
      if (s[participant][ap] == 'a') {
        return game(0);
      } else if (s[participant][ap] == 'b') {
        return game(1);
      } else {
        return game(2);
      }
    }
  } else if (participant == 1) {
    bp++;
    // 勝利条件
    if (!s[participant][bp]) {
      return participant;
    } else {
      if (s[participant][bp] == 'a') {
        return game(0);
      } else if (s[participant][bp] == 'b') {
        return game(1);
      } else {
        return game(2);
      }
    }
  } else {
    cp++;
    // 勝利条件
    if (!s[participant][cp]) {
      return participant;
    } else {
      if (s[participant][cp] == 'a') {
        return game(0);
      } else if (s[participant][cp] == 'b') {
        return game(1);
      } else {
        return game(2);
      }
    }
  }
}

int main() {
  // 勝った人を表す
  int win;
  ap = -1;
  bp = -1;
  cp = -1;

  // 手札の入力
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
  }

  // 勝者を判定する
  // 第一引数：カードのインデックス
  // A, B, Cの誰か
  ap++; // ゲーム開始
  win = game(0);

  switch (win) {
    case  0:
      cout << "A" << endl;
      break;
    case  1:
      cout << "B" << endl;
      break;
    case  2:
      cout << "C" << endl;
      break;
  }

  return 0;
}


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

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

int main() {
    int a,b;
    cin>>a>>b;
    cout << gcd(a,b) << endl;
    
    return 0;
    
   
}



Measured memory_bytes: 3096
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

type Item struct {
  Value int
  Index int
}
type Items []Item
func (A Items) Len() int { return len(A) }
func (A Items) Less(i, j int) bool { return A[i].Value < A[j].Value }
func (A Items) Swap(i, j int) { A[i], A[j] = A[j], A[i] }

func main() {
  NKQ := NextIntVec()
  N, K, Q := NKQ[0], NKQ[1], NKQ[2]
  A := NextIntVec()
  B := make([]Item, N)
  for i := range B {
    B[i] = Item{A[i], i}
  }
  C := make([]int, N + 1)
  C[N] = 1
  dist := 10000000001
  for dist > 0 {
    D := make([]Item, 0)
    s := 0
    for i, c := range C {
      if c == 0 { continue }
      if K <= i - s {
        tmp := make([]Item, 0)
        tmp = append(tmp, B[s:i]...)
        sort.Sort(Items(tmp))
        D = append(D, tmp[:i - s - K + 1]...)
      }
      s = i + 1
    }
    if len(D) < Q { break }
    sort.Sort(Items(D))
    if D[Q - 1].Value - D[0].Value < dist {
      dist = D[Q - 1].Value - D[0].Value
    }
    for _, d := range D {
      if D[0].Value < d.Value { break }
      C[d.Index] = 1
    }
  }
  Write(dist)
  Output()
}

Measured memory_bytes: 7808
using System;

public class Program {

        public static void Main(string[] args) {


            var sArray = Console.ReadLine().Split(' ');

            var a = int.Parse(sArray[0]);
            var b = int.Parse(sArray[2]);

            var op = sArray[1];

            if(op == "+") {

                Console.WriteLine(a + b);

            } else if(op == "-") {

                Console.WriteLine(a - b);

            }

            
        }

    }

Measured memory_bytes: 11092
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();//問題番号
    int g = sc.nextInt();//目標点数
    int[] p = new int[d];//各番号の問題数
    int[] c = new int[d];//各番号のボーナス点数
    int min_count = Integer.MAX_VALUE;

    for(int i = 0; i < d; i++){
      p[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }

    for(int i = 0; i < (int)Math.pow(2, d); i++){
      int max_idx = -1;
      int idx = d;
      int cnt = 0;
      int sum = 0;
      for(int j = 0; j < d; j++){
        idx -= 1;
        if((1 & (i >> j)) == 1){
          sum += p[idx] * (idx+1) * 100 + c[idx];
          cnt += p[idx];
        }else{
          max_idx = Math.max(max_idx, idx);
        }
      }
      if(sum < g){
        int one_cnt = 0;
        while( sum < g && one_cnt <= p[max_idx]){
          sum += 100 * (max_idx + 1);
          one_cnt += 1;
        }
        if(sum >= g){
          cnt += one_cnt;
        }else{
          cnt = Integer.MAX_VALUE;
        }
      }
      min_count = Math.min(min_count, cnt);
    }

    System.out.println(min_count);
  }
}


Measured memory_bytes: 22740
n=int(input())
a=list()
b=["S","H","C","D"]

for i in range(n):
    s,r=input().split()
    r=int(r)
    if s=="S":
        a.append(0+r)
    elif s=="H":
        a.append(13+r)
    elif s=="C":
        a.append(26+r)
    elif s=="D":
        a.append(39+r)
for k in range(1,53):
    if not k in a:
        print(b[(k-1)//13],(k-1)%13+1)


Measured memory_bytes: 5608
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    int pos = 0;
    vi ss;
    while (pos != n) {
        if (s1[pos] == s2[pos]) {
            ss.push_back(1);
            pos++;
        } else {
            ss.push_back(2);
            pos += 2;
        }
    }
    ll ret = ss[0] == 1 ? 3 : 6;
    for (int i = 1; i < ss.size(); i++) {
        if (ss[i] == 1 && ss[i - 1] == 1)
            ret = (ret * 2) % MOD;
        else if (ss[i] == 1 && ss[i - 1] == 2)
            ret = ret;
        else if (ss[i] == 2 && ss[i - 1] == 1)
            ret = (ret * 2) % MOD;
        else
            ret = (ret * 3) % MOD;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
int C[1001][1001];
int M = 1e9 + 7;
int main() {
  int N, K;
  std::cin >> N >> K;
  C[0][0] = 1;
  for (int n = 0; n <= K; ++n)
    C[n][0] = 1;
  for (int k = 1; k <= N; ++k)
    for (int n = k; n <= K; ++n)
      C[n][k] = (C[n - 1][k] + C[n - 1][k - 1]) % M;
  std::cout << C[K][N] << std::endl;
}


Measured memory_bytes: 7004
import sys

inputNum = sys.stdin.readlines()

for i in inputNum:
    new = []
    n = i[:-1].split(' ', 6)
    for s in n:
        new.append(float(s))
    k = new[0]
    q = 0
    for a in new[0:3]:
        new[q] = a/k
        q = q + 1
    l = new[3]
    for a in new[3:6]:
        new[q] = a - l*new[q-3]
        q = q + 1
    if new[4] == 0:
        y = new[5]
    else:
        y = new[5]/new[4]
    x = new[2]-(new[1]*y)
    print("{0:.3f}".format(x)+" "+"{0:.3f}".format(y))

Measured memory_bytes: 7440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200005;
int n;
ll a[maxn],x,sum,ans=10000000000000000ll;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	for(int i=0;i<n-1;i++){
		x+=a[i];
		ans=min(ans,abs(2*x-sum));
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main(){
	while(true){
		int n; cin >> n;
		if(n == 0)break;
		bool l = false, r = false;
		bool k = false;
		int cnt = 0;
		for(int i = 0; i < n; i++){
			string str; cin >> str;
			if(str == "lu"){
				if(r && !k){
					cnt++;
					k = true;
				}
				l = true;
			}
			else if(str == "ru"){
				if(l && !k){
					cnt++;
					k = true;
				}
				r = true;
			}
			else if(str == "ld"){
				if(k && !r){
					cnt++;
					k = false;
				}
				l = false;
			}
			else{
				if(k && !l){
					cnt++;
					k = false;
				}
				r = false;
			}
		}
		cout << cnt << endl;
	}


	return 0;
}




Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a1, a2, a3, a4, b1, b2, b3, b4, S, T;

    scanf ("%d %d %d %d\n", &a1, &a2, &a3, &a4);    
    scanf ("%d %d %d %d\n", &b1, &b2, &b3, &b4);

    S = a1 + a2 + a3 + a4;
    T = b1 + b2 + b3 + b4;

    if (S > T) {
        printf ("%d\n", S);
    }
    else {
        printf ("%d\n", T);
    }

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

long long n,a[300005],ans=0;

int main(){
		cin>>n;
		for(int i=1;i<=n;i++)cin>>a[i];	
		int j=0,now=0,pp=0;
		for(int i=1;i<=n;i++){
			while((pp^a[j+1])==now+a[j+1]&&j<n){
			now+=a[j+1];
			pp = pp^a[j+1];
			j++;
			}
			if(pp==now)ans+=(j-i+1);
			now-=a[i];
			pp = pp^a[i];
		}
		cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<cstdint>

int main() {
  int64_t K; std::cin >> K;
  std::queue<int64_t> q;
  for(int i = 1; i <= 9; ++i) q.push(i);
  while(q.size() < K) {
    int64_t v = q.front(); q.pop(); --K;
    int64_t v10 = v*10, vm = v%10;
    if(vm != 0) q.push(v10+vm-1);
    q.push(v10+vm);
    if(vm != 9) q.push(v10+vm+1);
  }
  for(int i = 0; i < K-1; ++i) q.pop();
  std::cout << q.front() << std::endl;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

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

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll num_bc = b / c;
    ll num_bd = b / d;
    ll num_bcd = b / lcm(c, d);
    ll num_b = b - num_bc - num_bd + num_bcd;

    --a;
    ll num_ac = a / c;
    ll num_ad = a / d;
    ll num_acd = a / lcm(c, d);
    ll num_a = a - num_ac - num_ad + num_acd;

    cout << num_b - num_a << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    double a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;
    set<double> sugar,water;
    for(int i=0;i<=30;i++){
        for (int j = 0;j<=30;j++){
            double W = 100 * a * i + 100 * b * j;
            if (W <= f){
                water.insert(W);
            }
            
        }
    }
    for (int i = 0; i * c < f;i++){
        for (int j = 0; j * d < f;j++){
            double w=c*i+d*j;
            if(w<f){
                sugar.insert(w);
            }
        }
    }
/*     for(auto it:sugar){
        cout << it << ' ';
    }
    cout << endl; */
    double res = 0;
    double t = 100 * e / (100 + e);
    double a1 = -1, a2 = -1;
    for (auto a : water)
    {
        for(auto b:sugar){
            if(a+b>f)
                continue;
            double C = 100 * b / (a + b);
            if (C <= t)
            {
                //cout << a << ' ' << b << ' ' << C << endl;
                res = max(res, C);
                if(res==C){
                    a1 = a + b;
                a2 = b;
                }
                
            }
        }
    }
    cout << a1 << ' ' << a2 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<P,P> PP;

void Main() {
  int n,m;
  cin >> n >> m;
  int a[n][m];
  rep(i,n)rep(j,m) R a[i][j];
  vector<PP> v;
  rep(i,n) {
    if(i%2) {
      rrep(j,m) {
        if(a[i][j]%2) {
          if(!j) {
            if(i==n-1) break;
            a[i+1][j]++;
            a[i][j]--;
            v.pb(PP(P(i,j),P(i+1,j)));
          } else {
            a[i][j-1]++;
            a[i][j]--;
            v.pb(PP(P(i,j),P(i,j-1)));
          }
        }
      }
    } else {
      rep(j,m) {
        if(a[i][j]%2) {
          if(j==m-1) {
            if(i==n-1) break;
            a[i+1][j]++;
            a[i][j]--;
            v.pb(PP(P(i,j),P(i+1,j)));
          } else {
            a[i][j+1]++;
            a[i][j]--;
            v.pb(PP(P(i,j),P(i,j+1)));
          }
        }
      }
    }
  }
  pr(v.size());
  rep(i,v.size()) pr(v[i].F.F+1,v[i].F.S+1,v[i].S.F+1,v[i].S.S+1);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 5232
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 1;
        int ans = 0;
        boolean test = false;
        
        for(int i=0; i<N; i++){
            int A = sc.nextInt();
            if(A==1){
                test = true;
            }
            if(count==A){
                count++;
            }else{
                ans++;
            }
        }
        if(test){
            System.out.println(ans);
        }else{
            System.out.println(-1);
        }
    }
}

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

int main() {

	int n;
	scanf("%d", &n);

	string s;
	cin >> s;

	int x = 0, ans = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'I') {
			x++;
		}
		if (s[i] == 'D') {
			x--;
		}
		if (x > ans) {
			ans = x;
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
fig = input()
fig_a = fig[:3]
fig_b = fig[1:]

if (fig_a[0] == fig_a[1]) and (fig_a[0] == fig_a[2]):
    print("Yes")
elif (fig_b[0] == fig_b[1]) and (fig_b[0] == fig_b[2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
def merge(a):
    if len(a) == 1:
        return a, 0
    mid = len(a) // 2
    al, cnt_l, ar, cnt_r = *merge(a[:mid]), *merge(a[mid:])
    res_cnt, res_arr = 0, []
    while 0 < len(al) and 0 < len(ar):
        if al[-1] <= ar[-1]:
            res_arr.append(al.pop())
        else:
            res_arr.append(ar.pop())
            res_cnt += len(al)
    res_arr.reverse()
    return ar + al + res_arr, res_cnt + cnt_l + cnt_r


def inversion_count(a):
    return merge(a)[1]


def main():
    input()
    a = list(map(int, input().split()))
    print(inversion_count(a))


if __name__ == '__main__':
    main()



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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s >> s;
	cout << 'A' << s[0] << 'C' << '\n';
}


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

double dp[301][301][301];

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    int n;
    cin>>n;
    int arr[n];
    int cnt[4]={0};
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        cnt[arr[i]]++;
    }
    //cout<<"lol";
    //double dp[301][301][301];
    //memset(dp,0.0,sizeof(dp));
    for(int c=0; c<301; c++)
    {
        for(int b=0; b<301; b++)
        {
            for(int a=0; a<301; a++)
            {
                if(a==0 && b==0 && c==0) continue;
                if(a+b+c > n) continue;
                double p1 = (double) a/n;
                double p2 = (double) b/n;
                double p3 = (double) c/n;
                dp[a][b][c] = 1;
                if(a) dp[a][b][c] += dp[a-1][b][c]*p1;
                if(b) dp[a][b][c] += dp[a+1][b-1][c]*p2;
                if(c) dp[a][b][c] += dp[a][b+1][c-1]*p3;
                dp[a][b][c] /= (p1+p2+p3);
            }
        }
    }
    cout<<dp[cnt[1]][cnt[2]][cnt[3]];
    return 0;
}

Measured memory_bytes: 213376
N=int(input())
AB=[list(map(int,input().split())) for i in range(N-1)]
c=[[] for i in range(N)]
for i,j in AB:
    c[i-1].append(j-1)
    c[j-1].append(i-1)
from collections import deque
def bfs(c,N,s):
    d=[-1]*N
    d[s]=0
    q=deque([s])
    while q:
        i=q.popleft()
        for j in c[i]:
            if d[j]<0:
                d[j]=d[i]+1
                q.append(j)
    return d
d=bfs(c,N,0)
r=max(bfs(c,N,d.index(max(d))))
print(['First','Second'][r%3==1])

Measured memory_bytes: 94676
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
#include <iomanip>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int H, W, A, B; cin >> H >> W >> A >> B ;
VVI s(H, VI(W, 0));

rep(i, 0, B){
    rep(j, 0, A) cout << 1;
    rep(j, 0, W - A) cout << 0;
    cout << "\n";
}
rep(i, 0, H - B){
    rep(j, 0, A) cout << 0;
    rep(j, 0, W - A) cout << 1;
    cout << "\n";
}
}

// 境界，出力文字列 チェック



Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
ll n, m, add, ans, A[101010];
char s[1010];
int main() {
	cin >> n >> m;
	rep(i, n + m + 1) cin >> s[i];
	rep(i, n + m + 1) {
		if (s[i] - '0' < 0 || s[i] - '0'>9) {
			if (i != n) {
				cout << "No" << endl;
				return 0;
			}
		}
		else if (i == n && s[i] != '-') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = list(map(int, input().split()))
a = []
for _ in range(h):
    a.append(list(map(int, input().split())))
    
def totallength(y, x):
    cnt = 0
    for i in range(h):
        for j in range(w):
            cnt += a[i][j] * min([abs(i-y), abs(j-x)])
    return cnt

mincnt = 10**10
for i in range(h):
    for j in range(w):
        current = totallength(i, j)
        #print(i,j,current)
        if current < mincnt:
            mincnt = current

print(mincnt)


Measured memory_bytes: 5608
def tentousu(a):
  ans=0
  for i in range(len(a)):
    for j in range(i+1,len(a)):
      if a[i]>a[j]:ans+=1
  return ans
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(1,n,2):a[i],b[i]=b[i],a[i]
ans=inf=float('inf')
for i in range(2**n):
  s=bin(i)[2:].zfill(n)
  if s.count("0")!=n//2:continue
  ac=[]
  bc=[]
  for j in range(n):
    if s[j]=="1":ac.append((a[j],j))
    else:bc.append((b[j],j))
  ac.sort()
  bc.sort()
  x=[]
  for j in range(n):
    if j%2:x.append(bc[j//2])
    else:x.append(ac[j//2])
  f=False
  for j in range(1,n):
    if x[j-1][0]>x[j][0]:f=True
  if f:continue
  m=[]
  for j in range(n):m.append(x[j][1])
  ans=min(ans,tentousu(m))
if ans==inf:ans=-1
print(ans)


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

#define ll long long 
#define mp make_pair
#define pb push_back
#define root 1

typedef pair<ll, ll> P;

const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

vector<int> G[MAXN];
bool visited[MAXN];
ll dp[MAXN][2];

void prepare() {
	for(int i=0; i<MAXN; i++)
		dp[i][1] = 1LL, dp[i][0] = 1LL;
}

void dfs(int u) {
	visited[u] = true;
	for(int v : G[u]) {
		if(!visited[v]) {
			dfs(v);
			dp[u][1] *= dp[v][0];
			dp[u][0] *= (dp[v][0] + dp[v][1]);
			dp[u][0] %= MOD, dp[u][1] %= MOD;
		}
	}
}

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

	int n;	cin >> n;
	for(int i=1; i<n; i++) {
		int a, b;	cin >> a >> b;
		G[a].pb(b), G[b].pb(a);
	}	
	prepare();
	dfs(root);
	cout << (dp[root][0] + dp[root][1])%MOD;
	return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int


class Bridge {
    public:
        int a, b;
};

int n, m;
vector<Bridge> bridge;
vector< vector<bool> > graph;
vector<bool> visited;

bool dfs(int start);

int main(){
    cin >> n >> m;
    int N = n;
    bridge.resize(m);
    
    graph.resize(n);
    generate(graph.begin(), graph.end(), [N](){ return vector<bool>(N, false); });
    repi(i, bridge){
        cin >> (*i).a >> (*i).b;
        (*i).a--;
        (*i).b--;
        graph[(*i).a][(*i).b] = graph[(*i).b][(*i).a] = true;
    }
    visited.resize(n);
    int sum = 0;
    repi(i, bridge){
        fill(visited.begin(), visited.end(), false);
        graph[(*i).a][(*i).b] = graph[(*i).b][(*i).a] = false;
        bool ans = dfs(0);
        if(!ans)
            sum++;
        graph[(*i).a][(*i).b] = graph[(*i).b][(*i).a] = true;
    }
    cout << sum << endl;
    return 0;
}

bool dfs(int start){
    visited[start] = true;
    if(all_of(visited.begin(), visited.end(), [](bool a){ return a; }))
        return true;
    bool ans = false;
    rep(i, n){
        if(visited[i])
            continue;
        if(!graph[start][i])
            continue;
        ans |= dfs(i);
    }
    return ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

struct B{int x1,y1,x2,y2;string name;};
int W,H,n;

struct SITE{
	string myname;
	vector<B> co;
};

int pos;
map<string,int> to;
vector<SITE>info;

vector< vector<SITE>::iterator > lst;
vector<SITE>::iterator cur;


vector<SITE>::iterator find(string name){
	int lp = to[name];
	vector<SITE>::iterator it = info.begin();
	rep(i,lp){++it;}
	return it;
}

void move(string name){
	vector< vector<SITE>::iterator > newList;
	rep(i,pos+1){
		newList.push_back(lst[i]);
	}
	lst = newList;

	lst.push_back(find(name));
	cur = lst.back();
	pos = lst.size()-1;
}

main(){

	while(cin >> n , n ){
		to.clear();
		info.clear(),info.resize(n);
		cin >> W >> H;
		rep(i,n){
			string s;int d;
			cin >> s >> d;
			to[s] = i;
			
			info[i].myname = s;
			
			rep(j,d){
				B t;
				cin >> t.x1 >> t.y1 >> t.x2 >> t.y2 >> t.name;	
				info[i].co.push_back(t);
			}
			
		}
		
		int m;

		lst.clear();		
		lst.push_back(info.begin());
		cur = info.begin();
		pos = 0;
		
		cin >> m;
		
		rep(i,m){
			string s; cin >> s;
			if( s == "click" ){	
				int x,y;
				cin >> x >> y;
				SITE t= *cur;
				rep(i,t.co.size()){
					if(t.co[i].x1 <= x && x <= t.co[i].x2 &&
					   t.co[i].y1 <= y && y <= t.co[i].y2
					){
						move(  t.co[i].name );	
					}
				}
			}
			if( s == "show"){
				cout << (*cur).myname << endl;
			}
			
			if( s == "back"){
				if(pos==0)continue;
				
				pos--;
				cur = lst[pos];
			}
			
			if( s == "forward"){
				if(pos == lst.size()-1)continue;
				pos++;
				cur = lst[pos];
			}
			
		}
	}
}

Measured memory_bytes: 0
#include<stdio.h>

int main() {
  int k;
  char s[128];
  scanf("%d",&k);
  scanf("%s",s);
  int size=0;
  while (s[size]!=0) {
    size++;
  }
  if (size>k) {
    for (int i=0;i<k;i++) {
      printf("%c",s[i]);
    }
    printf("...\n");
  } else {
    printf("%s",s);
  }
  return 0;
}

Measured memory_bytes: 1728
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define pr pair<int,int>
using namespace std;
const int N = 100005;
int a[N];
int n,m;
vector<int> g[N];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for(int i=1;i<=n;++i){
		cin >> a[i];
	}
	for(int i=1;i<=m;++i){
		int x,y; cin >> x >> y;
		if (a[x] <= a[y]) g[x].push_back(y);
		if (a[y] <= a[x]) g[y].push_back(x);
	}
	int ans = 0;
	for(int i=1;i<=n;++i){
		if (g[i].size() == 0) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 8168
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        QuickScanner in = new QuickScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task045A solver = new Task045A();
        solver.solve(in, out);
        out.close();
    }
}

class Task {
    public void solve(QuickScanner in, PrintWriter out) {
        int D = in.nextInt();
        int T = in.nextInt();
        int S = in.nextInt();
        double time = (double)D/(double)T;
        if(T*S >= D) {
        	out.print("Yes");        	
        }else {
        	out.print("No");
        }
    }
}
class TaskB {
    public void solve(QuickScanner in, PrintWriter out) {
        char[] S = in.next().toCharArray();
        char[] T = in.next().toCharArray();
        int ans = T.length;
        for(int start = 0; start <= S.length - T.length; start++) {
        	int diff = 0;
        	for(int i = 0; i < T.length; i++) {
        		if(T[i] != S[start + i]) {
        			diff++;
        		}
        	}
        	ans = Math.min(ans,diff);
        }
        out.print(ans);
    }
}
class Task045A {
    public void solve(QuickScanner in, PrintWriter out) {
    	int a = in.nextInt();
    	int b = in.nextInt();
    	int h = in.nextInt();
    	out.print(((a + b)*h)/2);
    }
}


class QuickScanner {
    BufferedReader in;
    StringTokenizer token;
    String delim;
    public QuickScanner(InputStream inputStream)
    {
        this.in=new BufferedReader(new InputStreamReader(inputStream));
        this.delim=" \n\t";
        this.token=new StringTokenizer("",delim);
    }

    public boolean hasNext()
    {
        while(!token.hasMoreTokens())
        {
            try {
                String s=in.readLine();
                if(s==null) return false;
                token=new StringTokenizer(s,delim);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }
        return true;
    }

    public String next()
    {
        hasNext();
        return token.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

}


Measured memory_bytes: 32924
#include<bits/stdc++.h>
using namespace std;
main()
{
	int n;
	cin>>n;
	int a[n+1];
	a[0]=0;
	a[1]=0;
	vector<int> v(n+1,0);
	for(int i=2;i<=n;i++)
	{
		cin>>a[i];
		v[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<v[i]<<"\n";
	}
}


Measured memory_bytes: 4836
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc	= new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	
	System.out.println((a-1)*(b-1));
	
	}
}


Measured memory_bytes: 23764
n, m = map(int, input().split())
a = list(map(int, input().split()))
d = [10**5, 2,5,5,4,5,6,3,7,6]
dp = [(0, 0)] * (n + 1)
for i in range(n):
    if i > 0 and dp[i][0] == 0:
        continue
    k, _ = dp[i]
    for ai in a:
        if i + d[ai] <= n:
            dp[i+d[ai]] = max(dp[i+d[ai]], (k+1, ai))
ans = []
i = n
for _ in range(dp[n][0]):
    ans.append(str(dp[i][1]))
    i -= d[dp[i][1]]
print(''.join(ans))


Measured memory_bytes: 4304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  string s;
  int s_length;
  cin >> s;

  s_length = (int)(s.length());

  rep(i, s_length) {
    if(s[i]==',') {
      cout << ' ';
    }
    else {
      cout << s[i];
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a,b;
    cin >> a >> b;
    // スペース区切りの整数の入力
    int c = a * b;
    string s;
    if((c % 2) == 0){
      s = "Even";
    }else{
      s = "Odd";
    }
    // 出力
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF 1000000 
#define r 100 
#define c 100 
void matrixChainOrder(int p[]);
int n,m[r][c],p[100];

int main()
{
  int i;

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d%d",&p[i-1],&p[i]);	      

  matrixChainOrder(p);
  printf("%d\n",m[1][n]);

  return 0;
}

void matrixChainOrder(int p[])
{
  int i,j,k,l,q;

  for(i=1;i<n;i++) m[i][i]=0;
  
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(q<m[i][j]) m[i][j]=q;	  
      }
    }
  }
}

Measured memory_bytes: 636
n, x, y = map(int, input().split())

ans = [0 for i in range(n)]

for i in range(1, n+1):
    for j in range(i+1, n+1):
        if i <= x and j <= x:
            d = j-i
        elif i <= x and x < j <= y:
            d = min(j-i, x-i + y-j+1)
        elif i <= x and y < j:
            d = x-i + 1 + j-y
        else:
            d = min(j-i, i-x + 1 + abs(y-j))
        ans[d] += 1

for a in ans[1:]:
    print(a)


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<long> v;
long n,i,k,s;
int main() {
    cin >> n >> k;
    v.resize(n);
    for(i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(),v.end());
    s = 0;
    for(i = 0; i < k; i++) s += v[i];
    cout << s;
    return 0;
}

Measured memory_bytes: 3564
import bisect

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

cnt = 0
for i in range(n):
    cnt += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))
print(cnt)

Measured memory_bytes: 23092