akhauriyash/Code-Regression huggingface dataset:
////////////////////////
// 操作しない
function emit() {return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
var myOut = main(emit());
// 操作しない
////////////////////////
function consolog(t) {console.log(t);}
//0:何もしない  1:数値へ変換  2:半角スペースで配列に分割  3:改行で配列に分割  4:半角スペースで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字ずつの配列に分割  7:1文字に分割し、数値配列へ
function arcv (i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}


function main(inp) { // return で返す
    inp = arcv(inp, 3);
    var N = Number(inp[0]);
    return N * N * N;
}


////////////////////////
// 操作しない
if (myOut !== undefined) consolog(myOut);

Measured memory_bytes: 9420
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int M = int.Parse(s[1]);
        int X = int.Parse(s[2]);
        int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int costToM = 0;
        int costToZero = 0;
        for(int i = 0; i < M;i++)
        {
            if (A[i] > X) costToM++;
            else costToZero++;
        }
        Console.WriteLine(Math.Min(costToZero, costToM));
    }
}


Measured memory_bytes: 11348
import sys

N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

if sum(As) < sum(Bs):
    print(-1)
    sys.exit()

ans = 0
sumShortage = 0
Surpluss = []
for A, B in zip(As, Bs):
    if A < B:
        ans += 1
        sumShortage += B - A
    else:
        Surpluss.append(A - B)

Surpluss.sort(reverse=True)

for Surplus in Surpluss:
    if sumShortage <= 0:
        break
    sumShortage -= Surplus
    ans += 1

print(ans)


Measured memory_bytes: 18356
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    int num, k;
    vector<vi> c(10, vi(10));
    for (int i = 1; i <= N; ++i) {
		int r = i % 10;
		int l;
		num = i;
		while (num != 0) {
			k = num % 10;
			num /= 10;
		}
		l = k;
		++c[l][r];
	}
	ll total = 0;
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			total += c[i][j] * c[j][i];
		}
	}
	cout << total << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3600
#include<stdio.h>
int  main(){
  int n,m,i,j,sum=0,ans=0; 
  scanf("%d %d",&n,&m);
  int data[m+1][n+1];
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&data[j][i]);
      sum+=data[j][i];
      ans+=data[j][i];
    }
    data[m][i]=sum;
    sum=0;
  }
  sum=0;
  for(j=0;j<m;j++){
    for(i=0;i<n;i++){
      sum+=data[j][i]; 
    }
    data[j][n]=sum;
    sum=0;
  }
  data[m][n]=ans;
  for(i=0;i<n+1;i++){
    for(j=0;j<m+1;j++){
      if(j!=0&&j!=m+1){
	printf(" ");
      }
      printf("%d",data[j][i]);
    }
    printf("\n");
  }
  return(0);
}

Measured memory_bytes: 1068
# 逆順に見ていく
# M本の橋が全て崩落した状態=全ての島が行き来できない=不便さ:N*(N-1)//2
# 橋ができたら、UnionFindで一つに島グループとしてつなぐ
# 新たにできた橋が、今まで別の島グループだったときは
# 二つの島グループの間の組み合わせの数だけ不便さが減る
# 島グループ1の数 * 島グループ2の数だけ不便さが減る
# 新たにできた島グループが同じ島グループだったときは何も変わらない

import sys
readline=sys.stdin.readline

# 0-indexed
class UnionFind:
  N=0
  parent=None
  size=None
  def __init__(self,N):
    self.N=N
    self.parent=[i for i in range(self.N)]
    self.size=[1]*self.N
    
  def root(self,x):
    while x!=self.parent[x]:
      self.parent[x]=self.parent[self.parent[x]]
      x=self.parent[x]
    return x
  
  def same(self,x,y):
    return self.root(x)==self.root(y)
  
  def unite(self,x,y):
    x=self.root(x)
    y=self.root(y)
    if x==y:
      return
    if self.size[x]>self.size[y]:
      # 大きい方にくっつける
      self.parent[y]=x
      self.size[x]+=self.size[y]
    else:
      self.parent[x]=y
      self.size[y]+=self.size[x]
      
  def get_group_size(self,x):
    return self.size[self.root(x)]
  
  def get_roots(self):
    r=set()
    for i in range(self.N):
      r.add(root(i))
    return r
  
  def show_parent(self):
    print(self.parent)
    
  def show_size(self):
    print(self.size)
    
N,M=map(int,readline().split())
UF=UnionFind(N)
ans=[N*(N-1)//2]
decay=[None]*M
for i in range(M):
  a,b=map(int,readline().split())
  decay[M-1-i]=[a-1,b-1]
  
# decayは逆順になっている
for i in range(M):
  a,b=decay[i]
  if UF.same(a,b):
    ans+=[ans[-1]]
  else:
    asize=UF.get_group_size(a)
    bsize=UF.get_group_size(b)
    ans+=[ans[-1]-asize*bsize]
    UF.unite(a,b)
    
for i in range(len(ans)-2,-1,-1):
  print(ans[i])


Measured memory_bytes: 27272
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
  char s[104];
  int flag = 0;
  char *n;

  scanf("%s", s);
  n = s;

  while(*n != '\0'){
    if(*n == 'L') flag = 1;
    n++;
    if(*n != '\0' && *n == 'R') flag = 1;
    n++;
  }

  if(flag == 1) printf("No\n");

  else printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
MOD = 10**9 + 7


def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0]*N
    ans = 3
    for a in A:
        if a == 0:
            if B[a] == 1:
                ans *= 2
        else:
            ans *= B[a-1] - B[a]
        B[a] += 1
        if 3 < B[a] or (a != 0 and B[a-1] < B[a]):
            ans = 0
            break
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84472
#include <stdio.h>
#include <string.h>

int c[15], a[15][15];

int main() {
    int n, m, x;
    scanf("%d %d %d", &n, &m, &x);
    for (int i = 0; i < n; i++) {
        scanf("%d", &c[i]);
        for (int j = 0; j < m; j++)
            scanf("%d", &a[i][j]);
    }
    int ans = -1;
    for (int i = 1; i < (1 << n); i++) {
        int cs = 0, sum[15];
        memset(sum, 0, 15 * sizeof(int));
        for (int j = 0; j < n; j++)
            if (i & (1 << j)) {
                cs += c[j];
                for (int k = 0; k < m; k++)
                    sum[k] += a[j][k];
            }
        int ok = 1;
        for (int j = 0; j < m; j++)
            if (sum[j] < x) ok = 0;
        if (ok && (ans == -1 || ans > cs)) ans = cs;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1704
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
string s[200];
int d[200][200];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>s[i];
		for(int j=0;j<N;j++)
		{
			d[i][j]=i==j?0:s[i][j]=='1'?1:1e9;
		}
	}
	for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++)
	{
		d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	}
	int ans=0;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)
    {
        ans=max(ans,d[i][j]);
        for(int k=0;k<N;k++)if((d[i][k]+d[k][j]+d[i][j])%2)
          {
          cout<<-1<<endl;
          return 0;
          }
      }
	cout<<ans+1<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int cnt=0;
    for(int i=0;i<n;++i){
        cin >> p[i];
        if(p[i]!=i+1) ++cnt;
    }
    if(cnt<=2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define LL long long
#define M 1000000007
#define F(i,j) f[i+2020][j+2020]
using namespace std;
int n,f[5050][5050],A[205020],B[205020],ans; LL js[8050],inv[8050];
inline LL pow(LL x,LL k,LL s=1){
	for(;k;x=x*x%M,k>>=1) k&1?s=s*x%M:0;
	return s;
}
inline LL C(int n,int m){
	return js[n]*inv[m]%M*inv[n-m]%M;
}
inline void ad(int& x,LL y){ x=(x+y)%M; }
int main(){
	scanf("%d",&n);
	for(int i=*js=1;i<=8000;++i) js[i]=js[i-1]*i%M;
	inv[8000]=pow(js[8000],M-2);
	for(int i=8000;i;--i) inv[i-1]=inv[i]*i%M;
	for(int i=1;i<=n;++i){
		scanf("%d%d",A+i,B+i);
		F(-A[i],-B[i])++;
	}
	for(int i=-2000;i<=2000;++i)
		for(int j=-2000;j<=2000;++j)
			ad(F(i,j),F(i-1,j)+F(i,j-1));
	for(int i=1;i<=n;++i) 
		ad(ans,F(A[i],B[i])-C(A[i]+B[i]<<1,A[i]<<1)+M);
	printf("%lld\n",ans*pow(2,M-2)%M);
}

Measured memory_bytes: 81792
#!/usr/bin/env python3
S = input()
Q = int(input())

count = True
ans = S

ireru_mae = ''
ireru_usiro = ''
for i in range(Q):
    T = input().split()
    if len(T)==1:
        count = not(count)
        ans = ireru_mae + ans + ireru_usiro
        ireru_mae = ''
        ireru_usiro = ''
        continue

    if count:
        if T[1] == '1': ireru_mae = T[2] + ireru_mae
        else: ireru_usiro += T[2]
    else:
        if T[1] == '1': ireru_usiro += T[2]
        else: ireru_mae = T[2] + ireru_mae

ans = ireru_mae + ans + ireru_usiro
if count:
    print(ans)
else:
    print(ans[::-1])


Measured memory_bytes: 4428
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
	int N = sc.nextInt();
      long tus=0;
for(int i=1;i<N;i++){
  tus=tus+i;
}

      System.out.println(tus);

    }
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
}
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  int N;
  map<int, int> A;

  void init() {
    cin >> N;
    int a;
    rep(i, N) {
      cin >> a;
      A[a]++;
    }
  }

  void solve() {
    using P = pair<int, int>;
    priority_queue<P> que;
    for(const auto& pr : A) {
      que.push(make_pair(pr.second, pr.first));
    }
    while(que.size() >= 2) {
      auto pr1 = que.top(); que.pop();
      auto pr2 = que.top(); que.pop();
      if(pr1.first >= 3) {
        que.push(make_pair(pr1.first - 2, pr1.second));
        que.push(make_pair(pr2.first - 0, pr2.second));
      } else if(pr1.first == 2 && pr2.first == 2) {
        que.push(make_pair(pr1.first - 1, pr1.second));
        que.push(make_pair(pr2.first - 1, pr2.second));
      } else if(pr1.first == 2 && pr2.first == 1) {
        que.push(make_pair(pr1.first - 1, pr1.second));
      } else {
        que.push(make_pair(pr1.first - 0, pr1.second));
        que.push(make_pair(pr2.first - 0, pr2.second));
        break;
      }
    }
    cout << que.size() << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 6140
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>


#define LL long long int
using namespace std;


int main(void)
{
	int n, k;
	int i;
	vector<int> a;
	vector<int> memo;
	int m = 0;

	cin >> n >> k;
	a.resize(n + 1);
	memo.resize(n + 1);

	for (i = 0; i < n + 1; i++) {
		memo[i] = 0;
	}

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

	reverse(memo.begin(), memo.end());

	for (i = 0; i < k; i++) {
		m = m + memo[i];
	}

	cout << n - m << endl;



	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
ll dp[3000][3000][2];
int main()
{
	int num;
	scanf("%d", &num);
	vector<pii>v;
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		v.push_back(make_pair(za + zb, za));
	}
	sort(v.begin(), v.end());
	for (int i = 0; i <= num / 2; i++)for (int j = 0; j <= num / 2; j++)for (int k = 0; k <= num % 2; k++)dp[i][j][k] = 1000000000000000000LL;
	dp[0][0][0] = 0;
	for (int i = 0; i <= num / 2; i++)
	{
		for (int j = 0; j <= num / 2; j++)
		{
			for (int k = 0; k <= num % 2; k++)
			{
				if (i + j + k>= v.size())continue;
				ll a = v[i + j + k].second, b = v[i + j + k].first - a;
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k] + b + (ll)(num / 2 - i - 1)*(a + b));
				dp[i][j + 1][k] = min(dp[i][j + 1][k], dp[i][j][k] + a + (ll)(num / 2 - j - 1)*(a + b));
				if (k < num % 2)dp[i][j][k + 1] = min(dp[i][j][k + 1], dp[i][j][k] + (a + b)*(ll)(num / 2));
			}
		}
	}
	printf("%lld\n", dp[num / 2][num / 2][num % 2]);
}

Measured memory_bytes: 119040
function main(input){
    const args = input.split(" ");
    const A = parseInt(args[0]);// カーテンレールの長さ
    const B =  parseInt(args[1]); // 2枚取り付けられるカーテンの長さ
    const result = A - B * 2;
    if(result < 0){
        console.log(0)
    }else{
        console.log(result)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int ans;
int i;
int main(void){
    int n; cin >> n;
    while (i * i <= n) {
        ans = i * i;
        ++i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
N, Y = list(map(int, input().split()))

foundFlg = False
for x in range(N+1):
    for y in range(N+1):
        if x + y > N:
            break
        z = N - x - y
        if z >= 0 and x*10000+y*5000+z*1000 == Y:
            print("{} {} {}".format(x, y, z))
            foundFlg = True
            break
        if foundFlg:
            break
    if foundFlg:
        break

if not foundFlg:
    print("-1 -1 -1")


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
from itertools import chain
# import numpy as np


def solve(X: int, K: int, D: int):
    X = abs(X)
    n = X // D
    if n >= K:
        return X - D * K
    m = X % D
    if (K - n) % 2 == 0:
        return m
    else:
        return D-m


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    X = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    ans = solve(X, K, D)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    h,w,k = get_nums_l()
    grid_s = [input() for _ in range(h)]

    ans = 0
    for by in range(2**h):
        for bx in range(2**w):
            c = 0

            for y in range(h):
                for x in range(w):
                    if 2**y & by == 0 and 2**x & bx == 0 and grid_s[y][x] == "#":
                        c += 1

            if c == k:
                ans += 1
    
    print(ans)


main()

Measured memory_bytes: 68900
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <functional>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#define SIZE 300
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int dp[SIZE][SIZE];

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		for(int j=i;j>0;j--)
		{
			for(int k=0;k<SIZE;k++)
			{
				if((k^a)<SIZE)
				{
					dp[j][k]+=dp[j-1][k^a];
					if(dp[j][k]>=MOD) dp[j][k]-=MOD;
				}
			}
		}
	}
	ll ret=0,fac=1;
	for(int i=1;i<=n;i++)
	{
		fac=fac*(ll) i%MOD;
		ret+=fac*(ll) dp[i][k];
		ret%=MOD;
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 640
/* 剰余取り忘れてしもたwガハハw　*/
#include <stdio.h>
#include <string.h>

int dp[50][3001];

int main() {
    while (1) {
        int i;
        int n, m, s;
        int square;
    
        scanf("%d %d %d", &n, &m, &s);
        if (n == 0 && m == 0 && s == 0) {
            return 0;
        }
    
        memset(dp, 0, sizeof(dp));
 
        square = n*n;
        dp[0][0] = 1;
        
        for (i=1; i<m+1; i++) {
            int j;

            for (j=s; j>=i; j--) {
                int k;

                for (k=0; k<square; k++) {
                    dp[k+1][j] += dp[k][j-i];
                    dp[k+1][j] %= 100000;
                }
            }
        }
    
        printf("%d\n", dp[square][s]);
    }
}

Measured memory_bytes: 1620
#include<stdio.h>
int main(void)
{
	int i,j,k,l,n,cnt;
	while(scanf("%d",&n)!=EOF){
		cnt=0;
		for(i=0;i<10;i++){
			for(j=0;j<10;j++){
				for(k=0;k<10;k++){
					for(l=0;l<10;l++){
						if(i+j+k+l==n){
							cnt++;
						}
					}
				}
			}
		}
		printf("%d\n",cnt);	
	}
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') insert(key);
    else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L') deleteLast();
      } else deleteKey(key);
    }
  }
  printList();
  return 0;
}


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


class UnionFind{
    public:
    vector<int> Parent;

    UnionFind(int N){
        Parent = vector <int> (N, -1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A] = root(Parent[A]);
    }
    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A, int B){
        A = root(A);
        B = root(B);
        if(A==B){
            return false;
        }
        if(size(A) < size(B)) swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;
        return true;
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    int A[M], B[M];
    rep(i, M){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    vector<ll> ans(M);
    ans[M-1] = (ll) N*(N-1)/2;

    UnionFind Uni(N);

    for(int i = M-1;i>=1;i--){
        // 繋がってなかったのが繋がった場合
        if(Uni.root(A[i]) != Uni.root(B[i])){
            ans[i-1] = ans[i] - (ll) Uni.size(A[i]) * Uni.size(B[i]);
            Uni.connect(A[i], B[i]);
        }
        else ans[i-1] = ans[i];

    }
    rep(i, M){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int n = sc.nextInt(); int m = sc.nextInt();
		int[][] a = new int[n][m];
		int[] b = new int[m];
		for (int i=0; i<n; i++) {
			for (int j=0; j<m; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		for (int i=0; i<m; i++) b[i] = sc.nextInt();
		
		for (int i=0; i<n; i++) {
			int ans = 0;
			for (int j=0; j<m; j++) {
				ans += a[i][j] * b[j];
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 40392
#include <cstdio>
#include <algorithm>
using namespace std;
const long long NR=210000;
long long n,a[NR];
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	for(long long i=1;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

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

#define int long long

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

signed main()
{
	int n = read();
	if (n % 2 == 0 || n % 5 == 0) return puts("-1"), 0;
	
	for (int i = 1, j = 7 % n; i <= n; ++i)
	{
		if (j == 0) return printf("%d\n", i), 0;
		j = (j * 10 + 7) % n;
	}
	return 0;
}


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

int main(void){
    int N;
    cin >> N;
    int ans=1;
    int z;
    int a[1000];
    int idx = 0;
    for(int i =2 ;i < 11 ; i++){
        for(int j =1; j <40; j++){
            z = pow(j, i);
            
            if(z<=1000){
                a[idx] = z;
                idx++;
            }
            else break;
        }
    }
    sort(a, a+idx);
    for(int i = 0 ; i < idx ; i++){
        if (N >= a[i] ) ans = a[i];
        else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <set> 
#include <string> 
#include <iomanip> 
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
    int n,i;
    cin >> n;

    int deme1[n],deme2[n];
    for(i=0;i<n;i++){
        cin >> deme1[i];
        cin >> deme2[i];
    }

    for(i=0;i<n-2;i++){
        if(deme1[i] == deme2[i] && deme1[i+1] == deme2[i+1] && deme1[i+2] == deme2[i+2]) {
            cout << "Yes";
            break;
        }
    }
    if(i==n-2) cout << "No";
    return 0;
}

Measured memory_bytes: 3620
S = gets.strip

if !S[0].eql?('A')
  puts 'WA'
elsif !(S[2, S.size - 3].count('C') == 1)
  puts 'WA'
elsif !S[1..-1].match(/[ABD-Z]/).nil?
  puts 'WA'
else
  puts 'AC'
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj));
typedef string str;
typedef long l;
typedef long long ll;
const ll INF=1e18;
const int mod=1e9+7; 
#define ins(a) cin >> a;
#define ind(a,b) cin >> a >> b;
#define rep(i,n) for(int i=0;i<n;i++)
#define endl cout << endl;
#define print(a) cout << a << endl;

int main()
{
    int h,w,n,cnt=0;
    cin >> h >> w >> n;
    vector<int> a(n);
    vector<int> x(w);
    rep(i,n)ins(a.at(i));
    rep(i,h){
        if(i%2){
            for(int j=w-1;j>=0;j--){
                a.at(cnt)--;
                x.at(j)=cnt+1;
                if(a.at(cnt)==0) cnt++;
            }
            rep(j,w)cout << x.at(j) << " ";
            endl
        }else{
            rep(j,w){
                a.at(cnt)--;
                cout << cnt+1 << " ";
                if(a.at(cnt)==0) cnt++;
            }
            endl
        }
    }
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bc155_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = CIn.ReadInt();
            var S = CIn.ReadStringArray(N);
            var dic = new Dictionary<string, int>();
            var max = 0;
            foreach(var s in S)
            {
                if (dic.ContainsKey(s))
                {
                    dic[s]++;
                }
                else
                {
                    dic.Add(s, 1);
                }
                max = Math.Max(max, dic[s]);
            }
            var list = new List<string>();

            foreach(var kvp in dic)
            {
                if(kvp.Value == max)
                {
                    list.Add(kvp.Key);
                }
            }
            list.Sort(StringComparer.Ordinal);

            foreach(var ans in list)
            {
                Console.WriteLine(ans);
            }
        }
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }

            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}


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

int main() {
  ll c;
  cin >> c;

  ll a_ans, b_ans;

  for (int i=-120;i<120;i++) {
    for (int j=-120;j<120;j++) {
      if (pow(i,5)-pow(j,5)==c) {
        a_ans = i;
        b_ans = j;
        break;
      }
    }
  }
  cout << a_ans << " " << b_ans << endl;
}



Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int id = -1;
    ll mx = 0;
    bool p = true;
    rep(i,n){
        if(abs(a[i]) > mx){
            mx = abs(a[i]);
            id = i;
            if(a[i] > 0) p = true;
            else p = false;
        }
    }
    if(id==-1){
        cout << 0 << endl;
        return 0;
    }
    vector<P> ans;
    if(p){
        rep(i,n-1){
            if(a[i]<=a[i+1]) continue;
            else{
                while(a[i]>a[i+1]){
                    a[i+1] += mx;
                    ans.push_back(P(id,i+1));
                }
                if(a[i+1] > mx){
                    mx = a[i+1];
                    id = i+1;
                }
            }
        }
    }else{
        for(int i=n-2;i>=0;i--){
            if(a[i]<=a[i+1]) continue;
            else{
                while(a[i]>a[i+1]){
                    a[i] -= mx;
                    ans.push_back(P(id,i));
                }
                if(a[i] < 0 && -a[i] > mx){
                    mx = -a[i];
                    id = i;
                }
            }
        }
    }
    cout << (int)(ans.size()) << endl;
    rep(i,ans.size()) cout << (ans[i].first+1) << " " << (ans[i].second+1) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  int n;
  cin >> n;

  if (n % 1000 == 0) {
    cout << "0" << endl;
    return 0;
  }
  int ret = ((n / 1000) + 1) * 1000 - n;
  // int r1 = n - 1000 * (n / 1000);
  // int m = n + 1000;
  // int r2 = n - 1000 * (m / 1000);
  // // cout << r1 << " " << r2 << endl;
  // if (n < 1000) {
  //   int tmp = 1000 - n;
  //   cout << tmp << endl;
  //   return 0;
  // }

  // int ret = min(abs(r1), abs(r2));
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
typedef array<LL,3> A;
P operator+(const P& lhs, const P& rhs)
{
	return P(lhs.first+rhs.first, lhs.second+rhs.second);
}
const int NN=1e5+10;
int rep[NN];
int Find(int a){
	while(rep[a]!=a){
		a=rep[a]=rep[rep[a]];
	}
	return a;
}
int mergedTo[NN];
vector<int> mergedBy[NN];
int lastEvent[NN];
vector<int> event[NN];
vector<P> weight[NN];
void Union(int a, int b,int e){
	a=Find(a);
	b=Find(b);
	if(a==b){
		return;
	}
	if(weight[a].back()<weight[b].back()){
		swap(a,b);
	}
	auto sum=weight[a].back()+weight[b].back();
	mergedTo[b]=a;
	lastEvent[b]=e;
	weight[a].push_back(sum);
	mergedBy[a].push_back(b);
	event[a].push_back(e);
	rep[b]=a;
}

int Find(int a,int e){
	while(rep[a]!=a&&lastEvent[a]<=e){
		a=mergedTo[a];
	}
	return a;
}
P Weight(int a, int e){
	int pos=lower_bound(event[a].begin(),event[a].end(),e)-event[a].begin();
	if(pos==event[a].size()||event[a][pos]!=e){
		pos--;
	}
	return weight[a][pos];
}
A es[NN];
bool ok[NN];
vector<P> edge[NN];
void dfs(int i,int e){
	ok[i]=true;
	for(auto a:edge[i]){
		if(a.second<=e&&!ok[a.first]){
			dfs(a.first,e);
		}
	}
}
int main() {
	int N,M;
	cin >> N >> M;
	for(int i=1;i<=N;i++){
		rep[i]=i;
		event[i].push_back(0);
		int X;
		cin >> X;
		weight[i].push_back(P(1,X));
		mergedBy[i].push_back(i);
	}
	for(int i=0;i<M;i++){
		int a,b,y;
		cin >> a >> b >> y;
		es[i]=A{{y,a,b}};
	}
	sort(es,es+M);
	for(int i=0;i<M;i++){
		Union(es[i][1],es[i][2],i+1);
		edge[es[i][1]].push_back(P(es[i][2],i+1));
		edge[es[i][2]].push_back(P(es[i][1],i+1));
	}
	int ret=0;
	for(int i=M-1;i>=0;i--){
		int a=es[i][1];
		if(ok[a]){
			continue;
		}
		a=Find(a,i+1);
		P p=Weight(a,i+1);
		//cerr << i << ", " << p.first << ", " << p.second << endl;
		if(p.second>=es[i][0]){
			dfs(a,i+1);
		}
		else{
			//cerr << i << endl;
			ret++;
		}
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 34288
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
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; }
using Graph = vector<vector<int> >;
using P = pair<int, int>; 
// MOD
const int MOD = 1000000007;
using ll = long long;
long long INF = 1<<30;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
//int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int H, W;
int field[100][100];

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI=3.14159265358979323846;
bool seen[100][100];

bool memo[110];
bool flag;
Graph G;

int dist[100][100];

bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second< y.second;
}

struct Unionfind{
    vector<int> par;

    Unionfind(int n) : par(n, -1){}

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    } 

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x]>par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    //ll a = 2000000000, b = 0, c = 0, k =2000000000;
    long long a, b, c, k; cin >> a >> b >> c >> k;
    long long ans = 0;
    if(k<a) for(ll i=0; i<k; i++) ans += 1;
    else if(k == a) ans = k;
    else for(ll i=0; i<a; i++) ans+= 1;
    if(k<=a+b and k>a) ans+=0;
    else ans += 0;
    if(k<=a+b+c and k>a+b) for(ll i=0; i<k-(a+b); i++) ans-=1;
    //for(int i=0; i<a; i++) ans += 1;
    cout << ans << endl;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(N - 1) - vec.at(0) << endl;
}

Measured memory_bytes: 256
/* 
* code by: imasnegi
**/

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

#define ll long long
#define nl "\n"
#define spc " "
#define fr(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define deb(a) cout << #a << " " << a << nl;

template<typename T>
void printArray(vector<T>& v) {
	for(auto& i : v)
		cout << i << spc;
	cout << nl;
}
const int MaxN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve_cases() {
	string s;
	cin >> s;
	ll sum = 0;
	for(auto& ch : s) {
		sum += ch - '0';
	}
	
	if(sum % 9 == 0) {
		cout << "Yes" << nl;
	}
	else cout << "No" << nl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cout << setprecision(10) << fixed;
	int t = 1;
	//cin >> t;
	FOR(tt, 1, t) {
		//cout << "Case #" << tt << ": ";
		solve_cases();
	}
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r, x;

int32_t main(){
INIT
cin>>n>>x>>t;
cout<<((n/x)+(((n%x)>0)?(1):(0)) )*t;


return 0;
}





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

using namespace std;

int main()
{
    int i,j,k,n,m,x,y=0,z,a,b;
    cin>>a;
    int c[a];
    for(i=0;i<a;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<a-1;i++)
    {
        for(j=i+1;j<a;j++)
        {
            y=y+(c[i]*c[j]);
        }
    }
    cout<<y<<endl;
}


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

queue<int> shuffle(queue<int>,int,int);

int main(int argc,char* argv[]){
  int n,r,p,c,val;

  while(true){
	cin >> n >> r;
	if(n == 0 || r == 0)
	  break;

	queue<int>que;
	for(int i = 1;i <= n;i++)
	  que.push(i);
	
	for(int i = 0;i < r;i++){
	  cin >> p >> c;
	  que = shuffle(que,p,c);
	}

	while(!que.empty()){
	  val = que.front();que.pop();
	}
	cout << val << endl;
  }

  return 0;
}

queue<int> shuffle(queue<int> que,int p,int c){
  queue<int> tmp;
  int n = que.size();
  for(int i = 1;i <= n;i++){
	if(i <= (n-(c+p-1)) || i > n-(p-1)){
	  que.push(que.front());
	  que.pop();
	}
	else{
	  tmp.push(que.front());
	  que.pop();
	}
  }
  while(!tmp.empty()){
	que.push(tmp.front());
	tmp.pop();
  }
  return que;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

#define ll long long
#define pint pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(),(VECTOR).end()

int main(){

	int N;
	double ans = 0.0;
	cin >> N;
	double x;
	string u;
	const string JPY = "JPY";
	for(int i = 0; i < N; i ++){
		cin >> x >> u;
		if(u == JPY)ans += x;
		else ans += 380000.0 * x;
	}
	cout << ans << endl;

	return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b, x ,y;
    cin >> x >> y;

    if(y%2==1) {
        cout << "No" << endl;
        return 0;
    }

    a = 2*x-y/2;
    b = y/2-x;
    if(a<0||b<0) {
        cout << "No" << endl;
        return 0;
    }

    if(a+b==x&&2*a+4*b==y) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 3632
h,w=map(int,input().split())
s=[input() for _ in range(h)]
dp=[[10**9]*w for _ in range(h)]
dp[0][0]=(s[0][0]=='#')+0
for i in range(h):
  for j in range(w):
    a=dp[i-1][j]
    b=dp[i][j-1] 
    if s[i-1][j] == "." and s[i][j] == "#":
      a+=1
    if s[i][j-1] == "." and s[i][j] == "#":
      b+=1
    dp[i][j]=min(a,b,dp[i][j])
print(dp[-1][-1])


Measured memory_bytes: 72896
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string> 
using namespace std;
int main(){
	string s;
	cin>>s;
	long long f = 0;
	int d = 0;
	long long sum = 0;
	for(int i=0;i<s.length();i++){
		if(s[i] == 'W'){
			sum+=f;
		}else{
			f++;
		}
	}
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 640
n,m = map(int,input().split())
ka = list(list(map(int,input().split())) for _ in range(n))

like = [0]*m
for i in range(n):
    for j in range(1,ka[i][0]+1):
        like[ka[i][j]-1] += 1

answer = 0
for i in range(m):
    if like[i] == n:
        answer += 1

print(answer)


Measured memory_bytes: 3060
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int w[100010], d[100010];
signed main(void)
{
  int n, k;
  cin >> n >> k;
  REP(i, n) cin >> w[i] >> d[i];

  auto check = [&](int mid) -> bool {
    int tmp = 0;
    REP(i, n) {
      // mid以下までに何個置けるか
      if(mid >= w[i]) {
        tmp += (mid - w[i])/d[i] + 1;
      }
    }
    return tmp >= k;
  };

  int lb = -1, ub = 2e18+1;
  while(ub-lb>1) {
    int mid = (lb+ub)/2;
    if(check(mid)) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  cout << ub << endl;

  return 0;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**7)

n = int(input())
T = [[] for _ in range(n)]
ab = [ tuple(map(int, input().split())) for _ in range(n-1) ]
for a, b in ab:
  T[a-1].append(b-1)
  T[b-1].append(a-1)
d = { (min(a)-1, max(a)-1):i for i, a in enumerate(ab) }
A = [1]*(n-1)
M = [set() for _ in range(n)]
seen = [False]*n
seen[0] = True
def dfs(v):
  now = 1
  for nv in T[v]:
    if not seen[nv]:
      seen[nv] = True
      while now in M[v]:
        now += 1
      A[d[(min(v, nv), max(v, nv))]] = now
      M[v].add(now)
      M[nv].add(now)
      dfs(nv)
dfs(0)
print(max(A), *A, sep="\n")

Measured memory_bytes: 99720
n=int(input())
a=[int(i) for i in input().split()]

b=a[:]
a.sort()

one=a[n//2-1]
two=a[n//2]

def get_median(i):
    if b[i]<=one:
        return two
    return one

for i in range(n):
	print(get_median(i))

Measured memory_bytes: 30780
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,t;
	long long p,a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld %lld",&a,&b);
		p=a*b;
		t=(long long)sqrt(p);
		if((long long)t*t==p)
		{
			if(a==b)
				printf("%lld\n",((long long)t-1)*2);
			else
				printf("%lld\n",((long long)t-1)*2-1);
		}
		else
		{
			if((long long)t*(t+1)<p)
				printf("%lld\n",(long long)t*2-1);
			else
				printf("%lld\n",(long long)t*2-2);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> vec(n);
  REP(i,n) cin >> vec[i];
  sort(vec.begin(),vec.end());
  int sum = 0;
  bool ans = false;
  REP(i,n-1) sum += vec[i];
  if(vec[n-1] < sum) ans = true;
  YesorNo(ans);
  }

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static int[] bit;
    static int n;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = 1<<m; // definition of n is different from in the question
        int[][] dp = new int[n][2];
        int[] A = new int[n];
        int[] ans = new int[n];
        for(int i=0;i<n;i++) A[i] = sc.nextInt();
        PriorityQueue<Integer> pq = new PriorityQueue<>(10,(Integer a, Integer b)->A[a]-A[b]);
        HashSet<Integer> record = new HashSet<>();
        PrintWriter out = new PrintWriter(System.out);
        for(int k=1;k<n;k++){
            record.clear();
            pq.clear();
            // option 1: directly come from k-1
            // option 2: i|j==k
            record.add(0);record.add(k);
            pq.add(0);pq.add(k);
            for(int i=1<<19;i>=1;i=i/2){
                if((i&k)==0) continue;
                for(int w:dp[i^k]){
                    if(record.add(w)) pq.add(w);
                }
            }
            while(pq.size()>2) pq.poll();
            dp[k][0] = pq.poll();
            dp[k][1] = pq.poll();
            int res = Math.max(ans[k-1],A[dp[k][0]]+A[dp[k][1]]);
            ans[k] = res;
            out.println(res);
        }
        out.flush();
    }
}

Measured memory_bytes: 189328