akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
 
int main(){
  string w;
  cin>>w;
  map<char, int> m;
  rep(i,w.length()) m[w[i]]++;
  for(auto x:m){
    if(x.second%2!=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}   

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
// ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//



int main() {
    ll r,d,x; cin >> r>>d>>x;
    rep(i,10){
        x = x*r - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) print((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}



string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}

int legal(string s,string t,int k){
  int n=s.size();
  repa(i,k,n){
    if(s[i]!=t[i-k]) return 0;
  }
  return 1;
}

string merge(string s,string t,int k){
  int n=s.size();
  string ret;
  rep(i,k) ret.push_back(s[i]);
  rep(i,n) ret.push_back(t[i]);
  return ret;
}


int main(){
  int n; cin>> n;
  vector<li> a(n); rep(i,n) cin >>a[i];
  li s=0,ans=0;
  rep(i,n) (s+=a[i])%=MOD;
  rep(i,n){
    (s-=a[i])%=MOD;
    (ans+=s*a[i]%MOD)%=MOD;
  }
  print((ans%MOD+MOD)%MOD);
}





Measured memory_bytes: 4840
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int ans=0;
		for(int i=0;i<N;i++) {
			int h=sc.nextInt();
			while(h%2==0) {
				h/=2;
				ans++;
			}
		}
		p(ans);
		//System.out.println(cc);
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 36192
#include<bits/stdc++.h>
#define int long long
#define N 4000005
#define MOD 1000000007
using namespace std;
int n,k,f[2005][2005],inv[N],fac[N],infac[N];
int C(int x,int y){
	return x>=y ? fac[x]*infac[y]%MOD*infac[x-y]%MOD : 0;
}
signed main(){
	cin>>n>>k;
	if(k==1){
		cout<<1<<endl;
		return 0;
	}
	fac[0]=infac[0]=inv[1]=1;//first deal
	for(int i=1;i<=n*k;i++)
		fac[i]=fac[i-1]*i%MOD;
	for(int i=2;i<=n*k;i++)
		inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
	for(int i=1;i<=n*k;i++)
		infac[i]=infac[i-1]%MOD*inv[i]%MOD;
	for(int i=1;i<=n;i++)
		f[i][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
//			cout<<i<<" "<<j<<"*"<<"%"<<C(k-2,(n-i)+(n-j+1)*(k-1)-1)<<endl;
			f[i][j]=(f[i-1][j]+C((n-i)+(n-j+1)*(k-1)-1,k-2)*f[i][j-1]%MOD*(n-j+1)%MOD)%MOD;
//			cout<<f[1][1]<<endl;
		}
	}
	cout<<f[n][n];
	return 0;
}

Measured memory_bytes: 119912
#include "bits/stdc++.h"
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> num(N);
  for(int i = 0; i < N; i++){
    cin >> num.at(i);
  }

  int max = 0;
  int min = 1000000000;
  for(int i = 0; i < N;i++){
    if(num[i] > max){
      max = num[i];
    }
    if(num[i] < min){
      min = num[i];
    }
  }
  cout << abs(max - min) << endl;
}

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

using namespace std ;

struct ST
{
	int tx ,ty ;
	int kx ,ky ;
	int cnt ;
	ST( int a ,int s ,int d ,int f ,int g ) : tx( a ) ,ty( s ) ,kx( d ) ,ky( f ) ,cnt( g ){}
} ;

int mx[ 4 ] = { 1 ,0 ,0 ,-1 } ;
int my[ 4 ] = { 0 ,1 ,-1 ,0 } ;
int map[ 50 ][ 50 ] ;

int w ,h ;
int tx ,kx ;
int ty ,ky ;

void ans()
{
	queue< ST > que ;
	bool came[ 50 ][ 50 ][ 50 ][ 50 ] = { false } ;
	que.push( ST( tx - 1 ,ty - 1 ,kx - 1 ,ky - 1 ,0 ) ) ;
	came[ tx - 1 ][ ty - 1 ][ kx - 1 ][ ky - 1 ] = true ;
	while( ! que.empty() )
	{
		ST st = que.front() ;
		if( st.tx == st.kx && st.ty == st.ky )
		{
			cout << st.cnt << endl ;
			return ;
		}
		else if( st.cnt >= 100 )
		{
			break ;
		}
		que.pop() ;
		for( int i = 0 ; i < 4 ; i++ )
		{
			int j = 3 - i ;
			tx = st.tx + mx[ i ] ;
			kx = st.kx + mx[ j ] ;
			ty = st.ty + my[ i ] ;
			ky = st.ky + my[ j ] ;
			if( tx < 0 || tx >= w || ty < 0 || ty >= h || map[ ty ][ tx ] == 1 )
			{
				tx = st.tx ;
				ty = st.ty ;
			}
			if( kx < 0 || kx >= w || ky < 0 || ky >= h || map[ ky ][ kx ] == 1 )
			{
				kx = st.kx ;
				ky = st.ky ;
			}
			if( came[ tx ][ ty ][ kx ][ ky ] == false )
			{
				que.push( ST( tx ,ty ,kx ,ky ,st.cnt + 1 ) ) ;
				came[ tx ][ ty ][ kx ][ ky ] = true ;
			}
		}
	}
	cout << "NA" << endl ;
}

int main()
{
	while( cin >> w >> h ,h )
	{
		cin >> tx >> ty ;
		cin >> kx >> ky ;
		for( int i = 0 ; i < h ; i++ )
		{
			for( int j = 0 ; j < w ; j++ )
			{
				cin >> map[ i ][ j ] ;
			}
		}
		ans() ;
	}
}

Measured memory_bytes: 9296
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int count;

        int n = sc.nextInt();
        int x = sc.nextInt();

        while (true) {
            if (n == 0 && x == 0) {
                break;
            }

            count = 0;

            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    for (int k = 1; k <= n; k++) {
                        if (i == j || j == k || k == i) {
                            continue;
                        }else if(i + j + k == x){
                            count++;      
                        }
                    }
                }
            }

            count /= 6;
            System.out.println(count);

            n = sc.nextInt();
            x = sc.nextInt();
        }

        sc.close();
    }
}


Measured memory_bytes: 26956
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int MOD = 1e9 + 7;

int64 inv(int64 a, int64 mod) {
  a %= mod;
  int64 v[] = { 0, 1, mod };
  int64 u[] = { 1, 0, a };
  while (v[2] != 1) {
    if (v[2] < u[2]) {
      int64 tmp[] = { v[0], v[1], v[2] };
      v[0] = u[0]; v[1] = u[1]; v[2] = u[2];
      u[0] = tmp[0]; u[1] = tmp[1]; u[2] = tmp[2];
      continue;
    }
    int64 coe = v[2] / u[2];
    for (int i = 0; i < 3; ++i) v[i] = v[i] - u[i] * coe;
  }
  return v[0] < 0 ? v[0] + mod : v[0];
}

int64 pow(int64 a, int64 p, int64 mod) {
  a %= mod;
  int64 ret = a;
  while (p > 1) {
    if (p % 2) {
      ret = (ret * ret) % mod;
      ret = (ret * a) % mod;
    } else {
      ret = (ret * ret) % mod;
    }
    p /= 2;
  }
  return ret;
}

int main() {
  //cout << fixed << setprecision(15);
  int N;
  cin >> N;

  for (int i = 1; i < 50000; ++i) {
    if (floor(i * 1.08) == N) {
      cout << i << "\n";
      return 0;
    }
  }
  
  cout << ":(" << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>arr(n),brr(m);
    for(int i=0;i<n;++i){
        cin>>arr[i];
        if(i) arr[i]+=arr[i-1];
    }
    for(int i=0;i<m;++i){
        cin>>brr[i];
        if(i) brr[i]+=brr[i-1];
    }
    int book=0;
    int a=upper_bound(brr.begin(),brr.end(),k)-brr.begin();
    int b=0;///upper_bound(arr.begin(),arr.end(),k)-arr.begin();
    book =max(a, b);

    for(int i=0;i<n;++i){
        if(arr[i]>k){
            int st2=upper_bound(brr.begin(),brr.end(),k)-brr.begin();
            book=max(book,st2);
            break;
        }
        else{
            int rem=k-arr[i];
            int st2= upper_bound(brr.begin(),brr.end(),rem)-brr.begin();
            book=max(book,i+st2+1);
        }
    }
    cout<<book<<endl;
}

int main()
{
    fast;
    int t;
    solve();
}





Measured memory_bytes: 6356
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF = 1 << 30;
#define MOD 998244353
using namespace std;


long long fact[300010];
void calcfact() {
    long long i;
    fact[0] = 1;
    fact[1] = 1;
    for (i = 2; i < 300010; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
    }
}
long long power(long long a, long long b) {
    long long x = 1, y = a;
    while (b > 0) {
        if(b % 2) {
            x = (x*y) % MOD;
        }
        y = (y*y) % MOD;
        b /= 2;
    }
    return x%MOD;
}
long long inv(long long x) {
    return power(x, MOD - 2);
}
long long nCr(long long n, long long r) {
    return (fact[n] * (inv(fact[r])*inv(fact[n - r]) % MOD)) % MOD;
}



int main() {
    calcfact();
    long long n, a, b, k;
    cin >> n >> a >> b >> k;
    long long ans = 0;
    for (long long i = 0; i <= n; i++) {
        long long w= k - (i*a);
        if (w%b != 0) { continue; }
        w = w / b;
        if (w < 0 || n < w) { continue; }
        long long t = 1;
        t *= nCr(n, i);
        t %= MOD;
        t *= nCr(n, w);
        t %= MOD;
        ans += t;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

ll f(ll x) {
    ll res = 0;
    if (x % 2 == 0) {
        res = x;
    }
    if ((x + 1) / 2 % 2 == 0) {
        res ^= 1;
    }
    return res;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    cout << (f(A - 1) ^ f(B)) << endl;
    return 0;
}


Measured memory_bytes: 256
while(True):
        try:
            a,b,c,d,e,f=map(float,input().split(" "))
            z=a*e-b*d
            if(z!=0):
                x=(c*e-b*f)/z
                y=(a*f-c*d)/z
            print("{:.3f} {:.3f}".format(x+0,y+0))
        except:
            break

Measured memory_bytes: 7320
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
  ll n,l,sum=0;
  cin >> n >> l;
  ll a[n],loc=-1;
  vector<ll> ans;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(loc==-1&&i!=0&&a[i-1]+a[i]>=l){
      loc = i-1;
    }
  }
  if(loc!=-1){
    for(int i=0;i<loc;i++){
      ans.push_back(i+1);
    }
    for(int i=n-1;i>loc+1;i--){
      ans.push_back(i);
    }
    ans.push_back(loc+1);
  }
  if(loc==-1){
    cout << "Impossible\n";
  }else{
    cout << "Possible\n";
    for(int i=0;i<ans.size();i++){
      cout << ans[i]<<endl;
    }
  }
}


Measured memory_bytes: 2548
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var n = o.a();
  var k = o.a();

  var ans = 0;
  var cur = n;
  var i = 0;
  while (cur > 0) {
    var border = Math.ceil(k/Math.pow(2, i));
    // console.log({border, cur})
    if (cur >= border) {
      ans += (cur - border + 1) / n * ( 1 / Math.pow(2, i));
      cur = border - 1;
    }
    i += 1;
  }
  console.log(ans);
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007, maxN = 1000000;

int Add(int x, int y) {
	return (x += y) < mod ? x : x - mod;
}
int Dec(int x, int y) {
	return (x -= y) < 0 ? x + mod : x;
}
int Mul(int x, int y) {
	return 1ll * x * y % mod;
}
int Fpow(int x, int y) {
	return y ? Mul(Fpow(Mul(x, x), y >> 1), y & 1 ? x : 1) : 1;
}

int n, fac[maxN + 10], inv[maxN + 10], invFac[maxN + 10], val[maxN + 10], ans;

void PreWork() {
	fac[0] = invFac[0] = 1;
	for (int i = 1; i <= n; ++i) {
		inv[i] = i == 1 ? 1 : Dec(0, Mul(mod / i, inv[mod % i]));
		fac[i] = Mul(fac[i - 1], i);
		invFac[i] = Mul(invFac[i - 1], inv[i]);
	}
}

int Comb(int x, int y) {
	return x < y ? 0 : Mul(fac[x], Mul(invFac[y], invFac[x - y]));
}

int main() {
	scanf("%d", &n);
	PreWork();
	for (int i = 1; i < n; ++i) {
		val[i] = Mul(Mul(Comb(i - 1, n - 1 - i), fac[i]), fac[n - 1 - i]);
		ans = Add(ans, Mul(i, Dec(val[i], val[i - 1])));
	}
	printf("%d", ans);
}

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


void solve(long long N, long long M){
    cout << (N * (N-1))/2 + (M * (M-1))/2 << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		long al = Long.parseLong(a);
		long bl = Long.parseLong(b);
		long cl = Long.parseLong(c);

		if (cl <= al) {
			al = al - cl;
		} else {
			cl = cl - al;
			al = 0;
			bl = bl - cl;
		}
		if (bl < 0) {
			bl = 0;
		}
		
		System.out.println(al + " " + bl);
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(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; }
typedef long long ll;
using namespace std;
int main(void){
   string t;cin>>t;
   ll res=0;
   if(t[0]=='D')res++;
   if(t[0]=='?')t[0]='D';
   rep(i,t.size()-1){
       if(t[i]=='P'&&t[i+1]=='D')res+=2;
       else if(t[i]=='D'&&t[i+1]=='D')res++;
       else if(t[i]=='P'&&t[i+1]=='?'){
           res+=2;t[i+1]='D';
       }
       else if(t[i]=='D'&&t[i+1]=='?'){
           res++;t[i+1]='D';
       }
   }
   cout<<t<<endl;
}

Measured memory_bytes: 3720
n, p = map(int, input().split())

def prf(m):
    pf = {}
    for i in range(2, int(m**0.5)+1):
        while m % i == 0:
            pf[i] = pf.get(i, 0)+1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf

pf = prf(p)
ans = 1

for i in pf:
    while pf[i] >= n:
        ans *= i
        pf[i] -= n
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef tuple<int,int,int> T;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((c+(b-1))/b <= (a+(d-1))/d){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using std::endl;

class dice
{
    private:
        int roll[6];

    public:
        explicit dice(int in[6]){
            for (int i = 0; i < 6; i++)
                roll[i] = in[i];
        }

        void move(const char c){
            int tmp;
            switch(c){
                case 'N':
                    tmp = roll[0];
                    roll[0] = roll[1];
                    roll[1] = roll[5];
                    roll[5] = roll[4];
                    roll[4] = tmp;
                    break;

                case 'E':
                    tmp = roll[0];
                    roll[0] = roll[3];
                    roll[3] = roll[5];
                    roll[5] = roll[2];
                    roll[2] = tmp;
                    break;

                case 'W':
                    tmp = roll[0];
                    roll[0] = roll[2];
                    roll[2] = roll[5];
                    roll[5] = roll[3];
                    roll[3] = tmp;
                    break;

                case 'S':
                    tmp = roll[0];
                    roll[0] = roll[4];
                    roll[4] = roll[5];
                    roll[5] = roll[1];
                    roll[1] = tmp;
                    break;

                default:
                    cout << "Wrong Direction: "
                         << c << endl;
                    break;
            }
        }
        int operator()(size_t i){
            return roll[i];
        }
};

int main()
{
    int eye[6];
    char c;

    for (int i = 0; i < 6; i++)
        cin >> eye[i];

    dice d(eye);

    getchar();

    c = getchar();

    while (c!='\n'){
        d.move(c);
        c = getchar();
    }

    cout << d.operator()(0) << endl;
    
    return 0;
} 


Measured memory_bytes: 3080
#include <stdio.h>
int main(){

	int a[10];
	int sum[10*9*8/6];
	int i,j,k,l;
	int max;
	
	for(i=0;i<10;i++)scanf("%d",&a[i]);
	l=0;
	for(i=0;i<10;i++)for(j=i+1;j<10;j++)for(k=j+1;k<10;k++)sum[l++]=a[i]+a[j]+a[k];
	max=0;
	for(i=0;i<10*9*8/6;i++)if(max<sum[i])max=sum[i];
	printf("%d ",max);
	for(i=0;i<10;i++)scanf("%d",&a[i]);
	l=0;
	for(i=0;i<10;i++)for(j=i+1;j<10;j++)for(k=j+1;k<10;k++)sum[l++]=a[i]+a[j]+a[k];
	max=0;
	for(i=0;i<10*9*8/6;i++)if(max<sum[i])max=sum[i];
	printf("%d\n",max);

	return 0;
}

Measured memory_bytes: 596
import java.util.*;
 
 
public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    if (r < 1200) {
    	System.out.println("ABC");
    } else if(r < 2800) {
        System.out.println("ARC");
    } else {
        System.out.println("AGC");
    }
  }
}

Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		//long n=sc.nextLong(),y=sc.nextLong();
		String[] s=new String[n];
		int max=0,count=0;
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
		}
		int m=sc.nextInt();
		String[] t=new String[m];

		for(int i=0;i<m;i++) {
			t[i]=sc.next();
		}

		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(s[i].equals(s[j]))count++;
			}
			//System.out.println(count);
			for(int j=0;j<m;j++) {
				if(s[i].equals(t[j]))count--;
			}
			max=Math.max(max, count);
			count=0;
		}
		System.out.println(max);

	}

}


Measured memory_bytes: 21844
#include <stdio.h>

namespace beet{
  
  template<typename T>
  void swap(T &a,T &b){
    T x=a;
    a=b;
    b=x;
  }

  const int MAX = 1e5+10;
  struct UnionFind{
    int r[MAX],p[MAX];
    UnionFind(int n){
      for(int i=0;i<n;i++){
        r[i]=1;
        p[i]=i;
      }    
    }
    int find(int x){
      if(p[x]!=x) p[x]=find(p[x]);
      return p[x];
    }
    int same(int x,int y){
      return find(x)==find(y);
    }
    void unite(int x,int y){
      x=find(x);y=find(y);
      if(x==y) return;
      if(r[x]<r[y]) swap(x,y);
      r[x]+=r[y];
      p[y]=p[x];
    }
  };
}
using namespace beet;

int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  UnionFind uf(n);
  while(q--){
    int t,x,y;
    scanf("%d %d %d",&t,&x,&y);
    if(t==0) uf.unite(x,y);
    if(t==1) printf("%d\n",uf.same(x,y));
  }  
  return 0;
}



Measured memory_bytes: 2764
#include <iostream>
#include <vector>
#include <list>
#include<utility>
#include <new>
#include <string>
#include<cmath>
#include<unordered_set>
#include<iomanip>
#include <stack>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll =  long long int;
#define mod 1000000007
/*bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second<b.second;
}*/
int main() {
int t;
cin>>t;
vector<int>a(t);
loop(i,0,t){
cin>>a[i];
}
sort(a.begin(),a.end());
int ans=0;
for(int i=0;i<t-2;i++){
    for(int j=i+1;j<t-1;j++){
            for(int k=j+1;k<t;k++){
        if(a[i]!=a[j]&&a[j]!=a[k]&&(a[i]+a[j])>a[k]){
ans++;        }
    }
    }
}
cout<<ans;
        return 0;
}


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

using namespace std;

int s(int n)
{
    int res = 0;
    while(n)
    {
        res += n % 10;
        n /= 10;
    }
    return res;
}

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

    int n;
    cin >> n;

    if(n % s(n) == 0)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>


using namespace std;

namespace {

}

int main()
{
	set<char> head = { 'M', 'A', 'R', 'C', 'H' };

	int N = 0;
	cin >> N;

	map<char, int> number;

	for (int i = 0; i < N; ++i){
		string s;
		cin >> s;
		if (head.find(s[0]) != head.end()){ // なければ追加。
			++number[s[0]];
		}
	}

	long long sum = 0;
	for (auto itr = number.begin(); itr != number.end(); ++itr){
		auto itr2 = itr; ++itr2; // itr2 = itr + 1;は不可。
		for (; itr2 != number.end(); ++itr2){
			auto itr3 = itr2; ++itr3;
			for (; itr3 != number.end(); ++itr3){
				sum += static_cast<long long>(itr->second) * itr2->second * itr3->second;
			}
		}
	}

	cout << sum;

	return 0;
}

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

int main() {
    string s;
    cin >> s;
    bool ok = false;
    for (int i=0; i<s.size(); ++i) {
        for (int j=i; j<s.size(); ++j) {
            string tmp = "";
            for (int k=0; k<i; ++k) tmp += s[k];
            for (int k=j; k<s.size(); ++k) tmp += s[k];
            if (tmp == "keyence") {
                ok = true;
            }
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let r = {
        let i = read::<isize>();
        i[0]
    };

    if r < 1200 {
        println!("ABC");
    } else if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}


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

using namespace std;

int		main(void)
{
	int N;

	cin >> N;
	bitset<8> C;
	int O = 0;
	
	for (int i = 0; i < N; i++)
	{
		int score;

		cin >> score;
		if (score < 400)
			C.set(0);
		else if (score < 800)
			C.set(1);
		else if (score < 1200)
			C.set(2);
		else if (score < 1600)
			C.set(3);
		else if (score < 2000)
			C.set(4);
		else if (score < 2400)
			C.set(5);
		else if (score < 2800)
			C.set(6);
		else if (score < 3200)
			C.set(7);
		else
			O++;
	}
	int mn = C.count();

	printf("%d %d\n", max(1, mn), mn + O);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"

unordered_map<int, int> m;
vector<int> val(200001, 0);

void dfs(vector<vector<int>> &v, int e, vector<int> &f, int x)
{
	f[e]=1;
	int v1=m[e]+x;
	val[e]+=v1;
	for(int i=0;i<v[e].size();i++)
	{
		if(f[v[e][i]]==0)
		{
			dfs(v, v[e][i], f, v1);
		}
	}
}

int32_t main()
{
	fast;
	int n, q;
	cin>>n>>q;
	vector<vector<int>> v(n+1);
	for(int i=0;i<n-1;i++)
	{
		int a, b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=0;i<q;i++)
	{
		int a, b;
		cin>>a>>b;
		m[a]+=b;
	}
	vector<int> f(n+1, 0);
	dfs(v, 1, f, 0);
	for(int i=0;i<n;i++)
	{
		cout<<val[i+1]<<' ';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 37192
n, x = map(int, input().split())
ds = [abs(int(y) - x) for y in input().split()]
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)
res = max(ds) 
for d in ds:
  res = gcd(res, d)
print(res)

Measured memory_bytes: 14224
#include <stdio.h>

int main()
{
	int d;
	long long int total=0;
	long long int i;
	while(scanf("%d",&d)!=EOF){
		total=0;
		for(i=d;i<600;i+=d){
			total+=(i*i*d);
		}
		printf("%lld\n",total);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
int n,s[100000],q,t,c,l,m,r,i,j;
main(){
  for(scanf("%d",&n);i<n;scanf("%d",&s[i++]));
  for(scanf("%d",&q);j++<q;){
    l=0,r=n,scanf("%d",&t);
    while(m=(l+r)/2,l<r){
      t-s[m]||(l=r,c++);
      t<s[m]&&(r=m);
      t>s[m]&&(l=m+1);
    }
  }
  printf("%d\n",c);
}

Measured memory_bytes: 3104
N=int(input())
C=[]
S=[]
T=[]
for i in range(N-1):
  c,s,t=map(int,input().split())
  C += [c]
  S += [s]
  T += [t]
answer=[]
for i in range(N-1):
  Time=0
  for j in range(i,N-1):
    if Time <= S[j]:
      Time=S[j]+C[j]
    else:
      Time=-(-(Time-S[j])//T[j])*T[j]+S[j]+C[j]
  answer += [Time]

for i in range(N-1):
  print(answer[i])
print(0)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 2e5 + 5;

int lab[maxn], ok[maxn];
int N, w, h;
vector<pair<int, ii>> edge;

void init(int n)
{
  for(int i = 1; i <= n; ++i)
    lab[i] = -1;
}

int finds(int u)
{
  if(lab[u] < 0) return u;
  return lab[u] = finds(lab[u]);
}

bool merges(int u, int v)
{
  u = finds(u); v = finds(v);
  if(u == v){
    if(ok[u]) return false;
    ok[u] = true;
    return true;
  }
  if(ok[u] && ok[v]) return false;
  if(lab[v] < lab[u]) swap(u, v);
  lab[u] += lab[v];
  lab[v] = u;
  ok[u] |= ok[v];
  return true;
}

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  cin >> N >> h >> w;
  while(N--){
    int x, y, v;
    cin >> x >> y >> v;
    y += h;
    edge.eb(v, mp(x, y));
  }
  init(w + h);
  sort(edge.rbegin(), edge.rend());
  ll mst = 0;
  for(auto & all : edge){
    if(merges(all.se.fi, all.se.se)){
      //cerr << all.se.fi << ' ' << all.se.se  << ' ' << all.fi << '\n';
      mst += all.fi;
    }
  }
  cout << mst;
}


Measured memory_bytes: 2676
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    if n % 2 == 1:
        return 0
    r = 0
    while n > 0:
        n //= 5
        r += n // 2

    return r


print(main())





Measured memory_bytes: 5456
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int n,a,b,c;
string s;

int main(){
	cin >> s;
	REP(i,0,6) if(s[i]=='1') c++;
		
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
mod = pow(10, 9) + 7
N = int(input())
# 制約が a<2**60 なので
L = 60

A = map(int, input().split())

counter = [0] * L
for a in A:
    for i in range(L):
        counter[i] += a & 1
        a >>= 1

tmp = 0
for i in range(L):
    tmp += counter[i] * (N - counter[i]) * (2 ** i)
    tmp %= mod

print(tmp)


Measured memory_bytes: 116364
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	char a;cin>>a;
    if ('A'<=a&&a<='Z'){
        cout<<"A"<<endl;
    }else{
        cout<<"a"<<endl;
    }
}

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

using namespace std;

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

  int a, b;
  cin >> a >> b;
  cout << (a <= 9 and b <= 9 ? a * b : -1);

  return 0;
}

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

int n,k;
int c[2345],g[2345];

vector<int>bigst[10];
vector<int>accum[10];

const int INF = 123456789;
int memo[2345][11];
int dp(int i,int j)
{
	if(j == 0)
	{
		return (i == 0) ? 0 : -INF;
	}
	if(memo[i][j] >= 0)return memo[i][j];
	int lim = min((int)bigst[j-1].size(),i);
	int ans = 0;
	for(int x = 0;x <= lim;++x)
	{
		int fst = dp(i - x,j - 1);
		ans = max(ans,accum[j-1][x] + x * (x - 1) + fst);
	}
	return memo[i][j] = ans;
}

int main()
{
	cin >> n >> k;
	REP(i,n)
	{
		cin >> c[i] >> g[i];
		g[i]--;
		bigst[g[i]].push_back(c[i]);
	}
	REP(i,10)
	{
		sort(ALL(bigst[i]),[](const int&i1,const int&i2){return i1 > i2;});
		accum[i].push_back(0);
		for(int& val : bigst[i])
		{
			accum[i].push_back(accum[i].back() + val);
		}
	}
	memset(memo,0xff,sizeof(memo));
	int ans = dp(k,10);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3176
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


        EXPLAINATION BELOW->
        Read Editorial first
      
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  string s;cin>>s;
  for(auto x:s)if(x=='7'){cout<<"Yes\n";return;}
  cout<<"No\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> G(n);
	vector<int> in_deg(n), dp(n);
	for(int i = 0; i < m; ++ i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		G[u].push_back(v);
		in_deg[v] ++;
	}
	queue<int> Q;
	for(int i = 0; i < n; ++ i) {
		if(!in_deg[i]) Q.push(i);
	}
	while(!Q.empty()) {
		int u = Q.front(); Q.pop();
		for(auto v:G[u]) {
			dp[v] = max(dp[v], 1 + dp[u]);
			in_deg[v] --;
			if(!in_deg[v]) Q.push(v);
		}
	}
	cout << *max_element(all(dp)) << '\n';
}


Measured memory_bytes: 6528
#include <stdio.h>
#define FOR(n) for(int i=0;i<n;i++)
int main(void){
    int k,s;
    int ans=0;
    scanf("%d %d",&k,&s);
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int p=s-i-j;
            if(p>=0&&p<=k) ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
n, m = list(map(int, input().split()))

count = 0
if n >= 2 and m >= 2:
    count = (n-2) * (m-2)
elif n == 1 and m >= 2:
    count = m - 2
elif n == 1 and m == 1:
    count = 1
elif m == 1 and n >= 2:
    count = n - 2
elif m == 1 and n == 1:
    count = 1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n;
long long v[200],w[200];
long long tot;
long long dp[100010];
int main()
{
	cin>>n>>tot;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	} 
	for(int i=1;i<=n;i++){
		for(int j=tot-w[i];j>=0;j--)
		   dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]); 
	}
	cout<<*(max_element(dp+1,dp+tot+1));
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int num[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0};
    for(int i=0,x,y;i<n;i++){
        cin>>x>>y;
        if(x<6&&y<6&&y-x>0){
            cout<<num[x];
            for(int j=x+1;j<=y;j++)cout<<" "<<num[j];
            cout<<endl;
        }
        else if(x<6&&y<6){
            cout<<num[15-x];
            for(int j=16-x;j<16-y;j++)cout<<" "<<num[j];
            cout<<endl;
        }
        else{
            cout<<num[x];
            for(int j=x+1;num[j-1]!=y;j++){
                if(j==16)j=1;
                cout<<" "<<num[j];
            }
            cout<<endl;
        }
    }
}

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

int N;
int x[60], y[60];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    map<pair<int, int>, int> mp;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i != j) {
                mp[make_pair((x[i] - x[j]), (y[i] - y[j]))]++;
            }
        }
    }

    int max_val = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        int val = itr->second;
        //pair<int, int> k = itr->first;
        //cout << k.first << " " << k.second << " " << val << endl;
        max_val = max(max_val, val);
    }
 
    cout << N - max_val << endl;

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
int a,b,d,i;
char c[200];
while(scanf("%d %d\n",&a,&b)!=EOF){
d=a+b;
sprintf(c,"%d",d);
for(i=0;c[i]!='\0';i++){
}
printf("%d\n",i);
}
return 0;
}






Measured memory_bytes: 2056
n,k=map(int,input().split())
a=list(map(int,input().split()))

rui=[0]
for i in a:
  rui.append(rui[-1]+i)
hantei=0
for i in range(0,len(rui)-k):
  if hantei<=rui[i+k]-rui[i]:
    hantei=rui[i+k]-rui[i]
    l=i
    r=i+k
ans=0
for i in range(l,r):
  ans+=(a[i]+1)/2
  
print(ans)

Measured memory_bytes: 32056
N, K = map(int, input().split())
S = input()

q = [(S[0], 0)]
cur = S[0]
for i in range(1, N):
    if S[i] != cur:
        q.append((S[i], i))
        cur = S[i]

lim = len(q)
ans = []
for i in range(lim):
    if q[i][0] == "0":
        j = i + 2 * K
    else:
        j = i + 2 * K + 1

    if j < lim:
        ans.append(q[j][1] - q[i][1])
    else:
        ans.append(N - q[i][1])

print(max(ans))


Measured memory_bytes: 88104
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
typedef std::pair<ll, ll> P;

using namespace std;

bool pairCompare(const P& f, const P& s){
    return f.first < s.first;
}

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

    ll m = INF;
    rep(i, n){
        if(i-k+1 >= 0) m = min(m, abs(v[i])+abs(v[i] - v[i-k+1]));
        if(i+k-1 <= n-1) m = min(m, abs(v[i])+abs(v[i+k-1] - v[i]));
    }
    cout << m;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=600000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 1000000007
#define eps 1e-8
int n,m,l,r;
ll fac[N+10],invfac[N+10];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

ll qpow(ll x,int y)
{
	ll ans=1;
	while (y)
	{
		if (y&1) ans=ans*x%maxd;
		x=x*x%maxd;y>>=1;
	}
	return ans;
}

void init()
{
	fac[0]=invfac[0]=1;
	rep(i,1,N) fac[i]=fac[i-1]*i%maxd;
	invfac[N]=qpow(fac[N],maxd-2);
	per(i,N-1,1) invfac[i]=invfac[i+1]*(i+1)%maxd;
}

ll C(int n,int m)
{
	if ((n<m) || (n<0) || (m<0)) return 0;
	return fac[n]*invfac[m]%maxd*invfac[n-m]%maxd;
}

ll calc(int n,int m,int sum,int lim,int r)
{
	if (sum<1ll*m*r) return 0;
	sum-=m*r;
	ll ans=0;
	for (int i=0,f=1;i<=n-m;i++,f*=-1)
	{
		ll tmp=C(n-m,i)*C(n+sum,n)%maxd;
		ans=(ans+tmp*f+maxd)%maxd;
		sum-=lim;
		if (sum<0) break;
	}
	return ans*C(n,m)%maxd;
}

ll solve(int n,int m,int sum)
{
	ll ans=C(n+sum,n);
	per(i,sum,1)
	{
		ll del=(calc(n,m,sum,i,i)-calc(n,m,sum,i,i+1)+maxd)%maxd;
		ans=(ans-del+maxd)%maxd;
	}
	return ans;
}

int main()
{
	init();
	n=read();m=read();l=read();r=read();
	printf("%lld",(solve(n,m,r)-solve(n,m,l-1)+maxd)%maxd);
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    string s, t;
    cin >> s;
    t = s;
    reverse(s.begin(), s.end());
    int cnt = 0;
    rep(i, s.size())
    {
        if (s[i] != t[i])
        {
            cnt += 1;
        }
    }
    cout << cnt / 2 << endl;

    return 0;
}


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

int main(){
    string s;
    cin >> s;
    
    vector<string> p;
    string t;
    p.push_back(t);
    p[0] += s[0];
    p.push_back(t);
    
    for(int i=1; i<s.size(); i++){
        p[p.size()-1]+= s[i];
        if(p[p.size()-1]==p[p.size()-2]){
            if(i==(int)s.size()-1){
                p.pop_back();
                p[p.size()-1]+= s[i];
            }
            else continue;
        }
        else{
            p.push_back(t);
        }
    }
    if(p[p.size()-1]==t)
        p.pop_back();
    
    cout << p.size() << endl;
    
    return 0;
}

Measured memory_bytes: 10996
package main

import (
	"fmt"
)

func main() {

	var A, B, C int
	fmt.Scanf("%d %d %d", &A, &B, &C)

	if A*B*C == 5*5*7 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 1832
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        System.out.println(solve(A, B, C));

        sc.close();
    }

    static int solve(int A, int B, int C) {
        int[] values = { A, B, C };
        int result = 0;
        while (true) {
            Arrays.sort(values);
            if (values[0] == values[2]) {
                break;
            }

            if (values[0] + 2 <= values[1]) {
                values[0] += 2;
            } else {
                ++values[0];
                ++values[1];
            }

            ++result;
        }

        return result;
    }
}

Measured memory_bytes: 22996
import java.util.Scanner;
import java.util.Stack;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        Stack<Integer> stack = new Stack<Integer>();

        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            if (n == 0) {
                System.out.println(stack.pop());
            } else {
                stack.push(n);
            }
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000