akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

string s,t;

int main () {
    cin >> s >> t;

    vector<string> ans;

    REP(i, s.size()) {
        bool match = true;
        string str = s;
        REP(j, t.size()) {
            if(i+j < s.size() && (s[i+j] == t[j] || s[i+j]=='?')) {
                str[i+j] = t[j];
            } else {
                match = false;
            }
        }
        
        replace(str.begin(), str.end(), '?', 'a');
        if(match) {
            ans.push_back(str);
        }
    }

    if(ans.size() == 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(ans.begin(), ans.end());

    cout << ans[0] << endl;
}

 

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


int main(void) {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  rep(i, n) {
    cin >> a[i + 1];
  }

  int i = 1;
  int count = 0;
  while (count < n + 1) {
    if (i == 2) {
      break;
    }
    count++;
    i = a[i];
  }

  if (i == 2) {
    cout << count << endl;
  } else {
    cout << -1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	int max = -1000000;
	int min = 1000000;
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		if (x > max)max = x;
		if (x < min)min = x;
		sum += x;
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}


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

int main() {
  char A;
  cin >> A;
  if ( A == 'a' || A == 'i' || A == 'u' || A == 'e' || A == 'o'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(void)
{
  int a, b, c, d, e, k;
  
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;
  
  if(e-a > k){
    cout << ":(" << endl;
  }
  
  else{
    cout << "Yay!" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
<?php
while (true) {
    list($height, $width) = getSpacesByExplodeTrimInput();
    $lines = array(); 
    if ($height == 0 && $width == 0) {
        break;
    }
  
    for ($i = 0; $i < $height; $i++) {
        if ($i % 2 !== 0) {
                $lines[] = setEvenNumLine($width);
        } else {
                $lines[] = setOddNumLine($width);
        }
    }
 
    echo implode($lines), PHP_EOL;
}
  
 
  
function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}
  
function setEvenNumLine($width)
{
    $line = "";
    for ($i = 0; $i < $width; $i++) {
        $line .= $i % 2 !== 0 ? "#" : ".";
    }
    return $line.PHP_EOL;
}
  
function setOddNumLine($width)
{
    $line = "";
    for ($i = 0; $i < $width; $i++) {
        $line .= $i % 2 !== 0 ? "." : "#";
    }
    return $line.PHP_EOL;
}

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

typedef long long ll;

ll GCD(ll x, ll y){
    if(x%y == 0) return y;
    return GCD(y, x%y);
}

int main(){
    ll n;
    cin >> n;
    vector<ll> v(n);
    for(int i=0; i<n; i++) cin >> v[i];

    if(n == 1){
        cout << v[0] << endl;
        return 0;
    }

    ll lcm = v[0];
    for(int i=1; i<n; i++){
        ll gcd = GCD(lcm, v[i]);
        lcm = lcm / gcd * v[i];
    }
    cout << lcm << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int solve(int n, int k, int s){
	int i;
	if(s<0)return 0;
	if(!k){
		return s?0:1;
	}
	int cnt=0;
	for(i=n;i>0;--i){
		cnt+=solve(i-1,k-1,s-i);
	}
	return cnt;
}

int main(void){
	int n,k,s;
	while(scanf("%d %d %d",&n,&k,&s) != EOF, n||k||s){
		printf("%d\n",solve(n,k,s));
	}
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

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

    vector<long> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    long sum = 0;
    for (long v : a)
        sum += v;

    long u = a[0];
    long best = abs(u - (sum - u));
    for (int i = 1; i < N - 1; ++i) {
        u += a[i];
        best = min(best, abs(u - (sum - u)));
    }

    cout << best << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }


D EPS = 0.00001;

D solver(D q) {
	D x = q/2.0;
	
	while (fabs(x*x*x - q) >= EPS*q) {
		x = x - (x*x*x-q)/(3*x*x);
	}
	
	return x;
}

int main() {
	ll Q;
	
	while (cin>>Q) {
		if (Q==-1) break;
		D q = Q;
		
		printf("%lf\n", solver(q));
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }


int main() {
    int k;
    cin >> k;
    vector<ll> ans;
    for (int len = 1; len <= 10; ++len) {
        string s;
        for (int i = 1; i < 10; ++i) {
            s += char('0'+i);
            auto dfs = [&](int x, auto &&f) -> void {
                if(!x){
                    ans.emplace_back(stoll(s));
                }else {
                    for (int i = -1; i <= 1; ++i) {
                        if(isdigit(s.back()+i)) {
                            s += char(s.back()+i);
                            f(x-1, f);
                            s.pop_back();
                        }
                    }
                }
            };
            dfs(len-1, dfs);
            s.pop_back();
        }


    }
    sort(ans.begin(),ans.end());
    cout << ans[k-1] << "\n";
    return 0;
}

Measured memory_bytes: 2420
#include <stdio.h>
  int main(void){
   int sum,i;
    int book[9];
for(i=0;i<9;i++){
  book[i] = 0;
    }
while(1){
    scanf("%d",&sum);
       for(i=0;i<9;i++){
         scanf("%d",&book[i]);
if(sum == 0){
  goto  finish;
}
          sum -= book[i];
            }
 printf("%d\n",sum);
sum = 0;
}
finish:
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

map<string,int> anslist;
string ansstr = "01234567";
int m[4] = {-4,-1,1,4};	//上,左,右,下

void solve(){
	int index;
	queue<string> q;
	q.push(ansstr);
	anslist[ansstr] = 0;
	while(!q.empty()){
		string buf = q.front();
		q.pop();
		index = buf.find('0');

		for(int i=0;i<4;i++){
			if(index+m[i]>=0 && index+m[i]<=7){
				//上段右端と下段左端の移動できないのはcontinue
				if(i==1&&index==4 || i==2&&index==3){
					continue;
				}

				//文字の交換
				string s = buf;
				s[index] = buf[index+m[i]];
				s[index+m[i]] = buf[index];
				
				//まだ登録されてない場合のみデータを追加
				if(!anslist.count(s)){
					q.push(s);
					anslist[s] = anslist[buf]+1;
				}
			}
		}
	}
}

int main(){
	solve();
	char num[8];
	while(cin >> num[0]){
		for(int i=1;i<8;i++){
			cin >> num[i];
		}
		string str = "";
		for(int i=0;i<8;i++){
			str += num[i];
		}
		cout << anslist[str] << endl;
	}
}

Measured memory_bytes: 2188
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

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; }

const int INF = 1e9;
const long long LINF = 1e18;

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

		if (U == S)
		{
     	 A--;
		}
		else
		{
                    B--;
                }

                cout << A << ' ' << B << endl;
                return 0;
}


Measured memory_bytes: 256
io = STDIN
nn,mm=Hash.new{|h,k|h[k]=0},Hash.new{|h,k|h[k]=0}
n=io.gets.to_i
n.times do
  nn[io.gets.chomp]+=1
end
m=io.gets.to_i
m.times do
  mm[io.gets.chomp]+=1
end
nonly=nn.keys-mm.keys
monly=mm.keys-nn.keys
nmand=mm.keys && nn.keys
nmax=nonly.map{|str|nn[str]}.max
mmax=monly.map{|str|mm[str]}.max
andmax=nmand.map{|str|nn[str]-mm[str]}.max
if nonly==[]
  puts (andmax>0 ? andmax : 0)
else
  puts nmax||0
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int mx = 1e3;
int s[mx][3];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n-1; i++){
		cin >> s[i][0] >> s[i][1] >> s[i][2];
	}
	for(int k = 0; k < n-1; k++){
		int t = s[k][0]+s[k][1];
		for(int i = k+1; i < n-1; i++){
			if(t <= s[i][1]){
				t = s[i][0]+s[i][1];
			}else{
				if(t % s[i][2]){
					t = (((t/s[i][2])+1)*s[i][2]);
				}
				t += s[i][0];
			}
		}
		cout << t << endl;
	}
	cout << 0 << endl;
}

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

public class Main {

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

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String ans = "";

		for (int i = 97; i < 123; i++){
			String alphabet = String.valueOf((char)i);
			if (!S.contains(alphabet)){
				ans = alphabet;
				break;
			}
		}
		if ("".equals(ans)){
			ans = "None";
		}

		System.out.println(ans);
	}
}



Measured memory_bytes: 22768
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input())-1])

Measured memory_bytes: 2940
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var whxy = Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray();
        var w = whxy[0];
        var h = whxy[1];
        var xx = whxy[2];
        var yy = whxy[3];

        var s = w * h / 2;
        var multi = xx == w / 2 && yy == h / 2 ? 1 : 0;
        Console.WriteLine($"{s:F10} {multi}");
    }
}


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

int main(){
  int N=1;
  int point =0;
  int a=0;
  
  while(!(N==0)){
    point =0;
    cin >> N;
    if(N==0){
      break;
    }
    rep(i,(N/4)){
      cin >> a;
      point= point + a;
    }
    cout << point <<endl;
  } 
  return 0; 
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
    int n,i;
    double sum=0;
    cin>>n;
    double m=(double)n/3;


    printf("%.12lf\n",m*m*m);
    return 0;
}


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

const string keywords[] = {
    "maerd",
    "remaerd",
    "esare",
    "resare"
};

int main(int argc, const char * argv[]) {
    string S;
    
    cin >> S;
    reverse(S.begin(), S.end());
    
    int index = 0;
    while (index < S.length()) {
        bool isFind = false;
        for (int i = 0; i < 4; i++) {
            if (S.compare(index, keywords[i].length(), keywords[i]) == 0) {
                index += keywords[i].length();
                isFind = true;
                break;
            }
        }
        
        if (!isFind) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    
    return 0;
}

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

using namespace std;

typedef long long llint;

int main() {
  llint n, k;
  cin >> n >> k;
  vector<llint> a(n), sum(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];

  llint x = 0;
  for (int i = 50; 0 <= i; i--) {
    llint y = x | (1LL << i);
    int cnt = 0;
    for (int l = 0; l <= n; l++) {
      for (int r = l + 1; r <= n; r++) {
        llint d = sum[r] - sum[l];
        if ((d & y) == y) cnt++;
      }
    }
    if (k <= cnt) x = y;
  }
  cout << x << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

using Graph = vector<vector<int>>;
Graph g(200005);
bool ok = false;

void dfs(int used, int gole, int now) {
	if (used > 2) return;
	if (now == gole) {ok = true; return;}
	for (auto &x : g[now]) {
		dfs(used + 1, gole, x);
	}
}

int main(void) {
	int n, m;
	cin >> n >> m;
	rep (i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
	}
	dfs(0, n - 1, 0);
	cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
set<string> a;
int n;
void dfs(string s, char b){
    if(s.size() == n){
    a.insert(s);
    return ;
    }
  
  for(char i = 'a'; i <= b; i++){
      dfs(s + i , ((b == i) ? char(b + 1) : b));
  }
   }
   
int main(){
    cin >> n;
    string s = "a";
    
    dfs("",'a');
    for(auto value : a)
    cout << value << endl;
}

Measured memory_bytes: 12416
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself
        
*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"

/*int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int powermod(int A, int p, int MOD = mod){
    A%=MOD;
    int res  = 1;
    while(p){
        if(p&1)
            res = ((__int128)res*A)%MOD;
        
        A = ((__int128)A*A)%MOD;
        p>>=1;
    }

    return res;
}*/

//bool comp()
//{
//}

int32_t main(void)
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,d;
        cin>>n>>d;
        int cnt=0;
        while(n--)
        {
            int x,y;
            cin>>x>>y;
            double dd=sqrt(x*x+y*y);
            
            if(dd<=d)
            cnt++;
        }
        
        cout<<cnt<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int h, w, n, x, y;
    std::string s, t;
    std::cin >> h >> w >> n
        >> x >> y
        >> s >> t;

    // [lb, ub]
    auto ud = std::make_pair(1, h), lr = std::make_pair(1, w);

    for (int i = n; i; i--) {
        if (t[i - 1] == 'D') ud.first = std::max(1, ud.first - 1);
        else if (t[i - 1] == 'U') ud.second = std::min(h, ud.second + 1);
        else if (t[i - 1] == 'R') lr.first = std::max(1, lr.first - 1);
        else if (t[i - 1] == 'L') lr.second = std::min(w, lr.second + 1);

        if (s[i - 1] == 'D') --ud.second;
        else if (s[i - 1] == 'U') ++ud.first;
        else if (s[i - 1] == 'R') --lr.second;
        else if (s[i - 1] == 'L') ++lr.first;

        if (lr.first > lr.second || ud.first > ud.second) break;
    }

    bool flg = ud.first <= x && x <= ud.second && lr.first <= y && y <= lr.second;
    std::cout << (flg ? "YES" : "NO") << std::endl;

    return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<string>

using namespace std;

int main(){
    string str;
    int n,i,a;
        
    while(cin>>str){
        if(str=="-") break;
        cin>>n;
        for(i=0; i<n; i++){
            cin>>a;
            string sub = str.substr(0,a);
            str.erase(0,a);
            str+=sub;
        }
        cout<<str<<endl;
    }
    
    return 0;

}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int H, W;
vector<string> s;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

bool check_next(int x, int y){
  return x >=0 && x < W && 0<= y && y < H;
}
bool solve(int x, int y){
  REP(i, 4){
    int nx = x + dx[i], ny = y + dy[i];
    if(!check_next(nx, ny)) continue;
    if(s[ny][nx] == '#'){
      return true;
    }
  }
  return false;
}
int main(){
  cin >> H >> W;
  s.resize(H);
  REP(i, H){
    cin >> s[i];
  }
  bool flag = true;
  REP(i, H){
    REP(j, W){
      if(s[i][j] == '.') continue;
      if(!solve(j, i)){
        flag = false;
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,k=1;
    cin>>x>>y;
	int t=y;
    while(t){
		t/=10;k*=10;
	}
	long long s=x*k+y;
    for(int i=1;i<=1100;++i)
    	if(i*i==s){
			cout<<"Yes";return 0;
		}
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ans = 0
drink_num = 0
# 値段に関してソート
ab.sort(key=lambda shop: shop[0])
for i in range(n):
    if (drink_num + ab[i][1]) > m:
        ans += ab[i][0] * (m - drink_num)
        drink_num += m - drink_num
        break
    ans += ab[i][0] * ab[i][1]
    drink_num += ab[i][1]
print(ans)

Measured memory_bytes: 64600
import scala.io.StdIn._
object Main extends App {
  val Array(n, k) = readLine.split(" ").map{_.toInt}
  val x = readLine.split(" ").map{_.toInt}
  println((0 to (n - k)).map{i => calc(x(i), x(i + k - 1))}.min)

  def calc(head: Int, last: Int): Int = last - head + Math.min(Math.abs(head), Math.abs(last))
}


Measured memory_bytes: 43956
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,y;
    cin>>n>>y;
    rep(i,n+1){
        rep(j,n+1){
            int k = n - i - j;
            if(k>=0){
                if(1000*i+5000*j+10000*k==y ){
                    cout<<k<<" "<<j<<" "<<i<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<list>
#include<utility>
#include<algorithm>
using namespace std;


typedef list<int> OuterList;
struct Doll
{
	int outerCount;	//±êðüêçêél`ÌÂ
	int h, r;	//å«³
	OuterList outerList;	//±êðüêçêél`ÌQÆæÌCfbNX
};
const int N = 200;
//ärÖÌ¹¢Å±±É@ÝvÔá¦½H
Doll doll[N];

//åÌå«¢ÉÀÑÖ¦éæ¤
bool SortDoll(const Doll &lhv, const Doll &rhv)
{
	return (lhv.h+lhv.r) > (rhv.h+rhv.r);
}
//êÔO¤Ìl`ª½¢ÌðÔ·
//max_elementÉn·àÌÍAoperator<ãíèÌàÌ
bool CmpOuterDoll(int lhv, int rhv)
{
	return doll[lhv].outerCount < doll[rhv].outerCount;
}

int main()
{
	int n,m,i,j,dollCount;
	const int INVALID_VALUE = -1;

	while(scanf("%d",&n),n)
	{
		for(i = 0; i < n; ++i)
			scanf("%d%d",&doll[i].h, &doll[i].r);
		scanf("%d",&m);
		for(i = 0; i < m; ++i)
			scanf("%d%d",&doll[i+n].h, &doll[i+n].r);

		dollCount = n+m;
		//åÌå«¢ÉÀÑÖ¦é
		sort(doll, doll+dollCount, SortDoll);

		// él`ðàïÅ«él`Ìñ
		for(i=0; i < dollCount; ++i)
		{
			doll[i].outerCount = INVALID_VALUE;	//Ü¾mèµÄ¢Ü¹ñæ
			doll[i].outerList.clear();	//Á¦È³¢æ
			for(j = 0; j < dollCount; ++j)
			{
				//üèÜ·H
				if(doll[i].h < doll[j].h &&
					doll[i].r < doll[j].r)
				{
					doll[i].outerList.push_back(j);
				}
			}
		}

		int finishCount = 0;
		int maxDoll = 0;
		//Sl`ªðI¦éÜÅ[v
		while(finishCount < dollCount)
		{
			for(i = 0; i < dollCount; ++i)
			{
				//Ü¾»Ìl`ÌªIíÁÄ¢È¢Èç
				if(doll[i].outerCount == INVALID_VALUE)
				{
					bool f = true;	//SÄÌO¤ÌzªðI¦Ä¢é©
					for(OuterList::iterator ite = doll[i].outerList.begin();
						ite != doll[i].outerList.end(); ++ite)
					{
						if(doll[*ite].outerCount == INVALID_VALUE)
						{
							f = false;
							break;
						}
					}
					//SÄIíÁÄ¢éÈçA él`ÍA»Ìl`ðÍ¦él`ÌÂ+1@ÂÉÈèÜ·
					if(f)
					{
						if(doll[i].outerList.empty())
						{
							//½à»êðÍ¤±ÆªoÈ¢l`ÈÌÅ·
							doll[i].outerCount = 1;
						}
						else
						{
							//±êð©ÄAY¦ðÇµ½±Æðã÷·éÌÅµ½
							doll[i].outerCount = doll[
								*max_element(
									doll[i].outerList.begin(), doll[i].outerList.end(), CmpOuterDoll
								)
								].outerCount + 1;
						}
						maxDoll = max(maxDoll, doll[i].outerCount);
						finishCount++;	//Ü½êÂmèµÜµ½
					}
				}
			}
		}

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

Measured memory_bytes: 0
import math
n = int(input())

a = math.floor(n / 1.08)
b = a + 1

aa = math.floor(a * 1.08)
bb = math.floor(b * 1.08)
if (aa == n):
    print(a)
else:
    if (bb == n):
        print(b)
    else:
        print(':(')


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> s(n);
        for(int i=0; i<n; ++i)
            cin >> s[i];

        int ret = 0;
        for(;;){
            map<int, int> num;
            for(int i=0; i<n; ++i)
                ++ num[s[i]];
            vector<int> c(n);
            for(int i=0; i<n; ++i)
                c[i] = num[s[i]];
            if(s == c){
                cout << ret << endl;
                cout << s[0];
                for(int i=1; i<n; ++i)
                    cout << ' ' << s[i];
                cout << endl;
                break;
            }
            s = c;
            ++ ret;
        }
    }
}

Measured memory_bytes: 0
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad (guard)

main :: IO ()
main = do
  a <- readLn
  b <- readLn
  c <- readLn
  x <- readLn
  print $ solve a b c x

solve :: Int -> Int -> Int -> Int -> Int
solve a b c x = length $ do
  na <- [0 .. a]
  nb <- [0 .. b]
  nc <- [0 .. c]
  guard $ na * 500 + nb * 100 + nc * 50 == x
  return ()


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define pb push_back
#define INF INT_MAX
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
bool func(ll n,ll k){
    while(n%k==0){
        n=n/k;
    }
    return (n%k)==1;
}
int main() {
    ios;
  ll n;cin>>n;
 if(n==2){
 cout<<1; return 0;
}
 ll ans=0;
   for(ll i=2;i*i<=n;i++){
     if(n%i==0&&func(n,i))ans++;
     if(i*i!=n&&(n%i==0&&func(n,n/i)))ans++;
   }
   for(ll i=1;i*i<=n;i++){
      if((n-1)%i==0)ans++;
      if(i*i!=n-1&&(n-1)%i==0)ans++;

   }
   cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(){
    long long n, k, ans = 0;
    cin >> n >> k;
    vector<long long> num(k);
    for(int i = 1; i <= n; i++){
        num[i % k]++;
    }
    for(int a = 0; a < k; a++){
        long long b = (k - a) % k;
        long long c = (k - a) % k;
        if((b + c) % k != 0) continue;
        ans += num[a] * num[b] * num[c];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
	return 0;
}

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


int main() {
    string s;
    cin>>s;

    if(s == "Sunny") cout<< "Cloudy" << endl;
    else if(s == "Cloudy") cout<< "Rainy" << endl;
    else if(s == "Rainy") cout<< "Sunny" << endl;

    return 0;
}

Measured memory_bytes: 256
program neither_AB_nor_BA
  implicit none
  integer(8), parameter :: md = 998244353_8
  integer(8) :: n, i, p = 1_8, c = 1_8, x = 0_8
  read(*,*) n
  do i = 0_8, (n-1_8)/2_8
    x = mod(x+p*c,md)
    p = mod(2_8*p,md)
    c = mod(c*(n-i),md)
    c = mod(c*inv(i+1_8),md)
  end do
  write(*,'(i0)') modulo(pow(3_8,int(n,4))-2_8*x,md)
contains
  function inv(n) result(y)
    integer(8), intent(in) :: n
    integer(8) :: a, b, x, y, t, q
    a = modulo(n,md)
    b = md
    x = 0_8
    y = 1_8
    do while (b /= 0_8)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    y = modulo(y,md)
  end
  function pow(a,b) result(r)
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer :: k
    integer(8) :: r, p
    r = 1_8
    p = a
    k = b
    do while (k > 0)
      if (btest(k,0)) r = mod(r*p,md)
      p = mod(p*p,md)
      k = rshift(k,1)
    end do
  end
end program neither_AB_nor_BA

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n;
ll a[16][16];
ll dp[(1<<16)];
ll ans;

int main() {
    cin >> n;
    rep(i,n) rep(j,n) cin >> a[i][j];
    rep(i,(1<<n)) {
        ll sum = 0;
        rep(j,n) {
            if (!(i&(1<<j))) continue;
            for (int k = j+1; k < n; k++) {
                if (!(i&(1<<k))) continue;
                sum += a[j][k];
            }
        }
        dp[i] = sum;
    }
    rep(i,(1<<n)) {
        for (int j = i; j >= 0; j--) {
            j &= i;
            int k = i-j;
            dp[i] = max(dp[i], dp[j]+dp[k]);
        }
    }
    cout << dp[(1<<n)-1] << endl;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  if(N < 105) {
    cout << 0 << endl;
  }
  else if(N < 135) {
    cout << 1 << endl;
  }
  else if(N < 165) {
    cout << 2 << endl;
  }
  else if(N < 189) {
    cout << 3 << endl;
  }
  else if(N < 195) {
    cout << 4 << endl;
  }
  else if(N <= 200) {
    cout << 5 << endl;
  }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  vector<int> R(0);
  for (int i = 0; i < 100000; i++) {
    R.push_back(0);
  }
  if (S[0] == '0') {
    R.push_back(0);
  }
  int cnt = 1;
  for (int i = 1; i < N; i++) {
    if (S[i - 1] == S[i]) {
      cnt++;
    } else {
      R.push_back(cnt);
      cnt = 1;
    }
  }
  R.push_back(cnt);
  for (int i = 0; i < 100000; i++) {
    R.push_back(0);
  }
  int Rs = R.size();
  int A[Rs+1];
  A[0] = 0;
  for (int i = 0; i < Rs; i++) {
    A[i+1] = A[i] + R[i];
  }
  int ans = -1;
  for (int i = 0; i < Rs-2*K+1; i+=2) {
    ans = max(ans,A[i+2*K+1]-A[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2928
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 22 20:51:06 2020

@author: H_Hoshigi
"""

N, R = map(int, input().split())
naibu_rate = 0
if N >= 10:
    naibu_rate = R
else:
    naibu_rate = R + 100*(10-N)
print(naibu_rate)



Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int ans[100][100];

int main()
{
  int h, w, n;
  int a[10000];

  cin >> h >> w >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int c = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(i % 2 == 0) ans[i][j] = c + 1;
      else ans[i][w-j-1] = c + 1;

      a[c]--;
      if(a[c] == 0){
        c++;  
      }
    }
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << ans[i][j];
      if(j != w-1) cout << " ";
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef long long ll;
const ll mod = 1000000;
const double pi = acos(-1);
double polar;

void rotate(double &x,double &y,double theta){
  double tx=x,ty=y;
  x=tx*cos(theta)-ty*sin(theta);
  y=tx*sin(theta)+ty*cos(theta);
}

double getAngle(int month,int day,int hour,int minute){
  static double unit=((1+1/365.24)*360)/(24*60);
  static int daylist[]={31,29,31,30,31,30,31,31,30,31,30,31};
  double daytotal=0;
  rep(i,12){
    if (month == i+1)break;
    daytotal+=daylist[i];
  }
  daytotal+=day-1;
  return (daytotal*60*24+hour*60+minute)*unit;
}

bool isok(vector<double> &x,vector<double> &y,vector<double> &z,double angle){
  int n=x.size();
  rep(i,n){
    rotate(x[i],z[i],pi/2-polar);
  }
  rep(i,n){
    rotate(x[i],y[i],angle);
  }
  rep(i,n){
    rotate(x[i],z[i],-(pi/2-polar));
  }
  //rep(i,n)cout << z[i] <<" ";cout << endl;

  rep(i,n){
    double ang=asin(z[i]);
    if (ang < 0.0)return false;
  }
  return true;
}

main(){
  polar=43.2/180*pi;
  int te;
  cin>>te;
  while(te--){
    int month,day,hour,minute;
    char dummy;
    cin>>month>>dummy>>day>>hour>>dummy>>minute;
    double angle=getAngle(month,day,hour,minute);
    angle=angle/180*pi;
    int n;
    cin>>n;
    rep(i,n){
      string name;int m;
      cin>>name>>m;
      vector<double> x(m),y(m),z(m);
      rep(j,m){
	double ang,h;
	cin>>ang>>h;
	ang=ang;
	ang=ang/180*pi;
	h=h/180*pi;
	z[j]=sin(h);
	x[j]=cos(h)*cos(ang);
	y[j]=cos(h)*sin(ang);
	//cout << sqrt(x[j]*x[j]+y[j]*y[j]+z[j]*z[j]) << endl;
      }
      //cout <<"check " << name << endl;
      if (isok(x,y,z,angle))cout << name << endl;
    }
    //cout <<"tc end " <<  endl << endl;
  }
  return false;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int max = 0;
  int min = 1000000000;

  for (int i = 0; i < N; i++) {
    if (vec.at(i) > max) {
    	max = vec.at(i);
    }
    if (vec.at(i) < min) {
    	min = vec.at(i);
    }
  }
  
  cout << max - min << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int a[11000];

int main(){
  int H,W,N,C[110][110];
  cin>>H>>W>>N;
  for(int i=1;i<=N;i++) cin>>a[i];
  int now=1;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      C[i][j]=now;
      a[now]--;
      if(a[now]==0) now++;
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j) cout<<" ";
      if(i%2==0) cout<<C[i][j];
      else cout<<C[i][W-1-j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 384
use std::io::{self, BufRead};
use std::collections::HashMap;

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let _ = lines.next().unwrap().unwrap();
  let line = lines.next().unwrap().unwrap();
  let vs: Vec<i32> = line.split(' ').map(|x| x.parse().unwrap()).collect();

  let mut groups: HashMap<i32, usize> = HashMap::new();
  for v in &vs {
    if groups.contains_key(v) {
      let v1 = groups[v] + 1;
      groups.insert(*v, v1);
    } else {
      groups.insert(*v, 1);
    }
  }

  let counts: HashMap<i32, usize> = groups.iter().map(|(k, n)| (*k, n * (n - 1) / 2)).collect();
  let counts1: HashMap<i32, usize> = groups.iter().map(|(k, n)| if *n <= 1 { (*k, 0) } else { (*k, (n - 1) * (n - 2) / 2) }).collect();
  let total: usize = counts.values().sum();

  for v in &vs {
    println!("{}", total - counts[v] + counts1[v]);
  }
}

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

int main() {
  int n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    s.insert(t);
  }

  cout << s.size();
}

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

int main(){
  int n,t;
  int s,f;
  while(cin >> t , t){
    cin >> n;
    int sum = 0;
    for(int i=0;i<n;i++){
      cin >> s >> f;
      sum += f-s;
    }
    if(t<=sum)cout << "OK\n";
    else cout << t-sum << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;
ll L[200010], R[200010];
ll p[100010], q[100010];
ll tt[510][510] = {};
ll sum[510][510] = {};
ll tt_ans[510][510] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,Q;
    cin >> N >> M >> Q;
    rep(i,0,M){
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    }
    rep(i,0,Q){
        cin >> p[i] >> q[i];
        p[i]--;
        q[i]--;
    }



    rep(i,0,M){
        tt[L[i]][R[i]]++;
    }


    rep(i,0,N){
        rep(j,1,N+1){
            sum[i][j] = sum[i][j-1] + tt[i][j-1];
        }
    }

    rep(i,0,N){
        rep(j,0,N){
            rep(k,i,j+1){
                tt_ans[i][j] += sum[k][j+1] - sum[k][i];
            }
        }
    }
    rep(i,0,Q){
        ll count = 0;
        ll ans = tt_ans[p[i]][q[i]];
        print(ans);
    }
}


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

long long INF = 10000000000;

int main(){
    //input
    long long n;
    cin >> n;
    long long r[n+1], c[n+1];
    long long i;
    for(i = 1; i <= n; i++){
        cin >> r[i] >> c[i];
    }

    //calc
    long long dp[n+1][n+1];
    for(i = 1; i <= n; i++){
        dp[i][i] = 0;
    }
    long long j,d;
    for(d = 1; d <= n-1; d++){
        for(i = 1; i <= n-d; i++){
            dp[i][i+d] = INF;
            for(j = 0; j < d; j++){
                dp[i][i+d] = min(dp[i][i+d], dp[i][i+j] + r[i]*c[i+j]*c[i+d] + dp[i+j+1][i+d]);
            }
        }
    }

    //answer
    cout << dp[1][n] << endl;
    return 0;
}


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

typedef long long ll;

ll K;
ll comb[1000][1000], H[1000][1000];
vector<int> sol;

int main() {
    cin >> K;

    for(int i = 0; i < 1000; i++) {
        comb[i][0] = 1;
        for(int j = 1; j <= i; j++) {
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
        }
    }

    for(int i = 0; i < 1000; i++) {
        for(int j = 0; j < 1000 - i; j++) {
            H[i][j] = comb[i + j - 1][j];
        }
    }

    for(int i = 500; i >= 1; i--) {
        while(K >= H[8][i - 1]) {
            sol.push_back(i);
            K -= H[8][i - 1];
        }
    }

    int pos = (int)sol.size() - 1;
    for(int i = 1; i <= 500; i++) {
        printf("FESTIVA");

        while(pos >= 0 && sol[pos] == i) {
            printf("L");
            pos--;
        }
    }
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long n,i,a,c=0;
  map<long long,long long>mp;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>a;
    mp[a]++;
  }
  for(auto u:mp)
  {
    if(u.first<u.second)
      c+=u.second-u.first;
    else if(u.first>u.second)
      c+=u.second;
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 9628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	ll N, K;
	cin >> N >> K;
	ll A[N];
	for(int i = 0; i < N; i++) cin >> A[i];

	ll inv[N], rinv[N];
	for(int i = 0; i < N; i++) {
		inv[i] = 0;
		for(int j = 0; j < i; j++) {
			if(A[j] > A[i]) inv[i]++;
		}
	}
	for(int i = N - 1; i >= 0; i--) {
		rinv[i] = 0;
		for(int j = N - 1; j > i; j--) {
			if(A[j] > A[i]) rinv[i]++;
		}
	}
	ll ans = 0;
	for(int i = 0; i < N; i++) {
		ans += (inv[i] * (((K + K * K) / 2) % mod)) % mod;
		ans %= mod;
		K--;

		ans += (rinv[i] * (((K + K * K) / 2) % mod)) % mod;
		ans %= mod;
		K++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef vector<vector<int>> Graph;

int main() {
	//入力;
	int N, i;
	cin >> N >> i;
	cout << N - i + 1 << endl;
	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

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

int main(){
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    rep(i,n) a[i] = l+i;
    int sum = 0;
    rep(i,n) sum += a[i];
    int ans = -1;
    int d = 1e9;
    rep(i,n){
        int x = sum - a[i];
        d = min(d, abs(sum-x));
        if(d == abs(x-sum)) ans = x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		System.out.println(Math.min(A, B) + Math.min(C, D));
		
	}
}


Measured memory_bytes: 21332
import sys
from collections import deque

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def bfs(n, adj):
    dis = [-1] * n
    visited = [False] * n
    nxt = deque([0])
    dis[0] = 0
    visited[0] = True

    while nxt:
        u = nxt.popleft()

        for v in adj[u]:
            if not visited[v]:
                dis[v] = dis[u] + 1
                visited[v] = True
                nxt.append(v)

    return dis

def solve():
    n = int(input())
    adj = [None] * n
    for i in range(n):
        u, k, *vs = [int(j) - 1 for j in input().split()]
        adj[u] = vs

    # debug(adj, locals())
    dis = bfs(n, adj)

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

    pass

if __name__ == '__main__':
    solve()

Measured memory_bytes: 8044
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for(ll b = K + 1; b <= N; ++b) {
        //if(b == 1) continue;
        ans += N/b*(b-K);
        if(K == 0) --ans;
        if( N/b*b + K <= N) 
            ans += min(N, (N/b + 1)*b - 1) - N/b*b - K + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

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

int count(int n)
{
	int ans = 0;
	while(n%2 == 0)
	{
		n = n/2;
		ans++;
	}

	return ans;
}

int main()
{
	FAST;
	int n;
	cin >> n;
	
	cout << pow(2,floor(log2(n)));
	return 0;
}

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

const long long N = 1e5 + 17;
ll cnt, lnt, mn = N, mx, a[N], n, m,k, x, y, ans, sum;
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;
vector<char>vi;

int main()
{
    cin >> n >> m;
    n *= 3;
    ans = (n + m) / 2;
    cout << ans;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,cnt=0;
	for(int i=0;i<5;i++){
		cin>>x;
		if(x==0){
			cnt=i+1;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3636
//                _                                      
//  ___ _ __ ___ (_) __ ___      ___   _ _ __ ___  _ __  
// / __| '_ ` _ \| |/ _` \ \ /\ / / | | | '_ ` _ \| '_ \ 
// \__ \ | | | | | | (_| |\ V  V /| |_| | | | | | | |_) |
// |___/_| |_| |_|_|\__, | \_/\_/  \__,_|_| |_| |_| .__/ 
//                  |___/                         |_|  
//code by smigwump
//https://codeforces.com/blog/entry/62393 hashing hack protection
//https://codeforces.com/blog/entry/61587 rand() alternatives
//https://codeforces.com/blog/entry/61675 randomized hack protection
#include <bits/stdc++.h>
typedef long long ll;
#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
#define REP(i,a,b) for(ll i = a; i <= b; i++)
#define PER(i,a,b) for(ll i = a; i >= b; i--)

using namespace std;

int main() {
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin);
	//     freopen("output.txt", "w", stdout);
	// #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int ls = sz(s);
    int lt = sz(t);
    int ans = 1e9;
    for(int i = 0; (i+lt) <= (ls); i++) {
    	int tans = 0;
    	REP(j,0,lt-1) {
    		if(t[j] != s[i+j]) {
    			tans++;
    		}
    	}
    	ans = min(ans,tans);
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

int main(){
    ll H1,M1,H2,M2,K; cin>>H1>>M1>>H2>>M2>>K;
    M1+=(60*H1);
    M2+=(60*H2);
    M2-=K;
    cout<<M2-M1<<endl;
}

Measured memory_bytes: 3624
import itertools
N=int(input())
S=[]
T=[]
P = list(map(int,input().split()))
p=''.join(map(str,P))
Q = list(map(int,input().split()))
q=''.join(map(str,Q))
for i in range(1,N+1):
  S.append(str(i))
for v in itertools.permutations(S, N):
    T.append(''.join(map(str,v)))
#print(T.index(p))
#print(T.index(q))
print(abs(T.index(p)-T.index(q)))

Measured memory_bytes: 6040
#include <algorithm>
#include <cctype>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

pair<string, int> parse(const string &letter) {
	int idx = 0;
	while(isalpha(letter[idx])) ++idx;
	return {letter.substr(0, idx), stoi(letter.substr(idx))};
}

void print(int idx, const vector<int> &next) {
	while(next[idx] != idx) {
		cout << idx + 1 << "\n";
		idx = next[idx];
	}
	cout << idx + 1 << "\n";
}

int main() {
	for(int n; cin >> n && n;) {
		map<pair<string, int>, int> jump;
		vector<int> next(n);

		iota(next.begin(), next.end(), 0);

		for(int i = 0; i < n; ++i) {
			string letter;
			cin >> letter;

			if(letter == "-") {
				print(i, next);
			}
			else {
				const bool re_mark = letter.back() == 'v';
				if(re_mark) {
					next[i + 1] = i;
					letter.erase(letter.begin() + letter.size() - 1);
				}

				if(letter.size() > 1) {
					const auto cur = parse(letter);
					const auto dest = make_pair(cur.first, cur.second + 1);

					if(jump.count(dest)) {
						const int dest_idx = jump.at(dest);
						jump.erase(dest);
						next[i] = dest_idx;
					}

					if(cur.second > 1) {
						jump[cur] = i;
					}
					else if(!re_mark) {
						print(i, next);
					}
				}
			}
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1896
// ABC080B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int wari(int n) {
	int sum = 0;
	while(n>0)
	{
		sum += n % 10;
		n = n / 10;
	}
	return sum;
}

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

	int sum;
	sum=wari(N);
	if (N % sum == 0)cout << "Yes" << endl;
	else cout << "No"<< endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256