akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

const int MAX_N = 2 * 1e6 + 2;

bool is_prime[MAX_N];
vector<int> primes;

void hurui() {
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i < MAX_N; i++) {
        is_prime[i] = true;
    }
    for (int i = 2; i < MAX_N; i++) {
        if (!is_prime[i]) continue;
        int now = i * 2;
        while (now < MAX_N) {
            is_prime[now] = false;
            now += i;
        }
    }
}

void solve(int k) {
    if (is_prime[k]) {
        cout << 0 << endl;
        return;
    }
    for (int i = 0; i < primes.size() - 1; i++) {
        if (primes[i] < k && primes[i + 1] > k) {
            cout << primes[i + 1] - primes[i] << endl;
            return;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    hurui();
    for (int i = 2; i < MAX_N; i++) {
        if (is_prime[i]) {
            primes.push_back(i);
        }
    }
    while (true) {
        cin >> K;
        if (K == 0) break;
        solve(K);
    }
    return 0;
}


Measured memory_bytes: 5784
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll x, k, d;
    cin >> x >> k >> d;
    if (x > 0) {
        if (k < x / d) cout << x - k * d;
        else {
            k -= x / d;
            x %= d;
            if (k % 2) cout << d - x;
            else cout << x;
        }
    } else {
        if (k < -x / d) cout << -x - k * d;
        else {
            k -= -x / d;
            x %= d;
            if (k % 2) cout << x + d;
            else cout << -x;
        }
    }
}


Measured memory_bytes: 3192
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[] l = new int[n];
    int count = 0;
    int cood = 0;
    
    for(int i=0;i<n;i++){
      if(cood > x) break;
      l[i] = sc.nextInt();
      cood += l[i];
      count++;
    }
    
    if(cood <= x) count++;
    
 	System.out.println(count);
  }
}

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

const int MAXN = 10005;

long long a[MAXN], c[MAXN];
int top = 0;
int vis[MAXN];

long long sum(long long a)
{
        long long ans = 0;
	while (a) ans += a%10, a /= 10;
	return ans;
}

int main()
{
	long long B = 1e15;
	for (int i = 1; i <= 300; i++) {
		long long cur = i;
		while (cur <= B) a[++top] = cur, cur = cur*10+9;
	}
	sort(a+1, a+top+1);
	top = unique(a+1, a+top+1)-a-1;
	for (int i = 1; i <= top; i++)
		for (int j = i+1; j <= top; j++)
			if (a[i]*sum(a[j]) > a[j]*sum(a[i]))
				vis[i] = 1;
	int tot = 0;
	for (int i = 1; i <= top; i++)
		if (!vis[i]) 
			c[++tot] = a[i];
	int K;
	cin >> K;
	for (int i = 1; i <= K; i++)
		cout << c[i] << endl;
	return 0;
}


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

string longestRepeatedSubstring(string str)
{
    int n = str.length();
    int LCSRe[n+1][n+1];

    memset(LCSRe, 0, sizeof(LCSRe));
    string res;
    int res_length = 0;

    int i, index = 0;
    for (i=1; i<=n; i++)
    {
        for (int j=i+1; j<=n; j++)
        {
            if (str[i-1] == str[j-1] &&
                LCSRe[i-1][j-1] < (j - i))
            {
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1;

                if (LCSRe[i][j] > res_length)
                {
                    res_length = LCSRe[i][j];
                    index = max(i, index);
                }
            }
            else
                LCSRe[i][j] = 0;
        }
    }

    if (res_length > 0)
        for (i = index - res_length + 1; i <= index; i++)
            res.push_back(str[i-1]);

    return res;
}

int main()
{
    int n;cin>>n;
    string str;cin>>str;
    cout << longestRepeatedSubstring(str).size();
    return 0;
} 


Measured memory_bytes: 97920
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr);
 
const int N = 3e5+5;
const int MOD = 1e9+7;

 
int32_t main()
{
	IOS;
 	int a, b, c;
	cin >> a >> b >> c;
	int ans = (a + b);
	ans = ans * c;
	ans /= 2;
	cout << ans << endl;	
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int dp[31], n, i, result[100];

int main()
{	
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;

	for (int a = 3; a < 31; a++)
	{
		dp[a] = dp[a - 1] + dp[a - 2] + dp[a - 3];
	}

	for (;; i++)
	{
		cin >> n;
		if (n == 0)
		{
			break;
		}
		result[i] = dp[n] / 3650 + 1;
	}

	for (int a = 0; a < i; a++)
	{
		cout << result[a] << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a,b=inintm()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a,b))


Measured memory_bytes: 62084
[a,b,c,d] = [int(i) for i in input().split()]
turn = 0
while a > 0 and c > 0:
    if turn % 2 == 0:
        c -= b
    else:
        a -= d
    turn += 1

if turn % 2 == 0:
    print("No")
else:
    print("Yes")


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

int main(){
	int R;
	scanf("%d", &R);
	if(R < 1200){
		printf("ABC\n");
	}
	else if(R < 2800){
		printf("ARC\n");
	}
	else{
		printf("AGC\n");
	}
	return 0;
}

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

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (a[i] == b[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")


a,b,c=map(int, input().split())

p(a,b,c)

ans="No"
if a<c and c<b: ans="Yes"
if b<c and c<a: ans="Yes"

print(ans)


Measured memory_bytes: 3060
(defun main ()
  (let ((n (read))
        (s (read))
        (dp (make-array '(3030 3030 3) :initial-element 0))
        (a (make-array 3030 :initial-element 0))
        (mod 998244353))
    (dotimes (i n)
      (setf (aref a i) (read)))
    (setf (aref dp 0 0 0) 1)

    (dotimes (i n)
      (dotimes (j (1+ s))
        (setf (aref dp (1+ i) j 0) (rem (+ (aref dp (1+ i) j 0) (aref dp i j 0)) mod))
        (setf (aref dp (1+ i) j 1) (rem (+ (aref dp (1+ i) j 1) (aref dp i j 0) (aref dp i j 1)) mod))
        (setf (aref dp (1+ i) j 2) (rem (+ (aref dp (1+ i) j 2) (aref dp i j 0) (aref dp i j 1) (aref dp i j 2)) mod))
        (when (<= (+ j (aref a i)) s)
          (setf (aref dp (1+ i) (+ j (aref a i)) 1) (rem (+ (aref dp (1+ i) (+ j (aref a i)) 1) (aref dp i j 0) (aref dp i j 1)) mod))
          (setf (aref dp (1+ i) (+ j (aref a i)) 2) (rem (+ (aref dp (1+ i) (+ j (aref a i)) 2) (aref dp i j 0) (aref dp i j 1)) mod)))))
    (format t "~d~%" (aref dp n s 2))))

(main)


Measured memory_bytes: 239972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long N;
    cin >>N;
    vector<long long>vecA(N+1);
    vector<long long>vecB(N);
    for(int i=0;i<N+1;i++){
        cin >>vecA.at(i);
    }
    for(int i=0;i<N;i++){
        cin >>vecB.at(i);
    }
   long long summ=0;
    for(int i=0;i<N;i++){
    long long stand3=vecA.at(i)-vecB.at(i);
    long long stand4=vecB.at(i)-vecA.at(i);
    if(stand3>=0){
        summ+=vecB.at(i);
    }
    else{
        summ+=vecA.at(i);
        if(vecA.at(i+1)>=stand4){
            summ+=stand4;
            vecA.at(i+1)-=stand4;
        }
        else{
            summ+=vecA.at(i+1);
            vecA.at(i+1)=0;
        }
     }
    }
    cout <<summ<<endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define LL long long
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f3f3f3f
#define mem(i, j) memset(i, j, sizeof(i))
#define pb push_back
using namespace std;

const int N = 1e6 + 5;
char a[N];
int b[N];
int main() {

    scanf("%s", a + 1);
    int n = strlen(a + 1);
    rep(i, 0, n) {
        b[i] = 0;
    }
    int sum = 0;
    dep(i, 1, n) {
        b[i] += (a[i] - '0') * 9;
        b[i - 1] += b[i] / 10;
        b[i] %= 10;
        sum += b[i];
    }
    sum += b[0];
    int x = 10 - b[n];
    sum += x;
    b[n] += x;
    while(1) {
        dep(i, 1, n) {
            if(b[i] >= 10) {
                sum -= 9;
                b[i] -= 10;
                b[i - 1]++;
            }
            else break;
        }
        if(sum <= x) {
//            printf("%d\n", x);
            int ans = x / 9; if(x % 9) ans++;
            printf("%d\n", ans); return 0;
        }
        b[n] += 10; x += 10; sum += 10;
    }
    return 0;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	
	int map[]{ -1, -1, -1 };
	bool is_error = false;
	rep (i, m) {
		int x, y;
		cin >> x >> y;
		--x;

		if (map[x] != -1 && map[x] != y) is_error = true;
		if (n > 1 && x == 0 && y == 0) is_error = true;

		map[x] = y;
	}

	if (is_error)
		cout << -1 << endl;
	else {
		rep(i, n) {
			if (map[i] != -1)
				cout << map[i];
			else {
				if (i == 0 && n != 1)
					cout << 1;
				else
					cout << 0;
			}
		}
	}

	cout << endl;
}


Measured memory_bytes: 256
import Data.Char

rotate :: Int -> [a] -> [a]
rotate _ [] = []
rotate n xs = zipWith const (drop n (cycle xs)) xs

caesar :: Int -> Char -> Char
caesar n c
  | isAsciiLower c = cs !! (ord c - ord 'a')
  | otherwise      = c
  where cs = rotate n ['a'..'z']

solver :: String -> String
solver xs = head $ dropWhile f [map (caesar i) xs | i <- [0..(ord 'z' - ord 'a')]]
  where f s = let ws = words s
              in  not $ "the" `elem` ws || "this" `elem` ws || "that" `elem` ws

main :: IO ()
main = getContents >>= mapM_ (putStrLn . solver) . lines

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

#define MAX 1000001 
bool v[MAX];

int main(void) {
  for (int i = 0; i < MAX; i++) {
    v[i] = false;
  }

  int s;
  cin >> s;
  int prev = s;
  v[s] = true;
  for (int i = 1; i < MAX; i++) {
    //cout << prev << " ";
    int a_i = prev % 2 == 0 ? prev / 2 : 3 * prev + 1;
    if (v[a_i]) {
      //cout << a_i << endl;
      cout << i + 1 << endl;
      return 0;
    }
    v[a_i] = true;

    prev = a_i;
  }

  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h> 
using namespace std; 
int main()
{
	int N,K;
	cin>>N;
	int arr[N];
	for(int i=0;i<N;i++)
	{
		cin>>arr[i];
	}	
	int sum=0;
	for(int i=0;i<N;i++)
	{
		sum+=arr[i];
	}
	int P=sum/N;
	int Q=sum/N + 1;
	int res=0;
	for(int i=0;i<N;i++)
	{
			res+=((arr[i]-P)*(arr[i]-P));
	}
	int res1=0;
	for(int i=0;i<N;i++)
	{
			res1+=((arr[i]-Q)*(arr[i]-Q));
	}
	int r=min(res,res1);
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#define NMAX (int )1e5+5

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

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

int N,ans = 0,M = -1;
char animal[NMAX],truth[NMAX];
char S[NMAX];
string dx[4] = {"SS","SW","WS","WW"};
bool check(int b){
	if(truth[b] == 'o'){
		if(animal[b-1] == animal[b+1]){
			return true;
		}else{
			return false;
		}
	}else{
		if(animal[b-1] != animal[b+1]){
			return true;
		}else{
			return false;
		}
	}
}
void made(int b){
	if(truth[b] == 'o'){
		animal[b+1] = animal[b-1];
	}else{
		if(animal[b-1] == 'S'){
			animal[b+1] = 'W';
		}else{
			animal[b+1] = 'S';
		}
	}
}

int solve(int a){
	animal[0] = dx[a][0];
	animal[1] = dx[a][1];
	animal[N] = animal[0];
	for (int i = 0; i < N; ++i)
	{
		if(animal[i] == 'S'){
			truth[i] = S[i];
		}else{
			if(S[i] == 'o'){
				truth[i] = 'x';
			}else{
				truth[i] = 'o';
			}
		}
		if(i == N-1){
			if(!check(i)){
				return -1;
			}else{
				if((truth[0] == 'o' && animal[N-1] != animal[1]) 
					|| (truth[0] == 'x' && animal[N-1] == animal[1])){
					return -1;
				}
			}
		}else if(i != 0){
			made(i);
		}
	}
	for (int j = 0; j < N; ++j)
	{
		cout << animal[j];
	}
	cout << "\n";
	return 0;
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> S[i];
	}
	for (int i = 0; i < 4; ++i)
	{
		M = max(solve(i),M);
			if(M == 0){
				return 0;
			}
		}
		if(M == -1){
			cout << M << endl;
		}

	#ifdef DEBUG
		debug();
	#endif
	// answer();

		return 0;
	}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 998244353;

int x[maxn], y[maxn];
double dist(int idx1, int idx2) {
  int dx = x[idx1] - x[idx2];
  int dy = y[idx1] - y[idx2];
  return sqrt(dx*dx + dy*dy);
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  double ret = 0;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++){
      double tt = dist(i,j);
      ret+=tt*2;
    }
  ret/=n;
  printf("%.10f\n",ret);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main()
{
	int i;
	int j;
	for(i = 1; i <= 9; i++)
	{
		for(j = 1; j <= 9; j++)
		{
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return 0;
}

Measured memory_bytes: 524
N = int(input())
A = list(map(int, input().split()))
A = [0 if i in [0,N+1] else A[i-1] for i in range(N+2)]

tmpr = 0
for i in range(1,N+2):
	tmpr += abs(A[i]-A[i-1])

for i in range(1,N+1):
	mae = abs(A[i]-A[i-1]) + abs(A[i+1]-A[i])
	ato = abs(A[i+1]-A[i-1])
	sa = mae - ato

	print(tmpr - sa)
	

Measured memory_bytes: 13920
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        string inpt = Reader.ReadLine();

        int idx = inpt.Length - 1;
        while (idx >= 0)
        {
            bool mt = false;
            foreach (string w in words)
            {
                if (idx + 1 < w.Length)
                {
                    continue;
                }
                if (inpt.Substring(idx - w.Length + 1, w.Length).Equals(w))
                {
                    idx -= w.Length;
                    mt = true;
                    break;
                }
            }
            if (!mt)
            {
                break;
            }
        }
        bool ans = idx < 0;

        Console.WriteLine(ans ? "YES" : "NO");
    }

    private string[] words = new string[] { "dream", "dreamer", "erase", "eraser" }.OrderByDescending(a => a.Length).ToArray();


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

   
dreamerer


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 4952
#include<stdio.h>
#define MAX 10000

typedef struct node{
 int id;
 int rootid;
 struct node *up;
}node;



int Getrootid(node N[],int x){
 node *p;

 if(N[x].up==NULL)N[x].rootid=x;

 else{
  p=N[x].up;
  while(p->up != NULL)p=p->up;
  N[x].rootid=p->id;
  N[x].up=p;
 }


return N[x].rootid;
}



int main(){

 int n,q,i;
 int com;
 int x,y;
 node N[MAX];


 scanf("%d %d",&n,&q);

 for(i=0;i<n;i++){
  N[i].id=i;
  N[i].rootid=-1;
  N[i].up=NULL;
 }

 for(i=0;i<q;i++){

   scanf("%d",&com);

   if(com==0){/*unite*/

    scanf("%d %d",&x,&y);
    N[x].rootid=Getrootid(N,x);
    N[y].rootid=Getrootid(N,y);
    if(N[x].rootid != N[y].rootid)
     N[ N[x].rootid ].up=&(N[ N[y].rootid ]);

   }
   else if(com==1){/*same*/

    scanf("%d %d",&x,&y);
    N[x].rootid=Getrootid(N,x);
    N[y].rootid=Getrootid(N,y);
    if(N[x].rootid==N[y].rootid)
     printf("1\n");
    else printf("0\n");

   }

 }

return 0;
}


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

int main(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0; i<n; i++){
        cin>>a[i];
    }
    ll ini = a[0];
    ll countAbtak = 0;
    ll maxcount = 0;
    for(ll i = 1; i<n; i++){
        if(a[i] <= ini){
            //cout<<"in"<<endl;
            countAbtak++;
        }

        if(countAbtak>maxcount){
            maxcount = countAbtak;
        }
        if(a[i] > ini){
            countAbtak = 0;
        }
        ini = a[i];
    }
    cout<<maxcount<<endl;
return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;
 
    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }
 
    private void solve() {
        try {
            long N = scanner.nextLong();
            long A = 1;
            long B = N;
            long min = solveF(A, B);
            for (long i = 2; i <= Math.sqrt(N); i++) {
                if (N % i == 0) {
                    int f = solveF(i, N / i);
                    if (f < min) {
                        min = f;
                    }
                }
            }
            System.out.println(min);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private int solveF (long a, long b) {
        return a > b ? String.valueOf(a).length() : String.valueOf(b).length();
    }
 
    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
 
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }
 
        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }
 
        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
 
        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==0)
    cout<<b/c+1<<endl;
  else
    cout<<b/c-(a-1)/c<<endl;
}

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

// macro-----------------------------------------------------------------------------------------
#define rep(i, a, b) for (int i = a; i < b; i++)
#define int long long
const int inf = 100100100100000;
const int mod = 1000000007;

// general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr) {
    vector<int> ret = arr;
    rep(i, 1, arr.size()) { ret[i] += ret[i - 1]; }
    return ret;
}

// io_method-------------------------------------------------------------------------------------
int input() {
    int tmp;
    cin >> tmp;
    return tmp;
}
string raw_input() {
    string tmp;
    cin >> tmp;
    return tmp;
}
void print(int n) { cout << n << endl; }
void print(vector<int> arr) {
    cout << arr[0];
    rep(i, 1, arr.size()) cout << " " << arr[i];
    cout << endl;
}
void print(string s) { cout << s << endl; }

// main_method-----------------------------------------------------------------------------------

struct edge {
    int from, to, cost;
};
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<edge> edges(m);
    rep(i, 0, m) {
        int a, b, c;
        cin >> a >> b >> c;
        edges[i] = {a - 1, b - 1, -c};
    }

    bool isnc = false;
    vector<int> dist(n, inf);
    dist[0] = 0;

    rep(i, 0, n) {
        rep(j, 0, m) {
            int frm = edges[j].from, to = edges[j].to, cost = edges[j].cost;
            if (dist[frm] != inf && dist[to] > dist[frm] + cost) {
                dist[to] = dist[frm] + cost;
                if (i == n - 1 && to == n - 1)
                    isnc = true;
            }
        }
    }

    if (isnc)
        print("inf");
    else
        print(-dist.back());
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        
        if (a.equals("H")) {
            if (b.equals("H")) {
                System.out.println("H");
            } else {
                System.out.println("D");
        }
        } else {
            if (b.equals("D")) {
            System.out.println("H");
        } else {
            System.out.println("D");
        } 
    }
    }
}


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

int main() {

	int n, m; cin >> n >> m;
	int cnt = m;
	ll tmp = 1;
	while (cnt--) {
		tmp *= 2;
	}
	cout << (1900 * m + (n - m) * 100) * tmp << endl;
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, m, a[101010];
void solve(){
	cin >> n >> m;
	priority_queue<int> q;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		q.push(a[i]);
	}
	
	for(int i = 0; i < m; i++){
		int p = q.top(); q.pop();
		q.push(p/2);
	}
	i64 ans = 0;
	while(!q.empty()){
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1148
#include<iostream>

using namespace std;
int main(){
  int n;
  cin>>n;
  int d[110];
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>d[i];
    int cnt=1;
    if(i>0){
      for(int j=0;j<i;j++){
      if(d[i]==d[j])cnt=0;
      }
    }
    ans+=cnt;
  }
  cout<<ans<<endl;
}
  


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<long long> b(40);
  b[0]=1;
  for(int i=0;i<30;i++)b[i+1]=2*b[i];
  double sum=0;
  int r=1,cn=0;
  while(r<K){r*=2; cn++;}
  //cout << cn << endl;
  for(int i=1;i<=N;i++){
    int cnt=0;
    int I=i;
    while(I<K){cnt++; I*=2;}
    sum+=1.0/b[cnt];
  }
  //cout << sum << endl;
  printf("%.12f\n",sum/N);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }
    vvl dp(n, vl(3, 0));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i = 1; i < n; ++i) {
        dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
        dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
        dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
    }
    ll ret = max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
    cout << ret << "\n";
    return 0;
}

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


using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define sortA(arr)   sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x,n;
    cin>>x>>n;
    vi f(101,0);
    vi arr(n);
    int min=150,value;
    rep(i,0,n){
        cin>>arr[i];
        f[arr[i]]=1;

    }
    rep(i,0,101){
        if(f[i]==0){
            if(abs(i-x)<min)
            {min=abs(i-x);
            value=i;
            }
        }
    }
    if(abs(x+1)<min)
    {
        min=abs(x+1);
        value=-1;
    }
    if(abs(x-101)<min){
        min=abs(x-101);
        value=101;
    }
    cout<<value<<endl;
}


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

int main(){

  string s; cin >> s;
  int cnt = 0;
  rep(i,3){
    if(s[i] == '1') cnt++;
  }

  cout << cnt << endl;
  return 0;
}

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

int main()
{
    string a,b;
    int l,c=0;

    cin>>a>>b;
    l=a.length();

    for(int i=0;i<l;i++){
        if(a[i]!=b[i])c++;
    }
    cout<<c<<endl;
    return 0;
}


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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  vector<vector <int>> vec({{}, {6}, {6,12}, {6,3,9}, {2,4,3,9}
      , {2,4,6,3,9}, {2,4,6,12,3,9}, {2,4,6,8,10,3,9}, {2,4,6,8,10,12,3,9}});

  vector<int> ans;

  int N; cin >> N;
  if (N == 3) {
    ans = vector<int>({2, 3, 25});
  }else {
    int x = N % 8;
    int y = N / 8;
    if (x == 0) {
      for (int i = 0; i < y; i++) {
	for (int t : vec.at(8)) ans.push_back(i * 12 + t);
      }
    }else {
      ans = vec.at(x);
      for (int i = 1; i <= y; i++) {
	for (int t : vec.at(8)) ans.push_back(i * 12 + t);
      }
    }
  }
    
  bool first = true;
  for (int x : ans) {
    if (!first) cout << " ";
    cout << x;
    first = false;
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 636
#!python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ANS = 0
    for a in A:
        while a % 2 == 0:
            a //= 2
            ANS += 1
    print(ANS)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4148
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
ll mod=1000000007;
int main(){
    int n=in();
    vec a(n+1);
    rep(i,n){
        a[i+1]=in();
    }
    vec ans;
    vec b(n+1);
    rep3(i,n,1){
        int tmp=0;
        for(int k=i*2;k<=n;k+=i){
            tmp+=b[k];
        }
        b[i]=(tmp - a[i] + 2) % 2;
        if(b[i]==1)ans.pb(i);
    }
    cout<<ans.size()<<endl;
    for(ll i=ans.size()-1;i>=0;i--){
        cout<<ans[i]<<" ";
    }
}


Measured memory_bytes: 3064
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <sstream>
#include <limits>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
#define PI (acos(-1.0))
#define Abs(a) (((a)<0) ? (-(a)) :(a) )
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i,n) for(int i=((n)-1);i>=0;i--)
#define rrep(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define Pii pair<int,int>
#define PB push_back
#define Size(x) ((int)(x.size()))
using namespace std;
typedef long long mint;
typedef unsigned long long umint;
bool forw[5005][5005], rev[5005][5005];
int a[5005];
int main()
{
    //freopen("in.txt","r",stdin);
    int n, k;
    cin >> n >> k;
    int val;
    int tot = 0;
    Rep(i,n)
    {
        scanf("%d",&val);
        if(val >= k)
        {
            continue;
        }
        a[++tot] = val;
    }
    n = tot;
    forw[0][0] = true;
    for(int i = 1; i <= n; i++)
    {
        for(int j =  0; j < k; j++)
        {
            forw[i][j] = forw[i - 1][j];
            if( j >= a[i] && forw[i - 1][j - a[i]])
            {
                forw[i][j] = true;
            }
        }
    }
    rev[n + 1][0] = true;
    for(int i = n; i > 0; i--)
    {
        for(int j =  0; j < k; j++)
        {
            rev[i][j] = rev[i + 1][j];
            if(j >= a[i] && rev[i + 1][j - a[i]])
            {
                rev[i][j] = true;
            }
        }
    }
    int cnt = n;
    //cout << cnt << endl;
    //cout << n << endl;
    for(int i = 1; i <= n; i++)
    {
        int lo = k - a[i];
        int hi = k - 1;
        int rst = k - 1;
        for(int j = 0 ; j < k; j++)
        {
            if(!forw[i - 1][j])
            {
                continue;
            }
            while(rst >= 0 && (!rev[i + 1][rst] || rst + j >= k))
            {
                rst--;
            }
            if(rst < 0)
            {
                continue;
            }
            if(rst + j >= lo)
            {
                //cout << j <<" "<<rst <<" "<< i << endl;
                //cout << rev[i + 1][rst] << " " << forw[i - 1][j] << endl;
                cnt--;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}



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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
#define fir first
#define sec second

const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

//http://drken1215.hatenablog.com/entry/2019/06/10/143300 写経

int H, W;
vector<string> fi;
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];

int main(void){
	cin>>H>>W;
	fi.resize(H);
	for (int i = 0; i < H; i++) cin>>fi[i];

	for (int i = 0; i < H; i++) {
		int cur = 0;
		for (int j = 0; j < W; j++) {
			if (fi[i][j] == '#') cur = 0;
			else ++cur;
			Left[i][j] = cur;
		}
	}
	for (int i = 0; i < H; i++) {
		int cur = 0;
		for (int j = W - 1; j >= 0; --j) {
			if (fi[i][j] == '#') cur = 0;
			else ++cur;
			Right[i][j] = cur;
		}
	}
	for (int j = 0; j < W; j++) {
		int cur = 0;
		for (int i = 0; i < H; i++) {
			if (fi[i][j] == '#') cur = 0;
			else ++cur;
			Up[i][j] = cur;
		}
	}
	for (int j = 0; j < W; j++) {
		int cur = 0;
		for (int i = H - 1; i >= 0; i--) {
			if (fi[i][j] == '#') cur = 0;
			else ++cur;
			Down[i][j] = cur;
		}
	}

	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (fi[i][j] == '#') continue;
			ans = max(ans, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
		}
	}
	cout<< ans <<endl;
	
	return 0;
}

Measured memory_bytes: 72448
#include <cstdio>
#include <iostream>

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

int main()
{
    int a, b;
    std::cin >> a >> b;
    printf("%d\n", gcd(a, b));

    return 0;
}

Measured memory_bytes: 3148
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



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

    int m = 0;
    int l, r;
    for (int i = 0; i < N; ++i) {
        cin >> l >> r;
        m += r - l + 1;
    }

    cout << m << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n;
	cin>>n;
	set <long long int> st;
	long long int x;
 	for(long int i=0;i<n;i++){
 		cin>>x;
 		st.insert(x);
	 }
	 if(st.size()==n)
	 cout<<"YES";
	 else
	 cout<<"NO";
	 return 0;
}

Measured memory_bytes: 9600
#include<stdlib.h>
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a >= 1 && a <= 9&&b >= 1 && b <= 9)
			printf("%d", a * b);
		else
			printf("-1");
	return 0;
}

Measured memory_bytes: 128
// AOJ ALDS1_10_C Longest Common Subsequence

#include <algorithm>
#include <iostream>

using namespace std;

// returns the length of the longest common subsequence
// of x[i:n] and y[j:m]
int llcs(string x, string y) {
  int n = x.length();
  int m = y.length();
  int dp[n + 1][m + 1];
  for (auto arr : dp) {
    fill(arr, arr + m + 1, 0);
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int j = m - 1; j >= 0; --j) {
      int res = -1;
      res = max(dp[i + 1][j], dp[i][j + 1]);
      if (x[i] == y[j])
        res = max(res, dp[i + 1][j + 1] + 1);
      dp[i][j] = res;
    }
  }
  return dp[0][0];
}

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

  string x, y;
  // print length of longest common subsequence of x and y
  while (cin >> x >> y) {
    cout << llcs(x, y) << endl;
  }
}


Measured memory_bytes: 7104
y=raw_input()
f=0
if y.count('N')>0:
	if y.count('S')==0:
		f=1

if y.count('S')>0:
	if y.count('N')==0:
		f=1

if y.count('E')>0:
	if y.count('W')==0:
		f=1


if y.count('W')>0:
	if y.count('E')==0:
		f=1

if f:
	print "No"
else:
	print "Yes"


Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,m,d[100010],ans;
vector<int>v[100010];
int dfs(int x){
    if(d[x]>0)return d[x];
    int res=0;
    for(int i:v[x])chmax(res,dfs(i)+1);
    d[x]=res;
    return res;
}
signed main(){
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].pb(b);
    }
    rep(i,n)if(d[i]==0)chmax(ans,dfs(i));
    cout<<ans<<endl;
    return 0;
}

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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

void solve(int N, int K, string S) {
	S[K-1] = tolower(S[K-1]);
	cout << S << '\n';

    return;
}

signed main() {
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    
    solve(N, K, S);
    
    return 0;
}



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

int h,w;
char a[8][8];
string ans;

void input(){
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
}
string solve(){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			for(int k=0;k<h;k++){
				for(int l=0;l<w;l++){
					if(a[i][j]=='#'&&a[k][l]=='#'&&i<k&&j>l){
						return "Impossible";
					}
				}
			}
		}
	}
	return "Possible";
}

int main() {
	input();
	ans=solve();
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def func(s, r=0, t=0):
    if len(s)==1:
        return int(s)+r+t
    else:
        a = func(s[1:], (int(s[0])+r)*10, t)
        b = func(s[1:], 0, int(s[0])+r+t)
        return a+b

s, = [list(map(int, s.split())) for s in open(0)][0]
s = str(s)

ans = func(s)
print(ans)

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

int main() {
    int n,m;
    cin >> n >> m;
    int ans = 1;
    for(int i = m / n; i > 0; i--)
    {
        if (m % i == 0) {
            if (m % i <= n) {
                ans = i;
                break;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int p = Integer.parseInt(sc.next());
		
		int ans =  (3 * a + p) / 2;
		
		System.out.println(ans);
	
	}
}


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

ll a[100000];
ll b[100000];

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

	int N, x;
	cin >> N >> x;
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		b[i] = a[i];
	}

	ll s1 = 0, s2 = 0;
	for(int i = 1; i < N; i++) {
		if(a[i - 1] + a[i] <= x) continue;
		ll d = (a[i - 1] + a[i]) - x;
		s1 += d;
		a[i] = max(0LL, a[i] - d);
	}


	cout << s1 << endl;
}

Measured memory_bytes: 1920
import java.util.Scanner;
import java.util.Deque;
import java.util.LinkedList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> deque = new LinkedList<>();
		String tmp = "";
		while (sc.hasNext()) {
			switch ((tmp = sc.next()).charAt(tmp.length() - 1)) {
				case '+':
					deque.push(deque.poll() + deque.poll());
					break;
				case '-':
					int n = deque.poll();
					deque.push(deque.poll() - n);
					break;
				case '*':
					deque.push(deque.poll() * deque.poll());
					break;
				default:
					deque.push(Integer.parseInt(tmp));
					break;
			}
		}
		System.out.println(deque.poll());
	}
}



Measured memory_bytes: 26244
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		TreeSet<Segment> left = new TreeSet<Segment>((s1, s2) -> {
			int cmp = Integer.compare(s2.left, s1.left);
			if (cmp != 0) return cmp;
			return Integer.compare(s1.id, s2.id);
		});
		TreeSet<Segment> right = new TreeSet<Segment>((s1, s2) -> {
			int cmp = Integer.compare(s1.right, s2.right);
			if (cmp != 0) return cmp;
			return Integer.compare(s1.id, s2.id);
		});
		int tmp1, tmp2;
		for (int i = 0; i < N; i++) {
			tmp1 = sc.nextInt();
			tmp2 = sc.nextInt();
			Segment segment = new Segment(tmp1, tmp2, i);
			left.add(segment);
			right.add(segment);
		}
		long ans = calc(new TreeSet<>(left), new TreeSet<>(right), 0, true);
		ans = Math.max(ans, calc(left, right, 0, false));
		out.println(ans);
		
		out.flush();
	}
	
	static final int NONE = 10000000;
	
	static long calc(TreeSet<Segment> left, TreeSet<Segment> right, int pos, boolean leftTurn) {
		long ret = 0;
		int nPos = NONE;
		if (leftTurn) {
			if (!left.isEmpty()) {
				Segment seg = left.pollFirst();
				if (pos < seg.left) {
					ret += seg.left - pos;
					right.remove(seg);
					nPos = seg.left;
				}
			}
		} else {
			if (!right.isEmpty()) {
				Segment seg = right.pollFirst();
				if (seg.right < pos) {
					ret += pos - seg.right;
					right.remove(seg);
					nPos = seg.right;
				}
			}
		}
		if (nPos == NONE) {
			ret += Math.abs(pos);
		} else {
			ret += calc(left, right, nPos, !leftTurn);
		}
		return ret;
	}
	
	static class Segment {
		int left, right, id;
		
		public Segment(int left, int right, int id) {
			this.left = left;
			this.right = right;
			this.id = id;
		}
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 76488
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3664
mod=10**9+7
a,b=map(int,input().split())

if abs(a-b)>=2:
    print(0)
    exit()

ans=1
for i in range(2,a+1):
    ans*=i
    ans%=mod

for i in range(2,b+1):
    ans*=i
    ans%=mod

if a==b:
    ans*=2
    ans%=mod

print(ans)

Measured memory_bytes: 63768
# 初期入力
N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))
A =list(map(lambda x:x*(-1),A))     #最大値を取り出すため―１を掛ける
import heapq  # heapqライブラリのimport
heapq.heapify(A)  #         リストを優先度付きキューへ
m=0
for i in range(M):
    a=heapq.heappop(A)  #       最大値の取り出し
    a //=-2             # 負の値を2で割り切り捨てると、絶対値が大きくなる。
    heapq.heappush(A, -a) #正の値で2で割り、戻すとき負にする
    #print(A)

A_sum =sum(A)
A_sum *=(-1)
print(A_sum)

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

static const auto do_fast_io = [] {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return nullptr;
}();

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

/**
 * References
 */


Measured memory_bytes: 3640