akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define Sort(a) sort(a.begin(),a.end())
const int INF = 1e9+7;

int main(){
  int H,W,white=0;
  cin >> H >> W;
  vi dh = {0,1,0,-1}, dw = {1,0,-1,0};
  vector<vector<char>> A(H,vector<char>(W));
  vector<vector<int>> B(H,vector<int>(W));
  rep(i,H){
    rep(j,W){
      cin >> A.at(i).at(j);
    }
  }
  queue<P> q;
  rep(i,H){
    rep(j,W){
      B.at(i).at(j) = INF;
      if(A.at(i).at(j)=='#'){
        q.push(P(i,j));
        B.at(i).at(j) = 0;
      }
    }
  }
  int m = 0;
  while(q.size()){
    P p = q.front(); q.pop();
    rep(k,4){
      int nh = p.first + dh.at(k);
      int nw = p.second + dw.at(k);
      if(0<=nh&&nh<H&&0<=nw&&nw<W&&A.at(nh).at(nw)=='.'&&B.at(nh).at(nw)==INF){
        A.at(nh).at(nw) = '#';
        B.at(nh).at(nw) = min(B.at(nh).at(nw), (B.at(p.first).at(p.second) + 1));
        q.push(P(nh,nw));
        m = max(m,B.at(nh).at(nw));
      }
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 13328
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; string S; cin >> N >> S;
    bool dp[4][1000] = {};
    dp[0][0] = true;
    REP(i, 0, N) {
        int cur = S[i] - '0';
        for (int j = 2; j >= 0; j--) {
            REP(k, 0, 1000) {
                int next = 10 * k + cur;
                if (next < 1000 && j < 3) {
                    dp[j + 1][next] = (dp[j + 1][next] | dp[j][k]);
                }
            }
        }
    }
    int ans = 0;
    REP(i, 0, 1000) {
        if (dp[3][i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n = i_input()
    a = i_list()
    m = INF
    l = []
    cnt = 0
    for i in a:
        if i < 0:
            cnt += 1
        i = abs(i)
        l.append(i)
        m = min(m,i)

    if cnt %2==0:
        print(sum(l))
    else:
        print(sum(l)-m*2)



if __name__=="__main__":
    main()


Measured memory_bytes: 95124
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int A,B,C; cin >> A >> B >> C;

	if(A == B) cout << C << endl;
	else if(A == C) cout << B << endl;
	else cout << A << endl;


	return 0;

}


Measured memory_bytes: 256
s = input()
i = 0
while True:
    if s == "":
        print("YES")
        exit(0)
    if i == 0:
        if s[:5] == "dream":
            s = s[5:]
            i = 1
        elif s[:5] == "erase":
            s = s[5:]
            i = 2
        else:
            break
    elif i == 1:
        if s[:5] == "dream":
            s = s[5:]
            i = 1
        elif s[:2] == "er":
            s = s[2:]
            i = 3
        else:
            break
    elif i == 2:
        if s[:5] == "dream":
            s = s[5:]
            i = 1
        elif s[:5] == "erase":
            s = s[5:]
            i = 2
        elif s[:1] == "r":
            s = s[1:]
            i = 0
        else:
            break
    elif i == 3:
        if s[:5] == "dream":
            s = s[5:]
            i = 1
        elif s[:3] == "ase":
            s = s[3:]
            i = 2
        elif s[:5] == "erase":
            s = s[5:]
            i = 2
        else:
            break
print("NO")

Measured memory_bytes: 9288
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int[] p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
				43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for(int i = 2; i <= N; i++) {
			int t = i;
			for(int k : p) {
				if(t == 1) break;
				while(t % k == 0) {
					map.merge(k, 1, (v1, v2) -> v1 + v2);
					t /= k;
				}
			}
		}
		int cnt = 0;
		int a = 0;
		int b = 0;
		int c = 0;
		int d = 0;
		int e = 0;
		for(int k : map.keySet()) {
			//System.out.println(k +" " + map.get(k));
			int t = map.get(k);
			if(t >= 74) {
				a++;
			}
			if(t >= 24) {
				b++;
			}
			if(t >= 14) {
				c++;
			}
			if(t >= 4) {
				d++;
			}
			if(t >= 2) {
				e++;
			}
		}
		//System.out.println(a);
		cnt += a;
		cnt += b * (e - 1);
		cnt += c * (d - 1);
		cnt += (d * (d - 1) * (e - 2)) / 2;
		System.out.println(cnt);
	}
}

Measured memory_bytes: 28756
def kaijou(n):
    ret = 1
    for i in range(1, n + 1):
        ret *= i
        ret %= MOD
    return ret


n, m = map(int, input().split())
MOD = 10**9 + 7

if abs(n - m) >= 2:
    print(0)
else:
    if n == m:
        ans = kaijou(n)**2 * 2 % MOD
    else:
        n, m = max(n, m), min(n, m)
        ans = kaijou(n) * kaijou(m) % MOD
    print(ans)


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int check(char c1,char c2,char c3 , string s)
{
	int n = sz(s);
	vi v1;
	vi v2;
	vi v3;
	rep(i,0,n-1)
	{
		if(s[i]==c1)
			v1.pb(i);
		else if(s[i]==c2)
			v2.pb(i);
		else 
			v3.pb(i);
	}
	int ans=0;
	mi mp;
	for(int x:v3)
		mp[x]++;
	rep(i,0,sz(v1)-1)
	{
		rep(j,0,sz(v2)-1)
		{
			if(v1[i]>v2[j])
				continue;
			auto q = lower_bound(v3.begin(), v3.end(), v2[j]+1); 
			int id = q - v3.begin();
			ans += sz(v3) - id;
			int diff = v2[j] - v1[i];
			int tar = v2[j] + diff;
			if(mp[tar]>=1)
				ans = ans - mp[tar];
			//cout << ans << endl;
		}
	}
	return ans;
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T=1;
	while(T--)
	{
		int n;
		cin >> n;
		string s;
		cin >> s;
		int ans=0;
		ans += check('R','G','B',s);
		ans += check('R','B','G',s);
		ans += check('B','R','G',s);
		ans += check('B','G','R',s);
		ans += check('G','R','B',s);
		ans += check('G','B','R',s);
		cout << ans << endl;
	}
}


Measured memory_bytes: 4076
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;

signed main(){
	cin>>S;
	REP(i,S.size()){
		cout<<"x";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
import itertools
s = 1
a = 0
b = 0
N = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
ite = [x for x in range(1, N + 1)]
ite = itertools.permutations(ite)
for i in ite:
    if list(i) == p:
        a = s
    s += 1
s = 1
ite = [x for x in range(1, N + 1)]
ite = itertools.permutations(ite)
for i in ite:
    if list(i) == q:
        b = s
    s += 1
if a > b:
    total = a - b
else:
    total = b - a
print(total)

Measured memory_bytes: 3064
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int N, K; std::cin >> N >> K;
    std::vector<int> P(N), C(N);
    for(int i(0); i < N; ++i){
        std::cin >> P[i]; --P[i];
    }
    for(int i(0); i < N; ++i) std::cin >> C[i];
    std::vector<int> prd(N);
    std::vector<std::vector<long long>> sc(N, std::vector<long long>(N+1));

    for(int i(0); i < N; ++i){
        int cur(i);
        for(int j(1);; ++j){
            cur = P[cur];
            sc[i][j] = sc[i][j-1] + C[cur];
            if(i == cur){
                prd[i] = j; break;
            }
        }
    }
    long long ans(-2 * LINF);
    for(int i(0); i < N; ++i){
        if(prd[i] > K){
            for(int j(1); j <= K; ++j){
                chmax(ans, sc[i][j]);
            }
        }
        else if(sc[i][prd[i]] < 0){
            for(int j(1), j_len(prd[i]); j <= j_len; ++j){
                chmax(ans, sc[i][j]);
            }
        }else{
            long long p(sc[i][prd[i]]);
            for(int j(1), j_len(prd[i]); j <= j_len; ++j){
                chmax(ans, sc[i][j] + p * ((K-j)/prd[i]));
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 198876
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >; // グラフ

// トポロジカルソートする
void rec(int v, const Graph &G, vector<bool> &seen, vector<int> &order) {
    seen[v] = true;
    for (auto next : G[v]) {
        if (seen[next]) continue; // 既に訪問済みなら探索しない
        rec(next, G, seen, order);
    }
    order.push_back(v);
}

int main() {
    int N, M; cin >> N >> M; // 頂点数と枝数
    Graph G(N); // 頂点数 N のグラフ
    map<pair<int,int>,int>D;
    for (int i = 0; i < M; ++i) {
        int a, b, d;
        cin >> a >> b >> d; // ノード a からノード b へと有向辺を張る
        a--;b--;
        G[a].push_back(b);
        D[make_pair(a,b)]=d;
    }

    // 探索
    vector<bool> seen(N, 0); // 初期状態では全ノードが未訪問
    vector<int> order,c(N,-1); // トポロジカルソート順
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // 既に訪問済みなら探索しない
        rec(v, G, seen, order);
    }
    reverse(order.begin(), order.end()); // 逆順に

    int cnt=0;
    for (auto v : order){
        if(c[v]==-1){c[v]=0;}
        for(auto x : G[v]){
            if(c[x]!=-1){
                if(c[x]-c[v]!=D[make_pair(v,x)]){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
            else c[x]=c[v]+D[make_pair(v,x)];
        }
    }
    cout<<"Yes"<<endl;
}

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

// 最大公約数
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

  vector<int> gcdL(n);
  vector<int> gcdR(n);
  rep(i, n) {
    int j = n - 1 - i;
    if (i == 0) {
      gcdL[i] = a[i];
      gcdR[j] = a[j];
    } else {
      gcdL[i] = gcd(a[i], gcdL[i - 1]);
      gcdR[j] = gcd(a[j], gcdR[j + 1]);
    }
  }

  int ans = 0;
  rep(i, n) {
    int g;
    if (i == 0) {
      g = gcdR[1];
    } else if (i == n - 1) {
      g = gcdL[n - 2];
    } else {
      g = gcd(gcdL[i - 1], gcdR[i + 1]);
    }
    ans = max(ans, g);
  }

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

Measured memory_bytes: 1408
import java.util.*;
import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	char[][] vals=new char[][]{{},
		{'.',',','!','?',' '},
		{'a','b','c'},
		{'d','e','f'},
		{'g','h','i'},
		{'j','k','l'},
		{'m','n','o'},
		{'p','q','r','s'},
		{'t','u','v'},
		{'w','x','y','z'},
	};

	public void run() {
		char[] keys=sc.next().toCharArray();

		StringBuilder sb=new StringBuilder();

		char now=0;	int times=-1;

		for(int i=0;i<keys.length;i++){
			char key=keys[i];
			if(key=='0'){
				if(Character.isDigit(now)){
					sb.append(vals[now-'0'][times%vals[now-'0'].length]);
				}
				now=0;
				times=-1;
			}else{
				now=key;
				times++;
			}
		}
		ln(sb);
	}
	public static void main(String[] args) {
		int n=sc.nextInt();
		while(n--!=0)
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

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

using Weight = long long;
using Vertex = int;
struct Edge {Vertex from, to; Weight weight;};
using Graph = std::vector<std::vector<Edge>>;

std::vector<Weight> BellmanFord(const Graph& G, Vertex s, Weight INF = 1e18) {
  std::vector<Weight> d(G.size(), INF);
  d[s] = 0;
  for(auto k = 0; k < 2*G.size(); ++k) for(const auto& E: G) for(const auto& e: E) if(d[e.from] != INF) {
    if(d[e.to] > d[e.from] + e.weight) {
      d[e.to] = d[e.from] + e.weight;
      if(G.size()-1 <= k) d[e.to] = -INF;
    }
  }
  return d;
}

int main() {
  int N, M; Weight P;
  cin >> N >> M >> P;

  Graph G(N);
  for(auto i = 0; i < M; ++i) {
    Vertex A, B; Weight C;
    cin >> A >> B >> C;
    --A; --B;
    G[A].push_back({A, B, P-C});
  }

  Weight INF = 1e18;
  auto d = -BellmanFord(G, 0, INF)[N-1];
  if(d < 0)    d = 0;
  if(d == INF) d = -1;
  cout << d << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;

using namespace std;

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

  int ans = 0;
  for (int i=0;i<N;i++) {
    ans+=L+i;
  }
  if (L >=0) ans -= L;
  else if (L < 0 && L+N <=0) ans -= N+L-1;
  cout <<ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

  int k, n, p[10000], i, j, tmp, sum = 0;
  // n = total

  scanf("%d%d", &n, &k);
  for(i = 0; i < n; i++) scanf("%d", &p[i]);

  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (p[i] > p[j]) {
        tmp =  p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }

  for(i = 0; i < k; i++) {
    sum += p[i];
  }

  printf("%d\n", sum);

  return 0;

}


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

int main() {
  	long long int N;
  	cin >> N;
  	long long int A[N];
  	for (long long int i = 0; i < N; i++) cin >> A[i];
  
  	long long int help[N], help2[N];
  	for (long long int i = 0; i < N; i++){
      	help[i] = i + 1 - A[i];
      	help2[i] = i + 1 + A[i];
    }
  
  	long long int aa[1000001], bb[1000001];
  
  	for (long long int i = 0; i < 1000001; i++){
      	aa[i] = 0;
      	bb[i] = 0;
    }
  
  	for (long long int i = 0; i < N; i++){
      	if (help[i] >= 400000) continue;
      	if (help2[i] >= 400000) continue;
      	aa[help[i] + 500001]++;
      	bb[help2[i] + 500001]++;
    }
  
  	long long int count = 0;
  
  	for (long long int i = 0; i < 1000001; i++){
      	count += aa[i] * bb[i];
    }
  
  	cout << count << endl;
}



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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  int ans = h[n-1] - h[0];
  for(int i = 0; i < n-k+1; i++){
    ans = min(ans,h[i+k-1]-h[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
typedef long long ll;

int n, W;
ll dp[110][110000];
ll w[110], v[110];
 
int main(){
    cin >> n >> W;
    for(int i = 1;i <= n;i++)cin >> w[i] >> v[i];
    for(int j = 1;j < 110000;j++){
        dp[0][j] = LINF;
    }
    for(int i = 1;i <= n;i++){
        for(int j = 0;j < 110000;j++){
            dp[i][j] = dp[i-1][j];
            if(j-v[i] >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
            }
        }
    }
    int ans = 0;
    for(int v = 0;v < 110000;v++){
        if(dp[n][v] <= W){
            ans = max(ans, v);
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 90392
#include <stdio.h>

int main(){

  int a,b;
  char op;

  scanf("%d %c %d",&a,&op,&b);

  if(op=='+'){
    printf("%d\n",a+b);
  }else if(op=='-'){
    printf("%d\n",a-b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 1100000
using namespace std;
int a[N],i,j,n,m,k,l,o;
long long ans,now;
const int mo=1e9+7;
int ny(int x,int m)
{
	int ans=1,p=x;
	while (m)
	{
		if (m&1) ans=(1ll*ans*p)%mo;
		m>>=1;
		p=(1ll*p*p)%mo;
	}
	return ans;
}
int main()
{
	scanf("%d%d",&n,&k);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	now=1;
    for (i=k;i<=n;i++)
    {
    	ans=(ans+1ll*now*a[i])%mo;
    	now*=i;
    	now%=mo;
    	now*=ny(i-k+1,mo-2);
    	now%=mo;
	}
	now=1;j=k;
	for (i=n-k+1;i>=1;i--)
	{
		ans=(ans-1ll*a[i]*now)%mo;
		now*=j;
		now%=mo;
		now*=ny(j-k+1,mo-2);j++;
		now%=mo;
	}
	printf("%d",ans);
}

Measured memory_bytes: 640
def output(out):
    for i in out:
        for j in i:
            print(j, end='')
        print()
    return

def func(H, W):
    out = ['' for i in range(H+2)]
    b = ['#' for j in range(W+2)]
    out[0] = b
    for i in range(H):
        s = input()
        out[i+1] = ['#'] + list(s) + ['#']
    out[-1] = b
    return out

s = input().split(' ')
H = int(s[0])
W = int(s[1])
out = func(H, W)
output(out)


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

const int MOD = 1e9 + 7, MAX = 2000001;

int comb(int n, int k){
    // Calculate factorial and inverse element
    int64_t fac[MAX], finv[MAX], inv[MAX];
    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;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int X, Y, ans = 0;
    cin >> X >> Y;
    int n = (2 * Y - X) / 3;
    int m = (2 * X - Y) / 3;
    if ((X + Y) % 3 == 0 && n >= 0 && m >= 0) {
        ans = comb(n + m, n);
    }
    cout << ans << endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll x=n/(a+b);
    ll ans=x*a;
    n-=x*(a+b);
    if(n<=a)ans+=n;
    else ans+=a;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
N = int(input())
P = [[int(i) for i in input().split(" ")]for _ in range(N)]

min_point = 100
for i in range(N-1):
	for j in range(i+1, N):
		p = P[i]
		q = P[j]
		if p[0] <=  q[0]:
			x = q[0]-p[0]
			y = q[1]-p[1]
			point = 0
			mp = [False for _ in range(N)]
			count = N
			index = 0
			qu = queue.Queue()
			while count:
				if not mp[index]:
					point += 1
					qu.put(P[index])
					mp[index] = True
					count -= 1
					while not qu.empty():
						top = qu.get()
						for k in range(N):
							if not mp[k] and ((top[0]-x == P[k][0] and top[1]-y == P[k][1]) or (top[0]+x == P[k][0] and top[1]+y == P[k][1])):
								count -= 1
								qu.put(P[k])
								mp[k] = True
				index += 1
			if point < min_point:
				min_point = point
if N == 1:
	min_point = 1
print(min_point)




Measured memory_bytes: 3952
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()
 
int main()
{
	vc s(3);
	vc abc{'a','b','c'};
	rep(i,3){
		cin>>s.at(i);
	}
	sort(all(s));
	if(s==abc){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}

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

int main()
{
    int64_t n;
    cin>>n;
    bitset<32>a(n);
    cout<<a<<endl;
    cout<<~a<<endl;
    cout<<(a<<1)<<endl;
    cout<<(a>>1)<<endl;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

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

    double X=0;
    double p=1;
    F(i,0,m) p*=1/2.0;
    double sum=1;
    int cnt=1;
    while(sum>0.01){
        sum=0;
        double t=1.0;
        F(i,0,cnt-1) t*=1-p;
        sum=(1900*m*cnt+100*(n-m)*cnt)*t*p;
        X+=sum;
        ++cnt;
    }
    cout << ceil(X) << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define int long long
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int h,w;
int g[1005][1005];

bool check(int y,int x){
    if ((0<=y && y<=h-1) && (0<=x && x<=w-1)) return true;
    return false;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    queue<pair<int,int>> q;
    rep(i,h)rep(j,w){
        char s;
        cin >> s;
        if (s=='.'){
            g[i][j]=0;
            q.push(make_pair(i,j));
        }
        else g[i][j]=s-'0';
    }
    int ans=0;
    while (true){
        queue<pair<int,int>> tmp;
        while (!q.empty()){
            pair<int,int> now=q.front();
            q.pop();
            int y=now.fi;
            int x=now.se;
            rep(i,8){
                int ny=y+dy8[i];
                int nx=x+dx8[i];
                if (!check(ny,nx)) continue;
                if (g[ny][nx]>0){
                    g[ny][nx]--;
                    if (g[ny][nx]==0) tmp.push(make_pair(ny,nx));
                }
            }
        }
        q=tmp;
        if (q.empty()) break;
        ans++;
    }
    cout << ans << endl;
}

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

int main(){
    int H,W; cin >> H >> W;
    int N; cin >> N;
    int a[N]; 
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    int ans[H][W];

    int k=0;
    for(int i=0;i<H;i++){
        if(i%2==0){
            for(int j=0;j<W;j++){
                ans[i][j]=k+1;
                //cout << k+1 << endl;
                a[k]--;
                if(a[k]==0) k++;
            }
        }
        if(i%2!=0){
            for(int j=W-1;j>=0;j--){
                ans[i][j]=k+1;
                a[k]--;
                if(a[k]==0) k++;
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var a, b, c, ans int;

	fmt.Scan(&a, &b, &c)

	ans = 0
	for i := a; i < b+1; i++ {
		if c% i == 0 {
			ans += 1
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1156
#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;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    for(;;){
        int n;
        if(!(cin >> n))
            return 0;
        vector<bool> prime;
        makePrimeNumber(n, prime);
        int ret = 0;
        for(int i=0; i<=n; ++i)
            if(prime[i])
                ++ ret;
        cout << ret << endl;
    }
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i];

    }

    int res = 0;
    for(int i = 0; i <= N; ++i) {
        for(int j = N; j >= i; --j) {
            vector<int> tmp;
            for(int k = 0; k < i; ++k) tmp.pb(v[k]);
            for(int k = N - 1; k >= j; --k) tmp.pb(v[k]);
            if(tmp.size() > K) break;

            int sum = 0;
            for(int k = 0; k < tmp.size(); ++k) {
                sum += tmp[k];

            }
            res = max(res, sum);
            sort(all(tmp));
            for(int k = 0; k < min(K - int(tmp.size()), int(tmp.size())); ++k) {
                sum -= tmp[k];
                res = max(res, sum);

            }
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G1[500005],G2[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<(x)<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,q;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];
bool flag,dame;


int main(){
    cin >> a >> b >> c >> d;
	pd(a-b);
	p((c-a)*(d-b));
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const ll INF = TEN(18);

ll solve(ll H, ll W) {
    ll res = INF;
    for (int i = 1; i <= H; ++i) {
        ll u = W * i;
        ll a = (H - i) / 2 * W, b = (H - i + 1) / 2 * W;
        ll c = W / 2 * (H - i), d = (W + 1) / 2 * (H - i);
        chmin(res, max({u, a, b}) - min({u, a, b}));
        chmin(res, max({u, c, d}) - min({u, c, d}));
    }
    return res;
}

int main() {
    ll H, W;
    cin >> H >> W;
    cout << min(solve(H, W), solve(W, H)) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

/*
水を入れる容器が 2 つあります。
容器  には水を Aミリリットルまで入れることができ、水が Bミリリットル入っています。
容器 2 には水が C ミリリットル入っています。
容器 2から容器 1に入るだけ水を移します。
容器2の中には何ミリリットルの水が残るでしょうか。

*/
    public static void main (String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        int ans = c - (a - b);
        if (ans < 0){
            ans = 0;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
def input_from_console():
    n, l = map(int, input().split())
    return n, l


def solve(n, l):
    all_data = [ l + item for item in range(n)]
    new_list = sorted([abs(item) for item in all_data])
    if new_list[0] in all_data:
        result = sum(all_data) - new_list[0]
    else:
        result = sum(all_data) + new_list[0]
    return result


def main():
    n, l = input_from_console()
    print(solve(n, l))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Measured memory_bytes: 3064
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

template<typename T>
vector<T> getVector(int N) {
    vector<T> v(N);
    REP(i, N) cin >> v[i];
    return v;
}

typedef vector<int> VI;

VI mulv(VI A, VI B) {
    int n = A.size();

    VI C(n);
    REP(i, n) {
        C[i] = B[A[i]];
    }

    return C;
}

VI powv(VI A, ll n) {
    VI X(A.size());
    REP(i, (int)A.size()) X[i] = i;

    while(1) {
        if (n & 1) {
            X = mulv(X, A);
        }
        n >>= 1;
        if (!n)
            return X;
        A = mulv(A, A);
    }
}

int main(void)
{
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
        A[i]--;
    }
    cout << powv(A, K)[0]+1 << endl;
    
    return 0;
}


Measured memory_bytes: 8012
#include <iostream>
using namespace std;
int main()
{
  for(;;){
    int t;
    cin >> t;
    if(t==0) break;
    int n;
    cin >> n;
    int sum = 0;
    for(int i=0; i<n; i++){
      int s,f;
      cin >> s >> f;
      sum += f - s;
    }
    if(sum >= t) cout << "OK" << endl;
    else cout << t - sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
from itertools import combinations

N, M, X = map(int, input().split())
box = [list(map(int, input().split())) for _ in range(N)]

ans = -1

for j in range(1, N+1):
    for i in combinations(box, j):
        kakaku = 0
        rika = [0 for _ in range(M)]
        for el in i:
            kakaku += el[0]
            for n, k in enumerate(el[1:]):
                rika[n] += k

        if all(p >= X for p in rika):
            if ans == -1:
                ans = kakaku
            else:
                ans = min(kakaku, ans)

print(ans)

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int X, N;
  std::cin >> X >> N;
  std::map<int, bool> isin_p;
  std::vector<int> p(N);
  rep(i, N) {
    std::cin >> p[i];
    isin_p[p[i]] = true;
  }

  int ans = -1;
  int d = std::abs(X - ans);
  for(int x = 0; x <= 101; ++x) {
    if(isin_p[x]) continue;
    int new_d = std::abs(X - x);
    if(new_d < d) {
      ans = x;
      d = new_d;
    }
  }

  std::cout << ans << '\n';
}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
using Graph = vector<vector<char>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 1e9+7;

signed main(){
    string n;
    cin >> n;
    int m = n.length()-1;
    if(n[m]=='s') cout << n<<"es" << endl;
    else cout << n<<"s" << endl;
    return 0;
}


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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long C){
    if (A == 5 && B == 5 && C == 7) {
        cout << "YES" << endl;
        return;
    }
    if (A == 7 && B == 5 && C == 5) {
        cout << "YES" << endl;
        return;
    }
    if (A == 5 && B == 7 && C == 5) {
        cout << "YES" << endl;
        return;
    }
    cout << "NO" << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

int a[100005];
vector<int> ans;

int main(void){
	map<int, int> m;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> a[i];
	}
	for (int i = 0; i < N; i++){
		m[a[i]]++;
		m[a[N-1-i]]--;
		if (!m[a[i]]) m.erase(a[i]);
		if (!m[a[N-1-i]]) m.erase(a[N-1-i]);
		if (m.empty()) ans.push_back(i+1);
	}

	for (size_t i = 0; i < ans.size(); i++){
		if (i) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;

}




Measured memory_bytes: 4512
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
int inv[1100];
int fact[1100];
int factinv[1100];
int pow[1100][1100];
int factpow[1100][1100];
int invpow[1100][1100];
long long dp[1100][1100];
long long dp2[1100][1100];
long long dp3[1100][1100];
int finvpow[1100][1100];
long long gcd(long long a,long long b){
	while(a){
		b%=a;
		long long c=a;a=b;b=c;
	}
	return b;
}
long long ABS(long long a){return max(a,-a);}
int main(){
	inv[1]=1;
	for(int i=2;i<1100;i++)inv[i]=(mod-(mod/i)*(inv[mod%i])%mod)%mod;
	fact[0]=factinv[0]=1;
	for(int i=1;i<1100;i++){
		fact[i]=(long long)fact[i-1]*i%mod;
		factinv[i]=(long long)factinv[i-1]*inv[i]%mod;
	}
	for(int i=0;i<1100;i++){
		pow[i][0]=factpow[i][0]=invpow[i][0]=finvpow[i][0]=1;
		for(int j=1;j<1100;j++){
			pow[i][j]=(long long)pow[i][j-1]*i%mod;
			factpow[i][j]=(long long)factpow[i][j-1]*fact[i]%mod;
			invpow[i][j]=(long long)invpow[i][j-1]*inv[i]%mod;
			finvpow[i][j]=(long long)finvpow[i][j-1]*factinv[i]%mod;
		}
	}
	int a;
	long long b,c,d;
	scanf("%d%lld%lld%lld",&a,&b,&c,&d);
	long long t=ABS(b-c+d);
	if(b==0&&c==0&&d==0){
		long long ret=0;
		for(int i=0;i*2<=a;i++){
			ret=(ret+(long long)fact[a]*invpow[2][i]%mod*factinv[i]%mod*factinv[a-i*2]%mod)%mod;
		}
		printf("%lld\n",ret*pow[a][a]%mod);
		return 0;
	}
	for(int i=1;i<=a;i++){
		dp3[i][0]=1;
		for(int j=1;j<=a/i;j++){
			if(t%j||gcd(t/j,i)!=1)continue;
			for(int k=a/i;k>=0;k--){
				for(int l=1;k+l*j<=a/i;l++){
					dp3[i][k+l*j]=(dp3[i][k+l*j]+(long long)dp3[i][k]*finvpow[j][l]%mod*factinv[l]%mod*factpow[j-1][l]%mod*invpow[i][l])%mod;
				}
			}
		}
	}
	for(int i=1;i<=a;i++){
		if(i%2==0){
			for(int j=0;j<=a/i;j++){
				if(j%2)continue;
				dp2[i][j]=(long long)fact[i*j]*factinv[j/2]%mod*invpow[2][j/2]%mod*finvpow[i][j]%mod*pow[i][j/2]%mod;
			}
			continue;
		}
		for(int j=0;j<=a/i;j++){
			for(int k=0;k*2<=j;k++){
				dp2[i][j]=(dp2[i][j]+(long long)fact[i*j]*factinv[j-k*2]%mod*factinv[k]%mod*invpow[2][k]%mod*pow[i][k]%mod*finvpow[i][j])%mod;
			}
		}
	}
	dp[0][0]=1;
	for(int i=0;i<=a;i++){
		for(int j=0;j<a;j++){
			if(!dp[i][j])continue;
			int v=j+1;
			for(int k=0;i+k<=a;k+=v){
				dp[i+k][v]=(dp[i+k][v]+(long long)dp[i][j]*dp2[v][k/v]%mod*dp3[v][k/v]%mod*fact[k/v]%mod*factpow[v][k/v]%mod*fact[a-i]%mod*factinv[a-i-k]%mod*factinv[k])%mod;
			}
		}
	}
/*	for(int i=1;i<=a;i++){
		for(int j=0;j<=a/i;j++){
			printf("%lld ",dp2[i][j]*dp3[i][j]%mod*fact[j]%mod*factpow[i][j]%mod);
		}
		printf("\n");
	}
	for(int i=0;i<=a;i++){
		for(int j=0;j<=a;j++)printf("%lld ",dp[j][i]);
		printf("\n");
	}*/
	printf("%lld\n",dp[a][a]%mod);
}

Measured memory_bytes: 48304
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
using namespace std;
#define ll long long

int main(){
vector<ll> sosu(1000000,0);
for(ll i=2; i*i<1000000; i++){
  if(sosu[i] == 1){
    continue;
  }
  ll j=i;
  while(1000000 > i*j){
    sosu[i*j] = 1;
    j++;
  }
}
sosu[0] = 1;
sosu[1] = 1;
   while(1){
    int a,d,n;
    cin >> a >> d >> n;
    if(a==0 && d==0 && n==0){
      break;
    }
    while(n>0){
      while(sosu[a] != 1){
        a += d;
        n--;
        if(n == 0){
          a -= d;
          cout << a << endl;
          break;
        }
      }
      a += d;
    }
  }

  return 0;
}



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

using namespace std;
using vi = vector <int>;

void fileIO() {
    #ifdef ROBIN
        freopen("in", "r", stdin);
        freopen("out", "w", stdout);
    #endif // ROBIN
}

int main() {
    // optimize();
    fileIO();
    int n; cin >> n;
    int a, b;
    vector <vi> permutations;
    vi P, Q, original_permutation;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        P.push_back(x);
    }

    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        Q.push_back(x);
    }

    for (int i = 1; i <= n; i++) original_permutation.push_back(i);
    //ekhon shobgula permutations bair korbo
    int koto_tomo = 1;
    do {
        if (original_permutation == P) a = koto_tomo;
        if (original_permutation == Q) b = koto_tomo;
        koto_tomo++;
    } while (next_permutation(original_permutation.begin(), original_permutation.end()));

    cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)


























int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n), c(n);
    REP(i, n){
        cin >> p[i];
        p[i]--;
    }
    REP(i, n){
        cin >> c[i];
    }
    ll ans = -INF;
    REP(i, n){
        ll sum = 0, loop = 0;
        {
            ll now = i;
            REP(j, n){
                sum += c[now];
                now = p[now];
                loop++;
                if(now == i) break;
            }
        };
        ll now = i, cnt = 0, s = 0;
        REP(j, min(k, loop)){
            cnt++;
            s += c[now];
            ans = max(ans, max(sum, 0LL) * ((k - cnt) / loop) + s);
            now = p[now];
        }
    }
    cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	int a[100], c = 1;
	for (int i = 0; i < n; i++) cin >> a[i];

	sort(a, a + n, greater<int>());

	int cap = a[0];
	for (int i = 1; i < n; i++) {
		if (a[i] < cap) {
			c++;
			cap = a[i];
		}
	}

	cout << c << endl;
}

Measured memory_bytes: 256
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res
n = int(input())
data = list(map(int, input().split()))
count = count(data)
ans = sum(data)
q = int(input())
answers = []
for _ in range(q):
    b, c = map(int, input().split())
    if b in count:
        num = count[b]
        ans += c*num - b*num
        if c in count:
            count[c] += num
        else:
            count[c] = num
        count[b] = 0
    answers.append(ans)
for a in answers:
    print(a)

Measured memory_bytes: 20816
N = int(input())
SP = [list(input().split()) + [i+1] for i in range(N)]
SP = [[sp[0], int(sp[1]), sp[2]] for sp in SP]
#SP2 = [SP[i] + [i] for i in range(N)]
SP = sorted(SP, key = lambda x : x[1], reverse=True)
SP = sorted(SP, key = lambda x : x[0])
#SP = sorted(SP, key = lambda x : x[0]), key = lambda x : x[1], reverse=True)
#print(SP)
ans = [sp[2] for sp in SP]
for a in ans :
    print(a)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,m;
	ios::sync_with_stdio(false);
	cin>>n>>m;
	ll d=n-m;
	ll tim=1LL*100*d+1LL*1900*m;
	ll t=pow(2,m);
	tim*=t;
	cout<<tim;
}


Measured memory_bytes: 256