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

using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        int i;
        int isok=1;
        for(i=0;i<n;i++)
        {
            int x;
            scanf("%d",&x);
            if(x%2==0)
            {
                if(x%3&&x%5)
                    isok=0;
            }
        }
        if(isok)
            printf("APPROVED\n");
        else
            printf("DENIED");
    }
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;


int main(){

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

  cout << ceil((double)(b-a)/(a-1))+1;
 
  return 0;
}


Measured memory_bytes: 256
/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp
 */

#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
#include <iterator>

void printVector(const std::vector<unsigned int> &v) {
  std::ostringstream oss;
  std::copy(v.begin(), v.end() - 1,
            std::ostream_iterator<unsigned int>(oss, " "));
  oss << v.back();
  std::cout << oss.str() << std::endl;
}

unsigned int Count = 0;

void merge(std::vector<unsigned int> &A, const unsigned int &left,
           const unsigned int &mid, const unsigned int &right) {
  unsigned int n1 = mid - left;  // 5 - 0
  unsigned int n2 = right - mid; // 9 - 6
  // L[0...n1], R[0...n2] ?????????
  std::vector<unsigned int> L(n1 + 1); // 0 1 2 3 4 MAX
  std::vector<unsigned int> R(n2 + 1); // 5 6 7 8 9 MAX

  for (size_t i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (size_t i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = std::numeric_limits<unsigned int>::max();
  R[n2] = std::numeric_limits<unsigned int>::max();
  unsigned int i = 0;
  unsigned int j = 0;
  for (size_t k = left; k < right; k++) {
    Count++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(std::vector<unsigned int> &A, const unsigned int &left,
               const unsigned int &right) {
  if (left + 1 < right) {
    unsigned int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(int argc, char const *argv[]) {
  std::string Param;
  std::istringstream Stream;
  unsigned int n = 0;

  getline(std::cin, Param);
  Stream.str(Param);
  Stream >> n;
  Stream.clear();

  std::vector<unsigned int> S(n);
  getline(std::cin, Param);
  Stream.str(Param);
  for (size_t i = 0; i < n; i++) {
    Stream >> S[i];
  }
  Stream.clear();

  mergeSort(S, 0, n);

  printVector(S);
  std::cout << Count << std::endl;
  return 0;
}

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

using namespace std;

int main(){

	int n, flag;
	int sum=0;
	vector<int> a;

	cin>> n;

	a.resize(n);

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

	while(1){
		flag=0;
		//for(int j=0;j<n;j++) cout<< a[j] << " " << endl;
		for(int i=0;i<n;i++){
			if(a[i]%2==0)	{
				a[i]/=2;
			}else{
				flag=1;
				break;
			}
		}
		if(flag==0){
			sum++;
			continue;
		}
		break;
	}

	cout<< sum << endl;

}
/*
struct xxxx{
	int x;
	int y;
	int num;

	bool operator<(const xxxx &in) const{
		return num<in.num;
	};
};
*/

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

const int N=1e5+30;
typedef long long ll;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define re register ll
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
inline void read(ll &res)
{
	res=0;
	re g=1;register char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
ll n,m;

int main()
{
	read(n);
	switch(n)
	{
		case 22:{cout<<"Christmas Eve Eve Eve";
			break;
		}
		case 23:{cout<<"Christmas Eve Eve";
			break;
		}
		case 24:{cout<<"Christmas Eve";
			break;
		}
		case 25:{cout<<"Christmas";
			break;
		}	
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) {
    cout << B << endl;
  }
  else if (A >= 6)  {
    cout << B / 2 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,M,ba[21][21],x,y,l,i,j,x2,y2,c;
  char d,k;



  while(1){

    //syokika
    x2=10;
    y2=10;
    c=0;
    for(i=0;i<21;i++){
      for(j=0;j<21;j++){
	ba[i][j]=0;
      }
    }

    //input isi
    scanf("%d",&N);
    c=N;
    if(N==0)break;
    for(i=0;i<N;i++){
      scanf("%d%d",&x,&y);
      ba[x][y]=1;
    }

    //input robot
    scanf("%d",&M);
    for(i=0;i<M;i++){
      scanf("%c%c %d",&k,&d,&l);

      if(d=='N'){
	while(l!=0){
	  y2=y2+1;
	  ba[x2][y2]*=2;
	  if(ba[x2][y2] == 2) c=c-1;
	  --l;

	}
      }
     else if(d=='E'){
	while(l!=0){
	  x2=x2+1;
	  ba[x2][y2]=ba[x2][y2]*2;
	  if(ba[x2][y2] == 2) c=c-1;
	  --l;

	}
      }
     else if(d=='W'){
	while(l!=0){
	  x2=x2-1;
	  ba[x2][y2]=ba[x2][y2]*2;
	  if(ba[x2][y2] == 2) c=c-1;
	  --l;

	}
      }
     else if(d=='S'){
	while(l!=0){
	  y2=y2-1;
	  ba[x2][y2]=ba[x2][y2]*2;
	  if(ba[x2][y2] == 2) c=c-1;
	  --l;

	}
      }
    }
    if(c==0) printf("Yes\n");
    else printf("No\n");
  }
 return 0;
}

Measured memory_bytes: 1012
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
if n == 1:
    print(0)
    quit()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
m = make_divisors(n)
res = m[:len(m)//2]
if n //(res[-1]-1) != n % (res[-1]-1):
    res[-1] = 1
print(sum(res) - len(res))

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

int main() {
  int n, k;
  string s;
  while ( cin >> n >> k >> s ) {
    int z = 0;
    int i = 0, j = 0;
    int answer = 0;
    while ( j < n ) {

      if ( s[j] == '1' ) { j++; }
      if ( s[j] == '0' ) {
        if ( k == 0 ) {
          while ( i < j && s[i] == '1' ) i++;
          while ( i < j && s[i] == '0' ) i++;
          k++;
        } else {
          while ( j < n && s[j] == '0' ) {
            j++;
          }
          k--;
        }
      }
      
      // cout << i << " " << j << " " << k << endl;
      int segment = j - i + 1 - (j == n);
      answer = max(answer, segment);
    }
    cout << answer << endl;

  }
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int n,m;
    cin >> n >> m;
    vector<string>s(n);

   for(int i = 0;i < n;i++){
       cin >> s[i];
   }
   sort(s.begin(),s.end());

   for(int i = 0;i < n;i++){
     cout << s.at(i);
   }

}
   

Measured memory_bytes: 256
s = input()
s_2 = s[2:-1]
c = 0 
f = 1

if s[0] == 'A': #条件1
    for i in range(len(s_2)): #条件2
        if s_2[i] in 'C':
            f = 1
            for j in range(len(s)):
                if s[j].isupper():
                    c += 1
                
            if c == 2: #条件3(大文字の個数が2の時で判別)
                print('AC')
            else:
                print('WA')
            break
        else:
            f = 0
            pass

else:
    print('WA')
    
if f == 0:
    print('WA')
                    
                


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<sstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define make_pair mkp;

const int maxn=1e4+10;

//分成两种情况讨论，一种不经过x,y，一种是经过x,y。。。
//int a[maxn];

int main(){
	int n,x,y,a,b,d;
	cin>>n>>x>>y;
	vector<ll>res(maxn,0);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			a=j-i;
			b=(x>i?x-i:i-x)+(y>j?y-j:j-y)+1;//加一表示的是x,y之间的距离
			d=min(a,b);//距离一定是选择最小的。。。
			res[d]++;
		}
	}
	for(int i=1;i<n;i++){
		cout<<res[i]<<endl;
	}
	return 0;

}

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

int main()
{
	int n, k;
	cin >> n >> k;
	unsigned long long int are = 0;
	unsigned long long int sore = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (i % k == 0)
		{
			++are;
		}
		if(k % 2 == 0 && i % k == k / 2)
		{
			++sore;
		}
	}
	cout << (unsigned long long int)(sore*sore*sore + are*are*are) << endl;
	return 0;
}


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

#define int long long
#define rr register

#define MAXN 200010
#define inf 1e18

using namespace std;

inline int read(int &T) {
    int s = 0, f = 0;
    char ch = getchar();
    while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
    while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
    return T = f ? -s : s;
}

void print(int x) {
    if (x < 0) x = -x, putchar('-');
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

int n;

string s;

signed main() {
    n = read(n);
    cin >> s;
    int len = s.length();
    for (rr int i = 0; i < (n > len ? len : n); i++)
        cout << s[i];
    if (len > n) cout << "...";
}   

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int T = cin.nextInt();
        int A = cin.nextInt();
        int[] H = cin.arrayInt();

        double min = 10000;
        int index = 0;
        for (int i = 0; i < N; i++)
        {
            double t = Math.Abs(T - H[i] * 0.006 - A);
            if (t < min)
            {
                min = t;
                index = i;
            }
        }
        Console.WriteLine(index + 1);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13204
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, stx, sty;
struct Edge {
	int to, next;
} edge[(N << 1) + 1];
int start[N + 1], tot;
int depa[N + 1], depb[N + 1], up[21][N + 1];
int xx[N + 1], yy[N + 1];
int ans;

inline void addedge(int u, int v)
{
	edge[++tot] = Edge{ v, start[u] };
	start[u] = tot;
	edge[++tot] = Edge{ u, start[v] };
	start[v] = tot;
	return;
}
inline void dfs1(int u, int fa)
{
	depa[u] = depa[fa] + 1;
	for (int i = start[u]; i; i = edge[i].next) {
		int v = edge[i].to;
		if (v != fa && depb[v] > depa[u] + 1)
			dfs1(v, u);
	}
	return;
}
inline void dfs2(int u, int fa)
{
	depb[u] = depb[fa] + 1;
	for (int i = 1; i <= 20; i++)
		up[i][u] = up[i - 1][up[i - 1][u]];
	for (int i = start[u]; i; i = edge[i].next) {
		int v = edge[i].to;
		if (v != fa) {
			up[0][v] = u;
			dfs2(v, u);
		}
	}
	return;
}
inline int lca(int x, int y)
{
	if (depb[x] > depb[y])
		swap(x, y);
	for (int i = 20; i >= 0; i--) {
		if (up[i][y] && depb[up[i][y]] >= depb[x])
			y = up[i][y];
		if (x == y)
			return x;
	}
	for (int i = 20; i >= 0; i--) {
		if (up[i][x] && up[i][x] != up[i][y]) {
			x = up[i][x];
			y = up[i][y];
		}
	}
	return up[0][x];
}
inline int dis(int x, int y)
{
	int llca = lca(x, y);

	return depb[x] + depb[y] - (depb[llca] << 1);
}
int main()
{
	n = read();
	stx = read();
	sty = read();
	for (int i = 1; i < n; i++) {
		xx[i] = read();
		yy[i] = read();
	}

	for (int i = 1; i < n; i++) {
		int a = read(), b = read();
		addedge(a, b);
	}
	dfs2(sty, 0);
	tot = 0;
	for (int i = 1; i <= n; i++)
		start[i] = 0;
	for (int i = 1; i < n; i++)
		addedge(xx[i], yy[i]);
	dfs1(stx, 0);

	for (int i = 1; i < n; i++) {
		if (dis(xx[i], yy[i]) > 2 && ((depa[xx[i]] < depb[xx[i]] && depa[xx[i]]) || (depa[yy[i]] < depb[yy[i]] && depa[yy[i]]))) {
			printf("-1\n");
			return 0;
		}
	}
	for (int i = 1; i <= n; i++)
		if (depa[i] < depb[i] && depa[i])
			ans = max(ans, depb[i] - 1);
	printf("%d\n", ans << 1);
	return 0;
}


Measured memory_bytes: 35428
#別解思考
n = int(input())
res = 0
for i in range(1, n // 2 +1):
    res += (int(n / i) * (i + int(n / i) * i)) // 2
res += (n + n // 2 +1) * (n - n // 2 ) //2
print(res)

Measured memory_bytes: 9116
n, k = map(int, input().split())
P = [int(x) for x in input().split()]
p_e = list()
exp = 0
for p in P:
    # 期待値
    # 累積和
    exp += (1+p)/2
    p_e.append(exp)  
# この後差を取るので
# n==kの時とそうでない時でやり方を分けないとだめ
if n == k:
    print(p_e[-1])
else:
    # 初期値
    maxv = p_e[k-1] - 0
    for i in range(1, n-k):
        # 隣接するk個の期待値の和
        p_sum = p_e[k+i] - p_e[i]
        maxv = max(maxv, p_sum)
    print(maxv)

Measured memory_bytes: 32000
package main

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

const (
	mod = int(1e9 + 7)
)

func main() {
	input := bufio.NewReader(os.Stdin)

	var S string
	fmt.Fscanf(input, "%s\n", &S)

	dp := make([][]int, 100001)
	for i := range dp {
		dp[i] = make([]int, 13)
	}

	dp[0][0] = 1
	for i := range S {
		if S[i] == '?' {
			for d := 0; d < 10; d++ {
				for j := 0; j < 13; j++ {
					dp[i+1][(j*10+d)%13] += dp[i][j]
				}
			}
		} else {
			d := int(S[i] - '0')
			for j := 0; j < 13; j++ {
				dp[i+1][(j*10+d)%13] += dp[i][j]
			}
		}
		for j := 0; j < 13; j++ {
			dp[i+1][j] %= mod
		}
	}
	fmt.Println(dp[len(S)][5])
}


Measured memory_bytes: 14592
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n;
  cin >> n;
  multiset<int> a;
  REP(i,n) {
    int b;
    cin >> b;
    a.insert(b);
  }


  ITR(itr, a){
    if(itr != a.begin()){
      if(*itr % *a.begin() == 0){
        a.erase(itr);
        if(a.size() == 1){
          break;
        }
      }
      else {
        a.insert(*itr % *a.begin());
        itr = a.begin();
      }
    }
  }

  cout << *a.begin() << endl;

  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    vector<ll> vec_copy(N);
    rep(i,N){
        vec_copy[i] = vec[i];
    }
    sort(all(vec_copy));
    vector<pair<ll,ll> > num(0);
    ll ans = 0;
    ll left = 0;
    ll right = 0;
    while(right < N){
        if (right == N - 1){
            if (vec_copy[right] != vec_copy[left]){
                ans += (right - left) * (right - left - 1) / 2;
                num.push_back(pair<ll,ll> (vec_copy[left], right - left));
                num.push_back(pair<ll,ll> (vec_copy[right], 1));
            }
            else{
                ans += (right - left + 1) * (right - left) / 2;
                num.push_back(pair<ll,ll> (vec_copy[left], right - left + 1));
            }
            right++;
        }
        else{
            if (vec_copy[right] != vec_copy[left]){
                ans += (right - left) * (right - left - 1) / 2;
                num.push_back(pair<ll,ll> (vec_copy[left] , right - left));
                left = right;
            }
            else{
                right++;
            }
        }
    }
    ll len_num = num.size();
    rep(i,N){
        ll left = 0;
        ll right = len_num - 1;
        if (num[left].first == vec[i]){
            ll number = num[left].second;
            cout << ans - number + 1 << endl;
        }
        else if (num[right].first == vec[i]){
            ll number = num[right].second;
            cout << ans - number + 1 << endl;
        }
        else{
            while(true){
                if (right - left == 1){
                    ll number = num[left].second;
                    cout << ans - number + 1 << endl;
                    break;
                }
                else{
                    if (num[(left + right) / 2].first <= vec[i]){
                        left = (left + right) / 2;
                    }
                    else{
                        right = (left + right) / 2;
                    }
                }
            }
        }
    }
}



Measured memory_bytes: 6896
#include<iostream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

const int N = 201000;
const int MOD = 1000000007;

int n, x, y, c[N], w[N], nr[N], wmin[N], wm1, wm2;

void calcnr() {
int i;
wm1 = wm2 = 1000000001;

    for(i = 1; i <= n; ++i) {
        if(w[i] + wmin[c[i]] <= x)
            w[i] = wmin[c[i]];
    }

    for(i = 1; i < N; ++i) if(wmin[i]) {
        if(wmin[i] < wm1) {
           wm2 = wm1;
           wm1 = wmin[i];
        }
        else
            wm2 = min(wm2, wmin[i]);
    }


    for(i = 1; i <= n; ++i) {
        int wm = wm1;
        if(wm1 == wmin[c[i]])
            wm = wm2;

        if(w[i] + wm <= y) {
            nr[c[i]]++;
        }
    }
}

int fact[N], inv[N];

int comb(int n, int k) {
    int r = (1LL * fact[n] * inv[n - k]) % MOD;
    r = (1LL * r * inv[k]) % MOD;

    return r;
}

int po(int el, int p) {
    int r = 1;

    while(p) {
        if(p & 1)
            r = (1LL * r * el) % MOD;
        el = (1LL * el * el) % MOD;
        p /= 2;
    }

    return r;
}

int invmod(int el) {
    return po(el, MOD - 2);
}

void pre() {
    int i;

    //cout << (1LL * 6 * invmod(6)) % MOD << "\n";

    fact[0] = 1;
    for(i = 1; i < N; ++i)
        fact[i] = (1LL * fact[i - 1] * i) % MOD;

    for(i = 0; i < N; ++i)
        inv[i] = invmod(fact[i]);
}

void calcrez() {
    pre();int i;

    int rez = 1, st = 0;

    for(i = 1; i < N; ++i) if(nr[i]) {
        st += nr[i];
        rez = (1LL * rez * comb(st, nr[i])) % MOD;
    }

    cout << rez;
}

int main() {
    int i;
    //freopen("ttt", "r", stdin);

    cin >> n >> x >> y;
    for(i = 1; i <= n; ++i) {
        scanf("%d%d", &c[i], &w[i]);
        if(!wmin[c[i]] || wmin[c[i]] > w[i])
            wmin[c[i]] = w[i];
    }

    calcnr();

    calcrez();

    return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] N = new int[6];
		for(int i=0;i<6;i++)N[i]=Integer.parseInt(sc.next());
		Dice dice1 = new Dice(N);
		for(int i=0;i<6;i++)N[i]=Integer.parseInt(sc.next());
		Dice dice2 = new Dice(N);
		//String order = sc.next();
		//char[] charOrder = order.toCharArray();
		
		
		
			System.out.println(dice1.equals(dice2)?"Yes":"No");
		
		sc.close();
	}

}

class Dice{
	private int[] roll=new int[6];
	private int[] nowRoll= new int[6];
	Dice(int[] N){
		for(int i = 0;i<6;i++){
			this.roll[i]=N[i];
			this.nowRoll[i]=N[i];
		}
	}

	public int getRoll(int i){
		return nowRoll[i];
	}

	public void roll(char c){
		//int dir;
		int[] tmpRoll=new int[6];
		for(int i=0;i<6;i++)tmpRoll[i]=this.nowRoll[i];
		int[][] mapRoll={{3,1,0,5,4,2},{1,5,2,3,0,4},{4,0,2,3,5,1},{2,1,5,0,4,3},{0,2,4,1,3,5},{0,3,1,4,2,5},{5,1,3,2,4,0}};
		int dir=0;
		if(c=='E') dir=0;
		if(c=='N') dir=1;
		if(c=='S') dir=2;
		if(c=='W') dir=3;
		if(c=='R') dir=4;
		if(c=='L') dir=5;
		if(c=='X') dir=6;
		
		for(int i=0;i<6;i++)this.nowRoll[i]=tmpRoll[mapRoll[dir][i]];
	}
	public int getRightRoll(int roll,int front){
		int[][] a={{-1,2,4,1,3,-1},{3,-1,0,5,-1,2},{1,5,-1,-1,0,4},{4,0,-1,-1,5,1},{2,-1,5,0,-1,3},{-1,3,1,4,2,-1}};
		int r=a[roll][front];
		return this.nowRoll[r];
	}
	public boolean equals(Dice d){
		int[] N= new int[6];
		for(int i=0;i<6;i++) N[i]=d.getRoll(i);
		Dice d1 = new Dice(N);
		boolean bool=false;
		
		for(char c: "RRRERRRERRREERRRWRRRWRRRX".toCharArray()){
			boolean eachBool=true;
			for(int i=0;i<6;i++) eachBool=eachBool&&(this.getRoll(i)==d1.getRoll(i));
			d1.roll(c);
			bool=bool||eachBool;
		}	
		//for(int i=0;i<6;i++)System.out.println(d1.getRoll(i));
		return bool;
	}
}

Measured memory_bytes: 26264
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int a,b,k[10005],l[100005];
  cin>>a>>b;
  vector<int>v(a,0);
  for(int i=0;i<b;++i){
    cin>>k[i]>>l[i];
    v[k[i]-1]++;
    v[l[i]-1]++;
  }
  for(int i=0;i<a;++i){
    if(v[i]%2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    
    int n, m;
    cin >> n >> m;
    
    int l = -inf, r = inf;
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        chmax(l, u);
        chmin(r, v);
    }
    cout << max(0, r - l + 1) << '\n';
}


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

int main(){
	int n, m, a, b;
	cin >> n >> m;
	vector<int> count(n);
	for(int i=0; i < m; i++) {
		cin >> a >> b;
		count.at(a-1)++;
		count.at(b-1)++;
	}
	for(int i=0; i < n; i++)
		cout << count.at(i) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<int> vi;

struct hopcroft_karp {
	int N,M;
	vector<vector<int>> E;
	vector<int> dist,match,Q;
	hopcroft_karp(int n, int m):N(n),M(m),E(N),dist(N+M),match(N+M,-1),Q(N+M){}

	inline void add_edge(int i, int j) {E[i].push_back(j);}

	bool bfs() {
		fill(&dist[0],&dist[0]+N+M,-1);
		int qf = 0, qb = 0, u;
		bool ok = false;
		for(int i = 0; i < N; ++i)
			if(match[i] == -1)
				Q[qb++] = i, dist[i] = 0;
		while(qf != qb) {
			if((u = Q[qf++]) < N) {
				for(int v : E[u])
					if(dist[N+v] == -1)
						dist[Q[qb++] = N+v] = dist[u] + 1;
			} else {
				if(match[u] == -1) ok = true;
				else if(dist[match[u]] == -1)
					dist[Q[qb++] = match[u]] = dist[u] + 1;
			}
		}
		return ok;
	}

	bool dfs(int u) {
		for(int &i = Q[u]; i < E[u].size(); ++i) {
			int v = N+E[u][i];
			if(dist[v] == dist[u]+1 && (match[v] == -1 || (dist[match[v]] == dist[v]+1 && dfs(match[v])))) {
				match[v] = u, match[u] = v-N;
				return true;
			}
		}
		return false;
	}

	int solve() {
		int ans = 0;
		while(bfs()) {
			fill(&Q[0],&Q[0]+N,0);
			for(int i = 0; i < N; ++i)
				if(match[i] == -1 && dfs(i))
					++ans;
		}
		return ans;
	}
};

const int N = 105, P = 1e7+5;
int a[N]={-1};
bool p[P];
vi odd,evn;

inline void add(int i) {
	((i&1)?odd:evn).pb(i);
}

int main() {
	fill(p,p+P,1);
	p[0] = p[1] = false;
	for(int i = 2; 1LL * i * i < P; ++i)
		if(p[i])
			for(int j = i * i; j < P; j += i)
				p[j] = false;
	p[2] = false;
	int n;
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i)
		scanf("%d",a+i);
	for(int i = 1; i <= n; ++i) {
		if(a[i-1] != a[i]-1) add(a[i]-1);
		if(a[i+1] != a[i]+1) add(a[i]);
	}
	hopcroft_karp HK(evn.size(), odd.size());
	for(int i = 0; i < evn.size(); ++i)
		for(int j = 0; j < odd.size(); ++j)
			if(p[abs(evn[i]-odd[j])])
				HK.add_edge(i,j);
	int k = HK.solve();
	printf("%d\n",k + int((odd.size()-k)/2*2 + (evn.size()-k)/2*2 + ((odd.size()-k)&1)*3));
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include <experimental/iterator>

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* debug */
auto debug = std::experimental::make_ostream_joiner(std::cout, " ");

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int n;
Int p, r;
Int ans;

int main(){
	cin >> n;
	p = n / 15;
	ans += 60 * p + 120 * p * (p - 1) / 2;
	ARC(i, p * 15, n + 1){
		if(i % 3 != 0 && i % 5 != 0){
			ans += i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC069
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            long[] inputs = Console.ReadLine().Split(' ')
                        .Select(long.Parse)
                        .ToArray();
            int odd = 0, four = 0, even = 0;
            foreach (var item in inputs)
            {
                if (item % 4 == 0) four++;
                else if (item % 2 == 0) even++;
                else odd++;
            }
            string result = "No";
            if (odd - four <= 0 || (even == 0 && odd - four <= 1)) result = "Yes";
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 22880
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

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

int k,m,n;
int main(){
	n=read();
	long long sum=0;
	for(register int i=1;i<=n;i++){
		if(i%3==0 || i%5==0)continue;
		sum+=i;
	}
	printf("%lld\n",sum);
	return 0;
}

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

int main(){
  int w,a,b;
  cin >> w >> a >> b;
  int ans;
  if(a+w<=b)ans=b-a-w;
  else if(b+w<=a)ans=a-b-w;
  else ans = 0;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  int64_t A, B, C, K;
  cin >> A >> B >> C >> K;

  int64_t ans(0);

  if (A >= K) {
    cout << K << endl;
    return 0;
  }

  int64_t tmp = A + B;
  if (tmp >= K) {
    cout << A << endl;
    return 0;
  }

  ans = A - (K - A - B);

  cout << ans << endl;
}


Measured memory_bytes: 3608
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
 
typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
 
#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;
 
 
using namespace std;
 
int main() {
 
	SINT64 N = 0;
	SINT64 kazu = 0;
	SINT64 ans = 0;
 
	cin >> N;
 
	vector<SINT32> DATA1(N);
	vector<SINT32> DATA2(N);
	vector<SINT32> clac1(N);
	vector<SINT32> clac2(N);
	vector<SINT64> p(30);
	
	rep(i,0,N) {
		cin >> DATA1[i];
	}
	rep(i,0,N) {
		cin >> DATA2[i];
	}
	rep(i,0,30) {
		p[i] = (SINT64)pow(2,i);
	}
 
	rep(i,1,30) {
 
		SINT64 buf = 0;
		rep(j,0,N) {
			clac1[j] = DATA1[j] % p[i];
			clac2[j] = DATA2[j] % p[i];
		}
		sort(clac2.begin(),clac2.end());
 
		rep(j,0,N) {
			SINT64 A,B,C;
			A = lower_bound(clac2.begin(),clac2.end(), p[i-1]-clac1[j]) - clac2.begin();
			B = lower_bound(clac2.begin(),clac2.end(), p[i]-clac1[j]) - clac2.begin();
			C = lower_bound(clac2.begin(),clac2.end(), p[i-1]+p[i]-clac1[j]) - clac2.begin();
 
			buf += B-A+N-C;
		}
		if ((buf % 2) != 0) {
			ans += p[i-1];
		}
 
	}
 
	cout << ans << endl;
	return 0;
}
 
//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);
 
//	// DATA.emplace_back(BUF);	//後ろに追加
 
//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用
 
//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入
 
 
//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列
 
/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/
 
// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;
 
 
//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin(); 
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();
 
 
/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
 
/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}
 
	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }
 
	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/
 
/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;
 
	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}
 
*/

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

int main() {
  int n,tempN=0,count=1;
  vector<int> d(100);

  cin >> n;
  rep(i,n) cin >> d[i];
  sort(d.begin(), d.end(), greater<int>());

  for(int i=1; i<n; i++){
    if(d[tempN]>d[i]){
      tempN=i;
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
S = list(input())
s = S[0]
r = 0
if(len(S) == 1):
  print(r)
  quit()
for i, l in enumerate(S):
  if(i+1 >= len(S)):
    break
  if(S[i+1] == l):
    r += 1
    if(l == '0'):
      S[i+1] = '1'
    else:
      S[i+1] = '0'
print(r)
    

Measured memory_bytes: 3956
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
signed main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	putchar((((abs(a-b))<=(abs(a-c)))?(65):(66)));
	return putchar(10),0;
}

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

int main() {
  const ll M = 1e9+7;
  int n; string s;
  cin >> n >> s;
  map<char,ll> c;
  rep(i,n) {
    c[s[i]]++;
  }
  ll ans = 1, p = 1, q = 0;
  for (auto ci : c) {
    char k = ci.first;
    int v = ci.second;
    ans = ans * (v+1) % M;
  }
  cout << ans - 1 << endl;

  return 0;
}

Measured memory_bytes: 3752
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
using namespace std;

struct CARD {
	int number;
	char mark;
};

int partition(vector<CARD>& A, int p, int r) {
	int i,j,x=A[r].number;
	i=p-1;
	for(j=p; j<r; ++j) {
		if(A[j].number<=x) {
			++i;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}

void quickSort(vector<CARD>& A, int p, int r) {
	if(p<r) {
		int q;
		q=partition(A,p,r);
		quickSort(A,p,q-1);
		quickSort(A,q+1,r);
	}
	return;
}

int main() {
	int n;
	int i;
	bool stability=true;
	vector<CARD> A;
	map<int,queue<char> > M;

	scanf("%d",&n);
	A.resize(n);

	for(i=0; i<n; ++i) {
		(void)getchar();
		scanf("%c %d",&A[i].mark,&A[i].number);
		M[A[i].number].push(A[i].mark);
	}
	quickSort(A,0,n-1);
	for(i=0; i<n; ++i) {
		stability=stability && (A[i].mark==M[A[i].number].front());
		M[A[i].number].pop();
	}
	printf((stability?"Stable\n":"Not stable\n"));
	for(i=0; i<n; ++i) {
		printf("%c %d\n",A[i].mark,A[i].number);
	}
	return 0;
}

Measured memory_bytes: 21188
#include<iostream>

using namespace std;
const int K=300000;
int p[K];

void furui(){
   for(int i=0; i<K; i++) p[i]=1;
   p[0]=p[1]=0;
   for(int i=2; i*i<=K; i++){
      if(p[i]){
         for(int j=2; i*j<K; j++){
            p[i*j]=0;
         }
      }
   }
}

int main(){

   furui();
   while(1){
      int n;
      cin>> n;
      if(!n) break;

      int s=0;
      for(int i=0; i<=n; i++){
         s+=p[i];
      }
      int t=0;
      for(int i=0; i<=2*n; i++){
         t+=p[i];
      }

      cout<< t-s<< endl;
   }

   return 0;
}

Measured memory_bytes: 4272
#include <iostream>
using namespace std;
struct g{
	int a;
	int b;
	int c;
	int d;
};
int hoge(int);
int ten();
int *a;
int n,m,q;
g *group;
int main(){
	cin >> n >> m >> q;
	group = new g[q];
	a = new int[n];
	a[0] = 1;
	for(int i = 0;i < q;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		group[i].a = a;
		group[i].b = b;
		group[i].c = c;
		group[i].d = d;
	}
	cout << hoge(1);

	return 0;
}

int hoge(int b){
	if(b == n){
		return ten();
	}
	int maxp = 0;
	for(int i = a[b - 1];i <= m;i++){
		a[b] = i;
		int buf = hoge(b + 1);
		if(maxp < buf){
			maxp = buf;
		}
	}
	return maxp;

}

int ten(){
	int ans = 0;
	for(int i = 0;i < q;i++){
		if(a[group[i].b - 1] - a[group[i].a - 1] == group[i].c){
			ans += group[i].d;
		}
	}
	return ans;
}


Measured memory_bytes: 3624
def solve():
    N = int(input())
    cnt = [1]*(N+1)

    for i in range(2, N+1):
        j = 1
        while i*j<=N:
            cnt[i*j] += 1
            j += 1

    ans = 0
    for i in range(1, N+1):
        ans += i*cnt[i]
    print(ans)

solve()


Measured memory_bytes: 151452
N = int(input())
S = [list(input()) for _ in range(N)]

j = -1
ans = []
cnt = 0
for al in [chr(i) for i in range(97, 123)]:
    j += 1
    cnt_min = 100
    for i in range(N):
        cnt = 0
        while al in S[i]:
            S[i].remove(al)
            cnt += 1
        cnt_min = min(cnt_min, cnt)
    ans += [al] * cnt_min
ans = ''.join(ans)
print(ans)


Measured memory_bytes: 3064
S = input()
T = input()
s_l = len(S)
t_l = len(T)
t=list(T)
ans = 'UNRESTORABLE'
for i in range(s_l-t_l+1):
  s = list(S[i:i+t_l])
  count=0
  for a,b in zip(s,t):
    if (a==b)or(a=='?'):
      count+=1
      if count==t_l:
        ans = S[:i]+T+S[i+t_l:]
        
    else:break
        
print(ans.replace('?','a'))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdlib>
#include <iomanip>

using namespace std;
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 long long INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

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

	for (int i = 0; i < 110000; ++i) {
		dp[i] = INF;
	}
	dp[0] = 0;
  // 配るDP
	for (int i = 0; i < N; ++i) {
		for (int j = 1; j <= K; ++j) {
			chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}

	cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int x;
    cin >> x;
    
    if(x == 1)
        cout << "Hello World" << endl;
    else
    {
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io;


fn main() {
    let (a, b, c) = {
        let i = read::<isize>();
        (i[0], i[1], i[2])
    };

    if a <= c && c <= b { println!("Yes"); }
    else { println!("No"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h> 
using namespace std; 
int main() {
  int k; 
  int e[1000002] = {0}; 
  scanf("%d", &k); 
  int l = 0; 
  int i = 0; 
  while ((e[0] == 0) && (e[l] <= 1)) {
    i ++; 
    l = (l*10 + 7) % k; 
    e[l] ++; 
  }
  if (e[0] == 0)
    cout << -1; 
  else
  	cout << i;   
 
}

Measured memory_bytes: 7660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
ll GCD(ll a,ll b){
    ll hoge;
    do{
        hoge=a%b;
        a=b;
        b=hoge;
    }while(hoge!=0);
    return a;
}
ll LCM(ll a,ll b){
    return a/GCD(a,b)*b;//overflow対策
}
int main(){
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   a--;
   ll cnt_a=0,cnt_b=0,lcm_s=LCM(c,d);
   cnt_a+=a-(a/c+a/d)+a/lcm_s;
   cnt_b+=b-(b/c+b/d)+b/lcm_s;
   cout<<cnt_b-cnt_a<<endl;
}

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

using namespace std;

typedef long long ll;

const ll INF = 1e15;
const int MAX_N = 1e2 + 5;
const int MAX_P = MAX_N * 1e3 + 5;

int n, capacity;

ll dp[2][MAX_P];

int p[MAX_N], w[MAX_N];

int main() {
  ll ans;
  // dp[n][p] = the minimum weight to get the profit p from the first n objects
  // dp[n][p] = min(dp[n - 1][p] (so i don't chose the object n), dp[n - 1][w - p[i]] + w[i] (i chose it))
  int t;
  cin >> n >> capacity;
  for (int i = 1; i <= n; ++i) {
    cin >> w[i] >> p[i];
  }
  for (int i = 0; i < MAX_P; ++i) {
    dp[0][i] = dp[1][i] = INF;
  }
  t = 1;
  dp[0][0] = 0;
  ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < MAX_P; ++j) {
      dp[t][j] = dp[1 - t][j];
      if (j - p[i] >= 0) {
        dp[t][j] = min(dp[t][j], dp[1 - t][j - p[i]] + w[i]);
      }
      if (dp[t][j] <= capacity) {
        ans = max(ans, 1LL * j);
      }
    }
    t = 1 - t;
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;

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

  int n; 
  cin >> n;
  int res = 1;
  while (res < n) res <<= 1;
  cout << (res <= n ? res : res/2) << endl;

  return 0;
}



Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 1000; ++i) {
		string b;
		int hoge = i;
		REP(q, 3) {
			b.push_back('0' + hoge % 10);
			hoge /= 10;
		}
		for (int q = 0; q < s.length(); ++q) {
			if (b.empty() == false) {
				if (b.back() == s[q])b.pop_back();
			}
		}
		if (b.empty() == true) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
  
  int N,M,X,Y;
  scanf("%d%d%d%d",&N,&M,&X,&Y);
  
  int i,j,x[N],y[M];
  for(i = 0 ; i < N ; i++){
    scanf("%d",&x[i]);
  }
  for(i = 0 ; i < M ; i++){
    scanf("%d",&y[i]);
  }
  
  int war = 0;
  if(X >= Y){
    war = 1;
  }
  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < M ; j++){
      if(x[i] >= y[j]||X >= y[j]||Y <= x[i]){
        war = 1;
      }
    }
  }
  
  if(war == 1){
    printf("War");
  }else{
    printf("No War");
  }
  
  return 0;
  
}

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

using namespace std;

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

    vector<int> A(N);
    vector<long long> B(N + 1, 0);  // 累積和テーブル

    for(int i = 0; i < N; i++) {
        cin >> A[i];
        B[i + 1] = B[i] + A[i];
    }

    long ans = 0;
    int mod = 1000000007;

    for(int i = 0; i < N; i++) {
        long long sum = (B[N] - B[i + 1]) % mod;
        ans += A[i] * sum;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

void up(string& s) {
    if (s.length() == 1) {
        if (s.at(0) == '9') {
            s = "01";
        } else {
            s.at(0) = s.at(0) + 1;
        }
    } else {
        string sub = s.substr(1);

        if ((int)(s.at(0) - s.at(1)) == 1) {
            up(sub);
            if (sub.at(0) == '0' || sub.at(0) == '1') {
                s.at(0) = '0';
            } else {
                s.at(0) = sub.at(0) - 1;
            }
            s = s.at(0) + sub;
        } else if ((int)(s.at(0) - s.at(1)) == 0) {
            if (s.at(0) == '9') {
                up(sub);
                if (sub.at(0) == '0' || sub.at(0) == '1') {
                    s.at(0) = '0';
                } else {
                    s.at(0) = sub.at(0) - 1;
                }
                s = s.at(0) + sub;
            } else {
                s.at(0) = s.at(0) + 1;
            }
        } else if ((int)(s.at(0) - s.at(1)) == -1) {
            s.at(0) = s.at(0) + 1;
        }
    }
}

int main() {
    long K;
    cin >> K;
    
    string s = "1";

    for (int i = 0; i < K - 1; ++i) {
        up(s);
    }

    reverse(s.begin(), s.end());
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef long double ld;
typedef pair<ld, ll> P;

void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001000000;
const ll mod=1000000007;


int main(){
  ll n,k;
  cin>>n>>k;
  ll a[n];
  ll m=0;
  ll now=0;
  rep(i,n){
    cin>>a[i];
    now+=a[i];
    m=max(m,a[i]);
  }
 
  ll nl,nh;
  nl=1;
  nh=m;
  ll nm;
  
  while(nh-nl>0){
    nm=(nl+nh)/2;
    ll cnt=0;
    rep(i,n){
      if(a[i]%nm==0){
        cnt+=a[i]/nm;
        cnt--;
      }
      else{
        cnt+=a[i]/nm;
      }
    }
    if(cnt>k){
      nl=nm+1;
    }
    else{
      nh=nm;
    }
  }
  cout<<nh<<endl;
}



Measured memory_bytes: 5204
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        if (sc.nextInt() == 1) {
            System.out.println("Hello World");
        } else {
            System.out.println(sc.nextInt() + sc.nextInt());
        }
    }

}


Measured memory_bytes: 21716