akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
 
using namespace std;

int N, A, B, used[100], rings[100], G[100][199];
 
int rec(int pos)
{
    used[pos] = true; int ret = 1;
     
    for(int i = 0; i < rings[pos]; i++)
    {
        if(!used[G[pos][i]])
        {
            ret = max(ret, rec(G[pos][i]) + 1);
        }
    }
     
    used[pos] = false;
     
    return ret;
}
 
int main()
{
    int N, A, B;
     
    while(true)
    {
        scanf("%d", &N);
         
        if(N == 0) { break; }
 
        for(int i = 0; i < 100; i++)
        {
            used[i] = false; rings[i] = 0;
        }
     
        for(int i = 0; i < N; i++)
        {
            scanf("%d", &A); A--;
            scanf("%d", &B); B--;
         
            G[A][rings[A]] = B; rings[A]++;
            G[B][rings[B]] = A; rings[B]++;
        }

        int nodes = 0;
         
        for(int i = 0; i < 100; i++)
        {
            if(rings[i])
            {
                nodes++;
            }
        }
     
        int ret = 0;
     
        for(int i = 0; i < 100; i++)
        {
            ret = max(ret, rec(i));
                 
            if(ret == nodes) { break; }
        }
         
        printf("%d\n", ret);
    }
     
    return 0;
}

Measured memory_bytes: 3276
import math
n,d = list(map(int,input().split()))
l = []
for i in range(n):
    l.append(list(map(int,input().split())))

def dist(x,y):
    res = 0
    for i,j in zip(x,y):
        res += (i - j)**2
    if int(math.sqrt(res)) == math.sqrt(res):
        return 1
    else:
        return 0

ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += dist(l[i],l[j])

print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
using namespace std;

const double PI=acos(-1);

int main(){
    int a, b, c, x, cnt = 0;
    cin >> a >> b >> c >> x;
    for(int aa = 0; aa <= a; aa++){
        for(int bb = 0; bb <= b; bb++){
            for(int cc = 0; cc <= c; cc++){
                if((aa*500 + bb*100 + cc*50) == x){
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

class disjoint_set {
  public:
    vector<int> rank, p;
    disjoint_set() {};
    disjoint_set(int size) {
      rank.resize(size, 0);
      p.resize(size, 0);

      for (int i = 0; i < size; i++) {
        makeSet(i);
      }
    }
    void makeSet(int x) {
      p[x] = x;
      rank[x] = 0;
    }
    bool same(int x, int y) {
      return find_set(x) == find_set(y);
    }
    void unite (int x, int y) {
      link(find_set(x), find_set(y));
    }
    void link(int x, int y) {
      if (rank[x] > rank[y]) {
        p[y] = x;
      } else {
        p[x] = y;
        if (rank[x] == rank[y]) {
          rank[y]++;
        }
      }
    }
    int find_set(int x) {
      if (x != p[x]) {
        p[x] = find_set(p[x]);
      }
      return p[x];
    }
};
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > x(n);
  vector<pair<int, int> > y(n);

  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    x[i] = {a, i};
    y[i] = {b, i};
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  vector<pair<int, pair<int, int> > > grp;
  for (int i = 0; i < n - 1; i++) {
    int s = x[i].second;
    int t = x[i + 1].second;
    int d = x[i + 1].first - x[i].first;
    grp.push_back({d, {s, t}});
  }
  for (int i = 0; i < n - 1; i++) {
    int s = y[i].second;
    int t = y[i + 1].second;
    int d = y[i + 1].first - y[i].first;
    grp.push_back({d, {s, t}});
  }
  sort(grp.begin(), grp.end());
  ll ans = 0;
  disjoint_set djs(n);
  for (auto e : grp) {
    int s = e.second.first;
    int t = e.second.second;
    if (!djs.same(s, t)) {
      djs.unite(s, t);
      ans += e.first;
    }
  }
  cout << ans << endl;
}

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

int main(){
    int x;
    cin >> x;
    bool a[10500] ={0};
    a[0] = true;
    rep(i,10100){
        if(a[i]==true){
            rep(j,6){
                a[i+100+j] = true;
            }
        }
    }
    if(x > 10100){
        cout << 1 << endl;
    }else{
        cout << (int)a[x]<<endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

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

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  for (i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (i = 0; i < n; i++)
  {
    cin >> b[i];
  }
  for (i = 0; i < n; i++)
  {
    cin >> c[i];
  }
  sort(all(a));
  sort(all(b));
  sort(all(c));

  for (i = 0; i < n; i++)
  {
    auto ita = lower_bound(all(a), b[i]);
    ll anum = ita - a.begin();
    if (ita == a.end())
    {
      // anum = 0;
    }

    auto itc = upper_bound(all(c), b[i]);
    ll cnum = c.end() - itc;
    ans += anum * cnum;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;

typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    cin >> N;
    rep(i, 50000){
        if((int)((float)i*1.08) == N) {
            cout << i;
            return 0;
        }
    }
    cout << ":(";
}


Measured memory_bytes: 256
s = input()

EQS = []
n = 3
for i in range(2**n):
  eq = ""
  for j in range(len(s)):
    eq += s[j]
    if((i>>j)&1):
      eq += "+"
    else:
      eq += "-"
  eq = eq[:-1]
  EQS.append(eq)

def clc(eq):
  total = int(eq[0])
  for i in range(1,len(eq),2):
    if eq[i]!=eq[-1]:
      if eq[i]=="+":
        total+=int(eq[i+1])
      else:
        total-=int(eq[i+1])
  
  return total

for i in EQS:
  total = clc(i)
  if total ==7:
    i +="=7"
    print(i)
    exit()

Measured memory_bytes: 3064
a, b, k = map(int, input().split())
if (b - a + 1) > 2 * k:
    for i in range(a, a + k):
        print(i)
    for i in range(b - k + 1, b + 1):
        print(i)
else:
    for i in range(a, b + 1):
        print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int inf = 1e9+9;
const int mod = 1e9+7;

const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
#define maxn 400100
ll fac[maxn], invfac[maxn];

ll potmod(ll a, ll b)
{
	ll res = 1;
	while (b > 0)
	{
		if (b & 1) res = (res * a ) % mod;
		a = (a * a)%mod;
		b /= 2;
	}
	return res;
}

inline ll binom(int n, int k)
{
	return fac[n] * invfac[k] % mod * invfac[n - k] % mod;
}
inline ll path(int x, int y, int a, int b)
{
	int b1 = abs(x - a), b2 = abs(b - y);
	return binom(b1 + b2, b2);
}

int main()
{
	fac[0] = 1; invfac[0] = 1;
	FOR(i, 1, 400000) 
	{
		fac[i] = fac[i-1] * i % mod;
		invfac[i] = potmod(fac[i], mod - 2);
	}
	boost;
	int n, m, bokx, boky;
	cin >> n >> m >> bokx >> boky;
	ll res = 0;
	for (int i=1; i<=n-bokx; ++i)
	{
		ll ile = path(1, 1, i, boky);
		ile *= path(i, boky+1, n, m);
		ile %= mod;
		res += ile;
		while (res >= mod) res -= mod;
	}
	
	cout << res;
}


Measured memory_bytes: 6528
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    n,k = map(int, r.split())
    r = stdin.readline()[:-1]
    a = list(map(int, r.split()))
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    if n <= k:
        print(0)
    elif k == 0:
        print(sum(a))
    else:
        a.sort()
        print(sum(a[:-k]))
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 80848
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return map(int, input_tuple)


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def calc_bincount(w):
    bincount = {}
    for i in range(w - 1):
        bincount[i] = 2**i
        for j in range(2**i):
            while j:
                if j & 3 == 3:
                    bincount[i] -= 1
                    break
                j >>= 1
    bincount[-4] = bincount[-3] = bincount[-2] = bincount[-1] = 1
    return bincount


def main():
    h, w, k = intin()
    mod = 1000000007

    bincount = calc_bincount(w)

    counts_first = {}
    for i in range(1, w + 1):
        counts_first[i] = 0
    counts_first[1] = 1
    h_to_counts = {0: counts_first}

    for i in range(1, h + 1):
        prev_counts = h_to_counts[i - 1]
        h_to_counts[i] = {}
        for j in range(1, w + 1):
            h_to_counts[i][j] = 0

            # j - 1 --> j
            if j > 1:
                incr = ((bincount[j-3] * bincount[((w+1)-j)-2]) * prev_counts[j-1]) % mod
                h_to_counts[i][j] += incr
                h_to_counts[i][j] %= mod

            # j --> j
            incr = ((bincount[j-2] * bincount[((w+1)-j)-2]) * prev_counts[j]) % mod
            h_to_counts[i][j] += incr
            h_to_counts[i][j] %= mod

            # j + 1 --> j
            if j < w:
                incr = ((bincount[j-2] * bincount[((w+1)-j)-3]) * prev_counts[j+1]) % mod
                h_to_counts[i][j] += incr
                h_to_counts[i][j] %= mod

    print(h_to_counts[h][k])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38452
#include<stdio.h>
int a[]={1,2,3,4,5,6},
x[4][4]={{1,0,4,5},{2,0,3,5},{3,0,2,5},{4,0,1,5}};
void F(int n)
{
	int t=a[x[n][0]],i;
	for(i=0;i<3;++i)a[x[n][i]]=a[x[n][i+1]];
	a[x[n][3]]=t;
}
int main()
{
	int n,i;
	char s[9];
	while(scanf("%d",&n),n)
	{
		for(i=0;i<6;++i)a[i]=i+1;
		while(n--)
		{
			scanf("%s",s);
			if(s[0]=='n')F(0);
			if(s[0]=='w')F(1);
			if(s[0]=='e')F(2);
			if(s[0]=='s')F(3);
		}
		printf("%d\n",a[0]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    auto dp = initVec2<int>(n + 1, k + 1);
    for(int j = 0; j < k; j++){
        deque<int> deq;
        int l = 0;
        for(int i = 0; i < n; i++){
            while(not deq.empty() && dp[deq.back()][j] <= dp[i][j]){
                deq.pop_back();
            }

            deq.push_back(i);

            if(i - l >= m){
                if(deq.front() == l){
                    deq.pop_front();
                }
                l++;
            }
            if(i >= j){
                dp[i+1][j+1] = dp[deq.front()][j] + a[i] * (j + 1);
            }
        }
    }

    int ans = 0;
    rep(i, n + 1){
        ans = max(ans, dp[i][k]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 241408
#include "bits/stdc++.h"
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2011&lang=jp
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n;
	while (cin >> n, n) {
		vector<vector<int>> yotei(31);
		vector<set<int>> s(n); // s[i] := maps set which i-th person may have 
		for (int i = 0; i < n;i++) {
			int t; cin >> t;
			for (int j = 0;j < t;j++) {
				int x; cin >> x;
				yotei[x].push_back(i);
			}
		}
		for (int i = 0;i < n;i++) s[i].insert(i);
		bool f = false;
		for (int i = 1; i <= 30;i++) {
			set<int> ts;
			for (auto it : yotei[i]) {
				for (auto m : s[it]) {
					ts.insert(m);
				}
			}
			for (auto it : yotei[i]) {
				s[it] = ts;
			}
			if (ts.size() == n) {
				cout << i << endl;
				f = true;
				break;
			}
		}
		if (!f) cout << -1 << endl;
	}
}

Measured memory_bytes: 3108
n, k = map(int, input().split())
max_k = (n - 1) * (n - 2) // 2
if k > max_k:
  print(-1)
else:
  rest = max_k - k
  print(n - 1 + rest)
  for i in range(n - 1):
    print(1, i + 2)
  tmp = [2, 3]
  for i in range(rest):
    if tmp[1] <= n:
      print(tmp[0], tmp[1])
      tmp[1] += 1
    else:
      tmp = [tmp[0] + 1, tmp[0] + 2]
      print(tmp[0], tmp[1])
      tmp[1] += 1

Measured memory_bytes: 3608
import java.util.Scanner;
class Main{
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
			int n=sc.nextInt();
			if(n==0)break;
			int Aans=0;
			int Bans=0;
			int a=0;
			int b=0;
			int temp;
			for(int i=0;i<n;i++){
				a=sc.nextInt();
				b=sc.nextInt();
				if(a!=b){
					temp=Math.max(a, b);
					if(temp==a){
						Aans+=a+b;
					}else if(temp==b){
						Bans+=a+b;
					}
				}else{
					Aans+=a;
					Bans+=b;
				}
			}
			System.out.println(Aans+" "+Bans);

		}
		
	}
}

Measured memory_bytes: 51404
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

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

    vector<int> s(n, k - q);
    for (int h = 0; h < q; h++) {
        int a;
        cin >> a;
        a--;

        s[a]++;
    }

    for (int i = 0; i < n; i++) {
        cout << (s[i] > 0 ? "Yes" : "No") << '\n';
    }

    return 0;
}

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

ans = []

for i in range(n+1):
    ans.append(0)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            s = x*x + y*y + z*z
            s += x*y + y*z + z*x
            if (s > n) : continue
            ans[s] += 1

for i in range(1,n+1):
    print(ans[i])


Measured memory_bytes: 9112
#include <stdio.h>
int main(){
    int a,b,c,t;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    if(b>c){
        t=b;
        b=c;
        c=t;
    }
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2672
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r,int c)
{
	stack<int> S;
	S.push(r);
	color[r] = c;
	while(!S.empty()){
		int u= S.top();S.pop();
		for(int i=0;i<G[u].size();i++){
			int v = G[u][i];
			if(color[v] == NIL){
				color[v] = c;
				S.push(v);
			}
		}
	}
}

void assigncolor()
{
	int id = 1;
	for(int i=0;i<n;i++) color[i] = NIL;
	for(int i=0;i<n;i++){
		if(color[i] == NIL) dfs(i,id++);
	}
}

int main()
{
	int s,t,m,q;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> s >>t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	
	assigncolor();
	cin >> q;
	
	for(int i = 0;i<q;i++){
		cin >> s >> t;
		if(color[s] == color[t]){
			cout << "yes" <<endl;
		}else{
			cout << "no" <<endl;
		}
	}
	
	return 0;
}

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

int main() 
{
	int a[10000];
	a[1]=1;
	for(int i=2;i<=999;i++)
	{
		a[i]=a[i-1]+i;
	}
	int x,y;
	cin>>x>>y;
	int d=y-x;
	cout<<a[d]-y<<endl;
	return 0;
} 

Measured memory_bytes: 256
/* Print a Chessboard */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void) {
	int H, W, i, j;

	while(1) {
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0) {
			break;
		} else {
			for(i = 0; i < H; i++) {	
				for(j = 0; j < W; j++) {
					if(i % 2 == 0) {
						if(j % 2 == 0){
							printf("#");
						} else {
							printf(".");
						}
					} else {
						if(j % 2 == 0){
							printf(".");
						} else {
							printf("#");
						}
					}
				}
				putchar('\n');
			}
			putchar('\n');
		}
	}

	return 0;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int x;
    cin >> x;

    ll num  = 0;
    ll maxV = 0;
    // 処理
    for (float b = 1; b < 35; b++) {
        for (float p = 2; p < 10; p++) {
            // cout << b << " " << p << " " << pow(b, p) << endl;
            num = pow(b, p);
            // cout << num << endl;

            if (num <= x) maxV = max(maxV, num);
        }
    }

    // 出力
    cout << maxV << endl;

    return 0;
}


Measured memory_bytes: 256
BIG_NUM = 2000000000

while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end='')
            else:
                print(".",end='')
        print()

    print() #データセットの区切り



Measured memory_bytes: 7008
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int x = sc.NextInt();
        int n = sc.NextInt();
        int[] p = n == 0 ? new int[0] : sc.IntArray();

        var hs = new HashSet<int>();
        foreach (var i in p)
        {
            hs.Add(i);
        }

        for (int d = 0;; d++)
        {
            if (!hs.Contains(x - d))
            {
                Console.WriteLine(x - d);
                return;
            }

            if (!hs.Contains(x + d))
            {
                Console.WriteLine(x + d);
                return;
            }
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main() {
  int N;
  vector<pair<string, int> > shop;
  int value[105];

  cin >> N;

  rep(i, N) {
    string S;
    int P;
    cin >> S >> P;
    P = -P;
    shop.push_back(make_pair(S, P));
    value[i] = P;
  }

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

  int ans;
  rep(i, N) {
    rep(j, N) {
      if (shop[i].second == value[j]) {
        ans = j;
        break;
      }
    }
    ans++;
    cout << ans << endl;
  }


  return 0;

}

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

const long long N=1000010;
long long a[N];

int main(){
	
ios_base::sync_with_stdio(false);

long long start,end,n,i,p1,p2,k1,ans=0;

cin>>n;

for(i=0;i<n;i++)
	cin>>a[i];

sort(a,a+n);

start=a[0];
end=a[n-1];

for(i=start;i<=end;i++){

k1=upper_bound(a,a+n,i)-a;

//cout<<i<<" "<<k1<<endl;

p1=k1;
p2=n-k1;

if(p1==p2)
ans++;}

cout<<ans<<endl;

return 0;}

Measured memory_bytes: 1024
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

int main(){
	ll a, b, k;
  	scanf("%lld%lld%lld", &a, &b, &k);
	if (a + b <= k){
      	a = 0;
      	b = 0;
		printf("%lld% lld", a, b);
		return 0;
	}
	if (a <= k){
		b = a + b - k;
		a = 0;
		printf("%lld %lld", a, b);
		return 0;
	}
	a -= k;
	printf("%lld %lld", a, b);
	return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(a<b) swap(a,b);
  if(a<c) swap(a,c);
  if(a==b+c) cout <<"Yes\n";
  else cout<<"No\n";
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

ans = 0
for k in range(1,n+1):
    ans += (k*(n//k)*(n//k + 1))//2
print(ans)



Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main(){  
    ll N, D, A;  cin >> N >> D >> A;
    vector<pll> XH(N, {0,0});
    vector<ll> cnt(N+1, 0), X(N+1, 1e18), H(N+1, 0);
    for(int i=0; i<N; i++){
        cin >> XH[i].first >> XH[i].second;
    }
    sort(XH.begin(), XH.end());
    for(int i=0; i<N; i++){
        X[i] = XH[i].first;
        H[i] = XH[i].second;
    }

    ll ans = 0;
    int cur = 0;
    while(cur < N){
        ll remainH = H[cur] - A*cnt[cur];
        ll dc = (remainH + A - 1)/A;
        cnt[cur] += dc;
        ans += dc;
        ll maxRange = X[cur] + 2*D;
        int maxCur = upper_bound(X.begin(), X.end(), maxRange) - X.begin();
        if(maxCur < N){
            cnt[maxCur] -= dc; 
        }

        cur++;
        if(cur == maxCur){
            cnt[cur] += cnt[cur-1];
            continue;
        }
        for(int i=cur; i<maxCur; i++){
            cnt[i] += cnt[i-1];
            if(A*cnt[i] < H[i]){
                cur = i;
                break;
            }
            if(i==maxCur-1){
                cur = maxCur;
                cnt[cur] += cnt[cur - 1];
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
	int h,w,n;
	int a[10010];
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	
	int ret[102][102];
	
	int k=1;
	for(int i=0;i<h;i++){
		if(i%2==0){
			for(int j=0;j<w;j++){
				if(a[k]==0)k++;
				ret[i][j]=k;
				a[k]--;
			}
		}
		else {
			for(int j=w-1;j>=0;j--){
				if(a[k]==0)k++;
				ret[i][j]=k;
				a[k]--;
			}
		}
	}
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%d%c",ret[i][j],(j+1==w)?'\n':' ');
		}
	}
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
 
int main() {

 vector<char> alpha(26);
 int c=0;

 for (char moji='A'; moji<='Z'; moji++)
 {alpha.at(c)=moji;
 c=c+1;
 }
 

 int N;
 string S;
 cin>>N;
 cin>>S;
 vector<char> res(S.size());

 for (int i = 0; i < S.size(); i++)
 {
     for (int p = 0; p < 26; p++)
     {
         if (S.at(i)==alpha.at(p))
         {

            
           
             
                if (p+N>=26)
                {
                res.at(i)=alpha.at(p+N-26);
                }
                else
                {
                 res.at(i)=alpha.at(p+N);
                }
             
         }
        
     }
     
     
    
 }
string re;
 for (int i = 0; i < S.size(); i++)
 {
    re+=res.at(i);
 }
 
  cout<<re;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    try (Scanner scanner = new Scanner(System.in)) {
      while (scanner.hasNext()) {
        String[] s = scanner.nextLine().split(",");
        Student student = new Student(s[0], Double.parseDouble(s[1]), Double.parseDouble(s[2]));
        if (student.bmi.isDebu()) {
          System.out.println(student.studentId);
        }
      }
    }
  }
}

class Student {
  final String studentId;
  final Bmi bmi;

  Student(String studentId, double kg, double m) {
    this.studentId = studentId;
    this.bmi = new BmiImpl(kg, m);
  }
}

interface Bmi {
  int debu = 25;

  boolean isDebu();
}

class BmiImpl implements Bmi {

  private final double kg;
  private final double m;

  BmiImpl(double kg, double m) {
    this.kg = kg;
    this.m = m;
  }

  public double calc() {
    return kg / Math.pow(m, 2);
  }

  @Override
  public boolean isDebu() {
    return calc() >= debu;
  }
}

Measured memory_bytes: 26124
#!/usr/bin/env python3

import itertools


def max_honests(n, statements):
    g = itertools.product((True, False), repeat=n)
    res = 0
    for is_hon in g:
        flag = True
        for i in range(n):
            if is_hon[i]:
                for x, y in statements[i]:
                    if is_hon[x] != y:
                        flag = False
        if flag:
            res = max(res, sum(is_hon))
    return res


def main():
    n = int(input())
    statements = [set() for _ in range(n)]
    for i in range(n):
        a = int(input())
        for _ in range(a):
            x, y = (int(z) for z in input().split())
            statements[i].add((x - 1, bool(y)))
    res = max_honests(n, statements)
    print(res)


if __name__ == "__main__":
    main()


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

int main()
{
	ll H,W;
	cin>>H>>W;
	
	ll arr[H][W];
	ll sub=0;
	ll dp[H][W];
	dp[0][0]=1;
	char c;
	 for(ll i=0;i<H;i++)
	 {
	 	for(ll j=0;j<W;j++)
	 	{
	 		ll count=0;
			 cin>>c;
	 		if(c=='.')
	 		{
	 			arr[i][j]=0;
	 			
	 			if(i!=0||j!=0)
	 			{
	 				dp[i][j]=0;
					 if(i-1>=0)
	 				{
	 					if(arr[i-1][j]==0)
	 					{
	 					dp[i][j]=(dp[i][j]+dp[i-1][j])%1000000007;
						 }
					 }
					 
					 if(j-1>=0)
					 {
					 	if(arr[i][j-1]==0)
					 	{
					 	dp[i][j]=(dp[i][j]+dp[i][j-1])%1000000007;
						 }
					 }
				 }
	 			
			 }
			 
			 else  if(c=='#')
			 {
			 	arr[i][j]=1;
			 	dp[i][j]=0;
			 }
			 
			 
		 }
		 
		
	 }
	 
	 cout<<dp[H-1][W-1]%1000000007<<endl;
	 
	 
}


Measured memory_bytes: 15872
X,Y = map(int,input().split())
cnt = 0
if X==3:
    cnt += 100000
elif X==2:
    cnt += 200000
elif X==1:
    cnt += 300000
if Y==3:
    cnt += 100000
elif Y==2:
    cnt += 200000
elif Y==1:
    cnt += 300000
if X==1 and Y==1:
    cnt += 400000
print(cnt)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define   vpll   vector<pll >
#define   all(x) x.begin(),x.end()
#define   present(c,x)    ((c).find(x) != (c).end())
#define   dbg(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#define   sz(a)  a.size()
#define   vll vector<int>
#define   pll pair<int,int>
#define   ff  first
#define   ss  second
#define   br  cout<<"\n";
#define   ld  long double
#define   int  long long int
const int  INF = 1e18+7;
const int  MAX = 1234567;
const int  MOD = 1000000007;
 
bool ispalin ( string s , int start , int end ){
	int mid = start + ( end - start ) / 2  ;
	for ( int i = start ; i <= mid ; i++ )
		if ( s[i] != s [end - i + 1 ] )
			return false ;
	return true ;	
}
 
void solve(){
	string s ;
	cin >> s ;
	int n = s.length() ;
	s = " " + s ;
	if ( ispalin( s , 1 , n  ) and ispalin( s , 1 , ( n - 1 ) / 2   ) and ispalin ( s ,  (( n + 3 ) / 2 ) , n  ) )
		cout << "Yes" ;
	else
		cout << "No " ;	    
}
int32_t main(){
    int t;
    t=1;

    cin.sync_with_stdio(0), cin.tie(0);
    //cin>>t;
    while(t--){
        solve();
        br;
    }
    return 0;
}
 
 
 
 

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  if (c >= 'a' && c <= 'z') {
    cout << 'a' << '\n';
  } else {
    cout << 'A' << '\n';
  }
  
  return 0;
}

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

typedef long long ll;

ll n,l,r,cnt;

int main()
{
	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>l>>r;
		cnt += r-l+1;
	}
	cout<<cnt<<endl;
	return 0;
}

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

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_i = pair<double, int>;
using i_d = pair<int, double>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr ll INF = 1LL << 60;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = {
  { typeid(int), "%d" }, { typeid(ll), "%lld" }, { typeid(double), "%lf" }, { typeid(char), "%c" }};

template <class T> static void scan(vector<T>& v);
static void scan(vector<string>& v, bool isWord = true);
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; }

ll dp[101][100001];

int main(int argc, char *argv[]) {
  //INFILE();

  ll n, w;
  cin >> n >> w;

  vector<ll> weights(static_cast<int>(n));
  vector<ll> values(static_cast<int>(n));
  REP(i, 0, n) {
    cin >> weights[i] >> values[i];
  }

  REP(i, 0, n) {
    REP(j, 0, w + 1) {
      if (j != 0 && dp[i][j] == 0) continue;
      chmax(dp[i + 1][j], dp[i][j]);
      if (j + weights[i] > w) continue;
      chmax(dp[i + 1][j + weights[i]], dp[i][j] + values[i]);
    }
  }

  cout << *max_element(ALL(dp[n])) << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}


Measured memory_bytes: 77184
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL MOD=1e9+7;
LL ans=0;
int N,M;
int main(){
    cin>>N>>M;
    int a=max(N,M);
    int b=min(N,M);
    if(a-b>1){
       cout<<0<<endl;
    }else{
       ans=1;
       REP(i,a){
           ans*=(i+1);
           ans%=MOD;
       }
       REP(i,b){
           ans*=(i+1);
           ans%=MOD;
       }
       if(a==b){
          ans*=2;
          ans%=MOD;
       }
        cout<<ans<<endl;
    }

    return(0);
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		char[] o = sc.next().toCharArray();
		char[] e = sc.next().toCharArray();

		for(int i = 0; i < o.length; i++) {
			System.out.print(o[i]);
			if(i != e.length) {
				System.out.print(e[i]);
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 21588
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

import itertools

per = list(itertools.permutations(range(1, N+1)))
for idx, ele in enumerate(per):
    if ele == P:
        s = idx
    if ele == Q:
        t = idx

print(abs(s-t))

Measured memory_bytes: 45296
#include<cstdio>
#include<vector>

#define	pb	push_back

using namespace std;

typedef	vector<int>	vi;

char field[5050];

bool vanish(int u,int l){
	vi rem;
	for(int i=l;i>=u;i--){
		if(field[i]!=31)	rem.pb(i);
	}

	int rnum=rem.size(),h=l-u+1;
	if(rnum!=l){
		for(int i=0;i<rnum;i++)	field[l-i]=field[rem[i]];
		for(int i=u-1;i>=0;i--)	field[h-rnum+i]=field[i];
		for(int i=0;i<rnum;i++)	field[i]=0;
	}
}

int main(){
	for(int n;scanf("%d",&n),n;){
		for(int i=0;i<5050;i++)	field[i]=0;
		for(int t=0;t<n;t++){
			int type,len,p;	scanf("%d%d%d",&type,&len,&p);
			p--;

			char blk;
			if(type==1)	blk=((1<<len)-1)<<(5-p-len);
			else		blk=1<<(4-p);

			for(int i=0;i<=5050;i++){
				if(i==5050 || (field[i]&blk)!=0){
					if(type==1){
						field[i-1]|=blk;
						vanish(i-1,i-1);
					}
					else{
						for(int j=1;j<=len;j++)	field[i-j]|=blk;
						vanish(i-len,i-1);
					}
					break;
				}
			}
		}

		int cnt=0;
		for(int i=0;i<5050;i++){
			for(int j=0;j<5;j++)	if(field[i]&(1<<j))	cnt++;
		}
		printf("%d\n",cnt);
	}

	return 0;
}

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

int main() {
    int H,W;
    cin >> H >> W;
    vector<vector<int>> A(H,vector<int>(W,0));
    vector<tuple<int,int>> u;
    for (int h=0;h<H;++h) {
        string s;
        cin >> s;
        for (int w=0;w<W;++w) {
            if (s[w]=='#') {
                A[h][w]=1;
                u.push_back(make_tuple(h,w));
            }
        }
    }
    vector<tuple<int,int>> u_prev;
    int ans=0;
    while (true) {
        u_prev.swap(u);
        u.clear();
        for (auto p : u_prev) {
            int p0=get<0>(p);
            int p1=get<1>(p);
            if (p0>0 && A[p0-1][p1]==0) {
                A[p0-1][p1]=1;
                u.push_back(make_tuple(p0-1,p1));
            }
            if (p1>0 && A[p0][p1-1]==0) {
                A[p0][p1-1]=1;
                u.push_back(make_tuple(p0,p1-1));
            } 
            if (p0<H-1 && A[p0+1][p1]==0) {
                A[p0+1][p1]=1;
                u.push_back(make_tuple(p0+1,p1));
            }
            if (p1<W-1 && A[p0][p1+1]==0) {
                A[p0][p1+1]=1;
                u.push_back(make_tuple(p0,p1+1));
            }
        }
        if (u.size()==0){
            break;
        }
        ans+=1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17768
#include<bits/stdc++.h>
using namespace std; 
int main(void){
	int	n;
	char a[100001];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int i=0;
	int cnt=0;
	while(1){
		if(i>=n-1)	break;
		//cout<<i<<endl;
		if(a[i]!=a[i+1]){
			cnt++;
			i+=2;
		}
		else{
			i++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 3204
S_d = input()
T = input()
len_S_d = len(S_d)
len_T = len(T)
ans_list = []
all_a = S_d.replace("?", "a")
for i in range(len_S_d - len_T + 1):
	if all(map(lambda x: x[0] == x[1] or x[0] == "?", zip(S_d[i:i + len_T], T))):
		ans_list.append(all_a[:i] + T + all_a[i + len_T:])
if ans_list:
	print(min(ans_list))
else:
	print("UNRESTORABLE")


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



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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;

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 main()
{
    ll n, m;
    cin >> n >> m;

    ll tmp = 1LL << m;
    ll ans = (1900LL * m) + 100LL*(n-m);
    cout << tmp * ans << endl; 

	return 0;
}


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

int d[3][4]={{0,4,5,1},{0,2,5,3},{4,2,1,3}};//d,u,l,r

void dice(int a[6], int n){
	int tmp = a[d[n][0]];
	a[d[n][0]] = a[d[n][1]];
	a[d[n][1]] = a[d[n][2]];
	a[d[n][2]] = a[d[n][3]];
	a[d[n][3]] = tmp;
}

int check(int a[6], int b[6]){
	for(int i = 0;i < 6;i++)if(a[i] != b[i])return 0;
	return 1;
}

int func(int a[6], int b[6]){
	for(int i = 0;i < 6;i++){
		for(int j = 0;j < 4;j++){
			dice(b, 0);
			if(check(a, b))return 1;
		}
		if(i%2 == 0)dice(b, 1);
		else dice(b, 2);
	}
	return 0;
}

int calc(int a[100][6], int n){
	for(int i = 0;i < n-1;i++){
		int b[6], c[6];
		for(int j = 0;j < 6;j++)b[j] = a[i][j];
		for(int j = i+1;j < n;j++){
			for(int k = 0;k < 6;k++)c[k] = a[j][k];
			if(func(b, c))return 1;
		}
	}
	return 0;
}

int main(){
	int a[100][6];
	int n;cin >> n;
	for(int j = 0;j < n;j++)
	for(int i = 0;i < 6;i++)cin >> a[j][i];
	
	if(calc(a, n))cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

int main() {
  vector<int> v(3);
  cin >> v.at(0);
  cin >> v.at(1);
  cin >> v.at(2);
  sort(v.begin(), v.end());
  cout << v.at(0) * v.at(1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

vll dx = {1, 0, -1, 0};
vll dy = {0, 1, 0, -1};

bool comp(const P p1, const P p2){
    return p1.first * (p2.second + 1) > p2.first * (p1.second + 1);
}

bool bcomp(const P p1, const P p2) {
    return p1.second < p2.second;
}

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

    ll n, T;
    cin >> n >> T;
    ll a, b;
    vector<P> p(n);
    REP(i, n) {
        cin >> a >> b;
        p[i] = {a, b};
    }
    sort(ALL(p), comp);
    vector<P> q1, q2;
    REP(i, n) {
        if (p[i].first > 0) q1.push_back(p[i]);
        else q2.push_back(p[i]);
    }
    sort(ALL(q2), bcomp);
    n = q1.size();
    ll inf = 1e15;
    ll len = min(35LL, n);
    vvll dp(n + 1, vll(len + 1, inf)); // dp[i][j] : i 番目の店までのうち j コの店を選択したときの最短時間
    REP(i, n + 1) dp[i][0] = 0;
    REP(i, n) {
        REP(j, len) {
            if (j > i) break;
            // i + 1 番目の店を選ばないとき
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            // i + 1 番目の店を j + 1 コ目の選択するとき
            // 直前の店まで x --> 移動で x + 1
            // (x + 1) --> a(x + 1) + b
            // total = x + 1 + a(x + 1) + b = (a + 1)(x + 1) + b;
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], (q1[i].first + 1) * (dp[i][j] + 1) + q1[i].second);
        }
    }
    ll res = 0;
    REP(j, len + 1) {
        ll cnt = dp[n][j], tmp = 0;
        if (cnt > T) break;
        for (auto qq : q2) {
            cnt += 1 + qq.second;
            if (cnt > T) break;
            tmp++;
        }
        res = max(res, j + tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 71404
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 123456;

vector <pair <int, int> > g[N];
ll dist[N];
int popped[N];

struct compare {
  bool operator() (const int &l, const int &r) {
    return dist[l] < dist[r];
  }
};

int main() {
  int n;
  ll m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a].push_back({b, c});
  }
  dist[1] = 0;
  for (int i = 2; i <= n; i++) dist[i] = LLONG_MIN;
  priority_queue <int, vector <int>, compare> q;
  q.push(1);
  while (! q.empty()) {
    int vertex = q.top();
    q.pop();
    popped[vertex] = 1;
    for (auto e : g[vertex]) {
      ll alt;
      if (dist[vertex] == LLONG_MAX) {
        alt = LLONG_MAX;
      } else if (popped[e.first] && dist[vertex] + e.second > dist[e.first]) {
        alt = LLONG_MAX;
      } else {
        alt = dist[vertex] + e.second;
      }
      if (alt > dist[e.first]) {
        q.push(e.first);
        dist[e.first] = alt;
      }
    }
  }
  if (dist[n] == LLONG_MAX) cout << "inf" << endl;
  else cout << dist[n] << endl;
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  int n; cin >> n;
  vector<vector<int>> f(n,vector<int>(10)), p(n,vector<int>(11));
  rep(i,n) rep(j,10) cin >> f[i][j];
  rep(i,n) rep(j,11) cin >> p[i][j];
  
  int ans=-INF;
  reps(bit,1,1<<10){
    int sum=0;
    rep(i,n){
      int cnt=0;
      rep(j,10) if(f[i][j]<<j & bit) cnt++;
      sum += p[i][cnt];
    }
    chmax(ans,sum);
  }
  cout << ans;

return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

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

int main()
{
	int dp[1<<10][331] = {{0}};
	int ans[11][331] = {{0}};
	dp[0][0] = 1;
	ans[0][0] = 1;

	rep(i, 1<<10){
		int stand = 0, tmp = i;
		while(tmp){
			stand += tmp&1;
			tmp >>= 1;
		}

		rep(j, 331){
			rep(k, 10){
				if((i>>k)&1 && j-stand*k>=0){
					int inc = dp[i^(1<<k)][j-stand*k];
					dp[i][j] += inc;
					ans[stand][j] += inc;
				}
			}
		}
	}

	int n, s;
	while(scanf("%d%d", &n, &s) != EOF){
		if(n < 0 || 10 < n)
			puts("0");
		else
			printf("%d\n", 0<=s && s<=330 ? ans[n][s] : 0);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n, m; cin >> n >> m;
    vector<int> l(m), r(m);
    for(int i = 0; i < m; i++) {
        cin >> l[i];
        cin >> r[i];
    }

    int maxl = 0;
    int minr = INF;
    for(int i = 0; i < m; i++) {
        maxl = max(maxl, l[i]);
        minr = min(minr, r[i]);
    }

    int ans = max((int)0, minr - maxl + 1);

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


Measured memory_bytes: 1792