akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int N; 
int *A;

void Rec(int left, int right, int n, int &low, int &high)
{
  if(left >= right)
  {
    if(A[left] >= n && left < low)
      low = left;

    if(A[right] > n && right > high)
      high = right;

    return;
  }

  int mid = (left + right) / 2;

  if(n <= A[mid])
    Rec(left, mid, n, low, high);
  if(A[mid] <= n)
    Rec(mid + 1, right, n, low, high);

}

int main()
{
  cin >> N;
  A = new int[N];

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

  int M; cin >> M;

  for(int i = 0; i < M; ++i)
  {
    int Num; cin >> Num;
    int low = N + 1, high = -1;

    Rec(0, N, Num, low, high);

    if(low == N + 1) low = N;
    if(high == -1) high = N;

    cout << low << " " << high << endl;
  }

  delete [] A;

  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    ll N;
    cin>>N;
    int M = 5;
    vector<ll> A(M);
    REP(i,M) cin>>A[i];
    sort(ALL(A));
    ll ans = N/A[0];
    if (A[0] == 1) ans--;
    ans += 5;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 10;
struct data {
  int nt, to;
} a[N << 1];
ll A[N], B[N], dp[N], s[N];
int p[N], f[N], vs[N];
int head[N], cnt = 0;

void add(int x, int y) {
  a[++cnt].to = y;
  a[cnt].nt = head[x];
  head[x] = cnt;
}

bool cmp(int x, int y) {
  return A[x] < A[y];
}

int find(int k) {
  return f[k] == k ? f[k] : f[k] = find(f[k]);
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for(int i = 1; i <= n; ++i) {
    p[i] = f[i] = i;
    scanf("%lld%lld", &A[i], &B[i]);
    s[i] = B[i];
    dp[i] = A[i] = max(A[i] - B[i], 0ll);
  }
  sort(p + 1, p + 1 + n, cmp);
  for(int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  for(int o = 1; o <= n; ++o) {
    int u = p[o];
    vs[u] = 1;
    for(int i = head[u]; i; i = a[i].nt) {
      int to = a[i].to;
      if(vs[to]) {
        int fx = find(u), fy = find(to);
        if(fx == fy) continue;
        f[fy] = fx, s[fx] += s[fy];
        dp[fx] = min(dp[fx], max(dp[fy], A[fx] - s[fy]));
      }
    }
  }
  printf("%lld\n", dp[find(1)] + s[find(1)]);
  return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void){
  int a,c,d,e;
  d=e=c=0;
  0<=a<=86400;
  scanf("%d",&a);
  if(a>=3600){
    d=a/3600;
    a=a%3600;
  }
  if(a>=60){
    e=a/60;
    a=a%60;
  }
  if(a>=1) c=a;
  else{
    c=0;
  }
  printf("%d:%d:%d\n",d,e,c);
  return 0;
}

Measured memory_bytes: 592
import java.util.*;

// CODEFES 2017.qualA-D
// http://code-festival-2017-quala.contest.atcoder.jp/tasks/code_festival_2017_quala_d

public class Main {
	
	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		int H = in.nextInt();
		int W = in.nextInt();
		int d = in.nextInt();
		
		StringBuilder answer = new StringBuilder();
		
		if (d == 1) {
			char[][] color = new char[][]{{'R', 'G'}, {'G', 'R'}};
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					answer.append(color[i % 2][j % 2]);
				}
				answer.append("\n");
			}
		} else if (d == 2) {
			char[][] color = new char[][]{
				{'R', 'R', 'B', 'B'}, 
				{'G', 'G', 'Y', 'Y'}, 
				{'B', 'B', 'R', 'R'},
				{'Y', 'Y', 'G', 'G'}
			};
			
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					answer.append(color[i % 4][j % 4]);
				}
				answer.append("\n");
			}
		} else if (d % 2 == 1) {
			char[][] color = new char[2 * d][2 * d];
			
			char[] gr = new char[]{'G', 'R'};
			char[] by = new char[]{'B', 'Y'};
			
			for (int x = 0; x < 2; x++) {
				for (int y = 0; y < 2; y++) {
					int offset = (x + y) % 2;
					
					for (int j = 0; j < d; j++) {
						int numBY = Math.min(j,  d - j);
						int index = 0;
						while (index < numBY) {
							color[index + d * x][j + d * y] = by[offset];
							index++;
						}
						int numGR = d - 2 * numBY;
						while (index < numBY + numGR) {
							if (j <= d / 2) {
								color[index + d * x][j + d * y] = gr[offset];
							} else {
								color[index + d * x][j + d * y] = gr[(offset + 1) % 2];
							}
							
							index++;
						}
						
						while (index < d) {
							color[index + d * x][j + d * y] = by[(offset + 1) % 2];
							index++;
						}
					}
				}
			}
			
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					answer.append(color[i % (2 * d)][j % (2 * d)]);
				}
				answer.append("\n");
			}
		} else {
			char[][] color = new char[2 * d][2 * d];
			
			char[] rg = new char[]{'R', 'G'};
			char[] by = new char[]{'B', 'Y'};
			
			for (int x = 0; x < 2; x++) {
				for (int y = 0; y < 2; y++) {
					int offset = (x + y) % 2;
					
					for (int j = 0; j < d; j++) {
						int numRG = Math.abs(j - d / 2);
						int rgOffset = offset;
						if (j >= d / 2) {
							numRG++;
							rgOffset = (rgOffset + 1) % 2;
						}
						int otherNumRG = numRG - 1;
						
						int index = 0;
						while (index < numRG) {
							color[index + d * x][j + d * y] = rg[rgOffset];
							index++;
						}
						while (index + otherNumRG < d) {
							color[index + d * x][j + d * y] = by[offset];
							index++;
						}
						while (index < d) {
							color[index + d * x][j + d * y] = rg[(rgOffset + 1) % 2];
							index++;
						}
					}
				}
			}
			
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					answer.append(color[i % (2 * d)][j % (2 * d)]);
				}
				answer.append("\n");
			}
		}
		System.out.println(answer);
	}
}


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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define IFOR(i,n,m) for(ll i=(ll)(n);i>=(ll)(m);--i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) IFOR(i,n,0)

const ll MOD = 1000000007;

using namespace std;

int a[100005];
int b[100005];

int main()
{
	int N, x;
	cin >> N >> x;
	REP(i, N)
	{
		cin >> a[i];
	}
	memcpy(b, a, sizeof(int)*N);

	ll ans = 0;
	REP(i, N - 1)
	{
		if (a[i] + a[i + 1] > x)
		{
			ll d = a[i] + a[i + 1] - x;
			a[i + 1] = std::max(a[i + 1] - d, (ll)0);
			ans += d;
		}
	}

	ll ans2 = 0;
	IFOR(i, N - 1, 1)
	{
		if (b[i] + b[i - 1] > x)
		{
			ll d = b[i] + b[i - 1] - x;
			b[i - 1] = std::max(b[i - 1] - d, (ll)0);
			ans2 += d;
		}
	}

	cout << std::min(ans, ans2) << endl;
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
a, b, c = map(int, input().split())
k = int(input())

for i in range(k):
    if a == max(a, b, c):
        a, b, c = 2*a, b, c
    elif b == max(a, b, c):
        a, b, c = a, 2*b, c
    else:
        a, b, c = a, b, 2*c
    
print(a+b+c)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program {
	static void Main(string[] args) {
		new Calc().Solve();
	}
	public class Calc {
		private Utils.Scan cin = new Utils.Scan();
		public Calc() { }
		public void Solve() {
			var NT = cin.ReadLong(' ');
			var t = cin.ReadLong(' ');
			long s_time = t[0];
			long sum = 0;
			for (int i = 1; i < NT[0]; i++) {
				if (t[i] - t[i - 1] < NT[1]) { sum += t[i] - t[i - 1]; } else sum += NT[1];
			}
			sum += NT[1];
			sum.WL();
			return;
		}
	}
}
public static class Utils {
	public class Scan {
		public Scan() { }
		public int ReadInt() => Console.ReadLine().IntParse();
		public int[] ReadInt(char separator) => Console.ReadLine().Split(separator).Select(int.Parse).ToArray();
		public double ReadDouble() => double.Parse(Console.ReadLine());
		public double[] ReadDouble(char separator) => Console.ReadLine().Split(separator).Select(double.Parse).ToArray();
		public long ReadLong() => long.Parse(Console.ReadLine());
		public long[] ReadLong(char separator) => Console.ReadLine().Split(separator).Select(long.Parse).ToArray();
	}
	public static string Docking<T>(this IEnumerable<T> list, Func<T, string> filter = null) {
		StringBuilder sb = new StringBuilder();
		foreach (var item in list) {
			sb.Append(filter == null ? item.ToString() : filter(item));
		}
		return sb.ToString();
	}
	public static int IntParse(this string s) => int.Parse(s);
	public static void WL(this object obj) => Console.WriteLine(obj);
}

Measured memory_bytes: 32928
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
use std::collections::HashMap;
#[fastout]
fn main() {
    input! {
        n: usize,
        d: [usize; n],
        m: usize,
        t: [usize; m],
    }
    let mut map_d: HashMap<usize, usize> = HashMap::new();
    for i in 0..n {
        let counter = map_d.entry(d[i]).or_insert(0);
        *counter += 1;
    }
    for i in 0..m {
        let counter = map_d.entry(t[i]).or_insert(0);
        if *counter > 0 {
            *counter -= 1;
        } else {
            println!("NO");
            return;
        }
    }
    println!("YES");
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
long long mod = 1000000007;
 
long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}
 
void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
 
int main() {
    long long n, k, sum = 0;
    cin >> n >> k;
    vector<long> as(n);
    for (int i = 0; i < n; i++){
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    for (int i = 0; i < n - k; i++){
        sum += as[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<ll> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }

  int ans{};
  for (int i = 0; i != N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (L[i] == L[j]) continue;
      for (int k = j + 1; k < N; ++k) {
        if (L[i] == L[k] || L[j] == L[k]) continue;
        if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j])
          ++ans;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

void main()
{
    auto cin = new Scanner;
    string s;
    cin.scan(s);
    writeln(s.count('1'));
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
INF=10**10
n=int(input())
f=lambda:map(int,input().split())
s_min=t_min=INF
s_max=t_max=-INF
for _ in range(n):
  x,y=f()
  s_min=min(s_min,x+y)
  s_max=max(s_max,x+y)
  t_min=min(t_min,x-y)
  t_max=max(t_max,x-y)
print(max(s_max-s_min,t_max-t_min))

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

ll floor(ll A, ll B, ll x){
    ll kou1 = (A * x) / B;
    ll kou2 = x / B;
    kou2 = kou2*A;
    ll ans = kou1 - kou2;
    return ans;
}

int main()
{
    ll A, B, N; cin >> A >> B >> N;
    ll max_n;
    if(N<B){
        cout << floor(A, B, N) << endl;
    }else{
        cout << floor(A, B, B-1) << endl;
    }
}

Measured memory_bytes: 3672
#include <cmath>
#include <iostream>
#include <set>
#include <string>


#ifdef MY_LOCAL
namespace sandbox {
#endif

using namespace std;
int main()
{
	int k;
	cin >> k;

	string s;
	cin >> s;

	if (s.size() <= k)
		cout << s << endl;
	else
		cout << s.substr(0, k) + "..." << endl;

	return 0;
}

#ifdef MY_LOCAL
}
#endif

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  for(int i = 0; i < min(k, 50); i++){
    vector<int> imos(n);	 //I'll begin the imos method
    for(int j = 0; j < n; j++){
      int l = max(0, j-a[j]);
      int r = min(n-1, j+a[j]);
      imos[l]++;
      if(r+1 <= n-1){
      	imos[r+1]--;
      }
    }
    for(int k = 0; k < n; k++){
      if(k > 0){
        imos[k] += imos[k-1];
      }
    }
    for(int l = 0; l < n; l++){
      a[l] = imos[l];
    }
    //a = imos;
  }
  
  for(int i = 0; i < n; i++){
    cout << a[i] << " ";
  }
}


Measured memory_bytes: 4784
n=int(input())
s=list(str(input()))
m = [0 for i in range(len(s))]
if s[0] == ".":
    m[0] = 1
else:
    m[0] = 0
for i in range(1,len(s)):
    if s[i] == ".":
        m[i] = m[i-1]+1
    else:
        m[i] = m[i-1]
l = [0 for i in range(len(s)+1)]
l[0] = m[-1]
for i in range(1,len(s)+1):
    l[i] = i-m[i-1] + m[-1]-m[i-1]
print(min(l))


Measured memory_bytes: 20676
<?php

fscanf(STDIN, "%d", $num_count);
$target_num = array_map("intval", explode(" ", trim(fgets(STDIN))));
sort($target_num);

fscanf(STDIN, "%d", $search_count);
$keys = array_map("intval", explode(" ", trim(fgets(STDIN))));

$hash = [];
$hash[0] = true;

for ($i = 0; $i < $num_count; ++$i) { 
	$new_hash = [];
	foreach ($hash as $k => $v) {
		$new_hash[$k] = true;
		$new_hash[$k+$target_num[$i]] = true;
	}
	$hash = $new_hash;
}
ksort($hash);

foreach ($keys as $v) {
	if (isset($hash[$v])) echo "yes\n";
	else echo "no\n";
}




Measured memory_bytes: 9388
n,x = gets.chomp.split.map(&:to_i)
as = gets.chomp.split.map(&:to_i)
sum = Array.new(n-1,0)
ans = 0
(n-1).times do |i|
	sum[i] = as[i] + as[i+1]
end

(n-1).times do |i|
	next if sum[i] <= x
	diff = sum[i] - x
	ans += diff
	sum[i+1] -= [as[i+1], diff].min if i < n - 2
end

puts ans

Measured memory_bytes: 13060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,y;
  cin >> n >> k >> x >>y;
  int ans;
  if(n<=k) ans=n*x;
  else ans=k*x+(n-k)*y;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste
// #include "UnionFind.h"
// #include "power.h"

signed main() {
    int H, W;
    cin >> H >> W;
    int ans = H * W;
    int h, w;
    cin >> h >> w;
    ans -= (W * h);
    ans -= (H * w);
    ans += h * w;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 201
using namespace std;
typedef pair<int,int> P;
int h,w;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
string mp[N];

int bfs(char s){
  queue<P> Q;
  int D[N][N];
  memset(D,-1,sizeof(D));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) 
      if(mp[i][j]==s)Q.push(P(i,j)),D[i][j]=0;

  while(!Q.empty()){
    P t=Q.front();Q.pop();
    int y=t.first,x=t.second;
    if(mp[y][x]=='\%') return D[y][x];
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i];
      if(nx<0||ny<0||nx>=w||ny>=h||D[ny][nx]!=-1||mp[ny][nx]=='#')continue;
      
      Q.push(P(ny,nx));
      D[ny][nx]=D[y][x]+1;
    }
  }
  return 1e9;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>mp[i];
  cout <<((bfs('@')<bfs('$'))? "Yes":"No")<<endl;

  return 0;
}

Measured memory_bytes: 3524
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int pow3[10];

int main() {
  //
  ll n;
  cin >> n;
  queue<string> que;
  que.push("3");
  que.push("5");
  que.push("7");
  int ans = 0;
  while (true) {
    string s = que.front();
    // cout << s.size() << endl;
    que.pop();
    if (stoll(s) > n) break;
    int cnt[3] = {0};
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '3') cnt[0]++;
      if (s[i] == '5') cnt[1]++;
      if (s[i] == '7') cnt[2]++;
    }
    if (cnt[0] * cnt[1] * cnt[2] > 0) ans++;
    que.push(s + "3");
    que.push(s + "5");
    que.push(s + "7");
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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


int main() {

	int n;
	string s;
	char c[101],c2[101];
	int x[101]={},x2[101]={};

	cin>>n;
	cin>>s;

	int r=0;
	rep(i,n){
		x[i+1]=x[i];
		x2[i+1]=x2[i];
		if(s[i]=='('){
			x[i+1]++;
		}
		if(s[i]==')'){
			x2[i+1]++;
			if(x[i+1]==0){
				c[r]='(';
				r++;
			}else{
				x[i+1]--;
			}
		}
	}
	int l=0;
	rrep(i,n){
		if(s[i]=='('){
			if(x2[n]-x2[i+1]==0){
				c2[l]=')';
				l++;
			}else{
				x2[n]--;
			}
		}
	}
	rep(i,r){
		cout<<c[i];
	}
	cout<<s;

	rep(j,l){
		cout<<c2[j];
	}
	cout<<endl;
	return 0;

}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    K = int(input())
    S = input()
    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
#include <stdio.h>
#include <bits/stdc++.h>
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//																														tree<key, mapped = null_type, cmp = less<key>, rb_tree_tag, tree_order_statistics_node_update> name; order_of_key find_by_order

using namespace std;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fs first
#define sc second
#define abs(a) ((a) < 0 ? -(a) : (a))
#define sqr(a) ((a) * (a))

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

inline pair<pair<bool, bool>, pair<string, bool> > useinout();

void initialization() {
#ifdef SOL
	if (useinout().fs.fs)
		freopen("input.txt", "r", stdin);
	if (useinout().fs.sc)
		freopen("output.txt", "w", stdout);
#else
	srand(__rdtsc());
	const string file = useinout().sc.fs;
	if (!file.empty()) {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
	if(useinout().sc.sc) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
}

int solution();

void finish(int exitval) {
	fflush(stdout);
#ifdef SOL
	fprintf(stderr, "\nexit value: %d\ntime: %.3lf ms\n", exitval, 1000. * clock() / CLOCKS_PER_SEC);
#endif
}

int main() {
	initialization();
	finish(solution());
	return (0);
}

const double eps = 1e-9;
const int mod = (int) 1e+9 + 7;
const double pi = acos(-1.);
const int maxn = 100100;

int c[maxn], a[maxn];

int solution() {

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		c[a[i]]++;
	}
	int ans = 1;
	bool ok;
	if (n & 1) {
		ok = c[0] == 1;
		for (int i = 2; i < n; i += 2) {
			ok &= c[i] == 2;
			ans = ans * 2 % mod;
		}
	} else {
		ok = 1;
		for (int i = 1; i < n; i += 2) {
			ok &= c[i] == 2;
			ans = ans * 2 % mod;
		}
	}
	if (ok) {
		printf("%d", ans);
	} else {
		printf("0");
	}

	return (0);
}

inline pair<pair<bool, bool>, pair<string, bool> > useinout() {
	return (mp(mp(0, 0), mp("", 0)));
}

//by Andrey Kim


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld,lld> pi;
#define F first
#define S second
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (lld i = a; i < b; i++)
lld r,j,l,x,y,m,b,n,s,f,q,i,z,p,c,k,d,t,u,e,g;string s1,s2,s3,s4;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>n;lld a[n];
  rep(i,0,n)
  {
    cin>>a[i];/*
    p=n-(500*i);
    if(p<=a&&p>=0)
    {
      cout<<"Yes";return 0;
    }*/
  }sort(a,a+n);p=0;
  for(i=n-1;i>=0;i--)
  {
    if(p%2==0)
    {
      c+=a[i];
    }
    else
    {
      d+=a[i];
    }
    p++;
    //cout<<"No";
  }
  cout<<c-d;
} 

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,ko;
    ll x,y,w,z;
    char hoge,fuga;
    cin>>n>>a;
    n%=500;
    if(n<=a) Yes;
    else No;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
template<typename T>
inline T GET() {
	T val;
	cin >> val;
	return val;
}

void init();
void solve();

signed main()
{
    init();
    solve();
}

vector<int> a, dp;
int N;

void init()
{
	cin >> N;
	CINV(a, N);
}

void solve()
{
	dp.RS(N, INT_MAX);
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);
	reps(i, 2, N) {
		dp[i] = min(dp[i-2] + abs(a[i-2] - a[i]), dp[i-1] + abs(a[i-1] - a[i]));
	}
	cout << dp[N-1] << endl;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int d,t,s;
	cin>>d>>t>>s;
	double T;
	T=double(d)/double(s);
	if(T<=t)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
 }

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
 string s[3]={"Sunny","Cloudy","Rainy"};
 
 signed main(){
     string t;
     cin>>t;
     
     int k=find(s,s+3,t)-s;
     cout<<s[(k+1)%3]<<endl;
     return 0;
 }

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

int main() {
    int k,x; cin >> k >> x;
    if (500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3608
from itertools import permutations

N,M,R=map(int,input().split())
*r,=map(int,input().split())
inf=float("inf")
d=[[inf]*N for _ in range(N)]

for _ in range(M):
    A,B,C=map(int,input().split())
    d[A-1][B-1]=C
    d[B-1][A-1]=C

for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])

ans=inf
for i in permutations(r):
    v=0
    for j in range(R-1):
        v+=d[i[j]-1][i[j+1]-1]
    ans=min(ans,v)

print(ans)

Measured memory_bytes: 72664
import java.util.*;
 
public class Main {
  	public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      
      ArrayList<Integer> redApples = new ArrayList<Integer>();
      for (int i = 0; i < a; i++) {
        redApples.add(sc.nextInt());
      }
      ArrayList<Integer> greenApples = new ArrayList<Integer>();
      for (int j = 0; j < b; j++) {
        greenApples.add(sc.nextInt());
      }
      ArrayList<Integer> colorlessApples = new ArrayList<Integer>();
      for (int k = 0; k < c; k++) {
        colorlessApples.add(sc.nextInt());
      }
      
      Collections.sort(redApples, Collections.reverseOrder());
      Collections.sort(greenApples, Collections.reverseOrder());
      Collections.sort(colorlessApples, Collections.reverseOrder());
      
      ArrayList<Integer> allApples = new ArrayList<Integer>();
      allApples.addAll(redApples.subList(0, x));
      allApples.addAll(greenApples.subList(0, y));
      allApples.addAll(colorlessApples);
      Collections.sort(allApples, Collections.reverseOrder());
      
      long delicious = 0;
      for (int i = 0; i < x + y; i++) {
        delicious += (long)allApples.get(i);
      }
      System.out.println(delicious);
    }
}

Measured memory_bytes: 101228
#include<bits/stdc++.h>
#define N 1000001
using namespace std;
map<int,int> m;
vector<int> v;
int p,q,s,g,f;

int main(){
  while(cin>>p>>q){
    f=0;
    v.clear();
    m.clear();
    for(int i=0;i<80;i++){
      v.push_back(p/q);
      if(!(p%q)){
	f=1;
	break;
      }
      if(m.find(p%q)!=m.end()){
	s=m[p%q]+1,g=i;
	break;
      }
      m[p%q]=i;
      p%=q;
      p*=10;
    }
    for(int i=1;i<v.size();i++)cout<<v[i];
    cout<<endl;
    if(f)continue;
    for(int i=1;i<v.size();i++){
      if(s<=i&&i<=g)cout<<'^';
      else cout<<' ';
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
char s[N];int a[N],b[N],tot,n,res,k;
int main(){
	scanf("%d%d%s",&n,&k,s+1);
	tot=0;
	fp(i,1,n){
		if(s[i]!=s[i-1])b[++tot]=s[i]-'0';
		++a[tot];
	}
	fp(i,1,tot)a[i]+=a[i-1];
	fp(i,1,tot)if(b[i]==0)cmax(res,a[min(tot,i+k+k-1)]-a[i-1]);
	else cmax(res,a[min(tot,i+k+k)]-a[i-1]);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main()
{
	int S , h , m , s , f ;
	cin >> S ;
	h = S / 3600 ;
	f = S % 3600 ;
	m = f / 60 ;
	s = f % 60 ;
	cout << h <<":"<< m <<":"<< s << endl;
}

Measured memory_bytes: 1164
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

maxa = max(a)

a.remove(maxa)

half = maxa / 2
minabs_from_half = 10**18

ans = -1
for ai in a:
    if abs(half - ai) < minabs_from_half:
        ans = ai
        minabs_from_half = abs(half - ai)

print(maxa, ans)

Measured memory_bytes: 58864
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

vector<int> G[200010];
int v[200010], ans[200010];

void dfs(int now, int prev, int t){
    ans[now] = t;
    for(int nv: G[now])if(nv != prev){
        dfs(nv, now, t+v[nv]);
    }
}

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    rep(i, n-1){
        int a, b;
        scanf("%d%d", &a, &b);
        G[--a].push_back(--b);
        G[b].push_back(a);
    }
    rep(i, n) v[i] = ans[i] = 0;
    rep(i, q){
        int p, x;
        scanf("%d%d", &p, &x);
        v[--p] += x;
    }
    dfs(0, -1, v[0]);
    rep(i, n) printf("%d ", ans[i]);
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N,T;
  cin>>N>>T;
  vector<int>t(N);
  for(int i=0;i<N;i++)cin>>t[i];
  ll ans=0;
  for(int i=0;i<N-1;i++)ans+=max(t[i]+T-t[i+1],0ll);
  ans=N*T-ans;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

/*********** Constants ***********/
const auto INF = static_cast<ll>(1e15);
const auto MOD = static_cast<ll>(1e9 + 7);

/************* Utils *************/
struct Node {
    int key;
    Node *prev;
    Node *next;
};

void Init(Node **lst) {
    *lst = (Node *)malloc(sizeof(Node));
    (*lst)->next = *lst;
    (*lst)->prev = *lst;
}

void Insert(Node **lst, int key) {
    Node *n = (Node *)malloc(sizeof(Node));
    n->key = key;
    n->next = (*lst)->next;
    (*lst)->next->prev = n;
    (*lst)->next = n;
    n->prev = *lst;
}

void Delete(Node **lst, int x) {
    Node *del = (*lst)->next;
    while (del != *lst && del->key != x) {
        del = del->next;
    }
    if (del == *lst) {
        return;
    }
    del->prev->next = del->next;
    del->next->prev = del->prev;
    free(del);
}

void DeleteFirst(Node **lst) {
    Node *del = (*lst)->next;
    if (del == *lst) {
        return;
    }
    del->prev->next = del->next;
    del->next->prev = del->prev;
    free(del);
}

void DeleteLast(Node **lst) {
    Node *del = (*lst)->prev;
    if (del == *lst) {
        return;
    }
    del->prev->next = del->next;
    del->next->prev = del->prev;
    free(del);
}

/*********** Variables ***********/
ll N;
Node* List;

/*********** Functions ***********/
bool init() {
    Init(&List);
    cin >> N;
    string command; int key;
    for (ll i = 0; i < N; i++) {
        cin >> command;
        if (command == "insert") {
            cin >> key;
            Insert(&List, key);
        }
        else if (command == "delete") {
            cin >> key;
            Delete(&List, key);
        }
        else if (command == "deleteFirst") {
            DeleteFirst(&List);
        }
        else if (command == "deleteLast") {
            DeleteLast(&List);
        }
    }
    return true;
}

void solve() {
}

void output() {
    Node *show = List->next;
    bool first = true;
    while (show != List) {
        if (first) {
            cout << show->key;
            first = false;
        }
        else {
            cout << " " << show->key;
        }
        show = show->next;
    }
    cout << endl;
}

int main() {
    init();
    solve();
    output();
    return 0;
}


Measured memory_bytes: 34416
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            string[] In2 = Console.ReadLine().Split(' ');
            int[] V = new int[n];
            int[] C = new int[n];
            int max = -1001001001;
            for(int i=0; i < n; i++)
            {
                V[i] = int.Parse(In[i]);
                C[i] = int.Parse(In2[i]);
            }
            for (int i = 0; i < (1 << n); i++)
            {
                var d = new int[n];
                for (int j = 0; j < n; j++)
                {
                    if (((i >> j) & 1) == 1) { d[j] = 1; }
                }
                int sum = 0;
                for(int j = 0; j < n; j++)
                {
                    if (d[j] == 1)
                    {
                        sum += V[j]-C[j];
                    }
                }
                max = (int)Math.Max(max, sum);
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 46056
import java.util.Scanner;

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];
        int[] sum = new int[n + 1];
        for (int i = 0 ; i < n ; i++) {
            p[i] = sc.nextInt();
            sum[i + 1] = sum[i] + p[i];
        }
        int max = 0;
        for (int i = 0 ; i < n - k + 1 ; i++) {
            max = Math.max(max, sum[i + k] - sum[i]);
        }
        System.out.println((double) (max + k) / 2);
    }
}

Measured memory_bytes: 73208
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void Zalgorithm(string& S, vector<int>& A, int start)
{
	auto size = S.size() - start;
	A[0] = size;
	int i = 1, j = 0;
	while (i < size) {
		while (i + j < size && S[j + start] == S[i + j + start]) ++j;
		A[i] = j;
		if (j == 0) { ++i; continue; }
		int k = 1;
		while (i + k < size && k + A[k] < j)
		{
			A[i + k] = A[k];
			++k;
		}
		i += k; j -= k;
	}
}

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

	auto len = 0;
	for (auto i = 0; i < N; ++i)
	{
		vector<int> A(N - i);
		Zalgorithm(S, A, i);
		for (auto j = 1; j < N - i; ++j)
		{
			len = max(len, min(j, A[j]));
		}
	}
	cout << len << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
lst = list(map(int, input().split()))

M = max(lst)
m = min(lst)
ans = float("INF")

for i in range(m,M+1):
    num = 0
    for j in lst:
        num += (i-j)**2
    ans = min(ans, num)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;

  return 0;
}


Measured memory_bytes: 3592
/*2019/07/29 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
/*
int asc_t(const void *a,const void *b){return ((user_t*)a)->score - ((user_t*)b)->score;}
int desc_t(const void *a,const void *b){return ((user_t*)b)->score - ((user_t*)a)->score;}
*/

int main(){
    int n;
    double a[2000];

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lf",&a[i]);
    }
    double sum=0;
    for(int i=0;i<n;i++){
        sum+=1/a[i];
    }
    printf("%.8lf\n",1/sum);

    return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	string S;
	cin >> S;
	if(S=="AAA"||S=="BBB") cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<string,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
vi used;
bool H=false;
vvi G;
int dfs(int a){
	used[a]=true;
	int co=0;
	rep(i,G[a].size())if(used[G[a][i]]==0&&dfs(G[a][i]))co++;
	if(co>=2){
		H=true;
		return 0;
	}else if(co==1)return 0;
	else return 1;
}
int main(){
	cin>>n;
	G=vvi(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	used=vi(n);
	int t=dfs(0);
	if(t||H)cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}






Measured memory_bytes: 6272
using System;
using System.Linq;
using System.Text;

// チェスボードの描画

public class ITP1_5_C
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        StringBuilder sb = new StringBuilder();
        while (true)
        {
            int[] nums = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int h = nums[0];
            int w = nums[1];
            if (h == 0 && w == 0)
            {
                break;
            }
            // 偶数
            StringBuilder evenSb = new StringBuilder();
            // 奇数
            StringBuilder oddSb = new StringBuilder();
            for (int j = 0; j < w; j++)
            {
                evenSb.Append(j % 2 == 0 ? "#" : ".");
                oddSb.Append(j % 2 == 0 ? "." : "#");
            }
            string evenLine = evenSb.ToString();
            string oddLine = oddSb.ToString();
            for (int i = 0; i < h; i++)
            {
                sb.AppendLine(i % 2 == 0 ? evenLine : oddLine);
            }
            sb.AppendLine();
        }
        Console.Write(sb.ToString());
    }
}



Measured memory_bytes: 16368
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N;
  cin >> N;
  int x[100], y[100];
  ll h[100];
  int x_t, y_t, H_t;
  rep(i, N) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] >= 1) {
      x_t = x[i]; y_t = y[i]; H_t = h[i];
    }
  }
  int c_x, c_y, H;
  rep(c_xi, 101) rep(c_yi, 101) {
    bool flag = true;
    ll H_i = H_t + abs(x_t - c_xi) + abs(y_t - c_yi);
    rep(k, N) {
      H_i = max(H_i, 0LL);
      if (h[k] != max(H_i - abs(x[k] - c_xi) - abs(y[k] - c_yi), 0LL)) {
        flag = false;
      }
    }
    if (flag) {
      c_x = c_xi; c_y = c_yi; H = H_i;
    }
  }
  cout << c_x << " " << c_y << " " << H;
  return 0;
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int dx = c - a, dy = d - b;
    cout << c - dy << " " << d + dx << " " << a - dy << " " << b + dx << endl;
}

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

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

  long long ans = 1;
  if(abs(n-m) >= 2){
    cout << 0 << endl;
  }else{
    for(int i = 1;i <= n;i++){
      ans = (ans * i) % 1000000007;
    }
    for(int i = 1;i <= m;i++){
      ans = (ans * i) % 1000000007;
    }
    if(n == m) ans = (ans * 2) % 1000000007;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n = int(input())

TABLES = []
H = []
for _ in range(n):
    x, y, h = map(int, input().split())
    TABLE = [[0] * 101 for _ in range(101)]
    for i in range(101):
        for j in range(101):
            TABLE[i][j] = h + abs(x - i) + abs(y - j)
    TABLES.append(TABLE)
    H.append(h)

for k in range(n):
    if H[k] != 0:
        a = k
        break

for i in range(101):
    for j in range(101):
        temp = TABLES[a][i][j]
        flag = True
        for k in range(n):
            if H[k] == 0:
                if TABLES[k][i][j] < temp:
                    flag = False
                    break
            else:
                if TABLES[k][i][j] != temp:
                    flag = False
                    break
        if flag:
            print(i, j, temp)
            exit()


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

using namespace std;

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

    stack<char> st;
    for (auto c:s) {
        if (st.empty() or !(st.top() == 'S' and c == 'T')) {
            st.push(c);
        } else {
            st.pop();
        }
    }

    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 644
n = int(input())
list_a = []
for i in range(0,n):
    list_a.append(int(input()))
number = 0
count = 0
while True:
    number = list_a[number] - 1        
    count += 1
    if number == 1:
        print(count)
        break
    if count > n:
        print(-1)
        break


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    vector<int> a,b;
    forn(i,n){
        if(s[i]=='o'){
            a.pb(i);
            i+=c;
        }
    }
    ford(i,n){
        if(s[i]=='o'){
            b.pb(i);
            i-=c;
        }
    }
    forn(i,k){
        if(a[i]==b[k-i-1]) cout<<a[i]+1<<endl;
    }

    return 0;
}



Measured memory_bytes: 3468
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+10;
ll n,m,a,b,cnt;
ll head[N],bl[N];
struct Edge{ll nxt,to;}edge[N<<1];
inline void add(ll u,ll v){edge[++cnt]=(Edge){head[u],v};head[u]=cnt;}
void dfs(ll u,ll col){
	bl[u]=col;
	for(ll i=head[u];i;i=edge[i].nxt){
		ll v=edge[i].to;
		if(bl[v]==-1) dfs(v,!col);
		if(bl[v]!=!col){printf("%lld",n*(n-1)/2-m);exit(0);}
	}
}
int main(){
	scanf("%lld%lld",&n,&m);
	for(ll i=1;i<=m;i++) scanf("%lld%lld",&a,&b),add(a,b),add(b,a);
	memset(bl,-1,sizeof(bl));
	dfs(1,0);
	ll s1=0,s2=0;
	for(ll i=1;i<=n;i++){
		if(bl[i]==1) s1++;
		else if(bl[i]==0) s2++;
	}
	printf("%lld",s1*s2-m);
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, a, b;
	cin >> x >> a >> b;
	cout << (abs(x - a) < abs(x - b) ? 'A' : 'B') << endl;
	return 0;
}

Measured memory_bytes: 256
/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
/*
	"With self-discipline most anything is possible."
*/
	
	string s; cin >> s;
	
	for(long long i = 0; i < s.size(); i++) cout << 'x';
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5+10;
const int MOD = 1e9+7;

int a[N],n,m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> n >> m;
	for(int i=1;i<=n;++i){
		cin >> a[i];
		a[i] = (a[i]+a[i-1]) % m;
	}

	ll ans = 0;
	map<int, int> mp;
	mp[0] = 1;
	for(int i=1;i<=n;++i){
		if(i>=m) --mp[(a[i-m]+m-i%m)%m];
		int x = (a[i]+m-i%m) % m;
		auto itr = mp.find(x);
		if(itr != mp.end()) ans += itr->second;
		++mp[x];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10368
x,n = map(int,input().split())
sub_list=[0]*n

if n == 0: #n=0のとき
    print(x)
else: #n>=1のとき
    number_list = list(map(int,input().split()))
    for tmp in range(0,n):
        sub_list[int(tmp)]=abs(number_list[int(tmp)]-x) #xとの差をsub_listに格納
    sub_list.sort()

    if sub_list.count(0) == 0:
        print(x)
    else:
        for tmp in range(1,100):
            if sub_list.count(tmp) == 0:
                print(x-tmp)
                break
            elif sub_list.count(tmp) == 1:
                    Ans1=x-tmp
                    Ans2=x+tmp
                    if number_list.count(Ans1) == 0: #Ans1がnumber_listに存在しないならAns1が答え、存在するならAns2が答え
                        print(Ans1)
                    else:
                        print(Ans2)
                    break

Measured memory_bytes: 62080