akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		while (scanner.hasNext()) {

			String[] numSet = input().split(" ");

			int a = Integer.parseInt(numSet[0]);
			int b = Integer.parseInt(numSet[1]);

			System.out.println(String.valueOf(a + b).length());

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26528
N = int(input())
a = [int(x) for x in input().split()]
Alice = 0
Bob = 0

for i in range(N):
  max_val = max(a)
  max_idx = a.index(max_val)
  
  if i % 2 == 0:
    Alice += max_val
  else:
    Bob += max_val
  del a[max_idx]

print(Alice - Bob)

Measured memory_bytes: 3060
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

vector<int> tree[100001];
ll dp1[100001], dp2[100001];
void solve2(int src, bool vis[], int m, ll par_ans)
{
    vis[src] = 1;
    dp2[src] = ((1+par_ans) * dp1[src]) % m;
    vector<ll> prefix, suffix;
    for(int child : tree[src])
    {
        if(!vis[child]){
        prefix.push_back(1 + dp1[child]);
        suffix.push_back(1 + dp1[child]);}
    }
    for(int i = suffix.size() - 2; i >= 0; i --)
    {
        suffix[i] = (suffix[i] * suffix[i+1]) % m;
    }
    for(int i = 1; i < prefix.size(); i ++)
    {
        prefix[i] = (prefix[i] * prefix[i-1]) % m;
    }
    int cno = 0;
    for(int child : tree[src])
    {
        if(!vis[child])
        {
            ll ways = (1 + par_ans);
            ways = (cno > 0) ? (ways * prefix[cno-1]) % m : ways;
            ways = (cno < suffix.size() - 1) ? (ways * suffix[cno+1]) %m : ways;
            solve2(child, vis, m, ways);
            cno++;
        }
    }
}

void solve1(int src, bool vis[], int m)
{
    vis[src] = 1;
    dp1[src] = 1;
    for(int child : tree[src])
    {
        if(!vis[child])
            {
                solve1(child, vis, m);
                dp1[src] = (dp1[src] * (1 + dp1[child]))%m;
            }
    }
}

int main() {
   int n,m; 
   cin >> n >>m;
   for(int i = 0; i < n-1; i++)
   {
       int u,v;
       cin >> u>> v;
       tree[u].push_back(v);
       tree[v].push_back(u);
   }
   bool vis[n+1];
   memset(vis, 0, sizeof vis);
   solve1(1, vis, m);
   memset(vis, 0, sizeof vis);
   solve2(1, vis, m, 0);
   for(int i = 1; i <= n; i++)
    cout<<dp2[i]<<'\n';
   return 0;
}


Measured memory_bytes: 25344
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

i = 10
for j in {a,b,c,d,e} :
  if i>j%10 and j%10>0 :
    i = j%10
  
ans = 0
if i!=0 :
  ans = 10-i
print (-(-a//10)*10+-(-c//10)*10+-(-b//10)*10+-(-d//10)*10+-(-e//10)*10-ans)

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

int h, w, n, a, b;
long long cnt[10];
set<pair<int, int>> black;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
 	cin >> h >> w >> n;
 	cnt[0] = (long long) (h-2) * (w-2);

 	for (int i = 0; i < n; i++) {
 		cin >> a >> b;
 		black.insert({a, b});
 		for (int j = max(1, a-2); j <= a; j++) {
 			for (int k = max(1, b-2); k <= b; k++) {
 				if (min(h, j+2) - j != 2 || min(w, k+2) - k != 2) {
					continue;
				}
 				int num = 0;
 				for (int l = j; l <= min(h, j+2); l++) {
 					for (int m = k; m <= min(w, k+2); m++) {
 						num += (black.count({l, m}));
 					}
 				}
 				cnt[num-1]--;
 				cnt[num]++;
 			}
 		}
 	}

 	for (int i = 0; i <= 9; i++) {
 		cout << cnt[i] << '\n';
 	}
 	
	return 0;
}

Measured memory_bytes: 4992
N = int(input())
A = list(map(int, input().split()))

if N == 0 and A[0] == 1:
  print(1)
  exit(0)
elif A[0] > 0:
  print(-1)
  exit(0)

X = [0] * (N+1)
X[-1] = A[-1]
for i in range(N,0,-1):
  X[i-1] = X[i] + A[i-1]
  
#print(X)

wk = 2
ans = 1
for i in range(1,N+1):
  
  #print(i,X[i])
  if 0 <= A[i] <= wk:
    ans += min(wk,X[i])
    wk -= A[i]
    wk *= 2
  else:
    print(-1)
    exit(0)
  
print(ans)

Measured memory_bytes: 20068
#include <iostream>
#include <cstdio>
const int MAXN = 100 ;
const int INF = 0x3f3f3f3f ;
using namespace std ;

int f[MAXN + 5][10 + 5] , p[MAXN + 5][10 + 5] , b[10 + 5] ;

int main ( ) {
	int n , Ans = -INF ;
	
	cin >> n ;
	
	for ( int i = 1 ; i <= n ; ++i )
		for ( int j = 1 ; j <= 10 ; ++j )
			cin >> f[i][j] ;
	
	for ( int i = 1 ; i <= n ; ++i )
		for ( int j = 0 ; j <= 10 ; ++j )
			cin >> p[i][j] ;
	
	b[10] = 1 ;
	
	while ( !b[0] ) {
		int tmp = 0 ;
		
		for( int i = 1 ; i <= n ; ++i ) {
			int sum = 0;
			for( int j = 1 ; j <= 10 ; ++j )
				if( f[i][j] && b[j] ) ++sum ;
			tmp += p[i][sum] ;
		}
		
		Ans=max ( Ans , tmp ) ;
		
		int k = 10 ;
		
		while ( b[k] )
			b[k--] = 0 ;
		
		b[k] = 1 ; 
	}
	
	cout << Ans << endl ;
	
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
  int x[10000], y[10000], i, count=0;;
  for (i=0; i<=3000; i++) {
    cin >> x[i+1] >> y[i+1];
    if (x[i+1]==0 && y[i+1]==0) {break;
    }
    count++;
  }
  for (i=0; i<count; i++) {
    if (x[i+1] <= y[i+1]) {
      cout << x[i+1] << " " << y[i+1] << endl;
    } else {
      cout << y[i+1] << " " << x[i+1] << endl;
    }
  }
return 0;
}

Measured memory_bytes: 3008
def bfs(maze):
    d = [[0] * 70 for i in range(70)]
    d[1][1] = 1
    que = [(1, 1)]
    while 0 < len(que):
        new_que = []
        for x, y in que:
            if x == 2 * w - 1 and y == 2 * h - 1:
                return d[y][x]
            for dx, dy in ((0, 1), (-1, 0), (0, -1), (1, 0)):
                mx, my = x + dx, y + dy
                nx, ny = mx + dx, my + dy
                if nx < 0 and w < nx and ny < 0 and h < ny:
                    continue
                if maze[my][mx] == 0 and d[ny][nx] == 0:
                    new_que.append((nx, ny))
                    d[ny][nx] = d[y][x] + 1
        que = new_que
    return 0

while True:
    w, h = map(int, input().split())
    maze = [[0] * (w * 2 + 1) for i in range(h * 2 + 1)]
    if w == h == 0:
        break
    for x in range(w * 2 + 1):
        maze[0][x] = maze[h * 2][x] = 1
    for y in range(h * 2 + 1):
        maze[y][0] = maze[y][w * 2] = 1

    for y in range(1, h * 2):
        a = [int(i) for i in input().split()]
        if y % 2 == 1:
            for x in range(w - 1):
                maze[y][2 * x + 2] = a[x]
        else:
            for x in range(w):
                maze[y][2 * x + 1] = a[x]

    print(bfs(maze))

Measured memory_bytes: 7796
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n,m;
	cin>>n>>m;

	lli sum=0;
	map<lli,lli> d;
	d[0]++;
	REP(i,0,n){
		lli tmp;
		cin>>tmp;
		sum += tmp;
		d[sum%m]++;
	}

	lli ans=0;
	for(auto e:d){
		lli num = e.second;
		ans += num*(num-1)/2;
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>
int main(void)
{
   int S,h,m,s;
   scanf("%d",&S);
   if(S<60){
   printf("0:0:%d\n",S);
   }
   else if(S<3600){
       m=S/60;
       s=S%60;
    printf("0:%d:%d\n",m,s);
   }
   else {
       h=S/3600;
       m=S%3600;
       s=m%60;
       m=m/60;

       printf("%d:%d:%d\n",h,m,s);

   }
    return 0;
}

Measured memory_bytes: 592
import numpy as np
N,K = map(int,input().split())
R,S,P = map(int,input().split())
Ts = np.array(list(str(input())))
T = np.zeros(N,dtype=int)

T[Ts=='r'] = P
T[Ts=='s'] = R
T[Ts=='p'] = S
for i in range(K, N):
    if Ts[i]==Ts[i-K] and T[i-K]!=0:
        T[i] = 0

print(np.sum(T))

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

int main() {
    unsigned long N;
    unsigned long trans[5];
    unsigned long min_trans;
    unsigned long time;
    cin >> N;
    for (int i = 0; i < 5; ++i) {
        cin >> trans[i];
    }

    min_trans = N;
    for (int i = 0 ; i < 5; ++i) {
        min_trans = min(min_trans, trans[i]);
    }

    time = 4 + N / min_trans;
    if (N % min_trans != 0) time++;
    cout << time << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
ans = 0
memo = {}
for i in range(1, n + 1):
    i = str(i)
    if (i[-1], i[0]) not in memo:
        memo[(i[-1], i[0])] = 1
    else:
        memo[(i[-1], i[0])] += 1
for i in range(1, n + 1):
    i = str(i)
    if (i[0], i[-1]) in memo:
        ans += memo[(i[0], i[-1])]
print(ans)


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

/* -128 ~ 127 */
using i8  = int8_t;
/* 0 ~ 255 */
using u8  = uint8_t;
/* -32,768 ~ 32,767 */
using i16 = int16_t;
/* 0 ~ 65,535 */
using u16 = uint16_t;
/* -2,147,483,648 ~ 2,147,483,647 */
using i32 = int32_t;
/* 0 ~ 4,294,967,295 */
using u32 = uint32_t;
/* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using i64 = int64_t;
/* 0 ~ 18,446,744,073,709,551,615 */
using u64 = uint64_t;
/* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f32 = float;
/* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f64 = double;
using f80 = __float80;

template <class T>
using Vec = vector<T>;

template <typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

/* 定数 */
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define fn auto
#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) // 最大公約数
#define LCM(a, b) a / __gcd(a, b) * b // 最小公倍数

class PrimeList {
  private:
    u64 max;
    Vec<u64> vals;
    Vec<bool> is_prime;
  public:
    PrimeList(u64 val): max(val), is_prime(val + 1, true) {
        is_prime[0] = false; is_prime[1] = false;
        for(int i = 4; i <= max; i += 2) is_prime[i] = false;
        for(int i = 3; i * i <= max; i += 2) {
            if(!is_prime[i]) continue;
            for(int j = 3; i * j <= max; j += 2)
                if(is_prime[i * j]) is_prime[i * j] = false;
        }
        for (int i = 0; i <= max; i++) if (is_prime[i]) vals.push_back(i);
    }
    bool exists(u64 x) const { return is_prime[x]; }
    u64 size() const noexcept { return (u64)vals.size(); }
    u64 range_max() const noexcept { return max; }
    u64 operator[](u64 index) const { return vals[index]; }
    decltype(vals)::const_iterator begin() const noexcept { return vals.cbegin(); }
    decltype(vals)::const_iterator end() const noexcept { return vals.cend(); }
};

void Main() {
    u32 Q;
    cin >> Q;
    PrimeList p(10e5);
    Vec<u32> a(10e5, 0);
    for (int i = 0; i < 10e5; i++) {
        if (i % 2 == 0) continue;
        if (p.exists(i) && p.exists((i + 1) / 2)) a[i] = 1;
    }
    Vec<u32> s(10e5 + 1, 0);
    for (int i = 0; i < 10e5; i++) {
        s[i + 1] = s[i] + a[i];
    }
    for (int i = 0; i < Q; i++) {
        u32 l, r;
        cin >> l >> r;
        r++;
        cout << s[r] - s[l] << endl;
    }
}

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




Measured memory_bytes: 9332
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define ull unsigned long long
#define vc vector
#define SQ(j) (j)*(j)
#define ch first
#define range second
//
//#define ld long double
#define dbl  double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define sz(xxx) ((int)(xxx.size()))
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

//#define printf(...) (0)
#define db(x) if(DEBUG) {cout << #x << " = " << x << endl;}
#define dbCont(x) if(DEBUG) {cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;}

using namespace std;

template<class K, class V>
ostream &operator<<(ostream &out, pair<K, V> &elem) {
    out << "{" << elem.first << "," << elem.second << "}";
    return out;
}


int DEBUG = 0;

using namespace std;



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

    s[0]++;
    cout << s << endl;
    return 0;
}

/*

7
1 0 0 5 0 0 2

 */

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

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(a==1&&b==2){
		cout<<3;
	}
	else if(a==1&&b==3){
		cout<<2;
	}
	else if(a==2&&b==3){
		cout<<1;
	}
	else if(a==3&&b==2){
		cout<<1;
	}
	else if(a==3&&b==1){
		cout<<2;
	}
	else if(a==2&&b==1){
		cout<<3;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



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

  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  a--, b--, c--, d--;
  
  FOR(i, a, c) {
    if (s[i] == '#' && s[i + 1] == '#') {
       cout << "No\n";
       return 0;
    }
  }
  FOR(i, b, d) {
    if (s[i] == '#' && s[i + 1] == '#') {
       cout << "No\n";
       return 0;
    }
  }
  if (c > d) {
    bool f = false;
    FOR(i, b, d + 1) {
      if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
        f = true;
        break;
      }
    }
    if (!f) {
       cout << "No\n";
       return 0;
    }
  }
  cout << "Yes\n";





  
  return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int n=in(),i,j;
	char s[101],t[101];
	chin(s);
	chin(t);
	rep(i,n){
		for(j=0;j+i<n;j++)if(s[i+j]!=t[j])break;
		if(j+i==n)break;
	}
	print(n+i);
	return 0;
}

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

int main() {
  long long N;
  long long ans = 0;
  cin >> N;
  for (int i=1; i<=N; i++) {
    if (i%3 != 0 && i%5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 3624
function Main(input) {
	input = input.split("\n");


    const num = Number(input[0]);

    if (input[1].length > num) {
         console.log(input[1].substr( 0, num ) + '...');
    } else {
        console.log(input[1]);
    }
}

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

Measured memory_bytes: 29596
#include <stdio.h>
#include <string.h>

int main(void){
    int N;
    int X;
    int sum = 0;
    int min;
    double result;
    int kekka;

    

    scanf("%d %d",&N,&X);
    if(N < 2 || N > 100){
        return 0;
    }
    

    int m[101];

    for(int i = 0; i < N; i++){
        scanf("%d",&m[i]);
        if(m[i] < 1 || m[i]>1000){
            return 0;
        }
    }

	min = m[0];
    for(int i = 0; i < N; i++){
        if(m[i] <= min){
            min = m[i];
        }
    }

    for(int i= 0;i < N; i++){
        sum = sum + m[i];
    
    }

    if(sum <= X){
       result = (X - sum) / min;
  
    }else{
        return 0;
    }
    kekka = (int)result + N;
     printf("%d\n",kekka);
    }

Measured memory_bytes: 128
#include <iostream>
using std::cin;
using std::cout;

inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)
  
  const auto insertion_sort = [&](unsigned gap){
    unsigned count = 0;
    for(unsigned i = gap; i < n; i++){
      unsigned v = a[i];
      int j = i - gap;
      while(j >= 0 && a[j] > v){
        a[j+gap] = a[j];
        j -= gap;
        count++;
      }
      a[j+gap] = v;
    }
    return count;
  };

  unsigned gap_num = 11, count = 0;
  while(gaps[--gap_num] > n);

  for(int i = gap_num; i >= 0; i--) count += insertion_sort(gaps[i]);

  cout << (gap_num+1) << '\n';

  for(; gap_num; gap_num--) cout << gaps[gap_num] << ' ';
  cout << gaps[0] << '\n';

  cout << count << '\n';
}

int main(){
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  unsigned n,i;
  cin >> n;
  auto a = new unsigned[n];
  for(i = 0; i < n; i++) cin >> a[i];
  shell_sort(a,n);
  for(i = 0; i < n; i++) cout << a[i] << '\n';
  delete[](a);
}

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

int main() {
  int N, X;
  int j = 1;
  X = 0;
  cin >> N;
  for(int i = 0; i < 8; i++){
    X += (N/j)%10;
    j *= 10;
  }
  if(N%X == 0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }

}

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

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

  multimap<int,int> m;
  int a, b;
  for(int i = 0; i < M; ++i){
    cin >> a >> b;
    m.emplace(make_pair(b, a));
  }

  int x = 0;
  int ans = 0;
  for(const auto& e : m){
    if(x <= e.second){
      x = e.first;
      ++ans;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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;
typedef pair<int,int> P;

int n;
int a[3005];
ll dp[3005][3005];

int main(){
    cin >> n;
    rep(i,n)cin >> a[i];
    for(int i=0;i<=n;i++)dp[i][i]=0;
    for(int w=1;w<=n;w++){
        for(int l = 0;l+w<=n;l++){
            int r=l+w;
            if(w%2==n%2)dp[l][r]=max(dp[l+1][r]+a[l],dp[l][r-1]+a[r-1]);
            else dp[l][r]=min(dp[l+1][r]-a[l],dp[l][r-1]-a[r-1]);
        }
    }
    //rep(i,n)rep(j,n)cout << dp[i][j] << endl;
    cout << dp[0][n] << endl;
}

Measured memory_bytes: 70016
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int p[1100][2100];

int main() {
	int H, W, d;
	cin >> H >> W >> d;

		int off = (d-1)/2 ;
		int cnt = d % 2 ? 1 : 2;
		int i = 0;
		while(cnt <= d) {
			rep(j,cnt) {
				p[i][off+j] = 2;
			}
			rep(j,cnt)
				p[i][off+j+d] = 3;
			cnt += 2;
			i++;
			off--;
		}
		cnt -= 2;
		off++;
		i--;
		while(cnt > 0) {
			cnt -= 2;
			off++;
			i++;
			if(cnt < 0) break;
			rep(j,cnt)
				p[i][off+j] = 2;
			rep(j,cnt)
				p[i][off+j+d] = 3;
		}

		rep(i,d) {
			rep(j,d*2) {
				if(!p[i][j]) {
					int t;
					t = (i < d/2) ? 1 : 0;
					if(j < d/2 || d+d/2 <= j) t = !t;
					p[i][j] = t;
				}
			}
		}

	string s = "RYGB";
	rep(i,H) {
		rep(j,W) {
			int a = 0;
			cout << s[p[i % d][j % (2*d)] ^ ((i / d) % 2)];
		}
		cout << endl;
	}
	return 0;
}


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

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

    sort(a.begin(), a.end());
    int min_num = a[0];
    int min_amari = a[0];
    int min_amari_index = 0;

    while (min_num != 1 && a[n - 2] != 0)
    {
        for (auto i = min_amari_index+1; i < n; i++)
        {
            a[i] = a[i] % min_amari;
        }
        sort(a.begin(), a.end());
        for (auto i = 0; i < n; i++)
        {
            if(a[i] != 0){
                min_amari = a[i];
                min_amari_index = i;
                break;
            }
        }
        
    }


    if(min_amari == 1){
        cout << 1 << endl;
    }else{
        cout << a[n-1] << endl;
    } 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long n,m,s,t,tot,ans,u,v,d,a[200001],b[200001],c[200001],head[100001],nxt[400001];
long long mod=1e9+7,to[400001],w[400001],dis1[100001],dis2[100001],g1[100001],g2[100001];
bool v1[100001],v2[100001];
inline long long read()
{
   long long sum=0,x=1;
   char ch=getchar();
   while (ch<'0'||ch>'9')
   {
       if (ch=='-')
	     x=-1;
	   ch=getchar();
   }
   while (ch>='0'&&ch<='9')
   {
   	   sum=sum*10+ch-'0';
	   ch=getchar();
   }
   return sum*x;
}
inline void write(long long x)
{
    if (x<0)
	{
        putchar('-');
        x=-x;
    }
    if (x>9)
      write(x/10);
    putchar(x%10+'0');
    return;
}
inline void add(int u,int v,int d)
{
    nxt[++tot]=head[u];
	to[tot]=v;w[tot]=d;
	head[u]=tot;
}
inline void dijkstra(long long*d,long long*g,bool*v,int s)
{
    priority_queue<pair<long long,int>,vector<pair<long long,int> >,greater<pair<long long,int> > >q;
	d[s]=0ll;
    q.push(pair<long long,int>(0ll,s));
    g[s]=1;
    while (!q.empty())
	{
        pair<long long,int>sr=q.top();
		q.pop();
        int u=sr.second;
		long long du=sr.first;
        if (v[u]||d[u]<du)
		  continue;
        v[u]=1;
        for (register int i=head[u];i;i=nxt[i])
		{
            if (d[to[i]]==du+w[i])
              g[to[i]]=(g[to[i]]+g[u])%mod;
            if (d[to[i]]>du+w[i])
            {
            	g[to[i]]=g[u];
                d[to[i]]=du+w[i];
				q.push(pair<long long,int>(d[to[i]],to[i]));
			}
        }
    }
}
int main()
{
    n=read();m=read(); 
    s=read();t=read();
    for (register int i=1;i<=m;++i)
    {
        u=read();v=read();d=read();
        add(u,v,d);
        add(v,u,d);
        a[i]=u;b[i]=v;c[i]=d;
	}
    memset(dis1,127,sizeof(dis1));
	memset(dis2,127,sizeof(dis2));
    dijkstra(dis1,g1,v1,s);
    dijkstra(dis2,g2,v2,t);
    long long dis=dis1[t];
    ans=g1[t]*g1[t]%mod;
    for (register int i=1;i<=n;++i)
      if (dis1[i]+dis2[i]==dis&&dis1[i]==dis2[i])
        ans=(ans-g1[i]*g1[i]%mod*g2[i]%mod*g2[i]%mod)%mod;
    for (register int i=1;i<=m;++i)
	{
        u=a[i];v=b[i];d=c[i];
        if (dis1[u]+d+dis2[v]==dis&&dis1[u]+d>dis2[v]&&dis2[v]+d>dis1[u])
          ans=(ans-g1[u]*g2[v]%mod*g1[u]%mod*g2[v]%mod)%mod;
        u=b[i],v=a[i],d=c[i];
        if (dis1[u]+d+dis2[v]==dis&&dis1[u]+d>dis2[v]&&dis2[v]+d>dis1[u])
          ans=(ans-g1[u]*g2[v]%mod*g1[u]%mod*g2[v]%mod)%mod;
    }
    write((ans%mod+mod)%mod);
    return 0;
}

Measured memory_bytes: 24732
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

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

    map<string, int> s;
    for (int i = 0; i < n; i++) {
        string si;
        cin >> si;
        s[si]++;
    }

    int c = 0;
    for (map<string, int>::iterator i = s.begin(); i != s.end(); i++) {
        c = max(c, i->second);
    }

    for (map<string, int>::iterator i = s.begin(); i != s.end(); i++) {
        if (i->second == c) {
            cout << i->first << endl;
        }
    }
}


Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

// 0:A 1:T 2:G 3:C
int main(){
  int n;

  cin >> n;

  long long dp[101][4][4][4];
  REP(i,101){
    REP(j,4){
      REP(k,4){
        REP(l,4){
          dp[i][j][k][l] = 0;
        }
      }
    }
  }

  REP(j,4){
    REP(k,4){
      REP(l,4){
        if ((j == 0 && k == 2 && l == 3) || (j == 0 && k == 3 && l == 2) || (j == 2 && k == 0 && l == 3)) {
          continue;
        }
        dp[3][j][k][l] = 1;
      }
    }
  }

  for (int i = 4; i <= 100; i++) {
    REP(j,4){
      REP(k,4){
        REP(l,4){
          REP(m,4){
            if(j == 0 && k == 2 && l == 3) continue;
            if(j == 0 && k == 3 && l == 2) continue;
            if(j == 2 && k == 0 && l == 3) continue;
            if(k == 0 && l == 2 && m == 3) continue;
            if(k == 0 && l == 3 && m == 2) continue;
            if(k == 2 && l == 0 && m == 3) continue;
            if(j == 0 && k == 2 && m == 3) continue;
            if(j == 0 && l == 2 && m == 3) continue;
            dp[i][k][l][m] += dp[i-1][j][k][l];
            dp[i][k][l][m] %= 1000000007;
          }
        }
      }
    }
  }

  long long ans = 0;
    REP(j,4){
      REP(k,4){
        REP(l,4){
          ans += dp[n][j][k][l];
        }
      }
    }

  cout << ans%1000000007 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <numeric>
#include <iomanip>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, k;
string s;
vector<string> vs;
map<string, int> mp;
bool used[11];

void solve(int i,string t){
	if (i == k){
		mp[t]++;
		return;
	}

	REP(j, vs.size()){
		if (used[j] == 0){
			used[j] = 1;
			solve(i + 1, t + vs[j]);
			used[j] = 0;
		}
	}
}

int main(){
	while (cin >> n >> k&&n+k){
		fill(used, used + 11, 0);
		mp.clear();
		vs.clear();
		REP(i, n){
			cin >> s;
			vs.push_back(s);
		}
		solve(0, "");
		//cout << endl;
		//map<string, int>::iterator it = mp.begin();
		//while (it != mp.end()){
		//	cout << (*it).first << endl;
		//	it++;
		//}
		cout << mp.size() << endl;
	}
}

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

int main(){
	int n;
	scanf("%d",&n);

	int* b = new int[n-1];
	for(int i=0;i<n-1;i++){
		scanf("%d",&b[i]);
	}

	int* a = new int[n];
	a[0] = b[0];
	a[n-1] = b[(n-1)-1];
	for(int i = 1;i<n-1;i++){
		if(b[i-1]>b[i]){
			a[i] = b[i];
		}else{
			a[i] = b[i-1];
		}
	}

	int sum = 0;
	for (int i=0;i<n;i++){
		sum += a[i];
	}

	printf("%d",sum);
	return 0;

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	a, b := readI(), readI()
	ar, br := make([]rune, b), make([]rune, a)
	for i := 0; i < b; i++ {
		ar[i] = rune(a) + '0'
	}
	for i := 0; i < a; i++ {
		br[i] = rune(b) + '0'
	}

	as, bs := string(ar), string(br)
	if as > bs {
		fmt.Println(bs)
	} else {
		fmt.Println(as)
	}

}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


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

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

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

const int MX = 4000100;

int N;
int A[2010];
int S;

int main() {
	cin >> N;

	rep(i, N) {
		cin >> A[i];
		S += A[i];
	}

	bitset<MX> T;
	T.set(0);

	rep(i, N) {
		T |= T << A[i];
	}

	rep(i, MX) {
		if (i * 2 >= S && T[i]) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 2300
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 + 100;
vector<pair<ll, ll>> bst[SIZE];
vector<ll> pref;

int main()
{
    fastInp;

    ll n, m;
    cin >> n >> m;
    vector<ll> vec(n), pref(m * 2 + 1), inc(m * 2), val(m * 2);
    ll s = 0;
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
        --vec[i];
    }

    for (int i = 1; i < n; i++) {
        ll u = vec[i], v = vec[i - 1];
        if (u < v) u += m;

        s += (u - v);
        inc[v + 1]++;
        pref[u + 1] -= (u - v - 1);
        inc[u]--;
    }

    ll ans = s;
    ll cur = 0, curInc = 0;

    for (int i = 0; i < m * 2; i++) {
        cur += curInc;
        cur += pref[i];
        curInc += inc[i];
        val[i % m] += cur;
        if (i >= m) {
            ans = min(ans, s - val[i % m]);

        }
    }

    cout << ans;
    return 0;    
}

Measured memory_bytes: 32188
def main():

    n,m = map(int,input().split())
    a = []
    for i in range(n):
        aa = list(input())
        a.append(aa)
    b = []
    for i in range(m):
        bb = list(input())
        b.extend(bb)

    for i in range(n-m+1):
        for j in range(n-m+1):
            tmp_a = []
            for k in range(i,i+m):
                tmp_a.extend(a[k][j:j+m])
            # print('-----------')
            # print(i,j)
            # print(tmp_a)
            if b == tmp_a:
                print('Yes')
                return
    print('No')

if __name__ == '__main__':
    main()


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

int main(void)
{
    string a, b;
    cin >> a >> b;

    string s = a + b;
    // cout << s << endl;
    int num = stoi(s);

    int sqrt_num = sqrt(num);
    // cout << sqrt_num << endl;
    if (sqrt_num * sqrt_num == num)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>

using namespace std;

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

	vector<int> a(n);
	int oddNum = 0, evenNum = 0;


	for (auto& i : a) {
		cin >> i;
		if (i % 2 == 0)evenNum++;
		else oddNum++;
	}
	
	evenNum += oddNum / 2;
	oddNum %= 2;
	evenNum = min(evenNum, 1);

	if (oddNum + evenNum == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}





	return 0;

}




Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct Node{
  int key;
 struct  Node *next,*prev;
}Node;
Node *nil;

Node* listSearch(int key){
  Node *cur=nil->next;//?????????????????????
  while(cur!=nil&& cur->key!=key){//????????????????????§
    cur= cur->next;
  }
  return cur;
}
void init(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}
void deleteNode(Node *p){
  if(p==nil)return;
  p->prev->next=p->next;
  p->next->prev=p->prev;
  free(p);
}
void deleteLast(){
  deleteNode(nil->prev);
}
void deleteFirst(){
  deleteNode(nil->next);
}
void deleteKey(int key){
  deleteNode(listSearch(key));
}
void printList(){
  Node *cur=nil->next;
  int i;
  for(i=0;cur!=nil;cur=cur->next,i++){
    if(i)printf(" ");
    printf("%d",cur->key);
}
  printf("\n");
}

void insert(int key){
  Node *x=(Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
int main(){
  int n,i,key;
  char command[20];
  scanf("%d",&n);
  init();////
  for(i=0;i<n;i++){
    scanf("%s %d",command,&key);
    if(!strcmp(command,"insert"))insert(key);//if(i) i!=0
    else if(!strcmp(command,"deleteFirst"))deleteFirst();
    else if(!strcmp(command,"deleteLast"))deleteLast();
    else deleteKey(key);
  }
  printList();

  return 0;
}

Measured memory_bytes: 31788
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int main()
{
    long long n,k;
    cin>>n>>k;
    vector <long long> vect(n,0);
    for(int i=0;i<n;i++)
        cin>>vect[i];
    long long count1=0,count2=0;
    for(int i=0;i<n;i++)
    {
        long long a=vect[i];
        for(int j=i+1;j<n;j++)
        {
            if(a>vect[j])
                count1++;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(vect[i]>vect[j])
                count2++;
        }
    }
    long long count3=(k*count1)%mod;
    long long a=(k*(k-1)/2)%mod;
    a=(count2*a)%mod;
    cout<<(count3+a)%mod;
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

D, G = map(int, readline().split())
problems = []
for i in range(1, D+1):
    p, c = map(int, readline().split())
    score = 100 * i
    problems.append({
        "score": score,
        "number": p,
        "bonus": c,
        "sum": score * p + c
    })

keta = len(problems)
answer = float("inf")
for i in range(0, 2 ** D):
    bits = list(str(format(i, "0{}b".format(keta))))
    sum_number = 0
    sum_score = 0
    half_index = None
    for j, is_full in enumerate(bits):
        if is_full == "1":
            sum_number += problems[j]["number"]
            sum_score += problems[j]["sum"]
        else:
            half_index = j
    if half_index is None:
        if sum_score >= G:
            answer = min(answer, sum_number)
        continue
    for _ in range(problems[half_index]["number"]):
        if sum_score >= G:
            break
        sum_score += problems[half_index]["score"]
        sum_number += 1
    if sum_score >= G:
        answer = min(answer, sum_number)

print(answer)

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

const int N = 2005;
int n , m;
char str[N][N];
int a[N][N] , b[N][N] , res;
int L[N] , R[N] , h[N] , s[N] , top;

int main() {
    scanf("%d%d" , &n , &m);
    res = max(n , m);


    for (int i = 0 ; i < n ; ++ i) {
        scanf("%s" , str[i]);
        for (int j = 0 ; j < m ; ++ j) {
            a[i][j] = (str[i][j] == '#');
        }
    }

    for (int i = 0 ; i < n ; ++ i) {
        for (int j = 0 ; j + 1 < m ; ++ j) {
            a[i][j] ^= a[i][j + 1];
        }
    }
    -- m;

    for (int i = 0 ; i < n ; ++ i) {
        for (int j = 0 ; j < m ; ++ j) {
            if (i == 0 || a[i][j] == a[i - 1][j]) {
                ++ h[j];
            } else {
                h[j] = 1;
            }
        }
        for (int j = 0 ; j < m ; ++ j) {
            while (top && h[s[top]] > h[j]) {
                R[s[top --]] = j;
            }
            s[++ top] = j;
        }
        while (top) R[s[top --]] = m;
        for (int j = m - 1 ; j >= 0 ; -- j) {
            while (top && h[s[top]] >= h[j]) {
                L[s[top --]] = j;
            }
            s[++ top] = j;
        }
        while (top) L[s[top --]] = -1;
        for (int j = 0 ; j < m ; ++ j) {
            res = max(res , (h[j]) * (R[j] - L[j]));
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 21248
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    int a[n+5];
    for(int i=0;i<n;i++)
    cin>>a[i];
    long long total=0;
    for(int i=0;i<n;i++)
    total=total^a[i];
    for(int i=0;i<n;i++)
    {
        int k=total^a[i];
        cout<<k<<" ";
    }
    return 0;
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int a,b; cin>>a>>b;
  int ans;
  if (a%b==0) {
    ans = 0;
  } else {
    ans = 1;
  }
  cout << ans << endl;
}


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

int main() {
  int n; cin >> n;
  cout << n << ':';
  for (int i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      cout << ' ' << i;
      n /= i;
    }
  }
  if (n != 1) cout << ' ' << n;
  cout << endl;
  return 0;
}



Measured memory_bytes: 3108
n, k = map(int, input().split())
cums = [0] * (n + 1)
cums[0] = 1
MOD = 1000000007
for i in range(1, n + 1):
    cums[i] = ((n + n - i + 1) * i) // 2 - ((i - 1) * i) // 2 + 1
ans = 0
for i in range(k, n + 1):
    ans = (ans + cums[i]) % MOD
ans = (ans + 1) % MOD
print(ans)


Measured memory_bytes: 19776
fun main(args: Array<String>) {
    val a = Array(3) { listOf<Int>() }

    a[0] = readIntList()
    a[1] = readIntList()
    a[2] = readIntList()

    val n = readInt()
    //val b = List(n) { readInt() }
    val b = mutableListOf<Int>()
    repeat(n) {
        b.add(readInt())
    }
    if (
        b.containsAll(a[0]) || b.containsAll(a[1]) || b.containsAll(a[2]) ||
        b.containsAll(listOf(a[0][0], a[1][0], a[2][0])) ||
        b.containsAll(listOf(a[0][1], a[1][1], a[2][1])) ||
        b.containsAll(listOf(a[0][2], a[1][2], a[2][2])) ||
        b.containsAll(listOf(a[0][0], a[1][1], a[2][2])) ||
        b.containsAll(listOf(a[0][2], a[1][1], a[2][0]))
    ) println("Yes")
    else println("No")

}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

int main()
{

	int n,m;
	cin >> n >> m;
	vector<int> h(n+1);
	for (int i=1;i<=n;++i)
	{
		cin >> h[i];
	}

	vector<vector<int>> road(n+1);
	for (int i=1;i<=m;++i)
	{
		int a,b;
		cin >> a >> b;
		road[a].push_back(b);
		road[b].push_back(a);
	}

	int good=0;
	for (int i=1;i<=n;++i)
	{
		int size=road[i].size();
		int j;
		for (j=0;j<size;++j)
		{
			if (h[i]<=h[road[i][j]])
			{
				break;
			}
		}
		if (j>=size)
		{
			++good;
		}
	}
	cout << good << endl;
}






Measured memory_bytes: 8804
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val x = sc.nextInt()
    val y = sc.nextInt()

    var xc = mutableSetOf(0)
    var yc = mutableSetOf(0)

    var dirX = true
    var canLeft = false

    var fcount = 0
    s.forEachIndexed { i, c ->
        if (c == 'T') {
            canLeft = canLeft || !dirX
            dirX = !dirX
            return@forEachIndexed
        }

        fcount += 1
        if (s.length > i + 1 && s[i + 1] == 'F') {
            return@forEachIndexed
        }

        if (dirX) {
            val nxc = hashSetOf<Int>()
            xc.forEach {
                nxc += it + fcount
                if (canLeft) nxc += it - fcount
            }
            xc = nxc
        } else {
            val nyc = hashSetOf<Int>()
            yc.forEach {
                nyc += it + fcount
                nyc += it - fcount
            }
            yc = nyc
        }
        fcount = 0
    }

    println(if (x in xc && y in yc) "Yes" else "No")
}

Measured memory_bytes: 112844
N,K = list(map(int,input().split()))
MOD = 10**9+7

A = [i for i in range(N+1)]
tmp = sum(A[-K:]) - sum(A[:K]) + 1
ans = tmp

for i in range(K+1,N+2):
    tmp += A[-i] - A[i-1]
    ans += tmp
    ans %= MOD
print(ans)

Measured memory_bytes: 18472
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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

const ll mod = 998244353;





int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] != s[s.size()-i-1]){
            s[s.size()-i-1] = s[i];
            ans ++;
        }
    }

    cout << ans <<endl;

    return 0;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
	int D; cin >> D; 
	int C[30] = {}; 
	for(int i = 1; i <= 26; i++) cin >> C[i]; 
	int S[370][30] = {}; 
	for(int i = 1; i <= D; i++){
		for(int j = 1; j <= 26; j++){
			cin >> S[i][j]; 
		}
	}
	int ans[370] = {}; 
	int L[30] = {}; 
	for(int i = 1; i <= D; i++){
		int E[30] = {}; 
		for(int j = 1; j <= 26; j++){
			E[j] = S[i][j] + C[j] * (i - L[j]); 
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 26; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = a; L[a] = i; 
	}
	for(int i = 1; i <= D; i++) cout << ans[i] << endl; 
}

Measured memory_bytes: 3676
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail+1)%LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head+1)%LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b;}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);

    for(i = 1; i <= n; i++) { 
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n+1;

    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) enqueue(u);
        else{
            printf("%s %d\n",u.name, elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 11860
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(begin(x), end(x)), end(x))
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool isin(const T& x, const T& l, const T& r){ return l <= x and x < r; }
inline ostream& fcout(int n = 10){ return cout << fixed << setprecision(n); }
inline ostream& rcout(int n = 2){ return cout << right << setw(n); }
constexpr int64_t INF = numeric_limits<int64_t>::max();
constexpr int32_t INF32 = numeric_limits<int32_t>::max();
constexpr int64_t MOD = 1000000007LL;
constexpr double PI = 3.14159265358979323846264338327950288;
constexpr double EPS = 1e-10;


int A, B, K;


int32_t main(){
    cin >> A >> B >> K;

    if(A >= K) cout << A-K << ' ' << B << endl;
    else if(B >= K-A) cout << 0 << ' ' << B-(K-A) << endl;
    else cout << 0 << ' ' << 0 << endl;

    return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	int sx, sy, tx, ty;
	scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
	
	//1回目行き
	string s = "";
	rep(ty-sy) s += "U";
	rep(tx-sx) s += "R";
	string s1(s);
	
	//1回目帰り
	rep((int)s1.length()){
		if(s1[i] == 'U'){
			s += "D";
		}else if(s1[i] == 'R'){
			s += "L";
		}
	}
	
	//2回目行き
	s += "LU";
	s += s1;
	s += "RD";
	
	//2回目帰り
	s += "RD";
	rep((int)s1.length()){
		if(s1[i] == 'U'){
			s += "D";
		}else if(s1[i] == 'R'){
			s += "L";
		}
	}
	s += "LU";
	
	
	cout << s;
	
}

Measured memory_bytes: 256
while True:
	surface = [list(raw_input()) for _ in range(0, 8)]

	surf = []
	for i in range(0, 8):
		if "1" in surface[i]:
			surf.append(surface[i])
	
	if len(surf) == 1 : print "C"
	else:
		if len(surf) == 2:
			x = surf[0].index("1")
			y = surf[1].index("1")
			if x - y == 0 : print "A"
			elif x - y == -1 : print "E"
			elif x - y ==  1 : print "G"
		elif len(surf) == 3:
			x = surf[0].index("1")
			y = surf[1].index("1")
			if x - y ==   1 : print "D"
			elif x - y == 0 : print "F"
		elif len(surf) == 4 : print "B"
		
	try:
		raw_input()
	except EOFError:
		break

Measured memory_bytes: 6296