akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long> num(N);
  
  for (int i = 0; i < N; i++) {
    cin >> num.at(i);
    num.at(i) -= (i + 1);
  }
  
  sort(num.begin(), num.end());
  
  int ma,mb;
  
  if (N % 2 == 0) {
    ma = num.at(N/2);
    mb = num.at(N/2 - 1);
  }
  else {
    ma = num.at((N - 1)/2);
    mb = num.at((N - 1)/2);
  }
  
  long sunuke1,sunuke2 = 0;
  
  for (int i = 0; i < N; i++) {
    sunuke1 = sunuke1 + abs(num.at(i) - ma);
    sunuke2 = sunuke2 + abs(num.at(i) - mb);
  }
  
  cout << min(sunuke1,sunuke2) << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
const double EPS=1e-10;
struct point{
	double x,y;
	point(const point&a):x(a.x),y(a.y){}
	point(const double&x=0,const double&y=0):x(x),y(y){}
	point operator+(const point&p)const{return point(x+p.x,y+p.y);}
	point operator-(const point&p)const{return point(x-p.x,y-p.y);}
	point operator*(const double&k)const{return point(x*k,y*k);}
	point operator/(const double&k)const{return point(x/k,y/k);}
	double norm(){return x*x+y*y;}
	double abs(){return sqrt(norm());}
	void operator=(const point&a){
		x=a.x,y=a.y;
	}
	bool operator<(const point&p)const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator==(const point&p)const{
		return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
	}
	friend double dot(const point&a,const point&b){
		return a.x*b.x+a.y*b.y;
	}
	friend double cross(const point&a,const point&b){
		return a.x*b.y-a.y*b.x;
	}
};
typedef point vector;
struct segment{
	point p1,p2;
	segment(const double&a,const double&b,const double&c,const double&d){
		p1.x=a,p1.y=b,p2.x=c,p2.y=d;
	}
	segment(const point&a, const point&b):p1(a),p2(b){}
	point get_vec()const{return point(p2.x-p1.x,p2.y-p1.y);}
};
bool orthogonal(const vector&a,const vector&b){
	return fabs(dot(a,b))<EPS;
}
bool orthogonal(const point&a,const point&b,const point&c,const point&d){
	return fabs(dot(a-b,c-d))<EPS;
}
bool orthogonal(const segment&a,const segment&b){
	return fabs(dot(a.get_vec(),b.get_vec()))<EPS;
}
bool parallel(const vector&a,const vector&b){
	return fabs(cross(a,b))<EPS;
}
bool parallel(const point&a,const point&b,const point&c,const point&d){
	return fabs(cross(a-b,c-d))<EPS;
}
bool parallel(const segment&a,const segment&b){
	return fabs(cross(a.get_vec(),b.get_vec()))<EPS;
}
point project(const segment&s,const point&p){
	vector base=s.get_vec();
	double r=dot(p-s.p1,base)/base.norm();
	return s.p1+base*r;
}
point reflect(const segment&s,const point&p){
	return p+(project(s,p)-p)*2.0;
}
int ccw(const point&a,const point&b,const point&c){
	vector t1=b-a;
	vector t2=c-a;
	if(cross(t1,t2)>EPS) return 1;
	if(cross(t1,t2)<-EPS) return -1;
	if(dot(t1,t2)<-EPS) return -2;
	if(t1.norm()<t2.norm()) return 2;
	return 0;
}
int main(){
	double a,b,c,d;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c>>d;
		segment s1(a,b,c,d);
		cin>>a>>b>>c>>d;
		segment s2(a,b,c,d);
		if(parallel(s1,s2))  cout<<2<<endl;
		else if(orthogonal(s1,s2)) cout<<1<<endl;
		else cout<<0<<endl;
	}
	return 0;
}



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

bool a(string s){
  string t(s.rbegin(),s.rend());
  return s==t;
}

int main(){
 
  string s;
  cin>>s;
  int n=s.size();
  if(a(s)&&a(s.substr(0,(n-1)/2))&&a(s.substr((n+1)/2))){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

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

using namespace std;

typedef long long LL;
typedef double DB;
typedef unsigned int UI;
typedef pair<int, int> PII;

const int inf = 0x7f7f7f7f;

#define rdi() read<int>()
#define rdl() read<LL>()
#define rds(a) scanf("%s", a)
#define mk(i, j) make_pair(i, j)
#define pb push_back
#define fi first
#define se second
#define For(i, j, k) for (int i = j; i <= k; i ++)
#define Rep(i, j, k) for (int i = j; i >= k; i --)
#define Edge(i, u) for (int i = head[u]; i; i = e[i].nxt)

template<typename t> t read() {
    t x = 0; int f = 1; char c = getchar();
    while (c > '9' || c < '0') f = c == '-' ? -1 : 1 , c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - 48 , c = getchar();
    return x * f;
}

template<typename t> void write(t x) {
    if (x < 0){
        putchar('-'), write(-x);
        return;
    }
    if (x >= 10) write(x / 10);
    putchar(x % 10 + 48);
}

const int P = 1e9 + 7;
const int N = 1e5 + 10;
int fac[N], facinv[N], a[N], n, pos, vis[N], id;

int power(int a, int b) {
    int c = 1;
    for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P;
    return c;
}

int C(int x, int y) {
    return 1ll * fac[x] * facinv[y] % P * facinv[x - y] % P;
}

int main() {
    n = rdi() + 1;
    for (int i = 1; i <= n; i ++) a[i] = rdi();
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i ++) fac[i] = 1ll * fac[i - 1] * i % P;
    facinv[n] = power(fac[n], P - 2);
    for (int i = n - 1; i >= 0; i --) facinv[i] = 1ll * facinv[i + 1] * (i + 1) % P;
    for (int i = 1; i <= n; i ++) {
        if (vis[a[i]]) {
            pos = i;
            id = a[i];
            break;
        }
        vis[a[i]] = i;
    }
    int len = n - pos + 1;
    for (int i = 1; i <= n; i ++) {
        int ans = C(n, i);
        if (i - 1 <= len - 1 + vis[id] - 1) ans -= C(len - 1 + vis[id] - 1, i - 1);
        ans = (ans + P) % P;
        write(ans), putchar(10);
    }
    return 0;
}
	

Measured memory_bytes: 5136
S = input().split(" ")
n = int(S[0])
x = int(S[1])

arr = [int(s) for s in input().split(" ")]

import fractions
def gcd(a, b):
    return fractions.gcd(a, b)

# import math
# def gcd(a, b):
#     return math.gcd(a, b)

def calculate(n,x,arr):
    data = []
    for ar in arr:
        if ar < x:
            data.append(x - ar)
        else:
            data.append(ar - x)

    return data

data = calculate(n,x,arr)

if len(data) == 1:
    print(data[0])
else:
    res = gcd(data[0],data[1])
    for index,da in enumerate(data):
        if index < 2:
            continue
        res = gcd(res,da)
    print(res)

Measured memory_bytes: 14484
#include <iostream>
#include <stack>
#include <regex>
#include <vector>
#include <string>
#include <sstream>      // std::ostringstream
using namespace std;
std::vector<std::string> split(const std::string &str, char sep);
int main(void)
{
  stack<int> st;
  regex re(R"(^\d+$)");
  string l;
  getline(cin,l);
  vector<string> lvec = split(l, ' ');
  //cout << lvec.size() << endl;
  for (string c : lvec)
  {
    //数字?
    if(regex_match(c,re))
    {
      int newnum = stoi(c);
      st.push(newnum);
      continue;
    }
    //そうでなければ演算子
    //共通処理
    int a = st.top();
    st.pop();
    int b = st.top();
    st.pop();
    if (c=="+")
    {
      st.push(a + b);
    }
    else if (c=="*")
    {
      st.push(a * b);
    }
    else
    {
      st.push(b-a);
    }
  }
  cout << st.top() << endl;
}
std::vector<std::string> split(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}


Measured memory_bytes: 3320
#include<bits/stdc++.h>					
using namespace std;	
int main()	
{
int a,b;
cin>>a>>b;
char aa[100],bb[100];char bbb = b+'0';char aaa =a+'0';
for(int i = 0;i<b;i++){	
	aa[i] = aaa;
}
for(int i = 0;i<a;i++){
	bb[i] = bbb;
}


if(a==b){
	for(int i = 0;i<b;i++){	
	cout<<aa[i];}
}
for(int i = 0;i<min(a,b);i++){
	int a1 = aa[i],b1 = bb[i];
 	if(a1<b1){
 		for(int i = 0;i<b;i++){	
	cout<<aa[i];
}return 0;
	 }else if(b1<a1){
	 	for(int i = 0;i<a;i++){	
	cout<<bb[i];
}return 0;
	 }else{
	 	continue;
	 }
	 
}



return 0;									
 } 


Measured memory_bytes: 256
"use strict";

const main = arg => {
  const input = arg.trim().split("\n");
  const X = parseInt(input[0].split(" ")[0]);
  const A = parseInt(input[0].split(" ")[1]);
  if (X >= A) {
    console.log(10);
  } else {
    console.log(0);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29604
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,j;
    cin>>n;
    long long a[n],p,i=n-2,r=n-2;
    for(j=0;j<n;j++)
    cin>>a[j];
    sort(a,a+n);
    p=a[n-1];
    while(r>0){
        if(r==1){
            p=p+a[i];break;r=r-1;
        }else{
            p=p+2*a[i];i=i-1;r=r-2;
        }
    }
    cout<<p<<endl;
    
    return 0;
}


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

int main(void){
    int A, B;
    scanf("%d %d", &A, &B);
    if (A >= B) printf("%d\n", 1);
    else if (A < B && B%A == 0) printf("%d\n", B/A);
    else printf("%d\n", B/A+1);
    return 0;
}



Measured memory_bytes: 2756
// header {{{
// header {{{
#include <bits/stdc++.h>
using namespace std;
 
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
 
#define ASSERT(expr...) assert((expr))
 
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
 
using f32 = float;
using f64 = double;
// }}}
 
constexpr i64 INF = 1'010'000'000'000'000'017LL;
 
constexpr i64 MOD = 1'000'000'007LL;
 
constexpr f64 EPS = 1e-12;
 
constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

 
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define ll long long int
#define VI vector <int>
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
 
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
 
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
 
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}
 
// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
 
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}
 
//--------------------------------------------------------------------
 
bool isOK(int mid, double key){
 
    if((double)mid*mid > key) {
             return true;
     } else {
              return false;
     }
}

 int binary_search(double key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


bool isKaibun(string st){
    bool ans = true;
    int n = st.length();
    REP(i,n/2){
        if(st[i] != st[n-i-1]){
            return false;
        }
    }
    return true;
}

int toInt(char a){
    return a-'0';
}

void solve() {
    int K,N;
    cin >> K >> N;
    int ans = -1;
    int b;
    VI a;
    a.resize(N);
    cin >> a[0];
    FOR(i,1,N){
        cin >> a[i];
        ans = max(ans,a[i]-a[i-1]);
    }
    ans = max(ans,K-a[N-1]+a[0]);
    cout << K-ans;
}
signed main() {
 
    solve();
 
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        double num[] = new double[n];
        double sum = 0;
        
        for(int i = 0; i < n; i++){
            num[i] = stdIn.nextDouble();
            sum += 1 / num[i];
        }
        
        System.out.println(1 / sum);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair

int main() {
   int a,b,c,n;
   cin>>a>>b>>c>>n;
   ll sum=0;
   for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=n;j++)
       {
           if(i*a+j*b>n)
            break;
           ll k=i*a+j*b;
           k=n-k;
           if(k%c==0)
            sum++;
       }
   }
   cout<<sum;
   return 0;
}


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

#define inf 0x3f3f3f3f

using namespace std;

typedef long long ll;

const ll mod = 998244353;

int i, j;
string s;
int n;
ll total = 0;
int a[100001], b[100001];
void solve() {
  cin >> n;
  for (i = 0; i < n + 1; ++i) cin >> a[i];
  for (i = 0; i < n; ++i) cin >> b[i];
  for (i = 0; i < n; ++i) {
    int take = min(a[i], b[i]);
    total += take;
    a[i] -= take;
    b[i] -= take;
    if (i + 1 < n) {
      take = min(a[i + 1], b[i]);
      total += take;
      a[i + 1] -= take;
      b[i] -= take;
    }
  }
  if (a[n] >= 0) total += min(a[n], b[n - 1]);
  cout << total << endl;
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}

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

int main() {
  int a, b, c;
  cin>>a>>b>>c;
  map<int, int> m;
  ++m[a];
  ++m[b];
  ++m[c];
  if (m[5] == 2 && m[7] == 1) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }

}

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

int N;

int main() {
    cin >> N;

    if (N % 111 == 0) {
        cout << N << endl;
        return 0;
    }

    int num = N / 111;
    num++;
    printf("%d%d%d\n", num, num, num);
}

Measured memory_bytes: 256
import math

A, B, H, M = [int(x) for x in input().split()]

pos_long = [B * math.sin(M / 60  * 2 * math.pi), B * math.cos(M / 60  * 2 * math.pi)]
pos_short = [A * math.sin((H * 60 + M) / 720  * 2 * math.pi), A * math.cos((H * 60 + M) / 720 * 2 * math.pi)]

print(math.sqrt((pos_long[0] - pos_short[0]) ** 2 + (pos_long[1] - pos_short[1]) ** 2))

Measured memory_bytes: 9520
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

int main()
{
    string ans = "";
    ll n;
    cin >> n;

    while (n != 0)
    {
        ll r = n % 2;
        if (r < 0)
            r += 2;
        n = (n - r) / (-2);
        ans += (char)('0' + r);
    }
    reverse(all(ans));
    if (ans == "")
        ans = "0";
    cout << ans << endl;

    return 0;
}

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

minus = (N - 1) * (N - 2) // 2 - K  # 減らす回数

if minus < 0 :
    print('-1')
else :
    print(N - 1 + minus)
    # 1を中心とするスターを作成する
    for i in range(2,N+1) :
        print('1 {}'.format(i))

    if minus > 0 :
        # 辺の数を減らす
        for i in range(2,N+1) :
            for j in range(i+1,N+1) :
                if minus <= 0 :
                    break
                print('{} {}'.format(i,j))
                minus -= 1
            else :
                continue
            break


Measured memory_bytes: 3332
情報数 = int(input())

現在の校舎状態 = [[[0 for x in range(10)] for y in range(3)] for z in range(4)]

for i in range(情報数):
    棟, 階, 部屋番号, 追加人数 = map(int, input().split())
    現在の校舎状態[棟-1][3-階][部屋番号-1] += 追加人数

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" ", end='')
            print(現在の校舎状態[i][2-j][k], end='')
        print()
    if i != 3:
        print("####################")


Measured memory_bytes: 5756
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				StringTokenizer st = new StringTokenizer(buf);
				int V = Integer.parseInt(st.nextToken());
				int d = Integer.parseInt(st.nextToken());
				int f[] = new int[V+1];
				int count = 1;
				f[0] = 1;
				f[1] = 2;
				for (int i=2;i<=V;i++) {
					f[i] = (f[i-1]+f[i-2])%1001;
				}
				Arrays.sort(f);
				for (int i=2;i<=V;i++) {
					if (f[i]-f[i-1]>=d) count++;
				}
				System.out.println(count);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 21660
use std::io;

fn main() {
  let stdin = io::stdin();
  let mut buf = String::new();
  for i in 1.. {
    buf.clear();
    stdin.read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace()
      .map(|x| x.parse::<i32>().unwrap());
    let mut a = iter.next().unwrap();
    let mut b = iter.next().unwrap();
    if a == 0 && b == 0 { break; }
    if a > b { std::mem::swap(&mut a, &mut b) }
    println!("{} {}", a, b);
  }
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M; cin>>N>>M;
    vector<bool> ac(N,false);

    int numAC=0;
    vector<int> wa(N,0);
    rep(m,0,M){
        int p; cin>>p;
        string s; cin>>s;

        if(s=="AC" && !ac.at(p-1)){numAC++; ac.at(p-1)=true;} 
        else if(s=="WA" && !ac.at(p-1)) wa.at(p-1)++;
    }

    int numWA=0;
    rep(n,0,N) if(ac.at(n)) numWA+=wa.at(n);

    cout<<numAC<<" "<<numWA<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 3005;
double dp[N][N];

int main() {
    int n;
    cin >> n;
    vector<double> p(n);
    REP(i,n) cin >> p[i];
    dp[0][0] = 1;
    REP(i,n) REP(j,n+1){
        dp[i+1][j+1] += dp[i][j] * p[i];
        dp[i+1][j] += dp[i][j] * (1 - p[i]);
    }
    double ans = 0;
    REP(j,n+1){
        if (j > n - j){
            ans += dp[n][j];
        }
    }
    printf("%.15f\n", ans);

    return 0;
}


Measured memory_bytes: 70656
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

int main() {
   string S;
   char ans;
   cin >> S;
   if (S.size() != 26) {
      bool flg = false;
      for (char ch = 'a'; ch <= 'z'; ch++) {
         flg = true;
         for (int i = 0; i < S.size(); i++) {
            if (S[i] == ch) {
               flg = false;
               break;
            }
         }
         if (flg) {
            ans = ch;
            break;
         }
      }
      for (int i = 0; i < S.size(); i++) cout << S[i];
      cout << ans << endl;
   } else {
      int tmp = -1;
      bool flg = false;
      for (int i = 24; i >= 0; i--) {
         if (S[i] < S[i + 1]) {
            tmp = i;
            break;
         }
         if (i == 0) {
            cout << "-1" << endl;
            return 0;
         }
      }
      for (char ch = S[tmp]; ch <= 'z'; ch++) {
         flg = true;
         for (int i = 0; i <= tmp; i++) {
            if (S[i] == ch) {
               flg = false;
               break;
            }
         }
         if (flg) {
            ans = ch;
            break;
         }
      }
      for (int i = 0; i < tmp; i++) cout << S[i];
      cout << ans << endl;
   }
   
   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
    int a, b, i, n, s;
 
    while(scanf("%d%d%d", &a, &b, &n) != EOF){
 
        s = 0;
 
        for(i=0; i<n; i++){
            a = a % b;
            a = a * 10;
            s += a / b;
        }
 
        printf("%d\n", s);
 
    }
    return 0;
}

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

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> P(N), C(N);
    for(int i=0;i<N;i++){
        cin >> P[i];
        P[i]--;
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }

    vector<bool> used(N, false);
    vector<vector<ll>> groups;
    for(int i=0; i<N; i++){
        if(used[i]) continue;

        vector<ll> group;
        int j = i;
        while(true){
            used[j] = true;
            group.push_back(C[j]);
            j = P[j];
            if(i == j) break;
        }
        groups.push_back(group);
    }

    ll res = numeric_limits<ll>::min();
    for(auto group : groups){
        vector<ll> vsum = {0};
        for(auto v : group){
            vsum.push_back(v + vsum.back());
        }
        ll ngroup = group.size();
        auto nloop = K / ngroup;
        ll val;
        for(int i=0; i<ngroup; i++){
            for(int j=0; j<min(K, ngroup); j++){
                if(i+j+1 >= ngroup){
                    val = vsum[i+j+1-ngroup] - vsum[i] + vsum.back();
                }else{
                    val = vsum[i+j+1] - vsum[i];
                }
                res = max(res, val);

                if(nloop > 0){
                    res = max(res, val + (nloop - 1) * vsum.back());
                }

                if(j < K%ngroup){
                    res = max(res, val + nloop * vsum.back());
                }
            }
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3848
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string A, B;
  cin>>A>>B;
  if(A.size()>B.size()) {
    cout<<"GREATER"<<endl;
    return 0;
  }
  if(A.size()<B.size()) {
    cout<<"LESS"<<endl;
    return 0;
  }
  bool equ = true, a=false;
  for(int i=0;i<A.size();++i) {
    if(A[i]<B[i]) {
      equ = false;
      a = false;
      break;
    }
    else if(A[i]>B[i]) {
      equ = false;
      a = true;
      break;
    }
  }
  if(equ) cout<<"EQUAL"<<endl;
  else if(a) cout<<"GREATER"<<endl;
  else cout<<"LESS"<<endl;
}


Measured memory_bytes: 3620
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll N,T,A[100000];
ll dat[400000];
const ll INF=0xffffffffff;
ll n=1;
ll init(ll n_){
	while(n<n_) n*=2;
	for(ll i=0;i<2*n-1;i++){
		dat[i]=-INF;
	}
}

void update(ll k,ll a){
	k+=n-1;
	dat[k]=a;
	while(k>0){
		k=(k-1)/2;
		dat[k]=max(dat[k*2+1],dat[k*2+2]);
	}
	return;
}

ll query(ll a,ll b,ll k,ll l,ll r){
	if(r<=a||b<=l) return -INF;
	if(a<=l&&r<=b) return dat[k];
	ll vl=query(a,b,k*2+1,l,(l+r)/2);
	ll vr=query(a,b,k*2+2,(l+r)/2,r);
	return max(vl,vr);
}
ll dmax=-INF;
int main()
{
	cin>>N>>T;
	init(N);
	for(ll i=0;i<N;i++){
		cin>>A[i];
		update(i,A[i]);
	}
	for(ll i=0;i<N-1;i++){
		dmax=max(dmax,query(i+1,N,0,0,n)-A[i]);
	}
	ll cnt=0;
	for(ll i=0;i<N-1;i++){
		if( query(i+1,N,0,0,n) - A[i] == dmax) cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3072
while True:
    n=input()
    if n==0:
        break
    board=[""]*n
    for i in xrange(n):
        board[i]=raw_input()
    dp=[[0]*(n+1) for unused in xrange(n+1)]
    for y in xrange(n):
        for x in xrange(n):
            if board[y][x]==".":
                dp[y][x]=min(dp[y][x-1],dp[y-1][x],dp[y-1][x-1])+1
    print max(map(max,dp))

Measured memory_bytes: 33004
h,w=[int(j) for j in input().split()]
s=[list(input())for i in range(h)]
par=[-1 for i in range(h*w)]    #par<0なら自身が親で要素の個数、>0なら子で親の位置示す
def root(a):
    if par[a]<0:
        return a
    else:
        return root(par[a])

def size(a):
    return -par[root(a)]

def connect(a,b):
    a=root(a)
    b=root(b)
    if a==b:
        return False
    if size(a)<size(b):
        a,b=b,a
    par[a]+=par[b]
    par[b]=a
    return True

for i in range(h):
    for j in range(w):
        for x,y in [(1,0),(-1,0),(0,1),(0,-1)]:
            p,q=i+x,j+y
            if 0<=p<h and 0<=q<w:
                if s[p][q]!=s[i][j]:
                    if root(w*p+q)!=root(w*i+j):
                        connect(w*p+q,w*i+j)

from collections import Counter
c=Counter()
for i in range(h):
    for j in range(w):
        p=i*w+j
        q=root(p)
        if c[q]==0:
            c[q]=[0,0]
        if s[i][j]=="#":
            c[q][0]+=1
        else:
            c[q][1]+=1
ans=0
for i in c:
    ans+=c[i][0]*c[i][1]
print(ans)

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

int gcm(int i, int j){
    if(i<j) return gcm(j, i);
    else if(i%j) return gcm(j, i%j);
    else return j;
}
int main() {
	int N, M; cin >> N >> M;
	string S, T; cin >> S >> T;
	int G = gcm(N, M);
	bool fl=true;
	for(int i=0; i<G; ++i){
	    if(S[i*N/G]!=T[i*M/G]){
	        fl=false;
	        break;
	    }
	}
	if(fl) cout << (long) N*M/G << endl;
	else cout << -1 << endl;;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    int T[n], A[n];
    REP(i, n){
        sc(T[i])
        sc(A[i])
    }
    ll aT = T[0], aA = A[0];
    for (int i = 1; i < n; i++){
        if (aT < T[i]) aT = T[i];
        else if (aT % T[i] != 0) aT += T[i] - (aT % T[i]);
        if (aT / T[i] * A[i] < aA) aT += (aA - aT / T[i] * A[i]) / A[i] * T[i];
        if (aT / T[i] * A[i] < aA) aT += T[i];
        aA = aT / T[i] * A[i];
    }
    cout << aT + aA << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n;
#define N 200000
LL ai[N];
LL sum;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i)
        cin >> ai[i], sum += ai[i];
    if (sum % (1ll * n * (n + 1) / 2)) {puts("NO"); return 0;}
    sum /= 1ll * n * (n + 1) / 2;
    ai[0] = ai[n];
    for (int i = 1; i <= n; ++ i)
    {
        if ((sum - (ai[i] - ai[i - 1])) % n) {puts("NO"); return 0;}
        LL d = (sum - (ai[i] - ai[i - 1])) / n;
        if (0 <= d && d <= sum); else {puts("NO"); return 0;}
    }
    puts("YES");
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int maxn = 1e5 + 10;
using namespace std;
int s[maxn], a[maxn];
int main()
{
    int t;
    cin >> t;
    int sum = 0, cnt = 0;
    for (int i = 0; i < t; i++)
        cin >> s[i];
    sort(s, s + t);
    int k = 0;
    for (int i = 0; i < t; i++) {
        if (i == 0)
            a[k]++;
        else {
            if (s[i] == s[i - 1])
                a[k]++;
            else
                a[++k]++;
        }
    }
    for (int i = 0; i <= k; i++)
        if (a[i] & 1)
            sum++;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i;
    char s[5];
    double a, sum = 0.0;
    scanf("%d", &n);
    while (n--) {
        scanf("%lf %s", &a, s);
        if (strcmp(s, "BTC") == 0) {
            sum += (a*380000.0);
        }
        else sum += a;
    }
    printf("%lf\n", sum);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 50

const int INF = 1e9 + 7;


int main() {


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

	ll n, m;
	cin >> n >> m;
	vector<pll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	ll cnt = 0;//本数
	sort(a.begin(), a.end());

	
	ll ans = 0;//金
	for (int i = 0; i < n; i++) {
		//cout << "cnt = " << cnt << endl;
		if (cnt + a[i].second < m) {
			//cout << "a" << endl;
			ans += a[i].first*a[i].second;
			cnt += a[i].second;
		}
		else {
			//cout << "b" << endl;
			while (cnt < m) {
				cnt++;
				ans += a[i].first;
			}
		}
		//cout << i << " " << cnt << " " << ans << endl;
		if (cnt == m) {
			break;
		}
	}

	cout << ans << endl;






	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N, W;
    cin >> N >> W;
    vector<ll> dp(1000 * N + 1, W * N + 1);

    dp[0] = 0;

    vector<ll> dp_n(dp);
    for (ll i = 0; i < N; ++i) {
        ll w, v;
        cin >> w >> v;
        for (ll sum_v = 0; sum_v <= 1000 * N; ++sum_v) {
            if (sum_v - v >= 0) {
                dp_n[sum_v] = min(dp_n[sum_v], dp[sum_v - v] + w);
            }
        }
        dp = dp_n;
    }

    auto it = find_if(rbegin(dp), rend(dp),
        [W](auto a) { return a <= W; });
    cout << distance((++it), rend(dp)) << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for(int i=0; i<N; i++){
    cin >> V.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> C.at(i);
  }
  
  int ans = 0;
  for(int i=0; i<N; i++){
    if(V.at(i)>C.at(i)){
	  ans += V.at(i)-C.at(i);
    }
  }
  
  cout << ans <<endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
# define debug cerr<<"ERROR"<<endl
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int inf=1e9,mod=998244353,N=2e5+5;

vector<int>g[N];
int used[N];

void dfs(int x){
	used[x]=1;
	for(auto i:g[x]){
		if(!used[i]){
			dfs(i);
		}
	}
}

void solve(){
	int n,m;
	cin>>n>>m;
	rep(i,m){
		int u,v;
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
	}
	int cnt=0;
	forn(i,n){
		if(!used[i]){
			cnt++;
			dfs(i);
		}
	}
	cout<<cnt-1;
}

int main(){
 	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}

Measured memory_bytes: 12340
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
const int M = 1e5 + 10;
const int INF = 0x3f3f3f3f;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define endl '\n'
#define ls (i << 1)
#define rs (i << 1 | 1)
#define loop(i, a, b) for (int i = a; i < b; ++i)

inline int read() {
    char ch = getchar();
    int w = 1, c = 0;
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-') w = -1;
    for (; isdigit(ch); ch = getchar()) c = (c << 3) + (c << 1) + (ch ^ 48);
    return w * c;
}

int main() {
    int x = read();
    cout << (!x) << endl;
    return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int d,t,s;
  cin >> d >> t >> s;
  if(t*s>=d)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (C >= A && C <= B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

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

cout << (s=="ABC" ? "ARC" : "ABC") << endl;
return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <deque>
using namespace std;

int main(){
    int N, T;
    int sum = 0;
    cin >> N >> T;
    deque<int> wait_time;

    for(int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        wait_time.push_back(temp);
    }

    for(int i = 0; i < N - 1; i++) {
        int diff = wait_time[1] - wait_time[0];
        wait_time.pop_front();
        if(diff < T) sum += diff;
        else sum += T;
    }

    sum += T;

    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 1024
n,p = map(int,input().split())
s = 0 
a = int(p)
b = {}

def calc(x):
    c = []
    b, e = 2, 0
    while b * b <= x:
        while x % b == 0:
            x = x // b
            e = e + 1
        if e > 0:
            c.append((b, e))
        b, e = b + 1, 0
    if x > 1:
        c.append((x, 1))
    return c
    
    
if p == 1:
    print(1)
else:
    d = calc(p)
    ans = 1
    for i in range(len(d)):
        if d[i][1] >= n:
            ans *= d[i][0] ** (d[i][1] // n)
    print(ans)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int k, n; cin >> k >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	a.push_back(a[0]+k);
	int x = 0;
	rep(i, n)chmax(x, a[i+1]-a[i]);
	int ans = k - x;
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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


int main(){
    int a,b,q; cin >> a >> b >> q;
    vector<ll> s(a+2),t(b+2),x(q);
    s[0] = -1e18,s[a+1] = 1e18,t[0] = -1e18,t[b+1] = 1e18;    
    rep(i,a) cin >> s[i+1];
    rep(i,b) cin >> t[i+1];
    rep(i,q) cin >> x[i];

    vector<ll> S(2),T(2);
    ll ans = 3*1e18;
    rep(i,q){
        ans = 3*1e18;
        S[1] = *upper_bound(s.begin(),s.end(),x[i]);
        S[0] = *(upper_bound(s.begin(),s.end(),x[i])-1);
        T[1] = *upper_bound(t.begin(),t.end(),x[i]);
        T[0] = *(upper_bound(t.begin(),t.end(),x[i])-1);
        rep(j,2){
            rep(k,2){
                ans = min(ans,min(abs(S[j]-x[i]) + abs(T[k]-S[j]),abs(T[k]-x[i]) + abs(T[k]-S[j])));
            }
        }
        cout << ans << endl;
    }
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
		int N;
	cin >> N;
	int cnt = 0;
	fx(N) {
		int d1, d2;
		cin >> d1 >> d2;
		if (d1==d2) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		if (cnt==3) {
			cey;
			return 0;
		}
	}
	cen;
    return 0;
}



Measured memory_bytes: 3676
<?php
$n = trim(fgets(STDIN));
$t = [];
for($i = 0; $i < $n; $i++)
{
    $in = explode(" ", trim(fgets(STDIN)));
    $t[] = $in;
}

$m = array("S", "H", "C", "D");
$o = [];
for($j = 0; $j < count($m); $j++)
{
    for($k = 1; $k <= 13; $k++)
    {
        $o[] = array($m[$j],(string)$k);
    }
}

$r = $o;

for($l = 0; $l < count($o); $l++)
{
    for($n = 0; $n < count($t); $n++)
    {
        if($o[$l][0] == $t[$n][0] && $o[$l][1] == $t[$n][1])
        {
            unset($r[$l]);
        }
    }
}

$r = array_values($r);

for($m = 0; $m < count($r); $m++)
{
    echo $r[$m][0] . " " . (int)$r[$m][1] . "\n";
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    string S;
    cin >> S;
    if(S == "AAA" || S == "BBB") {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N; cin >> N;
	string kanban; cin >> kanban;
	int ans = 0;
	for (int n = 0; n < N;n++) {
		string str; cin >> str;
		bool flag = false;
		for (int i = 0; i < str.size();i++) {
			if (str[i] != kanban[0])continue;
			for (int j = i + 1; j < str.size();j++) {
				if (str[j] != kanban[1]) continue;

				int at = j;
				int dif = j - i;
				bool f = true;
				at += dif;
				for (int k = 2; k < kanban.size();k++) {
					if (at >= str.size()) { f = false; break; }
					if (kanban[k] != str[at]) { f = false; break; }
					at += dif;
				}
				if (f) {
					ans++;
					flag = true;
					break;
				}
			}
			if (flag)break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        String[] in = null;
        int a, b;
        int numConstractionPoint;

        try {
            while ((line = input.readLine()) != null) {
                in = line.split(" "); // read a,b
                if (in[0].equals("0") && in[1].equals("0")) {
                    break;
                }
                a = Integer.parseInt(in[0]);
                b = Integer.parseInt(in[1]);

                // read number of constractionPoint
                numConstractionPoint = Integer.parseInt(input.readLine());

                // read contractionPoint
                int[][] intersection = new int[b][a];
                int constractionX, constractionY;
                for (int i = 0; i < numConstractionPoint; i++) {
                    line = input.readLine();
                    in = line.split(" ");
                    constractionX = Integer.parseInt(in[0]) - 1;
                    constractionY = Integer.parseInt(in[1]) - 1;
                    if (constractionY == 0) {
                        for (int j = constractionX; j < a; j++) {
                            intersection[0][j] = -1;
                        }
                    } else if (constractionX == 0) {
                        for (int j = constractionY; j < b; j++) {
                            intersection[j][0] = -1;
                        }
                    } else {
                        intersection[constractionY][constractionX] = -1;
                    }
                }
                if (intersection[0][0] < 0) { // start is constractionPoint
                    System.out.println(0);
                    break;
                }

                // solve
                for (int i = 0; i < b; i++) {
                    for (int j = 0; j < a; j++) {
                        if (intersection[i][j] < 0) { // [i][j] is constractionPoint etc...
                            intersection[i][j] = 0;
                        } else if (i == 0 || j == 0) { // [i][j] is latticeEnd(left or under)
                            intersection[i][j]++;
                        } else {
                            intersection[i][j] = intersection[i - 1][j] + intersection[i][j - 1];
                        }
                    }
                }
                System.out.println(intersection[b - 1][a - 1]);

            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}


Measured memory_bytes: 24300
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int main(){
  int a,b;cin>>a>>b;
  cout<<6-a-b<<endl;
  return 0;
}

Measured memory_bytes: 256
class SegmentTree:
    def __init__(self, initial_values, f=max, zero=0):
        self.__size = len(initial_values)
        self.__n = 1 << ((self.__size - 1).bit_length())
        self.__f = f
        self.__z = zero
        self.__dat = [zero for _ in range(2 * self.__n)]
        zi = self.__n - 1
        for i, v in enumerate(initial_values):
            self.__dat[zi + i] = v
        for i in range(zi-1, -1, -1):
            self.__dat[i] = self.__f(self.__dat[2*i+1], self.__dat[2*i+2])
    
    def update(self, index, value):
        i = self.__n + index - 1
        if self.__dat[i] == value: return
        self.__dat[i] = value
        while i > 0:
            i = (i-1)//2
            self.__dat[i] = self.__f(self.__dat[2*i+1], self.__dat[2*i+2])
    
    def query(self, from_inclusive, to_exclusive):
        if to_exclusive <= from_inclusive: return self.__z
        a, b = self.__n + from_inclusive - 1, self.__n + to_exclusive - 2
        ans = self.__z
        while b - a > 1:
            if a&1 == 0: ans = self.__f(ans, self.__dat[a])
            if b&1 == 1: ans, b = self.__f(ans, self.__dat[b]), b-1
            a, b = a//2, (b-1)//2
        ans = self.__f(ans, self.__dat[a])
        if a != b: ans = self.__f(ans, self.__dat[b])
        return ans

N = int(input())
S = input()
g = lambda c: 1 << (ord(c)-ord('a'))
tree = SegmentTree([g(c) for c in S], lambda x,y:x|y)
Q = int(input())
for _ in range(Q):
    t, a, b = input().split()
    if t == '1': tree.update(int(a)-1, g(b))
    else: print(bin(tree.query(int(a)-1, int(b))).count('1'))

Measured memory_bytes: 115864
#include<cstdio>
#define N 2002
#define p 924844033
inline int mod(int x){return x<p?x:x-p;}
int a[N],f[N][2],i,j,m,n,s,x;
int main()
{
	scanf("%d%d",&n,&m),f[0][0]=1;
	for(i=1;i<=m;i++)
	{
		for(j=0;j<=n;f[j++][0]=0)f[j][1]=mod(f[j][0]+f[j][1]);
		for(s=(n-i)/m+2>>1;s--;)
		for(j=n;j--;)
		{
			f[j+1][0]=mod(f[j+1][0]+f[j][0]);
			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));
			f[j][0]=mod(f[j][0]+f[j][1]);
			f[j][1]=0;
		}
		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;
	}
	for(;i<=n&&i<=m<<1;i++)
	{
		for(j=0;j<=n;f[j++][1]=0)f[j][0]=mod(f[j][0]+f[j][1]);
		for(s=(n-i)/m+2>>1;s--;)
		for(j=n;j--;)
		{
			f[j+1][0]=mod(f[j+1][0]+f[j][0]);
			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));
			f[j][0]=mod(f[j][0]+f[j][1]);
			f[j][1]=0;
		}
		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;
	}
	for(i=*a=1;i<=n;i++)a[i]=(long long)a[i-1]*i%p;
	for(i=0;i<=n;i++)x=i&1?(x+(long long)(p-a[n-i])*(f[i][0]+f[i][1]))%p:(x+(long long)a[n-i]*(f[i][0]+f[i][1]))%p;
	return 0&printf("%d\n",x);
}

Measured memory_bytes: 1728
#include <iostream>
#include<string>
int main() {
	std::string s, t;
	std::cin >> s >> t;
	s += s;
	auto ans = "No";
	for (int i = 0;i <= s.size() - t.size();i++)
	{
		if (s.substr(i, t.size()) == t)
		{
			ans = "Yes";
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    long long b,n;
    scanf("%d%lld%lld",&a,&b,&n);
    long long x=b-1;
    while(x>n)
        x--;
    long long t= a*x/b;
    printf("%lld",t);
}


Measured memory_bytes: 3828