akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

bool larger(pair<int,int>& a, pair<int,int>& b){
	return a.first*a.second < b.first*b.second;
}

int main(){
	while(1){
		int n,w,d;
		cin >> n >> w >> d;
		if(w==0) break;
		
		vector<pair<int,int> > cakes;
		cakes.push_back(make_pair(w,d));
		for(int i=0; i<n; i++){
			int p,s;
			cin >> p >> s;
			p--;
			int x=cakes[p].first, y=cakes[p].second;
			cakes.erase(cakes.begin()+p);
			s %= x+y;
			if(s<x){
				if(s<=x/2){
					cakes.push_back(make_pair(s, y));
					cakes.push_back(make_pair(x-s, y));
				}else{
					cakes.push_back(make_pair(x-s, y));
					cakes.push_back(make_pair(s, y));
				}
			}else{
				s-=x;
				if(s<=y/2){
					cakes.push_back(make_pair(x, s));
					cakes.push_back(make_pair(x, y-s));
				}else{
					cakes.push_back(make_pair(x, y-s));
					cakes.push_back(make_pair(x, s));
				}
			}
		}
		
		sort(cakes.begin(), cakes.end(), larger);
		for(int i=0; i<n; i++){
			cout << cakes[i].first*cakes[i].second << " ";
		}
		cout << cakes[n].first*cakes[n].second << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100001
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int P,Q,R,i,ans=0;
  scanf("%d%d%d",&P,&Q,&R);
  ans=P+Q;
  if(ans>Q+R)ans=Q+R;
  if(ans>P+R)ans=P+R;

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


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

#define pi 2*acos(0)
#define INF 1e16
#define MIN 1e-9
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define m_p make_pair
#define p_b push_back
#define n_p(a) next_permutation(all(a))
#define all(v) v.begin(),v.end()
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define rev(s) reverse(all(s))
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define mem(a,k) memset(a,k,sizeof a)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define u_b(X,V) upper_bound(X.begin(),X.end(),V)
#define l_b(X,V) lower_bound(X.begin(),X.end(),V)
#define cnt(s,c) count(all(s),c)

//bitwise helpers
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

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

    ll n, W;

    cin >> n >> W;

    ll w[n], v[n];

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

    ll dp[W + 1];

    mem(dp, 0);

    for(int i = 0; i < n; i++) {
        for(int j = W; j >= w[i]; j--) {
            dp[j] = max(dp[j], v[i] + dp[j - w[i]]);
        }
    }

    cout << dp[W] << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------
vector<long long> factor_array(long long n){
    vector<long long> res ;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i) ;
            if(i*i!=n){
                res.push_back(n/i) ;
            }
        }
    }
    sort(res.begin(),res.end()) ;
    res.pop_back() ;
    return res ;
}

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    cin >> n ;
    vll a(n) ;
    ll ans = 0 ;
    REP(i,n){
        cin >> a[i] ;
    }
    sort(ALL(a)) ;
    vector<int> vec(a[n-1]+1,1) ;
    REP(i,n){
        ll x = a[i] ;
        bool f = i+1<n && x==a[i+1] ;
        if(vec[x]==0){
            continue ;
        }
        if(!f && vec[x]==1){
            ans++; 
        }
        ll j = 1 ;
        while(j*x<=a[n-1]){
            vec[j*x] = 0 ;
            j++ ;
        }
    }

    cout << ans <<endl;



    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}


Measured memory_bytes: 8772
n, m = map(int, input().split())
s1 = []
s2 = []
for i in range(m):
	a, b = map(int, input().split())
	if a == 1:
		s1.append(b)
	elif b == n:
		s2.append(a)
if len(set(s1) & set(s2)) == 0:
	print("IMPOSSIBLE")
else:
	print("POSSIBLE")

Measured memory_bytes: 21848
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<cstdlib>
using namespace std ;

#define MAXN 200007

int n ;
string a , b ;

int nxt[ MAXN ][ 30 ] ;

int lst[ 30 ] ;

void input ( ) {
    cin >> a >> b ;
    n = a.size ( ) ;
    for ( int i = 0 ; i <= 26 ; ++ i ) {
        lst[ i ] = n ;
    }
    for ( int i = n - 1 ; i >= 0 ; -- i ) {
        for ( int j = 0 ; j <= 26 ; ++ j ) {
            nxt[ i ][ j ] = lst[ j ] ;
        }
        lst[ ( a[ i ] - 'a' ) ] = i ;
    }
}

void solve ( ) {
    int m = b.size ( ) ;
    int pos = lst[ ( b[ 0 ] - 'a' ) ] ;
    long long full = 0 ;
    if ( pos == n ) { cout << "-1\n" ; return ; }
    for ( int i = 1 ; i < m ; ++ i ) {
        if ( nxt[ pos ][ ( b[ i ] - 'a' ) ] != n ) {
            pos = nxt[ pos ][ ( b[ i ] - 'a' ) ] ;
        }
        else if ( lst[ ( b[ i ] - 'a' ) ] != n ) {
            pos = lst[ ( b[ i ] - 'a' ) ] ;
            ++ full ;
        }
        else {
            cout << "-1\n" ; return ;
        }
    }
    cout << full * n + pos + 1 << "\n" ;
}

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


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i=0,j=n-1,cnt=0;
    while(i<j)
    {
        if(s[i]=='W' && s[j]=='R')
        {
            i++;
            j--;
            cnt++;
        }
        if(s[i]=='R')
            i++;
        if(s[j]=='W')
            j--;
    }
    cout<<cnt<<endl;
    return 0;
}


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

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

    vector<pii> v(n);
    rep(i,n){
      string l;
      int p,a,b,c,d,e,f,s,m;
      cin >> l>>p>>a>>b>>c>>d>>e>>f>>s>>m;

      auto time=a+b+c+m*(d+e);
      auto price=m*s*f - p;

      v[i]=make_pair((double)price/(double)time,l);
    }

    sort(v.begin(),v.end(),[](auto x,auto y)->bool{ 
          return x.first == y.first ? x.second < y.second : (x.first > y.first); 
        });

    for(auto i:v){
      cout<<i.second<<endl;
    }
    cout << "#" << endl;
  }
}



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


def solve(a: int, b: int, x: int):
    p = a // x
    q = b // x
    ans = q - p
    if a % x == 0:
        ans += 1
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

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

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll h, w, m;
  cin >> h >> w >> m;

  vll by(m), bx(m);
  vector<P> tgt;
  rep(i, m) {
    cin >> by[i] >> bx[i];
    by[i]--;
    bx[i]--;
    tgt.emplace_back(by[i], bx[i]);
  }

  sort(all(tgt));

  vll yy(h), xx(w);
  rep(i, m) {
    yy[by[i]]++;
    xx[bx[i]]++;
  }

  auto my = *max_element(all(yy));
  auto mx = *max_element(all(xx));

  ll ans = my + mx - 1;

  vll candy;
  vll candx;

  rep(i, h) {
    if (yy[i] == my) {
      candy.push_back(i);
    }
  }

  rep(i, w) {
    if (xx[i] == mx) {
      candx.push_back(i);
    }
  }

  for (auto y : candy) {
    for (auto x : candx) {
      if (!binary_search(all(tgt), make_pair(y, x))) {
        ans++;
        goto finish;
      }
    }
  }

finish:

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


Measured memory_bytes: 26016
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;
using System.Xml;

namespace hello_world
{
	class Program
	{

		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] s = Console.ReadLine().Split(" ");
			long[] aa = new long[n];
			long sum = 1;
			if (s.Contains("0"))
				Console.WriteLine("0");
			else
			{
				try
				{
					checked
					{
						for (int i = 0; i < n; i++)
						{
							aa[i] = long.Parse(s[i]);

							sum *= aa[i];
							if (sum > 1000000000000000000)
							{
								sum = -1;
								i = n - 1;
							}


						}
						Console.WriteLine(sum);
					}
				}
				catch
				{
					Console.WriteLine(-1);
				}
			}

		}

	}
}



Measured memory_bytes: 41212
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>

using namespace std;

const int CMax = 200002;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int a, b, c, d, e, k, n;

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

string baseConverter(int base, int num) {
    string tNum = "";
    while (num > 0) {
        tNum = (char)('0' + num%base) + tNum;
        num /= base;
    }
}

bool isPalindrom(string tS) {
    int sn = (int)tS.length();
    for (int i = 0; i < sn / 2; i++) {
        if (tS[i] != tS[sn - i - 1]) return false;
    }
    return true;
}

int dist(int i, int j) {
    return  (j < i ? n + j : j) - i;
}

int main()
{
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    scanf("%d", &k);

    if (e - a > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}


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

int main()
{
  long A,B;
  cin>>A>>B;
  long a=B;
  if(A>B){
    B=A;
    A=a;
  }
  while(true){
    B%=A;
    if(B==0) break;
    a=A;
    A=B;
    B=a;
  }
  //A is GCD
  int ans=1;
  for(int i=2;i<1000000;i++){
    if(A%i==0){
      ans+=1;
      while(A%i==0){
        A/=i;
      }
    }
  }
  if(A!=1)ans+=1;
  cout<<ans<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef unsigned long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
ll n, a, b, c, d;
unordered_map<ll, ll> cache;
ll rec(ll num) {
    if (num == 0) return 0;
    if (num == 1) return d;
    if (cache.count(num)) return cache[num];

    ll res = num * d;
    ll div2_1 = num + (num % 2);
    ll div2_2 = num - (num % 2);

    ll div3_1 = num + (3 - num % 3);
    ll div3_2 = num - (num % 3);

    ll div5_1 = num + (5 - (num % 5));
    ll div5_2 = num - (num % 5);

    res = min(res, (num % 2) * d + a + rec(div2_1 / 2));
    res = min(res, (3 - num % 3) * d + b + rec(div3_1 / 3));
    res = min(res, (5 - num % 5) * d + c + rec(div5_1 / 5));

    if (div2_2 >= 0) res = min(res, (num % 2) * d + a + rec(div2_2 / 2));
    if (div3_2 >= 0) res = min(res, (num % 3) * d + b + rec(div3_2 / 3));
    if (div5_2 >= 0) res = min(res, (num % 5) * d + c + rec(div5_2 / 5));

    return cache[num] = res;
}
int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;

    cin >> t;
    while (t--) {
        cache.clear();
        cin >> n >> a >> b >> c >> d;
        cout << rec(n) << endl;
    }
    return 0;
}


Measured memory_bytes: 4252
#include<stdio.h>

int kuku(int x, int y){
    return (x*y);
}

int main(){
    int i, j;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            printf("%dx%d=%d\n",i, j, kuku(i, j));
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int k;
  cin>>k;
  vector<bool>b(k);
  int x=7%k;
  int ans=1;
  if(x==0) cout<<ans<<endl;
  else{
    b[x]=true;
    while(1){
      ans++;
      x*=10;
      x+=7;
      x%=k;
      if(b[x]){
        ans=-1;
        break;
      }
      else if(x==0) break;
      else{
        b[x]=true;
      }
    }
    cout<<ans<<endl;
  }
}

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

int main(){
  int n;
  ll t,a[100010];
  cin>>n>>t;
  for(int i=0;i<n;i++) cin>>a[i];
  ll ans=0,min=a[0],max=0;
  for(int i=1;i<n;i++){
    if(a[i]<min) min=a[i];
    else if(a[i]>min){
      if(a[i]-min==max) ans++;
      else if(a[i]-min>max){
        max=a[i]-min;
        ans=1;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int a[] = {6 , 2 , 10 , 3 , 9 , 4 , 8 , 12};
int b[] = {2 , 10 , 3 , 9 , 4 , 8 , 6 , 12};
int n;

int main()
{
	cin >> n;
	if(n == 3)
	{
		cout << 2 << " " << 5 << " " << 63;
		return 0;
	}
	if(n % 2 == 1)
	{
		for(int i = 0 ; i < min(n , 8) ; i++)
			cout << a[i] << " ";
		for(int i = 8 ; i < n ; i++)
		{
			a[i % 8] += 12;
			cout << a[i % 8] << " ";
		}
	}
	else
	{
		for(int i = 0 ; i < min(n , 8) ; i++)
			cout << b[i] << " ";
		for(int i = 8 ; i < n ; i++)
		{
			b[i % 8] += 12;
			cout << b[i % 8] << " ";
		}
		/*
		for(int i = 0 ; i < 8 ; i++)
			cout << b[i] << " ";
		*/
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string a = s;
	reverse(a.begin(), a.end());
	if (a == s) cout << "Yes";
	else cout << "No";
}   

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <iostream>
#include <limits.h>

using namespace std;

int main()
{
    long long n1, n2;
    cin >> n1 >> n2;
    if (n1 % n2 == 0) {
        cout << -1 << endl;
        return 0;
    }
    
    cout << n1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  int a, b;
  cin >> a >> b;
  string sa = string(b,a+'0');
  string sb = string(a,b+'0');
  cout << (sa < sb ? sa : sb) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int n;
int num[1222];

bool solve(int i, int m);

int main(){
    cin >> n;
    rep(i, n) cin >> num[i];
    int q;
    cin >> q;
    int m;
    for (int j = 0; j < q; j++){
        cin >> m;
            bool tf = solve(0, m);
        if (tf)
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}

bool solve(int i,int m){
    if (m==0)
        return true;
    if (i>=n)
        return false;
    else{
        bool l = solve(i + 1, m) || solve(i + 1, m - num[i]);
    }
}


Measured memory_bytes: 3096
#include<stdio.h>

int main(void) {
  long long n, h[100001], ans = 0, cnt = 0;
  h[0] = 0;
  scanf("%lld", &n);

  for (int i = 1; i <= n; i++) {
    scanf("%lld", &h[i]);
    if (h[i] <= h[i - 1]) {
      cnt++;
    }
    else {
      cnt = 0;
    }
    if (cnt > ans) ans = cnt;
  }

  printf("%lld", ans);

  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#define ll long long
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll n,k;
ll a[1000010],b[1000010];
int f(ll x){
	//x秒以内に完食するための修行回数がk回以下か？
	ll ans=0;
	for(int i=0;i<n;i++)if(a[i]*b[i]>x)ans+=a[i]-x/b[i];
	return ans<=k;
}


int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	for(int i=0;i<n;i++)scanf("%lld",b+i);
	sortup(a,n);
	sortdown(b,n);
	//答えが0か
	{
		ll s=0;
		for(int i=0;i<n;i++)s+=a[i];
		if(s<=k){
			puts("0");
			return 0;
		}
	}
	ll l=0,r=1e13;//lはng,rはok
	while(r-l>1){
		ll m=(l+r)/2;
		if(f(m))r=m;
		else l=m;
	}
	printf("%lld",r);
}

Measured memory_bytes: 7420
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  
  int ans = 0;
  int now = 0;
  bool flg = false;
  for (int i = 0; i < N; i++)
  {
    now = a.at(now) - 1;
    ans++;
    if (now == 1) {flg = true; break;}
  }
  if (!flg) ans = -1;
  
  cout << ans << endl;
}

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

constexpr unsigned long long m = 1'000'000'000 + 7;

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

  int counters[60][2] = {};
  for (int bitpos = 0; bitpos < 60; ++bitpos) {
    long long bit = 1LL << bitpos;
    for (int i = 0; i < n; ++i)
      ++counters[bitpos][a[i] & bit ? 1 : 0];
  }

  long long sum = 0;
  for (int bitpos = 0; bitpos < 60; ++bitpos) {
    long long bit = 1LL << bitpos;
    for (int i = 0; i < n; ++i) {
      int c = counters[bitpos][a[i] & bit ? 0 : 1];
      sum += c * (bit % (2 * m));
      sum %= (2 * m);
    }
  }

  cout << (sum/2);
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; };
}
void solve() {
  int ans = INF;
  auto f = [](int k) {
    int cnt = 0;
    int kk = k;
    while ((kk & 1) == 0) {
      cnt++;
      kk >>= 1;
    }
    return cnt;
  };
  for (auto x : va) {
    chmin(ans, f(x));
  };
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 30
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

int d[210000];

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

    int N;
    cin>>N;
    vector<int> V[210000];
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    d[1]=0;
    queue<int> que;
    que.push(1);
    int t;
    while(!que.empty()){
        int now=que.front(); que.pop();
        for(int next:V[now]){
            if(d[next]==0){
                d[next]=d[now]+1;
                t=next;
                que.push(next);
            }
        }
    }
    for(int i=0;i<210000;i++) d[i]=0;
    que.push(t);
    int ans;
    while(!que.empty()){
        int now=que.front(); que.pop();
        for(int next:V[now]){
            if(d[next]==0){
                d[next]=d[now]+1;
                t=next;
                ans=d[next];
                que.push(next);
            }
        }
    }
    ans++;
    //cout<<ans<<endl;
    if(ans%3==2) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
}


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

long long ans;
long long m[5];

int main(){
    int N; cin >> N;
    for(int i=0; i<N; i++){
        string S; cin >> S;
        if(S.at(0)=='M') m[0]++;
        if(S.at(0)=='A') m[1]++;
        if(S.at(0)=='R') m[2]++;
        if(S.at(0)=='C') m[3]++;
        if(S.at(0)=='H') m[4]++;
    }
    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            for(int k=j+1; k<5; k++){
                ans +=m[i]*m[j]*m[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
int main()
{
	int a; cin >> a;
	string str; cin >> str;
	lli arr[a + 50], suf[3][a + 50], now;
	memset(suf, 0, sizeof(suf));
	for(int i=a - 1; i >= 0; i--)
	{
		if(str[i] == 'R') arr[i] = 0;
		else if(str[i] == 'G') arr[i] = 1;
		else				   arr[i] = 2;
		for(int j=0; j<3; j++)
			suf[j][i] = suf[j][i + 1];
		suf[arr[i]][i] ++;
	}
	lli ans = 0;
	for(int i=0; i<a; i++)
	{
		for(int j=i + 1; j < a; j++)
		{
			if(arr[i] == arr[j]) continue;
			if(arr[i] + arr[j] == 1) 			now = 2;
			else if(arr[i] + arr[j] == 2) 		now = 1;
			else								now = 0;
			ans += suf[now][j + 1];
			if(j + (j - i) < a)
			{
				if(arr[j + (j - i)] == now)
					ans --;
			}
		}
	}
	cout << ans << '\n';
}


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

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
        s ^= a.at(i);
    }

    for(int i = 0; i < n; ++i) {
        printf("%d", s ^ a.at(i));
        if(i != n - 1) printf(" ");
        else printf("\n");
    }

    return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <limits.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
 
int main()
{
    ios::sync_with_stdio(false);
    int N, r, i;
    int min=INT_MAX, max=INT_MIN;
     
    cin >> N;
    rep(i,N) {
        cin >> r;
        if(r-min > max) max = r-min;
        if(r < min) min = r;
    }
    cout << max << endl;
    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

class Combination{
public:
    int N;
    ll mod;
    vector<ll> fact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1){
        fact[0] = 1;
        for(ll i=1; i<=N; i++){
            fact[i] = i * fact[i-1] % mod;
        }
    }

    ll POW(ll a, ll b){
        ll res = 1;
        while(b > 0){
            if(b & 1){
                res = res * a % mod;
            }
            a = a * a % mod;
            b >>= 1;
        }
        return res;
    }

    ll combin(int n, int k){
        if(n < k) return 0;
        if(n < 0 || k < 0){
            return 1;
        }
        return fact[n] * POW(fact[k] * fact[n-k] % mod, mod - 2) % mod;
    }
};

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

    Combination C(2*n, MOD);


    FOR(i, 1, k+1){
        ll ans = C.combin(n-k+1, i) * C.combin(k-1, i-1) % MOD;
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ss = br.readLine().split(" ");
        int n = Integer.parseInt(ss[0]);
        int m = Integer.parseInt(ss[1]);
        int[][] num1 = new int[n][m];
        int[] num2 = new int[m];
        int a=0;

        for(int i=0; i<n; i++){
            String[] str = br.readLine().split(" ");
            for(int j=0; j<m; j++){
                num1[i][j] = Integer.parseInt(str[j]);;
                
                //System.out.print(num1[i][j]);
            }
                //System.out.println("");
        }
        for(int i=0; i<m; i++){
        	num2[i] = Integer.parseInt(br.readLine());
            //System.out.println(num2[i]);
        }
        for(int i=0; i<n; i++){
        	for(int j=0; j<m; j++){
        		a += num1[i][j] * num2[j];
        	}
        	System.out.println(a);
        	a=0;
        }
    }
}

Measured memory_bytes: 22604
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int slen = s.length();
        int tlen = t.length();
        boolean ok = false;
        // 辞書順で初め => 後ろに一致するものを探す
        char ft = t.charAt(0);// tの最初の文字
        search: for (int i = 0; i < slen; i++) {
            char c = s.charAt(slen - 1 - i); // sの文字取得 後ろから取っていく
            // System.out.println(c);
            if (c == ft || c == '?') {
                // 一文字目が取れたので全部一致するか試す
                int cnt = 0;
                for (int j = 0; j < tlen; j++) {
                    if (slen - 1 - i + j >= slen)
                        break;
                    // System.out.println((slen - 1 - i) + " : " + j);
                    c = s.charAt(slen - 1 - i + j);
                    char tc = t.charAt(j);
                    // System.out.println(c + " : " + tc);
                    if (c != tc && c != '?')
                        break;
                    cnt++;
                }
                if (cnt == tlen) {
                    ok = true;
                    for (int j = 0; j < tlen; j++) {
                        char tc = t.charAt(j);
                        // 結合する
                        s = s.substring(0, slen - 1 - i + j) + tc + s.substring(slen - 1 - i + j + 1);
                    }
                    break search;
                }
            }
        }

        if (ok) {
            for (int i = 0; i < slen; i++) {
                char ans = s.charAt(i);
                if (ans == '?') {
                    System.out.print('a');
                } else {
                    System.out.print(ans);
                }

            }
            System.out.println("");
        } else {
            System.out.println("UNRESTORABLE");
        }
        sc.close();
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int n,nrimp;
    float result;
    cin>>n;

    if(n%2!=0)
        nrimp=n/2+1;
    else
        nrimp=n/2;

    result=(float)nrimp/n;

    cout<<result;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  int poor=0;
  if(a==b && b!=c)
    poor=1;
  if(b==c && c!=a)
    poor=1;
  if(c==a && a!=b)
    poor=1;
  if(poor)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>

#define INF 1000000001

int cnt=0;

void merge(int *A,int left,int mid,int right){
  std::vector<int> lArray,rArray;
  
  for(int i = 0;i < mid-left;++i){
    lArray.push_back(A[left+i]);
  }
  
  for(int i=0;i<right-mid;++i){
    rArray.push_back(A[mid+i]);
  }
  
  //???????????????
  lArray.push_back(INF);
  rArray.push_back(INF);
  
  int lCount = 0, rCount=0;
  
  for(int i=left;i<right;++i){
    cnt++;
    if(lArray[lCount] <= rArray[rCount]){
      A[i] = lArray[lCount];
      lCount++;
    }else{
      A[i] = rArray[rCount];
      rCount++;
    }
  }
}

void mergeSort(int *A,int left,int right){
  //right????????????????´?
  if(left + 1 < right){
    int mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}


int main() {
  int A[500001];
  
  int n;
  std::cin >> n;
  
  for(int i=0;i<n;++i){
    std::cin >> A[i];
  }
  
  mergeSort(A,0,n);
  
  for(int i=0;i<n;++i){
    if(i)std::cout << " ";
    std::cout << A[i];
  }
  std::cout << std::endl;
  
  std::cout << cnt << std::endl;
  
  return 0;
}

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

using namespace std;
typedef long long int ll;

int main()
{
	int n; cin >> n;
	vector<ll> v(n+1, 1);
	ll ans = 1;
	for(int num = 2; num <= n; ++num)
	{
		int next = num;
		while(next <= n)
		{
			v[next] += 1;
			next += num;
		}
		ans += v[num] * num;
	}
	cout << ans << "\n";
	return 0;
}


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

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

int main() {
    int x, y;

    cin >> x >> y;

    double num = (4 * x - y) / 2;
    if ((4 * x - y) % 2 == 0 && 4 * x >= y && x - num >= 0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vi dp(n + 1, 0);
	rep2(i, 1, n) {
		dp[i] = dp[i - 1] + 1;
		int six = 1;
		while (pow(6, six) <= i) {
			dp[i] = min(dp[i], dp[i - pow(6, six)] + 1);
			six++;
		}
		int nine = 1;
		while (pow(9, nine) <= i) {
			dp[i] = min(dp[i], dp[i - pow(9, nine)] + 1);
			nine++;
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int len = s.size();
    rep(i, len){
        int alnum = s[i] - 'A';
        int newnum = (alnum + n) % 26;
        cout << (char)('A' + newnum);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3648
n, m = map(int, input().split())
wa = [0 for _ in range(n)]
ac = [0 for _ in range(n)]

for _ in range(m):
    p, s = input().split()
    if s == 'WA' and ac[int(p)-1] == 0:
        wa[int(p)-1] += 1
    else:
        if ac[int(p)-1] == 0:
            ac[int(p)-1] = 1

wa_ans = 0
ac_ans = sum(ac)
for i in range(n):
    if ac[i] == 1:
        wa_ans += wa[i]

print(ac_ans, wa_ans)


Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	cout << a[n / 2] - a[n / 2 - 1] << endl;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n,k;
	cin>>n>>k;

	ll t=0,s=0,g=n,st=0,gt=0;
	for(int i=1; i<n+2; i++){
		st+=s;
		s++;
		gt+=g;
		g--;
		if(i>=k){
			t+=gt-st+1;
			t%=i197;
		}
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>

int main(void){
	double x1, y1, x2, y2, x3, y3, x4, y4;
	double a12, a34;
	int n;
	int i;

	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		if(x2 != x1){
			a12 = (y2 - y1) / (x2 - x1);
		}else{
			if(x4 == x3){
				printf("YES\n");
				continue;
			}else{
				printf("NO\n");
				continue;
			}
		}
		if(x4 != x3){
			a34 = (y4 - y3) / (x4 - x3);
		}else{
			printf("NO\n");
			continue;
		}

		if(a12 == a34){
			puts("YES");
		}else{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 0
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    var s string
    fmt.Scan(&n,&s)
    ans := 0
    for i:=1; i<n; i++{
        a := make([]bool, 26)
        b := make([]bool, 26)
        for j:=0; j<i; j++{
            a[s[j]-'a']=true
        }
        for j:=i; j<n; j++{
            b[s[j]-'a']=true
        }
        cnt := 0
        for j:=0; j<26; j++{
            if a[j] && b[j]{
                cnt++
            }
        }
        ans = max32(ans,cnt)
    }
    fmt.Println(ans)
}









func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
using ll =  long long;
const int INF = 0x3f3f3f3f;

const int MAX_N = 1e5+10;
vector<pair<int,int>> g[MAX_N];
int color[MAX_N];
int N;

void dfs(int x, int c)
{
    color[x]=c;
    for(int i=0;i<g[x].size();++i){
        int y = g[x][i].first, w = g[x][i].second;
        if(color[y]==-1){ 
			if(w%2)dfs(y,c^1);
			else dfs(y, c);
		}
    }
}

void solve()
{
	memset(color,-1,sizeof(color));
	int root = -1;
	for(int i=1;i<=N;++i){
	    if(g[i].size()==1){
		    root = i;
		    break;
	    }
	}
	dfs(root, 0);
	for(int i=1;i<=N;++i)cout <<color[i]<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	int u,v,w;
	for(int i=1;i<=N-1;++i){
		cin >> u >> v >> w;
		g[u].push_back(make_pair(v,w));
		g[v].push_back(make_pair(u,w));
	}
	solve();
	return 0;
}


Measured memory_bytes: 10368
#include<stdio.h>
int main(){
  int A[100][100];
  int b[100];
  int n,m,i,j,k,o = 0;

  scanf("%d%d",&n,&m);
  for(i = 0;i <  n;i++){
    for(j = 0;j <  m;j++){
       scanf("%d",&A[i][j]);
    }
  }
  for(i = 0;i <  m;i++){
    scanf("%d",&b[i]);
  }
  for(i = 0;i <  n;i++){
    for(j = 0;j <  m;j++){
      k = A[i][j] *b[j];
      o += k;
    }
    printf("%d\n",o);
    o = 0;
  }
  return 0;
}


Measured memory_bytes: 2108
fun main() {
    val n= readLine()!!.toInt()
    val words= mutableSetOf<String>()
    var f=true
    var bef: String?=null
    for (i in 0 until n){
        val word=readLine()!!
        words.add(word)
        if (bef!=null){
            if (word.first()!=bef.last()){
                f=false
            }
        }
        bef=word
    }
    if (!f || words.size!=n){
        println("No")
    }else{
        println("Yes")
    }
}

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

#define int long long

using namespace std;

const int maxn = 1e5 + 10, mod = 1e9 + 7;
int a[maxn], fac[maxn], n, k;

int pw(int base, int power)
{
    int res = 1;
    while (power) {
        if (power & 1)
            (res *= base) %= mod;
        (base *= base) %= mod;
        power >>= 1;
    }
    return res;
}

int inv(int x) { return pw(x, mod - 2); }

int C(int n, int k)
{
    if (k > n)
        return 0;
    return fac[n] * inv(fac[k]) % mod * inv(fac[n - k]) % mod;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> k;

    if (k == 1)
        return cout << 0, 0;

    fac[0] = 1;
    for (int i = 1; i < maxn; i++)
        fac[i] = fac[i - 1] * i % mod;

    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x = a[i];
        (ans += x * C(i, k - 1) % mod) %= mod;
        (ans += mod - x * C(n - i - 1, k - 1) % mod) %= mod;
    }

    cout << ans;

    return 0;
}


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

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	double a, b;
	cin >> a >> b;
	cout << ceil((b-1)/(a-1)) << endl;
	return 0;
}

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

int main() {
	vector<int> arr(3);
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr.begin(), arr.end());
	if (arr[0] == 5 && arr[1] == 5 && arr[2] == 7) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}	
}


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

long long int n;
int main(){
  cin >> n;
  
  long long sum = 0;
  for(long long i=1;i*i<=n;i++){
    if (n % i == 0){
      long long div = n / i - 1;
      if (div <= i) break;
      sum += n / i - 1;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int ans = 0;
		ans += 10 - n%10;
		ans += (10 - n%100/10) * 10;
		ans += (10 - n/100) * 100;
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;

	int a[12] = { 0,2,0,1,0,1,0,0,1,0,1,0 };
	if (a[x - 1] == a[y - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    string n;
    bool ans=false;
    cin >> n;
    for(int i=0; i<n.size(); i++){
        if(n[i]=='7'){
            ans = true;
        }
    }

    if(ans==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3548