akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int N , K , L , mx; string S , T; char mn = 127;

string work(int pos){
	pos = 2 * N - pos - 1;
	int len = L; for(int i = 1 ; i < K ; ++i) len <<= 1;
	return string(len , mn) + string(T , pos + mx , N - len);
}

int main(){
	cin >> N >> K >> S; T = S;
	reverse(T.begin() , T.end()); T = S = S + T;
	reverse(T.begin() , T.end());
	for(int i = 0 ; i < (int)S.size() ; ++i) mn = min(mn , S[i]);
	for(int i = 0 ; i < (int)S.size() ; ++i) mx = max(mx , L = S[i] == mn ? L + 1 : 0);
	L = mx;
	for(int i = 1 ; i < K && L < N ; ++i) L <<= 1;
	if(L >= N){cout << string(N , mn); return 0;}
	string ans; L = 0;
	for(int i = 0 ; i < (int)S.size() ; ++i){
		L = S[i] == mn ? L + 1 : 0;
		if(i >= N && L == mx){string T = work(i); if(ans.empty() || ans > T) ans = T;}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
P=list(map(lambda x:int(x)-1,input().split()))
C=list(map(int,input().split()))

if K<=N:
  ans = -10**9
  for i in range(N):
    now,last = i,0
    for _ in range(K):
      last += C[P[now]]
      ans = max(ans,last)
      now=P[now]
  print(ans)
  exit()
ans = -10**9
for i in range(N):
  tmp,now,done = [0],i,set()
  for _ in range(N+1):
  #while now not in done:
    tmp.append(tmp[-1]+C[P[now]])
    if P[now] == i:
      break
    now = P[now]
  tmp = tmp[1:]
  cnt = len(tmp)
  m = max(tmp)
  ans = max(ans,m,tmp[-1]*(K//cnt-1)+m)
  if K%cnt != 0:
    ans = max(ans, tmp[-1]*(K//cnt)+max(tmp[:K%cnt]))
    #print(i,ans,tmp)
print(ans)




Measured memory_bytes: 82588
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
	
	int a, b, c, d;
	bool is = true;
	cin >> a >> b >> c >> d;
	while (a > 0 and c > 0) {
		if (is)
			c -= b;
		else
			a -= d;
		is = !is;
	}
	if (a <= 0)
		cout << "No\n";
	else
		cout << "Yes\n";
	return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vector<pll> P(N);
    REP(i,0,N) {
        ll a;
        cin >> a;
        P[i] = {a, i+1};
    }
    
    ASC(P);
    FORR(p,P) PS(p.second);
    PR("");
    
    return 0;
}

/*



*/

Measured memory_bytes: 4776
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    
    cin >>a>>b;
    if(a==1) a+=13;
    if(b==1) b+=13;
     
    if(a==b){
        cout <<"Draw";
    }    
    else if(a>b){
        cout <<"Alice";
    }                
    else{
        cout <<"Bob";
    }
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n%2==1) {
    cout << "No" << endl;
  return 0;}
  string a=s.substr(0,n/2);
  string b=s.substr(n/2);
  if(a==b) {
    cout << "Yes" << endl;}
  else {
    cout << "No" << endl;}
  return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    char a,b; cin>>a>>b;
    cout<<(a==b?"H":"D")<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b))cout << 'A';
	else cout << 'B';
}

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

using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
int sub(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);

const int N=500001;
int fa[N];
vi adj[N];
int sz[N];
int get(int x){
	if(fa[x]==x)return x;
	return fa[x]=get(fa[x]);
}

void merge(int x,int y){
	x=get(x),y=get(y);
	if(sz[y]>sz[x])swap(x,y);
	sz[x]+=sz[y];
	fa[y]=x;
}
vector<pi>ans;
int cnt[N];
void dfs(int u,int p){
	for(auto i:adj[u]){
		if(i!=p)
		dfs(i,u);
	}
	if(cnt[u]&1){
		if(p==-1)return;
		ans.pb(mp(u,p));
		cnt[u]++;
	}
	else{
		if(p==-1)return;
		ans.pb(mp(p,u));
		cnt[p]++;
	}
}
void solve(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)fa[i]=i,sz[i]=1;
	
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		if(get(x)==get(y)){
			ans.pb(mp(x,y));
			cnt[x]++;
		}
		else{
			merge(x,y);
			adj[x].pb(y);
			adj[y].pb(x);
		}

	}
	if(m&1){
		cout<<"-1";
		return;
	}
	dfs(0,-1);
	for(auto i:ans)cout<<i.F+1<<' '<<i.S+1<<"\n";
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//cin>>tc;
	for(int _=0;_<tc;_++){
		//cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}

int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}

int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}

int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 25588
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
vector<int> v[111111];
int d[111111],c[111111],D;
    
P visit(int p,int x,int z) {
  d[x]=z;
  P r(0,x);
  for(int i=0; i<v[x].size(); i++) {
    int y=v[x][i];
    if(y==p) continue;
    P t=visit(x,y,z+1);
    t.first++;
    if(r.first<t.first) r=t;
  }
  return r;
}
int diameter() {
  P r=visit(-1, 1,0);
  P t=visit(-1,r.second,0);
  D=t.first;
  return t.second;
}

int main() {
  int n;
  cin >> n;
  for(int i=0,x,y; i<n-1; i++) {
    cin >> x >> y;
    x--,y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int x=diameter();
  queue<int> que;
  que.push(x);
  c[x]=(n-1)*2-D;
  while(!que.empty()) {
    x=que.front();que.pop();
    for(int i=0; i<v[x].size(); i++) {
      int y=v[x][i];
      if(c[y]) continue;
      if(d[x]>d[y]&&D/2<=d[y]) c[y]=c[x]+(D%2&&D/2==d[y]?0:1);
      else c[y]=c[x]-1;
      que.push(y);
    }
  }
  for(int i=0; i<n; i++) cout << c[i] << endl;
  return 0;
}


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

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

inline void Main() {
  // code
  int n;
  cin >> n;

  rep(i, 9) {
    if(n % (i+1) == 0) {
      int j = n / (i+1);
      if(0 <= j && j <= 9) {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

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

	vector<ll> aa(n,-1);
	rep(i,m){
		ll s,c;
		cin >> s >> c;
		--s;
		if(aa[s] == -1) aa[s] = c;
		else{
			if(aa[s] != c){
				cout << -1 << endl;
				return;
			}
		}
	}

	if(n > 1 && aa[0] == 0){
		cout << -1 << endl;
		return;
	}

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

	ll res = 0;
	rep(i,n){
		if(aa[i] == -1){
			if(i > 0) aa[i] = 0;
			else aa[i] = 1;
		}
		res += aa[i] * pow(10,n-1-i);
	}

	cout << res << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;
#define pb push_back


//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())


//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key  
//   itr->second = value
//}


// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());


// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());


// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()


// stack <int> s; 


// queue <int> gquiz; 


// __gcd(m, n) 

// ll arr[10e5 + 5];


// char arr[10e5 + 5];


// printf ("%.9f\n",x);
// cout << fixed << setprecision(9);



bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}

int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // ll n;
    // cin >> n;
    string str1,str2;
    cin >> str1 >> str2;
    ll c = 0;
    for(ll i = 0; i<str1.size(); i++)
    {
        if(str1[i] != str2[i])
        {
            ++c;
        }
    }
    cout << c << endl;
    return 0;
}   

Measured memory_bytes: 3824
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod = 1e9 + 7;
using namespace std;
void add(int& a , int b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
int solve (string s){
	int n = s.length() ;
	if(n == 1) return cout << 1  << endl , 0 ;
	vector<string> v ;
	int fin = n - 2 ;
	int nb = 1 ;
	while(fin >= 0 && s[fin] == s[n - 1]) {fin-- ; nb++ ;}
	bool b = false ;
	for(int i = 0 ; i <=fin ; i++){
		string t = "" ; t += s[i] ;
		if(!v.size()) v.push_back(t) ;
		else{
			if(v[v.size() - 1] == t && i < fin){t += s[i + 1] ; i++ ; v.pb(t) ;}
			else if(t != v[v.size() - 1]) v.pb(t) ;
			else b = true ;
		}
	}
	nb -= b ;
	vi verif1 ;
	int tmp = nb ;
	while(tmp){
		if(!verif1.size()) {verif1.pb(1) ; tmp-- ;}
		else if(verif1[verif1.size() - 1] == 1 && tmp >= 2){
			verif1.pb(2) ;
			tmp -= 2 ;
		}
		else{
			verif1.pb(1) ;
			tmp-- ;
		}
	}
	int res  = - 1 ;
	if(verif1.size() <= 1 || verif1[verif1.size() - 1] != verif1[verif1.size() - 2]) res = verif1.size() ;
	if(res == -1){
		tmp = nb ;
		verif1.clear() ;
		while(tmp){
			if(!verif1.size() && tmp >= 2) {verif1.pb(2) ; tmp -= 2 ;}
			else if(verif1[verif1.size() - 1] == 1 && tmp >= 2){
				verif1.pb(2) ;
				tmp -= 2 ;
			}
			else{
				verif1.pb(1) ;
				tmp-- ;
			}
		}
		res = verif1.size() ;
	}
	return  res + v.size() + b ; 
}
int main(){
	IOS;
	string s ; cin >> s ;
	int ans1 = solve(s) ;
	cout << ans1   << endl ;	
	
	
	return 0;
}


Measured memory_bytes: 11144
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {

    // 標準入力からデータを読み込む準備
    Scanner sc = new Scanner(System.in);

    // 2つの文字の固まりを整数値と想定して読み込む
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(a<b){
	System.out.println("a < b");
    }else if(a==b){
	System.out.println("a == b");
    }else{
	System.out.println("a > b");
    }

    
    sc.close();
} 
}


Measured memory_bytes: 26264
#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 END cout<<endl;
#else
#define DEB(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 MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
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;
	int N=S.size();
	int ans=N*(N-1)/2+1;
	char C='a';
	REP(i,26){
		int cnt=0;
		REP(j,N){
			if(S[j]==C){
				cnt++;
			}
		}
		if(cnt>=2){
			ans-=cnt*(cnt-1)/2;
		}
		C++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        while(true){
        	String tmp=scan.nextLine();
        	if(tmp.equals("."))break;
        	char [] line =tmp.toCharArray();
        	Stack <Character> scale =new Stack<Character>();
        	String ans="yes";
        	for(int i=0;i<line.length;i++){
        		switch(line[i]){
        		case '(' :
        			scale.push(line[i]);
        			break;
        		case '[' :
        			scale.push(line[i]);
        			break;
        		case ')' :
        			if(!scale.empty() && scale.pop()=='(');
        			else {
        				i=line.length;
        				ans = "no";
        			}
        			break;
        		case ']' :
        			if(!scale.empty() && scale.pop()=='[');
        			else {
        				i=line.length;
        				ans = "no";
        			}
        			break;
        		}
        	}
        	if(!scale.empty())ans="no";

        	System.out.println(ans);
        }
    }
}
        	

Measured memory_bytes: 12000
import java.util.Scanner;	//Scannerクラス：Java標準入力を取得する

class Main{	//長方形の面積と周の長さ
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {	//try(Scanner sc = new Scanner(Sytem.in)){で標準入力が使える
        	int a = sc.nextInt();			//縦	int a = sc.nextInt();
            int b = sc.nextInt();			//横	int a = sc.nextInt();
            System.out.println(String.format("%d %d", a * b, 2 * (a + b)));	//面積と周の長さを表示
        }
    }
}



Measured memory_bytes: 26224
n, m, r = map(int, input().split())
v = list(map(int, input().split()))

inf = 10 ** 18
d = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

import itertools
ans = 10 ** 18
for a in itertools.permutations(v):
    dis = 0
    for i in range(r-1):
        dis += d[a[i+1]-1][a[i]-1]
    ans = min(ans, dis)
print(ans)

Measured memory_bytes: 46936
import Data.Functor( (<$>))

main = do
    ls <- takeWhile ("-1 -1 -1"/=) . lines <$> getContents
    let
	records = (read <$>) <$> words <$> ls

	eval [m,f,r]
	    | m == -1 || f == -1    = 'F'
	    |	80 <= m+f	    = 'A'
	    |	65 <= m+f	    = 'B'
	    |	50 <= m+f	    = 'C'
	    |	30 <= m+f	    = if 50<=r then 'C' else 'D'
	    |	otherwise	    = 'F'

	putCharLn rec = putStrLn [eval rec]

    putCharLn `mapM_` records
    



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int a, b;
    cin >> a >> b;

    int ans = (b - a) * (b - a + 1) / 2 - b;
    cout << ans << endl;

    return 0;
}


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

using namespace std;
long div(int n){
    long ret = 1;
    for(int a = 2; a * a <= n; ++a){
        if(n % a != 0){
            continue;
        }
        long tmp = 0;
        while(n % a == 0){
            ++tmp;
            n = n / a;
        }
        // cout << "tmp = " << tmp << endl;
        ret *= long(tmp + 1);
    }
    if(n != 1){
        ret *= 2;
    }
    return ret;

}
int main(void) {
    int n;
    cin >> n;
    long ans = 0;
    for(int i = 1; i < n; i++){
        ans += div(i);
        // cout << "ans = " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    rep(i, 0, 2) rep(j, 0, N) {
        cin >> A[i][j];
    }
    vector<vector<int>> dp(2, vector<int>(N, 0));
    dp[0][0] = A[0][0];
    dp[1][0] = A[1][0] + A[0][0];
    rep(i, 1, N) rep(j, 0, 2) {
        chmax(dp[j][i], dp[j][i - 1] + A[j][i]);
        if (j) {
            chmax(dp[j][i], dp[j - 1][i] + A[j][i]);
        }
    }
    cout << dp[1][N - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y, y+n);
    int ans1 = y[n / 2 - 1], ans2 = y[n / 2];
    for (int i = 0, t = y[n / 2]; i < n; i++) {
        if (x[i] < t) cout << ans2 << '\n';
        else cout << ans1 << '\n';
    }
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=25000+10,maxk=400+10,mod=1e9+7;
int n,k,m,a[maxn],sum[maxk][2],g[maxn][maxk][2];
bool vis[maxn];
inline void add(int &x,int y){
	x+=y;
	x=(x>=mod?x-mod:x);
}
inline int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return res;
}
void getf(int dp[maxn][maxk][2],int Sx,int Sy,int ty=0){
	dp[0][Sx][Sy]=1;
	DREP(j,k,1) sum[j][0]=(sum[j+1][0]+dp[0][j][0])%mod,sum[j][1]=(sum[j+1][1]+dp[0][j][1])%mod;
	REP(i,1,n){
		REP(j,1,k) REP(l,0,1){
			if(j==k && l==0) continue;
			if(j){
				add(dp[i][j][l],(ll)dp[i-1][j-1][l]*(k-j+1)%mod);
				if(j==k) add(dp[i][j][l],dp[i-1][j-1][0]);
			}
			add(dp[i][j][l],sum[j][l]);
		}
		DREP(j,k,1) sum[j][0]=(sum[j+1][0]+dp[i][j][0])%mod,sum[j][1]=(sum[j+1][1]+dp[i][j][1])%mod;
	}
	if(ty){
		DREP(j,k,1) sum[j][0]=(sum[j+1][0]+g[0][j][0])%mod,sum[j][1]=(sum[j+1][1]+g[0][j][1])%mod;
		REP(i,1,n){
			REP(j,1,k) REP(l,0,1){
				if(j==k && l==0) continue;
				if(j){
					add(g[i][j][l],(ll)g[i-1][j-1][l]*(k-j+1)%mod);
					if(j==k) add(g[i][j][l],g[i-1][j-1][0]);
				}
				add(g[i][j][l],sum[j][l]);
				if(j>=m) add(g[i][j][l],dp[i][j][l]);
			}
			DREP(j,k,1) sum[j][0]=(sum[j+1][0]+g[i][j][0])%mod,sum[j][1]=(sum[j+1][1]+g[i][j][1])%mod;
		}
	}
}
int dp[maxn][maxk][2],f[maxn][maxk][2],ans;
int main(){
	n=read(),k=read(),m=read();
	REP(i,1,m) a[i]=read();
	bool flag=1;
	REP(i,1,m){
		if(vis[a[i]]){
			flag=0;
			break;
		}
		vis[a[i]]=1;
	}
	memset(vis,0,sizeof(vis));
	if(flag){
		getf(dp,0,0,1);
		REP(i,0,k) add(ans,g[n][i][1]);
		int Fac=1;
		DREP(i,k,k-m+1) Fac=(ll)Fac*i%mod;
		ans=(ll)ans*ksm(Fac,mod-2)%mod;
		printf("%d\n",ans);
		return 0;
	}
	REP(i,1,m-k+1){
		bool b=1;
		REP(j,1,k){
			if(vis[a[i+j-1]]){b=0;break;}
			vis[a[i+j-1]]=1;
		}
		REP(j,1,k) vis[j]=0;
		if(b){flag=1;break;};
	}
	int pos;
	for(pos=1;!vis[a[pos]];++pos) vis[a[pos]]=1;
	REP(j,1,k) vis[j]=0;
	--pos;
	getf(dp,pos,pos==k);
	for(pos=1;!vis[a[m-pos+1]];++pos) vis[a[m-pos+1]]=1;
	--pos;
	getf(f,pos,pos==k);
	REP(i,1,n-m+1){
		int res1=0,res2=0;
		REP(j,0,k) add(res1,dp[i-1][j][0]),add(res1,dp[i-1][j][1]);
		REP(j,0,k) add(res2,f[n-i-m+1][j][0]),add(res2,f[n-i-m+1][j][1]);
		ans=(ans+(ll)res1*res2)%mod;
		if(!flag){
			res1=res2=0;
			REP(j,0,k) add(res1,dp[i-1][j][0]);
			REP(j,0,k) add(res2,f[n-i-m+1][j][0]);
			add(ans,mod-(ll)res1*res2%mod);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 162176
import math

def resolve():
    M,D=map(int,input().split())

    cnt=0
    for m in range(1,M+1):
        for d in range(1,D+1):
            if(d//10 < 2 or d%10 <2):
                continue
            if((d%10) * (d//10) == m):
                cnt+=1

    print(cnt)


resolve()

Measured memory_bytes: 9116
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for(int i = 0; cin >> ch;i++){
    if(ch == '\\') S1.push(i);
    else if(ch == '/' && S1.size() > 0){
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while(S2.size() > 0 && S2.top().first > j){
	a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }

  vector<int> ans;
  int t = 0;
  while(S2.size() > 0) { ans.push_back(S2.top().second); S2.pop();}
  reverse(ans.begin(),ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i = 0;i < ans.size();i++){
    cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	cin>>n;
	map<int,int> mymap;
	for(int i=1;i<=n;i++){
		cin>>x;
		mymap[x]++;
	}
	long long ans=0;
	map<int,int>:: iterator iter;
	for(iter=mymap.begin();iter!=mymap.end();iter++){
		if(iter->second<iter->first){
			ans+=iter->second;
		}else{
			ans+=iter->second-iter->first;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;

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

    int n;
    cin>>n;
    int A[n], B[n], C[n];
    for (int i=0;i<n;++i) cin>>A[i]>>B[i]>>C[i];

    int dp[n+1][3];
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for (int i=1;i<=n;++i){
        for (int last=0;last<=2;++last){
            dp[i][last] = 0;
            if (last != 0)
                dp[i][last] = max(dp[i][last], dp[i-1][0] + A[i-1]);
            if (last != 1)
                dp[i][last] = max(dp[i][last], dp[i-1][1] + B[i-1]);
            if (last != 2)
                dp[i][last] = max(dp[i][last], dp[i-1][2] + C[i-1]); 
        }
    }
    cout<<max(dp[n][0], max(dp[n][1], dp[n][2]))<<endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
    using namespace std;
    int main(){
    	int a,b,c;
    	cin >> a >> b >> c;
    	
    	int sum;
    	sum = a+b+c;
    	
    	if(sum >= 22){
    		cout << "bust";
    	}else{
    		cout << "win";
    	}
     
    }

Measured memory_bytes: 256
n = int(input())
for i in range(n):
  a = list(map(int,input().split()))
  b = 0
  c = 0
  x = 0
  for j in range(10):
    if b < a[j]:
      b = a[j]
    elif c < a[j]:
      c = a[j]
    else:
      x += 1
  if x == 0:
    print("YES")
  else:
    print("NO")


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {
    /**
     * ABC/ARC
     * @param 1 ≦ x ≦ 3,000
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            int x = sc.nextInt();
            if (x < 1200) {
                System.out.println("ABC");
            } else {
                System.out.println("ARC");
            }
        }
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long total = 0;
  vector<int> a(n);
  vector<long long> num(n);
  rep(i,n){
    cin >> a[i];
    total += a[i];
    num[i] = total;
  }
  long long ans = abs(total - num[0]*2);
  for(int i = 1; i < n -1; i++){
    ans = min(ans, abs(total - num[i]*2));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, A, B] = string_to_int(inputs[0])

    train = N * A
    taxi = B

    return min(train, taxi)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
    set<string>s;
    int n;cin>>n;
    while(n--){
    	string t;
    	cin>>t;
    	s.insert(t);
    }
    cout<<sz(s);
}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 19248
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  double ans;
  if (n%2==0) std::cout << 1.0/2.0 << '\n';
  else std::cout << (n/2+1.0)/n << '\n';
}


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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define endl '\n'
#define mod 1000000007

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

int main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	int n;
	cin >> n;
	string a,b,c;
	cin >> a >> b >> c;
	int ans = 0;
	forn(i,n){
		set<char> st;
		st.insert(a[i]);st.insert(b[i]);
		st.insert(c[i]);
		ans += st.size()-1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline
read = sys.stdin.read


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


def main():
    np.set_printoptions(threshold=20)
    N = int(input())
    AB = np.array(read().split(), dtype=np.int)
    A = AB[0::2]
    B = AB[1::2]
    A.sort()
    B.sort()
    if N % 2 == 1:
        n = N // 2
        print(B[n] - A[n] + 1)
    else:
        n = N // 2
        print((B[n] + B[n - 1]) - (A[n] + A[n - 1]) + 1)



if __name__ == '__main__':
    main()


Measured memory_bytes: 77368
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main(void){
  string s;
  cin >> s;
  int ans = s.size();

  for(int i=0;i<2;i++){
    int cnt = 0;
    for(int j=0;j<s.size();j++){
      if(j%2 == 0 && s[j] != (char)(i + '0')) cnt++; //奇数
      if(j%2 == 1 && s[j] == (char)(i + '0')) cnt++; //偶数
    }
    ans = min(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    string type(2 * N, '.');
    vi val(2 * N);

    vi bloc(N), wloc(N);
    vvi blab(2 * N + 1, vi(N + 1));
    vvi whab(2 * N + 1, vi(N + 1));

    for (int i = 0; i < 2 * N; i++) {
        cin >> type[i] >> val[i];
        --val[i];
        if (type[i] == 'B') {
            bloc[val[i]] = i;
            for (int v = val[i]; v >= 0; v--)
                blab[i][v] = 1;
        }
        else {
            wloc[val[i]] = i;
            for (int v = val[i]; v >= 0; v--)
                whab[i][v] = 1;
        }

        if (i) for (int v = 0; v < N; v++) {
            blab[i][v] += blab[i-1][v];
            whab[i][v] += whab[i-1][v];
        }
    }

    vvi dp(N + 1, vi(N + 1, INT_MAX));
    dp[0][0] = 0;

    auto smin = [](int& a, int b) { a = min(a, b); };
    for (int b = 0; b <= N; b++) {
        for (int w = 0; w <= N; w++) {
            if (b < N) {
                int uc = dp[b][w];
                uc += blab[bloc[b]][b] + whab[bloc[b]][w] - 1;
                smin(dp[b+1][w], uc);
            }
            if (w < N) {
                int uc = dp[b][w];
                uc += blab[wloc[w]][b] + whab[wloc[w]][w] - 1;
                smin(dp[b][w+1], uc);
            }
        }
    }

    cout << dp[N][N] << endl;

    return 0;
}



Measured memory_bytes: 78848
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

//#define MOD 1000000007LL
#define MOD 998244353LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w; cin >> h >> w;
	int ans = 0;
	if (h == 1 || w == 1) {
		ans = 1;
	}
	else {
		ans = h * w / 2;
		if (h % 2 == 1 && w % 2 == 1) ans++;
	}
	cout << ans << endl;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    //1年は195日 or 200日 999年で195*666 + 200*333
    int zenbu = 195*666 + 200*333;
    int N; cin >> N;
    vector<int> ans(N);
    rep(i, N){
        int y, m, d; cin >> y >> m >> d;
        int res = (y-1)*195 + ((y-1)/3)*5;
        //x年だったらx-1年経ってる (x-1)*195 + ((x-1)/3)*5日でx年1月1日
        for(int j = 1; j < m; j++){
            if(j % 2 == 0 && y % 3 != 0){
                res += 19;
            }
            else res += 20;
        }
        res += d-1;
        ans[i] = zenbu - res;
    }
    rep(i, N) cout << ans[i] << endl;
    return 0;
}


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

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a, i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = 0; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

//* main */
int i, j, k;

int main() {
	int n, t, a[10000], r;
	scanf("%d%d", &n, &t);
	REP(i, t)scanf("%d", &a[i]);
	qsort(a, t, sizeof(int), cmp2);
	r = 2 * a[0] - n - 1;
	printf("%d", r < 0 ? 0 : r);
	return 0;
}

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

using namespace std;

using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

const i64 INF = 1e18;
const i64 M = 1e9 + 7;
const int MXB = 20;
using bin = bitset<MXB + 1>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());

    int n, m;
    while (read(n, m)) {
        ivec cc(n, 1);
        ivec col(n);
        col[0] = 1;
        forn(i, m) {
            int u, v;
            read(u, v);
            u--; v--;

            col[v] |= col[u];
            cc[u]--;
            cc[v]++;
            if (cc[u] == 0) {
                col[u] = 0;
            }
        }

        int ans = 0;
        forn(i, n) {
            ans += col[i];
        }
        cout << ans << endl;
    }
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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 modpow(ll a, ll n, ll mod) {
  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(false);

  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);

  int a, b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

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

  return 0;
}


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


int main(){
  int n, k;
  cin >> n >> k;
  vector<int>vec(n);
  for (int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int p = n - k + 1;
  vector<int>height(p);
  for (int j = 0; j < p; j++){
    height.at(j) = vec.at(j) - vec.at(j + k-1);
  }
  sort(height.begin(), height.end());
  cout << height.at(0) << endl;
}

   
    
      
    


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1e6 + 5;

int mp[N];
vector<int> sieve(N, 0);
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, mx = 0; cin >> n;
    int a[n];
    for(auto &i: a){
            cin >> i, mp[i]++;
            if(i != 1) mx = max(mx, mp[i]);
    }

    if(!mx) return cout << "pairwise coprime", 0;

    int g = 0, p = 1;

    for(ll i = 2; i < N && p; i++){
        if(!sieve[i]){
            ll k = i, c = 0;
            while(k < N){
                sieve[k] = 1;
                c += mp[k];
                if(c > 1){
                    p = 0;
                    goto EmergencyGate;
                }
                k += i;
            }
        }
    }

    EmergencyGate:;

    if(p) return cout << "pairwise coprime", 0;

    for(int i = 0; i < n; i++) g = __gcd(g, a[i]);
    if(g == 1) return cout << "setwise coprime", 0;

    cout << "not coprime";
    return 0;
}

Measured memory_bytes: 14732
n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

flag = [False] * n
flag[0] = True
ans = 0

def dfs(x):
    global ans
    if all(flag):
        ans += 1
    for j in edge[x]:
        if not flag[j]:
            flag[j] = True
            dfs(j)
            flag[j] = False

dfs(0)
print(ans)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;
using ll = long long;

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

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

  t.pop_back();
  if (s == t) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }

  return 0;
}


Measured memory_bytes: 3632
main(n,i,d,r){for(;scanf("%d",&n)*n;printf("%d\n",r)){int h[50][32]={0};long long m[50],a=0,b;for(i=n;i--;m[i]=1LL<<i)for(scanf("%d",&r);r--;h[i][d]=1)scanf("%d",&d);for(r=d=-1;!~r&&++d<32;a=b)for(b=0,i=n;i--;b|=m[i]*h[i][d+1])r=(m[i]|=a*h[i][d])-(1LL<<n)+1?r:d;}}

Measured memory_bytes: 416
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main()
{
    int n;
    cin >> n;
    list<int> b;
    rep(i,n){
        int a;
        cin >> a;
        if(i%2==0) b.push_back(a);
        else b.push_front(a);
    }
    if(n%2 == 1) reverse(all(b));
    for(auto i : b) cout << i << " ";
    cout << endl;
}


Measured memory_bytes: 8448
n,m=map(int,input().split())
x=list(map(int,input().split()))
d=sorted(x)
d2=[]
ans=0
if m>1 and n<=m:
  for i in range(m-1):
    d2.append([d[i+1]-d[i],i])
  d2.sort(reverse=True)
  z=d[0]
  for i in range(n):
    if i!=n-1:
      ans+=d[d2[i][1]]-z
      z=d[d2[i][1]+1]
    else:
      ans+=d[m-1]-z
      
  print(ans)
else:
  print(0)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, string>> items(M);
    rep(i, M) cin >> items[i].first >> items[i].second;
    ll ac = 0;
    ll wa = 0;
    set<ll> ok;
    map<ll, ll> cnt;
    rep(i, M) {
        ll p = items[i].first;
        string s = items[i].second;
        if (ok.find(p) == ok.end()) {
            if (s == "AC") {
                ac ++;
                ok.insert(p);
            }else{
                cnt[p]++;
            }
        }
    }
    for (ll o : ok) {
        wa += cnt[o];
    }
    cout << ac << " " << wa << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 17408
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int I;

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}


int main(){
    long long int n,m=0;
    cin>>n;

    while(n>0){
        n/=2;
        m+=1;
    }    
    m=pow(2,m)-1;
    cout<<m<<endl;


    return 0;
} //カモンAC

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const double PI=3.1415926;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	int n;

	cin>>n;

	printf("%.2lf",2*(double(n))*PI);

	return 0;

}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int ncr_arr[55][55] = {};

int get_ncr(int n, int r);

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

    int ans = n - (k - 1);
    cout << ans << endl;
    return 0;
}

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

int main()
{
    string O, E;
    cin >> O >> E;
    for (int i = 0; i < E.size(); i++)
    {
        cout << O[i] << E[i];
    }
    if (E.size() < O.size())
    {
        cout << O[O.size()-1];
    }
    cout << endl;
}

Measured memory_bytes: 256
total = int(input())
cs = (100, 101, 102, 103, 104, 105)
dp = [int(i % cs[0] == 0) for i in range(total + 1)]
for c in cs[1:]:
  for i in range(c, total + 1): 
    dp[i] += dp[i - c]
if(dp[-1] == 0): print(0)
else: print(1)

Measured memory_bytes: 7448