akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main ()
{
  int X,Y,Z;
  scanf ("%d %d %d",&X,&Y,&Z);
  if (X>=1&&X<=100&&Y>=1&&Y<=100&&Z>=1&&Z<=100)
  {
      printf ("%d %d %d\n",Z,X,Y);
  }
  return 0;
}


Measured memory_bytes: 2148
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();

		long[]dp=new long[11];
		dp[0] = X;

		for (int i = 1; i < 11; i++) {
			dp[i] = r * dp[i-1] - D;
			System.out.println(dp[i]);
		}

		sc.close();
	}

}


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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        char c = (char) System.in.read();
        int b=0;
        if( c>=97 && c<122){
            b = c + 1;
        }
        else {
            System.out.println("Not allowed");
        }
        c =(char)b;
        System.out.println(c);
    }
}

Measured memory_bytes: 20820
# -*- coding: utf-8 -*-
from functools import reduce
N = int(input())
ary = []
for i in range(N):
    tmp = input()
    ary.append(int(tmp))


def GCD(a, b):
    if a < b:
        a, b = b, a

    while b > 0:
        a, b = b, a % b
    return a


def LCM(a, b):
    return a * b // GCD(a, b)


print(reduce(LCM, ary))


Measured memory_bytes: 3572
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        n %= k;
        if (2 * n < k) {
            System.out.println(n);
        } else {
            n = k % n;
            System.out.println(n);
        }
        sc.close();
    }
}

Measured memory_bytes: 23764
#include <iostream>
//#include<cstring>
//#include <iomanip>

using namespace std;

long long combination(long long a)
{
  long long ans;
  ans=a*(a-1)/2;
  return ans;
}

int main()
{
  int N,i,j;
  long long all,count,ans,memory;
  cin>>N;
  int A[N];
  int B[N]={};
 
  //配列に格納，その数字を覚えてBに数を入力
  for(i=0;i<N;i++)
  {
    cin>>A[i];
    memory=A[i];
    B[memory-1]++;
  }

  all=0;
  for(i=0;i<N;i++)
  {
    count=combination(B[i]);
    all+=count;
  }
  //cout<<all<<"\n\n";//引かない場合
  
  for(i=0;i<N;i++)
  {
    count=A[i];
    ans=combination(B[count-1]);
    //cout<<ans-1<<" ";
    cout<<all+1-B[count-1]<<"\n";
  }   
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf (1 << 21)
#define mod 1000000007

int main() {
    string S; cin >> S;
    int ans = inf;
    for (int i = 0; i < S.size() - 2; i++) {
        string s;
        for (int j = i; j < i + 3; j++) {
            s += S.at(j);
        }
        int x = stoi(s);
        x = abs(753 - x);
        ans = min(x, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], c[110][110];
int main(){
  int n, m, nn;
  cin>>n>>m>>nn;
  memset(c, -1, sizeof c);
  for(int i=1; i<=nn; ++i){
    scanf("%d",&a[i]);
  }
  int cnt=1;
  int rl=0, ud=1, x=0, y=0, z=1, xx, yy;
  c[x][y]=1;--a[z];
  while(cnt<n*m){
//    cout<<cnt<<", "<<x<<", "<<y<<" "<<rl<<" "<<ud<<endl;
    if(rl==1){
      yy=y+1;
    }
    else if(rl==-1){
      yy=y-1;
    }
    else{
      yy=y;
    }
    if(ud==1){
      xx=x+1;
    }
    else if(ud==-1){
      xx=x-1;
    }
    else{
      xx=x;
    }
    if(c[xx][yy]!=-1||xx>=n||xx<0||yy>=m||yy<0){
      if(rl==1){
        rl=0;
        ud=-1;
      }
      else if(rl==-1){
        rl=0;
        ud=1;
      }
      else if(ud==1){
        rl=1;
        ud=0;
      }
      else if(ud==-1){
        rl=-1;
        ud=0;
      }
    }
    else{
      ++cnt;
      x=xx;y=yy;
      if(a[z]==0)
        ++z;
      c[x][y]=z;
      --a[z];
    }
  }
  for(int i=0; i<n; ++i){
    for(int j=0; j<m; ++j){
      printf("%d ",c[i][j]);
    }
    printf("\n");
  }
  return 0;
}




Measured memory_bytes: 384
#include<iostream>

using namespace std;


int findSumOfDigits(int num) {
    int sum = 0;

    while (num > 0) {
        sum += num % 10;
        num /= 10;
    }

    return sum;
}

int main(void) {

    int N, A, B;
    int res = 0, sum;

    cin >> N >> A >> B;

    for (int i = 1; i <= N; i++) {
        sum = findSumOfDigits(i);
        
        if (sum>=A && sum <= B) {
            res += i;
        }
    }
    cout << res << endl;
}


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

int main(){
	double a, b, c, C;
	double S,L,h;

	cin>>a>>b>>C;

	h = b*sin(C/180*M_PI);
	S = a * h / 2;
	c = sqrt((pow(a,2)+pow(b,2) - 2 * a * b * cos(C/180*M_PI)));
	L = a+b+c;

	printf("%10lf\n", S);
	printf("%10lf\n", L);
	printf("%10lf\n", h);
}

Measured memory_bytes: 1248
def main():
    H, W = map(int, input().split())
    ans = float('inf')
    h1, h2, h3 = 0,0,0
    w1,w2,w1 = 0,0,0
    # 横3に切る場合
    h1 = H // 3
    h2 = H // 3
    h3 = H // 3
    if H % 3 == 1:
        h3 += 1
    elif H % 3 == 2:
        h2 += 1
        h3 += 1
    S = [h1*W,h2*W,h3*W]
    ans = min(max(S)-min(S),ans)
    # 横2縦1に切る場合
    h1 = H // 2
    h2 = H // 2
    h3 = H
    if H % 2 == 1:
        h2 += 1
    for w in range(1,W):
        S = [h1*(W-w),h2*(W-w),h3*w]
        ans = min(max(S)-min(S),ans)
    # 縦3に切る場合
    w1 = W // 3
    w2 = W // 3
    w3 = W // 3
    if W % 3 == 1:
        w3 += 1
    elif W % 3 == 2:
        w2 += 1
        w3 += 1
    S = [w1*H,w2*H,w3*H]
    ans = min(max(S)-min(S),ans)

    # 縦1横2に切る場合
    w1 = W // 2
    w2 = W // 2
    w3 = W
    if W % 2 == 1:
        w2 += 1
    for h in range(1,H):
        S = [w1*(H-h),w2*(H-h),w3*h]
        ans = min(max(S)-min(S),ans)

    print(ans)

if __name__ == "__main__":
    main()

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

int main() {
  int a,b,c;
  while(1){
    cin >> a >> b >> c;
    if(a== -1 && b== -1 && c== -1)
     break;
    if(a==-1 || b==-1)
      cout << 'F' << endl;
    else if(a+b>=80)
      cout << 'A' << endl;
    else if(a+b>=65 && a+b<80)
      cout << 'B' << endl;
    else if(a+b>=50 && a+b<65 || a+b>=30 && a+b<50 && c>=50)
      cout << 'C' << endl;
    else if(a+b>=30 && a+b<50 && c<50)
      cout << 'D' << endl;
    else if(a+b<30)
      cout << 'F' << endl;
    }
}



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

int main(){
  int n, b[200000],ans=0;
  cin >> n;
  for(int i=0;i<n-1;i++)cin >> b[i];
  ans=b[0]+b[n-2];
  for(int i=0;i<n-2;i++){
    ans+=min(b[i],b[i+1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
tbl = set()
dup = set()
vis = set()
for a in A:
   if a in vis:
      dup.add(a)
   else:
      vis.add(a)
   s = a
   while s < maxA:
      s += a
      tbl.add(s)

cnt = 0
for a in A:
   if a in dup:
      continue
   if a not in tbl:
      cnt += 1
print(cnt)

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

int main()
{
  string x,y,a,b,c;
  cin>>x;
  a="Sunny";b="Cloudy";c="Rainy";
  if(x==a)y=b;
  if(x==b)y=c;
  if(x==c)y=a;
  cout<<y<<endl;
  return 0;
}


Measured memory_bytes: 256
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}
template<typename T, int Begin, int End>
T& OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}
template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}

template<typename T, int N>
void Fill(T(&arr)[N], T val) {
	for (int i = 0; i < N; ++i) {
		Fill(arr[i], val);
	}
}
template<typename T, int M, int N>
void Fill2D(T(&arr)[M][N], T val) {
	for (int i = 0; i < M; ++i) {
		Fill(arr[i], val);
	}
}

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#endif

int X;
int main() {
	int sum = 0, i = 0;
	cin >> X;
	while (sum < X) {
		++i;
		sum += i;
	}
	cout << i;
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef unsigned long ulint;
const int mod = 2019;

int main() {
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 256
S,N,A,K,i,T,U;
main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d",&A,&K);
		while(A>K&&A%K)
		{
			T=A/K+1;
			A-=(A%K+T-1)/T*T;
		}
		S^=A/K;
	}
	puts(S?"Takahashi":"Aoki");
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n;
int main(){
	cin >> n;
	vector<int>h(n);
	rep(i,0,n)cin >> h[i];
	int temp_max = h[0];
	string ans = "Yes";
	rep(i, 1, n){
		if(h[i] > temp_max){
			temp_max = h[i] - 1;
		}else if(h[i] == temp_max){
			continue;
		}else {
			ans = "No";
		}
		// cout << temp_max << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

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

	map<string,int>mp;
	mp["AC"]=0;
	mp["WA"]=0;
	mp["TLE"]=0;
	mp["RE"]=0;

	string str;
	for(int i=0;i<n;i++){
		cin>>str;
		mp[str]++;
	}

	cout<<"AC "<<"x "<<mp["AC"]<<endl; 
	cout<<"WA "<<"x "<<mp["WA"]<<endl;
	cout<<"TLE "<<"x "<<mp["TLE"]<<endl;
	cout<<"RE "<<"x "<<mp["RE"]<<endl;
	return 0;
}


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

int main() {
	long long n,k,a;
	cin>>n>>k>>a;
	string s;
	//cin>>s;
	for(int i=0;i<10;++i) {
		int d = n*a-k;
		cout<<d<<" ";
		a = d;
	}
	return 0;
}

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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n, x;
  cin >> n >> x;
  if (n == 2) {
    if (x == 2) {
      cout << "Yes" << endl;
      cout << 1 << endl << 2 << endl << 3 << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }
  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  // ... 3 5 2 1 4
  // ... (2n-3) (2n-1) x 1 (2n-2)
  VI pool;
  pool.reserve(2 * n - 6);
  VI targ(5);
  if (n == 3 && x == 3) {
    REP(i, 0, 5) targ[i] = i + 1;
  } else if (x < 2 * n - 3) {
    REP(i, 2, 2 * n - 3) {
      if (i != x) pool.push_back(i);
    }
    targ[0] = 2*n-3;
    targ[1] = 2*n-1;
    targ[2] = x;
    targ[3] = 1;
    targ[4] = 2*n-2;
  } else {
    assert (x >= 4);
    // ... 3 1 x (2n-1) 2
    REP(i, 4, 2 * n - 1) {
      if (i != x) pool.push_back(i);
    }
    targ[0] = 3;
    targ[1] = 1;
    targ[2] = x;
    targ[3] = 2 * n - 1;
    targ[4] = 2;
  }
  REP(i, 0, n - 3) {
    cout << pool[i] << endl;
  }
  REP(i, 0, 5) {
    cout << targ[i] << endl;
  }
  REP(i, n - 3, 2 * n - 6) {
    cout << pool[i] << endl;
  }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define modo 1000000007
#define mod 998244353
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int x;
  cin>>x;
  if(x!=0){
    cout << 0 << endl;
    return 0;
  }

  vector<ll> p(n);
  rep(i,n-1){
    int y;
    cin>>y;
    if(y==0){
      cout << 0 << endl;
      return 0;
    }
    p[y]++;
  }

  repo(i,n-1){
    if(p[i]==0&&p[i+1]!=0){
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans=1;
  for(int i=1;i<n-1;i++){
    ans*=jou(p[i],p[i+1]);
    ans%=998244353ll;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

template<typename T>
struct SegmentTree {
private:
	int sz, n;
	vector<T> data;
	function<T(T, T)> f;
	T identity_element;
public:
	/* constructor */
	SegmentTree(
		const vector<T>& v, // initial data
		T identity_element, // identity element
		function<T(T, T)> f // operation
	) {
		sz = v.size();
		n = 1; while (n < sz) n <<= 1;
		this->f = f;
		this->identity_element = identity_element;
		data.resize(2 * n - 1, identity_element);
		for (int i = 0; i < sz; ++i)
			data[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; --i)
			data[i] = f(data[2 * i + 1], data[2 * i + 2]);
	}
	/* update query */
	void update(int idx, const T val) {
		idx += n - 1;
		data[idx] = val;
		while (idx) {
			idx = (idx - 1) >> 1;
			data[idx] = f(data[2 * idx + 1], data[2 * idx + 2]);
		}
	}
	/* get query */
	T get(int left, int right, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (r <= left || right <= l) return identity_element;
		if (left <= l && r <= right) return data[k];
		T val_l = get(left, right, 2 * k + 1, l, (l + r) / 2);
		T val_r = get(left, right, 2 * k + 2, (l + r) / 2, r);
		return f(val_l, val_r);
	}
};


int H, W, M;
vector<pair<int, int>> hw;
unordered_map<int, vector<int>> x_to_y, y_to_x;

void input(void) {
	cin >> H >> W >> M;
	hw.resize(M);
	for (int i = 0; i < M; ++i) {
		int h, w; cin >> h >> w;
		--h, --w;
		hw[i] = { h, w };
		x_to_y[w].push_back(h);
		y_to_x[h].push_back(w);
	}
}

int solve(void) {
	// seg木の用意
	vector<int> cnt(H, 0);
	for (auto& e : hw) 
		++cnt[e.first];
	SegmentTree<int> seg(
		cnt, 0, [](int a, int b) { return max(a, b); }
	);
	int res = 0;
	for (int i = 0; i < W; ++i) {
		// 各行消去
		for (auto& y : x_to_y[i]) {
			int tmp = seg.get(y, y + 1);
			seg.update(y, tmp - 1);
		}
		// resの更新
		res = max(res, seg.get(0, H) + (int)(x_to_y[i].size()));
		// 各行の復活
		for (auto& y : x_to_y[i]) {
			int tmp = seg.get(y, y + 1);
			seg.update(y, tmp + 1);
		}
	}
	return res;
}

int main(void) {
	input();
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 65800
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int nokori = a - b;
	c -= nokori;
	cout << ((c<0)?0:c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char Node[880][880];
int bs[880][880];
int zt[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
queue<int>QQ;
int my_min(int a,int b)
{
	return a<b ?a:b;
}
int merge(int r,int c)
{
	return r*800+c;
}
void ck(int sum,int &r,int &c)
{
	r=sum/800;
	c=sum%800;
}
int main()
{
	int h,w,k;
	scanf("%d %d %d",&h,&w,&k);
	memset(bs,-1,sizeof(bs));
	int sr,sc;
	for(int i=0;i<h;i++)
	{
		getchar();
		for(int k=0;k<w;k++)
		{
			scanf("%c",&Node[i][k]);
			if(Node[i][k]=='S')
				sr=i,sc=k;
		}
	}
	bs[sr][sc]=0;
	QQ.push(merge(sr,sc));
	int ans=1000000007;
	while(!QQ.empty())
	{
		int sum=QQ.front();
		QQ.pop();
		ck(sum,sr,sc);
	//	printf("%d %d\n",sr,sc);
		ans=my_min(ans,sr);
		ans=my_min(ans,sc);
		ans=my_min(ans,h-1-sr);
		ans=my_min(ans,w-1-sc);
		if(bs[sr][sc]==k)
			continue;
		for(int i=0;i<4;i++)
		{
			int nr,nc;
			nr=sr+zt[i][0];
			nc=sc+zt[i][1];
			if((nr>=0 && nr<h && nc>=0 && nc<w && bs[nr][nc]==-1 && Node[nr][nc]=='.'))
			{
				bs[nr][nc]=bs[sr][sc]+1;
				QQ.push(merge(nr,nc));
			}
		}
	}
	int aa=ans/k;
	if(ans%k!=0)
		aa++;
	printf("%d\n",aa+1);
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s,t;
    cin >> s >> t;
    int k = 0;
    int ans = 0;
    rep(i, s.length()-t.length()+1){
        string sub = s.substr(i, t.length());
        rep(j, t.length()){
            if(t[j] == sub[j]) k++;
        }
        ans = max(k, ans);
        k = 0;
    }
    cout << t.length() - ans << endl;
    return 0;
}

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

struct dsu {
  int cc;
  vector<int> p, sz, a;
  dsu(int n) : cc(n), p(n, -1), sz(n, 1), a(n) {}
  int root(int v) const {
    while (p[v] != -1) v = p[v];
    return v;
  }
  bool unite(int u, int v) {
    u = root(u), v = root(v);
    if (u == v) return false;
    --cc;
    if (sz[u] < sz[v]) swap(u, v);
    p[v] = u;
    sz[u] += sz[v];
    a[u] += a[v];
    return true;
  }
  bool same(int u, int v) const { return root(u) == root(v); }
  int size(int v) const { return sz[root(v)]; }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size() / 2;
  int m;
  cin >> m;
  vector<pair<int, int>> es;
  while (m--) {
    int l, r;
    cin >> l >> r;
    --l;
    if (s.size() & 1) {
      l -= l > n;
      r -= r > n;
    }
    if (l < n and n < r) {
      if (n - l > r - n) {
        r = 2 * n - r;
      } else if (n - l < r - n) {
        l = 2 * n - l;
      } else {
        continue;
      }
    }
    if (n <= l) {
      tie(l, r) = make_pair(2 * n - r, 2 * n - l);
    }
    es.emplace_back(l, r);
  }
  if (s.size() & 1) {
    s.erase(begin(s) + n);
  }
  dsu d(n + 1);
  for (int v = 0; v <= n; ++v) {
    int goal = (v < n ? s[2 * n - v - 1] : 'a') - (v ? s[2 * n - v] : 'a');
    int cur = (v < n ? s[v] : 'a') - (v ? s[v - 1] : 'a');
    d.a[v] = goal - cur + 260;
  }
  for (auto e : es) {
    d.unite(e.first, e.second);
  }
  for (int v = 0; v <= n; ++v) {
    if (d.a[d.root(v)] % 26) {
      cout << "NO\n";
      exit(0);
    }
  }
  cout << "YES\n";
}


Measured memory_bytes: 1732
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	for (long long int i = -200; i <= 200; i++) {
		for (long long int j = -200; j <= 200; j++) {
			if (i*i*i*i*i - j * j*j*j*j == N) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return(res);
}
int main(void) {
    int m, n; cin >> m >> n;
    
    cout << mod_pow(m, n, 1000000007) << endl;
    return(0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    ll a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200){
        cout<<s;
    }
    else{
        cout<<"red";
    }

}


Measured memory_bytes: 256
"use strict";

function main(arg) {
    const date = arg.split("\n")[0].split(" ").join("");
    const memo = [11,22,33,44,55,66,77,88,99,1010,1111,1212];
    
    console.log(memo.filter(n=>n<=date).length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int maxn = 100000 + 5;
const int maxm = 105;
const int mod = 1e9 + 7;
const ll inf = 1e15 + 7;
int main() {
    int n;
    cin >> n;
    bool ok = true;
    string pre;
    set<string> S;
    for(int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if(i && s.front() != pre.back()) ok = false;
        if(S.count(s)) ok = false;
        S.insert(s);
        pre = s;
    }
    puts(ok ? "Yes" : "No");
    return 0;
}


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

typedef long long ll;
const int MAX=1e5+10;
const int mod=1e9+7;

bool Check(int n,int* a){
    for(int i=n;i>0;i-=2){
        if(i-1>0&&a[i]!=a[i-1]||i-2>0&&a[i]-a[i-2]!=2) return false;
    }
    return true;
}

ll Pow(ll n){
    ll ans=1LL,a=2LL;
    while(n){
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}

void Solve(int n,int* a){
    sort(a+1,a+1+n);
    if(a[n]!=n-1||!Check(n,a)){
        cout<<0<<endl;
        return;
    }
    cout<<Pow((ll)(n>>1))<<endl;
}

int main(){
    int n;
    while(cin>>n){
        int a[100005];
        for(int i=1;i<=n;i++) cin>>a[i];
        Solve(n,a);
    }
    return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int main(){
    int N; cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i++){
        if (i >= 10000 && i != 100000){
            ans++;
        } else if (100 <= i && i <= 999){
            ans++;
        } else if (1 <= i && i <= 9){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sol () {
  string s;
  cin >> s;
  const int n = s.size();
  vector<int> ind;
  vector<char> ch;
  for(int i = 0; i < n; ++i) {
    const char c = s[i];
    if (c == 'x') continue;
    ind.push_back(i);
    ch.push_back(c);
  }
  if (ch.size() == 0) {
    return 0;
  }

  // check palin
  int ret = 0;
  int i = 0;
  int j = int(ch.size()) - 1;
  for(; i < j; ++i, --j) {
    if (ch[i] != ch[j]) {
      return -1;
    }
  }

  if (i > j) {
    --i;
    ++j;
  }

  int k1 = ind[i];
  int k2 = ind[j];
  while(k1 >= 0 || k2 < n) {
    if (k1 < 0) {
      ret++;
      k2++;
    } else if (k2 == n) {
      ret++;
      k1--;
    } else if (s[k1] == s[k2]) {
      k1--;
      k2++;
    } else if (s[k1] == 'x') {
      ret++;
      k1--;
    } else if (s[k2] == 'x') {
      ret++;
      k2++;
    }
  }

  return ret;
}

int main () {
  cout << sol() << endl;
}

Measured memory_bytes: 1020
#include<stdio.h>
#define REP(i,b,e) for(int i=b; i<e; i++)

int main(){
        short n;
        scanf("%hd", &n);
        short f[n];
        REP(i, 0, n){
                f[i] = 0;
                REP(j, 0, 10){
                        getchar();
                        f[i] |= (getchar()%2)<<j;
                }
        }

        int p[n][11];
        REP(i, 0, n) REP(j, 0, 11) scanf("%d", &p[i][j]);

        int ans = -1e9;
        REP(i, 1, 1<<10){
                int tmp = 0;
                REP(j, 0, n) {
                        char c = 0;
                        for(short a=i&f[j]; a; a>>=1) c += a&1;
                        tmp += p[j][c];
                }
                if(ans<tmp) ans = tmp;
        }
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	llong N;
	cin >> N;
	llong ans = 0;
	for(llong i=1; i<=N; ++i){
		llong q = N/i;
		ans += i * q * (q+1) /2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<climits>
using namespace std;
typedef struct{
  int a[2000];
  bool f;
}node;

node T[103];
int m;
int n;
int ans;
int cnt;
int num;
void route(){
  m=INT_MAX;
  if(cnt==n-1)return;
  for(int i=0;i<n;i++){
    if(T[i].f==true){
      for(int j=0;j<n;j++){
	if(m>T[i].a[j]){
	  if(T[j].f==false){
	    m=T[i].a[j];
	    num=j;
	  }
	}
      }
    }
  }
  ans+=m;
  cnt++;
  //  cout<<"m "<<m<<endl;
  T[num].f=true;
  route();
}
int main(){
  int key;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>key;
      if(key==-1)T[i].a[j]=INT_MAX;
      else T[i].a[j]=key;
    }
  }
  T[0].f=true;
  route();
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    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;
}

double temp(int t, int h) {
    double s = t-h*0.006;
    return s;
}

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    bool res = false;
    if (s[0] =='A') {
        res = true;
    }
    if(res==true) {
        for(int i=2; i<s.size()-1; ++i) {
            if (s[i] == 'C') {
                cnt++;
            }
        }
    }
    if (cnt==1) {
        res = true;
    } else {
        res = false;
    }
    if (res==true) {
        for(int i=1; i<s.size(); ++i) {
            if (s[i] == 'C' ) continue;
            if (s[i] < 'a' || s[i] > 'z') {
                res = false;
                break;
            }
        }
    }
    if (res == true) {
        cout << "AC" <<"\n";
    } else {
        cout << "WA" <<"\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
#define ld long double
#define int ll
#define INF LLONG_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

static const int MAX = 310;

int d[MAX][MAX];
int d2[MAX][MAX];

// O(N^3)
void floyd(int (&d)[MAX][MAX], const int& n) {

//  経由地点k, スタートi,  目的地jを, 右から(jから)走破していく.
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (d[i][k] == INF) continue;
      for (int j = 0; j < n; j++) {
        if (d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

// 距離の初期条件を入力する. 初期化絶対忘れちゃダメ！！！
// initialization (inside main function)
// for (int i = 0; i < N; i++) {
//   for (int j = 0; j < N; j++) {
//     d[i][j] = (i == j ? 0 : INFTY);
//   }
// }

// for (int i = 0; i < M; i++) {
//   int a, b, t;
//   cin >> a >> b >> t;
//   a--; b--;
//   d[a][b] = t;
//   d[b][a] = t;
// }

signed main() {
  int N, M, L; cin >> N >> M >> L;
  rep(i, N) rep(j, N) {
    d[i][j] = (i == j) ? 0 : INF;
    d2[i][j] = (i == j) ? 0 : INF;
  }

  rep(i, M) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    d[a][b] = d[b][a] = c;
  }

  floyd(d, N);

  rep(i, N) rep(j, N) {
    if (d[i][j] <= L) d2[i][j] = 1;
  }

  floyd(d2, N);

  int Q; cin >> Q;
  rep(qi, Q) {
    int s, t; cin >> s >> t;
    s--; t--;
    int ans = d2[s][t] - 1;
    if (d2[s][t] == INF) ans = -1;

    cout << ans << endl;
  }

}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define maxn 5010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define fi first
#define pi pair<int, int>
#define se second
#define mp make_pair
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int n, a, b;
ll dp[maxn][maxn]; // 
ll pw[maxn];
ll s[maxn * 2][maxn]; // 第二维固定的和 
ll tt[maxn * 2];
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> a >> b;
	if (a > b) swap(a, b);
	pw[0] = 1;
	for (int i = 1; i < maxn; i++)
		pw[i] = pw[i - 1] * 2 % mod;
	for (int i = n + 1; i >= 0; i--) {
		//当前1的位置
		for (int j = 1; j <= i + 1; j++) {
			int nl = i - j + 1;
			if (i == n + 1) nl--;
			if (nl >= b) dp[i][j] = pw[max(0, n - i)];
			else {
				dp[i][j] = (s[i + a + 1][j] + dp[i + 1][j]);
				dp[i][j] += tt[i + 2] - tt[i + a + 1];
				dp[i][j] %= mod;
				if (dp[i][j] < 0) dp[i][j] += mod;
			}
			s[i][j] = (s[i + 1][j] + dp[i][j]) % mod;
			if (i == j) 
				tt[i] = (tt[i + 1] + dp[i][i]) % mod; 
		}
	} 
	cout << dp[0][1] << endl;
	return 0;
}


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

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

min=10000000000
for T in range(n):
    s1=0
    s2=0
    for j in range(T):
        s1+=w[j]
    for k in range(T,n):
        s2+=w[k]
    ztc=abs(s1-s2)

    if min>ztc:
        min=ztc
print(min)


Measured memory_bytes: 38688
#include <bits/stdc++.h>
#define f1(n) for(int i=0;i<n;++i)
#define f2(n) for(int i=1;i<=n;++i)
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const int maxn = 2e5 + 5;
const int maxm = 18;
const ll Mod = 1e9 + 7;
const ll INF = 1e9 + 7;



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

	double r;
	cin >> r;
	cout << 2 * r * 3.1415926 << endl;



	return 0;
}

Measured memory_bytes: 3800
#include<iostream>
#include<vector>
#include<string>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;
const int MAX_N=1e5+5;
ll A[MAX_N];
vector<int>G[MAX_N];
ll T[MAX_N];
ll max(ll a,ll b){
	if(a>b)return a;
	else return b;
}
ll min(ll a,ll b){return -1*max(-a,-b);}
bool dfs(int v,int prev){
	if(G[v].size()==1 &&G[v][0]==prev){
		T[v]=A[v];
		return true;
	}
	bool re=true;
	ll sum=0;
	ll ma=0;
	rep(i,G[v].size()){
		if(G[v][i]!=prev){
			if(!dfs(G[v][i],v))return false;
			sum+=T[G[v][i]];
			ma=max(ma,T[G[v][i]]);
		}
	}
	T[v]=2*A[v]-sum;
	re&=(sum>=T[v]);
	re&=((min(sum-ma,sum/2)>=((sum-T[v])/2)));
	return re;
}
int main(){
	int n;
	cin>>n;
	rep(i,n)cin>>A[i+1];
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if(dfs(1,0) &&(G[1].size()==1||T[1]==0))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 15232
N, Y = map(int, input().split(' '))

for man in range(N+1):
    for go in range(N-man+1):
        if (10000*man+5000*go+1000*(N-man-go)) == Y:
            print('{} {} {}'.format(man, go, N-man-go))
            exit()

print('{} {} {}'.format(-1, -1, -1))


Measured memory_bytes: 3060
//
//AtCoder Beginner Contest 129
//C - Typical Stairs
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;

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; }            //最小公倍数

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

    vector<int> bk(n+1, 0);
    REP(i, m) {
        int a;
        cin >> a;
        bk[a]=1;
    }
    vector<int> dp(n+2, 0);
    dp[n]=1;
    REPD(i, n){
        if(bk[i]==1){
            dp[i]=0;
            continue;
        }
        dp[i]=(dp[i+1]+dp[i+2])%MOD;
    }
    cout << dp[0] << endl;

    return 0;
}


Measured memory_bytes: 4012
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

char a[256];
int ans;

char m[256];
int used[256]={0};

void search(int n,int now,vector<string> &in,const vector<string> &words){
  if (ans >= 2)return;
  if (n == now){
    ans++;
    rep(i,256)a[i]=m[i];
    return;
  }
  rep(i,(int)words.size()){
    string cur = in[now];
    string tar = words[i];
    if (tar.size() != cur.size())continue;
    //check
    bool isok=true;
    rep(j,(int)cur.size()){
      //cout << j << " " << cur[j] <<" " << tar[j] <<" " << used[cur[j]] <<" " << used[tar[j]] << endl;
      if (used[(int)cur[j]] == -1 && used[(int)tar[j]] == -1){
	used[(int)tar[j]]=now;
	used[(int)cur[j]]=now;
	m[(int)cur[j]]=tar[j];
	m[(int)tar[j]]=cur[j];
      }else if (used[(int)cur[j]] == -1     || used[(int)tar[j]] == -1)isok=false;
      else  if (   m[(int)cur[j]] == tar[j] && m[(int)tar[j]] == cur[j])assert(used[cur[j]] != -1 && used[tar[j]] != -1);
      else isok=false;
    }
    //search
    if (isok){
      search(n,now+1,in,words);
    }
    //backtrack
    rep(j,(int)cur.size()){
      if (used[(int)cur[j]] == now && used[tar[j]] == now){
	used[(int)cur[j]]=-1,used[(int)tar[j]]=-1;
      }
    }
  }
}

bool cmp(const string & a,const string &b){
  if (a.size() != b.size())return a.size() > b.size();
  return a < b;
}

int main(){
  int n;
  while(cin>>n && n){
    rep(i,256)used[i]=-1;
    ans=0;

    vector<string> words(n),inp;
    rep(i,n)cin>>words[i];
    sort(words.begin(),words.end());
    words.erase(unique(words.begin(),words.end()),words.end());
    sort(words.begin(),words.end(),cmp);
    string in;getline(cin,in);
    getline(cin,in);
    string tmp = in;
    rep(i,(int)tmp.size())if (tmp[i] == '.')tmp[i]=' ';
    stringstream sin(tmp);
    while(sin>>tmp)inp.push_back(tmp);
    sort(inp.begin(),inp.end());
    inp.erase(unique(inp.begin(),inp.end()),inp.end());
    sort(inp.begin(),inp.end(),cmp);
    
    search(inp.size(),0,inp,words);
    assert(ans > 0);
    if (ans != 1)cout <<"-." << endl;//" " << ans << endl;
    else {
      rep(i,(int)in.size()){
	if (isupper(in[i]))cout<<a[in[i]];
	else cout << in[i];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 948
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val jobs = new Array[(Long, Long)](N)
    for (i <- 0 until N) {
      val a, b = sc.nextLong()
      jobs(i) = (a, b)
    }
    val sorted = jobs.sortBy(_._2)

    var time = 0L
    for (job <- sorted) {
      val (a, b) = job
      time += a
      if (b < time) {
        println("No")
        sys.exit
      }
    }

    println("Yes")
  }
}

Measured memory_bytes: 128592
#include <bits/stdc++.h>
//#include "util.h"

#define ll long long
using namespace std;

void dfs(vector<int> &dp, vector<vector<pair<bool, int>>> &all_edges, int cur) {
  auto &edges = all_edges[cur];
  for (auto &e : edges) {
    if (!e.first) {
      dfs(dp, all_edges, e.second);
      e.first = true; // mark as visited
//      cout << "edge " << cur << "->" << e.second << '\n';
    }
    dp[cur] = max(dp[cur], dp[e.second] + 1);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  constexpr char nl = '\n';

  int N, M;
  cin >> N >> M;
  vector<vector<pair<bool, int>>> edges(N + 1); // outbound (visited, destination)
  for (int i = 0; i < M; ++i) {
    int s = 0;
    int d = 0;
    cin >> s >> d;
    edges[s].push_back(make_pair(false, d));
  }

  vector<int> dp(N + 1, 0);
  for (int i = 1; i <= N; ++i) {
    dfs(dp, edges, i);
  }

  int mx = 0;
  for (int i = 1; i <= N; ++i) {
    if (mx < dp[i]) {
      mx = dp[i];
    }
  }

  cout << mx << nl;

  return 0;
}


Measured memory_bytes: 8192
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列用のリスト　インプットをブランクで区切りリスト化
k = input()
s = [int(j) for j in k.split(" ")]
valIn = 0
# Nの桁毎の分解
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []

def irohacheck(n):
	global valIn
	valIn = 0
	# 分解した数値をリストにして格納
	num = digit(n)
	# num内の数字がsに含まれる場合には、valInをインクリメント
	for i in range(len(num)):
		if s.count(num[i])>0:
			valIn+=1

irohacheck(N)
while(valIn != 0):
	N += 1
	irohacheck(N)
print(N)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        string col1,col2,querycol;
        ll count1,count2;
        std::ios::sync_with_stdio(false);
       
            cin>>col1>>col2;
            cin>>count1>>count2;
            cin>>querycol;
            if(col1==querycol)
                count1--;
            else
                count2--;
            cout<<count1<<" "<<count2;

            
        return 0;
    }


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

int main(){
    int n, k;
    cin >> n >> k;
    int mx = (n-1)*(n-2)/2;
    if(k>mx){
        cout <<-1<<endl;return 0;
    }
    vector<P> hen;
    rep(i,n-1) hen.push_back(P(1,i+2));
    int x=2,y=3;
    rep(i,mx-k){
        hen.push_back(P(x,y));
        if(y<n){
            y++; continue;
        }else{
            x++;
            y=x+1;
            continue;
        }
    }
    cout << hen.size() <<endl;
    for(auto i:hen){
        printf("%d %d\n", i.first, i.second);
    }
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N,u,v; cin>>N>>u>>v;
    vector<int> dist_a(N+1,-1),dist_t(N+1,-1);
    Graph G(N+1);
    rep(i,N-1){
        int a,b; cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    if(G[u].size()==1&&G[u].at(0)==v){
        cout<<0<<endl;
        return 0;
    }
    dist_a[v] = 0;
    queue<int> Q;
    Q.push(v);
    while(!Q.empty()){
        int now = Q.front();
        Q.pop();
        for(auto next_v: G[now]){
            if(dist_a[next_v]!=-1)continue;
            dist_a[next_v] = dist_a[now] + 1;
            Q.push(next_v);
        }
    }
    dist_t[u] = 0;
    queue<int> Qt;
    Qt.push(u);
    while(!Qt.empty()){
        int now = Qt.front();
        Qt.pop();
        for(auto next_v: G[now]){
            if(dist_t[next_v]!=-1)continue;
            dist_t[next_v] = dist_t[now] + 1;
            Qt.push(next_v);
        }
    }
    int distination = 0;
    int l = 0;
    rep1(i,N){
        if(G[i].size()==1){
            if(dist_a[i]>l&&dist_t[i]<=dist_a[i]){
                distination = i;
                l = dist_a[i];
            }
        }
    }
    cout<<l-1<<endl;
}


Measured memory_bytes: 9564
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (1 <= a <= 10000 && 1 <= b <= 10000 && 1 <= c <= 10000)
	{


		if (c < a)
		{
			swap(a, c);
		}
		if (c < b)
		{
			swap(b, c);
		}
		if (b < a)
		{
			swap(a, b);
		}
		cout << a << " " << b << " " << c << endl;
		//cout << a+" "+b+" "+c << endl;
		return 0;
	}
	//else  cout << invalid << endl; 
}


Measured memory_bytes: 3100
def main():
    N = int(input())
    A = [[int(i) for i in input().split()] for j in range(N)]
    if N == 1:
        return print(1)
    A.sort()
    from collections import defaultdict
    cnt = defaultdict(int)
    for i in range(N):
        for j in range(i+1, N):
            # print(A[i], A[j], (A[j][0] - A[i][0], A[j][1] - A[i][1]))
            cnt[(A[j][0] - A[i][0], A[j][1] - A[i][1])] += 1
    # print(cnt.values())
    ans = (N-1) - (sorted(cnt.values())[-1] - 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>
#define deb(x)		cout << #x << " " << x << endl

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;
const int N = 22;
int dp[1 << N];
int adj[N][N];
int n;
inline void relax(int & a , int b){
    a = (a % MOD + b % MOD) % MOD;
}
int fun(int mask){
    auto & res = dp[mask];
    if(res != -1)
        return dp[mask];
    int ans = 0;
    int man = __builtin_popcount(mask);
    if(man == n)
        return res = 1;
    for(int i = 0 ; i < n ; i++)
        if(adj[man][i] && !((mask >> i) & 1))
            relax(ans , fun(mask | (1 << i)));
    return res = ans;
}

signed main(){

#ifndef ONLINE_JUDGE
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> n;

    memset(dp , -1 , sizeof dp);
    fo(i , n)
        fo(j , n)
            cin >> adj[i][j];

    cout << fun(0) <<  '\n';
    
    

    return 0;

}



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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define vii vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


bool check(vii& arr , int x , int k) {

    for(int i=0; i<arr.size(); i++) {
        double p = double(arr[i])/x;
        k -= (ceil(p)-1);
    }
    return (k >= 0);
}


int32_t main()
{   fastio;

    int n;
    cin>>n;

    int k;
    cin>>k;

    vii arr(n);

    for(auto& i:arr)
        cin>>i;

    int l=1;
    int r=1e10;
    int ans = 1e13;

    if(k == 0) {
        cout<<*max_element(all(arr));
        return 0;
    }
    if(k == 1 && n == 1) {

        cout<<(arr[0]+1)/2<<"\n";

        // else {
        //     int p = arr[n-2];
        //     cout<<p<<"\n";
        // }
        return 0;
    }


    while(l <= r) {
        int mid = (l+r)/2;

        if(check(arr , mid , k)) {
            r = mid-1;
            ans=min(ans , mid);
        }
        else {
            l = mid+1;
        }
    }

    cout<<min(ans , *max_element(all(arr)))<<"\n";

}

Measured memory_bytes: 4744