akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<utility>
#include<string.h>
#include<queue>
#include<stack>
using namespace std;

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

int main(void)
{
    int n;
    scanf("%d\n",&n);
    long int a[3005]={};
    long long int ans=0;
    REP(i,n)
    {
        scanf("%ld ",&a[i]);
        ans+=a[i]-1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i32,
        x: i32,
        t: i32
    }

    let i = n / x;
    let j = if n % x == 0 { 0 } else { 1 };

    println!("{}", (i + j) * t);
}


Measured memory_bytes: 2176
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    a = s.count("-")
    b = s.count("+")
    print(b-a)
    return

#B
def B():
    n = S()
    num = sum(map(int, n))
    n = int("".join(n))
    print(["Yes", "No"][n % num > 0])
    return

#C
def C():
    n, k = LI()
    LI()
    print((n - k) // (k - 1) + 1 + bool((n - k) % (k - 1)))
    return

# D
# 解説AC
# 解説むずくね？これでわかる人いる？
# 順に理解していく
# 1) 桁数が上がるとx/S(x)が上昇するのは解説を見ればわかる
#
# 2) 下一桁が9であることを理解する
# xの下一桁が9でないとして
# x/S(x) - (x+1)/S(x+1) について S(x) =y として
# x/y - (x+1)/(y+1) = x/y - x/(y+1) - 1/(y+1)
#                   = x * (1/y - 1/(y+1)) - 1/(y+1)
#                   = x/y/(y+1) - 1/(y+1)
#                   = (x/y - 1)/(y+1) → (1)
# 今明らかにx/y >= 1なので (1) > 0 だから
# x/y > (x+1)/(y+1)
# よって下一桁は大きいほうがいいので9である
#
# 3)繰上りがない場合変化させる桁は
# できるだけ小さいほうがいいということを示す
# 元の数をxとしてi桁目とi+1桁目について変化させるとすると
# どう考えてもx/S(x)はS(x)は同等の上昇がみられる
# 対しi+1桁目のほうがxが上昇するためi桁目の
# ほうがよいことがわかる
# しかし、繰上りがある場合はどちらがいいかは直感的には言えない 
# 
# 4) 確定させた桁の数が9であり、変わらないことを示す
# つまり変化させられる桁(そこの桁をi桁目として10**(i-1)をxに足す
# と最小値がとりうると考えられる)がi桁目としてi-1桁目より小さな桁
# について変化させる意味がないことを示す 
# x/S(x) - (x+10^(i-1))/S(x+1) について上と同様にすれば
# = (x/y - 10**(i-1)) / y が言えるので 
# x/y が 10**(i-1) を上回っている場合
# その桁より小さい値を変化させるとx/S(x)が減少することがわかる
# x/S(x)がx以上の整数でx/S(x)を一番小さくできるのであるから、
# 一度上回った 10**(i-1) をx/S(x)が下回ることはあり得ない
# つまり極限まで大きくしておく必要のある最大桁以下はすべて9にしておく
# 
# 4)このまま毎回x/yの値を計算してそれの桁数から足す10**(i-1)
# を計算してもよいが、変化させる桁目をi桁目としてi+1桁目を変化させた
# ほうがx/S(x)が小さくなるという状態は
# つまりx/yが10**(i-1)を上回ったという
# 意味になるためもっと計算量を落とした方法が本解法になる 
def D():
    K = II()
    ans = 1
    i = 0
    def Sunuke(a):
        return a / sum(map(int, str(a)))
    def Check(a, i):
        return Sunuke(a + 10 ** i) > Sunuke(ans + 10 ** (i + 1))
    while K:
        print(ans)
        K -= 1
        i += Check(ans, i)
        ans += 10 ** i
    return


#Solve
if __name__ == '__main__':
    D()

Measured memory_bytes: 40816
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string s,t; cin >> s >> t;
    bool flag=false;
    for(int i=0; i<s.size(); i++){
        if(s==t){
            flag=true;
            break;
        }
        s=s.back() + s.substr(0,s.size()-1);
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

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

	string ans;
	if ((a == 0 or b == 0) or (a < 0 and b > 0)) {
		ans = "Zero";
	}
	else if (a > 0 and b > 0) {
		ans = "Positive";
	}
	else {
		if ((abs(a - b) + 1) % 2 == 0) ans = "Positive";
		else ans = "Negative";
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (n); i >= (t); --i)
#define LF          '\n'

#ifdef DBG
#define err(...)    fprintf(stderr, __VA_ARGS__)
#define dump(x)     clog << std::setw(6) << (#x) << ": " << (x) << endl
#else
#define err(...)
#define dump(x)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int K, X;
    cin >> K >> X;

    set<int> ans;
    reps(i, X-K+1, X + K-1) {
        ans.insert(i);
    }

    vector<int> hoge;
    for (int e : ans) hoge.emplace_back(e);

    cout << hoge << endl;

    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
from statistics import median, mean
N = int(input())
A = list(map(int, input().split()))
B = A[:]
for i in range(1, N + 1):
    B[i-1] = B[i-1] - i
b = median(B)
ans = 0
for i in range(N):
    ans += abs(A[i] - b - i - 1)
print(int(ans))

Measured memory_bytes: 27244
fun main(args: Array<String>) {
    solve()
}

fun solve() {
    val (n,a,b) = readLine()!!.split(' ').map { it.toLong() }

    val c = n/(a+b)
    var bl = c*a
    val re = c*b

    if (bl + re + a <= n) {
        bl += a
    } else {
        bl += (n - (bl + re))
    }

    println(bl)
}

Measured memory_bytes: 38244
N,M = map(int, input().split())
s,p = [False]*N, [0]*N
for i in range(M):
  tmp = input().split()
  pi,Si = int(tmp[0])-1, tmp[1]
  s[pi] |= Si == "AC"
  p[pi] += 1 if not s[pi] else 0
print(sum(s), sum([pi for si,pi in zip(s,p) if si]))


Measured memory_bytes: 5424
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    string s;
    int w;
    cin>>s>>w;
    
    for (int i = 0; i < s.size(); i+=w)
    {
        cout<<s[i];
    }
    cout<<endl;

    return 0;
}

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

class UnionFindTree {
public:
  UnionFindTree(i64 N) : trees(N, -1), height(N, 1), count(N, 1) {
  }

  void merge(i64 ia, i64 ib) {
    if(is_same_group(ia, ib)) {
      return;
    }

    if(height[ia] > height[ib]) {
      swap(ia, ib);
    }

    i64 rb = find_root(ib), ra = find_root(ia);
    count[rb] += count[ra];
    count[ra] = 0;

    while(trees[ia] != -1) {
      i64 next = trees[ia];
      trees[ia] = ib;
      ia = next;
    }
    trees[ia] = ib;
  }

  bool is_same_group(i64 ia, i64 ib) {
    return find_root(ia) == find_root(ib);
  }

  i64 find_root(i64 ia) {
    vi children;
    i64 i;
    while(trees[ia] != -1) {
      children.pb(ia);
      ia = trees[ia];
    }
    REP(0, sz(children), i) {
      trees[children[i]] = ia;
    }
    return ia;
  }

  vi trees;
  vi height;
  vi count;
};

int main(int argc, char *argv[]) {
  i64 N, M, i;
  cin >> N >> M;

  UnionFindTree tree(N);
  REP(0, M, i) {
    i64 a, b;
    cin >> a >> b;
    a--; b--;
    tree.merge(a, b);
  }

  unordered_set<i64> S;
  REP(0, N, i) {
    S.insert(tree.find_root(i));
  }
  cout << sz(S) - 1 << endl;

  return 0;
}


Measured memory_bytes: 8740
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	LL w, h;
	cin >> w >> h;
	LL a[w+1];
	LL b[h+1];
	for(LL i = 0; i < w; i++) cin >> a[i];
	for(LL i = 0; i < h; i++) cin >> b[i];
	sort(a,a+w);
	sort(b,b+h);
	a[w] = 1e9;
	b[h] = 1e9;
	LL s = 0;
	LL t = 0;
	LL ans = 0;
	LL lw = w+1;
	LL lh = h+1;
	while(s < w || t < h){
		if(a[s] < b[t]){
			ans += lh*a[s];
			lw--;
			s++;
		} else {
			ans += lw*b[t];
			t++;
			lh--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1920
import sys
DBG = not True
n,m =      map(int, input().split())
c = []
for i in range(n):
  a,b = map(int, input().split())
  c.append([a,b])

c.sort(key=lambda x: x[0])
if DBG:
    print(n)
    print(m)
    print(c)
money = 0
drink = 0
for i in range(n):
    ai = c[i][0]
    bi = c[i][1]
    if DBG:
        print("i {} d {} m {}".format(i, drink,money))
        print("ai {} bi {}".format(ai, bi))
    if drink + bi >= m:
        print(money + ai*(m-drink))
        break
    else:
        drink += bi
        money += ai * bi


Measured memory_bytes: 21216
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int n, m;
int br[N];
int dp[N];

int main()
{
  cin >> n >> m;
  while(m--){
    int a;
    cin >> a;
    br[a] = 1;
  }
  dp[n] = 1;
  for(int i = n - 1 ; i >= 0 ; i--){
    if(br[i]){
      dp[i] = 0;
    }else{
      if(!br[i + 1])
        dp[i] = (dp[i + 1] + dp[i]) % mod;
      if(!br[i + 2])
        dp[i] = (dp[i] + dp[i + 2]) % mod;
    }
  }
  cout << dp[0] << endl;
  return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    int N, A, B;
    if (scanf("%d%d%d", &N, &A, &B) < 3) return 0;

    printf("%d\n", B < N * A ? B : N * A);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
namespace _5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> H = new List<int>();
            List<int> W = new List<int>();
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] == 0 && x[1] == 0)
                {
                    break;
                }
                else
                {
                    H.Add(x[0]);
                    W.Add(x[1]);
                }
            }
            for (int X = 0; X < H.Count; X++)
            {
                for (int i = 0; i < W[X]; i++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
                for (int i = 1; i < H[X] - 1; i++)
                {
                    Console.Write("#");
                    for (int I = 1; I < W[X] - 1; I++)
                    {
                        Console.Write(".");
                    }
                    Console.WriteLine("#");
                }
                for (int i = 0; i < W[X]; i++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
                Console.WriteLine();
            }
        }
    }
}

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

int main() {
  int a[9], n;
  for(int i = 0; i < 9; i++) {
    cin >> a[i];
  }
  cin >> n;
  int b[n];
  for(int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 9; j++) {
      if(a[j] == b[i]) {
        a[j] = 0;
      }
    }
  }
  for(int i = 0; i < 3; i++) {
  if(a[i] == a[i + 3] && a[i] == a[i + 6]) {
    cout << "Yes";
    return 0;
  } else if(a[i * 3] == a[i * 3 + 1] && a[i] == a[i * 3 + 2]) {
    cout << "Yes";
    return 0;
  }
  }
  if(a[0] == a[4] && a[0] == a[8]) {
    cout << "Yes";
    return 0;
  } else if(a[2] == a[4] && a[2] == a[6]) {
    cout << "Yes";
    return 0;
  }
  cout << "No";
}


Measured memory_bytes: 256
local printx = print
local print = function()end
local function sign(a)
  if a>0 then return 1
  elseif a<0 then return -1
  else return 0 end
end
local N = io.read("n")
local A = {}
for i=1,N do A[i] = io.read("n") end
local gans=10^18
for k=-1,1,2 do
  local ans = 0
  local sum = 0
  local s = k
  for i=1,N do
    local newsum = sum + A[i]
    print("i",i,"A[i]",A[i],"sum",sum,"newsum",newsum)
    if sign(newsum) ~= s then
      local add = math.abs(newsum) + 1
      ans = ans + add
      sum = s
      print("abs(add)",add)
    else
      sum = newsum
    end
    s = s * -1
  end
  print("k",k,A[i],sum,ans)
  print()
  gans = math.min(gans, ans)
end
printx(gans)

Measured memory_bytes: 2424
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	vint a(4), b(4);
	while(true)
	{
		rep(i, 8)
			cin >> (i < 4 ? a[i] : b[i-4]);
		if(cin.eof()) break;

		int hit = 0;
		rep(i, 4)
			hit += a[i] == b[i];

		int brow = -hit;
		rep(i, 4)
			brow += (a[i] == b[0] || a[i] == b[1] || a[i] == b[2] || a[i] == b[3]);
		cout << hit << " " << brow << endl;
	}
}

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

using namespace std;

typedef long long int ll;

const ll MAXN = 505;

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

  ll n;
  cin >> n;
  vector < set < ll > > v;
  set < ll > s;
  s.insert(1);
  v.push_back(s);
  v.push_back(s);

  if(n == 1){
    cout << "Yes" << endl;
    cout << 2 << endl;
    cout << "1 1" << endl;
    cout << "1 1" << endl;
    return 0;
  }

  int i = 2;
  for( ; ; ){
    set < ll > s;
    for(auto &j : v){
      j.insert(i);
      s.insert(i);
      i++;
    }
    v.push_back(s);

    if(i - 1 == n){
      cout << "Yes" << endl;
      cout << v.size() << endl;
      for(auto i : v){
        cout << i.size() << " ";
        for(auto j : i) cout << j << " ";
        cout << endl;
      }
      return 0;
    }else if(i - 1 > n){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 10880
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=max(A)

import fractions
ans=A[0]
for i in range(1,N):
  ans=fractions.gcd(ans,A[i])
if K>a:
  print('IMPOSSIBLE')
  exit()
if (a-K)%ans==0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 14224
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x[3],i,j,y[2],ans1=0,ans2=0,ans3;
	for(i=0;i<3;i++){
		cin>>x[i];
	}
	sort(x,x+3);
	ans1=x[0];
	for(j=0;j<2;j++){
		cin>>y[j];
	}
	sort(y,y+2);
	ans2=y[0];
	ans3=ans1+ans2-50;
	cout<<ans3<<endl;
	return 0;
}

Measured memory_bytes: 3036
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int dp[110][4][2];

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

  int ns = n.size();
  dp[0][0][0] = 1;
  for(int i = 0; i < ns; ++i){
    int nd = n[i] - '0';
    for(int j = 0; j < 4; ++j){
      for(int k = 0; k < 2; ++k){
        for(int d = 0; d <= (k ? 9 : nd); ++d){
          int nj = j;
          if(d)++nj;
          if(nj > K)continue;
          dp[i + 1][nj][k || (d < nd)] += dp[i][j][k];
        }
      }
    }
  }

  cout << dp[ns][K][0] + dp[ns][K][1] << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp
T = gets.chomp

sx = S.split('')
tx = T.split('')

from_hash = {}
to_hash = {}

no = false
sx.zip(tx).each do |s, t|
  if from_hash[s].nil?
    from_hash[s] = t
  end
  if to_hash[t].nil?
    to_hash[t] = s
  end

  if from_hash[s] != t
    no = true
    break
  end

  if to_hash[t] != s
    no = true
    break
  end
end

puts no ? 'No' : 'Yes'


Measured memory_bytes: 45632
N,Y=map(int,input().split())
ans=(-1,-1,-1)
for x in range(N+1):
    for y in range(N+1-x):
        z=N-x-y
        if 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  string s, t;
  cin >> s >> t;
  if (s.size() + 1 != t.size()){
	cout << "No" << endl;
	return 0;
  }
  forll(i, 0, s.size()){
	if(s[i] != t[i]){
	  cout << "No" << endl;
	  return 0;
	}
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[2010100], rf[2010100];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    repi(i, 1, 2010010) f[i] = (f[i - 1] * i) % mod;
    repi(i, 0, 2010010) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

ll fun(ll r, ll c){
    if(r==0&&c==0)return 1;
    else if(r==0||c==0)return max(r,c)+1;
    ll ans = 0;
    rep(i,c+1)ans = (ans + C(r+1+i,i+1)) % mod;
    return ans;
}

ll r1,r2,c1,c2;

int main(){
    cin>>r1>>c1>>r2>>c2;
    init();
    out((fun(r2,c2) - fun(r1-1,c2) - fun(r2, c1-1) + fun(r1-1,c1-1) + mod + mod)%mod);
}

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

int main()
{
    ll x;
    cin >> x;

    int five_hundred = x / 500;
    x %= 500;

    int five = x/5 ;

    cout << five_hundred*1000+five*5 << endl ;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    VI v(n);
    REP(i,n) cin >> v[i];
    LL ans=0;
    REP(i,n-1) {
        ans+=min((LL)b, (LL)(v[i+1]-v[i])*a);
    }
    cout << ans << endl;
    return 0;
}


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


const int INF = 1e9 + 5;

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i =0; i < n; i++){
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    vector<vector<int>> dp(n+1, vector<int>(3));
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;

    for(int i = 0; i< n; i++){
        dp[i+1][0] =  max(dp[i][1], dp[i][2]) + a[i];
        dp[i+1][1] = max(dp[i][0], dp[i][2]) + b[i];
        dp[i+1][2] = max(dp[i][1], dp[i][0]) + c[i];
    }

    printf("%d\n", max(dp[n][0], max(dp[n][1], dp[n][2])));


    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

bool check(int x){
    int xx = sqrt(x);
    xx++;
    rep(i, xx){
        if(i==0 or i==1) continue;
        if(x%i==0) return false;
    }
    return true;
}

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

    while(1){
        if (check(x)){
            cout << x << endl;
            return 0;
        }
        x++;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

from collections import defaultdict

ns = defaultdict(set)
ss = [None] * rows
for i in range(rows):
    s = input()
    ss[i] = s
n = rows * cols
start = ch*w+cw
goal = dh*w+dw
seen = [None]*n
seen[start] = 0
from heapq import heappop as hpp, heappush as hp
q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
# dx = [0,1,0,-1]
# dy = [1,0,-1,0]
dx = []
dy = []
vvs = []
for i in range(-2,3):
    for j in range(-2,3):
        if not (i==j==0):
            dx.append(i)
            dy.append(j)
            if abs(i)+abs(j)>1:
                vvs.append(1)
            else:
                vvs.append(0)
while q:
    pnum,pu = hpp(q)
    ux,uy = divmod(pu,w)
    # print(pnum,divmod(pu,w))
    if pu==goal:
        break
    for xx,yy,vv in zip(dx,dy,vvs):
#         x = ux+xx
#         y = uy+yy
        x,y = ux+xx, uy+yy
        u = x*w + y
        num = pnum+vv
        if x<0 or y<0 or x>=h or y>=w or ss[x][y]=="#":
            continue
#         print(x,y)
        if seen[u] is None or seen[u]>num:
            seen[u] = num
            hp(q, (num, u))
val = seen[goal]
if val is None:
    print(-1)
else:
    print(val)

Measured memory_bytes: 104108
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
typedef long long Int;
#define INF (1<<28)

int n, a[4096];
int dp[4096][4096], fr[4096][4096];
Int s[4096];

int main() {
    scanf("%d", &n);
    rep (i, n) scanf("%d", a+i);
    rep (i, n) s[i+1] = s[i] + a[i];
    rep (i, n) dp[0][i+1] = 1;
    rep (i, n) {
        vector<pair<Int, int> > v;
        rep (j, i) v.push_back(mp(s[i]-s[j], j));
        for (int j = i+1; j <= n; j++) v.push_back(mp(s[j]-s[i], -j));
        sort(v.begin(), v.end());
        int mx = 0, mi = -1;
        rep (k, v.size()) {
            const int j = v[k].second;
            if (j < 0) {
                if (mi != -1) {
                    dp[i][-j] = mx + 1;
                    fr[i][-j] = mi;
                }
            }
            else {
                if (mx < dp[j][i]) {
                    mx = dp[j][i];
                    mi = j;
                }
            }
        }
    }
    int ans = -1, pre = -1;
    rep (i, n) {
        if (ans < dp[i][n]) {
            ans = dp[i][n];
            pre = i;
        }
    }
    printf("%d\n", ans);
    vector<int> ax;
    int cur = n;
    while (pre != 0) {
        ax.push_back(pre);
        const int npre = fr[pre][cur];
        cur = pre;
        pre = npre;
    }
    rep (i, ax.size()) {
        if (i) putchar(' ');
        printf("%d", ax[ax.size()-1-i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 132264
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

ll n,a[100005],inv[100005],f[100005],mod=1e9+7,s,l,r,ans;

ll pwr(ll a, ll p){
    if(!p) return 1;
    ll t=pwr(a,p/2);
    t*=t; t%=mod;
    if(p%2) t*=a,t%=mod;
    return t;
}


int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n; f[0]=1;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        inv[i]=pwr(i,mod-2);
        s+=inv[i];
        s%=mod;
        f[i]=f[i-1]*i%mod;
    }
    l=2; r=n;
    for(int i=1;i<=n;i++){
        ans+=s*a[i]; ans%=mod;
        s+=inv[l]; s-=inv[r];
        s%=mod; if(s<0) s+=mod;
        l++; r--;
    }
    ans*=f[n]; ans%=mod;
    cout << ans;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <limits>
#include <iomanip>
#include <bitset>

#define INF 1000000000
#define Inf 1000000000000000000
#define mp make_pair
#define pb push_back
#define EPS 1e-9

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

int c[30], idx, sz;
ll ans;
char s[200010];

int main() {
    //freopen("in","r",stdin);
    
    scanf("%s", s);
    
    ans = 1;
    
    sz = strlen(s);

    for(int i = 0; i < sz; ++i) {
        idx = s[i] - 'a';
        ans += (i - c[idx]);
        ++c[idx];
    }
    
    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
signed main()
{
	int k, n, a[200000], ans = 1 << 30;
	scanf("%d%d", &k, &n);
	for(int i = 0; i < n; scanf("%d", &a[i++]));
	for(int i = 0; i < n; ++i)
	{
		ans = min(ans, k - ((a[(i + 1) % n] - a[i] + k) % k));
	}
	printf("%d\n", ans);
}


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

int main() {
    string a, b;
    cin >> a >> b;
    int flag = 0;
    if (a.size() > b.size()){
        flag = 1;
    }
    else if (a.size() < b.size()){
        flag = 2;
    }
    else{
        for (int i = 0; i < a.size(); i++){
            if(a.at(i) == b.at(i)){
                continue;
            }
            else if (a.at(i) > b.at(i)){
                flag = 1;
                break;
            }
            else{
                flag = 2;
                break;
            }
        }
    }

    if (flag == 0){
        cout << "EQUAL" << endl;
    }
    else if (flag == 1){
        cout << "GREATER" << endl;
    }
    else{
        cout << "LESS" << endl;
    }
}

Measured memory_bytes: 256
import math
import sys
sys.setrecursionlimit(10 ** 6 + 10)
from collections import defaultdict

def kari():
    map(int, input().split())

    num, num2 = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num2)]

def main():
    r, D, x = map(int, input().split())

    for i in range(10):
        x = r * x - D
        print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	if a <= b {
		for i := 0; i < b; i++ {
			putf("%d", a)
		}
		putf("\n")
	} else if a > b {
		for i := 0; i < a; i++ {
			putf("%d", b)
		}
		putf("\n")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

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

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define HSORT(V,n) sort(V,V+n)
#define RSORT(V) sort((V).rbegin(), (V).rend())
#define INF 2147483647
#define MININF -INF
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(void){
    int n;
    cin >> n;
    int l[n];
    rep(i,n){
        cin >> l[i];
    }
    HSORT(l,n);
    int c = 0;
    rep(i,n-2){
        FOR(j,i+1,n-1){
            FOR(k,j+1,n){
                if (abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j]){
                    c++;
                }
                else break;
            }
        }
    }
    PRINT(c);
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

typedef long long LL;

int main (){
    LL n,a,b,C,D;
    cin >> n >>a >>b >>C >> D;
    string ans="NO";
    for (int i=0;n-1>=i;i++) {
        LL mn=-i*D+(n-1-i)*C,mx=(n-1-i)*D-i*C;
        if (mn <= b-a && b-a<=mx) ans="YES";
    }
    cout<<ans<<endl;
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 2010;
bitset<N * N> d;

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	d[0] = 1;
	int n;
	cin >> n;
	int sum = 0;
	forn(i, n) {
		int a;
		cin >> a;
		sum += a;
		d |= (d << a);
	}
	for (int i = (sum + 1) / 2; i <= sum; ++i) {
		if (d[i]) {
		 	cout << i << endl;
		 	return 0;
		}
	}
	assert(0);

	return 0;
}

Measured memory_bytes: 1664
// #define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//functions: set.insert(val), *(set.find_by_order(order-1)), set.order_of_key(val)

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

const ll mod = 1e9+7;
const ll N = 1e6+6;
const ll maxN = 1e5+5;
const ll MAX_SIZE = 2e6+6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = mod){ // default argument
ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;}

ll power(ll x, ll y){
ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;}

int main()
{
    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif
    
    FIO
    ll n, d;
	cin >> n >> d;
	d = d * d;
	ll cnt = 0;
	FOR(i, n) {
		ll x, y;
		cin >> x >> y;
		if (x * x + y * y <= d) cnt++;
	}
	cout << cnt;
    return 0;
}




Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;

ll N, K, AI;
vector<ll> A1, A2;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N >> K;
    for (ll i = 0; i < N; i++) {
        cin >> AI;
        if (AI < 0) A1.push_back(AI);
        else A2.push_back(AI);
    }
    sort(A1.begin(), A1.end(), greater<ll>());
    
    ll ans = 1e15;
    for (ll i = 0; i < min((ll)A1.size(), K-1); i++) {
        if (A2.size() < K-i-1) continue;
        ans = min(ans, 2*abs(A1[i]) + A2[K-i-2]);
    }
    
    for (ll i = 0; i < min((ll)A2.size(), K-1); i++) {
        if (A1.size() < K-i-1) continue;
        ans = min(ans, 2*A2[i] + abs(A1[K-i-2]));
    }
    
    if (A1.size() >= K) ans = min(ans, abs(A1[K-1]));
    if (A2.size() >= K) ans = min(ans, A2[K-1]);
    cout << ans << "\n";
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	string s;cin>>s;
	string alp="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	rep(i,0,s.length()){
		ll j=int(s[i])-65;
		j=(j+n+26)%26;
		cout<<alp[j];
	}
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

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

const int inf = 1<<29;

struct Edge {
  int src,dst;
  int weight;
  Edge(int src, int dst, int weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int dist[101][101];

bool augment(const Graph& g, int u,
	     vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  for(Edges::const_iterator e = g[u].begin(); e != g[u].end(); ++e)
    if (!visited[e->dst]) {
      visited[e->dst] = true;
      if (augment(g, matchTo[e->dst], matchTo, visited)) {
	matchTo[e->src] = e->dst;
	matchTo[e->dst] = e->src;
	return true;
      }
    }
  return false;
}

int bipartiteMatching(const Graph& g, int L, Edges& matching) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  for(int u=0; u<L; ++u) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  for(int u=0; u<L; ++u)
    if (matchTo[u] >= 0) // make explicit matching
        matching.push_back( Edge(u, matchTo[u], 1) );
  return match;
}

int main() {
    int N,M,L,u,v,d,p,t;
    while(scanf("%d %d %d", &N, &M, &L), N|M|L) {
        REP(i, 100) {
            REP(j, 100) dist[i][j] = inf;
            dist[i][i] = 0;
        }

        REP(i,M) {
            scanf("%d %d %d", &u, &v, &d);
            dist[u][v] = dist[v][u] = d;
        }

        REP(k, N) REP(i, N) REP(j, N)
            dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);

        vector<pair<int,int> > reqs;
        Graph g(L*2);
        REP(i,L) {
            scanf("%d %d", &p, &t);
            reqs.push_back(make_pair(p,t));
        }

        REP(i,L) {
            REP(j,L) {
                if(reqs[j].second <= reqs[i].second) continue;
                if(reqs[j].second - reqs[i].second
                   >= dist[reqs[i].first][reqs[j].first]) {
                    g[i].push_back(Edge(i,j+L,1));
                    // printf("add %d to %d\n", i, j);
                }
            }
        }


        Edges es;
        printf("%d\n", L - bipartiteMatching(g,L,es));
    }
}

Measured memory_bytes: 8700
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
using namespace std;

int main() {
  int N,k, counter = 1;
  cin >> N;
  vector<int> d(N);
  for (int i=0; i<N; i++){
    cin >> d.at(i);
  }
  
  for (int i = 0; i<N; i++){
    k = i+1;
    while (k<N){
      if (d.at(i)==d.at(k)) {
        break;
      }
      if (k ==N-1){
        counter ++;
      }
      k++;
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;

typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

//constexpr long long MOD = (ll) 1e9+7;
constexpr long long MOD = 998244353;

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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}


void solve() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << c <<" "<< a <<" "<< b<<en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#                         author:  kagemeka 
#                         created: 2019-11-08 15:54:47(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version)  


def stringRotation(s):
    # |s| must be more than 1
    return s[-1] + s[:-1]


def main():
    s, t = sys.stdin.read().split()
    for _ in range(len(s)):
        if s == t:
            ans = 'Yes'
            break
        s = stringRotation(s)
    else:
        ans = 'No'
    
    print(ans)



if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>
#include<queue>
#include<set>


#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}



bool comp(const pair<long long int, vector<int>> a, const pair<long long int, vector<int>> b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}
	else {
		return a.second < b.second;
	}

}






bool searchMan(string str, string kouho) {
	bool result = false;
	int kouho_index = 0;

	for (int i = 0; i < str.size(); i++) {
		if (str[i] == kouho[kouho_index]) {
			kouho_index++;
			if (kouho_index == 3)break;
		}
	}

	if (kouho_index == 3)return true;

	return false;
}



int main(){

	int n;
	cin >> n;

	string str;
	cin >> str;

	int ans = 0;

	//全部試す
	for (int i = 0; i < 1000; i++) {
		string kouho;
		kouho = to_string(i);

		//ゼロパディング
		while (kouho.size() < 3) {
			kouho = "0" + kouho;
		}

		if (searchMan(str, kouho))ans++;




	}

	cout << ans << endl;
	

	return 0;
}



Measured memory_bytes: 384