akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int G[209][209];
vector<int> town;

void warshallFloyd(int n){
    
    int range=n;
    
    for(int k=1; k<=range; k++ ){
        for(int i=1; i<=range; i++ ){
            if(G[i][k]==INF) continue;
            for(int j=1; j<=range; j++ ){
                if(G[k][j]==INF) continue;
                if(G[i][j] > G[i][k]+G[k][j] ) G[i][j] = G[i][k]+G[k][j];
            }
        }
    }
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    
    rep1(i,N)rep1(j,N) G[i][j] = INF;
    
    rep(i,R){
        int t;
        cin >> t;
        town.push_back(t);
    }
    
    rep(i,M){
        int a, b, c;
        cin >> a >> b >> c;
        G[a][b] = c;
        G[b][a] = c;
    }
    
    warshallFloyd(N);
    
    ll ans=INF;
    sort(town.begin(),town.end());
    do{
        ll sum=0;
        //for(auto x : town) cout << x << " "; cout << "\n";
        for(int i=1; i<town.size(); i++){
            //cout2(town[i-1],town[i]);
            sum += G[ town[i-1] ][ town[i] ];
        }
        ans = min(ans,sum);
    }while( next_permutation(town.begin(), town.end()) );
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  ll N;
  cin >> N;
  string s = "";
  for (int i = 1;; i++)
  {
    if (N <= ll(pow(26, i)))
    {
      N--;
      for (int j = 0; j < i; j++)
      {
        s += 'a' + N % 26;
        N /= 26;
      }
      break;
    }
    else
    {
      N -= ll(pow(26, i));
    }
  }
  for (int i = s.length() - 1; i >= 0; i--)
  {
    cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4076
import std.string;
import std.stdio;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
  auto a=readln.split.to!(int[]),a1=a[0],a2=a[1],a3=a[2];
  auto b=sort(a);
  writeln((b[2]-b[1])+(b[1]-b[0]));
}  


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
b = list(map(int,input().split()))

ans = 0
for i in range(0,N):
    flag = True
    for t in range(0,i):
        #print(t)
        if b[t] > b[i]:
            flag = False
            break
    if flag == True:
        ans += 1

print(ans)

Measured memory_bytes: 3060
package main

import (
    "fmt"
)

func main() {
    var H int = scanInt()
    var W int = scanInt()
    var h int = scanInt()
    var w int = scanInt()
    fmt.Println(H * W - h * W - w * H + h * w)
}

func scanInt() (num int) {
    fmt.Scan(&num)
    return
}

func scanInts(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanString() (str string) {
    fmt.Scan(&str)
    return
}

func scanStrings(len int) (strs []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scan(&str)
        strs = append(strs, str)
    }
    return
}

Measured memory_bytes: 512
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int n,k,l[51];
	cin>>n>>k;
	for(int i=0;i<n;++i){
		cin>>l[i];
	}
	sort(l,l+n,greater<int>());
	int a=0;
	for(int i=0;i<k;++i){
		a+=l[i];
	}
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 256
m = [[0, 4, 8, 12, 3, 7, 11, 2, 6, 10],[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],[0, 10, 7, 4, 1, 11, 8, 5, 2, 12],[0, 9, 5, 1, 10, 6, 2, 11, 7, 3],[0, 12, 11, 10, 9, 8, 7, 6, 5, 4],[0, 3, 6, 9, 12, 2, 5, 8, 11, 1]]
S = list(input())
d = len(S)
dp = [[0] * 13 for _ in range(d)]
if S[0] == '?':
    for x in m[d%6]:
        dp[0][x] = 1
else:
    dp[0][m[d%6][int(S[0])]] = 1
for i in range(1,d):
    if S[i] == '?':
        for j in range(13):
            dp[i][j] = sum(dp[i-1][(13+j-x) % 13] for x in m[(d-i)%6]) % 1000000007
    else:
        for j in range(13):
            dp[i][j] = dp[i-1][(13+j-m[(d-i)%6][int(S[i])])%13]
print(dp[d-1][5])

Measured memory_bytes: 65016
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int p[1001];	p[0]=0;
		for(int i=1;i<=n;i++)	scanf("%d",p+i);

		int nn=0;
		static int xp[1001*1001];
		for(int i=0;i<=n;i++)for(int j=i;j<=n;j++)	xp[nn++]=p[i]+p[j];
		sort(xp,xp+nn);

		int maxscore=0;
		for(int i=0;i<nn;i++){
			if(m-xp[i]>=0)
				maxscore=max(maxscore,xp[i]+upper_bound(xp,xp+nn,m-xp[i])[-1]);
		}
		printf("%d\n",maxscore);
	}

	return 0;
}

Measured memory_bytes: 2716
N, K = map(int, input().split())

if K > (N - 1) * (N - 2) // 2:
    print(-1)
    exit()

# N を中心とするスターグラフ
uvs = [(i, N) for i in range(1, N)]

to_decrease = (N - 1) * (N - 2) // 2 - K
for i in range(1, N):
    for j in range(i+1, N):
        if to_decrease == 0:
            break
        uvs.append((i, j))
        to_decrease -= 1
    else:
        continue
    break

print(len(uvs))
for u, v in uvs:
    print(u, v)

Measured memory_bytes: 74028
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var N, K int
	N, _ = strconv.Atoi(next())
	K, _ = strconv.Atoi(next())
	
	res := 1
	for i := 0; i < N; i++ {
		if res < K {
			res *= 2
		} else {
			res += K
		}
	}
	fmt.Println(res)
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
	string s;
	int num,id;
}a[100];
bool cmp(node a,node b){
	if(a.s!=b.s)
		return a.s<b.s;
	return a.num>b.num;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i].s>>a[i].num;
		a[i].id=i;
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;++i)
		cout<<a[i].id+1<<endl;
	return 0;
}

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

#define pan(i,n) for(ll i=0;i<n;i++)
#define pans(i,n,a) for(ll i=a;i<n;i++)
#define ll long long int
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 200007
#define P pair<ll,ll>

using namespace std;

ll power(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;  
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0)  
    { 
        if (y & 1)  
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;  
    }
    return res;  
}  

int main(){
    ll n;
    cin>>n;
    vi v(n),a(n,0);
    pan(i,n){
        cin>>v[i];
        a[v[i]]++;
    }
    bool flag=true;
    ll count=(n%2==1 && a[0]==1) ? 1:0;
    // cout<<"count :: "<<count<<endl;
    for(ll i=n%2+1;i<n;i+=2){
        count+=(a[i]==2) ? 1:0;
    }
    // cout<<count<<endl;
    if(n%2==1){
        if(count==(n/2)+1) cout<<power(2,n/2,INF);
        else cout<<0;
    }
    else{
        if(count==(n/2)) cout<<power(2,n/2,INF);
        else cout<<0;
    }

}

Measured memory_bytes: 1792
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val H = input.nextInt()
    val A = input.nextInt()
    val attackCount = H / A + if (H % A > 0) 1 else 0
    
    println(attackCount)
  }
}

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

const int maxn=3000+999;
int n,ans,p,f[maxn],g[maxn][maxn],C[maxn][maxn];

int poww(int a,int b,int p){
	int ans=1;
	while(b){
		if(b&1)ans=ans*a%p;b>>=1;a=a*a%p;
	}
	return ans;
}
signed main(){
	cin>>n>>p;
    for(int i=0;i<=n;++i){
        C[i][0]=g[i][0]=1;
        for(int j=1;j<=i;++j) 
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%p,
            g[i][j]=(g[i-1][j-1]+(j+1)*g[i-1][j]%p)%p;
    }
    for(int i=0;i<=n;++i){
        int tmp=poww(2,poww(2,n-i,p-1),p),num=poww(2,n-i,p),now=1,sum=0;
        for(int j=0;j<=i;++j)sum=(sum+g[i][j]*now%p)%p,now=now*num%p;
        ans=((ans+(((i&1)?p-C[n][i]:C[n][i])*tmp%p)*sum%p)%p+p)%p;
    }
	cout<<ans;
}

Measured memory_bytes: 186880
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  while (n--) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  int64 ret = 0;
  for (auto& it : cnt) {
    int x = it.first, y = it.second;
    ret += (y >= x ? y - x : y);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
char st;
long long n,m,zs,s;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=n;i++)
      {
      	cin>>st;
	    if (st>='0'&&st<='9') 
	      zs++;
	  }
	if (zs!=n) {cout<<"No"<<endl;return 0;}
	cin>>st;
	if (st!='-') {cout<<"No"<<endl;return 0;}
	zs=0;
	for (int i=1;i<=m;i++)
      {
      	cin>>st;
	    if (st>='0'&&st<='9') 
	      zs++;
	  }
	if (zs!=m) {cout<<"No"<<endl;return 0;}
	cout<<"Yes"<<endl;
    return 0;
}

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

int main() {
    char x;
    int s_count = 0;
    int res = 0;
    while (cin >> x) {
        if (x == 'S') {
            s_count++;
        } else if (x == 'T') {
            if (s_count > 0) {
                s_count--;
            } else {
                res++;
            }
        }
    }
    cout << res + s_count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string str;
bool dp[210000];
string judge [4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
  while (cin >> str) {
	memset(dp, 0, sizeof(dp));
	dp[0] = true;
	for (int i = 0; i < str.size(); ++i) {
	  if (!dp[i]) continue;
	  for (int j = 0; j < 4; ++j) {
		if (str.substr(i, judge[j].size()) == judge[j])
		  dp[i + judge[j].size()] = true;
	  }
	}
	if (dp[str.size()]) puts("YES");
	else puts("NO");
  }
}
		  
	  


Measured memory_bytes: 640
n = int(input())

o = 0

for i in range(n):

  m = "True"

  a = int(input())

  b = a**0.5

  if a == 2 or a == 3 or a == 5 or a == 7:
    m = "True"

  elif a%2 == 0:
    m = "False"

  else:
    j = 3
    while j <= b:
      if a%j == 0:
        m = "False"
        break
      else:
        j += 1
  if m == "True":
    o += 1

print(o)


Measured memory_bytes: 5704
import math
import os
n = int(input())
i = 3
data = [2]
if n is 2:
  print(n)
else:
  while True:
    flag = True
    for d in data:
      if d > math.sqrt(i):
        break
      elif i % d == 0:
        flag = False
        break
    if flag:
      if i >= n:
        break
      data.append(i)
    i += 2
  print (i)

Measured memory_bytes: 3316
import java.io.IOException;
import java.util.BitSet;
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;
			boolean[][] map = new boolean[n][31];
			for (int i = 0; i < n; i++) {
				int f = scanner.nextInt();
				while (f-- > 0)
					map[i][scanner.nextInt()] = true;
			}
			int ans = -1;
			BitSet[] bit = new BitSet[n];
			for (int i = 0; i < n; i++) {
				bit[i] = new BitSet();
				bit[i].set(i);
			}
			for (int t = 1; t <= 30; t++) {
				BitSet tmp = new BitSet();
				for (int i = 0; i < n; i++)
					if (map[i][t]){
						tmp.or(bit[i]);
						
					}
				if (tmp.cardinality() == n) {
					ans = t;
					break;
				}
				for (int i = 0; i < n; i++)
					if (map[i][t])
						bit[i] = tmp;

				
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 68808
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;

int main() {
  int64_t A, B, C;
  cin >> A >> B >> C;
  if (A+B+1>=C) {
    cout << B+C << endl;
  }
  else {
    cout << A+2*B+1 << endl;
  }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep3(i, a, b) for (ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok ? "Yes" : "No");
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll, ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
// clang++ -std=c++11 -stdlib=libc++

int N, K;
int main() {
  cin >> N >> K;
  vll h(N);
  rep(i, N) cin >> h[i];
  sort(all(h));
  ll ans = LINF;
  for (int i = 0; i + K - 1 < N; i++) {
    chmin(ans, h[i + K - 1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  string A = S;

  string ans = "No";

  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < S.size(); j++) {
      if (i + j >= S.size()) S.at(j) = A.at(i + j - S.size());
      else S.at(j) = A.at(i + j);
    }
    if (S == T) ans = "Yes";
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#素因数分解、計算量はO(√N)
from collections import defaultdict
def factorize(n):
  b = 2
  dic = defaultdict(lambda: 0)
  while b * b <= n:
    while n % b == 0:
      n //= b
      dic[b] += 1
    b = b + 1
  if n > 1:
    dic[n] += 1
  return dic
N = int(input())
fct = factorize(2*N)
lis = []
for k,v in fct.items():
  lis.append(pow(k,v))
lis.sort(reverse=True)
ans = 10**18
from itertools import groupby, accumulate, product, permutations, combinations
for pro in product([1,0],repeat=len(lis)):
  prod1 = 1
  for i,p in enumerate(pro):
    if p==1:
      prod1 *= lis[i]
  prod2 = (N*2)//prod1
  if prod1<prod2:
    # prod1,prod2 = prod2,prod1
    continue
  for i in range(1,prod2+1):
    if prod1*i>ans:
      break
    if (prod1*i-1)%prod2==0:
      ans = min(ans, prod1*i-1)
      break
    if (prod1*i+1)%prod2==0:
      ans = min(ans, prod1*i)
      break
print(ans)



Measured memory_bytes: 68812
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if((s[0]==s[1])&&(s[1]==s[2]))
	{
		cout<<"No"<<"\n";
	}
	else
	{
		cout<<"Yes"<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3620
x = int(input())

a = 1
b = 0

def val():
    global a, b
    if pow(a,5) - pow(-b,5) == x:
        b = -b
        return True
    return pow(a,5) - pow(b,5) == x

while not val():
    if a >= b:
        b += 1
    else:
        a += 1
        b = 0
print(a,b)


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

using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pback pop_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vis vector<string>
#define vii vector<vector<int>>
#define mii map<int, int>
#define umii unordered_map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi,greater<int>>
#define setbits(x) __buitin_popcountll(x)
#define zrobits(x) __buitln_ctzll(x)
#define mod 1000000007 //1e9+7
#define inf 1e18
#define ps(x,y) fixed<<setpresicion(y)<<x
#define mk(arr,n,type) type *arr=new type[n]
#define w(x) int x;cin>>x; while(x--)
#define rg 1000005
#define deg(v) cout<<"Value is: "<<v<<endl
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(a,b) for(int i=a;i<b;i++)
#define frev(a,b) for(int i=(int)a;i>(int)b;--i)
//mt19937  ring(chrono: stready_clock::now().time_since_epoch().count)


void IO() {


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

class Graph {

	int v;
	list<int> *l;
	int MX = INT_MIN;
public:
	void init(int _v) {
		v = _v + 1;
		l = new list<int>[v];
	}

	void addEdge(int u, int v) {
		l[u].push_back(v);
	}

	void print() {

		for (int i = 1; i < v; i++) {
			for (auto node : l[i]) {
				cout << node << " ";
			}
			cout << endl;
		}
	}

	void traverseThroughAllEdges() {

		bool *visited = new bool[v];
		int *dp = new int[v];

		for (int i = 0; i < v; i++) {
			visited[i] = false;
			dp[i] = 0;
		}

		for (int vertex = 1; vertex < v; vertex++) {

			if (!visited[vertex]) {
				int totalEdges = dfs(vertex, dp, visited);
				//cout << totalEdges << " ";

				MX = max(MX, totalEdges);
			}
		}

	}

	int dfs(int currVertex, int *dp, bool *visited) {

		visited[currVertex] = true;
		//int edges = 0;
		int maxi = 0;
		for (auto node : l[currVertex]) {

			if (!visited[node]) {

				int countEdges = dfs(node, dp, visited);
				//edges = countEdges + 1;
				maxi = max(maxi, countEdges + 1);
			}
			else {
				// edges = dp[node] + 1;
				maxi = max(maxi, dp[node] + 1);
			}
		}
		dp[currVertex] = maxi ;
		return dp[currVertex];
	}

	int maxEdges() {
		return MX;
	}
};

int32_t main() {

	FASTIO;
	//IO();

	int v, e; cin >> v >> e;

	Graph g;

	g.init(v);

	for (int edge = 0; edge < e; edge++) {
		int u, v; cin >> u >> v;
		g.addEdge(u, v);
	}
	//g.print();
	g.traverseThroughAllEdges();
	cout << g.maxEdges() << endl;

	return 0;
}


Measured memory_bytes: 13312
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	int n;
	cin >> n;
	if (n == 3 || n == 5 || n == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    if(n>=1000) {
      System.out.println("ABD");
    } else {
      System.out.println("ABC");
    }
  }
}

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

int main() {
  int n; cin >>n;
  map<ll, ll> mp;
  rep(i,n){
    int a; cin >>a;
    mp[a]++;
  }
  vector<ll> rec;
  for(auto x : mp){
    if(x.second>=2) rec.push_back(x.first);
    if(x.second>=4) rec.push_back(x.first);
  }
  if(rec.size()<2) cout << 0 << endl;
  else cout << (ll)rec[rec.size()-1]*rec[rec.size()-2] << endl;
  return 0;
}

Measured memory_bytes: 9684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int lcm(int x, int y){
	int g = gcd(x,y);
	return x/g*y;
}

int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum = (sum%MOD*i%MOD)%MOD;
    }
    return sum;
}

int main(){
	int n; cin >> n;
	int s = 0, m = MOD;
	rep(i,n){
		int a; cin >> a;
		s += a;
		if (a%10){
			m = min(m,a);
		}
	}
	if (s%10){
		cout << s << endl;
	}else{
		if (m == MOD){
			cout << 0 << endl;
		}else{
			cout << s - m << endl;
		}
	}
}

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

struct player {
	int number;
	int out;
};

int main(void) 
{
	struct player *p;
	int n, m;
	int count, rest;
	int i;

	while (scanf("%d %d", &n, &m), !(n == 0 && m == 0)) {
		p                = (struct player *) malloc(sizeof(struct player) * (n + 1));
		count            = 0;
		rest             = n;

		for (i = 0; i <= n; i++) {
			p[i].number = i;
			p[i].out    = 0;
		}

		while (rest > 1) {
			for (i = 1; i <= n; i++) {
				if (p[i].out == 0) {				   
					count++;

					if (count % m == 0) {				   
						p[i].out = 1;						
						rest--;
					}

					if (rest == 1) 
						break;
				}
			}
		}

		for (i = 1; i <= n; i++) 
			if (p[i].out == 0) 
				printf("%d\n", p[i].number);

		free(p);
	}

	return 0;
}

Measured memory_bytes: 604
//doaremon,squirtle is love
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define testcase ll t;cin>>t;while(t--)
#define in(x) ll x;cin>>x;
#define output(x) cout<<x<<endl;//to print (-1)
#define inputarray() ll n;cin>>n;ll arr[n];rep(0,n)cin>>arr[i];
#define deb(a) cout<<" :: "<<#a<<" = "<<a<<endl
#define deb2(a,b) cout<<" :: "<<#a<<" = "<<a<<" :: "<<#b<<" = "<<b<<endl
#define setbit(x)  __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long int,long long int>
#define ub upper_bound // '>'
#define lb lower_bound // '>='
//erase,count,find,make_unique
#define len(arr) (sizeof(arr)/sizeof(arr[0]))
#define sz(x) ((long long)x.size())
#define make_unique(arr) arr.erase(unique(arr.begin(),arr.end()),arr.end()) //Makes a sorted array unique
#define rep(a,b) for(int i=a;i<b;i++)
#define updiv(a,b) (ceil)((a)*(1.0)/(b))
#define printarray(arr) cout<<"PRINT ARRAY"<<endl; rep(0,len(arr)) cout<<arr[i]<<" "; cout<<endl;
#define printvector(vect) cout<<"PRINT VECTOR"<<endl; for(auto x:vect) cout<<x<<" "; cout<<endl;
#define rev(x) reverse(all(x))
#define insideloop(x) cout<<x<<" "; cout<<endl;
//LLONG_MAX, ULLONG_MAX INT_MAX
typedef long long int ll;
typedef unsigned long long int ull;
#define M 1000000007
using namespace std;
int main()
{
    fast
string str;
cin>>str;
if(str[2]==str[3]&&str[4]==str[5])
cout<<"Yes\n";
else
cout<<"No\n";
return 0;
}








Measured memory_bytes: 256
import math
n=int(input())
towns=[]
for i in range(n):
  x,y=map(int,input().split())
  towns.append([x,y])
total=0
for i in range(n-1):
  for j in range(i+1,n):
    total+=math.sqrt((towns[i][0]-towns[j][0])**2+(towns[i][1]-towns[j][1])**2)
print(2*total/n)

Measured memory_bytes: 62124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;




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

int N;
cin >> N;
string S;
cin >> S;

// alp[i]:= 文字が'i番目のAlphabet'であるようなindexの集合
vector<set<int>> alp; 
alp.assign(26, set<int>({INF})); // INFを入れておくと末尾が分かりやすくなる
rep(i,N) alp[S[i] - 'a'].insert(i);

int Q;
cin >> Q;
while(Q--) {
    int type;
    cin >> type;
    // 「idx番目をpcからncに置き換える」⇔「alp[pc]からidxを消去してalp[nc]にidxを挿入する」
    if(type == 1) {
        int idx;
        char nc;
        cin >> idx >> nc;
        idx--;
        char pc = S[idx];
        S[idx] = nc;
        alp[pc - 'a'].erase(idx);
        alp[nc - 'a'].insert(idx);
    }
    else {
        int l,r;
        cin >> l >> r;
        l--; //半開区間[l,r)を考える
        int cnt = 0;
        //各文字cについて[l,r)に含まれるかどうかを見る
        //これは*lower_bound(l) < *lower_bound(r)かどうかと同値である
        rep(c,26) {
                int lid = *alp[c].lower_bound(l);
                int rid = *alp[c].lower_bound(r);
                if (rid > lid) cnt++;
        }
        cout << cnt << endl;
    }
}

return 0;
}

Measured memory_bytes: 24220
#include<stdio.h>
int main() {
	int a,b,c,r,sum;
	scanf("%d %d %d",&a,&b,&c);
	for(r = a;a <= b;a++) {
		if(c % a == 0) {
			sum += 1;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1852
ans = []
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "?":
        break
    else:
        if op == "+":
            ans.append(a+b)
        elif op == "-":
            ans.append(a-b)
        elif op == "*":
            ans.append(a*b)
        elif op == "/":
            ans.append(a//b)
for an in ans:
    print(an)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int a; cin >> a;
	cout << a + a * a + a * a * a << '\n';
	return 0;
}


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

#define _overload3(_1, _2, _3, name, ...) name
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, n) repi(i, 0, n)
#define REP(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)

typedef long long int ll;
typedef unsigned long long int ull;

const int MOD=(int)1e9+7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};

ll gcd(ll a,ll 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;}
ll digitsum(ll a){ll x=0;while(a>0){x+=a%10;a/=10;}return x;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int y,m,d;
    scanf("%d/%d/%d", &y, &m, &d);
    if(y<2019) cout<<"Heisei"<<endl;
    else if(y==2019){
        if(m<5){
            cout<<"Heisei"<<endl;
        }
        else cout<<"TBD"<<endl;
    }
    else cout<<"TBD"<<endl;
}

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

int main() {
    int n,i;
    long long S;
    double A,m;
    while (cin >> n && n) {
        int s[n];
        S = 0.0;
        for (i=0; i<n; i++) {
            cin >> s[i];
            S += s[i];
        }
        A = 0.0;
        m = (double) S/n;
        for (i=0; i<n; i++)
            A += (s[i] - m) * (s[i] - m);
        printf("%.8lf\n", sqrt(A/n));
    }
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b; cin >> a >> b;
  string s; cin >> s;
  
  bool ok = true;
  if(s.size()!=a+b+1) ok = false;
  
  a--;b--;
  rep(i,s.size()){
    if(i==a+1 && s[i]!='-') ok =false;
    if(i!=a+1 && s[i]-'0'<0 || s[i]-'0'>9) ok = false;
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str,s;
  int cnt=0;
  cin >> s;
  for(int i=0,l=s.size();i<l;i++)
    if(s[i]>='A'&&s[i]<='Z')s[i]+=('a'-'A');
  while(cin >> str){
    if(str=="END_OF_TEXT")break;
    for(int i=0,l=str.size();i<l;i++)
      if(str[i]>='A'&&str[i]<='Z') str[i]+=('a'-'A');
    if(s==str) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3176
def count(tmp_N):
    count = 0
    while True:
        if tmp_N % 2 == 0:
            tmp_N = tmp_N / 2
            count += 1
        else:
            break
    return count


N = int(input())
input_list = list(map(int, input().split(' ')))

result = 0

for input_tmp in input_list:
    result += count(input_tmp)

print(int(result))

Measured memory_bytes: 4148
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n,x,y,a[]= {1,3,5,7,8,10,12},b[]= {4,6,9,11};
    cin>>x>>y;
    bool fx=0,fy=0;
    for(i=0; i<7; i++)
    {
        if(a[i]==x)
            fx=1;
        else if(a[i]==y)
            fy=1;
    }
    if(fx==0||fy==0){
        fx=0;fy=0;
    }
    for(i=0; i<4; i++){
        if(b[i]==x) fx=1;
        if(b[i]==y) fy=1;
    }
    if(fx&&fy)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}





Measured memory_bytes: 3648
import sys

class Node():
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None
        self.parent = None

    def prewalk(self):
        nodeList = [self.key]
        if self.left:
            nodeList += self.left.prewalk()
        if self.right:
            nodeList += self.right.prewalk()
        return nodeList

    def inwalk(self):
        nodeList = []
        if self.left:
            nodeList += self.left.inwalk()
        nodeList += [self.key]
        if self.right:
            nodeList += self.right.inwalk()
        return nodeList

class Tree():
    def __init__(self):
        self.root = None

    def insert(self, key):
        Nz = Node(key)
        Ny = None #???????£?
        Nx = self.root
        while Nx:
            Ny = Nx
            if Nz.key < Ny.key:
                Nx = Nx.left
            else:
                Nx = Nx.right
        Nz.parent = Ny
        if Ny == None:
            self.root = Nz
        elif Nz.key < Ny.key:
            Ny.left = Nz
        else:
            Ny.right = Nz

    def print(self):
        print('', ' '.join(map(str, self.root.inwalk())))
        print('', ' '.join(map(str, self.root.prewalk())))

tree = Tree()

n = sys.stdin.readline()
for line in sys.stdin:
    if line[0] == 'i':
        tree.insert(int(line.split()[1]))
    else:
        tree.print()

Measured memory_bytes: 190548
#include <iostream>
#include <vector>
typedef long long int ll;
using namespace std;
int main(){
    int n,q;
    ll k;
    cin>>n>>k>>q;
    vector<int> a;
    for(int i=0;i<q;i++){
        int at;
        cin>>at;
        a.push_back(at);
    }
    vector<int> ct;
    for(int i=0;i<n;i++){
        ct.push_back(0);
    }
    for(int i=0;i<q;i++){
        ct[a[i]-1]++;
    }
    for(int i=0;i<n;i++){
        if(k-(q-ct[i])>0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
}


Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long
typedef pair<int, int> P;

int n;
int a[20000];
int power[18];

bool check(int k, int d) {
	int i, j;
	int b[20000];
	vector<P> seg;
	
	for (i = 0; i < n; i++) { b[i] = a[i] % power[k + 1]; }
	for (i = 0; i < n; i++) { b[i] = power[k + 1] - b[i]; }
	
	seg.push_back(P(d * power[k], (d + 1) * power[k] - 1));
	
	for (i = 0; i < n; i++) {
		vector<P> n_seg;
		
		for (j = 0; j < seg.size(); j++) {
			n_seg.push_back(P((seg[j].first + b[i]) % power[k+1], (seg[j].second + b[i]) % power[k+1]));
			n_seg.push_back(P(seg[j].first, seg[j].second));
		}
		
		for (j = 0; j < n_seg.size(); j++) {
			if (n_seg[j].first > n_seg[j].second || n_seg[j].first == 0) { return true; }
		}
		
		//marge same size segment
		sort(n_seg.begin(), n_seg.end());
		seg.clear();
		
		int id = 0;
		for (j = 1; j < n_seg.size(); j++) {
			if (n_seg[j].first - n_seg[id].second >= 2) {
				seg.push_back(P(n_seg[id].first, n_seg[j-1].second));
				id = j;
			}
		}
		seg.push_back(P(n_seg[id].first, n_seg[j-1].second));
	}
	return false;
}

signed main() {
	int i, d;
	
	power[0] = 1;
	for (i = 1; i < 18; i++) power[i] = power[i - 1] * 10;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int ans = 0;
	for (i = 0; i < 17; i++) {
		for (d = 9; d > 0; d--) {
			if (check(i, d)) { ans += d; break; }
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

G = { 1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1,
        4:2, 6:2, 9:2, 11:2,
        2:3 }

x, y = rdi()

if G[x] == G[y]:
        print "Yes"
else:
        print "No"


Measured memory_bytes: 4332
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;

int main(void) {
  int i, j, k, n, m, num;
  scanf("%d%d", &n, &m);
  string dic[n], rev[n];
  string w, wt;
  for(i = 0; i < n; ++i) {
    wt = "";
    cin >> w;
    dic[i] = w;
    for(j = 0; j < w.size(); ++j) wt.push_back(w[w.size() - 1 - j]);
    rev[i] = wt;
  }
  sort(dic, dic + n);
  sort(rev, rev + n);
  for(i = 0; i < m; ++i) {
    num = -1;
    wt = "";
    int ans = 0;
    cin >> w;
    if(w[0] == '*') {
      for(j = 0; j < w.size(); ++j) wt.push_back(w[w.size() - 1 - j]);
      w = wt;
      w.pop_back();
      for(j = 0; j < w.size(); ++j) if(w[j] == '?') num = j;
      if(num != -1) {
        for(j = 0; j < 26; ++j) {
          w[num] = 'a' + j;
          wt = w;
          while(wt[wt.size() - 1] == 'z') wt.pop_back();
          if(wt.size()) {
            wt[wt.size() - 1]++;
            ans += lower_bound(rev, rev + n, wt) - lower_bound(rev, rev + n, w);
          } else {
            ans += rev + n - lower_bound(rev, rev + n, w);
          }
        }
      } else {
        wt = w;
        while(wt[wt.size() - 1] == 'z') wt.pop_back();
        if(wt.size()) {
          wt[wt.size() - 1]++;
          ans += lower_bound(rev, rev + n, wt) - lower_bound(rev, rev + n, w);
        } else {
          ans += rev + n - lower_bound(rev, rev + n, w);
        }
      }
    } else if(w[w.size() - 1] == '*') {
      w.pop_back();
      for(j = 0; j < w.size(); ++j) if(w[j] == '?') num = j;
      if(num != -1) {
        for(j = 0; j < 26; ++j) {
          w[num] = 'a' + j;
          wt = w;
          while(wt[wt.size() - 1] == 'z') wt.pop_back();
          if(wt.size()) {
            wt[wt.size() - 1]++;
            ans += lower_bound(dic, dic + n, wt) - lower_bound(dic, dic + n, w);
          } else {
            ans += dic + n - lower_bound(dic, dic + n, w);
          }
        }
      } else {
        wt = w;
        while(wt[wt.size() - 1] == 'z') wt.pop_back();
        if(wt.size()) {
          wt[wt.size() - 1]++;
          ans += lower_bound(dic, dic + n, wt) - lower_bound(dic, dic + n, w);
        } else {
          ans += dic + n - lower_bound(dic, dic + n, w);
        }
      }
    } else {
      for(j = 0; j < w.size(); ++j) if(w[j] == '?') num = j;
      if(num != -1) {
        for(j = 0; j < 26; ++j) {
          w[num] = 'a' + j;
          if(lower_bound(dic, dic + n, w) != dic + n && *lower_bound(dic, dic + n, w) == w) ++ans;
        }
      } else {
        if(lower_bound(dic, dic + n, w) != dic + n && *lower_bound(dic, dic + n, w) == w) ++ans;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 12812
#include "bits/stdc++.h"
using namespace std;

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MOD = 1e9+7;

int n;
ll ans=0;

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n;
  for(int a=1; a<=n; a++){
    for(int b=1; b*a<n; b++){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, result = 0;
  cin >> n >> m;
  
  if (n == 1 && m == 1) {
    result = 1;
  } else if (n == 1 || m == 1) {
    result = n + m - 3;
  } else {
    result = (n - 2) * (m - 2);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
	int n,m,k;
	while (~scanf ("%d%d%d",&n,&m,&k)){
		int cont=(n-k)/(m+k);
		printf ("%d\n",cont);
	}
	return 0;
}

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

using namespace std;

#define LIMIT 100
typedef pair<int64_t, int64_t> ii;
typedef int64_t ll;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;

  cin >> n >> m;

  ll t = (1900*m ) +100*(n-m);

  std::cout << t*(1<<m) << std::endl;

  return 0;
}



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

int main() {
	long long n,x;
	cin >> n >> x;
	vector<long long> a(n,0);
	for(int i=0;i<n;i++)
	{
		cin >> a.at(i);
	}
	long long k = 0,sm=0;
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++)
	{
		sm += a.at(i);
		if(x >= sm)
		{
			k++;
		}
	}
	if(x > sm)
	{
		k--;
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int a[100010], li[100010];
ll fact[100010];

ll inv(int a){
	ll x = a, n = MOD - 2, ret = 1;
	
	while(n){
		if(n & 1) (ret *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	
	return ret;
}

ll comb(int a, int b){
	if(a < b) return 0;
	ll pos = fact[a];
	ll pot = inv(fact[b]);
	ll por = inv(fact[a - b]);
	
	return pos * pot % MOD * por % MOD;
}

int main(){
	int n; int pos; cin >> n; n++;
	REP(i,0,n) cin >> a[i], li[a[i] - 1]++;
	REP(i,0,n) if(li[i] == 2) pos = i + 1;
	
	fact[0] = 1;
	REP(i,0,n + 1) fact[i + 1] = fact[i] * (i + 1) % MOD;
	
	int pot = 0;
	bool f = true;
	REP(i,0,n){
		if(f and a[i] == pos) f = false, pot += i;
		else if(!f and a[i] == pos) pot += n - 1 - i;
	}
	
	cout << n - 1 << endl;
	REP(i, 1, n){
	 	cout << (comb(n, i + 1) - comb(pot, i) + MOD) % MOD << endl;
	}
	return 0;
}


Measured memory_bytes: 2816
#include<stdio.h>
int main(void){
	int x,a,b,A,B;
	scanf("%d%d%d",&x,&a,&b);
	A=a-x;
	if(A<0){
		A=-A;
	}
	B=b-x;
	if(B<0){
		B=-B;
	}
	if(A<B){
		printf("A");
	}
	else{
		printf("B");
	}
	return 0;
} 

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

int main(int argc, char *argv[]) {
	int next_abc = 0;
	std::cin >> next_abc;

	int answer = 0;
	for (int i = next_abc; i <= 999; i++) {
		if (i % 111 == 0) {
			answer = i;
			break;
		}
	}

	std::cout << answer << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
ll n;
int main(){
	cin>>n;
	n++;
	vector<int>vec;
	vector<int>vec2;
	for(int i=63;i>=0;i--){
		if(!((n>>i)&1)) continue;
		for(int j=1;j<=i;j++){
			vec.pb(j);
			vec2.pb(j);
		}
		int nxt = i+1;
		for(int j=i-1;j>=0;j--){
			if(!((n>>j)&1)) continue;
			reverse(vec2.begin(),vec2.end());
			vec2.pb(nxt);
			reverse(vec2.begin(),vec2.end());
			stack<int>S;
			for(int k=0;k<j;k++){
				S.push(vec[vec.size()-1]);
				vec.pop_back();
			}
			vec.pb(nxt);
			for(int k=0;k<j;k++){
				vec.pb(S.top());
				S.pop();
			}
			nxt++;
		}
		break;
	}
	cout<<vec.size()+vec2.size()<<endl;
	for(int i=0;i<vec.size();i++) cout << vec[i] << " ";
	for(int i=0;i<vec2.size();i++) cout << vec2[i] << " ";
	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NitroBoost \
        ios_base::sync_with_stdio(false); \
        cin.tie(NULL);
#define ll long long
#define fori(i,l,n) for(int i=l;i<n;i++)
#define ford(i,n,l) for(int i=n;i>l;i--)
#define All(i,x) for(auto i=x.begin();i!=x.end();++i)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define test int t;cin>>t;while(t--)
#define pb(i) push_back(i)
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n"
#define str(n) to_string(n)
#define fi first
#define sec second
#define prec(n) fixed<<setprecision(n)
#define mp make_pair
const double pi=3.141592653589793;
const int MOD=1e9+7;
ll power(ll x, ll y, ll m) 
{
     ll res = 1;x %= m;
    while (y > 0) {
        if (y & 1)
        res = (res*x) % m;
        y>>=1;
        x = (x*x) % m;
    }
    return res%m;
}
map<string,int>look;
int dp(int a[][3],int n,int x){
    if(n<=0)
    return 0;
    string key=str(n)+"|"+str(x);
    if(look.find(key)==look.end()){
        int maxc=INT_MIN;
        if(x!=0 )        
        maxc=max(maxc,dp(a,n-1,0)+a[n-1][0]);
        if(x!=1 )        
        maxc=max(maxc,dp(a,n-1,1)+a[n-1][1]);
        if(x!=2)        
        maxc=max(maxc,dp(a,n-1,2)+a[n-1][2]);
        look[key]=maxc;
    }
    return look[key];
}
void solve(){
    int n;
    cin>>n;
    int a[n][3];    
    fori(i,0,n)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    cout<<dp(a,n,-1);
}
int main(){  
    NitroBoost
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    //test
    {
        solve();
    }
    return 0;
}

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

typedef long long ll;
const int N = 2e3 + 5;
const int mod = 1e9 + 7 + 0.5;
int n, m;
int s[N], t[N];
ll dp[N][N];

int main() {
    while (cin >> n >> m) {
        for (int i = 1; i <= n; ++i) cin >> s[i];
        for (int i = 1; i <= m; ++i) cin >> t[i];

        dp[0][0] = 1;
        for (int i = 1; i <= n; ++i) dp[i][0] = 1;
        for (int i = 1; i <= m; ++i) dp[0][i] = 1;

        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mod) % mod;
                if (s[i] == t[j]) {
                    dp[i][j] += dp[i - 1][j - 1];
                    dp[i][j] %= mod;
                }
            }
        }

        cout << dp[n][m] << endl;
    }
}

Measured memory_bytes: 31616
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

bool isPrime[200000];
vector<int> primes;


int main(){
	rep(i, 200000) isPrime[i] = true;
	isPrime[0] = isPrime[1] = false;
	REP(i, 2, 200000){
		if(!isPrime[i]) continue;
		for(int j = i + i; j < 200000; j += i) isPrime[j] = false;
		primes.pb(i);
	}
	//cout<<primes.size()<<endl;
	while(1){
		int n = in.nextInt(),  p = in.nextInt();
		if(n == -1 && p == -1) break;
		
		vi v;
		int idx = upper_bound(all(primes), n) - primes.begin();
		for(int i = idx; i < primes.size(); i++){
			for(int j = i; j < primes.size(); j++){
				if(v.size() < p + 2) v.pb(primes[i] + primes[j]);
				else{
					sort(all(v));
					if(v.back() > primes[i] + primes[j]){
						v.pop_back();
						v.pb(primes[i] + primes[j]);
					}
					else{
						break;
					}
				}
			}
		}
		
		
		sort(all(v));
		printf("%d\n", v[p-1]);
		
		// rep(i, v.size()) cout<<" "<<v[i];
		// cout<<endl;
	}
}

Measured memory_bytes: 3608
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a > b)
            System.out.println("a > b");
        else if (a < b)
            System.out.println("a < b");
        else
            System.out.println("a == b");
    }
}


Measured memory_bytes: 26208