akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll n,m;
  cin >> n >> m;
 
 vp ans;
 ll d=m; 
 for(int i=1;i<=n&&d>0;i++){
  ans.eb(P(i,i+d)); 
  d-=2; 
 }
  d=m-1;
 for(int i=n;i>=0&&d>0;i--){
  ans.eb(P(i-d,i)); 
  d-=2; 
 } 
  
 for(auto p:ans) cout << p.fi << " " << p.se << endl; 
  
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 5156
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

// i の j 乗を取る関数　MODをとる
ll mpow(ll i, ll j)
{
  if (j == 0) return 1;
  ll res = mpow(i, j / 2) % MOD;
  res = (res * res) % MOD;
  return (j & 1) ? (res * i) % MOD : res;
}

ll comb(ll n, ll i)
{
  ll bunbo = 1, bunsi = 1;
  ll k = i;
  rep(j, k) {
    bunbo *= n;
    bunsi *= i;
    n--; i--;
  }
  return (bunbo / bunsi);
}

int main()
{
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  ll result = 0;
  reverse(s.begin(), s.end());
  if (p == 2) {
    rep(i,s.size()) {
      if ((s[i] - '0') % 2 == 0) {
        result += n-i;
      }
    }
  } else if (p == 5) {
    rep(i,s.size()) {
      if ((s[i] - '0') % 5 == 0) {
        result += n-i;
      }
    }
  } else {
    // 桁ごとにmodを求める
    vector<int> m(p, 0);
    vector<int> keta(200005, 0);
    int now = 0;
    ll ten = 1;
    rep(i,n) {
      keta[i] = (s[i] - '0') * ten % p;
      (ten *= 10) %= p;
    }

    // 累積和を求める
    rep(i,n) {
      now += keta[i];
      now %= p;
      m[now]++;
    }

    // modが同じ値になっているものの数で組み合わせを求める
    rep(i,p) {
      if (i == 0) result += m[i];
      result += comb(m[i], 2);
    }
  }
  cout << result << endl;
}



Measured memory_bytes: 1284
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            var M = cin.ReadInt;
            var str = "";
            if (N >= M)
            {
                for (int i = 0; i < N; i++)
                {
                    str += M.ToString();
                }
            }
            else
            {
                for (int i = 0; i < M; i++)
                {
                    str += N.ToString();
                }
            }
            WriteLine("{0}", str);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

    cout << max({a+b, a-b, a*b}) << endl;
    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, b, c,ans;
	1 <= a, b, c <= 100;
	scanf("%d %d %d", &a, &b, &c);
	ans = b - a;
	if (ans == c - b){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	off;
	int n;cin>>n;
	if(n == 1)
	{
		cout<<"Yes";
		return 0;
	}
	vector<int> arr(n);
	rep(i,0,n)
	cin>>arr[i];
	bool ok = true;
	rep(i,n-1,0)
	{
		int diff = arr[i]-arr[i+1];
		if(diff <= 1)
		{
			if(diff == 1)
				arr[i]--;
		}
		else
		{
			ok =false;
			break;
		}
	}
	if(ok)
		cout<<"Yes";
	else
		cout<<"No";
  	return 0;
}

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

string S,T;

bool judge_in_ith(int i){
	for(int j=0;j<T.length();j++){
		if(S[i+j] != '?' && S[i+j] != T[j]){
			return false;
		}
	}
	return true;
}

int find_max_index(){
	int start = S.length() - T.length();
	for(int i=start;0<=i;i--){
		if(judge_in_ith(i)) return i;
	}
	return -1;
}


int solve(){
	if(S.length()<T.length()){
		cout << "UNRESTORABLE" << endl;
		return 0;
	} 

	int index = find_max_index();


	if(index == -1){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	for(int i=0;i<T.length();i++){
		S[index+i] = T[i];
	}

	for(int i=0;i<S.length();i++){
		if(S[i]=='?') S[i] = 'a';
	}
	cout << S << endl;

	return 0;
}

int main(){
	cin >> S;
	cin >> T;
	solve();
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
if M :
    list = [input().split() for i in range(M)]

right = 0
wrong = 0
question = [0 for i in range(N+1)]
wrong_count = [0 for i in range(N+1)]

for i in range(M):
    if list[i][1] == "AC" :
        if question[int(list[i][0])] != 1 :
            right += 1
            wrong += wrong_count[int(list[i][0])]
            question[int(list[i][0])] = 1
    else :
        if question[int(list[i][0])] != 1:
            wrong_count[int(list[i][0])] += 1

print("{} {}".format(right, wrong))


Measured memory_bytes: 33912
import bisect

class BinaryIndexedTree:
    # http://hos.ac/slides/20140319_bit.pdf
    def __init__(self, size):
        self._bit = [0 for _ in range(size)]
        self._size = size
 
    def add(self, i, w):
        x = i + 1
        while x <= self._size:
            self._bit[x - 1] += w
            x += x & -x
 
    def sum(self, i):
        ret = 0
        x = i + 1
        while x > 0:
            ret += self._bit[x - 1]
            x -= x & -x
        return ret
 
    def __len__(self):
        return self._size
 
 
def count_inversions(li, max=None):
    if not max:
        max = __builtins__.max(li)
    bit = BinaryIndexedTree(size=max + 1)
    ret = 0
    for i in range(len(li)):
        ret += i - bit.sum(li[i])
        bit.add(li[i], 1)
    return ret

  
n,k = map(int, input().split())
a = list(map(int, input().split()))
sorted_a = sorted(a)
d = 0
tree = [0] * (n+1) 
mod = 10 ** 9 + 7
ans = (count_inversions(a, max=max(a)) * k) % mod

for i in a:
  d += bisect.bisect_left(sorted_a, i)

ans += (d*((k*(k-1))//2)) % mod 
print(ans%mod)

Measured memory_bytes: 3188
s = input()
from collections import defaultdict
d = defaultdict(bool)
def inv(c):
    dic = {"W":"E", "E":"W", "S":"N", "N":"S"}
    return dic[c]
for c in s:
    d[c] = True
def sol():
    for c in "NSWE":
        if d[c] == True and d[inv(c)] == False:
            return False
    return True
print("YNeos"[not sol()::2])  

Measured memory_bytes: 3316
N=gets.chomp.to_i
B=gets.chomp.split.map(&:to_i)

if N==1
  puts B.first
else
  ans = B.first + B.last
  (B.size-1).times do |i|
    ans += [B[i],B[i+1]].min
  end
  puts ans
end

Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class SegmentTree:
  __slots__ = ['ide','n','seg','segfunc']

  def __init__(self,size,func,element):
    self.segfunc = func
    self.ide = element
    # self.size = sizeを超える最小の2冪の数
    self.n = 2 ** (n-1).bit_length()
    # 全てのnodeの数は(2*n-1)個
    # 上にn-1個,最下段にn個
    self.seg = [self.ide] * (2*self.n-1)

  def apply(self,array):
    arraysize = len(array)
    # 配列埋め込み
    for i in range(arraysize):
      self.seg[self.n-1+i] = array[i]
    # 上にあげる
    for i in range(self.n-2,-1,-1):
      self.seg[i] = self.segfunc(self.seg[2*i+1],self.seg[2*i+2])

  def update(self,k,x):
    k += self.n -1
    self.seg[k] = x
    while k:
      k = (k-1)//2
      self.seg[k] = self.segfunc(self.seg[2*k+1],self.seg[2*k+2])

  def query(self,l,r):
    # 半開区間[l,r)
    l += self.n-1; r += self.n-1
    vl = vr = self.ide
    while l < r:
      if l & 1 == 0:
        vl = self.segfunc(vl,self.seg[l])
        l += 1
      if r & 1 == 0:
        vr = self.segfunc(vr,self.seg[r-1])
      l = (l-1)//2; r = (r-1)//2
    return self.segfunc(vl,vr)

  def query1(self,l,r):
    # 半開区間[l,r)
    l += self.n-1; r += self.n-1
    res = self.ide
    while l < r:
      if l & 1 == 0:
        res = self.segfunc(res,self.seg[l])
        l += 1
      if r & 1 == 0:
        res = self.segfunc(res,self.seg[r-1])
      l = (l-1)//2; r = (r-1)//2
    return res

  def query2(self, p, q):
      if q <= p:
          return self.ide
      p += self.n - 1
      q += self.n - 2
      res = self.ide
      while q - p > 1:
          if p & 1 == 0:
              res = self.segfunc(res, self.seg[p])
          if q & 1 == 1:
              res = self.segfunc(res, self.seg[q])
              q -= 1
          p = p // 2
          q = (q - 1) // 2 
      if p == q:
          res = self.segfunc(res, self.seg[p])
      else:
          res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
      return res
    

def segor(a,b):
  return a|b

n = int(input())
st = SegmentTree(n,segor,0)
S = input()
data = [0] * n
for i,si in enumerate(S):
  k = ord(si)-ord("a")
  data[i] = 1 << k
st.apply(data)
Q = int(input())
for _ in range(Q):
  typo,a,b = input().split()
  if typo == "1":
    st.update(int(a)-1,1 << (ord(b)-ord("a")))
  if typo == "2":
    print(bin((st.query1(int(a)-1,int(b))))[2:].count("1"))
  


Measured memory_bytes: 70404
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

const int MAX = 300000;
int a[MAX], dp[5][MAX];
signed main(){
  int n;
  scanf("%lld", &n);
  rrep(i,n)scanf("%lld", &a[i]);
  rrep(j,n){
    int x[] = {a[j], max(2-a[j], a[j]%2), a[j]%2==0, max(2-a[j], a[j]%2), a[j]};
    x[0] = dp[0][j-1]+a[j];
    repi(i,1,5)x[i] = min(x[i-1], dp[i][j-1]+x[i]);
    rep(i,5)dp[i][j] = x[i];
  }
  printf("%lld\n", dp[4][n]);
  return 0;
}






Measured memory_bytes: 13056
#include <iostream>

using namespace std;

const int MOD = 1000000007;

int dp[100001];

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a;
        cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    for(int i = 1; i <= N; i++){
        if(dp[i] == -1){
            dp[i] = 0;
        }else{
            if(i-2 < 0) dp[i] += dp[i-1];
            else dp[i] += (dp[i-1]+dp[i-2]);
            dp[i] %= MOD;
        }
    }
    cout << dp[N] << endl;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, a + b - n) << endl;
    return 0;
}



Measured memory_bytes: 892
#include <stdio.h>
int  main(void)
{
int H,W;
int p,i,j;

while(1){

scanf("%d %d",&H,&W);
if(H==0 && W==0)
 break;

for(p=0;p<W;p++){
 printf("#");
}
printf("\n");

for(i=0;i<(H-2);i++){
 printf("#");
  for(j=0;j<(W-2);j++){
   printf(".");
  }
 printf("#\n");
}

for(p=0;p<W;p++){
 printf("#");
}
printf("\n");

printf("\n");
}

return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,L;
  cin>>N>>L;
  vector<string> vec(N);
  for(ll i=0;i<N;i++) {
cin>>vec[i];
  }
  sort(all(vec));
  for(ll i=0;i<N;i++) {
cout<<vec[i];
  }
  cout<<endl;
}


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

void Main() {
  long long X;
  cin >> X;
  long long i = 1;
  long long m = 100;
  while (m * 1.01 < X) {
    i++;
    m *= 1.01;
  }
  cout << i << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int r, d, x;
  cin >> r >> d >> x;
  rep(i, 10){
    x = r * x - d;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S = sc.next();

    sc.close();

    String[] s = S.split("");

    Deque<String> deque = new ArrayDeque<>();

    for (int i = 0; i < s.length; i++) {
      if (s[i].equals("0")) {
        deque.addLast("0");
      } else if (s[i].equals("1")) {
        deque.addLast("1");
      } else {
        if (0 < deque.size()) {
          deque.pollLast();
        }
      }
    }

    String result = "";

    for (String value : deque) {
      result += value;
    }

    System.out.println(result);

  }

}

Measured memory_bytes: 21972
n = gets.to_i
l = gets.split.map(&:to_i)
ans = 0
(0...n-2).each do |i|
  (i+1...n-1).each do |j|
    (j+1...n).each do |k|
      t = [l[i], l[j], l[k]].sort
      if t[0] != t[1] && t[1] != t[2]
        ans +=1 if t[0] + t[1] > t[2]
      end
    end
  end
end
puts ans


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

using namespace std;
const long long INF = 1LL <<60;

long long n,m,x;
long long res=INF;
long long c[14],a[14][14];

int cost(long long count,long long sum,long long b[14]){
  //cout<<m<<endl;
  long long e[14],f[14];
  int i;
  //cout<<count<<" "<<sum<<endl;
  if(count==n){
    for(i=0;i<m;i++){
      if(b[i]<x){
        break;
      }
      if(i==m-1){
        if(sum<res){
          res=sum;
        }
        return 0;
      }
    }
    return 0;
  }
  else{
    for(i=0;i<m;i++){
      e[i]=b[i];
      f[i]=b[i]+a[count][i];
    }
    
    cost(count+1,sum,e);
    cost(count+1,sum+c[count],f);
  }
  return 1;
}

int main(void){
  cin>>n>>m>>x;
  int i,j,k;

  long long tmp[m];
  for(i=0;i<n;i++){
    cin>>c[i];
    for(j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  for(j=0;j<m;j++){
    tmp[j]=0;
  }
  cost(0,0,tmp);
  if(res==INF){
    res=-1;
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
#define rep(n) for( int i = 0 ; i < n ; i++ )
#define REP(n) for( int i = 1 ; i <= n ; i++ )
#define repll(n) for( ll i = 0 ; i < n ; i++ )
#define REPll(n) for( ll i = 1 ; i <= n ; i++ )

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin >> s >> t;
    bool c = 0;
    for( int i = 0 ; i < s.size() ; i++ ) {
        if( s == t ) c = 1;
        s = s.back() + s.substr( 0 , s.size() - 1 );
    }
    if( c == 1 ) cout << "Yes";
	else cout << "No";
}


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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

VI g[100010];
int d[100010], edge, v;
bool used[100010];

void dfs(int x) {
  used[x] = true;
  edge += d[x];
  v++;
  for(auto e: g[x]) {
    if(!used[e]) dfs(e);
  }
}

signed main(void)
{
  int n, m;
  cin >> n >> m;
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].PB(b);
    g[b].PB(a);
    d[a]++, d[b]++;
  }

  v = 0, edge = 0;
  dfs(0);
  int v1 = v, e1 = edge/2;

  v = 0, edge = 0;
  dfs(1);
  int v2 = v, e2 = edge/2;

  int v3 = 0, e3 = 0;
  REP(i, n) {
    if(!used[i]) {
      v = 0, edge = 0;
      dfs(i);
      v3 += v;
      e3 += edge/2;
      // cout << i << " " << v3 << " " << e3 << endl;
    }
  }

  int ret = 0;
  if(v1 > v2) {
    int vv = v1+v3;
    // cout << v1 << " " << v3 << " " << e1 << " " << e3 << endl;
    ret += vv*(vv-1)/2 - e1 - e3;
    ret += v2*(v2-1)/2 - e2;
  } else {
    int v = v2+v3;
    ret += v*(v-1)/2 - e2 - e3;
    ret += v1*(v1-1)/2 - e1;
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 9728
#include<cstdio>
#include<algorithm>
using namespace std;

int n,m;
int a[105];

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    int ans=0;
    for(int i=1;i<n;i++)
        if(a[i]<=m){
            ans++;
            m-=a[i];
        }
    if(m==a[n]) ans++;
    printf("%d",ans);
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
  int i;
  int time[4],mas,min,sec;
  mas = 0;
  for(i=0;i<4;i++) {
    scanf("%d",&time[i]);
    mas += time[i];
  }
  min = mas / 60;
  sec = mas % 60;
  printf("%d\n%d\n",min,sec);
  return(0);
}

Measured memory_bytes: 596
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
    int a,b,d,r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=1.0*a/b;
    printf("%d %d %.6f\n",d,r,f);
    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pbds;
#pragma comment(linker, "/stack:200000000")
#define mod 100000007
#define ll long long int
#define inf ( ll  )( 1e9 + 10 )
#define mxs (int)( 1e5 + 1e5 + 10 )
//#define md  int mid = ( l + r )>>1;
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions
int ans, t, n, m, i, j, k, a, b, c, d, g , q , cases;
string s , s2, s3, s4;
void brainfuck();
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    brainfuck();
    return 0;
}
void brainfuck()
{
    cin>>m>>n;
    if ( n == 1 )
    {
        cout<<"0";
        return;
    }
    ans = m - n;
    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string st1;
    cin >> st1;
    int tm=st1.size();
    for(int i=0;i<tm;i++)
    {
        cout << 'x';
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		
		int x = fs.nextInt();
		int n = fs.nextInt();
		
		HashSet<Integer> set = new HashSet<>();
		for(int i = 0; i < n; i++) {
			set.add(fs.nextInt());
		}
		
		int diff = 0;
		while(true) {
			
			if(!set.contains(x - diff)) {
				System.out.println(x- diff);
				return;
			}
			
			if(!set.contains(x + diff)) {
				System.out.println(x + diff);
				return;
			}
			
			diff++;
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32696
#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans = -1;
int main()
{
scanf("%d%d",&n,&m);//cin>>n>>m;
for (int i = 1; i * i <= m; ++i)
{
if (m % i == 0)
{
int i1 = i;
int i2 = m / i;//m/i， i 是一对约数
if (i1 <= m / n) ans = max(ans, i1);
if (i2 <= m / n) ans = max(ans, i2);
}
}cout << ans;
  return 0;}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    /**
     * https://atcoder.jp/contests/dp/tasks/dp_g
     * refs: www.mathcs.emory.edu/~cheung/Courses/171/Syllabus/11-Graph/Docs/longest-path-in-dag.pdf
     * 
     */ 

    static int[] dist;
    static int[] parentsCount;
    static LinkedList<Integer>[] adjList;
    static boolean[] visited;

    public static void dfs(int parent){

        visited[parent] = true;
        Iterator<Integer> iter = adjList[parent].iterator();

        while(iter.hasNext()){
            int child = iter.next();
            dist[child] = Math.max(dist[child], dist[parent] + 1);
            parentsCount[child]--;
            if(parentsCount[child] == 0)
                dfs(child);
        }
    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        dist = new int[n + 1]; 
        parentsCount = new int[n + 1]; 
        adjList = new LinkedList[n + 1];
        visited = new boolean[n + 1];

        for(int i = 0; i <= n; i++) adjList[i] = new LinkedList<>();
        Arrays.fill(dist, 0);
        Arrays.fill(parentsCount, 0);   // verbose

        for(int i = 0; i < m; i++){
            int from = in.nextInt();
            int to = in.nextInt();
            adjList[from].add(to); // populate adjacency list
            parentsCount[to]++;
        }
        for(int i = 1; i <= n; i++){
            if( !visited[i] && parentsCount[i] == 0)
                dfs(i);
        }

        int ret = 0;
        for(int i = 1; i <= n; i++)
            ret = Math.max(ret, dist[i]);
        
        System.out.println(ret);
    }
}

Measured memory_bytes: 113216
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#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 mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<vector<int> >in(n);
    rep(i,n){
      rep(j,4){
	int tmp;
	cin>>tmp;
	in[i].pb(tmp);
      }
    }
    vector<int>ans(4);
    rep(i,4)cin>>ans[i];
    bool h=false;
    rep(i,n)if(in[i][1]<=ans[0]&&in[i][2]<=ans[1]&&in[i][3]<=ans[2]&&
	       4*in[i][1]+9*in[i][2]+4*in[i][3]<=ans[3]){h=true;cout<<in[i][0]<<endl;}
    if(!h)cout<<"NA"<<endl;
  }

}

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

int n;
ll a, b, c, d;

int main(){
	cin >> n >> a >> b >> c >> d;
	b -= a;
	for(int i = 0; i <= n - 1; i++){
		ll x = i, y = n - 1 - i;
		if((x - y) * c - y * (d - c) <= b && b <= (x - y) * c + x * (d - c)){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int h, w, n;
  cin >> h >> w >> n;
  int m = max(h, w);
  int result = n / m;
  if (n % m) result++;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

class UnionFind {
    // 各ノードが根である時の高さ
    // ノードが根でないときは意味をなさない
    vector<int> rank;
    // 各ノードが属する木の根
    // findSetするときのみ更新される
    vector<int> p;
    // 二つの根を結合
    void link(int rx, int ry) {
        if (rx == ry) return;
        if (rank[rx] > rank[ry]) p[ry] = rx;
        else p[rx] = ry;
        if (rank[rx] == rank[ry]) rank[ry]++;
    }
public:
    //　根を作成
    // その木の高さは0
    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }
    // 初期化
    // 入力サイズ分のノードを確保
    // それらのノードをそれぞれ根とする木を作成
    // ノードの値は 0 ~ size-1
    UnionFind(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        rep(i,size) makeSet(i);
    }
    // あるノードの属する木の根を返す
    // 根を探す過程で途中のノードの親も更新
    int findSet(int x) {
        if (x != p[x]) p[x] = findSet(p[x]);
        return p[x];
    }
    // 二つのノードが同じ木にあるか判定
    bool same(int x, int y) {return findSet(x) == findSet(y);}
    // 二つのノードの属する木を結合
    void unite(int x, int y) {link(findSet(x), findSet(y));}
};

int main() {
    fast_io
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> fr(n), bl(n);
    int a, b;
    UnionFind tree(n);
    rep(i,m) {
        cin >> a >> b;
        a--; b--;
        fr[a].push_back(b);
        fr[b].push_back(a);
        tree.unite(a,b);
    }
    rep(i,k) {
        cin >> a >> b;
        a--; b--;
        bl[a].push_back(b);
        bl[b].push_back(a);
    }
    map<int,int> mp;
    rep(i,n) mp[tree.findSet(i)]++;
    int ans;
    rep(i,n) {
        ans = mp[tree.findSet(i)] - 1 - fr[i].size();
        for (int block: bl[i]) if (tree.same(i,block)) ans--;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

bool check(int n, vector<string>& a) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i][j] == '#') return false;
        }
    }
    return true;
}

void change(int n, vector<string>& a, int idx) {
    for (int j = 0; j < n; j++) {
        if (a[idx][j] == '#') continue;
        if (j == idx) continue;
        string s = a[idx];
        for (int i = 0; i < n; i++) {
            a[i][j] = s[i];
        }
    }

    if (a[idx][idx] == '#') return;

    string s = a[idx];
    for (int i = 0; i < n; i++) {
        a[i][idx] = s[i];
    }
}

int solve(int n, vector<string> a, int idx, int minv) {
    for (int j = 0; j < n; j++) {
        if (a[idx][j] == '#') continue;
        for (int i = 0; i < n; i++) {
            a[i][j] = (i == idx ? '#' : '.');
        }
    }

    int ans = minv + n;
    for (int j = 0; j < n; j++) {
        bool f = true;
        for (int i = 0; i < n; i++) {
            if (i == idx) continue;
            if (a[i][j] == '.') {
                f = false;
                break;
            }
        }

        ans -= f;
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (check(n, a)) {
        cout << -1 << endl;
        return 0;
    }

    int minv = n + 1;
    vector<int> idxs;
    for (int i = 0; i < n; i++) {
        bool f = false;
        for (int ii = 0; ii < n; ii++) {
            if (a[ii][i] == '#') {
                f = true;
                break;
            }
        }
        
        int cnt = !f;
        for (int j = 0; j < n; j++) {
            cnt += (a[i][j] == '.');
        }

        if (minv > cnt) {
            minv = cnt;
            idxs.clear();
            idxs.push_back(i);
        } else if (minv == cnt) {
            idxs.push_back(i);
        }
    }

    if (minv > n) {
        cout << -1 << endl;
        return 0;
    }

    int ans = minv + n;
    ans = min(ans, solve(n, a, idxs[0], minv));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int X; cin >> X;
    int A = X/1000; X %= 1000;
    int B = X/100; X %= 100;
    int C = X/10; int D = X%10;

    REP(i,2)REP(j,2)REP(k,2){
        int tmp = 0;
        if(i) tmp = A+B;
        else tmp = A-B;
        if(j) tmp += C;
        else tmp -= C;
        if(k) tmp += D;
        else tmp -= D;

        if(tmp == 7){
            cout << A;
            if(i) cout << '+'; else cout << '-';
            cout << B;
            if(j) cout << '+'; else cout << '-';
            cout << C;
            if(k) cout << '+'; else cout << '-';
            cout << D << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

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

def f(x, m):
    return x % m

a = x
a_set = {a}
a_array = [a]
a_index = 0
while(True):
    a = f(a ** 2, m)
    if a in a_set:
        a_index = a_array.index(a)
        break
    a_set.add(a)
    a_array.append(a)


a_iter_array = a_array[a_index:]
div, mod = divmod(n - a_index, len(a_iter_array))
ans = sum(a_array[:a_index]) + sum(a_iter_array) * div + sum(a_iter_array[:mod])
print(ans)

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

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int m;
    cin>>m;
    int obs[m];
    int prev,min,max;
    max=0;
    min=0;
    cin>>obs[0];
    for(int j=1;j<m;j++){
      prev=obs[j-1];
      cin>>obs[j];
      if(max<abs(obs[j]-prev) && obs[j]>prev)max=abs(obs[j]-prev);
      if(min<abs(obs[j]-prev) && obs[j]<prev)min=abs(obs[j]-prev);
    }
    cout  << max << " " << min << endl;
  }
  return 0;
}

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

using namespace std;

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

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

int N, M;
ll K;
V<ll> x, d;
V<bool> vis;


int main() {
	#ifdef LOCAL
	auto stTime = clock();
	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> N;

	x.assign(N + 1, 0);
	d.assign(N, 0);

	for (int i = 1; i <= N; ++i)
		cin >> x[i];

	for (int i = 1; i <= N - 1; ++i)
		d[i] = x[i + 1] - x[i];

	vi P(N, 0);

	for (int i = 1; i <= N - 1; ++i)
		P[i] = i;

//	db(d);
//	db(P);

	cin >> M >> K;

	for (int i = 1; i <= M; ++i) {
		int ai;
		cin >> ai;
		swap(P[ai], P[ai - 1]);
	}

	db(P);
	db(K % (N - 1));

	vis.assign(N + 1, 0);

	V<ll> Ed(N + 1, 0);

	for (int i = 1; i <= N - 1; ++i) {
		int curr = i;
		vi cyc;
		while (!vis[curr]) {
			cyc.pb(curr);
			vis[curr] = true;
			curr = P[curr];
		}

		if (!cyc.empty()) {
			db(cyc);
		}

		for (int j = 0; j < sz(cyc); ++j)
			Ed[cyc[j]] = d[cyc[(j + K) % sz(cyc)]];
	}

	db(d);
	db(Ed);

	ll ans = x[1];

	for (int i = 1;; ++i) {
		cout << ans << '\n';
		if (i == N)
			break;
		ans += Ed[i];
	}



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


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


int main() {

    int n, d, x;
    cin >> n >> d >> x;
    int ans = x;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        for (int j = 1; j <= 100; j += a) {
            if (j <= d) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
//const int mod = 1e9 + 7;

int main(){
 long long a,b,sum=0;
 cin>>a>>b;
 if(b<2*a)
 cout<<b/2<<endl;
 else{
 	sum=a;
 	b=b-2*a;
 	sum+=b/4;
 	cout<<sum<<endl;
 }
	
	
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	unsigned long X, Y;
	int index = 0;
	cin >> X >> Y;
	for (int i = 1; i <= 10000; i++)
	{
		if (X > Y)
		{
			index = i - 1;
			break;
		}
		X *= 2;
	}
	cout << index;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	
	static String[] heigth = new String[]
			{"1:",
			 "2:",
			 "3:",
			 "4:",
			 "5:",
			 "6:"};
	
	static BufferedReader reader =
			new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String[] args) throws IOException{
		Main byakko = new Main();
		int n = Integer.parseInt(reader.readLine());
		
		for(int i = 0; i < n; i++){
			byakko.input();
		}
		for(int i = 0; i < 6; i++){
			System.out.println(heigth[i]);
		}
		reader.close();
	}
	
	public void input() throws IOException{
		double x = Double.parseDouble(reader.readLine());
		
		if(x < 165)heigth[0] += "*";
		else if(165 <= x && x < 170)heigth[1] += "*";
		else if(170 <= x && x < 175)heigth[2] += "*";
		else if(175 <= x && x < 180)heigth[3] += "*";
		else if(180 <= x && x < 185)heigth[4] += "*";
		else if(185 <= x)heigth[5] += "*";
	}
	
}

Measured memory_bytes: 16924
#include<bits/stdc++.h>
using namespace std;
 
long long m_min(long long t[], long long K)
{
	long long m = INT_MAX;
	for(long long i=0; i<K; i++)
		if(t[i] < m)
			m = t[i];
	return m;
}
 
int main()
{
	long long N, K;
	long long temp;
	cin>>N>>K;
	long long arr[N];
	long long dp[N];
	dp[0] = 0;
 
	for(long long i=0; i<N; i++)
		cin>>arr[i];
 
	for(long long i=1; i<N; i++)
	{
		if(i<K)
			temp = i+1;
		else
			temp = K+1;
		long long t[temp-1];
		for(long long j=1; j<temp; j++)
		{
			t[j-1] = dp[i-j]+abs(arr[i]-arr[i-j]);
		}
		dp[i] = m_min(t, temp-1);
	}
	cout<<dp[N-1];
}

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

a=0
b=0
c=0

for i in range(1,n//3+1):
  a+=3*i

for i in range(1,n//5+1):
  b+=5*i
 
for i in range(1,n//15+1):
  c+=15*i
  
print(int(1/2*n*(n+1)-(a+b-c)))


Measured memory_bytes: 9112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long a = x[0] * x[1];
            long b = x[2] + x[3];
            Console.WriteLine(a % 2 == 1 && b % 2 == 1 ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 18412
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-9
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int n;
	scan(n);
	prin(n*n*n);
	return 0;
}


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

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

	int h[101], m[101];
	for (int i = 0; i < N; i++) {
		cin >> h[i] >> m[i];
	}
	h[N] = 24; m[N] = 0;
	int M;
	cin >> M;

	int k[101], g[101];
	for (int j = 0; j < M; j++) {
		cin >> k[j] >> g[j];
	}
	k[M] = 24; g[M] = 0;

	for (int i = 0, j = 0; i < N || j < M;) {
		if (h[i] == k[j] && m[i] == g[j]) {
			cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
			i++; j++;
		}
		else if (h[i] < k[j] || (h[i] == k[j] && m[i] < g[j])) {
			cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
			i++;
		}
		else {
			cout << k[j] << ':' << g[j] / 10 << g[j] % 10;
			j++;
		}
		if (i == N&&j == M) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}
}

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

bool is_prime(int x){
    if(x<=1)
        return false;
    for(int i=2;i<x;++i)
        if(x%i==0) return false;
    return true;
}

int main(){
    int x;
    cin >> x;
    for(int i=x; i<2*x; ++i){
        bool  f;
        f = is_prime(i);
        if (f) {
            cout<<i<<endl;
            break;
        }
        else continue;
    }

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i, ans = 0;
		int B[] = new int[n];
		B[n - 1] = -1;
		int sum = 0;
		for (i = 0; i < n - 1; i++)
			B[i] = sc.nextInt();

		for (i = 0; i < n - 1; i++) {
			if (B[i + 1] != -1 && B[i] > B[i + 1]) {
				sum += B[i + 1];
			} else {
				sum += B[i];
			}
		}
		ans = sum + B[0];
		System.out.println(ans);
	}
}

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

int main(){
    string s;
    cin >> s;
    
    string ans = "TBD";
    if(s.at(5) == '0' && (s.at(6) == '1' || s.at(6) == '2' || s.at(6) == '3' || s.at(6) == '4'))
    ans = "Heisei";
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = int(input())
l = []
for i in range(n):
    tmp = list(map(int,input().split()))
    l.append(tmp)

l.sort(key=lambda x:x[1])

now = 0
for a,b in l:
    now += a
    if now > b:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 53716