akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long long,long long>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int ans = 0;
	int ans2 = 1;
	for (int i = 1; i <= n; i++) {
		int sum = 0;
		int tmp = i;
		while (tmp % 2 == 0) {
			sum++;
			tmp /= 2;
		}
		if (ans < sum) {
			ans = sum;
			ans2 = i;
		}
	}
	cout << ans2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;
    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }
    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }
    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }
    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }
    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }
    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)

int main() {
	ll N;
	cin>>N;
	vector<string> s(N);
	std::map<string, ll> map;
	rep(i,N){
		cin>>s[i];
		sort(all(s[i]));
		map[s[i]]++;
	}
	ll ans = 0;
	for(auto x: map){
		ans += x.second*(x.second-1)/2;
	}
	
	cout<<ans<<endl;
}

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

// MAX NIKAL LO USKO* 3 KRDO AND DIFFERENCE NIKAL LO CURRENT SUM SE 
// YE DIFF EVEN H TOH ACCORDINLY MOVE LGEGA , ODD H TOH ODD LGEGA

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    int x = max(a,max(b,c));
    if(x * 3 % 2 == sum % 2){
        cout << (x * 3 - sum) / 2 << endl;
    }else{
        cout << ((x+1) * 3 - sum) / 2 << endl; 
    }
    return 0;
}


Measured memory_bytes: 256
/*
***************************************************************************
 name  : ITP1_08_A.cpp
 title : Toggling Cases
 make  : 2018/08/29 tanabe
***************************************************************************
*/

// Library
#include <iostream> // standard input output object
#include <cstring>  // character functions

main(void){
  std::string str; // string
  int len;         // length
  int i;           // index

  std::getline(std::cin,str); // input "str"

  len = str.length(); // length of str

  // initialized i = 0
  // continue i < len
  // increment i at loop update
  for(i = 0;i < len;i++){
    if(std::isupper(str[i])){
      str[i] = std::tolower(str[i]); // convert to upper
    }
    else
    if(std::islower(str[i])){
      str[i] = std::toupper(str[i]); // convert to lower
    }
  }

  std::cout << str << std::endl; // output "str"

}



Measured memory_bytes: 3164
N,K=gets.split.map(&:to_i)
as=Array.new(100005,0)
N.times do |i|
  a,b=gets.split.map(&:to_i)
  as[a]+=b
end
res=0
cnt=0
100005.times do |i|
  cnt+=as[i]
  if K<=cnt
    puts i
    exit
  end
end

Measured memory_bytes: 2556
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

Measured memory_bytes: 3080
main = do
  li <- getLine
  let x = read li
  let ans = compute (abs x)
  print ans

{-
2に行くのに-3,+5とするよりは+2の方が早いように、
逆向きを交えて狙う必要は実はないのだと思われる。
つまり時刻nには1+...+n = n(n+1)/2まで進むことができて、
それより手前はいずれかを落とすことで必ず到達できる。（要証明）
差がn以下ならその数ズバリを落とせばいい。
なので、xをカバーする最小のnを計算で求める。
n(n+1)/2 >= x
n^2 + n - 2x >= 0
n = -1 +- sqrt(1 + 8x)/2
-}

compute :: Int -> Int
compute x = ceiling ((sqrt (fromIntegral x * 8 + 1) - 1) / 2)

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;
    if(a*b>a*c&&b*c>a*c)cout<<a*c/2<<endl;
    else if(a*c>a*b&&b*c>a*b)cout<<a*b/2<<endl;
    else if(a*b>b*c&&a*c>b*c)cout<<b+c/2<<endl;

    return 0;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		int k = int.Parse(input[2]);
		int[] a = new int[n];
		int[] b = new int[m];
		input = Console.ReadLine().Split(' ');
		for(int i=0; i<n; i++) a[i] = int.Parse(input[i]);
		input = Console.ReadLine().Split(' ');
		for(int i=0; i<m; i++) b[i] = int.Parse(input[i]);

		int read = 0;
		long readTime = 0;	
		while(read<n)
		{
			readTime += (long)a[read];
			if(readTime > (long)k)
			{
				readTime -= (long)a[read];
				break;
			}
			read++;
		}
		int readA = read;
		int readB = 0;
		while(readB<m)
		{
			readTime += (long)b[readB];
			if(readTime > (long)k)
			{
				readTime -= (long)b[readB];
				break;
			}
			readB++;
		}
		//Console.WriteLine(readA.ToString()+" "+readB.ToString());
		read += readB;
		for(int i=0; i<readA; i++)
		{
			readTime -= a[readA-1-i];
			while(readB<m)
			{
				readTime += (long)b[readB];
				if(readTime > (long)k)
				{
					readTime -= (long)b[readB];
					break;
				}
				readB++;
			}
			if(read < readA - 1 - i + readB) read = readA - 1 - i + readB;
		}
		Console.WriteLine(read);
	}
}



Measured memory_bytes: 67848
int main(void){
	int n;
	int i,j,k;
	int a[5000];
	int max,sum = 0;
	
	
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
			for(i = 0;i < n;i++){
				scanf("%d",&a[i]);
			}
			max = a[0];
			
			for(i = 0;i < n;i++){
				sum = 0;
				for(j = i;j < n;j++){
					sum += a[j];
					if(sum > max)max = sum;
				}
			}
			printf("%d\n",max);
	}
		
		
	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

#define INF (1<<30)

#define oper min
#define NEUT mp(INF,INF)
#define K 18

struct ST {
	pair<int,int> st[K][1<<K];int n;  // K such that 2^K>n
	void init(pair<int,int> *a, int _n){
		n=_n;
		fore(i,0,n)st[0][i]=a[i];
		fore(k,1,K)fore(i,0,n-(1<<k)+1)
			st[k][i]=oper(st[k-1][i],st[k-1][i+(1<<(k-1))]);
	}
	pair<int,int> query(int s, int e){
		int k=31-__builtin_clz(e-s);
		return oper(st[k][s],st[k][e-(1<<k)]);
	}
};

int n;
pair<int,int> v[2][200005];
ST w[2];

priority_queue<pair<int,pair<int,int> > > qq;
vector<int> r;

int main(){
	scanf("%d",&n);
	fore(i,0,n){
		int x;
		scanf("%d",&x);
		v[i%2][i]=mp(x,i);v[1-i%2][i]=NEUT;
	}
	w[0].init(v[0],n);w[1].init(v[1],n);
	qq.push(mp(-w[0].query(0,n).fst,mp(0,n)));
	while(!qq.empty()){
		auto _=qq.top();qq.pop();
		int s=_.snd.fst,e=_.snd.snd;
		auto p=w[s%2].query(s,e);r.pb(p.fst);
		auto q=w[1-s%2].query(p.snd+1,e);r.pb(q.fst);
		if(s<p.snd)qq.push(mp(-w[s%2].query(s,p.snd).fst,mp(s,p.snd)));
		if(p.snd+1<q.snd)qq.push(mp(-w[(p.snd+1)%2].query(p.snd+1,q.snd).fst,mp(p.snd+1,q.snd)));
		if(q.snd+1<e)qq.push(mp(-w[(q.snd+1)%2].query(q.snd+1,e).fst,mp(q.snd+1,e)));
	}
	assert(r.size()==n);
	fore(i,0,r.size()){
		if(i)putchar(' ');
		printf("%d",r[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 79784
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

  vector<int> p(N);
  for (int i = 0; i < N; ++i)
  {
    cin >> p[i];
  }

  sort(p.begin(), p.end());

  int sum = 0;
  for (int i = 0; i < K; ++i)
  {
    sum += p[i];
  }

  cout << sum;
}

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

int main() {
    int n, m;

    cin >> n >> m;
    vector<int> A(n);
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    int total = 0;
    for (int i=0; i < n; i++) {
        total += A[i]; 
    }

    string ret = "Yes";
    for (int i=0; i < m; i++) {
        //cout << "A" << A[i] << endl;
        //cout << "B" << (total / (4 * m)) << endl;
        //cout << "C" << (1 / (4 * 1)) << endl;
        //cout << "D" << total << endl;
        if( (double)A[i] < ((double)total / ((double)4 * (double)m))) {
            ret = "No";
            break;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			String s = "";
			int w = scanner.nextInt();
			int h = scanner.nextInt();
			Map<String, Page> map = new HashMap<String, Page>();
			while (n-- > 0) {
				String name = scanner.next();
				if (s.isEmpty())
					s = name;
				int b = scanner.nextInt();
				Button[] buttons = new Button[b];
				for (int i = 0; i < b; i++) {
					int sx = scanner.nextInt();
					int sy = scanner.nextInt();
					int ex = scanner.nextInt();
					int ey = scanner.nextInt();
					String to = scanner.next();
					buttons[i] = new Button(sx, sy, ex, ey, to);
				}
				map.put(name, new Page(buttons));
			}
			int m = scanner.nextInt();
			String[] buff = new String[m];
			buff[0] = s;
			int l = 0;
			int r = 1;
			while (m-- > 0) {
				String op = scanner.next();
				if (op.equals("click")) {
					int x = scanner.nextInt();
					int y = scanner.nextInt();
					String to = map.get(buff[l]).click(x, y);
					if (!to.isEmpty()) {
						buff[++l] = to;
						r = l + 1;
					}
				} else if (op.equals("back"))
					l = Math.max(0, l - 1);
				else if (op.equals("forward"))
					l = Math.min(r - 1, l + 1);
				else
					System.out.println(buff[l]);
			}
		}
	}

	class Button {
		int sx, sy, ex, ey;
		String to;

		public Button(int sx, int sy, int ex, int ey, String to) {
			super();
			this.sx = sx;
			this.sy = sy;
			this.ex = ex;
			this.ey = ey;
			this.to = to;

		}

		boolean isHit(int x, int y) {
			return sx <= x && x <= ex && sy <= y && y <= ey;

		}

	}

	class Page {
		Button[] buttons;

		public Page(Button[] buttons) {
			super();
			this.buttons = buttons;
		}

		String click(int x, int y) {
			for (Button b : buttons) {
				if (b.isHit(x, y))
					return b.to;
			}
			return "";
		}
	}
}

Measured memory_bytes: 26312
import numpy as np

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

a = np.array(a, dtype='int64')
MOD = 10**9+7
ans = 0
for i in range(60):
    ca = a >> i & 1
    c1 = int(ca.sum())
    c0 = n - c1
    c0c1 = (c0 * c1) % MOD
    c0c1pow = (c0c1 * 2**i) % MOD
    ans = (ans + c0c1pow) % MOD
print(ans)  

Measured memory_bytes: 68908
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float('inf')

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float('inf')
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float('inf')
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(' ')
        elif type(ls[0])==str:
            print(' '.join(ls))
        elif type(ls[0])==int:
            print(' '.join(map(str,ls)))
        else:
            print('Output Error')
    else:
        if len(ls)==0:
            print('')
        elif type(ls[0])==str:
            print(''.join(ls))
        elif type(ls[0])==int:
            print(''.join(map(str,ls)))
        else:
            print('Output Error')

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
a = RI()

ls = []
for i in range(n):
    if i%2==1:
        ls.append(a[i])
    else:
        ls.insert(0,a[i])

# print(ls)

if n%2==1:
    myoutput(ls)
else:
    ls.reverse()
    myoutput(ls)

Measured memory_bytes: 126480
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a, b, cnt = 0;
  cin >> a >> b;
  while (a * cnt - (cnt - 1) < b) ++cnt;
  cout << cnt;
}


Measured memory_bytes: 3672
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int K;
  int even = 0;
  int odd = 0;
  cin >> K;
  for(int i = 1; i <= K; i++){
    if(i%2==1)odd++;
    else even++;
  }

  cout << odd * even << endl;

  return 0;
}


Measured memory_bytes: 256
def abc_3() :
	H, W = map(int, input().split())
	print (min(div_3(H, W), div_3(W, H), div_s(H, W), div_s(W, H)))

def div_3(H, W) :
	if W % 3 == 0 :
		return 0
	else :
		return H

def div_s(H, W) :
	min_diff = 10000000000
	for w in range(1, W) :
		s1 = w * H
		s2 = (W - w) * (H // 2)
		s3 = W * H - s2 - s1
		diff = max(s1, s2, s3) - min(s1, s2, s3)
		if diff < min_diff :
			min_diff = diff
	return min_diff

#for i in range(5) :
#	abc_3()
#	print ('input:', end = '')
#	if input() == 'q' :
#		exit()

abc_3()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>

using namespace std;


int main() {
    int N;
    cin >> N;
    string stone;
    cin >> stone;

    vector<pair<int, int>> bw_cnt(N);
    for (int i = 1; i < N; i++) {
        bw_cnt[i].first = bw_cnt[i - 1].first;
        if (stone[i - 1] == '#')
            bw_cnt[i].first++;
    }
    for (int i = N-1; i >= 0; i--) {
        if (i == N - 1) {
            if (stone[i] == '.')
                bw_cnt[i].second++;
        }
        else {
            bw_cnt[i].second = bw_cnt[i + 1].second;
            if (stone[i] == '.')
                bw_cnt[i].second++;
        }
    }
    int ans = bw_cnt[N-1].first;
    if (stone[N - 1] == '#') ans++;
    
    for (int i = 0; i < N; i++) {
        int temp = bw_cnt[i].first + bw_cnt[i].second;
        ans = min(ans, temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n, m;
V<int> s, c;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    s.resize(m), c.resize(m);
    for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
    int maxn = 1;
    for (int i = 0; i < n; i++) maxn *= 10;
    int ans = -1;
    for (int i = (maxn == 10 ? 0 : maxn / 10); i < maxn; i++) {
        bool is_ok = true;
        string tmps = to_string(i);
        for (int j = 0; j < m; j++) {
            if (tmps[s[j] - 1] != '0' + c[j]) {
                is_ok = false;
                break;
            }
        }
        if (is_ok) {
            ans = i;
            break;
        }
    }
    cout << ans << '\n';
    return 0;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 200007;

int n,stk[_]={0},top=0;char s[_];

int main()
{
	n=ts(s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='T' && top && stk[top]=='S')top--;
		else stk[++top]=s[i];
	}
	printf("%d\n",top);

	return 0;
}


Measured memory_bytes: 1280
import math

class Vector:
    def __init__(self,x,y):
        self.x = x
        self.y = y
        
    def __add__(self,other):
        return Vector(self.x+other.x,self.y+other.y)
    
    def __sub__(self,other):
        return Vector(self.x-other.x,self.y-other.y)
    
    def __mul__(self,scalar):
        return Vector(self.x*scalar,self.y*scalar)
    def __rmul__(self, scalar):
        return Vector(self.x*scalar,self.y*scalar)
   
    def __repr__(self):
        return str([self.x,self.y])
        
    def norm_2(self):
        return dot(self,self)
    
    def norm(self):
        return math.sqrt(self.norm_2())
    
def v_sum(v1,v2):
    return Vector(v1.x+v2.x,v1.y+v2.y) 
def scalar_multi(k,v):
    return Vector(k*v.x,k*v.y)
def v_diff(v1,v2):
    return v_sum(v1,scalar_multi(-1,v2))
    
def dot(vector1,vector2):
    return vector1.x*vector2.x+vector1.y*vector2.y

def cross(vector1,vector2):
    return vector1.x*vector2.y-vector1.y*vector2.x

def is_crossed(p,q,s,t):
    a = q-p
    b = t-s
    v = s-p
    w = t-p
    x = p-s
    y = q-s
    if cross(a,v)*cross(a,w)<=0 and cross(b,x)*cross(b,y)<=0:
        if cross(a,v) == cross(a,w) == cross(b,x) == cross(b,y) == 0:
            if 0<=dot(a,v)<=a.norm_2() or 0<=dot(a,w)<=a.norm_2()  or 0<=dot(b,x)<=b.norm_2() or 0<=dot(b,y)<=b.norm_2():
                return True
            else:
                return False
        else:    
            return True
    else:
        return False
        
q = int(input())
for i in range(q):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(int,input().split())
    p1 = Vector(x1,y1)
    p2 = Vector(x2,y2)
    p3 = Vector(x3,y3)
    p4 = Vector(x4,y4)
    
    if is_crossed(p1,p2,p3,p4):
        print(1)
    else:
        print(0)


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

signed main(){
    ll N; cin>>N;
    vector<ll> a(N); 
    rep(i,N) cin>>a[i];
    ll ans=-1;
    map<ll,ll>cnt;
    for(auto x:a){
        cnt[x]++;
        cnt[x+1]++;
        cnt[x-1]++;
    }
    rep(i,N){
        ans=max(cnt[i],ans);
    }
    if(N==1)cout<<1<<endl;
    else cout<<ans<<endl;

}

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

// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define pi acos(-1)
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.141592653589793//23846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)

#define local
#ifdef local
#endif

#define MAX 10233
#define LCH(i) ((i) << 1)
#define RCH(i) ((i) << 1 | 1)
inline ll read(){
   ll s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
const int N = 2e5+5;
ll c[N];
struct mon
{
        ll x,h;
};
mon monster[N];
bool cmp(mon a, mon b)
{
    return a.x < b.x;
}
int main()
{
    //ios::sync_with_stdio(false);cin.tie(NULL);
   // cout << 50ll << endl;
    ll n, d, a;
    n = read();
    d = read();
    a = read();
    for (int i = 0; i < n; i++)
    {
        monster[i].x = read();
        monster[i].h= read();
    }
    sort(monster, monster + n,cmp);
    ll ans = 0;
    for (int i = 0,j = 0; i < n; i++)
    {
        while(j < n && monster[j].x <=monster[i].x + 2*d)
            ++j;
        ll need = max((monster[i].h - c[i]*a + a - 1)/a, 0ll);
        ans += need;
        c[i] += need;
        c[j] -= need;
        c[i+1] += c[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 4992
n = int(input())
edges = [tuple(map(int, input().split())) for _ in range(n-1)]

connects = [[] for i in range(n+1)]
for e in edges:
    connects[e[0]].append(e[1])
    connects[e[1]].append(e[0])

x = max([len(i) for i in connects])
print(x)

from collections import deque
nodeQ = deque([1])
begin = {1: 0}
ecolors = {}

while len(nodeQ):
    node = nodeQ.popleft()
    ncolor = begin[node]
    nconnect = list(filter(lambda n: n > node, connects[node]))
    
    for i, ni in enumerate(nconnect):        
        begin[ni] = (ncolor + i) % x + 1
        ecolors[(node, ni)] = begin[ni]
        # print(node, ni, begin[ni])
        nodeQ.append(ni)
             
for e in edges:
    print(ecolors[e])

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main() {
  int A, B;
  cin >> A >> B;
  if(A % 2 == 1 && B % 2 == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> button(n);
 
  for(int i=0;i<n;i++){
    cin >> button.at(i);
  }
  
  for(int i=0,count=0,a=0;count<n;i=a-1,count++){
    a = button.at(i);
    if(button.at(i) ==2){
      cout << count+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var cnt = 0
    for (i in 1..n) {
        if (i < 10) cnt++
        else if (i in 100..999) cnt++
        else if (i in 10000..99999) cnt++
    }
    println(cnt)
}

Measured memory_bytes: 29780
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict

def solve():
    n, m = map(int, input().split())
    al = [int(i) for i in input().split()]
    bl = [0]*n
    d = defaultdict(int)
    for i in range(n):
        bl[i] = (al[i] + bl[max(0, i - 1)]) % m
        d[bl[i]] += 1
    ans = 0
    for k, v in d.items():
        if k == 0:
            v = v + 1
        ans += v * (v - 1) // 2
    print(ans) 

if __name__=="__main__":
    solve()

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

int main(){
//srandom((unsigned long)time(NULL));

string s;
cin>>s;
int a,b,c,d;
a=(int)s[0]-48;
b=(int)s[1]-48;
c=(int)s[2]-48;
d=(int)s[3]-48;
//cout<<a<<b<<c<<d<<endl;
int pd=a;
for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
        for(int k=0;k<2;k++){
            pd=a;
            if(i==0)pd+=b;
            if(i==1) pd-=b;
            if(j==0)pd+=c;
            if(j==1) pd-=c;
            if(k==0)pd+=d;
            if(k==1) pd-=d;

            if(pd==7){
                cout<<a;
            if(i==0)cout<<"+"<<b;
            if(i==1) cout<<"-"<<b;
            if(j==0)cout<<"+"<<c;
            if(j==1) cout<<"-"<<c;
            if(k==0)cout<<"+"<<d<<"=7"<<endl;
            if(k==1) cout<<"-"<<d<<"=7"<<endl;
            return 0;
            }
        }
    }
}



return 0;
}

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

int main(){
  string x;
  cin >> x;
  int count=1;
  if(x.at(0)=='S'&&x.at(1)=='S'&&x.at(2)=='S'){
    count=0;
  }
  else if(x.at(0)=='R'&&x.at(1)=='R'){
    count=2;
      if(x.at(0)=='R'&&x.at(1)=='R'&&x.at(2)=='R'){
        count=3;
      }
  }
  else if(x.at(1)=='R'&&x.at(2)=='R'){
    count=2;
  }

  
  cout << count <<endl;
}

Measured memory_bytes: 3632
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

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

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

  ll n;
  std::cin>>n;

  std::vector<std::string> s(n);
  std::vector<ll> len(n);

  rep(i,0,n){
    std::cin>>s[i]>>len[i];
  }

  std::string x;
  std::cin>>x;

  ll temp=-1;
  rep(i,0,n){
    if(s[i]==x){
      temp=i;
      break;
    }
  }

  ll ans=0;

  rep(i,temp+1,n){
    ans+=len[i];
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


int main(){
    int n; cin >> n;
    string s; cin >> s;
    
    int w[n+10];
    w[0] = 1;
    for (int i=0; i < n; i++) {
        w[i+1] = w[i] + (s[i] == 'W' ? 1 : 0);
    }
    
    int res = n;
    for(int i=0 ; i<=n ; i++){
        int left = w[i]-w[0];
        int right = n-i-(w[n]-w[i]);
        
        int sum = left+right;
        
        res = min(res,sum);
    }
    
    cout << res << endl;
}







Measured memory_bytes: 1796
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

long long int mod = 1000000007;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    b--;
    d--;
    if(a > d || c > b){
        cout<<0<<endl;
    }else{
        cout<<min(b,d) - max(a,c) + 1<<endl;
    }
}


Measured memory_bytes: 256
# AOJ 0501: Data Conversion
# Python3 2018.6.29 bal4u

while True:
	n = int(input())
	if n == 0: break
	tbl = {}
	for i in range(n):
		a, b = input().split()
		tbl[a] = b
	ans = ''
	m = int(input())
	for i in range(m):
		a = input()[0]
		ans += tbl[a] if a in tbl else a
	print(ans)


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

int find(int n){
int X =0;
while(n>0){
X+=n%10;
n/=10;
}
return X;
}

int main(){
int A,B,N;
cin>>N>>A>>B;
int sum=0;
for(int i =1;i<=N;i++){
int X = find(i);
if(X >=A&&X<=B){
sum +=i;
}
}
cout<<sum<<endl;
}


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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int n;
string s;
set<string> st;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n;
    int cnt = 0;
    forn(i, n) {
        cin >> s;
        if (st.find(s) == st.end()) {
            ++cnt;
            st.insert(s);
        }
    }
    cout << cnt << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 19248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  ll a,b,v,w,t;
  cin>>a>>v>>b>>w>>t;
  ll k=llabs(a-b);
  ll l=v-w;
  if(a==b || l>0&&(k+l-1)/l<=t){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return(0);
}


Measured memory_bytes: 3640
#include <stdio.h>
#include<stdlib.h>
int cmp ( const void *a , const void *b )
{
return *(int *)a - *(int *)b;
}
int main()
{
    int n,m,i,sum=0,t,k,z=0;
    int a[101];
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum=sum+a[i];
    }
    qsort(a,n,sizeof(a[0]),cmp);
    for(k=n-1;k>n-1-m;k--)
    {
        t=4*m*a[k];
        if(sum>t)
            z=1;
    }
    if(z==0)
        printf("Yes");
    else
        printf("No");

    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];

		for(int i=0; i<n; i++){
			a[i] = in.nextInt();
			b[i] = in.nextInt();
		}
		long plus = 0;
		long temp = 0;
		for(int i=n-1; i>=0; i--){
			temp = a[i]+plus;
			if(temp%b[i]!=0){
				plus += b[i]*(temp/b[i]+1) - temp;
			}

		}

		System.out.println(plus);
	}

}


Measured memory_bytes: 78824
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String test = "0";
        while(true) {
            String str = sc.nextLine();
            int sum =0;
            if(str.equals(test))break;
            for(int i=0;i<str.length();i++){
            	sum+=Integer.parseInt(String.valueOf(str.charAt(i)));
            }
            if(sum!=0)System.out.println(sum);
        }
        sc.close();
    }
}



Measured memory_bytes: 26860
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    int a,b,c;

    cin >> a >> b >> c;

    if((a * 100 + b * 10 + c) % 4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm> 
using namespace std;
int main(){
	int n,t=0;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);//1 2 3 4
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	for(int k=j+1;k<=n;k++){

		if((a[i]+a[j])>a[k] && (a[i]+a[k])>a[j] && (a[k]+a[j])>a[i])
		t++;
	} 
	cout<<t;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll a, b, c, d, x;
    cin >> a >> b >> c >> d >> x;
    x *= 100;
    ll ans = 0;
    if(x >= 200){
        ll k = x / 200;
        ans += min({k*d, k*2*c, k*4*b, k*8*a});
        x %= 200;
    }
    if(x >= 100){
        ll k = x / 100;
        ans += min({k*c, k*2*b, k*4*a});
        x %= 100;
    }
    if(x >= 50){
        ll k = x / 50;
        ans += min({k*b, k*2*a});
        x %= 50;
    }
    ans += x*a;
    cout << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

type AB struct {
	a, b int
}

var N, M int
var ans int

func main() {
	fmt.Scan(&N, &M)
	m := make(map[AB]int)

	for i := 0; i < M; i++ {
		var a int
		fmt.Scan(&a)
		var b int
		fmt.Scan(&b)

		m[AB{a, b}]++
		m[AB{b, a}]++
	}
	var used = [10]bool{}
	used[1] = true

	dfs(1, 1, used, m)
	fmt.Println(ans)
}
func dfs(n int, now int, used [10]bool, m map[AB]int) {

	if n == N {
		ans++
	} else {
		for i := 1; i <= N; i++ {
			if !used[i] && m[AB{now, i}] != 0 {
				used[i] = true
				dfs(n+1, i, used, m)
				used[i] = false
			}
		}
	}
}

/*  ----------------------------------------  */
func lcm(x, y uint64) uint64 {
	return (x / gcd(x, y)) * y
}

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(2500)
w,h = map(int,input().split())
while not(w==h==0):
    m = [[0]*(w+2)]
    m += [[0]+list(map(int,input().split()))+[0] for i in range(h)]
    m += [[0]*(w+2)]
    g = [[] for i in range(w*h)]
    for i in range(1,h+1):
        for j in range(1,w+1):
            if m[i][j]==1:
                for k in [-1,0,1]:
                    for l in [-1,0,1]:
                        if m[i+k][j+l]==1:
                            g[(i-1)*w+j-1].append((i+k-1)*w+j+l-1)
    reach = [False]*(w*h)
    def dfs(v):
        reach[v] = True
        for i in g[v]:
            if not reach[i]:
                dfs(i)
    ans = 0   
    for i in range(h*w):
        if g[i] and not reach[i]:
            ans += 1
            dfs(i)

    print(ans)

    w,h = map(int,input().split())



Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
int n,a[100005][3],f[100005][3];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
	for(int i=1;i<=n;i++)
	{
		f[i][0]=max(f[i-1][1],f[i-1][2])+a[i][0];
		f[i][1]=max(f[i-1][0],f[i-1][2])+a[i][1];
		f[i][2]=max(f[i-1][0],f[i-1][1])+a[i][2];
		//printf("f(%d)=(%d,%d,%d)\n",i,f[i][0],f[i][1],f[i][2]);
	}
	printf("%d\n",max(max(f[n][0],f[n][1]),f[n][2]));
	return 0;
}

Measured memory_bytes: 2560
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, C = list(map(int, sys.stdin.readline().split()))
    B = list(map(int, sys.stdin.readline().split()))
    A = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

    ret = 0
    for n in range(N):
        k = C
        for m in range(M):
            k += A[n][m] * B[m]

        if k > 0:
            ret += 1

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#define N 100


int main()
{
  int i,j,num,count=0,flag,data[N],change;

  scanf("%d",&num);

  for(i = 0 ; i < num ; i++)
    {
      scanf("%d",&data[i]);
    }

  flag =  1;
  while(flag)
    {
      flag = 0;
      for(j = num -1 ; j >= 1 ; j--)
	{
	  if(data[j] < data[j-1])
	    {
	      change = data[j];
	      data[j] = data[j-1];
	      data[j-1] = change;
	      flag = 1;
	      count++;

	    }
	}

    }
  for(i = 0 ; i < num ; i++)
    {
      printf("%d",data[i]);
      if(i != num-1)printf(" ");
      

    }

  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	string ans = "Yes";
	int sum = 0;
	string n;
	cin >> n;
	for (int i = 0; i < n.size(); i++) {
		sum += (int)(n[i] - '0');
	}

	if (stoi(n) % sum != 0)  ans = "No";



	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
#define INF 100000000
#define MOD 1000000007
using namespace std;



int main(){
    char a[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> a[i][j];
        }
    }
    for(int i=0; i<3; i++){
        cout<<a[i][i];
    }
    cout<<endl;
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K,Q;
int P[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>Q;
	FOR(i,N) P[i+1]=K-Q;
	FOR(i,Q) {
		cin>>x;
		P[x]++;
	}
	FOR(i,N) {
		if(P[i+1]>=1) _P("Yes\n");
		else _P("No\n");
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100009];
ll n,x;
vector<ll>v;
ll frog(ll pos)
{
    if(pos<=0)
        return 0;
    if(pos==1)
        return abs(v[0]-v[1]);
        if(dp[pos]==-1)
        {
            dp[pos]= min(abs(v[pos]-v[pos-1])+frog(pos-1),abs(v[pos]-v[pos-2])+frog(pos-2));
        }
    return dp[pos];
}

int main()
{
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(ll i=0; i<n; i++)
    {
        cin>>x;
        v.push_back(x);
    }
    cout<<frog(n-1)<<endl;
}


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

int main(){
	int n; cin >> n;
	set<int> s;
	for(int i = 0; i < n; ++i){
		int a; cin >> a;
		if(s.find(a) == s.end()) s.insert(a);
		else s.erase(a);
	}
	cout << s.size() << endl;
	return 0;
}

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

using namespace std;

bool ok(int n)
{
    for (int i = 1; i <= 9; ++i)
    {
        for (int j = 1; j <= 9; ++j)
        {
            if (n == i * j)
                return true;
        }
    }
    return false;
}

int main(void)
{

    int n;
    cin >> n;

    cout << (ok(n) ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  char c;
  cin >> c;
  cout << char(c + 1) << endl;  


  return 0;
}


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

int main()
{
  string s;
  cin >> s;
  
  if (s == "Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  
  return 0;
}

Measured memory_bytes: 256