akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
#define all(a) a.begin(), a.end()
#define mp(a, b) make_pair(a, b)

int INF = 100100100;
int MOD = 10e7+9;

int main(){
    int N;
    cin >> N;
    vector<int> a(N, 0);
    ll b = 0;
    rep(i, 0, N){
        cin >> a[i];
        b ^= a[i];
    }
    rep(i, 0, N){
        ll ans = b^a[i];
        cout << ans << ' ';
    }
}

Measured memory_bytes: 3976
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const ll MOD = 1e9 + 7;
inline ll addmod(ll a, ll b){
	if(a+b<MOD)return a+b;
	return a+b-MOD;
}
inline ll mulmod(ll a, ll b){
	return (a*b)%MOD;
}
inline ll expmod(ll a, ll e){
	ll ret = 1;
	while(e){
		if(e&1)ret = mulmod(ret, a);
		a = mulmod(a, a);
		e >>= 1;
	}
	return ret;
}
inline ll divmod(ll a, ll b){
	return mulmod(a, expmod(b, MOD-2));
}

int n,x,y,z;
int tmask;
int m1, m2, m3;

int memo[40][1<<16][2];
int dp(int now, int mask, bool ok){
	if(now == n)return ok;

	int& ret = memo[now][mask][ok];
	if(ret != -1)return ret;
	ret = 0;

	int nmask = mask<<1|1;
	REP(i,1,10){
		bool nok = ok;
		if((nmask & m1) && (nmask & m2) && (nmask & m3)){
			nok = true;
		}
		ret = addmod(ret, dp(now+1, nmask & tmask, nok));
		nmask <<= 1;
	}
	// if(ret > 0){
	// 	printf("%d %d %d = %d\n",now,mask,ok,ret);
	// }
	return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>n>>x>>y>>z;
    tmask = (1 << (x + y + z - 1)) - 1;
    m1 = 1<<(z-1);
    m2 = 1<<(y+z-1);
    m3 = 1<<(x+y+z-1);

    memset(memo, -1, sizeof memo);
    cout << dp(0, 0, false) << endl;

    return 0;
}


Measured memory_bytes: 20864
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int H,W,K;
string s[1000];
int X[22],Y[22];
long dis[22][22];
int D[5]={0,1,0,-1,0};
long dp[1<<20][20];
main()
{
	cin>>H>>W>>K;
	int id=2;
	for(int i=0;i<H;i++)
	{
		cin>>s[i];
		for(int j=0;j<W;j++)
		{
			if(s[i][j]=='s')
			{
				X[0]=i;
				Y[0]=j;
			}
			else if(s[i][j]=='e')
			{
				X[1]=i;
				Y[1]=j;
			}
			else if(s[i][j]=='a')
			{
				X[id]=i;
				Y[id++]=j;
			}
		}
	}
	for(int i=0;i<id;i++)
	{
		vector<vector<int> >d(H,vector<int>(W,1e9));
		d[X[i]][Y[i]]=0;
		queue<pair<int,int> >P;
		P.push(make_pair(X[i],Y[i]));
		while(!P.empty())
		{
			int x=P.front().first,y=P.front().second;
			P.pop();
			for(int r=0;r<4;r++)
			{
				int tx=x+D[r],ty=y+D[r+1];
				if(0<=tx&&tx<H&&0<=ty&&ty<W&&s[tx][ty]!='#'&&d[tx][ty]>d[x][y]+1)
				{
					d[tx][ty]=d[x][y]+1;
					P.push(make_pair(tx,ty));
				}
			}
		}
		for(int j=0;j<id;j++)
		{
			dis[i][j]=d[X[j]][Y[j]];
		}
	}
	int sz=id-2;
	for(int i=0;i<1<<sz;i++)for(int j=0;j<sz;j++)dp[i][j]=1e18;
	for(int i=2;i<id;i++)
	{
		dp[1<<i-2][i-2]=dis[0][i];
	}
	for(int i=1;i<1<<sz;i++)
	{
		for(int j=0;j<sz;j++)
		{
			if(dp[i][j]>1e17)continue;
			for(int k=0;k<sz;k++)
			{
				if(i>>k&1)continue;
				dp[i|1<<k][k]=min(dp[i|1<<k][k],dp[i][j]+dis[j+2][k+2]);
			}
		}
	}
	long ans=1e18;
	for(int i=0;i<1<<sz;i++)
	{
		if(__builtin_popcount(i)<K)continue;
		for(int j=0;j<sz;j++)ans=min(ans,dp[i][j]+dis[j+2][1]);
	}
	cout<<(ans>1e9?-1:ans)<<endl;
}



Measured memory_bytes: 168048
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    lis=[]
    for i in range(n):
        a,b=map(int,input().split())
        lis.append((b,a))
    lis.sort()
    time=0
    for l in lis:
        time+=l[1]
        if time>l[0]:
            print("No")
            break
    else:
        print("Yes")

if __name__=='__main__':
    main()

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

int main(){

    int q;
    cin >> q;
    map<string, int> mp;
    for(int i = 0; i < q; ++i){
        int com;
        string key;
        cin >> com >> key;
        if(com == 0){
            int x;
            cin >> x;
            mp[key] = x;
        }
        else if(com == 1){
            cout << mp[key] << endl;
        }
        else{
            mp[key] = 0;
        }
    }

    return 0;
}


Measured memory_bytes: 27876
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  string s;
  int l[12];
  while(cin >> s){
    s += ",";
    string tmp = "";
    int ati = 0;
    rep(i, s.size()){
      if(s[i] == ','){
        l[ati] = stoi(tmp);
        ati++;
        tmp = "";
      }else{
        tmp += s[i];
      }
    }
    double lsum = 0.;
    rep(i, 10)lsum += (double)l[i];
    double h = lsum / (double)(l[10] + l[11]);
    h = h * (double)l[10];
    double at = 0.;
    rep(i, 10){
      if(at <= h && h <= at + l[i]){
        cout << i+1 << endl;
        break;
      }
      at += l[i];
    }
  }
	return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;cin>>s;
  int len = s.length();
  for (int i=0;i<len;i++){
    if (s[i] == '?') {
      cout << "D";
    } else {
      cout << s[i];
    }
  }
  cout << endl;
}


Measured memory_bytes: 3756
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	Scanner scan = new Scanner(System.in);
	int X = scan.nextInt();
    int sum =0;
    int d =0;
    int l =0;
    int g =0;
    for(int i=0;i<=X;i++){
    	sum += i;
		if(X<=sum){
			d = i;
		break;
		}
    }
    System.out.println(d);
}
}

Measured memory_bytes: 22100
a,b,c = sorted(map(int,input().split()))
if (c-a)%2 ==0 and (c-b)%2 == 0:
  print((c-a)//2+(c-b)//2)
elif (c-a)%2 == 1 and (c-b)%2 == 1:
  print((2*c-b-a-2)//2+1)
elif (c-a)%2 == 0:
  print((c-a)//2+(c+1-b)//2+1)
else:
  print((c+1-a)//2+(c-b)//2+1)

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

using namespace std;

//#include <ext/rope>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
//typedef tree< double, int, less<double>, rb_tree_tag, tree_order_statistics_node_update> map_t;

/// Shortcut

#define TASK "TEST2"
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FOR(i, l, r) for (ll i = l; i <= r; i++)
#define FOD(i, l, r) for (ll i = l; i >= r; i--)
#define FORAUTO(i, a) for (auto i : a)

/// Functions

#define fi first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define upper upper_bound
#define lower lower_bound
#define itr iterator
#define rtr reverse_iterator
#define memset(a,x) memset(a, x, sizeof(a))
#define memsetf(a) memset(a, 0x3f, sizeof(a))
#define fillV(v, x) fill(v.begin(), v.end(), x)
#define fillArr(arr, n, x) fill(arr, arr + n, x)
#define fillA(a, n, x) fill(a + 1, a + n + 1, x)

/// Data Structure

#define um unordered_map
#define us unordered_set
#define pq priority_queue

/// BIT

#define cntBit(n) __builtin_popcount(n)
#define cntBitll(n) __builtin_popcountll(n)

/// EDIT

const ll MAX = 100005;
const ll MOD = 1e9 + 7;
const ll BASE = 1000;
const ll DIGIT = 4;
const ll LIM = (1 << 24);
const ll INF = (1 << 30);
const ll LIMIT = 1e18;

/// ================================ - MAIN - ================================

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen(TASK".INP","r",stdin);
        freopen(TASK".OUT","w",stdout);
    #endif
    int x;
    cin >> x;
    (x) ? cout << 0 : cout << 1;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
  int n = 1;
  while(n != 0){
    cin >> n;
    if(n == 0)break;
    vector<pair<int,pair<int,pair<int,char>>>>v(n);
    rep(i,n){
      char c;
      cin >> c;
      int cnt1 = 0,cnt2 = 0;
      rep(j,n - 1){
        int tmp;
        cin >> tmp;
        if(tmp == 0)cnt1--;
        if(tmp == 1)cnt2++;
      }
      v[i] = {cnt1,{cnt2,{i,c}}};
    }
    sort(v.begin(),v.end());
    rep(i,n)cout << v[i].second.second.second << endl;
  }
  return 0;
}


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

const int N = 1e+5 + 5;
int ans[N], dt[N], cou, t = 1, n, m, k;
set<int> adj[N];
bool vis1[N], vis2[N];

void dfs(int v)
{
    vis1[v] = true;
    cou++;
    dt[v] = t;
    for (auto it : adj[v])
        if (!vis1[it])
            dfs(it);
    return;
}
void setans(int v)
{
    vis2[v] = true;
    ans[v] = cou - adj[v].size() - 1;
    for (auto it : adj[v])
        if (!vis2[it])
            setans(it);
    return;
}
int main()
{
    cin >> n >> m >> k;
    for (int i = 1; i <= m; i++)
    {
        int a, b;
        cin >> a >> b;
        adj[a].insert(b);
        adj[b].insert(a);
    }
    for (int i = 1; i <= n; i++)
    {
        if (!vis1[i])
        {
            cou=0;
            dfs(i);
            setans(i);
            t++;
        }
    }
    for (int i = 1; i <= k; i++)
    {
        int a, b;
        cin >> a >> b;
        if (dt[b] == dt[a] && adj[a].find(b) == adj[a].end())
        {
            ans[a]--;
            ans[b]--;
        }
    }
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}

Measured memory_bytes: 16640
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto k = readLong();
    long n = 50;
    auto x = k % n;
    writeln(n);
    foreach(i; iota(n)) {
        if(i < x) {
            write(n - i + k/n, " \n"[i == n-1 ? 1: 0]);
        } else {
            write(n - i - 1 + k/n, " \n"[i == n-1 ? 1: 0]);
        }
    }
}



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

const int x = 179, p = 1791791791;
vector<int> hs, xp;

int get(int a, int b) {
    return ((hs[b] - hs[a] * xp[b - a]) % p + p) % p;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    hs.resize(n + 1);
    xp.resize(n + 1);
    xp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        xp[i] = (xp[i - 1] * x) % p;
        hs[i] = (hs[i - 1] * x + s[i - 1]) % p;
    }
    int pr = -1;
    int l = 0, r = 1;
    int ans = 0;
    while (r <= n) {
        while (get(l, r) == pr && r <= n)
            ++r;
        if (r <= n) {
            pr = get(l, r);
            l = r;
            r = l + 1;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <string.h>

int main(void){
  using namespace std;
  char s[1000], t[1000];
  int x[1000], sum=0, ans;

  cin >> s >> t;
  ans = strlen(t);

  if(strlen(s)==strlen(t)){
    sum=0;
    for(long unsigned int j=0;j<strlen(t);j++){
      if(s[j]!=t[j]) x[j]=1;
      else x[j]=0;    
      //cout << x[j];
    }
    for(long unsigned int j=0;j<strlen(t);j++){
      sum += x[j];
    }
    if(ans > sum) ans=sum;
  }
  
  else{
    sum=strlen(t);
    for(long unsigned int i=0;i<strlen(s)-strlen(t)+1;i++){
      sum=0;
      for(long unsigned int j=0;j<strlen(t);j++){
        if(s[i+j]!=t[j]) x[j]=1;
        else x[j]=0;    
        //cout << x[j];
      }
      for(long unsigned int j=0;j<strlen(t);j++){
        sum += x[j];
      }
      if(ans > sum) ans=sum;
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 3516
iw = str(input())
ow=[]

s="abcdefghijklmnopqrstuvwxyz"
l="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in iw:
    if i in s:
        ow1=l[s.index(i)]
    elif i in l:
        ow1=s[l.index(i)]
    else:
        ow1=i
    ow.append(ow1)

print("".join(ow))



Measured memory_bytes: 5568
n,m = map(int,input().split())
x = [0]*m
y = [0]*m
for i in range(m): 
    x[i],y[i] = map(int,input().split())
    x[i] -= 1
    y[i] -= 1
cnt = [1]*n
flag = [False]*n
flag[0] = True
for i in range(m):
    if flag[x[i]]: 
        flag[y[i]] = True
        if cnt[x[i]] == 1: 
            flag[x[i]] = False
    cnt[x[i]] -= 1
    cnt[y[i]] += 1
    
print(flag.count(True))

Measured memory_bytes: 12404
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  ll count = 0;
  ll now = 1;
  int i=0;
  while(i < n){
    if(a[i] == now){
      count++;
      now += 1;
    }
    i++;
  }
  if(count == 0) cout << -1 << endl;
  else cout << n - count << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
//#include<string>
#include<vector>


using namespace std;


int main(){
    int N;
    cin >> N;
    int buff;
    vector<int> G(N,0);
    for(int i=1;i<N;i++){
        cin >> buff;
        G[buff-1]++;
    }

    for(int i=0;i<N;i++){
        cout << G[i] << endl;
    }
    return 0;

}

Measured memory_bytes: 4052
# include <bits/stdc++.h>
# define maxn 300003
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);
# define pb push_back
# define mp make_pair
using namespace std;

int32_t main(){_
    ll x , y , z;
    cin >> x >> y >> z;
    if(x % z != 0) x += (z - (x % z));
    y -= y%z;
    if(x > y) rc(0);
    else rc( (y - x) / z + 1);
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i = 0; i < h; i++) {
			list.add(scan.next());
		}
		for (int i = 0; i < 2 * h; i++) {
			System.out.println(list.get(i / 2));
		}
		System.out.println();

	}
}

Measured memory_bytes: 24788
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        String[] arrayS = s.split("");
        String[] arrayT = t.split("");
        
        for(int i=0;i<n;i++){
            System.out.print(arrayS[i]);
            System.out.print(arrayT[i]);
        }
    }
}


Measured memory_bytes: 22740
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if(n>1)
  {
      int l=m-n+1;
      int r=m+n-1;
      for(int i=l; i<=r; i++)
      {
          cout<<i<<" ";
      }
      
  }
  else
  cout<<m;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// https://atcoder.jp/contests/abc122/tasks/abc122_b

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int n = s.size();
    int tmp = 0;
    rep(i, n){
        if (i==n-1){
            if (s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T') tmp++;
            chmax(ans, tmp);
        }else{
            if (s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T'){
                tmp++;
            }else{
                chmax(ans, tmp);
                tmp = 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	int x,a,b; 
  	cin >> x >> a >> b;
  	if(a >= b) {
    	cout << "delicious" << endl; 
    } else if(b - a <= x) {
    	cout << "safe" << endl;
    } else {
    	cout << "dangerous" << endl;
    }
  
}

Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let n: i32 = procon_read()[0];
	println!("{}", n*(n+1)/2);
}

Measured memory_bytes: 4352
@n, m = gets.split(" ").map(&:to_i)
@lights = []
m.times do
  @lights.push(gets.split(" ").map(&:to_i))
end

@ps = gets.split(" ").map(&:to_i)

@lights.each do |li|
  li.shift(1)
end

@switches = Array.new(@n, false)

@sum = 0

def recursive_dfs(switch_num, bool)
  if switch_num >= 0
    @switches[switch_num] = bool
  end
  if switch_num >= @n - 1
    judge = true
    @lights.each_with_index do |light, index1|
      switch_sum = 0
      light.each_with_index do |switch, index2|
        if @switches[switch - 1] == true
          switch_sum += 1
        end
      end
      if @ps[index1].even? != switch_sum.even?
        judge = false
      end
    end
    if judge == true
      @sum += 1
    end
    return
  end
  switch_num += 1
  2.times do |index|
    if index == 0
      recursive_dfs(switch_num, true)
    elsif index == 1
      recursive_dfs(switch_num, false)
    end  
  end
end

recursive_dfs(-1, false)
puts @sum

Measured memory_bytes: 3836
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>京都
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

signed main()
{
	int N;
	int P[100];

	cin >> N;
	REP(i, N) cin >> P[i];

	int cnt = 0;
	for (int i = 1; i < N - 1; i++)
	{
		bool flg = false;
		if (P[i - 1] > P[i] && P[i] >= P[i + 1]) flg = true;
		if (P[i + 1] > P[i] && P[i] >= P[i - 1]) flg = true;
		if (flg) cnt++;
	}

	cout << cnt << endl;
}











Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n, k, d;
    cin>>n>>k>>d;
    // ll sign = -1*(ans<0);
    n = abs(n);
    // if(abs(n) > d){
    //     ll ans = abs(n) - k*d;  
    //     cout<<ans;
    //     return ;
    // }
    ll times = n/d;
    if(times > k){
        cout<<n-k*d;
        return ;
    }
    ll pos = n-times*d;
    if((k-times)&1)
        cout<<abs(pos-d);
    else
        cout<<pos;

}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3620
N= int(input())

L = []
R = []
for i in range(N):
	l, r= map(int, input().split())
	L.append(l)
	R.append(r)

Q=[]
P=0
for x in range(N):
    P=R[x]-L[x]+1
    Q.append(P)
    
print(sum(Q))

Measured memory_bytes: 3064
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int count(int N)
{
        int cnt = 0;
        while (N)
        {
                cnt += N % 10;
                N /= 10;
        }
        return cnt;
}

int main()
{
        int N, K;
        cin >> N >> K;
        vector<string> l(N + 1);
        rep(i, N) cin >> l[i];
        sort(l.begin(), l.begin() + N);

        string ans = "";
        rep(i, N)
        {
                ans += l[i];
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, X, L[100000];
    int height=0, ans=1;
    cin >> N >> X;
    for(int i=0;i<N;i++){
        cin >> L[i];
        height += L[i];
        if(height > X)
            break;
        ans++;
    }
    printf("%d", ans);
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  vector<int>a(n), b(n);
  rep(i, n)cin>>a[i]>>b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if(n%2==0)cout<<(b[n/2]+b[n/2-1] - a[n/2]-a[n/2-1]+1)<<endl;
  else cout<<(b[n/2] - a[n/2]+1)<<endl;

  return 0;
}

Measured memory_bytes: 4740
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int a, b, c;
	string s;
	cin >> s;
	sort(all(s));
	if (s == "abc") puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int a, b, c; cin >> a >> b >> c;
    // if ((a*x-c)/b==0) 
    rep1(i, b) {
        ll amari = a * i % b;
        if (amari == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 256
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum INF = 10L^^18;

int N;
long X;
long[] B, L, U;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      X = readLong();
      B = new long[N];
      L = new long[N];
      U = new long[N];
      foreach (i; 0 .. N) {
        B[i] = readLong();
        L[i] = readLong();
        U[i] = readLong();
      }
      
      auto ps = new Tuple!(long, int)[N];
      foreach (i; 0 .. N) {
        ps[i] = tuple((X - B[i]) * U[i] - (0 - B[i]) * L[i], i);
      }
      ps.sort();
      auto sumL = new long[N + 1];
      foreach (j; 0 .. N) {
        const i = ps[j][1];
        sumL[j + 1] = sumL[j] + (0 - B[i]) * L[i];
      }
      auto sumU = new long[N + 1];
      foreach_reverse (j; 0 .. N) {
        const i = ps[j][1];
        sumU[j] = sumU[j + 1] + (X - B[i]) * U[i];
      }
      debug {
        writeln("ps = ", ps);
        writeln("sumL = ", sumL);
        writeln("sumU = ", sumU);
      }
      
      long lo = -1, hi = X * N;
      for (; lo + 1 < hi; ) {
        const mid = (lo + hi) / 2;
        const q = cast(int)(mid / X);
        const r = mid % X;
        debug {
          writefln("mid = %s: q = %s, r = %s", mid, q, r);
        }
        long maxScore = -INF;
        foreach (j; 0 .. N) {
          const i = ps[j][1];
          long score;
          score += (j < N - 1 - q) ? (sumL[N - 1 - q + 1] - (0 - B[i]) * L[i]) : sumL[N - 1 - q];
          score += (j >= N - q) ? (sumU[N - q - 1] - (X - B[i]) * U[i]) : sumU[N - q];
          score += (r < B[i]) ? ((r - B[i]) * L[i]) : ((r - B[i]) * U[i]);
          debug {
            writefln("  j = %s: score = %s", j, score);
          }
          chmax(maxScore, score);
        }
        (maxScore >= 0) ? (hi = mid) : (lo = mid);
      }
      writeln(hi);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 2*1e5 + 15 ;
vector<int>g[maxn];
int h[maxn];
bool visited[maxn];
int ans = 0 ;



int main()
{

   int n , k ;
   cin >> n >> k ;
   vector<int>a(n+1);
   for(int i = 1 ; i <= n ; i ++ )
   {
     cin >> a[i];
   }
   int index = -1  ,flag = 0;

   for(int i = 1 ; i <= n ; i++ )
   {
     if(a[i] >= 0  )
     {
       index = i ;
       break;
     }
  }

  if( index == -1 )
  {
     cout<<abs(a[n-k+1])<<endl;
  }
  else if(a[1] >= 0 )
  {
      cout<<a[k]<<endl;
  }

  else 
  {
     int ans = 1e9;
     
     for(int i = 1 ; i <= n ; i++ )
     {
        if(a[i] >= 0 )
        {
           index = i ;
           break;
        }
     }
     for(int i = index -1  ; i <= min(i+k-1,n) ; i++ )
     {
           if( i < index )
           {
             if( i - k + 1 >= 1)
             {
                 ans = min(ans,abs(a[i-k+1]));
             }
            
           }
          else 
           {
              int len = i - index + 1 ;

              int index2 = index - (k-len);
              if(index2 >= 1 )
              {
               int p1 = abs(a[index2])*2 + a[i] ;
               int p2 = a[i]*2 + abs(a[index2]);
               ans = min(ans,min(p1,p2));
             }
           }
     }
     cout<<ans<<endl;
  }
  
}


Measured memory_bytes: 5376
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(["EQUAL", "GREATER", "LESS"][(A > B) - (A < B)])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import numpy as np


n, capacity = map(int, input().split())
value_max = 10 ** 5
dp = np.full(value_max + 1, capacity + 1)
dp[0] = 0

for i in range(n):
    w, v = map(int, input().split())
    np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])

print(np.where(dp <= capacity)[0][-1])

Measured memory_bytes: 14016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/


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

    ll ans = (1LL<<60);
    ll sum = 0;
    ll tmp = 0;
    // - + - + ...
    for(int i=0; i<n; i++){
        sum += a[i];
        if(i%2 == 0 && sum >= 0){
            tmp += sum + 1;
            sum = -1;
        }
        else if(i%2 == 1 && sum <= 0){
            tmp += 1 - sum;
            sum = 1;
        }
    }

    ans = min(ans, tmp);

    tmp = 0;
    sum = 0;
    // + - + - + ...
    for(int i=0; i<n; i++){
        sum += a[i];
        if(i%2 == 0 && sum <= 0){
            tmp += 1 - sum;
            sum = 1;
        }
        else if(i%2 == 1 && sum >= 0){
            tmp += 1 + sum;
            sum = -1;
        }
    }

    ans = min(ans, tmp);

    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner sc= new Scanner(System.in);
    int n=sc.nextInt();
    if(1<=n && n<=999){
        System.out.println("ABC");
    }else{
        System.out.println("ABD");
    }
    
  }
}

Measured memory_bytes: 23764
#include<stdio.h>

int main(void)
{

  int n[10000]={};
  int r[10000]={};
  int s=0;
  int l=0;
  int x[1000]={};
  int k=0;
  int i=0;
  int j=0;
  int dmm=0;
  
  while(1){
   scanf("%d  %d/n", &n[s], &r[l]);
   
   if(n[s]==0&&r[l]==0)
     break;

   s++;
   l++;
  }
  
  
  s=0;
  l=0;
  
  while(1){
    for(i=0;i<n[s];i++)
      x[i]=n[s]-i;
    int m=l;
    int s2=s;
    for(k=0;k<r[m];k++){
      l++;
      for(i=0;i<r[l];i++){
	dmm=x[n[s+1]-1+i];
	for(j=n[s+1]+i-1;j>i;j--){
	  x[j]=x[j-1];
	}
	x[i]=dmm;
      }
      s++;
    }
    printf("%d\n",x[0]);

    s++;
    l++;

    if(n[s]==0&&r[l]==0)
      break;

  }

    
      
  return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	lint sum = 0;
	lint min_num = INF64;
	bool flag = true;
	for (int i = 0; i < N; i++)
	{
		lint tmp;
		cin >> tmp;
		if (tmp < 0)
			flag = !flag;

		sum += abs(tmp);
		min_num = min(min_num, abs(tmp));
	}

	if (flag)
		cout << sum << endl;
	else
		cout << sum - min_num * 2 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
   	int n = sc.nextInt();
    int max = 0;
    int sum = 0;
    int stack;
    
    for(int i = 0;i < n;i++){
      	stack = sc.nextInt();
    	sum += stack;
      	if(stack > max) max = stack;
    }
    
    if(sum - max > max)System.out.println("Yes");
    else System.out.println("No");

  }
}


Measured memory_bytes: 35628
#include <iostream>
using namespace std;
typedef long long int ll;
ll gcm(ll a, ll b) {
  if (b > a) swap(a, b);
  ll r = a % b;
  if (r == 0) return b;
  else return gcm(b, r);
}
int main() {
  ll a, b;
  while (cin >> a >> b) {
    ll g = gcm(a, b);
    ll l = a * b / g;
    cout << g << " " << l << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
//int g(int x){
//	x=modpow(x,MOD-2);
//	return x;
//}
int a,b;
signed main(){
	cin>>a>>b;
	cout<<max(0ll,a-b-b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t,k;
	cin>>t>>k;int arr[t];
	for(int i=0;i<t;i++){
		cin>>arr[i];
	}
	int dp[t];
	dp[0] = 0;
	for(int i=1;i<t;i++){
		dp[i] = INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j<0){
				break;
			}
			dp[i] = min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
		//cout<<dp[i]<<" ";
	}
	cout<<dp[t-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main ()
{
    int n ;
    scanf("%d", &n);

    if (n % 2 != 0)
    {
        printf("No\n");
        return 0 ;
    }
 
    char string [256];
    scanf(" %s", string);
 
    int t = strlen(string) / 2 ;
    int flag = 0 ;
 
    for (int i = 0 ; i < t ; i++)
    {
        if (string[i] != string[t + i])
        {
            flag = 1 ;
            break ;
        }
    }
 
    (flag) ? printf("No\n") : printf("Yes\n") ;
    return 0 ;
}

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

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

  ll n,m;
  cin >> n >> m;

  ll ans = 1;
  for(ll i = 1; i*i <= m; i++) {
    if(m % i != 0) continue;
    ll y = (m/i);
    if(n*i <= m) ans = max(ans, i);
    if(n*y <= m) ans = max(ans, y);
  }
  
  cout << ans << endl;
}


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

string sort_down(string s, int len){

    for(int i=0; i<len; i++){
        int min_s = i;
        for(int j=i+1; j<len; j++){
            if(s[min_s] > s[j]){
                min_s = j;
            }
        }
        if(min_s != i){
            char tmp = s[i];
            s[i] = s[min_s];
            s[min_s] = tmp;
        }
    }
    return s;
}

string sort_up(string s, int len){

    for(int i=0; i<len; i++){
        int max_s = i;
        for(int j=i+1; j<len; j++){
            if(s[max_s] < s[j]){
                max_s = j;
            }
        }
        if(max_s != i){
            char tmp = s[i];
            s[i] = s[max_s];
            s[max_s] = tmp;
        }
    }
    return s;
}

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

    int s_len = s.length();
    int t_len = t.length();
    int len = min(s_len, t_len);

    s = sort_down(s, s_len);
    t = sort_up(t, t_len);

    if(s < t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
 vector<vector<char> > mat(100,vector<char>(100,'.'));
  int H = 100;
  int W = 100;
  int A,B;cin>>A>>B;
  for (int i = 0; i < 50; i++)
  {
    for (int j = 0; j < W; j++)
    {
      mat[i][j] = '#';
    }
    
  }
  A--;B--;
  for (int i = 0; i < 50; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if(A <= 0)continue;
      if(j%2 == 0 &&i%2 == 0)
      {
        mat[i][j] = '.';
        A--;
      }
    }
    
  }
  
  for (int i = 50; i < 100; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if(B <= 0)continue;
      if(j%2 == 0 &&i%2 == 1)
      {
        mat[i][j] = '#';
        B--;
      }
    }
    
  }
  cout<<100<<" "<<100<<endl;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cout<<mat[i][j];
    }
    cout<<endl;
    
  }
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////
int n;vector<int> g[210000];
int d[210000], c[210000], ans[210000];
int fac[210000];

int f(int x, int par){
  int ret = fac[c[x]-1];
  for(auto to : g[x]){
    if(to == par)continue;
    ret = ret * modinv(fac[c[to]]) % MOD;
  }
  return ret;
}

int dfs(int x, int par){
  d[x] = 1;c[x] = 1;
  for(auto to : g[x]){
    if(to == par)continue;
    d[x] = (d[x]*dfs(to, x))%MOD;
    c[x] += c[to];
  }
  d[x] = (d[x] * f(x, par)) % MOD;
  return d[x];
}

void dfs2(int x, int par, int dpar){
  int ret = (fac[n-1] * dpar % MOD) * modinv(fac[n-c[x]]) % MOD;
  for(auto to : g[x]){
    if(to == par)continue;
    ret = (ret*d[to]%MOD) * modinv(fac[c[to]]) % MOD;
  }
  ans[x] = ret;
  for(auto to : g[x]){
    if(to == par)continue;
    int dnext = (ret*fac[c[to]]%MOD) * modinv(d[to]) % MOD;
    dnext = dnext * fac[n-1-c[to]] % MOD;
    dnext = dnext * modinv(fac[n-1]) % MOD;
    dfs2(to, x, dnext);
  }
}

signed main(){
  cin>>n;
  rep(i,n-1){
    int xx, yy;cin>>xx>>yy;xx--;yy--;
    g[xx].push_back(yy);
    g[yy].push_back(xx);
  }
  fac[0] = fac[1] = 1;
  repd(i,2,210000)fac[i] = (fac[i-1] * i) % MOD;
  dfs(0, -1);
  dfs2(0,-1, 1);
  rep(i,n){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 21488
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int main() {
    int n, x;
    cin >> n >> x;
    int ans = 0;
    rep(i, n) {
        int m;
        cin >> m;
        ans = gcd(ans, abs(m - x));
    }   

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

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

const double PI=acos(-1.0);

int N; ll K; vi A;
void input()
{
    cin>>N>>K;
    A.resize(N+1);
    for(int i=0;i<N;++i) cin>>A[i+1];
}

void solve()
{
    map<int,int> M;
    int i=1; M[i]++; int loop; int cnt=0;
    while(1){
        ++cnt;
        if(M[A[i]]>0){
            loop=A[i]; break;
        }
        M[A[i]]++; i=A[i];
        if(cnt==K){
            cout<<i<<endl; return;
        }
    }
    // cout<<loop<<endl;
    i=1; int left;
    while(1){
        if(i==loop){
            left=i; break;
        }
        i=A[i];
    }
    vi vloop;
    vloop.emplace_back(left);
    i=A[left];
    while(1){
        if(i==loop) break;
        vloop.emplace_back(i);
        i=A[i];
    }
    int loop_size=vloop.size();
    cout<<vloop[(K-cnt)%loop_size]<<endl;
}

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

Measured memory_bytes: 12524