akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n, k, q;
    scan(n, k, q);
    auto a = iota(q).map!(i => readln.chomp.to!int).array;
    a[] -= 1;

    auto s = new int[](n);
    s[] = q;

    foreach (ai ; a) {
        s[ai]--;
    }

    foreach (i ; 0 .. n) {
        writeln(s[i] < k ? "Yes" : "No");
    }
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 3836
n, m, x = map(int, input().split())

c = [0] * (n)
a = [0] * (n)

ans = 0

for i in range(n):
  x_input = list(map(int, input().split()))
  c[i] = x_input[:1][0]
  a[i] = x_input[1:]

a_rev = list(zip(*a))
for i in range(len(a_rev)):
  if sum(a_rev[i]) < x:
    print("-1")
    exit()

# print(c)
min_cost = sum(c)

num = len(a)
for i in range(2 ** num):
  bag = []
  bag_skill = []
  for j in range(num):
    if ((i >> j) & 1):
      # print(c[j])
      # print(j)
      bag.append(c[j])
      bag_skill.append(a[j])

  # print(bag)
  bag_skill = list(zip(*bag_skill))
  now = 0
  for k in range(len(bag_skill)):
    if sum(bag_skill[k]) >= x:
      now += 1
      # print("now = ", now)
    if now == len(bag_skill):
      cost = sum(bag)
      if cost < min_cost:
        min_cost = cost
  
print(min_cost)



Measured memory_bytes: 74620
N, M = map(int, input().split())
p = [int(i) for i in input().split()]
# graph = [[]]*(N+1)
graph = [[] for _ in range(N+1)]
group = [0]*(N+1)
ans = 0
for _ in range(M):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)
for i, num in enumerate(p, 1):
    space = [i]
    for point in space:
        if group[point]:
            continue
        group[point] = i
        space.extend(graph[point])
    ans += (group[num] == group[i])
print(ans)

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

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

    ll ans = 0;
    
    for (int i = 1; i <= n; ++i) {
        ll sum = 0;
        ll t = i;
        
        while (t > 0) {
            sum += t % 10;
            t /= 10;
        }
        
        if (a <= sum && sum <= b) {
            ans += i;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  int N,C,K;
  cin>>N>>C>>K;
  int T[N];
  for(int i=0;i<N;i++){
    cin>>T[i];
  }
  sort(T,T+N);
  int sum=1;
  int hassha=T[0];
  int ninzuu=1;
  for(int i=1;i<N;i++){
    if(T[i]<=hassha+K&&ninzuu<C){
      ninzuu++;
    }else{
      hassha=T[i];
      ninzuu=1;
      sum++;
    }


  }
  cout<<sum<<endl;


  





  



}


  
  

  

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000005);

mint g(int r, int c) {
  return  comb(r + c + 2, r + 1);
}

int main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  r1--; c1--;
  
  mint ans = g(r2, c2);
  ans -= g(r1, c2);
  ans -= g(r2, c1);
  ans += g(r1, c1);

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


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

const int limit=50;
int n,m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
	visited[v] = true;
	for (int v2 = 0; v2 < n; ++v2) {
		if (graph[v][v2] == false) continue;
		if (visited[v2] == true) continue;
		dfs(v2);
	}
}

int main(void) {

	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
	cin >> a[i] >> b[i];
	a[i]--, b[i]--;
	graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}

	int ans = 0;

	for (int i = 0; i < m; ++i) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

		for (int j = 0; j < n; ++j) visited[j] = false;

		dfs(0);

		bool bridge = false;
		for (int j = 0; j < n; ++j)
			if (visited[j] == false) bridge = true;
		if (bridge) ans += 1;

		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque

N, T = map(int, input().split())
queue = deque()

for i in range(N):
    l, r = map(int, input().split())
    queue.extend([(l, 1), (r, -1)])
queue = sorted(queue)

ans = p = 0

for t, s in queue:
    if s == 1:
        p += 1
        ans = max(ans, p)
    else:
        p -= 1
    
print(max(ans, p))


Measured memory_bytes: 28920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 10000;


int main(){
  map<string, int> mp;
  int N = in();
  string s;
  long long ans = 0;

  rep(i, N){
    cin >> s;
    sort(s.begin(), s.end());

    ans += mp[s];
    mp[s]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
priority_queue<int>p;
int n, x, ans;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		p.push(x);
		cin >> x;
		p.push(x);
	}
	for (int i = 1; i <= n; i++)
	{
		p.pop();
		ans += p.top();
		p.pop();
	}
	cout << ans;
}

Measured memory_bytes: 256
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] aa = new int[n + 1];
		for (int i = 1; i <= n; i++)
			aa[i] = (aa[i - 1] + sc.nextInt() - 1) % k;
		Integer[] ii = new Integer[++n];
		for (int i = 0; i < n; i++)
			ii[i] = i;
		Arrays.sort(ii, (i, j) -> aa[i] != aa[j] ? aa[i] - aa[j] : i - j);
		long ans = 0;
		for (int i = 0, j = 0; i < n; i++) {
			while (j < n && aa[ii[j]] == aa[ii[i]] && ii[j] - ii[i] < k)
				j++;
			ans += j - i - 1;
		}
		println(ans);
	}
}


Measured memory_bytes: 64976
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static long ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();


		ans = 0;

		for(int i = 1;i<N ; i++) {
			ans+=N/i;
			if(N/(double)i == N/i) {
				ans--;
			}
		}

		System.out.println(ans);
	}

	//素数判定
	public static boolean isPrime(long num) {
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 35664
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int x,y;
  cin >> x >> y;
  int c= y-2*x;
  if(c < 0 || c%2 == 1) cout << "No" << endl;
  else
  {
    x -= (c/2);
    if(x < 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}


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

int main(){
	int n;
	int count = 0;
	cin >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin >> v[i];
	}
	for(int i=0; i<n; i++){
		if(v[i] == i + 1) {
			if(i != n-1) {
				swap(v[i], v[i+1]);
			}
			count++;
		}
	}
	cout << count;
}



Measured memory_bytes: 640
x=int(input())
a=[0]
a.append(x)
i=x
j=1

while True:
  k=int((i/2)*(i%2==0)+(3*i+1)*(i%2==1))
  #print(a,k)
  if k in a:
    print(j+1)
    exit()
  else:
    a.append(k)
    i=k
    j=j+1
    continue


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)

vector<ll> len(55), pat(55);

ll rec(ll n, ll x) {
    if(n == 0) return x >= 1;
    if(x == 1) return 0;
    if(1 < x && x <= 1+len[n-1]) return rec(n-1, x-1);
    if(x == 2+len[n-1]) return 1+pat[n-1];
    if(2+len[n-1] < x && x <= 2+2*len[n-1]) return 1+pat[n-1]+rec(n-1, x-2-len[n-1]);
    if(x == 3+2*len[n-1]) return 1+2*pat[n-1];
}

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

    ll n, x; cin >> n >> x;
    len[0] = 1, pat[0] = 1;
    rep(i, n) {
        len[i+1] = 2*len[i] + 3;
        pat[i+1] = 2*pat[i] + 1;
    }
    cout << rec(n, x) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<ll,ll> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


int main()
{
    int time=0;
    int n,q;cin>>n>>q;
    queue<pair<string,int> >p;
    
    REP(i,n)
    {

        string x;int y;cin>>x>>y;p.push(mp(x,y));
    }
    while(!p.empty())
    {
        pair<string,int> t=p.front();p.pop();
        if(t.second<=q){time+=t.second;cout<<t.first<<" "<<time<<endl;}
        else
        {
            t.second-=q;
            time+=q;
            p.push(t);
        }
    }
}



Measured memory_bytes: 6392
a = list(input())
b = list(input())
c = list(input())
x = a.pop(0) #xにaのリストのいちばん最初の文字を取り出し、削除
while True:
    if x =="a":
        if len(a) == 0:
            print("A")
            exit()
        else:
            x = a.pop(0)
    elif x == "b":
        if len(b) == 0:
            print("B")
            exit()
        else:
            x = b.pop(0)
    else: 
        if len(c) == 0:
            print("C")
            exit()
        else:
            x = c.pop(0)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int a, b[10000], c, i;
    scanf("%d", &a);
    for(i=0;i<a;i++){
        scanf("%d", &b[i]);
    }
    c=a-1;
    for(i=c;i>=0;i--){
        if(i>0) printf("%d ", b[i]);
        else printf("%d", b[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>

int main(void)
{
	float a, b, c, d, e, f, x, y;
	
	while (scanf("%f", &a) != EOF){
		scanf("%f %f %f %f %f", &b, &c, &d, &e, &f);
		
		y = (c * d - f * a) / (b * d - e * a);
		x = (c - b * y) / a;
		
		printf("%.3f %.3f\n", x, y);
	}
	
	return (0);
}

Measured memory_bytes: 648
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

s = sum(A)
ans = 0

for x in A:
    ans += x * (s-x)
    ans %= mod
ans = ans*pow(2, mod-2, mod)
ans %= mod
print(ans)


Measured memory_bytes: 32928
import sys
sys.setrecursionlimit(2000000)

N = int(input())
ab = list(list(map(int,input().split())) for i in range(N-1))
c = list(map(int,input().split()))
c.sort(reverse=True)
print(sum(c)-c[0])
tree = [[-1]for i in range(N)]
for a,b in ab:
    tree[a-1].append(b)
    tree[b-1].append(a)
def func(l):
    if tree[l-1][0] != -1:
        return
    tree[l-1][0] = c.pop(0)
    for i in tree[l-1][1:]:
        func(i)
func(1)
for i in tree:
    print(i[0],end = " ")

Measured memory_bytes: 16220
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let k = read!(usize);
    let s = read!(String);
    for (i,c) in s.chars().enumerate() {
        if i<k {
            print!("{}", c);
        }
        else {
            print!("...");
            break;
        }
    }
    println!();
}

fn run() {
    solve();
}

Measured memory_bytes: 2272
from heapq import heappush, heappop

while True:
  n, m = map(int, input().split())
  if n == 0: break

  mp = ["X" + input() + "X" for _ in range(m)]
  mp.insert(0, "X" * (n + 2))
  mp.append("X" * (n + 2))
  
  que = []
  visited = [[False] * (n + 2) for _ in range(m + 2)]
  sur_flag = False
  for i in range(1, n + 1):
    if mp[1][i] =="&" or mp[m][i] == "&":
      sur_flag = True
      break
    c1, s1 = (1, 0) if mp[1][i] == "#" else (0, 1)
    c2, s2 = (1, 0) if mp[m][i] == "#" else (0, 1)
    heappush(que, (c1, s1, (i, 1)))
    heappush(que, (c2, s2, (i, m)))
    visited[1][i] = True
    visited[m][i] = True
  
  for i in range(1, m + 1):
    if mp[i][1] == "&" or mp[i][n] == "&":
      sur_flag = True
      break
    c1, s1 = (1, 0) if mp[i][1] == "#" else (0, 1)
    c2, s2 = (1, 0) if mp[i][n] == "#" else (0, 1)
    heappush(que, (c1, s1, (1, i)))
    heappush(que, (c2, s2, (n, i)))
    visited[i][1] = True
    visited[i][n] = True
  
  if sur_flag:
    print(0)
    continue
  
  direct = ((0, 1), (0, -1), (1, 0), (-1, 0))
  reached = False
  
  while que and not reached:
    cost, status, point = heappop(que)
    x, y = point
    for dx, dy in direct:
      newx, newy = x + dx, y + dy
      if not visited[newy][newx]:
        visited[newy][newx] = True
        if mp[newy][newx] == "&":
          print(cost)
          reached = True
          break
        elif mp[newy][newx] == "#":
          if status == 1:
            heappush(que, (cost + 1, 0, (newx, newy)))
          else:
            heappush(que, (cost, 0, (newx, newy)))
        elif mp[newy][newx] == ".":
          heappush(que,(cost, 1, (newx, newy)))


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

# 全部Kの倍数のパターン
ans = (N // K) ** 3
# 偶数の時は、全部Kの倍数+(K/2)のパターンでもよい
if K % 2 == 0:
  ans += ((N - K/2) // K + 1) ** 3

print(int(ans))

Measured memory_bytes: 3060
K = int(input())

mod = 0
last_mod = 0
for i in range(K):
    if i==0:
        last_mod = 7 % K
    else:
        last_mod = (last_mod*10)%K
    mod += last_mod
    mod %= K
    if mod%K == 0:
        print(i+1)
        exit()
print(-1)

Measured memory_bytes: 63332
/*
校舎の入居者数
2018/02/03
*/

#include<stdio.h>
void print(int a[3][10]);

int main(void){
  int a_1[3][10] = {0};
  int a_2[3][10] = {0};
  int a_3[3][10] = {0};
  int a_4[3][10] = {0};
  int n;/*n件の情報*/
  int b,f,r,v;/*b棟f階のr番目の部屋にv人が追加で入居したことを示す*/
  int k;

  scanf("%d",&n);
  for(k=0;k<n;k++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    switch(b){
    case 1:
      a_1[f-1][r-1] += v;
      break;
    case 2:
      a_2[f-1][r-1] += v;
      break;
    case 3:
      a_3[f-1][r-1] += v;
      break;
    case 4:
      a_4[f-1][r-1] += v;
      break;
    }
  }

  print(a_1);
  printf("####################\n");
  print(a_2);
  printf("####################\n");
  print(a_3);
  printf("####################\n");
  print(a_4);
  return 0;
}

void print(int a[3][10]){
  int i,j;
  for(i=0;i<3;i++){
    for(j=0;j<10;j++){
      printf(" %d",a[i][j]);
    }
    printf("\n");
  }
  return;
}


Measured memory_bytes: 2052
#include<iostream>
long n,k,a,i,j,m=1e9+7,v[2<<20];main(){for(std::cin>>n>>k;i<n;i++)for(j=0;j<n;j++){i||std::cin>>v[j];if(v[i]>v[j])a=(a+k*(k-1)/2+(i<j?k:0))%m;}std::cout<<a<<"\n";}

Measured memory_bytes: 256
import copy

N = int(input())

A = []
for _ in range(N):
    A.append(int(input()))


max1 = max(A)

max_i = A.index(max1)
max2 = max(A[:max_i] + A[max_i+1:])


for i in range(N):
    if A[i] == max1:
        print(max2)

    else:
        print(max1)


Measured memory_bytes: 14616
n = int(input())
A = list(map(int, input().split()))

import numpy as np
B = [0 for _ in range(n)]
ans = []
for i, a in enumerate(A[::-1]):
  i = len(A) - i - 1
  B[i] = int(np.array(B[i::i+1]).sum() % 2 != a)
  if B[i] == 1:
    ans.append(i+1)
print(len(ans))
if len(ans) > 0:
  print(*ans)

Measured memory_bytes: 39328
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int dp[110][11000];

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    dp[0][0]=1;
    REP(i,N) REP(j,10000){
        if(dp[i][j]){
            dp[i+1][j]=1;
            dp[i+1][j+a[i]]=1;
        }
    }
    
    int ans=0;
    REP(i,10000) if(dp[N][i] and i%10!=0) ans=i;
    cout<<ans<<endl;
 
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, H, W; cin >> N >> H >> W;
    vector<int> A(N), B(N);
    rep(i,N) cin >> A[i] >> B[i];

    int ans = 0;
    rep(i,N){
        if (A[i] >= H && B[i] >= W){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3576
#include<stdio.h>
#define N 1000

int main(void){
  int i,num,j,k,n;
  int p,sum[N],max[N],min[N];

  for(i=0;;i++){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(j=0;j<n;j++){
      sum[j]=0;
      for(k=0;k<5;k++){
        scanf("%d",&p);
        sum[j]+=p;
      }
    }
    max[i]=sum[0];
    min[i]=sum[0];
    for(j=0;j<n;j++){
      if(max[i]<sum[j]){
        max[i]=sum[j];
      }
      if(min[i]>sum[j]){
        min[i]=sum[j];
      }
    }
  }
  num=i;
  for(i=0;i<num;i++){
    printf("%d %d\n",max[i],min[i]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    int A;
    int B;
    int Park1;
    int Park2;
    
    cin >> N >> A >> B ;
    
    Park1 = N * A;
    Park2 = B;
    
    if(Park1 <= Park2){
        cout << Park1 << endl;
    }else if(Park2 < Park1){
        cout << Park2 << endl;
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define PI acos(-1.0)
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define MOD 1000000007
#define MOD1 1000000005
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, 1};
int dy4[] = {1, -1, 1, -1};

int main()
{
    #ifndef ONLINE_JUDGE
    freopen ("in.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
    #endif
    int n, i, j, d;
    cin>>n; int a[n+1];
    for(i=0;i<n;i++)cin>>a[i];
    sort(a, a+n); ull ans=a[n-1];
    d=(n-2)/2;
    for(i=0,j=n-2;i<d;i++,j--)ans+=(2*a[j]);
    if((n-2)%2!=0)ans+=(a[j]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		
		a[i] -= (i + 1);
	}
	sort(begin(a), end(a));
	
	i64 ans = 0;
	for(auto v : a) ans += std::abs(v - a[n / 2]);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
import Foundation

extension String {
    func toIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }
    
    func toList() -> [String] {
        return self.map{String($0)}
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }

    func counter() -> Dictionary<Character, Int>{
        var result:[Character:Int] = [:]
        
        for c in self{
            guard let _ = result.index(forKey: c) else {
                result[c] = 1
                continue
            }
            result[c]! += 1
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}


func codefes2017a() -> String {
    let NMK = readLine()!.toIntList()
    let N = NMK[0]
    let M = NMK[1]
    let K = NMK[2]
    var tmp = 0
    for n in 0...N{
        for m in 0...M{
            var x = n*(M-m)
            var y = m*(N-n)
            if (x+y) == K{
                return "Yes"
            }
        }
    }
    return "No"
}


print(codefes2017a())


Measured memory_bytes: 13640
from collections import deque
import sys
sys.setrecursionlimit(10 ** 6)  # import sysすること！再帰の深さ制限を緩くする
n = int(input())
count = 0
ans = []
if n <= 9:
    print(n)
    exit()


def dfs(pre_str, keta):
    global count, ans
    # print(pre_str)
    if len(pre_str) == keta:
        count += 1
        ans = pre_str
        if count+9 == n:
            print(ans)
            exit()
        return

    start = int(pre_str[-1])-1
    for i in range(start, start+3):
        if 0 <= i <= 9:
            dfs(pre_str+str(i), keta)
    return


for i in range(2, 100):
    for j in range(1, 10):
        dfs(str(j), i)


Measured memory_bytes: 3316
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**9 + 1

def precompute(N, M, data):
    data = data.reshape(-1, 3)
    A, B, C = data[:N].T
    D, E, F = data[N:].T
    X = np.unique(np.concatenate([A, B, D, [0, -INF, INF]]))
    Y = np.unique(np.concatenate([C, E, F, [0, -INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B)
    D = np.searchsorted(X, D)
    C = np.searchsorted(Y, C)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F)
    return A, B, C, D, E, F, X, Y

def solve(A, B, C, D, E, F, X, Y):
    H, W = len(X), len(Y)
    N = H * W
    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    def set_ng(A, B, C, D, E, F, H, W):
        ng = np.zeros((H * W, 4), np.bool_)

        for i in range(len(A)):
            for x in range(A[i], B[i]):
                v = x * W + C[i]
                ng[v][1] = 1
                ng[v - 1][0] = 1

        for i in range(len(D)):
            for y in range(E[i], F[i]):
                v = D[i] * W + y
                ng[v][3] = 1
                ng[v - W][2] = 1
        return ng

    ng = set_ng(A, B, C, D, E, F, H, W)
    x0, y0 = np.searchsorted(X, 0), np.searchsorted(Y, 0)
    v0 = x0 * W + y0
    visited = np.zeros(N, np.bool_)
    visited[v0] = 1
    stack = np.empty(N, np.int32)
    p = 0
    ret = 0

    def area(x):
        x, y = divmod(x, W)
        return DX[x] * DY[y]

    def push(x):
        nonlocal p, ret
        stack[p] = x
        visited[x] = 1
        ret += area(x)
        p += 1

    def pop():
        nonlocal p
        p -= 1
        return stack[p]

    push(v0)
    move = (1, -1, W, -W)
    while p:
        v = pop()
        for i in range(4):
            if ng[v][i]:
                continue
            w = v + move[i]
            if visited[w]:
                continue
            x, y = divmod(w, W)
            if x == 0 or x == H - 1 or y == 0 or y == W - 1:
                return 0
            push(w)
    return ret

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    signature = '(i8[:],i8[:],i8[:],i8[:],i8[:],i8[:],i8[:],i8[:])'
    cc.export('solve', signature)(solve)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit()

from my_module import solve

N, M = map(int, readline().split())
data = np.int64(read().split())

x = solve(*precompute(N, M, data))
if x == 0:
    print('INF')
else:
    print(x)

Measured memory_bytes: 150860
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(a>=b&&k>0){
		b*=2;
		k--;
	}
	while(b>=c&&k>0){
		c*=2;
		k--;
	}
//	cout<<a<<b<<c<<k<<endl;
	if(a<b&&b<c){
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#!python3.8
# -*- coding: utf-8 -*-
# abc171/abc171_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    p = sorted(i2nn())
    print(sum(p[:K]))
    return

main()


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int maxl = 35;
const int maxn = 100000 + 5;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n;
int a[maxn];
int dp[2][maxl];

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    n = read<int>();
    for(int i = 1; i <= n; ++i) { a[i] = read<int>(); }

    int cur = 0;
    memset(dp[cur], oo, sizeof dp[cur]);

    dp[cur][0] = 0;
    for(int i = 1; i <= n; ++i) {
        int bit = 0, x = 1;
        while(x < a[i]) x <<= 1, ++ bit;

        cur ^= 1;
        memset(dp[cur], oo, sizeof dp[cur]);

        for(int j = 0; j <= bit; ++j) if(dp[cur^1][j] < oo) {
            int delta = bit - j; 

            if(delta > 0 || x == a[i]) 
                chkmin(dp[cur][bit], dp[cur^1][j] + delta);
            else if(j > 0) 
                chkmin(dp[cur][bit-1], dp[cur^1][j] + delta);
        }
        for(int j = bit; j > 0; --j) chkmin(dp[cur][j-1], dp[cur][j]);
    }
    printf("%d\n", dp[cur][0]);

    return 0;
}


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

int main()
{
	int q, t1, t2;
	string s1, s2;
	const int maxS = 1000;
	int m[maxS][maxS];

	cin >> q;

	for (int i = 0; i < q; i++) {

		for (int i = 0; i < maxS; i++)
			for (int j = 0; j < maxS; j++)
				m[i][j] = 0;

		cin >> s1 >> s2;

		t1 = s1.size() - 1;
		t2 = s2.size() - 1;

		if (s1[0] == s2[0])
			m[0][0] = 1;

		for (int i = 0; i < t1; i++) {
			int f = 0;
			if (s1[i + 1] == s2[0])
				f = 1;
			m[i + 1][0] = max(m[i][0], f);
		}

		for (int j = 0; j < t2; j++) {
			int f = 0;
			if (s2[j + 1] == s1[0])
				f = 1;
			m[0][j + 1] = max(m[0][j], f);
		}

		for (int i = 0; i < t1; i++) {
			for (int j = 0; j < t2; j++) {
				if (s1[i + 1] == s2[j + 1])
					m[i + 1][j + 1] = m[i][j] + 1;
				else
					m[i + 1][j + 1] = max(m[i][j + 1], m[i + 1][j]);
			}
		}

		cout << m[t1][t2] << endl;
	}
	return 0;
}


Measured memory_bytes: 7104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, x;
  cin >> N >> x;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  int j = 0;
  while(x >= 0){
    x -= vec.at(j);
    j++;
    if(j == N){
      break;
    }
  }
  
  if(j != N){
   cout << j-1 << endl;
  }
  else if(j == N && x == 0){
    cout << j << endl;
  }
  else if(j == N && x != 0){
    cout << j-1 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	private static String line=sc.next();
	private static int start,end;
	public static void main(String[] args){
		char[] c=line.toCharArray();
		lab1:for(int i=0;i<=c.length-1;i++){
			if(c[i]=='A'){
				start=i;
				break lab1;
			}
		}
		lab2:for(int i=c.length-1;i>=0;i--){
			if(c[i]=='Z'){
				end=i;
				break lab2;
			}
		}
		int ans=end-start+1;
		System.out.println(ans);
	}
}

Measured memory_bytes: 26844
import java.util.*;

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

        int max = 0;
        int temp = 0;
        for (int i =0; i<s.length(); i++) {
            if (
                 s.charAt(i) == 'A'
              || s.charAt(i) == 'C'
              || s.charAt(i) == 'G'
              || s.charAt(i) == 'T') {
                  temp++;
                  if (max < temp) {
                      max = temp;
                  }
              }
              else {
                  temp =0;
              }
        }
        System.out.println(max);
        sc.close();
    }
}

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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test

const int inf = 1e18;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), dp(n, inf);
    for (int &x: a) {
        cin >> x;
    }
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        dp[i] = dp[i - 1] + abs(a[i - 1] - a[i]);
        if (i > 1) {
            dp[i] = min(dp[i], dp[i - 2] + abs(a[i - 2] - a[i]));
        }
    }
    cout << dp[n - 1] << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 4776
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin>>c;
    cout<<(char)(c+1);
    return 0;
}

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


int main() {
  int n, m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
  return 0;
}

Measured memory_bytes: 256
/**
filename:5_A-Exhaustive_Search.c
created on 21.9.2015 by charis
edited on 21.9.2015 by charis
*/

#include<cstdio>
/*
int n;
int S[10000];
int r;

void solve(int i, int A[], int m){
	if(i == n) {
		int s = 0;
		for(int k=0; k<n; k++) {	
			if( S[k] == 1) s += A[k] ;
			if (s == m) r=1 ;
		}
		if (s != m) r!= 0;
	}
	else {
		solve(i + 1, A, m) ;
		S[i] = 1 ;
		solve(i + 1, A, m) ;
		S[i] = 0 ;
	}
}
          time over
*/
int n;

int solve(int i, int A[], int m, int res){
	if(res == m) return 1 ;
	if (i >= n) return 0 ;
	
	res = solve(i+1, A, m, res) || solve(i+1, A, m, res + A[i]);
	
	return res ;
}

int main(){
	int q, m;
	scanf("%d", &n) ;
	int A[n] ;
	for (int i=0; i<n; i++) scanf("%d", &A[i]) ;
	
	scanf("%d", &q) ;
	for (int j=0; j<q; j++){
		scanf("%d", &m) ;
		int i=0, res=0;
		if(solve(i, A, m, res)) {
			printf("yes\n") ;
		}
		else printf("no\n") ;
	}
	
	return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	int l=s.size();
	bool zzz=0;
	for(int i=0;i<l;i++) {
		if(s[i]=='C') {
			for(int j=i+1;j<l;j++) {
				if(s[j]=='F') {
					zzz=1;
				}
			}
		}
	}
	if(zzz==1) {
		cout<<"Yes";
	} else {
		cout<<"No";
	}
}

Measured memory_bytes: 256
import sys

for line in iter(sys.stdin.readline, ''):
  t = line.strip().split(',')
  l = [int(x) for x in t[:10]]
  v = [int(x) for x in t[10:]]
  time = float(sum(l)) / float(sum(v))
  dis = time * float(v[0])

  s = 0
  for (i, x) in enumerate(l):
    s += x
    if s >= int(dis):
      print i + 1
      break

Measured memory_bytes: 4240
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const [n, k] = inputs[0].split(' ').map(Number);
  let list = new Array(n).fill(0);

  for (let i = 1; i <= k; i++) {
    let treatList = inputs[2 * i].split(' ').map(Number);
    for (let j = 0; j < treatList.length; j++) {
      if (list[treatList[j] - 1] === 0) {
        list[treatList[j] - 1] = 1;
      }
    }
  }

  console.log(list.filter((num) => num === 0).length);
}


Measured memory_bytes: 30028
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int count =  0;
    if(s == "SSS") cout << 0 << endl;
    else if(s == "SSR" || s == "RSS" || s == "SRS" || s == "RSR") cout << 1 << endl;
    else if(s == "RRS" || s == "SRR") cout << 2 << endl;
    else cout << 3 << endl;
    return 0;
}

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

#define sz(x) ((int)x.size())
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll; 


int main(){
  int n,k; cin>>n>>k; 
  string s; cin>>s; 
  s[k-1]=s[k-1]+32; 
  cout<<s<<endl; 
}

Measured memory_bytes: 256
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: usize = sc.read();
    let b: usize = sc.read();
    if b == 1 {
        println!("0");
        return;
    }
    let mut sum = a;
    let mut cnt = 1;
    while sum < b {
        sum += a;
        sum -= 1;
        cnt += 1;
    }
    println!("{}", cnt);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

namespace AOJ
{
    class Program
    {
        static IEnumerable<int> Read()
        {
            while(true)
            {
                var d = new int[14, 14];
                for(int i = 1; i < 13; i++)
                {
                    string line;
                    if ((line = Console.ReadLine()) == null) yield break;
                    for(int j = 1; j < 13; j++)
                    {
                        d[i, j] = line[j - 1] - '0';
                    }
                }
                int s = 2;
                for(int i = 1; i < 13; i++)
                    for(int j = 1; j < 13; j++)
                    {
                        if (d[i, j] != 1) continue;
                        if (d[i - 1, j] > 1)
                        {
                            d[i, j] = d[i - 1, j];
                            if (d[i, j - 1] <= 1) continue;
                            int r = d[i, j - 1];
                            for(int k = 1; k < 13; k++)
                                for(int l = 1; l < 13; l++)
                                {
                                    if (d[k, l] == r) d[k, l] = d[i, j];
                                }
                        }
                        else if (d[i, j - 1] > 1) d[i, j] = d[i, j - 1];
                        else
                        {
                            d[i, j] = s;
                            s++;
                        }
                    }
                var dic = new HashSet<int>();
                for(int i = 1; i < 13; i++)
                    for(int j = 1; j < 13; j++)
                        if (d[i, j] > 0)
                            dic.Add(d[i, j]);
                yield return dic.Count;
            }
        }

        static void Main(string[] args)
        {
            foreach (var num in Read())
            {
                Console.WriteLine(num);
                Console.ReadLine();
            }
        }
    }
}

Measured memory_bytes: 6236