akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);


    int k;
    cin >> k;

    ll ans = 0;
    for(int i = 1; i <= k; i++) {
        for(int j = 1; j <= k; j++) {
            for(int l = 1; l <= k; l++) {
                int g = __gcd(i, j);
                g = __gcd(g, l);
                ans += (ll) g;
            }
        }
    }
    cout << ans;
}








Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vl h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  while(k > 0) {
    if(h.size() == 0) break;
    h.pop_back();
    k--;
  }
  ll ans = 0;
  for(ll hp : h) ans += hp;
  cout << ans << endl;
}

Measured memory_bytes: 1792
N,Y = map(int,input().split())
for i in range(2001):
    for j in range(2001):
        if 10000*i+5000*j+1000*(N-i-j) == Y and N-i-j >= 0:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1) 

Measured memory_bytes: 3064
n, m = map(int, raw_input().strip().split(" "))
arr_n = [None] * n
arr_m = [None] * m
for i in range(n):
	arr_n[i] = raw_input().strip()
for i in range(m):
	arr_m[i] = raw_input().strip()

found = False
for i in range(n-m+1):
	if found:
		break
	for j in range(n-m+1):
		if found:
			break
		match = True
		for k in range(m):
			if arr_m[k] != arr_n[i+k][j:j+m]:
				match = False
				break
		if match:
			found = True
			print "Yes"
if not found:
	print "No"


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

int main()
{
    long long int n,x,y,z,p,q;
    cin>>n>>x>>y;
    z=x+y;
    if(n%z==0)
        cout<<(n/z)*x<<endl;
    else
    {
        p=(n/z)*(x+y);
        z=(n/z)*x;
        n=n-p;
        if(n>=x)
            cout<<z+x<<endl;
        else
            cout<<z+n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
  $stdin = fopen('php://stdin', "r");

  fscanf($stdin, "%d", $n);
  $a[0] = explode(' ', fgets($stdin));
  $a[1] = explode(' ', fgets($stdin));

  $res = 0;
  for ($i=0; $i<$n; $i++) {
    $sum = $a[0][0];
    if (0 < $i) {
      $sum += array_sum(array_slice($a[0], 1, $i)); // 上の段の合計
    }

    $sum += array_sum(array_slice($a[1], $i, $n-$i)); // 下の段の合計

    if ($res <= $sum) {
      $res = $sum;
    }
  }
  echo $res.PHP_EOL;


Measured memory_bytes: 4604
#!/usr/bin/env python3
#ABC61 C

from operator import itemgetter

n,k = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

x = sorted(ab,key = itemgetter(0))
s = 0
for i,j in x:
    if s < k <= s+j:
        print(i)
        break
    s += j


Measured memory_bytes: 29864
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = 0;
		for(int i = 8; i >= 0; i--) {
			sum+=(n%Math.pow(10, i+1))/Math.pow(10, i);
		}
		if(n%sum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){

int n;
double h,m;
double g=0,gm=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%lf:%lf",&h,&m);
g=30*h;gm=6*m;
g+=(0.5*m);
double H=0;
H=gm-g;
if(H<0)H*=-1;
if(H>180)H=360-H;

if(H<30)printf("alert\n");
else if(H<90)printf("warning\n");
else if(H<=180)printf("safe\n");
}
return 0;
}

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

using namespace std;

int n,av;
int a[55];
long long int dp[55][2555];

int main()
{
    dp[0][0]=1;
    cin>>n>>av;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        for(int k=i;k>=1;k--)
        {
            for(int j=2500;j>=0;j--)
                {
                    if(j-a[i]<0) break;
                    dp[k][j]+=dp[k-1][j-a[i]];
                }
        }
    }
    long long int res=0;
    for(int i=1;i<=n;i++)
    {
        res+=dp[i][i*av];
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N,M,x;
    cin >> N;
    int s[N],l[N],p[N];
    for(int i = 0 ; i < N ; i++){
	cin >> s[i] >> l[i] >> p[i];
    }
    int dp[500] = {0};
    for(int i = 0 ; i < N ; i++){
	for(int j = 0 ; j < 500 ; j++){
	    for(int k = s[i] ; k <= l[i] ; k++){
		if(j + k >= 500) continue;
		dp[j+k] = max(dp[j+k],dp[j]+p[i]);
	    }	
	}
    }

    cin >> M;
    vector<int> res(M);
    bool check = 0;
    for(int i = 0 ; i < M ; i++){
	cin >> x;
	res[i] = dp[x];
	if(res[i] == 0) check = 1;
    }
    if(check){
	cout << -1 << endl;
    }else{
	for(auto v : res){
	    cout << v << endl;
	}
    }	
    return 0;
}

Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int main(){
  int n[101];
  int i;
  int num;
  cin >> num;
  for(i=0;i<num;i++) cin >> n[i];
  cout << n[num-1];
  for(i=1;i<num;i++) cout <<" "<< n[num-i-1];
  cout << endl;
  return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> p( N );
	vector<int> s( N );
	for( int i = 0; i < N; i++ ) {
		cin >> p[i];
		s[i] = p[i];
	}

	sort( s.begin(), s.end() );
	int cnt = 0;
	for( int i = 0; i < N; i++ ) {
		if( p[i] != s[i] ) {
			cnt++;
		}
	}
	string ans = "YES";
	if( cnt > 2 ) {
		ans = "NO";
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	map<int,int> d,t;
	int n,m,tmp;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>tmp;d[tmp]++;;
	}
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>tmp;t[tmp]++;
	}
	for(auto x:t){
		if(d[x.first]<t[x.first]){
			cout<<"NO"; return 0;
		}
	}
	cout<<"YES";
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
int main(){
	ll x,count=0,a=100;
	ll calc =0;
	cin>>x;
	while(a<x){
		calc = a/100;
		a+=calc;
		count++;
	}
	cout<<count<<"\n";
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int n,a;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> a;
    if((n%500)<=a) cout << "Yes" << '\n';
    else cout <<"No" << '\n';
    return 0;
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

  vector<vector<string>> v;

  vector<string> v1 = {"a"};
  vector<string> v2 = {"aa", "ab"};
  vector<string> v3 = {"aaa", "aab", "aba", "abb", "abc"};

  v.push_back(v1);
  v.push_back(v2);
  v.push_back(v3);

  FOR(i,4,10){
    vector<string> vs;
    REP(j, v[i - 2].size()) {
      string s = v[i - 2][j];
      char M = 'a';
      REP(k,s.size()){
        char ch = s[k];
        M = max(ch, M);
      }
      FOR(ch, 'a', M+1){
        string p = s + char(ch);
        vs.push_back(p);
      }
    }
    v.push_back(vs);
  }

  REP(i, v[n - 1].size()) {
    ANS(v[n - 1][i]);
  }
  return 0;
}


Measured memory_bytes: 11460
#include<iostream>
#include<vector>
int main()
{
	std::vector<bool>result;
	while (true)
	{
		double x1, y1, x2, y2, x3, y3, xp, yp;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
		if (!std::cin)
		{
			break;
		}
		double k = ((x2 - x3)*(y3 - y1) - (x3 - x1)*(y2 - y3)) / ((x2 - x3)*(yp - y1) - (xp - x1)*(y2 - y3));
		double s = ((x1 - x3)*(yp - y1) - (xp - x1)*(y1 - y3)) / ((x2 - x3)*(yp - y1) - (xp - x1)*(y2 - y3));
		result.push_back(1 < k && 0 < s && s < 1);
	}
	for (auto i : result)
	{
		std::cout << (i ? "YES" : "NO") << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3196
/*
 * main.c
 *
 *  Created on: 2019/02/24
 *      Author: family
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	char s[10] = {0};
	scanf("%s", s);

	int month = ((s[5] & 0x0f) * 10 ) + (s[6] & 0x0f);
	int day = ((s[8] & 0x0f) * 10 ) + (s[9] & 0x0f);

	if ((month >= 5) && (day >= 1 )) {
		printf("TBD\n");
	} else {
		printf("Heisei\n");
	}
 	return 0;
}


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

int main()
{
    int n,d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d, 0));
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for(int i=0; i<n-1; i++){
        for(int j = i+1; j<n; j++){
            int sd = 0;
            for(int k = 0; k<d; k++){
                sd += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            int q = sqrt(sd);
            //cout << sd <<":" << q << endl;
            if(sd == q*q)  ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                HashMap<Long, Long> ihash = new HashMap<Long, Long>();

                long N = scan.nextLong();

                long Aheight;
                long jminusA;
                long Aplusk;
                long count = 0;

                for (long k = 1; k <= N; k++) {
                        Aheight = scan.nextLong();

                        jminusA = k - Aheight;
                        if (ihash.containsKey(jminusA)) {
                                count += ihash.get(jminusA);
                        }

                        Aplusk = Aheight + k;
                        if (ihash.containsKey(Aplusk)) {
                                ihash.replace(Aplusk,ihash.get(Aplusk)+1);
                        } else {
                                ihash.put(Aplusk,(long)1);
                        }
                }

                System.out.println(count);

        }
}

Measured memory_bytes: 70800
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	int ans = 0;
	for (int i = 0; i < s1.size(); i++) {
		ans += (s1[i] != s2[i]);
	}
	cout << ans;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
int dis[1003][1003];
bool vis[1003][1003][2];
int n,m,A,B,C,D;
char c[1003][1003];
bool has[1003][1003];
int main(){
	cin>>n>>m>>A>>B>>C>>D; 
	for(int i=0;i<1003;i++)for(int j=0;j<1003;j++)dis[i][j]=1e9;
	for(int i=1;i<=n;i++)scanf("%s",c[i]+1);
	deque<int>qu,qv;
	dis[A][B]=0;
	qu.push_back(A),qv.push_back(B);
	while(!qu.empty()&&!qv.empty()){
		int u=qu.front(),v=qv.front();qu.pop_front(),qv.pop_front();
		if(has[u][v])continue;has[u][v]=1;
		for(int i=-2;i<3;i++)for(int j=-2;j<3;j++){
			int uu=u+i,vv=v+j;
			if(uu<1||vv<1||uu>n||vv>m||dis[uu][vv]<=dis[u][v]+1||c[uu][vv]=='#')continue;
			dis[uu][vv]=dis[u][v]+1;
			qu.push_back(uu),qv.push_back(vv);
		}
		if(!vis[u][v][0]){
			vis[u][v][0]=1;
			for(int i=u-1;i>0&&c[i][v]!='#';i--){
				vis[i][v][0]=1;
				if(dis[i][v]>dis[u][v])dis[i][v]=dis[u][v],qu.push_front(i),qv.push_front(v);
			}
			for(int i=u+1;i<=n&&c[i][v]!='#';i++){
				vis[i][v][0]=1;
				if(dis[i][v]>dis[u][v])dis[i][v]=dis[u][v],qu.push_front(i),qv.push_front(v);
			}
		}
		if(!vis[u][v][1]){
			vis[u][v][1]=1;
			for(int i=v-1;i>0&&c[u][i]!='#';i--){
				vis[u][i][1]=1;
				if(dis[u][i]>dis[u][v])dis[u][i]=dis[u][v],qu.push_front(u),qv.push_front(i);
			}
			for(int i=v+1;i<=m&&c[u][i]!='#';i++){
				vis[u][i][1]=1;
				if(dis[u][i]>dis[u][v])dis[u][i]=dis[u][v],qu.push_front(u),qv.push_front(i);
			}
		}
	}
	if(dis[C][D]==1e9)puts("-1");
	else cout<<dis[C][D];
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ll a,p;cin>>a>>p;
    ll u=3*a+p;
    cout<<u/2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/**CLICK ss---> ctrl+j**/
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
void solve()
{
   ll n;
   cin>>n;
   cout<<n+(n*n)+((n*n)*n)<<endl;
}
int main()
{
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	/** 最大数 */
	static final int MAX = 55555;

	/** 合計を計算する数字の数 */
	static final int N = 5;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			// MAXまでのすべての素数を計算
			boolean[] isPrime = new boolean[MAX + 1];
			Arrays.fill(isPrime, true);
			isPrime[0] = isPrime[1] = false;
			for (int i = 2; i <= MAX; i++) {
				if (isPrime[i]) {
					for (int j = i * 2; j <= MAX; j += i) {
						isPrime[j] = false;
					}
				}
			}
			@SuppressWarnings("unchecked")
			List<Integer>[] lists = new List[N];
			IntStream.range(0, N).forEach(i -> lists[i] = new ArrayList<>());
			IntStream.range(2, MAX).filter(i -> isPrime[i]).forEach(i -> lists[i % N].add(i));
			int index = IntStream.range(1, N).filter(i -> lists[i].size() >= n).findFirst().getAsInt();
			IntStream.range(0, n).forEach(i -> System.out.println(lists[index].get(i)));
		}
	}
}


Measured memory_bytes: 26964
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

const vi num = {2,5,5,4,5,6,3,7,6};

int main(){
	int n,m;cin >> n >> m;
	vi a(m);
	rep(i,m){
		cin >> a.at(i);
		a.at(i)--;
	}
	vi dp(n+1,-INT_MAX);
	dp.at(0) = 0;
	rep(i,n+1){
		rep(j,m){
			if(i < num.at(a.at(j)))continue;
			dp.at(i) = max(dp.at(i), dp.at(i-num.at(a.at(j))) + 1);
		}
	}
	//rep(i,dp.size())cout << dp.at(i) << " ";
	//cout << endl;

	vi ans;
	sort(a.begin(),a.end(),greater<int>());
	int count = n;
	while(0 < count){
		rep(j,m){
			if(count < num.at(a.at(j)))continue;
			if(dp.at(count) == 1){
				if(count != num.at(a.at(j)))continue;
			}
			if(dp.at(count) == dp.at(count - num.at(a.at(j)))+1){
				ans.pb(a.at(j)+1);
				//cout << count << " " << a.at(j) + 1 << endl;
				count -= num.at(a.at(j));
				break;
			}
		}
	}
	
	
	rep(i,ans.size())cout << ans.at(i);
	cout << endl;
	return 0;	
}

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    K = int(rl())
    
    mods = [7 % K]
    for _ in range(10 ** 6):
        if mods[-1] == 0:
            print(len(mods))
            return
        mods.append((mods[-1] * 10 + 7) % K)
    print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 140404
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        sequence: [usize; n],
        q: usize,
        pairs: [(usize, usize); q],
    }
    let mut map: HashMap<usize, usize> = HashMap::new();

    let mut sum: usize = sequence.iter().sum();

    for s in &sequence {
        if let Some(count) = map.get_mut(s) {
            *count+=1;
        } else {
            map.insert(*s, 1);
        }
    }

    for p in &pairs {
        let mut count = 0;
        if let Some(count0) = map.get_mut(&p.0) {
            if p.1 > p.0 {
                sum += (p.1 - p.0) * *count0;
            } else {
                sum -= (p.0 - p.1) * *count0;
            }
            count = *count0;
            *count0 = 0;
        }
        println!("{}", sum);
        if let Some(count1) = map.get_mut(&p.1) {
            *count1+=count;
        } else {
            map.insert(p.1, count);
        }
    }
}


Measured memory_bytes: 9604
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

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

    double ans = 0;
    double sorezore = 1.0 / N;

    for (int i = 1; i <= N; ++i) {
        int tokuten = i;
        double kakuritu = 1.0;
        while (tokuten <= K-1) {
            tokuten *= 2;
            kakuritu *= 0.5;
        }
        ans += kakuritu;
    }
    cout << setprecision(9) <<ans * sorezore;
}

Measured memory_bytes: 256
//どっか～引用

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0; i<n; ++i) {
        int l, r;
        cin >> l >> r;
        ans += (r-l)+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
const int maxn = 100005 ; 
int a[maxn] ;
using namespace std;
int main(int argc, char *argv[])
{
    int n,k=0;
    cin>>n;
    for(int i= 0;i<n;i++){
        cin>>a[i];    
    }
    int i ;
    for(i=0;i<n;i++){
        if(a[i]==i+1){
        int t=a[i];
            a[i]=a[i+1];
            a[i+1]=t;
            k++;        
        }
    if(a[i]==i+1&&i==n-1){
        int t=a[i];
            a[i]=a[i-1];
            a[i-1]=t;
            k++;        
        }    
    }
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void) {
	int N,K;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		char c;
		cin >> c;
		if (i == K-1) {
			c = 'a' + (c - 'A');
		}
		cout << c;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    ans = A[0]
    for a in A[1:]:
        ans ^= a

    for a in A:
        print(a ^ ans, end=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 31404
from itertools import accumulate

N, K = map(int, input().split())
mod = 998244353
Move = [list(map(int, input().split())) for _ in range(K)]

DP = [0] * N
DP[0] = 1
DP[1] = -1
cnt = 0

for i in range(N):
    DP[i] += cnt
    DP[i] %= mod
    cnt = DP[i]
    for l, r in Move:
        if i + l < N:
            DP[i+l] += DP[i]
        if i + r + 1 < N:
            DP[i + r + 1] -= DP[i]

print(DP[-1])

Measured memory_bytes: 80132
#include <iostream>
using namespace std;
typedef long long ll;
ll n, m;
string s, t;

ll gcd(ll x, ll y){
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main(void){
    // Your code here!
    bool ans = true;
    cin >> n >> m >> s >> t;
    ll a = m / gcd(n, m);
    ll b = n / gcd(n, m);
    for (ll i = 0; i < n * m / gcd(n, m) / (a * b / gcd(a, b)); i++){
        if (s[i * b / gcd(a, b)] != t[i * a / gcd(a, b)]) ans = false;
    }
    if (ans) cout << n * m / gcd(n, m) << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int dp[500005];
string s;
int N;
int main() {
  cin >> N >> s;
  int nxt[N], prv[N];
  // 前の0の位置
  int pr = -1;
  FOR(i,0,N) {
    if(s[i] == '0') pr = i;
    prv[i] = pr; 
  }

  int nx = N;
  for(int i = N - 1; i >= 0; i--) {
    if(s[i] == '0') nx = i;
    nxt[i] = nx;
  }

  FOR(i,0,N) {
    dp[i+1] = max(dp[i+1], dp[i]);
    if(s[i] == '1') {
      // 101111....
      if(prv[i] > 0 && s[prv[i]-1] == '1') {
        int one = i - prv[i];
        dp[i+1] = max(dp[i+1], dp[prv[i]-1]+one);
      }
      // ...11111101
      if(nxt[i] < N - 1 && s[nxt[i]+1] == '1') {
        int one = nxt[i] - i;
        dp[nxt[i]+2] = max(dp[nxt[i]+2], dp[i]+one);
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 6660
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;++i)
#define END(x) (*(x.end()-1))

using namespace std;
typedef long long ll;
typedef vector<vector<int>> Graph;

template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a*b/gcd(a,b);
}


template<typename T>
bool same(T x_b,T x_e,T y_b,T y_e){
    for(auto i = x_b, j = y_b; i != x_e && j != y_e;++i,++j){
        if(*i!=*j){
            return false;
        }
    }
    return true;
}

using Graph=vector<vector<int>>;//グラフ型
void dfs(const Graph &G,int v/*根*/,vector<bool> &seen){
    seen[v]=true;  //vを訪問済にする
    for(auto next_v:G[v]){ //訪問済にしたvとつながっている場所を順番に探す
        if(seen[next_v]) continue; //もし探索済みならスルー
        dfs(G,next_v,seen); //再帰的に探索
    }
}
 
void bfs(const Graph &G,queue<int> &que/*発見したが訪問はしていない*/,vector<int> &dist/*開始地点からの距離*/){
    while(!que.empty()){
        int v=que.front();//queのうち先頭のものからスタート
        que.pop();//先頭を削除
 
        for(int nv :G[v]){//vとつながっている点を列挙
            if(dist[nv]!=-1) continue;//発見済(=距離が格納されている)であればスルー
            dist[nv]=dist[v]+1;//vとつながっている点に距離の情報を追加
            que.push(nv);//vとつながっている点を発見済にする
        }
    }
}

int main(void){
    string s;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}
/*

*/


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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while(true){
        string s;
        cin>>s;
        if(s=="0") break;
        int sum = 0;
        for(int i=0; i<s.length(); i++){
            int a = (int)s[i] - 48;
            sum += a;
        }
        cout<<sum<<endl;
    }

    
    return 0;
    
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long dp[5005][5005];
int main(){
	cin>>n>>k;
	dp[0][0]=1;
	for(int i=1;i<=2000;i++){
		for(int j=1;j<=2000;j++){
			dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%1000000007;
		}
	}
	for(int i=1;i<=k;i++){
		long long ans =dp[k][i]*(dp[n-k][i]*2+dp[n-k][i-1]+dp[n-k][i+1])%1000000007;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 79104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;

class Sobaya
{
    static void Main(){
      new Sobaya().calc();
      return;
    }
      
    Scanner cin;
    
    void calc(){
        cin = new Scanner();
        int n = cin.nextInt();
        int[] a = new int[n];
        int i1;
        for(i1=0; i1<n; i1++) a[i1]=cin.nextInt();
        
        int count = 0;
        for(i1=0; i1<n; i1++) if(a[i1]!= i1+1) count++;
        
        if(count==0 || count==2) Console.WriteLine("YES");
        else Console.WriteLine("NO");

    }
}




class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

int calc(int x){
    int tmp=x,res=0;
    while(tmp){
        res += tmp%10;
        tmp /= 10;
    }
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;cin>>n;
    int res=INF;
    for(int a=1;a<=n-1;a++){
        int b=n-a;
        res=min(res,calc(a)+calc(b));
    }
    cout<<res<<endl;

}


Measured memory_bytes: 256
def solution():
	n,m = [int(x) for x in input().split(' ')]
	e = []
	ans = 0 

	for i in range(m):
		_x,_y = [int(x) for x in input().split(' ')]
		e.append((_x-1,_y-1))

	for i in range(m):
		matrix = []
		for _i in range(n):
				matrix.append([-1]*n)
		for _i in range(m):
			if _i != i: 
				_e = e[_i]
				matrix[_e[0]][_e[1]]  = 1
				matrix[_e[1]][_e[0]]  = 1

		for k in range(n):
			for _i in range(n):
				for _j in range(n):
					if _i!=_j:
						if matrix[_i][k] >0 and matrix[k][_j] > 0:
							if matrix[_i][_j]>0:
								matrix[_i][_j] = min(matrix[_i][_j],matrix[_i][k]+matrix[k][_j])
							else:
								matrix[_i][_j] = matrix[_i][k]+matrix[k][_j]
		isconnected = True
		for _i in range(n):
			if not(isconnected):
				break			
			for _j in range(n):
				if _i == _j:
					continue
				if matrix[_i][_j] == -1:
					isconnected = False
					ans+=1
					break

	print(ans)



solution()

Measured memory_bytes: 3064
function bubbleSort (A) {
    let n = A.length;
    let count = 0;
    let flag = 1;
    let i = 0;
    while (flag === 1) {
        flag = 0;
          for (let j = n - 1; j >= i + 1; j--) {
             if (A[j] < A[j-1]) {
                 let tmp = A[j];
                 A[j] = A[j-1];
                 A[j-1] = tmp;
                 flag = 1;
                 count++;
         }
        }
        i++;
    } 
    return [A, count];
}

const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
input.shift();
let Arr = input[0].split(' ').map(Number);
let result = bubbleSort(Arr);
console.log(result[0].join(' '));
console.log(result[1]);


Measured memory_bytes: 15404
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
//#include<cctype>

using namespace std;

class Player{
public:
  int id;
};

int main()
{
  while(true){
    int m,n;
    cin >> m >> n;
    if( m == 0 && n == 0 ) break;
    vector< Player > p;
    for(int i = 0; i < m; ++i){
      Player tp;
      tp.id = i+1;
      p.push_back( tp );
    }

    int ans = 1;
    int nowplayer = 0;
    string s;
    getline(cin,s);
    for(int i = 0; i < n; ++i){
      //getline(cin,s);
      cin >> s;
      if(p.size()==1)continue;
      
      bool erased = false;
      if(ans % 15 == 0 ){
	if( s != "FizzBuzz" ){
	  erased = true;
	}
      }else if( ans % 3 == 0 ){
	if( s != "Fizz" ){
	  erased = true;
	}
      }else if( ans % 5 == 0 ){
	if( s != "Buzz" ){
	  erased = true;
	}
      }else{
	erased=true;
	//!isdigit(s[0]);
	//false;
	//bool lead = true;
	/*
	for(int j = 0; j < s.length(); ++j){
	  if( !isdigit(s[j]) ){
	    ng=true;
	    break;
	  }
	  if( lead && s[j] == '0' ){
	    //s.erase( s.begin() + j );
	    ng = true;
	    break;
	    //j = -1;
	  }else{
	    lead=false;
	  }
	}
	if(s.length()==0)ng=true;
	if( s.length() >= 7 ) ng = true;
	*/
	int d = atoi( s.c_str() );
	if( d == ans ){
	  erased = false;
	}
      }
      if( !erased ){
	++nowplayer;
      }else{
	p.erase( p.begin() + nowplayer );
      }
      nowplayer %= p.size();
      ++ans;
    }

    for(int i = 0; i < p.size(); ++i){
      if( i > 0 ) cout << ' ';
      cout << p[i].id;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 956
#include <iostream>
#include <map>

using namespace std;

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

int W, H;
string land[51];
pair<bool, bool> check[51][51]; // Black, White

void dfs(int x, int y, char ch)
{
    if (ch == 'B' && check[y][x].first)
        return;
    else if (ch == 'W' && check[y][x].second)
        return;

    if (land[y][x] == '.') {
        if (ch == 'B')
            check[y][x].first = true;
        else if (ch == 'W')
            check[y][x].second = true;
    }

    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];

        if (nx < 0 || ny < 0)
            continue;
        if (nx >= W || ny >= H)
            continue;
        if (land[ny][nx] == '.')
            dfs(nx, ny, ch);
    }
}


int main()
{
    while (cin >> W >> H, W && H) {
        // Input
        for (int y = 0; y < H; y++) {
            cin >> land[y];
            for (int x = 0; x < W; x++) {
                check[y][x].first = false;
                check[y][x].second = false;                
            }
        }

        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                if (land[y][x] == 'B')
                    dfs(x, y, 'B');
                else if (land[y][x] == 'W')
                    dfs(x, y, 'W');
            }
        }

        int ab, aw;
        ab = aw = 0;
        for (int y = 0; y < H; y++)
            for (int x = 0; x < W; x++) {
                if (!check[y][x].first || !check[y][x].second) {
                    if (check[y][x].first)
                        ab++;
                    else if (check[y][x].second)
                        aw++;
                }
            }
        
        cout << ab << " " << aw << endl;
    }

    return 0;
}

Measured memory_bytes: 1304
#include <stdio.h>

int main(){
  int a;
  int b;
  scanf("%d%d", &a, &b);
  if(a == b){
    printf("%d\n", a);
  }else if(a > b){
    printf("%d\n", a-1);
  }else if(a < b){
    printf("%d\n",a);
  }

}

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

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

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

bool is_prime(int m, int n) {
	int x = m * m + n * n;
	for (int y = 2; y * y <= x; y++) {
		if (x % y != 0) continue;
		int ry = sqrt((double)y) + EPS;
		for (int p = -ry; p <= ry; p++)
			for (int q = -ry; q <= ry; q++) {
				if (p * p + q * q != y) continue;
				if ((p * m + q * n) % y == 0 && (p * n - q * m) % y == 0)
					return false;
			}
	}
	return true;
}

int main() {
	int T; cin >> T;
	while (T--) {
		int m, n; cin >> m >> n;
		cout << (is_prime(m, n) ? 'P' : 'C') << endl;
	}
}

Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = ab[0], B = ab[1];
            var score = 0;
            for (int i = 0; i < 2; i++)
                if (A > B)
                    score += A--;
                else
                    score += B--;
            Console.WriteLine(score);
        }
    }
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    double n, m, d; cin >> n >> m >> d;
    double k = d==0 ? 1 : 2;
    cout << k*(n-d)*(m-1)/n/n << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7896
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>

using namespace std;
typedef unsigned long long ll;
typedef pair<int,int>P;

int main()
{
	int H,W,N;
	cin>>H>>W>>N;
	vector<int>cnt(N,0);
	vector<vector<int>>G;
	for(int i=0;i<H;i++)
	{
		vector<int>r(W,0);
		G.push_back(r);
	}
	for(int i=0;i<N;i++)
	{
		cin>>cnt[i];
	}
	int np=0;
	int npc=0;
	for(int i=0;i<H;i++)
	{ 
		if(i%2)
		{
			for(int j=0;j<W;j++)
			{
				G[i][j]=np;
				npc++;
				if(npc==cnt[np])
				{
					np++;
					npc=0;
				}
			}
		}
		else
		{
			for(int j=W-1;j>=0;j--)
			{
				G[i][j]=np;
				npc++;
				if(npc==cnt[np])
				{
					np++;
					npc=0;
				}
			}
		}
	}
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
		{
			cout<<G[i][j]+1<<(j==W-1?'\n':' ');
		}
}

Measured memory_bytes: 384
import sys

def solve():
      input = sys.stdin.readline
      N = int(input())
      used = {N}
      if N > 2: used |= {N - 1}
      for i in range(2, N):
            if i ** 2 > N: break
            else:
                  if N % i == 0:
                        d = N
                        while d % i == 0:
                              d //= i
                        if d % i == 1: used |= {i}
                  if (N - 1) % i == 0:
                        used |= {i}
                        if i ** 2 != N - 1: used |= {(N - 1) // i}
      print(len(used))
      #print(used)

      return 0

if __name__ == "__main__":
      solve()

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

int dig(int n)
{
	int c = 0;
  	while(n)
    {
    	c++;
      	n /= 10;
    }
  	return c;
}

int f(int i, int j)
{
	return max(dig(i), dig(j));
}

int main()
{
  	long long int n;
  	cin>>n;
  	int res = dig(n);
  	for(long long int i = 1; i*i <= n; i++)
    {
    	if(n % i != 0)
          	continue;
      	long long int b = n/i;
      	int cur = f(i, b);
      	res = min(cur, res);
    }
  	cout<<res;
	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 REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll m = 1e18;
    rep(i,N){
        cin >> a[i];
        cmin(m,a[i]);
    }
    ll M = m + 1;
    ll nofm = 0;
    ll nofM = 0;
    rep(i,N){
        if(a[i] == m){
            nofm++;
        }else if(a[i] == M){
            nofM++;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    if(!nofM){
        if(m == N-1 || m*2 <= N){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
            /*else if(N%m == 0){
            cout << "Yes" << endl;
        }else if(m == 2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }*/
        return 0;
    }
    if(nofm < M && 2*(M-nofm) <= nofM){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 4052
#include<iostream>

using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int mod = B;
    int remA = A % B;
    int reminder = A % B;
    int count = 0;
    if(remA == C) cout << "YES" << endl;
    else{
        for(;;){
            count++;
            if((remA + reminder) % mod == C){
                cout << "YES" << endl;
                break;
            }
            if((remA + reminder) % mod == 0){
                cout << "NO" << endl;
                // cout << count << " " <<reminder<<endl;
                break;
            }
            reminder = ((remA + reminder) % mod );
            // cout << reminder << endl;
            
        }
    }
  
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = [None] * H
R = [0] * H
for i in range(H):
    S[i] = input().rstrip()
    for j in range(W):
        if S[i][j] == '#':
            R[i] += 1

A = []
k = 1
first = None
for i in range(H):
    if R[i] == 0:
        continue
    ans = [0] * W
    j = 0
    while j < W and S[i][j] == '.':
        ans[j] = k
        j += 1
    k -= 1
    while j < W:
        if S[i][j] == '#':
            k += 1
        ans[j] = k
        j += 1
    A.append(ans)
    if first is None:
        first = ans
    i2 = i + 1
    while i2 < H:
        if R[i2] == 0:
            A.append(ans)
            i2 += 1
        else:
            break
    k += 1
for i in range(H):
    if R[i] == 0:
        A.insert(0, first)
    else:
        break
for i in range(H):
    print(' '.join(map(str, A[i])))


Measured memory_bytes: 7284
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 1e5 + 5;
int a[105];
bool dp[maxn];

int main() {
    int n, k;
    cin >> n >> k;
    REP(i, n) cin >> a[i];
    REPP(i, 1, k + 1) REP(j, n) {
        if (i < a[j]) break;
        if (!dp[i - a[j]]) dp[i] = true;
    }
    cout << (dp[k] ? "First" : "Second") << endl;
    return 0;
}


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

int main(){
 int x,y;
 for(int i=0; i<15000; i++){
  cin >> x >> y;
  if(x==0 && y==0){
    break;
  }
  if(x>=y){
   cout << y << " " << x << endl;
  }
  else{
    cout << x << " " << y << endl;
  }
 }

}


Measured memory_bytes: 3080
#include<iostream>
//#include<numeric>

using namespace std;

void swap ( int& x, int& y )
{
	int tmp = x;
	x = y;
	y = tmp;
}

int gcd ( int x, int y )
{
	if ( x < y )
		swap ( x,y );

	int r;

	while ( y > 0 )
	{
		r = x%y;
		x = y;
		y = r;
	}

	return x;
}

int main()
{

	int x,y;

	cin >> x >> y;

	cout << gcd(x,y) << endl;	

return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, y; cin >> x >> y;
  vector<int> gp = {4, 6, 9, 11};
  if(x == 2 || y == 2) cout << "No" << endl;
  else if(count(gp.begin(), gp.end(), x) ^ count(gp.begin(), gp.end(), y)) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}
  

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

int main()
{
    vector<string> r;
    string tmp;
    double weight;
    while (cin >> weight)
    {
	if (weight <= 48) {
	    tmp = "light fly";
	} else if (weight <= 51) {
	    tmp = "fly";
	} else if (weight <= 54) {
	    tmp = "bantam";
	} else if (weight <= 57) {
	    tmp = "feather";
	} else if (weight <= 60) {
	    tmp = "light";
	} else if (weight <= 64) {
	    tmp = "light welter";
	} else if (weight <= 69) {
	    tmp = "welter";
	} else if (weight <= 75) {
	    tmp = "light middle";
	} else if (weight <= 81) {
	    tmp = "middle";
	} else if (weight <= 91) {
	    tmp = "light heavy";
	} else {
	    tmp = "heavy";
	}
	r.push_back(tmp);
    }
    for (int i=0; i<r.size(); i++)
	cout << r[i] << endl;
}

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

    if (s[s.length() - 1] == 's') {
        cout << s << "es" << endl;
    } else {
        cout << s << 's' << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

a,b = miinps()

for i in range(1250):
  x = int(i*0.08)
  y = int(i*0.1)
  if x == a and y == b:
    print(i)
    exit()
  
print("-1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif

    int n;
    cin>>n;
    int rem = (n%1000);
    if(rem == 0){
        cout<<0;
    }else{
        cout<<1000-rem;
    }
    


    
}

Measured memory_bytes: 3648
from itertools import permutations
N = int(input())
x = tuple(map(int, input().split()))#(7, 3, 5, 4, 2, 1, 6, 8)
y = tuple(map(int, input().split()))
# y = (3, 8, 2, 5, 4, 6, 7, 1)
for idx, num in enumerate(list(permutations(range(1, N+1), len(range(N)))),start=1):
    if num == x:
        a = idx
    if num == y:
        b = idx
print(abs(a-b))

Measured memory_bytes: 8052
#include<stdio.h>
#define ll long long
ll min(ll a,ll b){if(a<b) return a; return b;}
int main(){
    ll n,a,b,p,ans;
    scanf("%lld%lld%lld",&n,&a,&b);
    p=a+b;
    ans=(n/p)*a+min(a,(n%p));
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int MOD=1e9+7;

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

  ll a,b,c;cin>>a>>b>>c;
  if(a*b*c%2){
      std::vector<ll> v(3);
      v[0]=a*b;v[1]=b*c;v[2]=c*a;
      sort(v.begin(),v.end());
      cout<<v[0]<<endl;
      return 0;
  }
  cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 100000001;
const ll mod = 1000000007;
void ChocolateBar() {
	int n;
	cin >> n;
	int t[101];
	int sum = 0;
	for (size_t i = 0; i < n; i++)
	{
		cin >> t[i];
		sum += t[i];
	}
	int m;
	cin >> m;
	for (size_t i = 0; i < m; i++)
	{
		int p, x;
		cin >> p >> x;
		cout << (sum - t[p - 1] + x) << endl;
	} 


}

int main() {
	ChocolateBar();

	return 0;
}



Measured memory_bytes: 256