akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long N; cin >> N;

    long long ans = 0;
    unordered_map<int,int> mp;

    for(int i=0; i<N; i++){
        int A; cin >> A;
        int target = i-A;
        if(target >= 0){
            ans += mp[target];
        }
        mp[A+i] += 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12068
import fractions

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

S=list(input())
T=list(input())

def lcm(a,b):
  return (a*b)//fractions.gcd(a,b)

NM=lcm(N,M)

#array=[0]*NM

battingS=[]
battingT=[]
#Scount=0
for i in range(0,N,NM//M):
  battingS.append(S[i])
  #Scount+=1
  #print(array)

Tcount=0

for j in range(0,M,NM//N):
  battingT.append(T[j])
  #Scount+=1
  '''
  if array[j]!=0 and array[j]!=T[Tcount]:
    print(-1)
    exit()
  else:
    array[j]=T[Tcount]
    Tcount+=1
  #print(array)
  '''

for i in range(len(battingS)):
  if battingS[i]!=battingT[i]:
    print(-1)
    exit()
#print(battingS,battingT)
print(NM)

Measured memory_bytes: 7908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 998244353;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };

int main()
{
ll n , s ;
cin >> n >> s ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
ll dp[n+1][s+1][3]={};
dp[0][0][0]=1;
dp[0][0][1]=1;
rep(i,n)rep(j,s+1)rep(k,3){
  (dp[i+1][j][k]+=dp[i][j][k] )%=mo;
  if(k!=2){
    (dp[i+1][j][k+1]+=dp[i][j][k] )%=mo;
  }

  if(j+a[i]<=s&&k==1){
    (dp[i+1][j+a[i]][k]+=dp[i][j][k] )%=mo;
    (dp[i+1][j+a[i]][k+1]+=dp[i][j][k] )%=mo;
  }
}
cout << dp[n][s][2] << endl;
return 0;
}


Measured memory_bytes: 211328
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3092
import java.util.*;

public class Main{
	public static void main(String[] args) {
		solve0001();
	}
	public static void solve0001() {
		Integer[] array=new Integer[10];
		Scanner sc = new Scanner(System.in); 
		
		for(int i=0; i < 10; i++){
			array[i] = new Integer(sc.nextInt());
		} 
		Arrays.sort(array,new MyComparator());
		for(int i = 0;i < 3;i++){
			System.out.println(array[i]); 
		}
	}
}
class MyComparator implements Comparator<Integer>{
	public int compare(Integer o1,Integer o2){
		return o1.intValue()<o2.intValue()?1:-1;
	}
}

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

int max(int x,int y){
  if(x>y) return x;
  return y;
}

int min(int x,int y){
  if(x<y) return x;
  return y;
}

int main(){
  double n,t,a,num=0,place=1;
  double res=100000,zansa,ave_t;
  int h;
  cin >> n >> t >> a;
  for(int i =0;i<n;i++){
    cin >> h;
    ave_t=t-h*0.006;
    zansa =fabs(ave_t-a);
    if(zansa<=res)place = i+1;
    res=min(res,zansa);
  //  cout << i+1 << " "<< ave_t << " " << zansa << endl;
  }
  cout << place << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def count_combination(n: int, r: int, mod: int = 10 ** 9 + 7) -> int:
    '''Count the total number of combinations.
        nCr % mod.
        nHr % mod = (n + r - 1)Cr % mod.
    Args:
        n   : Elements. Int of number (greater than 1).
        r   : The number of r-th combinations. Int of number (greater than 0).
        mod : Modulo. The default is 10 ** 9 + 7.
    Returns:
        The total number of combinations.
    Landau notation: O(n)
    See:
    https://qiita.com/derodero24/items/91b6468e66923a87f39f
    '''

    if (r > n) or (n < 0) or (r < 0):
        return 0

    if r > (n - r):
        return count_combination(n, n - r, mod)

    if r == 0 or r == n:
        return 1

    if r == 1:
        return n

    multiple = 1
    division = 1

    for i in range(r):
        multiple *= n - i
        division *= i + 1
        multiple %= mod
        division %= mod

    return multiple * pow(division, mod - 2, mod) % mod


def main():
    large_x, large_y = map(int, input().split())
    x = -large_x + 2 * large_y
    y = 2 * large_x - large_y

    # ■ポイント1
    # 原点から(X, Y)に到達するには，
    # (i + 1, j + 2)をx回, (i + 2, j + 1)をy回操作する必要がある，と言い換える

    # 移動したマスの数と操作回数に関する連立方程式を立てる
    #  x + 2y = X
    # 2x +  y = Y
    # これを解くと，x = (-X + 2Y) / 3, y = (2X - y) / 3

    # 到達できないパターン：x, yが整数でないとき
    if x % 3 != 0 or y % 3 != 0:
        print(0)
        exit()

    # ■ポイント2
    # 組み合わせは，(x + y)回のうちx回もしくはy回を選ぶ方法と同じ
    xy = (x + y) // 3
    y = y // 3
    print(count_combination(xy, y))

    # 類題: ARC035B
    # https://atcoder.jp/contests/arc035/tasks/arc035_b


if __name__ == '__main__':
    main()


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

signed main() {
    int N, M;
    cin >> N >> M;
    priority_queue<int> q;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        q.push(a);
    }

    for (int i = 0; i < M; i++) {
        int a = q.top();
        q.pop();
        q.push(a / 2);
    }

    int ans = 0;
    for (; q.size(); ){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
A[20000];z(int*a,int*b){return*b-*a;}
main(n,m,i,j){for(;scanf("%d",&n),m=n+n;puts(i>n?"No":"Yes")){
for(i=0;i<m;i++)scanf("%d",A+i);
for(i=qsort(A,n,4,z);i<n;A[i++]?i=n+1:1)for(j=n;j<m;j++)if(A[j])A[i]--,A[j]--;
}exit(0);}

Measured memory_bytes: 732
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

#define f first
#define s second
typedef pair<int, int> P;

int ID, rec[22];

int split(string s){
  stringstream ss(s);
  int i = 0;
  while(ss >> rec[i]) i++;
  return i;
}

bool compare(const P x, const P y){
  if(x.f == y.f){
    return x.s < y.s;
  }
  return x.f > y.f;
} 

int main(){
  int n;
  while(cin >> n, n){
    vector<P> data;
    string s;

    for(int cs = 0 ; cs < n ; cs++){
      memset(rec, 0, sizeof(rec));
      cin >> ID;
      getline(cin, s);
      int N = split(s);
      int tes = 0;
      int res = 0, flame = 1;
      for(int i = 0 ; flame <= 10 ; flame++, i++){
	res += rec[i] + rec[i+1];
	if(flame > 9) res += rec[i+2], i+=3;
	else if(rec[i] == 10) res += rec[i+2];
	else{
	  if(rec[i]+rec[i+1] == 10) res += rec[i+2];
	  i++;
	}
      }
      data.push_back(P(res, ID));
    }
    sort(data.begin(), data.end(), compare);
    for(int i = 0 ; i < n ; i++){
      cout << data[i].second << ' ' << data[i].first << endl;
    }
  }
  return 0;
}

      

Measured memory_bytes: 1228
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int H,W;
char a[1050][1050];
int f[1050][1050];
int num[1050][1050];
int dx[8]={-1,-1,-1,0,0,1,1,1};
int dy[8]={1,0,-1,1,-1,1,0,-1};
vector<P> cur,tmp,next;
int update()
{
	int col = 0;
	for(int i=0;i<cur.size();i++)
	{
		int x = cur[i].fi,y = cur[i].sec;
		if(f[x][y]!=0&&f[x][y]<=num[x][y])
		{
			tmp.pb(P(x,y));
			col++;
		}
	}
	for(int i=0;i<col;i++)
	{
		int x=tmp[i].fi,y=tmp[i].sec;
		f[x][y]=0;
		for(int j=0;j<8;j++)
		{
			int nx=x+dx[j],ny=y+dy[j];
			num[nx][ny]++;
		}
	}
	for(int i=0;i<tmp.size();i++)
	{
		int x = tmp[i].fi,y = tmp[i].sec;
		for(int j=0;j<8;j++)
		{
			int nx = x+dx[j],ny=y+dy[j];
			if(nx<0||nx>=H||ny<0||ny>=W)continue;
			if(f[nx][ny]!=0)next.pb(P(nx,ny));
		}
	}
	sort(next.begin(),next.end());
	next.erase(unique(next.begin(),next.end()),next.end());
	tmp.clear();
	cur.clear();
	cur=next;
	next.clear();
	return col;
}
int main()
{
	cin >> H >> W;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cin >> a[i][j];
			if(a[i][j]!='.')f[i][j]=a[i][j]-'0';
		}
	}
	for(int i=1;i<H-1;i++)
	{
		for(int j=1;j<W-1;j++)
		{
			cur.pb(P(i,j));
			int cnt = 0;
			for(int k=0;k<8;k++)
			{
				int nx=i+dx[k],ny=j+dy[k];
				if(f[nx][ny]==0)cnt++;
			}
			num[i][j]=cnt;
		}
	}
	int ans = 0;
	while(1)
	{
		int n = update();
		if(n==0)break;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 20516
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		String ans = "ABC";
		if(n >= 1000)ans = ans.replace("C", "D");
		System.out.println(ans);
	}

}


Measured memory_bytes: 22740
def main():
    N, M = (int(i) for i in input().split())

    par = [i for i in range(N)]
    size = [1 for i in range(N)]

    def find(x):
        if par[x] == x:
            return x
        else:
            par[x] = find(par[x])
            size[x] = size[par[x]]
            return par[x]

    def same(x, y):
        return find(x) == find(y)

    def union(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return
        if size[x] < size[y]:
            x, y = y, x
        size[x] += size[y]
        par[y] = x

    def get_size(x):
        return size[find(x)]

    for _ in range(M):
        a, b = (int(i)-1 for i in input().split())
        union(a, b)

    ans = max(get_size(i) for i in range(N))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 94088
#include <bits/stdc++.h>
using namespace std;
#define INF 0X3f3f3f3f
#define M 1000000007
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define mp make_pair
#define pb push_back 
#define fi first
#define se second
#define endl "\n"
#define PI acos(-1)
#define fastcin ios_base::sync_with_stdio(false)
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> ii;
typedef complex<double> base;

string s;
int cnt[10];

int main(void){
	cin >> s;

	bool ans = 0;
	for(int i = 0; i <= 1; i++){
		bool ok = 1;
		for(int j = i; j < i+2; j++){
			if(s[j] != s[j+1]) ok = 0;
		}
		if(ok) ans = 1;
	}

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

const int INF = 1<<30;

int main(void){
    int n, m;
    string s;
    cin >> n >> m >> s;
    vector<int> dp(n+1,INF);
    dp[n] = 0;
    queue<int> q;
    q.push(0);
    
    for(int i = n-1; i >= 0; --i) {
        while (1) {
            if (q.size() == 0) {
                puts("-1");
                return 0;
            }
            if (q.front() != INF && q.size() <= m) break;
            q.pop();
        }
        if (s[i] == '0') dp[i] = q.front()+1;
        q.push(dp[i]);
    }
    
    vector<int> ans;
    int x = 0;
    int rest = dp[0];
    
    while (x < n) {
        --rest;
        int i = 1;
        while (dp[x+i] != rest) ++i;
        ans.push_back(i);
        x += i;
    }
    
    for (int i=0; i<ans.size(); ++i) {
        printf("%d%c", ans[i], i==int(ans.size())-1?'\n':' ');
    }
    
    //cout << ans << endl;
    return 0;

}


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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		a.at(i) -= i;
	}
	map<int, int>st;
	st[0 - a.at(0)] = 1;
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		if (st.count(a.at(i)))ans += st.at(a.at(i));
		int x = 0 - (a.at(i)+i)-i;
		if (st.count(x))st.at(x)++;
		else st[x] = 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 13044
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
 
int main()
{
    int n,T;cin >> n >> T;

    long long int pre;cin >> pre;
    long long int sum = T;
    for(int i=0;i<n-1;i++){
        long long int now;cin >> now;
        if(pre+T<=now) sum += T;
        else sum += T - (pre+T-now);
        pre = now;
    }
    p(sum)
}

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

int main() {
	int A, B;
	cin >> A >> B;
	for (int i = 0; i <= 2000; i++) {
		if ((int)floor(i * 0.08) == A && (int)floor(i * 0.1) == B) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;

void rec(const Graph &G, int v ,int p, long long sum, vector<long long> &dist) {
    dist[v] = sum;
    for (auto e: G[v]) {
        if (e.first == p) continue;
        rec(G, e.first, v, sum+e.second, dist);
    }
}

int main() {
    int N; cin >> N;
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        int a, b; long long c; cin >> a >> b >> c;
        --a, --b;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    int Q, K; cin >> Q >> K; --K;
    vector<long long> dist(N, 0);
    rec(G, K, -1, 0, dist);

    for (int q = 0; q < Q; ++q) {
        int x, y; cin >> x >> y; --x, --y;
        cout << dist[x] + dist[y] << endl;
    }
}

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

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = A; i < B+1; i++) {
		int tmp = i, j = 0;
		while (tmp > 0) {
			j = j * 10 + tmp % 10;
			tmp /= 10;
		}

		if (i == j) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def number(B, i, j):
    bob = 0
    if i-1 != -1:
        for k in range(max(0,j-1),min(W-1,j+1)+1):
            if B[i-1][k] == '#':
                bob += 1
    if j-1 != -1:
        if B[i][j-1] == '#':
            bob += 1
    if j+1 != W:
        if B[i][j+1] == '#':
            bob += 1
    if i+1 != H:
        for k in range(max(0,j-1),min(W-1,j+1)+1):
            if B[i+1][k] == '#':
                bob += 1
    return bob

H, W = map( int, input().split())
B = [input() for _ in range(H)]
S = ['' for _ in range(H)]
for i in range(H):
    for j in range(W):
        if B[i][j] == '#':
            S[i] += '#'
        else:
            S[i] += str(number(B,i,j))
for i in range(H):
    print(S[i])

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {

        int a, b, ans;

        char op;

        

        while(1) {

            scanf("%d %c %d", &a, &op, &b);

            //足し算

            if(op == '+') {

                ans = a + b;

                printf("%d\n", ans);

            }

            //引き算

            else if(op == '-') {

                ans = a - b;

                printf("%d\n", ans);

            }

            //掛け算

            else if(op == '*') {

                ans = a * b;

                printf("%d\n", ans);

            }

            //割り算

            else if(op == '/') {

                ans = a / b;

                printf("%d\n", ans);

            }

            //opが"?"の時に処理を終了する

            else {

                break;

            }

        }

        return 0;

}


Measured memory_bytes: 2064
N = int(input()) + 1
D = list(map(int, input().split())) + [0] + [24]
D.sort()
for i in range(1, N, 2):
    D[i] = 24 - D[i]
D.sort()
ans = 24
for i in range(N):
    ans = min(ans, abs(D[i+1]-D[i]))
print(ans)


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

long double dp[3000][3000];

int main(){
    int n;
    cin >> n;
    long double p[n];
    for(int i = 0;i < n;i++)cin >> p[i];
    
    dp[0][0] = 1;
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= n;j++){
            if(j > 0)dp[i+1][j] = dp[i][j] * (1 - p[i]) + dp[i][j-1] * p[i];
            else dp[i+1][j] = dp[i][j] * (1 - p[i]);
        }
    }
    
    long double ans = 0;
    for(int i = (n + 1) / 2;i <= n;i++){
        ans += dp[n][i];
    }
    cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 144428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int k = scan.nextInt();
		String s = scan.next();

		if (k < s.length()) {
			s =  s.substring(0 , k) + "...";
			System.out.println(s);
		}
		else {
			System.out.println(s);
		}

		scan.close();

	}

}


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

int main()
{
    int n,flag=0,num,i;
    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>num ;
        if(i != num )
            flag++;
    }
    if(flag==0 || flag ==2)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;



return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
using mint = modint998244353;

typedef pair<mint, int> S;
typedef pair<mint, mint> F;
S op(S l, S r) { return {l.first + r.first, l.second + r.second}; }
S e() { return {0, 0}; }
S mapping(F l, S r) { return {r.first * l.first + r.second * l.second, r.second}; }
F composition(F l, F r) { return {r.first * l.first, r.second * l.first + l.second}; }
F id() { return {1, 0}; }

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<S> a(N);
	for (int i = 0; i < N; ++ i) {
		int x;
		cin >> x;
		a[i] = {x, 1};
	}
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
	for (int i = 0; i < Q; ++ i) {
		int t, l, r;
		cin >> t >> l >> r;
		if (t == 0) {
			int b, c;
			cin >> b >> c;
			seg.apply(l, r, {b, c});
		} else {
			cout << seg.prod(l, r).first.val() << endl;
		}
	}
}


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

int n, m;
vector<vector<int>> A;

void gene_a(vector<int> arr, int idx, int c){
    if(idx == n) {
        A.push_back(arr);
        return;
    }
    for(int i = c; i <= m; ++i){
        arr[idx] = i;
        gene_a(arr, idx+1, i);
    }
}

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

    int q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];
        --b[i];
    }

    vector<int> arr(n, 0);
    gene_a(arr, 0, 1);

    int res = 0;
    rep(i, A.size()){
        vector<int> A_cand = A[i];
        int sum = 0;
        rep(j, q){
            if(A_cand[b[j]] - A_cand[a[j]] == c[j]) sum += d[j];
        }

        res = max(res, sum);
    }

    cout << res << endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  int da = abs(a - x);
  int db = abs(b - x);
  string ans = da < db ? "A" : "B";
  cout<< ans << endl;
  return 0;
}


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

signed main(){
  lint a, b, x; cin >> a >> b >> x;
  lint ans;
  if(a != 0){
    ans = b/x - (a - 1)/x;
  }
  if(a == 0) ans = b/x + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <stdbool.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <chrono>
using namespace std;

int main(){
    #if 0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    #endif

    string S;
    cin >> S;

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    }
    else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    }
    else if (S == "Rainy") {
        cout << "Sunny" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define mod 1000000007

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};


int main(){

  string s;
  int i,j,k,l,n,m;
  vector<string> vs;
  vector<int> vi;
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq;

  cin >> n;
  int b[n-1];
  rep(i,0,n-2)cin >> b[i];
  
  long long ans = b[0];
  rep(i,1,n-2){
  ans += min(b[i-1],b[i]);
  }
  ans += b[n-2];
  
  cout << ans << endl;
//  printf("%.10f\n",ans);

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);

    vector<ll> d(N);
    ll sum = 0;
    for(int i = N-1; i >= 0; --i){
        sum += A.at(i);
        d.at(i) = sum;
    }

    ll ans = 0;
    rep(i, N-1){
        ll D = d.at(i+1)%mod;
        ans += (A.at(i)*D)%mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6428
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

class range {
  class Index {
    int x;
  public:
    Index(int x) : x(x) {}
    int operator*() const { return x; }
    bool operator!=(Index &r) { return x < r.x; }
    void operator++() { ++x; }
  };
  Index i, n;
public:
  range(int n) : i(0), n(n) {}
  range(int i, int n) : i(i), n(n) {}
  Index &begin() { return i; }
  Index &end() { return n; }
};

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha;
  cout.imbue(loc);

  int n;
  cin >> n;
  cout << n * (n + 1) / 2 << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int ans = 0;

    rep(i, n) {
        int a;
        cin >> a;
        ans += a;
    }
    ans -= n;
    cout << ans << endl;
    return 0;
}



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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    vector<int> a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    int ans = b[0];
    REP(i, 1, n) {
        ans += b[i];
        if(a[i] == a[i-1]+1) ans += c[a[i-1]-1];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
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 main() {
  long long N;
  cin >> N;
  long long A[N];
  REP(i, N) cin >> A[i];
  bool flag = false;
  REP(i, N) if(A[i] > i) flag = true;
  if(flag) cout << -1 << endl;
  else {
    // int cursol = N-1;
    long long target = A[N-1];
    long long ans = A[N-1];
    // while (cursol >= 0) {
    //   if (A[cursol] == target) {
    //     cursol--;
    //   }
    //   else {
    //     cursol--;
    //     target = A[cursol];
    //     ans++;
    //   }
    //   target--;
    // }
    for(int cursol = N-1; cursol >= 0; cursol--) {
      // cout << A[cursol] << ' ' << target << endl;
      if (A[cursol] == target) {}
      else if (A[cursol] < target) {
        cout << -1 << endl;
        return 0;
      }
      else {
        target = A[cursol];
        ans += target;
      }
      target--;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
L,R = map(int,input().split())
L_2019 = L%2019
R_2019 = R%2019
ans1 = (L_2019*R_2019)%2019
if R_2019 < L_2019 :
    print(0)
elif (R - L)//2019 > 0:
    print(0)
else:
    for i in range(L_2019,R_2019):
        for j in range(i+1,R_2019+1):
            ans2 = (i*j)%2019
            ans1 = min(ans1,ans2)
    print(ans1)


Measured memory_bytes: 3060
S = input()

for i in range(len(S)-1):
    if S[i] == S[i+1]:
        print(i+1, i+2)
        break
    elif i < len(S)-2:
        if S[i] == S[i+2]:
            print(i+1, i+3)
            break
else:
    print(-1, -1)

Measured memory_bytes: 9168
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            int count1 = n == 0 ? 0 : (n - 1) * n / 2;
            int count2 = m == 0 ? 0 : (m - 1) * m / 2;
            out.println(count1 + count2);
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 21204
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i == 0 or i == H-1:
            print("#"*W)
        else:
            print("#" + "."*(W-2) +"#")
    print()


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <string>

bool possible(const std::vector<std::string>& ss, const int h, const int w)
{
	const std::vector<int> dx = {1, 0, -1,  0};
	const std::vector<int> dy = {0, 1,  0, -1};

	for (int iRow = 0; iRow < h; ++iRow) {
		for (int jCol = 0; jCol < w; ++jCol) {
			if (ss[iRow][jCol] == '.') continue;
			bool found = false;
			for (int i = 0; i < 4; ++i) {
				const int currx = iRow + dx[i];
				const int curry = jCol + dy[i];
				if (currx < 0 || currx >= h) continue;
				if (curry < 0 || curry >= w) continue;
				if (ss[currx][curry] == '#') {
					found = true;
					break;
				}
			}
			if (found == false) return false;
		}
	}
	return true;
}

int main()
{
	int h, w;
	std::cin >> h >> w;
	std::vector<std::string> ss(h);
	for (int i = 0; i < h; ++i) {
		std::cin >> ss[i];
	}

	const bool isPossible = possible(ss, h, w);

	std::cout << (isPossible ? "Yes" : "No") << "\n";

	return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
top = ty - sy
right = tx - sx
first = []

for _ in range(top):
    first.append('U')
for _ in range(right):
    first.append('R')


second = []
for char in first:
    if char == 'R':
        second.append('L')
    elif char == 'U':
        second.append('D')


third = ['L']
for _ in range(top + 1):
    third.append('U')
for _ in range(right + 1):
    third.append('R')
third.append('D')

forth = []
for char in third:
    if char == 'R':
        forth.append('L')
    elif char == 'U':
        forth.append('D')
    elif char == 'L':
        forth.append('R')
forth.append('U')
# print(first)
# print(second)
# print(third)
# print(forth)


print(''.join(first) + ''.join(second) + ''.join(third) + ''.join(forth))


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  int cnt=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==0){
      b[cnt]=a[i];
      cnt++;
    }
  }
  bool can=true;
  for(int i=0;i<cnt;i++){
    if(b[i]%3 > 0 && b[i]%5 > 0){
      can=false;
      break;
    }
  }
  if(!can) cout << "DENIED" << endl;
  else cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
//shahil_005
//Some basic pre-written functions might have been copied from www.geeksforgeeks.org or cp-algorithms.com//

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 1e5 + 5;
//const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

int32_t main()
{
    string s;
    cin >> s;
    int n = s.size();
    int flag =0;
    for(int i=0;i<=n-1;i+=2)
    {
        if(s[i] == 'h' && s[i+1] == 'i')
        {
            continue;
        }
        else
        {
            flag =1;
        }
    }
    if(flag == 1)
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }

    return 0;
}



Measured memory_bytes: 256
fun main() {
    val (n, d) = readLine()!!.split(" ").map { it.toDouble() }
    var count = 0
    for (i in 1..n.toInt()) {
        val (x, y) = readLine()!!.split(" ").map { it.toDouble() }
        if ((x * x + y * y) <= d * d) {
            count++
        }
    }
    println(count)
}

Measured memory_bytes: 59940
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int k = rint();
        string[] read = stra();
        for(int i=0;i<k;i++){
            Write(read[0][i]);
            Write(read[1][i]);
        }
        WriteLine();
        
        
        
        
        
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    // A/B小数点以下切上
    static int divideup(int divided,int divid){
        int temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static int gcd(int big,int small){
        if(big < small){
            int temp = big;
            big = small;
            small = temp;
        }
        if(big % small == 0){
            return small;
        }else{
            big %= small;
            return gcd(small,big);
        }
    }
    static int lcm(int big,int small){
        long temp = big * small;
        int gcds = gcd(big,small);
        temp /= gcds;
        return (int)temp;
    }
}


Measured memory_bytes: 11092
package main
import "fmt"
func main(){
    // Your code here!
    var a,b,k int
    fmt.Scan(&a, &b, &k)
    
    x := min(a,k)
    a -= x
    k -= x
    
    x = min(b,k)
    b -= x
    
    fmt.Println(a,b)
}

func min(a,b int) int {
    if a > b {
        return b
    }
    return a
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define inf 1e18+9
using namespace std;
string st;
int dp[1000009][10];
int solve(int p,int c){
	if(dp[p][c]!=-1)
		return dp[p][c];
	if(p==st.size())return dp[p][c]=c;
	int x=st[p]-'0';
	x+=c;
	int c1=x/10;
	x=x%10;
	if(x<5)
		return dp[p][c]=solve(p+1,c1)+x;
	else if(x>5)
		return dp[p][c]=solve(p+1,c1+1)+(10-x);
	else
		return dp[p][c]=min(solve(p+1,c1),solve(p+1,c1+1))+5;
}
int32_t main(){
	if(fopen("input.txt", "r"))
		freopen("input.txt", "r", stdin),
		freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	cin >> st;
	reverse(st.begin(),st.end());
	memset(dp,-1,sizeof dp);
	cout << solve(0,0) ;
}

Measured memory_bytes: 126364
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 絶対値を求める
UInt Abs(const Int a) {
    return a > 0 ? a : -a;
}

Int Func(Int n, vector<Int>& p, vector<Int>& q) {
    vector<Int> v(n);
    for (Int i = 0; i < n; ++i) {
        v[i] = i;
    }
    // ループ前処理
    Int array_size = (Int)v.size();
    Int pPermuPosi = -1;
    Int qPermuPosi = -1;
    Int cnt = 0;
    do {
        bool isSameAsP = true;
        bool isSameAsQ = true;
        for (Int i = 0; i < array_size; ++i) {
            if (v[i] != p[i]) {
                isSameAsP = false;
            }
            if (v[i] != q[i]) {
                isSameAsQ = false;
            }
        }
        if (isSameAsP == true) {
            pPermuPosi = cnt;
        }
        if (isSameAsQ == true) {
            qPermuPosi = cnt;
        }
        ++cnt;
        // 階乗の各場合に行う処理
    } while (std::next_permutation(v.begin(), v.end()));
    // ループ後処理
    return Abs(pPermuPosi - qPermuPosi);
}

template <typename RetType, typename LoopFunc>
RetType PermutationLoop(Int n, LoopFunc loopFunc);

int main(void) {
    // 入出力処理
    Int n; // ループする回数 n! を決めるパラメータ
    cin >> n;
    vector<Int> p(n);
    vector<Int> q(n);
    for (Int i = 0; i < n; ++i) {
        cin >> p[i];
        --p[i];
    }
    for (Int i = 0; i < n; ++i) {
        cin >> q[i];
        --q[i];
    }
    cout << Func(n, p, q) << endl; 
    return 0;
}


Measured memory_bytes: 3532
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    A,B,C,D = mis()
    while True:
        C -= B
        if C<=0:
            print('Yes')
            break
        A -= D
        if A<=0:
            print('No')
            break




main()



Measured memory_bytes: 9924
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main(void)
{
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    for (int i = 0; i < N; i++)
    {
        cin >> m[i];
    }
    int s = accumulate(m.begin(), m.end(), 0);
    X -= s;
    int mini = *min_element(m.begin(), m.end());

    cout
        << N + int(X / mini) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
    long mod = 1000000007;
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long answer = 1;
    long[] colorCount = new long[3];

    for(int i = 0; i < n; i++)
    {
      int decided = 0;//入りうる色の個数

      for(int j = 0; j < 3; j++)
      {
        if(colorCount[j] == nums[i])
        {
          if(decided == 0) colorCount[j]++;
          decided++;
        }
      }

      answer *= decided;
      answer %= mod;
    }

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 19168
#include<iostream>
#include<cmath>
using namespace std;
int cnt=0;
void insertionSort(int A[],int n,int g){
    for(int i=g;i<n;i++){
        int v=A[i];
        int j=i-g;
        while(j>=0 && A[j]>v){
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}


int main(){
    int n;cin>>n;int A[n];for(int i=0;i<n;i++){cin>>A[i];}
    int m_=n;int G_[m_];G_[0]=n-1;int triger=1;//仮のG
    for(int j=1;j<m_;j++){
        int x=G_[j-1]/2;
        if(x==0){triger=j;break;}
        G_[j]=x;
    }
    int m=triger,G[m]={};//本物
    for(int i=0;i<m;i++){G[i]=G_[i];}G[m-1]=1;
    for(int i=0;i<m;i++){
        insertionSort(A,n,G[i]);
    }
    cout<<m<<endl;
    for(int j=0;j<m;j++){if(j!=0)cout<<' ';cout<<G[j];}cout<<endl;
    cout<<cnt<<endl;
    for(int i=0;i<n;i++){
        cout<<A[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 6996
// start fold
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
using namespace std;
#define ri register int
#define il inline
#define LL long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define enter putchar('\n')
#define size(x) ((int)x.size())
#define mem0(x) memset(x,0,sizeof(x))
template<class T>il void in(T &x)
{
	x=0; short f=1; char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
	x*=f;
}
template <typename T,typename ...Args>il void in(T &x, Args &...args)
{
	in(x); in(args...);
}
template<class T>il void out(T x,const char c='\n')
{
	static short st[30];
	short m=0;
	if(x<0) putchar('-'),x=-x;
	do st[++m]=x%10,x/=10; while(x);
	while(m) putchar(st[m--]|'0');
	putchar(c);
}
template <typename T,typename ...Args>il void out(const T &x,const Args &...args)
{
	out(x,' '); out(args...);
}
template<class T>il void print(T a[],int n)
{
	if(n<=0) return;
	for(ri i=0; i<n; ++i) out(a[i],' ');
	enter;
}
namespace i207M
{
// end fold
multiset<string>s;
signed main()
{
#ifdef M207
	freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
#endif
    int a,b,c;
	in(a,b,c);
	for(ri i=1; i<=a; ++i) s.insert("a");
	for(ri i=1; i<=b; ++i) s.insert("b");
	for(ri i=1; i<=c; ++i) s.insert("c");
	while(size(s)>1)
	{
		string t=*s.begin()+*s.rbegin();
		s.erase(s.begin()),s.erase(--s.end());
		s.insert(t);
	}
	cout<<*s.begin();
	return 0;
}
// start fold
}
signed main()
{
	i207M::main();
	return 0;
}
// end fold

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a != b && a == c && b != c) || (a == b && a != c && b != c) || (a != b && a != c && b == c)){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	int n , w;
	cin >> n >> w;
	
	vector<pii> v(n);
	for(auto& el : v)
		cin >> el.fi >> el.se;
		
	vector<vi> dp(n , vi(1010 * n , INF));
	rep(i , n)
	{
		dp[i][v[i].se] = min(dp[i][v[i].se] , v[i].fi);
		rep(j , 1010 * n)
		{
			if(i > 0)
				dp[i][j] = min(dp[i][j] , dp[i - 1][j]);
			if(i > 0 && j - v[i].se >= 0)
				dp[i][j] = min(dp[i][j] , dp[i - 1][j - v[i].se] + v[i].fi);
			if(dp[i][j] > w)
				dp[i][j] = INF;
		}
	}
	
	
	repn(j , 1010 * n)
	{
		rep(i , n)
		{
			if(dp[i][j] != INF)
			{
			//	cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
				dier(j);
			}
		}
	}
	
	/*
	rep(i , n)
	{
		rep(j , 18)
			cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
		cout << nl;
	}
	*/

	

	return 0;
}

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

int main(){
  int K, A, B;
  bool flag = false;
  cin >> K >> A >> B;
  repi(i, A, B+1){
    if (i % K == 0){
      flag = true;
      break;
    }
  }
  if (flag == true) cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3596
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
using namespace std;
typedef long long ll;

int main(void){
    string S;
    cin>>S;
    int size=sizeof(S);
    bool ans =true;
    if (S[0]==S[1]) ans=false;
    if (S[1]==S[2]) ans=false;
    if (S[2]==S[3]) ans=false;
    
    if (ans){
        cout<<"Good"<<endl;
    }
    else{
        cout<<"Bad"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256