akhauriyash/Code-Regression huggingface dataset:
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w)
}

fn main() {
    let k: i32 = input();
    let x: i32 = input();
    let y: i32 = input();

    if k % 2 == 0 && dist((x, y), (0, 0)) % 2 == 1 {
        println!("-1");
        return;
    }

    let ((x, y), flip) = xy_flip(x, y);
    let mut goal = (x, y);
    if x + y < k && (x + y) % 2 == 1 {
        goal = (x, y + k);
    }

    let mut v = vec![];
    let mut pos = (0, 0);
    let mut diff = (dist(goal, (0, 0)) + k - 1) / k * k - dist(goal, (0, 0));
    if diff % 2 == 1 || dist(goal, (0, 0)) < k {
        diff += k;
    }
    diff /= 2;
    while pos != goal {
        if diff > 0 {
            pos.0 = -diff;
            pos.1 = k - diff;
            diff = 0;
        } else {
            let dx = std::cmp::min(goal.0 - pos.0, k);
            pos.0 += dx;
            pos.1 += k - dx;
        }
        v.push(pos);
    }

    if pos != (x, y) {
        v.push((x, y));
    }

    with_stdout_lock(|mut w| {
        writeln!(w, "{}", v.len()).unwrap();
        for (x, y) in v {
            let (x, y) = inv_xy_flip(x, y, flip);
            writeln!(w, "{} {}", x, y).unwrap();
        }
    });
}

fn dist(p: (i32, i32), q: (i32, i32)) -> i32 {
    i32::abs(p.0 - q.0) + i32::abs(p.1 - q.1)
}

fn xy_flip(x: i32, y: i32) -> ((i32, i32), (bool, bool, bool)) {
    let mut p = (x, y);
    let mut flip = (false, false, false);
    if p.0 < 0 {
        p.0 = -p.0;
        flip.0 = true;
    }
    if p.1 < 0 {
        p.1 = -p.1;
        flip.1 = true;
    }
    if p.0 > p.1 {
        let t = p.0;
        p.0 = p.1;
        p.1 = t;
        flip.2 = true;
    }
    (p, flip)
}

fn inv_xy_flip(x: i32, y: i32, flip: (bool, bool, bool)) -> (i32, i32) {
    let mut p = (x, y);
    if flip.2 {
        let t = p.0;
        p.0 = p.1;
        p.1 = t;
    }
    if flip.1 {
        p.1 = -p.1;
    }
    if flip.0 {
        p.0 = -p.0;
    }
    p
}


Measured memory_bytes: 8316
A, B, C = map(int, input().split())
# print(', '.join(list(map(str, [A, B, C]))))

num0 = [A, B, C]
max_num = max([A, B, C])
res = 0

diff = [max_num - A, max_num - B, max_num - C]

while True:
    div_c = 0
    mod_c = 0
    for i in range(3):
        if diff[i] != 0:
            mod = diff[i] % 2
            div = int(diff[i] / 2)
            div_c += div
            mod_c += mod / 2
            num0[i] += (2 * div + mod)
    res = div_c + mod_c
    integer = int(res)

    if res - integer == 0 and num0[0] == num0[1] and num0[1] == num0[2]:
        break

    max_num += 1
    diff = [max_num - A, max_num - B, max_num - C]
    num0 = [A, B, C]

print(int(res))

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

using namespace std;

#define int long long

int n,p;
string s;
map<int,int> mp;

int qp(int a,int b)
{
	if (b == 0)
		return 1;
	int tmp = qp(a,b/2);
	if (b%2 == 0) return (tmp * tmp)%p;
	return ((tmp * tmp)%p * a)%p;	
}

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

	cin >> n >> p;
	cin >> s; s = '*' + s;
	if (p == 2 || p == 5)
	{
		int ans = 0;
		for (int i=1;i<=n;i++)
		{
			if ((s[i] - '0') % p == 0)
			ans += i;	
		}		
		cout << ans;
		return 0;
	}
	int cur = 0, ans = 0;
	mp[0]++;
	for (int i=1;i<=n;i++)
	{
		cur = (cur + ((s[i] - '0') * qp(10,n - i + 1))%p)%p;
		ans += mp[cur];
		mp[cur]++;
	}
	cout << ans;
}

Measured memory_bytes: 1104
#include<iostream>

using namespace std;

int main()
{
  char all[4];
  for(int i = 0;i<4;i++)
    scanf("%c",&all[i]);
  if(   (all[0]==all[1]) || (all[1]==all[2])     ||  (all[2]==all[3]) )
  {
    printf("Bad\n");
    return 0;
  }
  else
  {
  printf("Good\n");
  }
  return 0;
}


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


void solve(long long A, long long B, long long C){
   cout << (A^B^C) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<cmath>
    #include<tuple>
    #include<string>
    typedef unsigned long long ll;
    #define rep(i,a,b) for(int i=(a);i<(b);i++)
    #define F first
    #define S second
    using namespace std;
    const ll INF = 1e12;
    const int i_INF = 2147483647;
     
    int main() {
      int n;
      cin>>n;
      while(true){
        if(n%111==0){
          cout<<n<<endl;
          break;
        }
        n++;
      }
    }

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy";
	else if (s == "Cloudy") cout << "Rainy";
	else cout << "Sunny";
	return 0;
}

Measured memory_bytes: 256
//#pragma gcc optimize("Ofast")
//#pragma gcc optimize("unroll-loops")
#include <iostream>
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>
#include <cstdint>

using namespace std;

#define int long long

#ifndef M_PI
#define M_PI 3.141592653589793238462643383279
#endif

#define mp make_pair
#define mt make_tuple
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()
#define get0 get<0>
#define get1 get<1>
#define get2 get<2>
#define get3 get<3>

#define debug(x) cerr << #x << " = " << x << ", line = " << __LINE__ << endl

typedef long long ll;
typedef long double ld;
typedef tuple<long long, long long, long long> tlll;
typedef tuple<int, int, int> tiii;
typedef tuple<int, int, int, int> tiiii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int SZ = 1e6 + 1;
int used[SZ];


int32_t main()
{
#ifdef chikibambony
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
    int k;
    cin >> k;
    int cur = 0;
    for (int i = 1;;++i) {
        cur = (cur * 10 + 7) % k;
        if (used[cur]) {
            break;
        }
        if (cur == 0) {
            cout << i << endl;
            return 0;
        }
        used[cur] = 1;
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 11420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int n;

void func(vector<int> vec){
    //bit列を表示させる
    for(int i=0;i<n;i++){
        cout << vec[i];
    }
    cout << endl;
    return;
}

int main() {
    //入力
    cin >> n;
    vector<vector<pair<int,int>>> pr(n);
    //証言
    rep(i,n){
      int j=0;
      int nn;
      cin >> nn;
      while(j<nn){
        int a,b;
        cin >> a >> b;
        a--;
        pr[i].push_back(make_pair(a,b));
        j++;
      }
    }

    //----- bit 全探索 ------
    //ここで2^n-1個のbit列を列挙
    int cnt=0;
    int nax = -1;
    for (int bit = 0; bit < (1 << n); ++bit) {
        cnt=0;
        vector<int> vec(n);
        //ここで、列の各位が1かをみる
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
            //もし1だったら何か処理
            vec[i]=1;
            }

        }
        //証言の照らし合わせ
        rep(i,n){
          bool flag = true;
          //仮定上、今見てる人が正しいならば
          if(vec[i]){
            //その人の証言に矛盾がないか確認
            rep(j,pr[i].size()){
              if(pr[i][j].second==1){
                if(vec[pr[i][j].first]==1);
                else flag = false;
              }
              if(pr[i][j].second==0){
                if(vec[pr[i][j].first]==1)
                  flag = false;
              }
            }
            if(flag) cnt++;
          }
        }
        int cnt2=0;
        rep(i,n){
          if(vec[i])
            cnt2++;
        }
        if(cnt==cnt2)
          nax = max(cnt,nax);
    }
    cout << nax << endl;
}


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll gcd(ll a, ll b) {
	if (b == 0) return abs(a);
	else return gcd(b, a % b);
}

int main() {
	for (;;) {
		string s; cin >> s;
		if (s == "#") break;
		vector<bool> v;
		for (int i = 0; i < s.length();)
			if (s[i] == 'n') {
				v.push_back(false);
				i += 5;
			}
			else if (s[i] == 'w') {
				v.push_back(true);
				i += 4;
			}
		reverse(v.begin(), v.end());
		int a = (v[0] ? 1 : 0), b = 1;
		for (int j = 1; j < v.size(); j++) {
			a *= 2; b *= 2;
			a += (v[j] ? 1 : -1);
		}
		a *= 90;
		int d = gcd(a, b);
		a /= d; b /= d;
		cout << a;
		if (b != 1) cout << '/' << b;
		cout << endl;
	}
}

Measured memory_bytes: 1196
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>

#define range(i, n) for (i = 0; i < n; i++) 
#define rrange(i, n) for(i = n-1; i>=0; i--)

typedef long long int ll;

using namespace std;

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

vector<ll> p;
vector<ll> t;

ll ans(ll N, ll X);

ll ans(ll N, ll X) {
	if (N == 0) {
		if (X <= 0) return 0;
		else return 1;
	}
	else if (X <= 1 + t[N - 1]) {
		return ans(N - 1, X - 1);
	}
	else {
		return p[N - 1] + 1 + ans(N - 1, X - 2 - t[N - 1]);
	}
	
}

int main() {
	ll N, X;
	ll P, B;

	cin >> N >> X;



	int i;
	p.push_back(1);
	t.push_back(1);
	range(i, N) {
		p.push_back(p[i]*2 + 1);
		t.push_back(t[i]*2 + 3);
	}

	cout << dec << ans(N, X);

	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
s1 = gets.chomp.split(" ")
s2 = gets.chomp.split(" ")
s1 = s1.map!(&:to_i)
s2 = s2.map!(&:to_i)
data = []
all_data = []
for i in 0..(n-1)
    data[i] = i+1
end
all_data = data.permutation.to_a.sort
a = all_data.index(s1)+1
b = all_data.index(s2)+1
puts (a-b).abs

Measured memory_bytes: 7384
from itertools import combinations_with_replacement

N,M,Q = map(int,input().split())

numbers = [(i+1) for i in range(M)]

number_pattern = list(combinations_with_replacement(numbers,N))
right_pattern = [[] for i in range(len(number_pattern))]

for i in range(Q):
    a,b,c,d = map(int,input().split())
    for j in range(len(number_pattern)):
        if number_pattern[j][b-1] - number_pattern[j][a-1] == c:
            right_pattern[j].append(d)

ans_list = []

for i in right_pattern:
    if not i:
        ans_list.append(0)
    else:
        ans_list.append(sum(i))

ans_list.sort(reverse=True)

print(ans_list[0])

Measured memory_bytes: 42908
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
d = {}
s = 0
for i in range(N):
    a = int(input())
    if a in d.keys():
        d[a] += 1
    else:
        d[a] = 1
for i in d.values():
    s += i%2
print(s)







Measured memory_bytes: 15072
#include <bits/stdc++.h>
double v[50];
using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  
  int n; cin >> n;
  for(int i=0;i<n;i++) cin >> v[i];
  sort(v,v+n);
  double res = v[0];
  for(int i=1;i<n;i++) {
    res = (res + v[i]) / 2;
  }
  cout << setprecision(10) << res;
  return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
aind = A.index(1)
if aind%(K-1)==0:
    cl = aind//(K-1)
    if (N-aind-1)%(K-1)==0:
        cr = (N-aind-1)//(K-1)
    else:
        cr = (N-aind-1)//(K-1)+1
else:
    bind = aind+K-1-aind%(K-1)
    cl = bind//(K-1)
    if (N-bind-1)%(K-1)==0:
        cr = (N-bind-1)//(K-1)
    else:
        cr = (N-bind-1)//(K-1)+1
print(cr+cl)

Measured memory_bytes: 13880
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>

#define int long long
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001001001001;
vector<int> D;
int N,K;
	int a[100002];
	int wa[100002];
	int miwa[100002];
	int plwa[100002];
	int Kwa[100002];
	int miKwa[100002];
	int plKwa[100002];
signed main(){
	
	scanf("%lld %lld",&N,&K);
	rep(i,N){scanf("%lld",&a[i]);}
	int large=INF,largen=-1;
	int small=-INF,smallen=-1;
	rep(i,N){
		if(i==0){
			wa[i]=a[i];
			miwa[i]=min((int)0,a[i]);
			plwa[i]=max((int)0,a[i]);
		}else{
			wa[i]=a[i]+wa[i-1];
			miwa[i]=min((int)0,a[i])+miwa[i-1];
			plwa[i]=max((int)0,a[i])+plwa[i-1];
		}
		if(i>=K-1){
			if(i-K>=0)Kwa[i]=wa[i]-wa[i-K];
			else Kwa[i]=wa[i];
			if(i-K>=0)miKwa[i]=miwa[i]-miwa[i-K];
			else miKwa[i]=miwa[i];
			if(i-K>=0)plKwa[i]=plwa[i]-plwa[i-K];
			else plKwa[i]=plwa[i];
			if(plKwa[i]<=large){
				large=plKwa[i];
				largen=i;
			}
			if(miKwa[i]>=small){
				small=miKwa[i];
				smallen=i;
			}
		}
	}
	int ans1=0,ans2=0,ans3=0;
	if(largen)rep(i,N){
		if(i==largen-K+1){
			//ans1+=Kwa[largen];
			i=largen;
		}else ans1+=max(a[i],(int)0);
	}
	if(smallen)rep(i,N){
		if(i==smallen-K+1){;
			ans2+=Kwa[smallen];
			i=smallen;
		}else ans2+=max(a[i],(int)0);
	}
	printf("%lld\n",max(Kwa[N-1],max(ans3,max(ans1,ans2))) );
}

Measured memory_bytes: 5760
import std.stdio, std.array, std.conv, std.algorithm, std.string, std.numeric, std.range;
void main() {
	string s;
	while( (s=readln.strip).length != 0 ){
		auto as = s.split(' ').map!(to!int).array;
		int[10] m;
		m[as[0]-1] = 1; m[as[1]-1] = 1; m[as[2]-1] = 1;
		int c = 0;
		for(int i=0; i < 20-as[0]-as[1] && i < 10;i++){
			if(m[i] == 0) c++;
		}
		if(c>3) writeln("YES");
		else writeln("NO");
	}
}

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

int a[200],b[10],n,i,sl;

int kt(int x)
{
    if (x>=3200) {return 1;}
    if (x>=2800) {return 2;}
    if (x>=2400) {return 3;}
    if (x>=2000) {return 4;}
    if (x>=1600) {return 5;}
    if (x>=1200) {return 6;}
    if (x>=800) {return 7;}
    if (x>=400) {return 8;}
    return 9;
}
int main()
{
  //  freopen("baiA.inp","r",stdin);
   // freopen("baiA.out","w",stdout);
    scanf("%d\n",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d ",&a[i]);
        b[kt(a[i])]++;
    }
    for (i=2;i<=9;i++)
    {
        if (b[i]>0) {sl++;}
    }
    printf("%d %d",max(1,sl),sl+b[1]);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int f[3];
	
	scanf("%d %d %d", &f[0], &f[1], &f[2]);
	
	if (f[0] == 1 && f[1] == 1){
		printf("Open\n");
	}
	else if (f[2] == 1){
		printf("Open\n");
	}
	else {
		printf("Close\n");
	}
	
	return (0);
}

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

int main(void) {
    ll N; cin >> N;
    ll max = 0;
    ll ans = 0;
    for(ll i=0; i<N; i++) {
        ll A; cin >> A;
        if(A>max) max = A;
        else ans += (max-A);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	int N;
	cin>>N;
	int px=0,py=0,pt=0;
	rep(i,N){
		int x,y,t;
		cin>>t>>x>>y;
		int d = abs(x-px) + abs(y-py);
		int dt = t-pt;
		if(dt<d || (dt-d)%2==1){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

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

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    ll a, b100;
    double b;
    cin >> a >> b;
    b100 = floor(b * 100.0001);
    ll ans = (a * b100) / 100;
    cout << ans << endl;
}

Measured memory_bytes: 3848
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,j,c1,c2,mn,x1,x2,cnt;
	char s[101];
	scanf("%d",&n);
	scanf("%s",s);
	cnt=0; mn=0;
	for(i=0;i<n;i++)	{
		if(s[i]=='(')	cnt++;
		else {
			cnt--;
			if(cnt<mn)	mn=cnt;
		}
	}
	x1=-mn;
	x2=cnt+x1;
	for(i=0;i<x1;i++)	printf("(");
	for(i=0;i<n;i++)	printf("%c",s[i]);
	for(i=0;i<x2;i++)	printf(")");
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 1500000; const double eps = 1e-9;
int s[N],len;
ll ans[N]; int size,dig[N];
//Vi res;
ll getdig(ll x) {ll res=0; while (x)res+=x%10,x/=10; return res;}
bool ok(int dig, ll x) {
	int cnt=0,pre=0; rep(i,1,len) if (s[i]==9)cnt=i; else break;
	per(i,len,cnt+1) pre=10*pre+s[i];
	ll mi=1; rep(i,1,cnt) mi*=10;
	
	
	rep(i,1,1) if (1LL*((pre+1)*mi-1)*getdig(1LL*((pre+1+i)*mi-1))>1LL*((pre+1+i)*mi-1)*(dig)) {
	//	if (dig==117 && x == 9999999999999) printf("i = %d\n",i);
		return 0;
	}
	return 1;
}
void dfs(int x) {
	if (len>15) return;
	if (!x) {
		++size; dig[size]=ans[size]=0;
		per(i,len,1) dig[size]+=s[i],ans[size]=10*ans[size]+s[i];
	//	if (ans[size]==9999999999999&&dig[size]==getdig(ans[size])) printf("OWO %d %d\n",dig[size],ok(dig[size],ans[size]));
		if (!ok(dig[size],ans[size])) {size--;}
		return;
	}
	if (x>27) {s[++len]=9; x-=9; dfs(x); return;}
	if (len>3&&s[len-3]!=9) return;
	rep(i,0,min(9,x)) {s[++len]=i; dfs(x-i); len--;}
}
int main() { //freopen("1.in","r",stdin);
//	cerr << ok(getdig(9999999999999),9999999999999);
 
	rep(i,1,140) {
		len=0;dfs(i);
	}
	sort(ans+1,ans+size+1);
	cerr << size <<endl;
//	cerr << ans[size] <<endl;
//	rep(i,1,size)printf("%lld,",ans[i]);
	int k; read(k);
	rep(i,1,k) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#define _GLIBCXX_DEBUG
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく


//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

bool E[2005][2005];
vector<bool> seen;
typedef pair<int, int> P;
typedef tuple<int, int, int> Tu;
//typedef pair<string, int> P;
int D[2005];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

int main() {
    int N; cin >> N;
    long long K; cin >> K;
    vector<P> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i).first >> A.at(i).second;
    }
    sort(A.begin(), A.end());
    long long sum = 0;
    int count = 0;
    while (K > sum) {
        sum += A.at(count).second;
        if (sum >= K) {
            cout << A.at(count).first << endl;
            return 0;
        }
        count++;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  ll res = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    res += min(a, abs(a-k))*2;
  }
  cout << res << endl;
}

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

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

bool OK(string t) {
    int m = t.size();
    int cnt[27] = {0};
    for(auto& i : t) cnt[i - 'a']++;
    rep(i,26) if(cnt[i] > m/2) return true;
    return false;
}

void solve(string s) {
    int n = s.size();
    if(n == 2) {
        if(s[0] == s[1]) puts("1 2");
        else puts("-1 -1");
        return ;
    }

    for(int len=2; len<=3; len++) {
        for(int i=0; i+len<n; i++) {
            string t = s.substr(i,len);
            if(OK(t)) {
                printf("%d %d\n", i+1, i+len);
                return ;
            }
        }
    }
    puts("-1 -1");
}

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

    return 0;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for(int i = 0; i < M; i++) cin >> X.at(i);
  sort(X.begin(), X.end());
  
  if(N >= M){
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> dist(M-1);
  for(int i = 0; i < M-1; i++){
    dist.at(i) = X.at(i+1) - X.at(i);
  }
  sort(dist.begin(), dist.end());
  int ans = 0;
  for(int i = 0; i < M-N; i++){
    ans += dist.at(i);
  }
  cout << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    A,B,C,K = map(int,input().split())
    if K%2 == 0:
        ans = A - B
    else:
        ans = B - A
    if abs(ans) > 1000000000000000000:
        ans = 'Unfair'
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    string str;
    cin>>str;
    int ca=0,cb=0;
    for(int i=0;i<3;i++)
    {
        if(str[i]=='A')
        {
            ca++;
        }
        else
        {
            cb++;
        }
    }
    if(ca==0 || cb==0)
    {
        cout<<"No";
    }
    else
    cout<<"Yes";
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())

if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    res = min(b - 1, n - a)
    d = min(a - 1, n - b)
    s = b - a - 1
    res2 = d + 1 + (s // 2)
    print(min(res, res2))
    # print(res, res2, d)


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

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  if((n==1&&a!=b)||a>b){
    cout << 0 << endl;
  }else{
    cout << (n-2)*(b-a)+1 << endl;
  }
}

Measured memory_bytes: 3648
import java.io.IOException;
import java.io.InputStream;
import java.math.*;

public class Main {

	static FastReaderR in = new FastReaderR(System.in) ;
	
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		int N = in.nextInt() ;
		int a = 0 ;
		int b = 0 ;
		int ab = 0 ;
		int ans = 0 ;
		for(int i=0;i<N;i++){
			String line = in.next() ;
			if(line.charAt(0)!='B'&&line.charAt(line.length()-1)!='A'){
				int index = 0 ;
				while(true){
					index = line.indexOf("AB",index) ;
					if(index!=-1)
						ans++ ;
					else
						break ;
					if(index+1>=line.length())
						break ;
					index += 1 ;
				}
			}else{
				if(line.charAt(0)=='B'&&line.charAt(line.length()-1)=='A'){
					ab++ ;
					int index = 0 ;
					while(true){
						index = line.indexOf("AB",index) ;
						if(index!=-1)
							ans++ ;
						else
							break ;
						if(index+1>=line.length())
							break ;
						index += 1 ;
					}
				}else{
					if(line.charAt(0)!='B'&&line.charAt(line.length()-1)=='A'){
						a++ ;
						int index = 0 ;
						while(true){
							index = line.indexOf("AB",index) ;
							if(index!=-1)
								ans++ ;
							else
								break ;
							if(index+1>=line.length())
								break ;
							index += 1 ;
						}
					}
					if(line.charAt(line.length()-1)!='A'&&line.charAt(0)=='B'){
						b++ ;
						int index = 0 ;
						while(true){
							index = line.indexOf("AB",index) ;
							if(index!=-1)
								ans++ ;
							else
								break ;
							if(index+1>=line.length())
								break ;
							index += 1 ;
						}
					}
				}
			}
		}
		ans += Math.min(a, b) ;
		if(a==0&&b==0){
			if(ab!=0)
				ans += (ab-1) ;
		}else{
			if(ab!=0)
				ans += ab ;
		}
		System.out.println(ans);
	}

}

class FastReaderR {
    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;
 
    FastReaderR(InputStream is) {
        in = is;
    }
    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }
    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan());
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan());
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }
}





Measured memory_bytes: 25556
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}


int main(){
	int x, y, z;
	cin >> x >> y >> z;

	cout << z << " " << x << " " << y << endl;

}

Measured memory_bytes: 256
main = interact $ show . sol . map read . words

sol [n,m] = if abs (n-m) > 1 then 0 
  else f @*@ f @*@ if n==m then 2 else max n m
  where
  f = foldl1 (@*@) [1..min n m]

infixl 7 @*@
(@*@) a b = a*b `mod` (10^9+7)

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

using namespace std;

int main ()
{
    bool b = 0;
    string s, s1;

    cin >> s >> s1;

    for (int i = 0; i < (int) s.size(); i++) {
        if (s[i] != s1[i]) {
            b = 1;
            break;
        }
    }
    if (b) puts("No");

    else puts("Yes");

    return 0;
}


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

class MainClass
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NM[0];
        int M = NM[1];
        bool[,] A = new bool[N, N];
        for (int i = 0; i < N; i++)
        {
            var line = ReadLine();
            for (int j = 0; j < N; j++)
            {
                A[i, j] = line[j]=='#';
            }
        }
        var B = new bool[M, M];
        for (int i = 0; i < M; i++)
        {
            var line = ReadLine();
            for (int j = 0; j < M; j++)
            {
                B[i, j] = line[j] == '#';
            }
        }

        for (int i = 0; i < N-M+1; i++)
        {
            for (int j = 0; j < N-M+1; j++)
            {
                bool frag = true;
                for (int a = 0; a < M; a++)
                {
                    for (int b = 0; b < M; b++)
                    {
                        if (B[a, b] != A[i+a, j+b]) frag = false;
                    }
                }
                if (frag)
                {
                    WriteLine("Yes");
                    return;
                }
            }
        }
        WriteLine("No");
    }
}


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


int main()
{
    ll n;
    cin >> n;
    ll val;
    cin >> val;

    for(ll i=0; i<=n; i++)
    {
        for(ll j=0; j<=n; j++)
        {

                if( i*10000 + j*5000 + (n-i-j)*1000 ==val && n-i-j>=0)
                {
                    cout << i << " " << j << " " << n  - i - j << endl;
             return 0;
                }
            }
        }

    cout<<"-1 -1 -1"<<endl;



}



Measured memory_bytes: 3612
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>
#include <cstring>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll l = 0;
    ll r = 1e9;
    while(r-l>1) {
        ll m = (l+r)/2;
        ll num = 0;
        rep(i, n) {
            num += (a[i] - 1LL) / m;
        }
        if (num > k) {
            l = m;
        }
        else {
            r = m;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 4796
W, H, N = map(int, input().split())
x_list = [0, W]
y_list = [0, H]

for i in range(N):
    l = input().split()
    x = int(l[0])
    y = int(l[1])
    a = int(l[2])
    if a == 1:
        if x_list[0] < x:
            x_list[0] = x
    if a == 2:
        if x_list[1] > x:
            x_list[1] = x
    if a == 3:
        if y_list[0] < y:
            y_list[0] = y
    if a == 4:
        if y_list[1] > y:
            y_list[1] = y
            
S = (x_list[1] - x_list[0]) * (y_list[1] - y_list[0])

if x_list[1] - x_list[0] <= 0 or y_list[1] - y_list[0] <= 0:
    print(0)
else:
    print(S)
     

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n;
    cin >> n;
    ll a = 2, b =  1;
    if(n == 1){
        cout << 1 << endl;
    }else{
        ll c;
        for(int i = 0; i < n - 1; i++){
            c = a + b;
            a = b;
            b = c;            
        }
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
var x,y,z,t:int64;
begin
read(x,y,z);
if(x mod 2=0)or(y mod 2=0)or(z mod 2=0)then writeln(0)else begin
if x>y then begin t:=x;x:=y;y:=t;end;
if y>z then begin t:=y;y:=z;z:=t;end;
if x>y then begin t:=x;x:=y;y:=t;end;
writeln(x*y);
end;
end.

Measured memory_bytes: 128
n,l=map(int, input().split())
tastes=[l+i-1 for i in range(1,n+1)]
applepi=sum(tastes)

dif=101
for i in range(len(tastes)):
    tmp=tastes[:]
    tmp.pop(i)
    if dif > abs(applepi-sum(tmp)):
        dif = abs(applepi-sum(tmp))
        apples=tmp[:]

print(applepi-(applepi-sum(apples)))


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }



int main(){
    LL a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}



Measured memory_bytes: 3196
N,W=map(int,input().split())
goods=[tuple(map(int,input().split())) for _ in range(N)]
goods.sort(key=lambda x:x[0]/x[1],reverse=True)
dp=[0 for w in range(W+1)]
minw=W
for i in range(N):
    if i==0 or (goods[0][0]/goods[0][1]==goods[i][0]/goods[i][1] and minw>W%goods[i][1]):
        for j in range(W+1):
            dp[j]=goods[i][0]*(j//goods[i][1])
        minw=W%goods[i][1]
        roop=goods[i][1]
        continue
    for k in range(1+roop):
        weight=minw+roop*k
        if weight>W:
            for w in range(goods[i][1],1+W):
                dp[w]=max(dp[w-goods[i][1]]+goods[i][0],dp[w])
            break
        if weight%goods[i][1]==0:
            for w in range(W-weight,1+W):
                if w-goods[i][1]<0:continue
                dp[w]=max(dp[w-goods[i][1]]+goods[i][0],dp[w])
print(dp[W])


Measured memory_bytes: 5932
// ref: https://img.atcoder.jp/abc114/editorial.pdf
// ref: 

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

bool isInc(string s, char c){
    for(uint i=0; i<s.size(); ++i){
        if(s[i]==c){ return true; }
    }
    return false;
}

int solver(string s, int64 N){
    if(stoll(s)>N){ return 0; }
    
    int ret=0;
    if( isInc(s, '7') && isInc(s, '5') && isInc(s, '3') ){ ++ret; }

    ret += solver(s+'7', N);
    ret += solver(s+'5', N);
    ret += solver(s+'3', N);
    
    return ret;
}

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    int N; cin >> N;
    cout << solver(string("0"), N) << endl;
    
    return 0;
}


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

int main(){
  int n, q;
  while(true){
    cin >> n >> q;
    if(n == 0)
      break;

    int m;
    vector< vector<int> > sch(n, vector<int>(101, 0));
    for(int i=0; i<n; i++){
      cin >> m;
      for(int j=0; j<m; j++){
        int temp;
        cin >> temp;
        sch[i][temp] = 1;
      }
    }

    int ans, nmax = 0;
    for(int i=0; i<101; i++){
      int sum = 0;
      for(int j=0; j<n; j++){
        sum += sch[j][i];
          }
      if(sum > nmax){
        ans = i;
        nmax = sum;
      }
    }
    
    if(nmax < q)
      ans = 0;
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3156
def main():
    s = str(input())
    count = 0
    count_lst = [0]
    flag = False

    for i in range(len(s)):
        letter = s[i]
        string = 'ACGT'

        if letter in string:
            count += 1
            flag = True

        else:
            if flag:
                count_lst.append(count)
            count = 0
            flag = False

    if flag:
        count_lst.append(count)
    longest = max(count_lst)
    print(longest)


if __name__ == '__main__':
    main()

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


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

  int X;
  cin >> X;

  if (X >= 30) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
using namespace std;
using namespace __gnu_pbds;
 
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
 
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define  st first
#define  nd second
#define int long long
#define ull unsigned long long
 
 
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;
 
const int  M    =  1000000007;
const int  maxn =  1001   ;
const long long   inf  =  1e18     ;
const long double eps = 1.084202e-19;
 
 
 
void solve(){
    string s ; 
    int k , n ;  
    cin >> k >> n ;
    int a[n]; 
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    vector<int> v ; 
    for(int i = 1 ; i<n ; i++){
      v.push_back(a[i]-a[i-1]);
    }
    v.push_back(k-a[n-1]+ a[0]);
    int mi = k ;
    for(int i = 0 ; i<v.size() ; i++){
           mi = min(mi,k-v[i]);
    }
    cout<<mi;
}
 
int32_t main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int te;
      te = 1;
      while(te--){
          solve();
          cout<<"\n";
      }
 
return 0;
}

Measured memory_bytes: 3956
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
#include <limits>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
bool debug_enabled = false;
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

// }}}

// bin {{{
template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

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

template<class T>
void sort(T& arr) { // {{{
  std::sort(arr.begin(), arr.end());
} // }}}
template<class T, class By>
void sort_by(T& arr, By by) { // {{{
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
} // }}}

template<class T>
void reverse(T& arr) { // {{{
  std::reverse(arr.begin(), arr.end());
} // }}}

class Random { // {{{
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
}; // }}}

template <class A>
ostream& out_vec(const vector<A>& x, const string& sep) { // {{{
  rep(i, x.size()) {
    cout << x[i];
    if(i < x.size() - 1)
      cout << sep;
  }
  return cout;
} // }}}
// }}}

// modulo {{{
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modplus(ll a, ll b, ll mod) {
  ll x = ((a % mod) + (b % mod)) % mod;
  if(x < 0) x += mod;
  return x;
}

ll modminus(ll a, ll b, ll mod) {
  return modplus(a, -b, mod);
}

// }}}

// main {{{
void solve();
int main() {
  cout << setprecision(20);
  solve();
}
// }}}

void solve() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 1;
  int c = S[0];
  rep2(i, 1, N) {
    if(S[i] == c) continue;
    c = S[i];
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
using System;

namespace ABC045_C_ManyFormulas
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            ulong answer = SumOfManyFormulas(input, 0);
            Console.WriteLine(answer);
        }

        /// <summary>
        /// indexまでの和を
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        static ulong SumOfManyFormulas(string expression, int index)
        {
            if (expression.Length - 1 == index)
            {
                return SumOfExpression(expression);
            }

            // + を入れる場合
            string insertedPlus = expression.Insert(index + 1, "+");

            //Console.WriteLine(insertedPlus);
            //Console.WriteLine(expression);

            return SumOfManyFormulas(insertedPlus, index + 2) + SumOfManyFormulas(expression, index + 1);
        }

        static ulong SumOfExpression(string expression)
        {
            string[] split = expression.Split('+');
            ulong sum = 0;
            for (int i = 0; i < split.Length; i++)
            {
                sum += ulong.Parse(split[i]);
            }

            return sum;
        }
    }
}


Measured memory_bytes: 3032
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;


int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<int> v(N);
    string s;
    cin >> s;
    int n=0;
    rep(i, N){
        if((i != 0) && (s[i-1] == 'A') && (s[i] == 'C')){
            n++;
        }
        v[i] = n;
    }

    rep(i, Q){
        int l, r;
        cin >> r >> l;
        cout << v[l-1] - v[r-1] << endl;
    }
}



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

using namespace std;

#define ll long long
#define pb push_back
#define sn "\n"

int main(){
    int l, r, d;
    int counter = 0;
    cin >> l >> r >> d;
    for (int i = l; i <= r; i++){
        if (i % d == 0){
            counter++;
        }
    }
    cout << counter;
}


Measured memory_bytes: 3632