akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    long long N;
    cin >> N;
    vector<int> A;
    A.resize(N);
    long long sum = 0;
    for (long long i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    long long Q;
    cin >> Q;
    vector<long long> B, C;
    B.resize(Q);
    C.resize(Q);
    for (long long i = 0; i < Q; i++)
    {
        cin >> B[i] >> C[i];
    }
    
    vector<long long> cnt;
    cnt.resize(100010);
    fill(cnt.begin(), cnt.end(), 0);
    for (long long n : A)
    {
        cnt[n]++;
    }

    for (long long i = 0; i < Q; i++)
    {
        sum = sum + (C[i] - B[i]) * cnt[B[i]];
        cnt[C[i]] += cnt[B[i]];
        cnt[B[i]] = 0;
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5804
s = input()
N = int(input())

for i in range(N):
    cmd = list(map(str, input().split()))
    if cmd[0] == 'replace':
        a, b, c = int(cmd[1]), int(cmd[2]), cmd[3]
        if a == 0:
            s = cmd[3] + s[b+1:]
        else:
            s = s[0:a] + cmd[3] + s[b+1:]
    elif cmd[0] == 'reverse':
        a, b = int(cmd[1]), int(cmd[2])
        ss = s[a:b+1]
        ss = list(reversed(ss))
        ss = ''.join(ss)
        if a == 0:
            s = ss + s[b+1:]
        else:
            s = s[0:a] + ss + s[b+1:]
    elif cmd[0] == 'print':
        a, b = int(cmd[1]), int(cmd[2])
        print(s[a:b+1])


Measured memory_bytes: 5628
while True:
    height, width = [int(x) for x in input().split(" ")]
    if height == width == 0:
        break

    a, b = "#", "."
    for h in range(height):
        for w in range(width):
            if w % 2 == 0: print(a,end="")
            else: print(b, end="")
        print("\n",end="")
        a, b = b, a


    print("\n", end="")

Measured memory_bytes: 8992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    ll A;
    cin >> A;
    A--;
    a[i] = A;
  }
  vector<bool> f(n, 1);
  vector<ll> C(2 * n, 0);
  vector<ll> kai(2 * n, 0);
  ll j = 0;
  ll c = 0;
  while(f[j]) {
    f[j] = 0;
    kai[c] = j;
    C[j] = c;
    j = a[j];
    c++;
    if (!f[j]) break;
  }
  if (k < c) cout << kai[k] + 1 <<endl;
  else {
    ll m = k - C[j];
    ll p = c - C[j];
    m = m % p;
    m = m + C[j];
    cout << kai[m] + 1<<endl;
  }
}

Measured memory_bytes: 11180
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mod ((int)1e9+7)
#define MAXN 200010
using namespace std;
typedef long long ll;
int n;
ll mod_pow(ll a,ll x){
    ll ret=1;
    while(x){
        if(x&1) ret=ret*a%mod;
        x>>=1;
        a=a*a%mod;
    }
    return ret;
}
ll fac[200010],inv[200010];
void pre(){
    fac[1]=1; fac[0]=1;
    for(int i=2;i<=n;i++){ 
        fac[i]=i*fac[i-1]%mod;
       // cout<<fac[i]<<endl;
    }
    inv[n]=mod_pow(fac[n],mod-2);
    for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int N,int M){
    return fac[N]*inv[M]%mod*inv[N-M]%mod; 
}
int head[MAXN],cnt;
struct Edg{
    int to,nxt;
}e[MAXN<<1];
void add_e(int u,int v){
    e[++cnt].to=v;
    e[cnt].nxt=head[u];
    head[u]=cnt;
}
ll f[MAXN];
int sz[MAXN];
void getsize(int u,int fa){
    sz[u]=1;
    if(head[u]==-1) return;
    for(int i=head[u];i!=-1;i=e[i].nxt){
        if(e[i].to==fa) continue;
        getsize(e[i].to,u);
        sz[u]+=sz[e[i].to];
    }
}
void dfs(int u,int fa){
    f[u]=1;
    if(head[u]==-1) return;
    int son_sz=sz[u]-1,son;
    for(int i=head[u];i!=-1;i=e[i].nxt){
        son=e[i].to;
        if(son==fa) continue;
        dfs(son,u);
        f[u]=f[u]*f[son]%mod*C(son_sz,sz[son])%mod;
        son_sz-=sz[son];
    }
}
void pushdown(int x,int fa){
    if(fa){
        //cout<<"x= "<<x<<" "<<endl;
        //cout<<"C:"<<C(n-1,sz[x])<<" "<<f[x]<<endl;
        //cout<<"adfa ="<<mod_pow(C(n-1,sz[x])*f[x]%mod,mod-2)<<endl;
            f[x]=f[x]*f[fa]%mod*mod_pow(C(n-1,sz[x])*f[x]%mod,mod-2)%mod*C(n-1,n-sz[x])%mod;
        }
    if(head[x]==-1) return;
    int son;
    for(int i=head[x];i!=-1;i=e[i].nxt){
        son=e[i].to; if(son==fa) continue;
        pushdown(son,x);
    }
}
int main(){
    //freopen("data.in","r",stdin);
    //freopen("my.out","w",stdout);
    scanf("%d",&n);
    pre();
    memset(head,-1,sizeof(head));
    int u,v;
    for(int i=1;i<n;i++){
        scanf("%d %d",&u,&v);
        add_e(u,v);
        add_e(v,u);
    }
    getsize(1,0);
    dfs(1,0);
    //for(int i=1;i<=n;i++){
    //    cout<<"i= "<<i<<" "<<f[i]<<" "<<sz[i]<<endl;
   // }
    pushdown(1,0);
    for(int i=1;i<=n;i++){
        printf("%lld\n",f[i]);
    }
}

Measured memory_bytes: 13260
#115 C

N,K= map(int,input().split())
trees =[]

for _ in range(N):
    trees.append(int(input()))
trees.sort()
ans=10**10
for i in range(N-K+1):
    min_=trees[i]
    max_=trees[i+K-1]
    ans=min(ans,max_-min_)
print(ans)

Measured memory_bytes: 7384
import math
N =int(input())
min = math.inf
max_diff = -math.inf
for i in range(N):
    num = int(input())
    if min == math.inf:
        min = num
        continue
    if num - min > max_diff:
        max_diff = num - min
    if min > num:
        min = num
print(max_diff)


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

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();

    System.out.println(s.replaceFirst("2017/01/", "2018/01/"));
  }

}


Measured memory_bytes: 20052
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int res = 0;
        var curEnd = -1;
        foreach (var item in Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderBy(x => x[1]))
        {
            var start = item[0];
            var end = item[1];
            if (start <= curEnd) continue;
            res++;
            curEnd = end;
        }
        Console.WriteLine(res);
    }
}



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

using namespace std;
typedef long long ll;
typedef double ld;

ll n;
ll a[10010];

int main(void)
{
	scanf("%lld", &n);
	
	for(ll i = 2 ; i * i <= 2 * n ; i++)
	{
		for(ll j = 2 ; j * j <= 2 * n ; j++)
		{
			if(i * i + j * j > 2 * n)
				break;
			
			for(ll k = 2 ; k * k <= 2 * n ; k++)
			{
				if(i * i + j * j + k * k > 2 * n)
					break;
				
				ll gap = i + j + k;
				
				if(gap % 2 == 0)
				{
					gap /= 2;
					
					ll x = gap - j;
					ll y = gap - k;
					ll z = gap - i;
					
					if(x < 1 || y < 1 || z < 1)
						continue;
					
					a[(i * i + j * j + k * k) / 2]++;
				}
			}
		}
	}
	
	for(ll i = 1 ; i <= n ; i++)
		printf("%lld\n", a[i]);
	
	return 0;
}

Measured memory_bytes: 3896
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

int main() {
    int n=read();
    if (__builtin_popcount(n)==1) { puts("No"); return 0; }
    puts("Yes");
    printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n",1+n,1+n,2+n,2+n,3+n);
    for (int i=4;i+1<=n;i+=2)
        printf("1 %d\n1 %d\n%d %d\n%d %d\n",i,i+1,i,i+1+n,i+1,i+n);
    if ((n&1)==0) {
        for (int i=2;i<n;++i) {
            if (i==3) continue;
            int j=n^i^1;
            if (j!=3&&j<n) { printf("%d %d\n%d %d\n",i,n,j,n+n); break; }
        }
    }
    return 0;
}

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

const int maxN = 305, mod = 998244353;

int n, m;
int f[2][maxN + 1][maxN + 1];
int a[maxN + 1], cnt;
char s[maxN + 1];

inline void update(int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; }

int main()
{
	scanf("%s %d", s + 1, &m);
	n = strlen(s + 1); m = min(m, n);

	int l = 1;
	while(l <= n)
	{
		int r = l;
		while(r <= n && s[r] == '1') r ++;
		a[++ cnt] = r - l;
		l = r + 1;
	}

	int now = 0;
	f[now][0][0] = 1;
	for(int i = cnt; i >= 1; i--)
	{
		now ^= 1;
		memset(f[now], 0, sizeof(f[now]));
		for(int j = 0; j <= m; j++)
			for(int k = 0; k <= j; k++)
			{
				if(!f[now ^ 1][j][k]) continue;
				int res = f[now ^ 1][j][k];
				for(int t = 0; t <= a[i]; t++) update(f[now][j + t][k + t], res);
				for(int t = 1; t <= k; t++) update(f[now][j][k - t], res);
			}
	}

	int ans = 0;
	for(int i = 0; i <= m; i++) update(ans, f[now][i][0]);
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4504
#include <stdio.h>

int main()
{
	int i, N, A[201], K[201];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(A[i]), &(K[i]));
	
	int j, g;
	for (i = 1, g = 0; i <= N; i++) {
		if (K[i] == 1) g ^= A[i];
		else {
			for (j = A[i]; j >= K[i] && j % K[i] != 0; j -= (j % K[i]) / (j / K[i] + 1) * (j / K[i] + 1)) j -= j / K[i] + 1;
			if (j % K[i] == 0) g ^= j / K[i];
		}
	}
	
	if (g == 0) printf("Aoki\n");
	else printf("Takahashi\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1660
#include <iostream>

using namespace std;

int N;
int h[100000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> h[i];
    int max = 0;
    int m = 0;
    for(int i=1;i<N;i++){
        if(h[i] <= h[i-1]) m++;
        else m = 0;
        if(m > max) max = m;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<int> A(N+1,0);
    for(int i=0; i<M; i++){
        int a;
        cin >> a;
        A[a] = 1;
    }
    vector<ll> dp(N+1,0);
    dp[0] = 1;
    for(int i=0; i<N; i++){
        if(i+1<=N and A[i+1]==0){
            dp[i+1] += dp[i];
            dp[i+1] %= mod;
        }
        if(i+2<=N and A[i+2]==0){
            dp[i+2] += dp[i];
            dp[i+2] %= mod;
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1408
/*
@author: @sancodemonster
*/
 
#include <bits/stdc++.h>
 
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define ll long long int
#define ld long double
#define pb push_back 
#define mp make_pair
#define inf 1e17
#define MOD 1000000007
#define f(i,a,b)  for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end() 
using namespace std;

ll n;
ll h[100005];
ll dp[100005]  = {0};

ll rec(ll i,ll n)
{     
	if(i == n)
		return 0;
	if(i>n)
		return inf;

	if(dp[i]!=-1)
           return dp[i];
        
        ll one = INT_MAX;
        ll two = INT_MAX;
        if(i<=n-1)
          one = rec(i+1,n) + abs(h[i+1] - h[i]);
	//ll one = rec(i+1,n,cost+ abs(h[i+1] - h[i]));

        if(i<=n-2)
         two = rec(i+2,n) + abs(h[i+2]- h[i]);
	//ll two = rec(i+2,n,cost+ abs(h[i+2] - h[i]));

        
        dp[i] = min(one,two);

        return dp[i];

}
int main()
{	
 /* #ifndef ONLINE_JUDGE
    freopen("C:\\desktopp\\new coding problems\\in.txt" , "r" , stdin);
    freopen("C:\\desktopp\\new coding problems\\out.txt" , "w" , stdout);
  #endif*/

     flash;
     /////////////////////////////////////////////////////////////////////////////////////////////////////
       ll i,j,k;

       cin>>n;
        f(i,1,n+1)
        {
           cin>>h[i];
        }
        
        f(i,0,1e5)
         dp[i] = -1;
        //if(n>2)
        ll ans = rec(1,n);
        cout<<ans;
     /////////////////////////////////////////////////////////////////////////////////////////////////////

     return 0;
}


Measured memory_bytes: 6528
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    max_a, max_a2 = sorted(a, reverse=True)[:2]
    print('\n'.join(map(str, [max_a if i != max_a else max_a2 for i in a])))

if __name__ == '__main__':
    main()


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

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

        StringTokenizer st=new StringTokenizer(f.readLine());
        int n = Integer.parseInt (st.nextToken());
        int w = Integer.parseInt (st.nextToken());
        int[]weight=new int[n];
        int[]value=new int[n];
        int sum=0;
        for(int i=0;i<n;i++){
            st = new StringTokenizer (f.readLine());
            weight[i]=Integer.parseInt (st.nextToken());
            value[i]=Integer.parseInt (st.nextToken());
            sum+=value[i];
        }

        long dp[][]=new long[n+1][sum+1];
        for(int i=0;i<dp.length;i++){
            for(int j=0;j<dp[i].length;j++){
                dp[i][j]=Long.MAX_VALUE/2;
            }
        }
        dp[0][0]=0;
        long ans=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<sum+1;j++){
                if(j==30){
                    j=j;
                }
                dp[i+1][j]=Math.min(dp[i+1][j],dp[i][j]);
                if(j-value[i]>=0)
                    dp[i+1][j]=Math.min(dp[i+1][j],(long)dp[i][j-value[i]]+(long)weight[i]);


            }
        }
        for(int i=0;i<sum+1;i++){
            if(dp[n][i]<=w){
                ans=Math.max(ans,i);
            }
        }

//        for(int i=0;i<dp.length;i++){
//            System.out.println();
//            for(int j=0;j<dp[i].length;j++){
//                System.out.print(dp[i][j]+" ");
//            }
//        }

//        System.out.println();

        System.out.println(ans);



        f.close();
    }
}


Measured memory_bytes: 126180
using System;

class ABC_140_D
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);

        string S = Console.ReadLine();

        int change = 0;
        int ans = 0;
        for (int i = 0; i < N-1; i++)
        {
            char c1 = S[i];
            char c2 = S[i+1];
            if (c1 != c2) change++;
            else ans++;
        }

        for (int i = 0; i < K; i++)
        {
            if(change>=2)
            {
                change -= 2;
                ans += 2;
            }
            else if(change==1)
            {
                ans++;
                break;
            }
            else
            {
                break;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13116
from fractions import gcd

mod = 10 ** 9 + 7


def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception("modular inverse does not exist")
    else:
        return x % m


n = int(input())
A = list(map(int, input().split()))
lcm = A[0]
for i in range(n):
    g = gcd(lcm, A[i])
    lcm *= A[i] // g

ans = 0
for i in range(n):
    gyaku = modinv(A[i], mod)
    ans += lcm * gyaku
    ans %= mod
print(ans)


Measured memory_bytes: 6136
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)

int main() {
    ll H1, M1, H2, M2, K;
    cin>>H1>>M1>>H2>>M2>>K;
    ll ans;
    ans = (H2-H1)*60 + M2-M1 -K;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3160
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] N = new int[4];
        N[0] = sc.nextInt();
        N[1] = sc.nextInt();
        N[2] = sc.nextInt();
        N[3] = sc.nextInt();

        boolean ans = solve(N);

        System.out.println(ans ? "YES" : "NO");
    }

    private static boolean solve(int[] N) {
        Arrays.sort(N);

        if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) {
            return true;
        }

        return false;
    }

}


Measured memory_bytes: 23124
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split(' ');

        var b1 = 0;
        var b2 = 0;
        var b4 = 0;

        for (int i = 0; i < n; i++)
        {
            var x = m1(int.Parse(s[i]));
            if (x == 0)
            {
                b1++;
            }
            else if (x == 1)
            {
                b2++;
            }
            else
            {
                b4++;
            }
        }

        if (b2 == 0)
        {
            if (b1 <= b4 + 1)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        else
        {
            if (b1 <= b4)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }

    static int m1(int n)
    {
        var ans = 0;
        while (n % 2 == 0 && ans < 2)
        {
            ans++;
            n /= 2;
        }
        return ans;
    }
}

Measured memory_bytes: 20064
#include<stdio.h>

int main(void){

int x,y;

while(1){
scanf("%d %d",&x,&y);
if(x==0 && y==0)break;
if(x<y){
printf("%d %d\n",x,y);
}
else{
printf("%d %d\n",y,x);
}
}
}



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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct UnionFind
{
  vector<int> data;
  UnionFind(){}
  UnionFind(int sz):data(sz, -1){};
  int size(int x) { return -data[find(x)]; }
  int find(int x) { return data[x] < 0 ? x : data[x] = find(data[x]); }
  bool same(int x, int y) { return find(x) == find(y); }
  int unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] < data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return -data[x];
  }
  void init(int sz) {
    data.clear();
    data.resize(sz, -1);
  }
};

UnionFind uf;

int N, M;
vector<string> lang;
map<string, int> mp;
map<string, int> group;
vector<int> vec;
vector<string> ans;

bool input() {
  cin >> N >> M;
  if(!N && !M) return false;

  lang.clear();
  mp.clear();
  rep(i, N) {
    string l;
    cin >> l;
    lang.push_back(l);
    mp[l] = i;
  }

  vec.clear();
  group.clear();
  rep(i, M) {
    int k; cin >> k;
    int bit = 0;
    rep(j, k) {
      string l; cin >> l;
      bit |= 1<<mp[l];
      group[l] |= 1<<i;
    }
    vec.push_back(bit);
  }

  return true;
}

void solve(int idx, int bit) {
  if(__builtin_popcount(bit) > 5) return;
  if(uf.size(N) == __builtin_popcount(bit)+M) {
    if(ans.empty() || __builtin_popcountll(bit) < ans.size()) {
      ans.clear();
      rep(i, N) if((bit>>i)&1) ans.push_back(lang[i]);
    }
  }

  reps(i, idx, N) {
    if((bit>>i)&1) continue;
    UnionFind tmp = uf;
    rep(j, M) if((vec[j]>>i)&1) uf.unite(i, N+j);
    solve(i+1, bit|(1<<i));
    uf = tmp;
  }
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  bool flag = false;
  while(input()) {
    if(flag) cout << endl;
    flag = true;

    ans.clear();
    uf.init(N+M);
    solve(0, 0);
    if(ans.size()) {
      cout << ans.size() << endl;
      for(string l : ans) cout << l << endl;
    } else {
      cout << "Impossible" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <stdio.h>

int main(){
	while(true){
		char c;
		scanf("%c",&c);
		c+=('A'<=c&&c<='Z'?0x20:('a'<=c&&c<='z'?-0x20:0));
		std::cout<<c;
		if(c=='\n'){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1100
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define REPN(i,a,b) for(ll i = a; i <= b; ++i)
#define REPV(i,a,b) for(ll i = a; i >= b; --i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define with_tests int t; cin>>t; while(t--){ solve(); }
#define without_tests solve();
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 100000000
#define ff first
#define ss second
const int M=1e9+7;
 
void solve()
{
	float d, t, s;
	cin>>d>>t>>s;
	float time = (float)d / s;
	if(time <= t)
	cout<<"Yes";
	else
	cout<<"No";
}
 
int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  //with_tests;
  without_tests;
  return 0;
}

Measured memory_bytes: 3736
#include<stdio.h>
 int main()
 {
 	int a,b,c;
 	scanf("%d",&a);
 	scanf("%d",&b);
 	scanf("%d",&c);
 	if (a!=b&&b!=c&&c!=a)
 	{
 	printf("3");
 }
   else if (a==b&&b==c&&c==a){
   	printf("1");
   }
   else
   {
  printf("2") ;}
   return 0;
 }

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

using namespace std;

#define PI acos(-1)

double rad(double x)
{
    return x*PI/180.0;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double hour_angle = (h/12.0) * 360.0;
    double temp = m / 60;
    hour_angle += (temp/12.0) * 360;
    double min_angle = (m/60.0) * 360.0;
    //cout << hour_angle << " " << min_angle << endl;
    double diff;
    if(hour_angle > min_angle) diff = hour_angle - min_angle;
    else diff = min_angle - hour_angle;
    //cout << diff << endl;
    if(diff == 0){
        cout<<fixed<<setprecision(12)<<abs(a-b)<<'\n';
        return 0;
    }
    else if(diff == 180){
        cout<<fixed<<setprecision(12)<<abs(a+b)<<'\n';
        return 0;
    }
    double C = diff;
    double x = b * sin(rad(C));
    double y = a - b * cos(rad(C));
    double ans = sqrt(x*x+y*y);
    cout<<fixed<<setprecision(12)<<ans<<'\n';
}



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

void solve(){
	int n,k;
	scanf("%d%d",&n,&k);
	int ret = 0;
	for(int i=1;i<=n;i+=2){
		++ret;
	}
	if(ret>=k){
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	solve();
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


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

    stringstream NN;
    NN<<N;
    string ans;
    for(int i=0; i< NN.str().size(); i++){
        if(NN.str()[i]== '1'){
            ans += '9';
        }else if(NN.str()[i]== '9'){
            ans += '1';
        }else{
            ans += NN.str()[i];
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10 , mod = 1e9 + 7;
long long cnt[N] , res[N];
int n , m;
int main(){
	cin >> n >> m;
	for(int i = 1; i <= m; i ++){
		int a;
		scanf("%d" , &a);
		cnt[a] = 1;
	}
	if(!cnt[0])res[0] = 1; 
	if(!cnt[1])res[1] = 1;
	for(int i = 2; i <= n; i ++){
		if(cnt[i]) continue;
		res[i] = (res[i - 1] + res[i - 2]) % mod;
	}
	cout << res[n] << "\n";
}

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

L = []
R = []

for _ in range(K):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)
  
dp = [0]*(N+5)
dp[1] = 1

for i in range(2, N+1):
  dp[i] = dp[i-1]
  for j in range(K):
    if i-L[j] >= 0:
      dp[i] += dp[i-L[j]]
    if i-R[j]-1 >= 0:
      dp[i] -= dp[i-R[j]-1]
    dp[i] %= 998244353
    
print((dp[N]-dp[N-1])%998244353)

Measured memory_bytes: 16848
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            if b not in fct:
                fct.append(b)
        b = b + 1
    if n > 1:
        if n not in fct:
            fct.append(n)
    return fct

inputs = input().split()
a = int(inputs[0])
b = int(inputs[1])

af = factorize(a)
bf = factorize(b)

afbf = set(af) & set(bf)

print(len(afbf)+1)


Measured memory_bytes: 3064
def main():
    n = int(input())
    res = 0.0
    for _ in range(n):
        x, u = input().split()
        if u == "JPY":
            res += int(x)
        else:
            res += float(x) * 380000
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
C=[None for i in range(3)]
for i in range(3):
  C[i]=list(map(int,input().split()))
  
ok=True

diff=[0]*3
for i in range(3):
  diff[i]=C[i][1]-C[i][0]
if len(set(diff))>1:
  ok=False
  
diff=[0]*3
for i in range(3):
  diff[i]=C[i][2]-C[i][1]
if len(set(diff))>1:
  ok=False

diff=[0]*3
for i in range(3):
  diff[i]=C[1][i]-C[0][i]
if len(set(diff))>1:
  ok=False

diff=[0]*3
for i in range(3):
  diff[i]=C[2][i]-C[1][i]
if len(set(diff))>1:
  ok=False

print(("No","Yes")[ok])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int N,D;
    cin >> N >> D;
    cout<<(N+2*D)/(2*D+1)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

struct Edge {
    int u, v, w;
};

const int N = 1e5 + 10, inf = 1e9;
vector<Edge> edges;
vector<pii> g[N];
vector<int> e[N];
int d[N], color[N];
pii go[N];
bool root[N], good[N];
vector<pii> notdone;

void dfs(int v, int col) {
    for (pii e : g[v]) {
        int to = e.F, id = e.S;
        if (color[to]) continue;
        color[to] = col;
        if (color[v] != color[to]) {
            edges[id].w = d[to];
        }
        else {
            edges[id].w = d[to] - d[v];
        }
        dfs(to, col);
    }
}

void dfs2(int v, int col) {
    color[v] = col;
    for (int to : e[v]) {
        if (color[to]) continue;
        dfs2(to, 3 - col);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, m;
    cin >> n >> m;
    for (int i=1; i<=n; i++) {
        cin >> d[i];
        root[i] = 1;
    }
    for (int i=0; i<=m-1; i++) {
        int u, v;
        cin >> u >> v;
        if (d[u] > d[v]) swap(u, v);
        edges.pb({u, v, inf});
    }
    for (int i=0; i<=m-1; i++) {
        int u = edges[i].u, v = edges[i].v;
        if (d[u] < d[v]) {
            g[u].pb({v, i});
            root[v] = 0;
            good[v] = 1;
        }
        else {
            good[u] = good[v] = 1;
        }
    }
    for (int i=1; i<=n; i++) {
        if (!good[i]) {
            cout << "-1\n";
            return 0;
        }
    }
    for (int i=0; i<=m-1; i++) {
        int u = edges[i].u, v = edges[i].v;
        if (d[u] == d[v] && root[u] && root[v]) {
            e[u].pb(v), e[v].pb(u);
            edges[i].w = d[u];
        }
    }
    for (int i=0; i<=m-1; i++) {
        int u = edges[i].u, v = edges[i].v;
        if (d[u] == d[v]) {
            if (root[u] && root[v]) {
                continue;
            }
            else if (root[u]) {
                go[u] = {v, i};
            }
            else if (root[v]) {
                go[v] = {u, i};
            }
        }
    }
    for (int i=1; i<=n; i++) {
        if (root[i] && !color[i] && !e[i].empty()) {
            dfs2(i, 1);
        }
    }
    for (int i=1; i<=n; i++) {
        if (root[i] && color[i]) {
            dfs(i, 3 - color[i]);
        }
    }
    for (int i=1; i<=n; i++) {
        if (root[i] && e[i].empty()) {
            notdone.pb({d[i], i});
        }
    }
    sort(notdone.begin(), notdone.end());
    for (int i=0; i<notdone.size(); i++) {
        int v = notdone[i].S;
        int to = go[v].F, id = go[v].S;
        edges[id].w = d[v];
        color[v] = 3 - color[to];
        dfs(v, 3 - color[v]);
    }
    for (int i=1; i<=n; i++) {
        if (color[i] == 1) cout << "B";
        else cout << "W";
    }
    cout << "\n";
    for (int i=0; i<=m-1; i++) {
        cout << edges[i].w << "\n";
    }

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
   return 0;
}


Measured memory_bytes: 15216
#include <bits/stdc++.h>
  
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
 
using namespace std;
const int INF = 1<<29;
 
int main()
{
    while (1) {
        int n; cin >> n;
        if (!n) break;
        int t[20][20];
        loop (n, i) loop (n+1, j) cin >> t[i][j];
        int cost[20][100000];
        loop (n+1, i) loop (2<<n, j) cost[i][j] = INF;
        loop (n, i) cost[1][1<<i] = t[i][0];
        loop (n+1, i) {
            loop (1<<n, j) {
                if (__builtin_popcount(j) != i) continue;
                loop (n, k) if (j>>k&1) {
                    int c = t[k][0];
                    loop (n, l) if (j>>l&1 && l != k) {
                        c = min(c, t[k][l+1]);
                    }
                    cost[i][j] = min(cost[i][j], cost[i-1][j^(1<<k)] + c);
                }
            }
        }
        cout << cost[n][(1<<n)-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 7932
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, d, x = I[:3]
a = I[3:]

def main():
    return x + np.sum((d + a - 1) // a)

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 12512
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

MOD = 10**9+7

n,m = li()
x = li()
y = li()

x.sort(reverse=True)
y.sort(reverse=True)

x_coeff = [n-(2*i+1) for i in range(n)]
y_coeff = [m-(2*i+1) for i in range(m)]

x_sum = 0
y_sum = 0

for xi, xcoefi in zip(x, x_coeff):
    x_sum += (xi * xcoefi)
    x_sum %= MOD
    
for yi, ycoefi in zip(y, y_coeff):
    y_sum += (yi * ycoefi)
    y_sum %= MOD

ans = x_sum * y_sum
print(ans%MOD)

Measured memory_bytes: 19172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  int H[N];
  REP(i, 0, N)
    cin >> H[i];

  int flag = 0;
  for(int i=N-1; i>=1; i--){
    if ( (H[i] - H[i-1]) < -1 ) {
      flag = 1; // fail
      break;
    }
    else if ( (H[i] - H[i-1]) == -1 ) {
      H[i-1]--;
    }
  }

  if ( flag == 0 )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int i, j, k, l = 0, m = 0, tmp, N, is_same, score = 0, score_max = 0;
  char c1_eig[101], c2_eig[101];
  char s[101];

  scanf("%d", &N);
  scanf("%s", &s);


  for(i = 0; i <= N - 1; i++){
    l = 0;
    m = 0;
    score = 0;

      for(j = 0; j <= i; j++){
        is_same = 0;
        tmp = s[j];
        for(k = 0; k < l; k++){
          if(tmp == c1_eig[k]) is_same = 1;
        }
        if(is_same == 0){
          c1_eig[l] = tmp;
          l++;
        }
      }


      for(j = i + 1; j <= N - 1; j++){
        is_same = 0;
        tmp = s[j];
        for(k = 0; k < m; k++){
          if(tmp == c2_eig[k]) is_same = 1;
        }
        if(is_same == 0){
          c2_eig[m] = tmp;
          m++;
        }
      }

     for(j = 0; j < l; j++){
       for(k = 0; k < m; k++){
         if(c1_eig[j] == c2_eig[k]) score++;
       }
     }

    if(score > score_max) score_max = score;

  }
  printf("%d\n", score_max);


  return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

ll expo(ll a,ll b,ll m){
    if(b<0)return expo(expo(a,m-2,m),-b,m);
    ll res=1;
    while(b>0){
        if(b&1)res=(res*a)%mod;
        a=(a*a)%mod;
        b=b/2;
    }
    return res;
}


int main(){
    ll n,k;cin>>n>>k;

    ll ans=0;
    rep(i,k,n+2){
        ll ways=(((i*n)%mod)-((i*(i-1)) %mod)+1+mod)%mod;
        ans=(ans+ways)%mod;
    }
    cout<<ans;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int a[5][110];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			a[i][j]=max(a[i-1][j],a[i][j-1])+a[i][j];
		}
	}
	cout<<a[2][n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;

void solve()
{
	priority_queue<int> pque;
	char order[10] = "";
	while (true)
	{
		//cin >> order;
		scanf(" %s", order);
		if (order[2] == 'd')
		{
			break;
		}
		else if (order[0] == 'i')
		{
			int num;
			scanf("%d", &num);
			pque.push(num);
		}
		else
		{
			printf("%d\n", pque.top());
			pque.pop();
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

void solve(long long N, long long K, std::vector<long long> V)
{
    // dp[左からi個目の宝石まで取った][右からj個目の宝石まで取った][k個の宝石を戻した] = 所持
    vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(N + 1)));

    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            if (i + j >= K || i + j >= N) {
                continue;
            }
            dp[i + 1][j][0] = dp[i][j][0] + V[i];
            dp[i][j + 1][0] = dp[i][j][0] + V[N - j - 1];
        }
    }
    for (ll i = 0; i <= N; i++) {
        for (ll j = 0; j <= N; j++) {
            if (i + j >= K || i + j >= N) {
                continue;
            }
            vector<ll> jewels;
            copy(begin(V), begin(V) + i, back_inserter(jewels));
            copy(end(V) - j, end(V), back_inserter(jewels));
            sort(begin(jewels), end(jewels));
            for (ll k = 0; k < N && k < jewels.size(); k++) {
                if (i + j + k < K) {
                    dp[i][j][k + 1] = dp[i][j][k] - jewels[k];
                }
            }
        }
    }

    ll ans = 0;
    for (ll i = 0; i <= N; i++) {
        for (ll j = 0; j <= N; j++) {
            for (ll k = 0; k <= N; k++) {
                ans = max(ans, dp[i][j][k]);
            }
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> V(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&V[i]);
    }
    solve(N, K, std::move(V));
    return 0;
}


Measured memory_bytes: 1408
<?php
fscanf(STDIN, "%d %d", $N, $K);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
$ans = [];
for ($i = 0; $i < $N - $K; $i++) {
    $ans[] = $A[$i + $K] > $A[$i] ? "Yes" : "No";
}
printf("%s", implode(PHP_EOL, $ans));


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

using namespace std;

#define INF 1e9

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

    int h,w;
    cin>>h>>w;

    char c[60][60];

    for(int i=0;i<60;i++){
        for(int j=0;j<60;j++){
            c[i][j]='.';
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>c[i][j];
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(c[i][j]=='#')cout<<c[i][j];
            else{
                int res=0;
                for(int dx=-1;dx<=1;dx++){
                    for(int dy=-1;dy<=1;dy++){
                        if(c[i+dy][j+dx]=='#')res++;
                    }
                }
                cout<<res;
            }
        }
        cout<<endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <chrono>

#define endl "\n"

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

template<typename T>
void printArray(T a) {
    for(auto i : a)
        cout << i << " ";

    cout << endl;
}

template<typename T>
void print2DArray(T a) {
    for(auto i : a) {
        for(auto j : i)
            cout << j << " ";

        cout << endl;
    }
    cout << endl;
}

int main(int argc, char *argv[])
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);

    char c = 'a';
    cin >> c;
    

    cout << (char)(c + 1) << endl;

    return 0;
}


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

int n, m;
int s[99999];
int a[100000];
int b[99999];
int p;
int ans;

int main(){
	scanf("%d %d", &n, &m);
	for(int i=0; i<n-1; i++){
		scanf("%d", &s[i]);
	}
	for(int i=0; i<m; i++){
		scanf("%d", &a[i]);
	}
	for(int i=0; i<m; i++){
		if(a[i] < 0){
			for(int j=0; j<(-a[i]); j++){
				p--;
				b[p]++;
			}
		}else{
			for(int j=0; j<a[i]; j++){
				p++;
				b[p-1]++;
			}
		}
	}
/*	printf("\n");
	for(int i=0; i<n-1; i++)
		printf("%d\n", b[i]);
	printf("\n");
*/	for(int i=0; i<n-1; i++){
		ans += s[i] * b[i];
		ans %= 100000;;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3908
#!/usr/bin/env python3
#ABC124 D
from itertools import accumulate
import bisect
n,k = map(int,input().split())
s = list(map(int,list(input())))
#0→1 または 1→0 の切り替わるときに連続する数を入れるlist
L = [0] if s[0] == 1 else [0,0]
cnt = 1
for i in range(1,n):
    if s[i-1] != s[i]:
        L += [cnt]
        cnt = 0
    cnt += 1
L += [cnt,0]
L = list(accumulate(L))
ans = 0
if len(L) - 2*k - 1 < 1:
    print(L[-1])
    quit()
for i in range(0,len(L)-2*k-1,2):
    ans = max(ans,L[i+2*k+1] - L[i])
print(ans)


Measured memory_bytes: 53112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S[i];
    int headB = 0;
    int tailA = 0;
    int AB = 0;
    int other = 0;
    rep(i,N){
        if(S[i][0]=='B'&&S[i][S[i].size()-1]=='A') AB++;
        else if(S[i][0]=='B')headB++;
        else if(S[i][S[i].size()-1]=='A') tailA++;
        else other++;
    }
    int ans = 0;
    rep(i,N){
        rep(c,S[i].size()-1){
            if(S[i][c]=='A'&&S[i][c+1]=='B') ans++;
        }
    }
    if(AB==0){
        ans+=min(headB,tailA);
    }else{
        if(headB==0&&tailA==0) ans+=AB-1;
        else ans += AB+min(headB,tailA);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3740
#include<stdio.h>

int main(void){
  int i;    //インデックス
  int n, q; //文字列長,問数
  int l, r; //指定区間
  
  scanf("%d%d", &n, &q);
  char s[n]; //文字列
  int a[n];  //判定列
  scanf("%s", s);
  
  for(i = 1;i < n;i++){
    a[i] = a[i - 1];
    if(s[i - 1] == 'A' && s[i] == 'C'){
      a[i]++;
    }
  }
  
  while(q--){
    scanf("%d%d", &l, &r);
    l--;
    r--;
    printf("%d\n", a[r] - a[l]);
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll n, m; cin >> n >> m;
    string ans = "No";
    if(n==m) ans = "Yes";
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

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

using i64 = long long;
const int INF = 1e9;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, A, B; cin >> N >> A >> B;
    vector<int> t(N);
    for(int& x : t) cin >> x;
    sort(t.begin(), t.end());
    int sum = 0;
    for(int x : t) {
        if(A <= x && x < B) continue;
        ++sum;
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 998244353;
    unsigned long A, B, C, D;
    cin >> A >> B >> C >> D;
    vector dp(C + 1, vector<unsigned long>(D + 1));
    dp[A][B] = 1;
    for(unsigned long i{A}; i <= C; ++i)for(unsigned long j{B + (i == A)}; j <= D; ++j)(dp[i][j] = dp[i][j - 1] * i + dp[i - 1][j] * j + MOD - (dp[i - 1][j - 1] * (i - 1) * (j - 1)) % MOD) %= MOD;
    cout << dp.back().back() << endl;
    return 0;
}

Measured memory_bytes: 73684
char R[99],G[99],*r,*g,m;
main(c){
	for(;scanf("%s%s\n",R,G),*R!='-';){
		r=R,g=G;
		m=*g++;
		for(;c=getchar(),c!='\n';){
			while(c!=m){
				putchar(m);
				m=*g++;
			}
			m=*r++;
		}
		putchar(m);
		puts(g);
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric> 

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 999999999
using namespace std;

int main()
{
    int n, t;
    cin >> n >> t;
    int tb, ta;
    long total;
    total = 0;
    cin >> tb;
    REP(i, n - 1) {
        cin >> ta;
        total += min(t, ta - tb);
        tb = ta;
    }
    total += t;

    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){

	double a, b, c, d, h, C, S, L;

	cin >> a >> b >> C;

	h = b * sin(C * M_PI / 180);
	d = b * cos(C * M_PI / 180);
	c = sqrt(pow(a - d, 2) + pow(h, 2));
	S = a * h / 2;
	L = a + b + c;

	printf("%.6f\n%.6f\n%.6f\n", S, L, h);


	return 0;
}


Measured memory_bytes: 3440
N = gets.to_i
k = Math.sqrt(2*N).floor
if k*(k+1) != 2*N
	puts 'No'
	exit
end

s, a = 0, Array.new(k+1){ [k]*(k+1) }
k.times{|i|
	(k-i).times{|j|
		a[i-k-1][j-k+i] = a[j-k+i][i-k] = s+=1
	}
}

puts 'Yes'
puts k+1
puts *a.map{|_|_*' '}


Measured memory_bytes: 6908
import math
N=int(input())
A=list(map(int,input().split()))

kekka=1

for i in range(N):
    kekka*=A[i]
    if kekka>10**18:
        kekka=10**18+1

if kekka>10**18:
    kekka=-1


print(kekka)


Measured memory_bytes: 22164
#include <stdio.h>
int main(void) {
	
	int A, B, C, D, min, max, i, j;

	scanf("%d %d %d %d", &A, &B, &C, &D);

	if (A < C) min = C;
	else min = A;

	if (B < D) max = B;
	else max = D;

	if (B < C || D < A) {
		printf("0\n");
		return 0;
	}

	printf("%d\n", max - min);
	return 0;
}

Measured memory_bytes: 128
def partition(A,p,r):
    x=A[r]
    i=p
    for j in range(p,r):
        if A[j]<=x:
            A[i],A[j]=A[j],A[i]
            i+=1
    A[i],A[r]=A[r],A[i]
    return i
n=int(input())
a=[int(i)for i in input().split()]
b=partition(a,0,n-1)
A=[str(i)for i in a]
A[b]="["+A[b]+"]"
print(" ".join(A))


Measured memory_bytes: 16592