akhauriyash/Code-Regression huggingface dataset:
n = int(input())
count = 0 
flag = 0 
for i in range(n):
    
    temparr = input()
    temparr = temparr.split()
    first = int(temparr[0])
    sec = int(temparr[1])
    if first == sec:
        count += 1 
    else:
        count = 0 
    if count == 3:
        flag = 1 

if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62364
sx,sy,tx,ty=map(int,input().split())
ans=""
for i in range(tx-sx):
    ans+="R"
for j in range(ty-sy):
    ans+="U"
for i in range(tx-sx):
    ans+="L"
for j in range(ty-sy):
    ans+="D"
ans+="D"
for i in range(tx-sx+1):
    ans+="R"
for j in range(ty-sy+1):
    ans+="U"
ans+="LU"
for i in range(tx-sx+1):
    ans+="L"
for j in range(ty-sy+1):
    ans+="D"
ans+="R"

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String name[] = new String[3];
		for (int i = 0; i < 3; i++) {
			name[i] = sc.next();
		}
		for (int i = 0; i < 3; i++) {
			System.out.print(name[i].charAt(0));
		}
		System.out.println();

	}

}


Measured memory_bytes: 9680
#include <stdio.h>
int main(){
    while(1){
        int n,m,a[21][21],px=10,py=10;
        scanf("%d",&n);
        if(n==0) return 0;
        for(int i=0;i<21;i++) for(int j=0;j<21;j++) a[i][j]=0;
        for(int i=0;i<n;i++){
            int x,y;
            scanf("%d %d",&x,&y);
            a[x][y]=1;
        }
        scanf("%d",&m);
        for(int i=0;i<m;i++){
            char d;
            int l;
            scanf(" %c %d",&d,&l);
            for(int j=0;j<l;j++){
                if(d=='N') py++;
                if(d=='E') px++;
                if(d=='S') py--;
                if(d=='W') px--;
                if(a[px][py]) n--;
                a[px][py]=0;
            }
        }
        if(n==0) printf("Yes\n");
        else printf("No\n");
    }
}

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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    uint64_t N ;
    cin >> N;
    // find depth
    int depth = 0;
    uint64_t start = 1;
    uint64_t width = 26;
    std::string ans = "";
    while( start + width - 1 < N){
        depth++;
        start += width;
        width *= 26;
    }
    uint64_t width_up = width / 26;
    uint64_t offset = N - start;
    // cout << "depth" << depth << endl;
    // cout << "widht up" << width_up << endl;
    // cout << "offset" << offset << endl;
    while(depth-- >= 0){
        char c = 'a' + offset / width_up ;
        // cout << "found " << c << endl;
        ans += c;
        N /= 26;
        offset = offset - (c - 'a') * width_up ;
        width_up = width_up / 26;
        //cout << N << endl;
        // cout << "nex offset" <<  offset << endl;
    }
    cout << ans << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 4;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3552
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] B = new int[N-1];
    for(int i = 0; i < N-1; i++){
      B[i] = Integer.parseInt(sc.next());
    }
    
    int sum = 0;
    for(int i = 0; i < N; i++){
      if(i == 0){
        sum += B[i];
      }else if(i == N-1){
        sum += B[N-2];
      }else{
        sum += Math.min(B[i],B[i-1]);
      }
    }   
    System.out.println(sum);
  }
}

Measured memory_bytes: 21844
n, k = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))

seen = [0] * n
node = 0
number = 1
while k:
    if seen[node]:
        loop_length = number - seen[node]
        k %= loop_length
        break

    seen[node] = number
    number += 1
    node = A[node]
    k -= 1


for i in range(k):
    node = A[node]

print(node+1)


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

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

  vector<int> vec;
  for (int i = 0; i < S.size() - 1; i++)
  {
    if (S[i] == 'A') vec.push_back(1);
    else if (S[i] == 'B' and S[i + 1] == 'C') {
      vec.push_back(0);
      i++;
    }
    else vec.push_back(-1);
  }

  int cnt = 0;
  long long ans = 0;
  for (int i = 0; i < vec.size(); i++)
  {
    if (vec[i] == -1) {
      cnt = 0;
      continue;
    }
    else if (vec[i] == 1) cnt++;
    else if (vec[i] == 0) ans += cnt;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1532
#include <iostream>
#include <string>

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

    if(s == "SAT") {
        std::cout << 1 << std::endl;
    } else if(s == "FRI") {
        std::cout << 2 << std::endl;
    } else if(s == "THU") {
        std::cout << 3 << std::endl;
    } else if(s == "WED") {
        std::cout << 4 << std::endl;
    } else if(s == "TUE") {
        std::cout << 5 << std::endl;
    } else if(s == "MON") {
        std::cout << 6 << std::endl;
    } else {
        std::cout << 7 << std::endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 1e5;

int n;
int a[MaxN + 5];
map <int, int> cnt;

int main()
{
	while(scanf("%d", &n) != EOF)
	{
		for(int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			cnt[a[i]]++;
		}
		sort(a + 1, a + n + 1);
		//for(int i = 1; i <= n; i++)
		//	printf("%d ", cnt[a[i]]);
		//printf("\n");
		int L = 0, W = 0;
		for(int i = n; i >= 1; i--) {
			if(cnt[a[i]] <= 1) continue;
			else if(cnt[a[i]] >= 2) {
				if(L == 0) {
					if(cnt[a[i]] >= 4) {
						L = a[i];
						W = a[i];
						break;
					}
					else if(cnt[a[i]] >= 2 && cnt[a[i]] < 4) {
						L = a[i];
					}
				}
				else if(L != 0 && a[i] != L) {
					W = a[i];
					break;
				}
			}
		}
		LL ans = 0;
		ans = (LL)L * (LL)W;
		//printf("L = %d W = %d\n", L, W);
		printf("%lld\n", ans);
		memset(a, 0, sizeof(a));
		cnt.clear();
	}
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#include<queue>
using namespace std;
int n,m;
int ans=2020;
int main(){
  cin>>n>>m;
  if(m-n+1>=2019){
    cout<<0<<endl;
    return 0;
  }
  for(int i=n;i<m;i++){
    for(int j=i+1;j<=m;j++)
    ans=min(ans,int(1ll*i*j%2019));
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 256
/*
 * https://atcoder.jp/contests/abc157/tasks/abc157_d
 */
#include <bits/stdc++.h>
 
using namespace std;

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll int

/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現系
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

const int MOD = 1e9 + 7;

struct UnionFind {
    ll n;
    vector<ll> par,rank;

    UnionFind(ll N) : par(N) {
        n = N;
        REP(i,n) par[i] = i;
        rank.assign(n, 1);
    }

    ll root(ll x) {
        ll tmp = x;
        while(par[tmp] != tmp) {
            tmp = par[tmp];
        }
        return par[x] = tmp;
    }

    void unite(ll x, ll y) {
        ll rootX = root(x);
        ll rootY = root(y);
        if (rootX == rootY) return;
        rank[rootY] += rank[rootX];
        par[rootX] = rootY;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll count(ll x) {
        return rank[root(x)];
    }
};

ll n,m,k;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k;

    UnionFind unionFind(n);
    vector<ll> blocks(n, 1);
    REP(i,m) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        unionFind.unite(a,b);
        blocks[a]++;
        blocks[b]++;
    }
    REP(i,k) {
        ll c,d;
        cin >> c >> d;
        c--;d--;
        if(unionFind.same(c,d)) {
            blocks[c]++;
            blocks[d]++;
        }
    }
    REP(i,n) {
        if(i > 0) cout << " ";
        cout << unionFind.count(i) - blocks[i];
    }
    return 0;
}

Measured memory_bytes: 2048
cnt = int(input())
lst = list(map(int, input().split()))

if cnt == 1:
    print('Yes')
else:
    ma = lst[0]
    for i in range(1, cnt):
        if ma - lst[i] >= 2:
            print('No')
            break
        elif i == cnt-1:
            print('Yes')
        ma = max(ma, lst[i])





Measured memory_bytes: 14296
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	vector<ll> an;
	bool sign=true;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		an.push_back(t);
		if(i!=0){
			if(an[i]>=an[i-1]){
				if(an[i]==an[i-1])
					continue;
				an[i]--;
			}
			else
				sign=false;
		}
	}
	if(sign)
		puts("Yes");
	else
		puts("No");
		
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(c <= a+b)
		Yes;
	else
		No;
	ret 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	a, b, c, x := nextInt(), nextInt(), nextInt(), nextInt()
	ans := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if i*500+j*100+k*50 == x {
					ans++
				}
				if i*500+j*100+k*50 > x {
					break
				}
			}
		}
	}
	fmt.Println(ans)
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
/* テンプレートここまで */
void yes(){
  cout << "YES" << endl;
  exit(0);
}

void no(){
  cout << "NO" << endl;
  exit(0);
}
int main() {
  ll a,b,c; cin >> a >> b >> c;
  if(b-a==c-b) yes();
  else no();
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

moves = [(0,1),(0,-1),(1,0),(-1,0)] #全方向調べる

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)

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

using namespace std;

void doc() {
    freopen("OB.inp", "r", stdin);
    freopen("OB.out", "w", stdout);
}

void solve(){
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    int f[n][3];
    f[0][0] = a[0];
    f[0][1] = b[0];
    f[0][2] = c[0];
    for(int i = 1; i < n; i++){
        f[i][0] = max(f[i - 1][1], f[i - 1][2]) + a[i];
        f[i][1] = max(f[i - 1][0], f[i - 1][2]) + b[i];
        f[i][2] = max(f[i - 1][1], f[i - 1][0]) + c[i];
        //cout << f[i][0] << " " << f[i][1] << " " << f[i][2] << '\n';
    }
    int res = max(f[n - 1][0], max(f[n - 1][1], f[n - 1][2]));
    cout << res;
}

int main()
{
//    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}



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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vector<int>a(n);
	int sum = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		sum += a[i];
	}
	double ave = (double)sum / n;
	int ind = -1;
	double e = INF;
	for(int i = 0; i < n; ++i){
		if(abs(ave - a[i]) < e){
			e = abs(ave - a[i]);
			ind = i;
		}
	}
	cout << ind << "\n";
	return 0;
}


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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if ( k < s.size()) {
    for(int i = 0; i < k; i++) cout << s.at(i);
    cout << "..." << endl;
  }
  else cout << s << endl;
} 

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;  cin >> x;
    if (x < 1200) {
      cout << "ABC" << endl;
    } else {
      cout << "ARC" << endl;
    }

    return 0;
}


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


int main() {
	string S;
	cin >> S;
	if ('A' != S[0]) {
		cout << "WA"<<endl;
		return 0;
	}
	int count = 0; 
	for (int i = 2; i < S.size() - 1; ++i) {
		if ('C' == S[i]) {
			count++;
		}
	}
	for (int i = 1;i<S.size();++i) {
		if ('C' == S[i]) {
		}
		else {
			int num = S[i] - 'a';
			if (num >=0 && num <=25  ) {
			}
			else {
				cout << "WA" << endl;
				return 0;
			}
		}
	}
	if (1 == count) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
	return 0;
}

Measured memory_bytes: 3616
N,A,B = map(int,input().split())
S = input()
yosen = 0
kaigai = 0
for i in range(N):
  if S[i] == "a":
    if yosen != (A+B):
      print("Yes")
      yosen += 1
    else:
      print("No")
  elif S[i] == "b":
    if yosen != (A+B):
      if kaigai < B:
        print("Yes")
        yosen += 1
        kaigai += 1
      else:
        print("No")
    else:
      print("No")
  elif S[i] == "c":
    print("No")

Measured memory_bytes: 4016
n = int(input())
S = input()
l = set()
for i in range(1000):
    num = str(i).zfill(3)
    s = S
    if s.find(num[0]) == -1:
        continue
    s = s[s.index(num[0]) + 1:]
    if s.find(num[1]) == -1:
        continue
    s = s[s.index(num[1]) + 1:]
    if s.find(num[2]) == -1:
        continue
    l.add(num)
print(len(l))

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

int main()
{
	int n;
	int sn = 0;

	cin >> n;

	int tmp = n;

	while (tmp != 0)
	{
		sn += (tmp % 10);
		tmp /= 10;
	}

	if (n % sn)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
while True:
  a, op, b = input().split()
  a = int(a)
  b = int(b)
  if op=="?":
    break
  if op=="+":
    print(a+b)
  if op=="-":
    print(a-b)
  if op=="*":
    print(a*b)
  if op=="/":
    print(a//b)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll dp[100005], p[100005], n, k, a[105];
ll const mod = 1e9+7;
ll add(ll a, ll b){
	return(a%mod + b%mod)%mod;
}
ll sub(ll a, ll b){
	return (a%mod-b%mod+mod)%mod;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k;
	for (ll i = 0; i< n; i++)cin >>a[i];
	dp[0] = 1;
	for (ll i = 0; i< n; i++){
		memset(p, 0, sizeof(p));
		for (ll used = k; used >= 0; used--){
			//~ for (ll add = 1; add <= min(a[i], k-used)){
				//~ dp[used+add] += dp[used];
			//~ }
			ll qq = dp[used];
			ll L = used +1;
			ll R = min(a[i], k-used)+used;
			if (L <= R){
				p[L] = add(p[L], qq);
				if (R+1 <= k)p[R+1] = sub(p[R+1], qq);
			}
		}
		ll pre = 0;
		for (ll i = 0; i <= k; i++){
			pre = add(pre, p[i]);
			dp[i] = add(dp[i], pre);
		}	
	}
	cout << dp[k]%mod;
}


Measured memory_bytes: 1792
import heapq
INFTY = 10**4
N,X,Y = map(int,input().split())
C = {k:0 for k in range(N)}
G = {i:[] for i in range(1,N+1)}
G[1].append(2)
G[N].append(N-1)
for i in range(2,N):
    G[i].append(i-1)
    G[i].append(i+1)
G[X].append(Y)
G[Y].append(X)
for i in range(1,N+1):
    heap = [(0,i)]
    dist = [INFTY for _ in range(N+1)]
    dist[i] = 0
    hist = [0 for _ in range(N+1)]
    while heap:
        d,x = heapq.heappop(heap)
        if dist[x]<d:continue
        hist[x]=1
        for y in G[x]:
            if hist[y]==0 and dist[y]>d+1:
                dist[y] = d+1
                heapq.heappush(heap,(dist[y],y))
    for j in range(1,N+1):
        C[dist[j]] += 1
for k in range(1,N):
    print(C[k]//2)

Measured memory_bytes: 73948
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a) memset(a, 0x00, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("out.txt","w",stdout)
#define pb push_back
#define pp pop_back
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout << "hi" << endl
typedef long long ll;

using namespace std;

int main()
{_
    //iDEBUG;
    list<int> l;
    list<int>::iterator iter;

    int n, x;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        string str;
        cin >> str;
        if(str == "deleteFirst")
            l.pop_front();
        else if(str == "deleteLast")
            l.pop_back();
        else if(str == "insert")
        {
            cin >> x;
            l.push_front(x);
        }
        else
        {
            cin >> x;
            for(iter=l.begin(); iter!=l.end(); iter++)
                if(*iter == x)
                {
                    l.erase(iter);
                    break;
                }
        }
    }
    for(iter=l.begin(); iter!=l.end(); iter++)
    {
        if(iter != l.begin())
            cout << " ";
        cout << *iter;
    }
    cout << endl;

    return 0;
}


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

namespace CSharpSample01
{
    

    class Program
    {

        const int INF = 1000000000;

        static int Solve(int N, int K, int[] h)
        {
            int[] dp = new int[N];
            dp[0] = 0;
            for (int i = 1; i < N; i++) dp[i] = INF;
            
            for(int i = 1; i < N; i++)
            {
                for(int j = i - K; j <= i - 1; j++)
                {
                    if (j >= 0) dp[i] = Math.Min(dp[i], dp[j] + Math.Abs(h[i] - h[j]));
                }
            }         

            return dp[N - 1];
        }

        

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(Solve(N, K, h));
            
        }
    }
}

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

int main(){
	int n;
	cin >> n;
	
	set<int> mochi;
	rep(i, n){
		int d;
		cin >> d;
		mochi.insert(d);
	}

	cout << mochi.size() << endl;
}


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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
double min(double a,double b){
  if(a<b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}

int main(void){
  int N; cin >> N;
  
  int localmin = 1000000001;
  int localmax = 0;
  for(int i=0;i<N;i++){
  	int A;
    cin >> A;
    localmax = max(A,localmax);
    localmin = min(A,localmin);
  }
  cout << absolute(localmin,localmax) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

#define SIZE (10*10*10*10*10)
int64 H[SIZE];

int main()
{
  int cnt;
  int64 N;
  int64 i;
  int64 max = 0;


  get_N(&N);

  for (i=0; i<N; i++) {
    cnt = scanf("%lld", &H[i]);
    if (max == 0) {
      max = H[i];
      continue;
    }
    if ((H[i] < (max - 1))) {
      printf("No");
      return 0;
    }

    if (H[i] == (max - 1)) {
      H[i] -= H[i];
    }

    if (H[i] > max) {
      max = H[i];
    }
    
  }// for

  printf("Yes");

  return 0;
}



Measured memory_bytes: 896
#include<iostream>

int main(){
  while(true){
    int h, w;
    std::cin >> h;
    std::cin >> w;

    if(h == 0 && w == 0) break;

    std::string str = "";
    for(int i = 0; i < w; i++){
      str += "#";
    }

    std::string str_inner = "#";
    for(int i = 1; i < w - 1; i++){
      str_inner += ".";
    }
    str_inner += "#";

    std::cout << str << std::endl;
    for(int i = 1; i < h - 1; i++){
      std::cout << str_inner << std::endl;
    }
    std::cout << str << std::endl;
    std::cout << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

int main() {
    ll n, T;
    cin >> n >> T;
    vector<ll> t(n);
    ll ans = T;
    rep(i, 0, n) cin >> t[i];
    rep(i, 1, n) {
        ans += min(T, t[i] - t[i-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        int max = 0;
        int maxpos = 0;
        for (int i = 0; i < n; i++) {
            if (Math.abs(a[i]) > max) {
                max = Math.abs(a[i]);
                maxpos = i;
            }
        }

        int moveNum = 0;
        ArrayList<Integer[]> move = new ArrayList<Integer[]>();

        if (max == 0) {
            System.out.println(0);
            return;
        } else if (a[maxpos] > 0) {
            for (int i = 0; i < n; i++) {
                if(i ==  maxpos) continue;
                a[i] += max;
                moveNum++;
                move.add(new Integer[] { maxpos + 1, i + 1 });
            }
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1]) {
                    int dif = a[i - 1] - a[i];
                    int min = Integer.MAX_VALUE;
                    int minpos = 0;
                    for (int j = 0; j < n; j++) {
                        if (a[j] < min && a[j] >= dif) {
                            min = a[j];
                            minpos = j;
                        }
                    }
                    a[i] += min;
                    moveNum++;
                    move.add(new Integer[] { minpos + 1, i + 1 });
                }
            }
        }else{
            for(int i=0; i<n; i++){
                if(i == maxpos) continue;
                a[i] -= max;
                moveNum++;
                move.add(new Integer[]{maxpos+1, i+1});
            }
            for(int i=n-2; i>=0; i--){
                if(a[i] > a[i+1]){
                    int dif = a[i+1] - a[i];
                    int mmax = Integer.MIN_VALUE;
                    int mmaxpos = 0;
                    for(int j=0; j<n; j++){
                        if(a[j] > mmax && a[j] <= dif){
                            mmax = a[j];
                            mmaxpos = j;
                        }
                    }
                    a[i] += a[mmaxpos];
                    moveNum++;
                    move.add(new Integer[]{mmaxpos+1, i+1});
                }
            }
        }

        System.out.println(moveNum);
        for(int i=0; i<moveNum; i++){
            Integer[] mans = move.get(i);
            System.out.println(mans[0] + " " + mans[1]);
        }

        // int moveNum = 0;
        // ArrayList<Integer[]> move = new ArrayList<Integer[]>();
        // for(int i=1; i<n; i++){
        // if(a[i] < a[i-1]){
        // int dif = a[i-1] - a[i];
        // int min = Integer.MAX_VALUE;
        // int minpos = 0;
        // for(int j=0; j<n; j++){
        // if(a[j] < min && a[j] >= dif){
        // min = a[j];
        // minpos = j;
        // }
        // }
        // a[i] += min;
        // moveNum++;
        // move.add(new Integer[]{minpos+1, i+1});
        // }
        // }

    }
}

Measured memory_bytes: 23124
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }

        long sum = 0;
        LinkedList<Integer> q = new LinkedList<>();
        for (int i = 0; i < K; i++) {
            sum += p[i];
            q.offer(p[i]);
        }
        //System.out.println(q);
        int maxL = 0;
        int maxR = K-1;
        long max = sum;
        //System.out.println("# "+sum+" "+maxL + " " + maxR);
        for (int i = K; i < N; i++) {
            int l = q.poll();
            sum -= l;
            sum += p[i];
            q.offer(p[i]);
        //System.out.println(q + " " +sum+","+max);
            if (sum > max) {
                max = sum;
                maxL = i-(K-1);
                maxR = i;
            }
        }

        long ans = 0;
        for (int i = maxL; i <= maxR; i++) {
            ans += p[i]+1;
        }
        //System.out.println(maxL + " " + maxR);
        System.out.println((double)ans/2);
    }
}



Measured memory_bytes: 66160
import Data.List

dupIdx :: String -> [[Int]]
dupIdx s = go $ nub s
  where
    go [] = []
    go (x:xs) = let is = elemIndices x s
                 in is : go xs

solve :: String -> String -> Bool
solve s t = dupIdx s == dupIdx t

main :: IO ()
main = do
    s <- getLine
    t <- getLine
    putStrLn $ if solve s t then "Yes" else "No"

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

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

    sort(a.begin(), a.end());

    rep(i,n-1) {
        if (a[i] == a[i+1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <queue>
#include <cstring>

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

using ll = long long;

int N, K, L, s, t;
std::vector<std::vector<int> > road, railway;
int c1[2 * 100001], c2[2 * 100001];

void dfs(std::vector<std::vector<int> >& g, int c[], int v, int id) {
  c[v] = id;

  for (int i = 0; i < g[v].size(); ++i) {
    int nv = g[v][i];

    if (c[nv] == -1) {
      dfs(g, c, nv, id);
    }
  }
}

int main() {
  scanf("%d%d%d", &N, &K, &L);
  road.resize(N);
  railway.resize(N);
  for (int i = 0; i < K; ++i) {
    scanf("%d%d", &s, &t);
    s--, t--;
    road[s].push_back(t);
    road[t].push_back(s);
  }
  for (int i = 0; i < L; ++i) {
    scanf("%d%d", &s, &t);
    s--, t--;
    railway[s].push_back(t);
    railway[t].push_back(s);
  }

  std::memset(c1, -1, sizeof c1);
  std::memset(c2, -1, sizeof c2);

  int id = 0;

  for (int i = 0; i < N; ++i) {
    if (c1[i] == -1) {
      dfs(road, c1, i, id++);
    }
  }

  id = 0;

  for (int i = 0; i < N; ++i) {
    if (c2[i] == -1) {
      dfs(railway, c2, i, id++);
    }
  }

  std::map<std::pair<int, int>, int> mp;

  for (int i = 0; i < N; ++i) {
    mp[{c1[i], c2[i]}]++;
  }

  for (int i = 0; i < N; ++i) {
    printf("%d%c", mp[{c1[i], c2[i]}], (i == N - 1 ? '\n' : ' '));
  }

  return 0;
}


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

ll Pow(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

bool cmp(const int &a, const int &b){
    return a < b;
}

ll gcd(ll x, ll y){
    return x % y == 0 ? y : gcd(y, x % y);
}

ll lcm(ll x, ll y){
    return x / gcd(x, y) * y;
}

int main(){
    int x, a;
    scanf("%d%d", &x, &a);
    if (x < a) printf("0\n");
    else printf("10\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define Set(a, b) memset(a, (b), sizeof(a))
#define F first
#define S second
#define FT front()
#define BK back()
#define PB push_back
#define MP make_pair
#define repi(i, l, r) for (int i=l ; i <= (int)(r) ; ++i)
#define repd(i, r, l) for (int i=r ; i >= (int)(l) ; --i)
#define repv(x, v) for (auto (x) : v)
#define all(cont) cont.begin(), cont.end()
#define Sort(n) sort(all(n))
#define Sortcmp(n) sort(all(n), cmp)
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define nl "\n"

using namespace std;

bool cmp(const pair<long,long> &a,
              const pair<long,long> &b)
{
    return (a.second < b.second || (a.second == b.second && a.first < b.first));
}

bool binarySearch(int arr[], int n, int x){
    int k = 0;
    for (int b = n/2; b >= 1; b/2)
        while (k+b < n && arr[k+b] <= x) k += b;

    if (arr[k] == x) return k;
    return -1;
}

/* ASCII Table */
/* 48 == '0', 57 = '9', 65 == 'A', 90 == 'Z', 97 == 'a', 122 == 'z' */  

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    vector< tuple<int, int, int> > tp;
    vector<pair <int, string> > v;

    long n, m;
    long p, y;

    cin >> n >> m;

    repi(i, 0, m-1){
        cin >> p >> y;
        tp.PB(make_tuple(p, y, i));
    }

    Sort(tp);
    string id, tmp;
    long bef = 0, curr;
    repi(i, 0, m-1){
        if(bef == get<0>(tp[i])){
            curr++;
        } else {
            curr = 1;
        }

        id.clear();
        tmp = to_string(get<0>(tp[i]));
        repi(i, 1, 6 - tmp.size())
            id += "0";
        id += tmp;
        tmp = to_string(curr);
        repi(i, 1, 6 - tmp.size())
            id += "0";
        id += tmp;

        v.PB(MP(get<2>(tp[i]), id));

        bef = get<0>(tp[i]);
    }    

    Sort(v);

    repi(i, 0, m-1){
        cout << v[i].second << nl;
    }


}

/* Compile */
// g++ -std=c++11 -O2 -Wall test.cpp -o test
 
 
/* Source code dengan case
 
int main(){
    int T;
    cin >> T;
    for(int counterT = 1 ; counterT <= T ; T++){
         
        printf("%d\n", ans);
    }
    return 0;
}
 */
 
/* Source code dengan case
 
int main(){
    int T;
    cin >> T;
    for(int counterT = 1 ; counterT <= T ; T++){
         
        printf("Case #%d: %d\n", counterT, ans);
    }
    return 0;
}
 */

Measured memory_bytes: 10480
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    string s;
    int k;
    cin >> s >> k;
    char c='1';
    int n=s.size();
    int m=min(k,n);
    rep(i,m) {
        if (s[i]!='1') {
            c=s[i];
            break;
        }
    }
    cout << c << endl;
}


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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;

const double EPS = 1e-10;
const int INF = 1000000001;
const int N = 200000;
int n;
int a[N], L[N], R[N];

ll merge(int l, int m, int r) {
  ll res = 0LL;
  int i, j, k;
  int nl = m - l;
  int nr = r - m;
  for (i=0; i<nl; i++)
    L[i] = a[l + i];
  for (i=0; i<nr; i++)
    R[i] = a[m + i];
  
  L[nl] = R[nr] = INF;
  
/*
  k = l;
  i = j = 0;
  while (i<nl || j<nr) {
    if (i==nl)
      a[k++] = R[j++]; 
    else if (j==nr)
      a[k++] = L[i++];
    else if (L[i] <= R[j])
      a[k++] = L[i++];
    else {
      a[k++] = R[j++]; 
      res += nl - i;
    }
  }
*/
  i = j = 0;
  for (k=l; k<r; k++) {
    if (L[i] <= R[j]) {
      a[k] = L[i++];
//      res += j;
    } else {
      res += (ll)(nl - i);
      a[k] = R[j++];
    }
  }

  return res;
}

ll merge_sort(int l, int r) {
  ll res = 0;
  if (l+1<r) {
    int m = (l+r)/2;
    res = merge_sort(l, m);
    res += merge_sort(m, r);
    res += merge(l, m, r);
  }
  return res;
}

int main() {
  scanf("%d ", &n);
  for (int i=0; i<n; i++)
    scanf("%d ", a+i);

  printf("%lld\n", merge_sort(0, n));

  return 0;
}

Measured memory_bytes: 2760
s=input()
u=int(s)
n=len(s)

if n<=2:
  print(0)
  exit()

f=[0 for _ in range(3)]
a=0

for k in range(1,n+1):
  for i in range(3**k):
    d=i
    t=0
    f[0]=f[1]=f[2]=0
    for j in range(k):
      f[d%3]=1
      t+=(2*(d%3)+3)*10**j
      d = d//3
    if f[0]*f[1]*f[2]:
      if t <= u:
        a+=1

print(a)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, n){
		int in;
		cin >> in;
		while(in % 2 == 0 && in > 0){
			in /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

vec<int> prime;
set<int> p;
bool A[666666];

void print() {
   for (int x : prime) {
      cout << x << endl;
   }
}

void make() {
  int i, j;
 
  /* 判定フラグ */
  int flag;
 
  /* 素数かどうかを判定 */
  for( i=2;i<=55555;++i ) {
    flag = 0;
    for( j=2;j<i;++j ){
      if( i%j==0 ) {
        flag = 1;
        break;
      }
    }
    /* 判定結果を出力 */
    if( flag==0 )
      // printf("%d ", i);
      prime.push_back(i);
      p.insert(i);
  }
}

int main() {
   make();

   vec<int> kouho;
   for (int x : prime) {
      if (x % 10 == 3) {
         kouho.push_back(x);
      }
   }

   int n;
   cin >> n;
   rep (i, n-1) {
      cout << kouho[i] << " ";
   }
   cout << kouho[n-1] << endl;


   // vec<int> odd;
   // for (int i = 0; i <= 55555; i++) {
   //    if ((i % 2 == 1) && (p.find(i) == p.end())) {
   //       odd.push_back(i);
   //    }
   // }
   // printA(odd);

   // // print();
   // int n;
   // cin >> n;

   // int sum = 0;
   // rep (i, n-1) {
   //    cout << prime[i] << " ";
   // }
   // cout << prime[n-1] << endl;

   return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main(){
    string N; cin >> N;
    if(N>="2019/05/01") cout << "TBD" << endl;
    else cout << "Heisei" << endl;
    
    
//    cout << N << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [int(a) for a in input().split()]

A.sort()
A_min = A[1]

def func():
    for i in range(A_min, 0, -1):
        cnt = 0
        for j in range(n):
            if cnt == 0:
                if A[j] % i > 0:
                    cnt += 1
                    bad = j
            elif cnt == 1:
                if A[j] % i > 0:
                    cnt += 1
                    break

        if cnt < 2:
            return i

result = func()
print(result)

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//互除法
ll GCD(ll a, ll b){
  return b ? GCD(b,a%b) : a;
}

ll LCM(ll a, ll b){
  return (a / GCD(a,b))*b;
}

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, M; cin >> N >> M;
  vector<ll> a(N); FOR(i,N){ cin >> a[i]; }
  
  //main
  ll r = (a[0]/2)%2;
  FOR(i,N){ if((a[i]/2%2)^r){ cout << 0 << endl; return 0; } }
  
  ll l=1; FOR(i,N){ l=LCM(l,a[i]); }
  FOR(i,N){ if(l/2%a[i] != a[i]/2){ cout << 0 << endl; return 0; } }
  ll ans = l/2<=M ? (M-l/2)/l+1 : 0;
  
  // output
  cout << ans << endl;

  return 0;
}

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

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e17;

int main() {
    ll N, M, L;
    cin >> N >> M >> L;
    ll dis[300][300] = {};
    ll Ldis[300][300] = {};
    rep(i,N){
        rep(j,N) {
            if (i == j) {
                dis[i][j] = 0;
                Ldis[i][j] = 0;
            } else {
                dis[i][j] = LINF;
                Ldis[i][j] = LINF;
            }
        }
    }
    rep(i,M){
        ll a,b,c;
        cin >> a >> b >> c;
        if (c > L) continue;
        dis[a-1][b-1] = c;
        dis[b-1][a-1] = c;
    }

    rep(k,N){
        rep(i,N) {
            rep(j,N){
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }

    rep(i,N){
        rep(j,N) {
            if (i == j) continue;
            if(dis[i][j] <= L) Ldis[i][j] = 1LL;
        }
    }

    rep(k,N){
        rep(i,N) {
            rep(j,N){
                Ldis[i][j] = min(Ldis[i][j], Ldis[i][k] + Ldis[k][j]);
            }
        }
    }

    ll Q;
    cin >> Q;
    rep(i,Q){
        ll s, t;
        cin >> s >> t;
        if(Ldis[s-1][t-1] < LINF) cout << Ldis[s-1][t-1] - 1<< endl;
        else cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int n; readV(n);
  writeln((n%1000)%111 == 0 || (n/10)%111 == 0 ? "Yes" : "No");
}


Measured memory_bytes: 256
import math

a,b,C=map(int,input().split())
s=math.sin(math.radians(C))
t=math.cos(math.radians(C))
S=(a*b*s)/2
l=a+b+math.sqrt(a**2+b**2-2*a*b*t)
h=S*2/a
print('{:.8f}'.format(S),'{:.8f}'.format(l),'{:.8f}'.format(h))


Measured memory_bytes: 5716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,C;
  cin>>N>>C;
  VVI D(C,VI(C)),A(N,VI(N));
  rep(i,C) rep(j,C) cin>>D[i][j];
  rep(i,N) rep(j,N) cin>>A[i][j];
  VVI X(3,VI(C));
  rep(i,N) rep(j,N) X[(i+j)%3][A[i][j]-1]++;
  int ans=1001001001;
  rep(i,C){
    rep(j,C){
      if(i==j) continue;
      rep(k,C){
        if(i==k or j==k) continue;
        int tmp=0;
        rep(m,C){
          tmp+=X[0][m]*D[m][i];
          tmp+=X[1][m]*D[m][j];
          tmp+=X[2][m]*D[m][k];
        }
        ans=min(ans,tmp);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1280
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM
import Data.List

type Map = IM.IntMap Int

readIntLines :: IO [Int]
readIntLines = map (fst . fromJust . BC.readInt) . BC.lines <$> BC.getContents

get :: Int -> Map -> Int
get key m = fromMaybe 0 $ IM.lookup key m

solve :: Int -> Int -> Int -> Map -> Int
solve k right prev m
  | left <= 0 = prev
  | otherwise = solve k (right - 1) result m
    where left = right - k + 1
          curr = get right m - get left m
          result = if curr < prev then curr else prev

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  hs <- sort <$> readIntLines
  print . solve k (length hs) (10 ^ 9) $ IM.fromList $ zip [1..] hs

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

int main(){
	int i=0,x;
	while(1){    //while(1)?????????while(0)???????????¨???
		scanf("%d",&x);
		i++;
		if(x==0)
			break;
		
		printf("Case %d: %d\n",i,x);

	}

	return 0;
}

Measured memory_bytes: 1188