akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){int N;cin>>N;vector<int>a(N);for(int i=0;i<N;i++)cin>>a.at(i);
           sort(a.begin(),a.end());int x=0;for(int i=0;i<N;i++){if((i+1)%2)x+=a.at(i);if(i%2)x-=a.at(i);}
x=abs(x);cout<<x<<endl;}

Measured memory_bytes: 256
import numpy as np

n = int(input())
x = np.array(input().split(),dtype=np.int64)

shouhiHP = 1001001001000
for k in range(min(x),max(x)+1):
    xHP = x - k
    xHP2jou = xHP ** 2
    sum_xHP = sum(xHP2jou)
    if sum_xHP < shouhiHP:
        shouhiHP = sum_xHP
    else:
        pass

print(shouhiHP)

Measured memory_bytes: 12504
n = int(input())

ans = [50]*26

al = list("abcdefghijklmnopqrstuvwxyz")

for i in range(n):
    t = input()
    for s in range(26):
        ans[s] = min(ans[s],t.count(al[s]))
        
for i in range(26):
    for t in range(ans[i]):
        print(al[i],end = "")

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

#define MAX 10000
#define INF INT_MAX
#define WHITE 0
#define GRAY 1
#define BLACK 2

vector<pair<int, int> > M[MAX];
int n;
int col[MAX];
int d[MAX];

void init() {
	for (int i = 0; i < n; i++) {
		col[i] = WHITE;
		d[i] = INF;
	}
}
void input() {
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v, c;
			cin >> v >> c;
			M[u].push_back(make_pair(v, c));
		}
	}
}
void dijkstra(int s) {
	d[s] = 0;
	priority_queue<pair<int, int> > PQ;
	PQ.push(make_pair(d[s] * (-1), s));
	col[s] = GRAY;
	while (!PQ.empty()) {
		pair<int, int> f = PQ.top();
		PQ.pop();
		int u = f.second;
		col[u] = BLACK;
		if (d[u] < f.first * (-1))
			continue;
		for (int j = 0; j < M[u].size(); j++) {
			int v = M[u][j].first;
			if (col[v] != BLACK) {
				if (d[u] + M[u][j].second < d[v]) {
					d[v] = d[u] + M[u][j].second;
					col[v] = GRAY;
					PQ.push(make_pair(d[v] * (-1), v));
				}
			}
		}
	}
}
void output() {
	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << endl;
	}
}

int main() {
	cin >> n;
	init();
	input();
	dijkstra(0);
	output();
	return 0;
}



Measured memory_bytes: 8080
import math
import fractions
from functools import reduce

n, m = map(int,input().split())
a = list(map(int,input().split()))
a = [t // 2 for t in a]#リストの要素すべてを2で割る

def lcm_base(x, y):
    return (x * y)//fractions.gcd(x,y)

def lcm_list(numbers): #最小公倍数を求める
    return reduce(lcm_base, numbers, 1)

def num_dev2(x):
    return bin(x)[::-1].find("1") #２で割り切れる回数を確認

lcm = lcm_list(a)
q = m//lcm #mは最小公倍数で何回割れるか

count = 0
dev2 = num_dev2(a[0])
for i in range(1,n):
    if dev2 != num_dev2(a[i]):#リストのすべての要素の２で割れる回数は等しいか
        count += 1
        break
if count != 0:
    print(0)
else:
    print(math.ceil(q/2))

Measured memory_bytes: 16348
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		sc.close();
		boolean f=false;
		for(i=1;i<10;i++) {
			if(n%i==0) {
				if(n/i<10) {
					f=true;
					break;
				}
			}
		}
		out.println(f?"Yes":"No");
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int def;
  def = 3*max({a,b,c})-a-b-c;
  if(def%2==0){
    cout << def/2 << "\n";
  }
  else{
    cout << (def+1)/2+1 << "\n";
  }


  return 0;
}


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

int N, A, B, C;
string moves[100005];

string ans = "";
void move(int i)
{
	if(moves[i] == "AB")
	{
		if(A < B)
		{
			A++;
			B--;
			
			ans += "A\n";
		}
		
		else if(B < A)
		{
			B++;
			A--;
			
			ans += "B\n";
		}
		
		else
		{
			if(A == 1 && B == 1)
			{
				if(C == 0 && moves[i + 1] == "AC")
				{
					A++;
					B--;
					
					ans += "A\n";
				}
				
				else
				{
					A--;
					B++;
					
					ans += "B\n";
				}
			}
			
			else
			{
				A++;
				B--;
				
				ans += "A\n";
			}
		}
		
		if(A < 0 || B < 0 || C < 0)
		{
			printf("No");
			exit(0);
		}
	}
	
	else if(moves[i] == "BC")
	{
		if(B < C)
		{
			B++;
			C--;
			
			ans += "B\n";
		}
		
		else if(C < B)
		{
			C++;
			B--;
			
			ans += "C\n";
		}
		
		else
		{
			if(B == 1 && C == 1)
			{
				if(A == 0 && moves[i + 1] == "AB")
				{
					B++;
					C--;
					
					ans += "B\n";
				}
				
				else
				{
					C++;
					B--;
					
					ans += "C\n";
				}
			}
			
			else
			{
				B++;
				C--;
				
				ans += "B\n";
			}
		}
		
		if(A < 0 || B < 0 || C < 0)
		{
			printf("No");
			exit(0);
		}
	}
	
	else
	{
		if(A < C)
		{
			A++;
			C--;
			
			ans += "A\n";
		}
		
		else if(C < A)
		{
			C++;
			A--;
			
			ans += "C\n";
		}
		
		else
		{
			if(A == 1 && C == 1)
			{
				if(B == 0 && moves[i + 1] == "BC")
				{
					C++;
					A--;
					
					ans += "C\n";
				}
				
				else
				{
					A++;
					C--;
					
					ans += "A\n";
				}
			}
			
			else
			{
				A++;
				C--;
				
				ans += "A\n";
			}
		}
		
		if(A < 0 || B < 0 || C < 0)
		{
			printf("No");
			exit(0);
		}
	}
}

int main()
{
	scanf("%d%d%d%d", &N, &A, &B, &C);
	
	for(int i = 1; i <= N; i++)
	{
		cin >> moves[i];
	}
	
	for(int i = 1; i <= N; i++)
	{
		move(i);
	}
	
	printf("Yes\n");
	printf("%s", ans.c_str());
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define pl pair<ll, ll>
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define f(i,a, b) for (ll i = a; i < b; i++)
#define ft int t; cin>>t; while(t--)
#define mp make_pair
#define pb push_back
#define ld float
#define fd(i,a, b) for (ll i = a; i >= b; i--)
#define nl "\n"
 /*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
     typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/

 ull powm(ull a,ull b){

   ull res=1;

   while(b){
     if(b%2)res=(res*a);
     a=(a*a);
     b/=2;
   }

 return res;
 }


int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
 ll n,m;
 cin>>n>>m;
 ll sm=0,pp;
 f(i,0,m) {cin>>pp; sm+=pp;}
 cout<<max(-1LL,n-sm);
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 200005
using namespace std;
typedef long long ll;
int n,x[N],f[N];
pii a[N],b[N];
int main(){
//	freopen("11.txt","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].xx,&a[i].yy),x[i]=a[i].yy;
	sort(a+1,a+1+n),sort(x+1,x+1+n);
	int mx=0;
	for(int i=1;i<=n;i++){
		mx=max(mx,a[i].yy);
		b[i].yy=lower_bound(x+1,x+1+n,mx)-x;
	}
	mx=inf;
	for(int i=n;i;i--){
		mx=min(mx,a[i].yy);
		b[i].xx=lower_bound(x+1,x+1+n,mx)-x;
	}
	sort(b+1,b+1+n);
	int ans=0;
	for(int i=1,j=1,tot=0,s=0;i<=n;i++){
		while(b[j].yy+1<b[i].xx)s=(s+f[j])%dalao,j++;
		f[i]=(tot-s+dalao)%dalao;
		if(b[i].xx==1)f[i]++;
		tot=(tot+f[i])%dalao;
		if(b[i].yy==n)ans=(ans+f[i])%dalao;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
from collections import defaultdict
N, M  = map(int, input().split())
li1 = []
li2 = []
for i in range(N):
    A = list(map(int, input().split()))
    li1.append(A)
U = 300
L = 0
while U-L > 1:
    m = (U+L)//2
    li = [0] * M
    flag = False
    while not flag:
        d = defaultdict(int)
        if not 0 in li:
            break
        for i in range(N):
            for j in range(M):
                if li[li1[i][j]-1] == 0:
                    d[li1[i][j]] += 1 #dのkeyは競技
                    break
        f = True
        for k in d:
            if d[k] > m:
                li[k-1] = 1
                f = False
        if f:
            flag = True
    if flag:
        U = m
    else:
        L = m
print(U)

Measured memory_bytes: 46684
N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
    w_,v_=map(int,input().split())
    w.append(w_)
    v.append(v_)
INF=10**9
dp=[[0]*(W+1) for i in range(N+1)]#dp[i+1][j] i個目までで容量jのときの最大の価値
#dp[i+1][w]:=max(dp[i][w-wi],dp[i][w])加えるか加えないか
for i in range(N):
    for j in range(1,W+1):
        if j-w[i]>=0:
            dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i+1][j])
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])
ans=0
for j in range(W+1):
    ans=max(ans,dp[N][j])
print(ans)


Measured memory_bytes: 120684
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
 
using namespace std;
 
int main(){
    int n;
    int nums[6000] = {0};
    
    int qf = 0;
    int qe = 0;
    for(int i = 2; i <= 50100; i++){
        bool f = false;
        for(int qe = 0; qe < qf; qe++ ){
            if(i < nums[qe] * nums[qe]) break; //この行で速さが変わる（爆速）
            if(i % nums[qe] == 0) {
                f = true;
                break;
            }
        }
        if(!f) { nums[qf] = i; qf++; }
    }

    while(cin >> n){
        int index = 0;
        while(true){
            if(nums[index + 1] == n) {
                cout << nums[index] << " " << nums[index + 2] << endl;
                break;
            }
            if(nums[index] <= n && nums[index + 1] >= n) {
                cout << nums[index] << " " << nums[index + 1] << endl;
                break;
            }
            index++;
        }
    }
    return 0;
}

Measured memory_bytes: 1192
N = int(input())
HPs = [tuple(map(int, input().split())) for i in range(N)]

HPs.sort(key=lambda x: x[0] + x[1])

dp = {0: 0}
for H, P in HPs:
    for num, minH in list(dp.items()):
        if H >= minH:
            if num + 1 in dp:
                dp[num + 1] = min(dp[num + 1], minH + P)
            else:
                dp[num + 1] = minH + P

print(max(dp.keys()))


Measured memory_bytes: 57712
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

    sort(p.begin(),p.end(),greater<int>());
    p[0] /= 2;
    int price = 0;
    rep(i,n) price += p[i];

    cout << price << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		boolean x, y, z;
		a: while(true) {
			x = y = z = false;
			int a[] = new int[5];
			for (int i = 0; i < 5; i++) {
				a[i] = stdIn.nextInt();
				if (a[i] == 0)
					break a;
			}
			for (int i = 0; i < 5; i++) {
				if (a[i] == 1) {
					x=true;
				}
				if (a[i] == 2) {
					y=true;
				}
				if (a[i] == 3) {
					z=true;
				}
			}
			if ((x && y && z) || (x && !y && !z) || (!x && y && !z) || (!x && !y && z)) {
                for (int i = 0; i < 5; i++) {
                    System.out.println("3");
                }
            } else {
                if (x && y && !z) {
                    for (int i = 0; i < 5; i++) {
                        if (a[i] == 1) {
                            System.out.println("1");
                        } else {
                            System.out.println("2");
                        }
                    }
                } else if (x && !y && z) {
                    for (int i = 0; i < 5; i++) {
                        if (a[i] == 3) {
                            System.out.println("1");
                        } else {
                            System.out.println("2");
                        }
                    }
                } else if (!x && y && z) {
                    for (int i = 0; i < 5; i++) {
                        if (a[i] == 2) {
                            System.out.println("1");
                        } else {
                            System.out.println("2");
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 28684
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        string DataSet;
        string[] Data;
        List<int> AddLen = new List<int>();
        while((DataSet = Console.ReadLine()) != null){
            Data = DataSet.Split(' ');
            AddLen.Add((int.Parse(Data[0]) + int.Parse(Data[1])).ToString().Length);
        }
        for(int i = 0; i < AddLen.Count; i++){
            Console.WriteLine(AddLen[i]);
        }
    }
}

Measured memory_bytes: 9196
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T, vector<T>, greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16, mod2 = 998244353;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}


signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0LL, c - (a - b)) << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func main() {
	sc := NewScanner()
	N, M := sc.nextInt(), sc.nextInt()
	A := make([]string, N)
	B := make([]string, M)
	for i := 0; i < N; i++ {
		A[i] = sc.nextStr()
	}
	for i := 0; i < M; i++ {
		B[i] = sc.nextStr()
	}
	for i := 0; i+M-1 < N; i++ {
		for j := 0; j+M-1 < N; j++ {
			res := true
			for k := 0; k < M; k++ {
				a := A[i+k][j : j+M]
				b := B[k][0:M]
				// fmt.Println(i, j, k, a, b)
				if a != b {
					res = false
				}
			}
			if res {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

const double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x;

long double f(long double a, long double b, long double theta) {
    if(theta > PI / 2.0 - EPS) {
        return 0.0;
    }
    long double ret;
    if(a * tan(theta) <= b) {
        ret = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        ret = b * b / tan(theta) * a / 2.0;
    }
    return ret;
}

void solve(){
    long double ok = PI / 2.0;
    long double ng = 0.0;
    for(int _ = 1; _ <= 100000; _++){
        long double mid = (ok + ng)/2.0;
        if(f(a, b, mid) < x) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(10) << ok / PI * 180 << endl;
    return ;
}

int main()
{
    cin >> a >> b >> x;
    solve();
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
using namespace std;

int main()
{
    ll t,n,m,i,j,k,x,y,u,v,l,r;
    cin >> n;
    cout << (n-2)*180;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    map<int, int> m;
    rep(i,n) {
        int num; cin >> num;
        m[num]++;
    }
    bool flag = true;
    if(n%2==0){
        for(auto a : m){
            if(a.second!=2) flag = false;
            if(a.first%2==0) flag = false;
        }
    }else{
        for(auto a : m){
            if(a.first%2==1) flag = false;
            else{
                if(a.second==1){
                    if(a.first!=0) flag = false;
                }else if(a.second!=2) flag = false;
            }
        }
    }

    ll ans = 1;
    rep(i,n/2){
        ans = (ans*2)%1000000007;
    }
    if(flag) cout << ans << endl;
    else cout << 0 << endl;

    return 0;
}

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

// #define int long long

/* short */
#define pb push_back
#define print(Target) cout << Target << '\n'

/* REPmacro */
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

/* const */
const int INF = INT_MAX;

signed main()
{
  ios::sync_with_stdio(false);
  string s;

  while (getline(cin, s), s != ""){
    for (;s.find("the") == -1 && s.find("this") == -1 && s.find("that") == -1;){
      REP(i, s.size()){
        if ('a' <= s[i] && s[i] <= 'y'){
          s[i]++;
        } else if (s[i] == 'z'){
          s[i] = 'a';
        }
      }
    }
    print(s);
  }
  
  return (0);
}

Measured memory_bytes: 1176
import sys
stdin = sys.stdin


h,w = map(int, stdin.readline().split())
grid = [list(map(int, stdin.readline().split())) for _ in range(h)]

for hi in range(h):
    for wj in range(w):
        grid[hi][wj] %= 2

ans_list = []
# 奇数を左に流す
for hi in range(h):
    for wj in range(w-1):
        if grid[hi][wj] == 1:
            grid[hi][wj] = 0
            grid[hi][wj+1] = (grid[hi][wj+1]+1) % 2
            ans_list.append((hi+1, wj+1, hi+1, wj+2))


# 奇数を下に流す
for hi in range(h-1):
    if grid[hi][-1] == 1:
        grid[hi][-1] = 0
        grid[hi+1][-1] = (grid[hi+1][-1]+1) % 2
        ans_list.append((hi+1, w, hi+2, w))
        


# 結果を表示する
print(len(ans_list))
for ans in ans_list:
    print(*ans)

Measured memory_bytes: 27184
package main

import (
	"bufio"
	"fmt"
	"os"
)

var N, M int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &M)

	as := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	nums := make(map[int]int)
	accs := make([]int, N+1)
	nums[0]++
	for i := 1; i < N+1; i++ {
		accs[i] = (accs[i-1] + as[i-1]) % M
		nums[accs[i]]++
	}

	ans := 0
	for _, count := range nums {
		if count > 1 {
			ans = ans + combination(count, 2)
		}
	}
	fmt.Println(ans)
}

func combination(a, b int) int {
	if a-b < b {
		return combination(a, a-b)
	}
	prod := 1
	for i := 0; i < b; i++ {
		prod = prod * (a - i)
	}
	f := factorial(b)
	return prod / f
}

func power(a, pow int) int {
	if pow == 1 {
		return a
	} else if pow%2 == 0 {
		rt := power(a, pow/2)
		return rt * rt
	} else {
		return a * power(a, pow-1)
	}
}

func factorial(n int) int {
	ret := 1
	for n >= 1 {
		ret = ret * n % M
		n--
	}
	return ret
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
//#include<ext/rope>
//using namespace __gnu_cxx
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds;
#define lowbit(x) (x&-x)
#define pb push_back
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
#define clr(a,b) memset(a,b,sizeof(a))
#define caze(T) for(cin>>T;T;T--)
#define inf (1<<29)
#define Endl ('\n')
#define fi first
#define se second
#define db double
#define ldb long double
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
inline char nc() {
	#define SZ 1000000
	static char buf[SZ], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline int scan(T &x) {
	char c, sign=1; 
	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;
	if(c==EOF) return EOF;
	for(x = 0; isdigit(c); c = nc())
		x = (x<<1) + (x<<3) + (c&15);
	return x *= sign, 1;
}
template<typename T, typename...Args>
inline int scan(T &x, Args&...args) {
	return scan(x), scan(args...);
}
int main()
{IOS;
	int n,k;cin>>n>>k;
	vector<int>v[2];
	int c[2]={0,0};
	v[0].pb(0);v[1].pb(0);
	for(int i=0,x;i<n;++i)
	{
		cin>>x;int t=x<0?0:1;
		if(!x){--k;continue;}
		x=abs(x);
		c[t]++;
		v[t].pb(x);
	}
	sort(all(v[0]));
	int ans=1<<30;
	for(int i=0;i<=min(c[0],k);++i)
		if(k-i<=c[1])
			ans=min(ans,v[0][i]+v[1][k-i]+min(v[0][i],v[1][k-i]));
	cout<<ans<<Endl;
}

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

int main() {
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(b-a<=k&&c-a<=k&&d-a<=k&&e-a<=k
    &&c-b<=k&&d-b<=k&&e-b<=k&&d-c<=k&&
    e-c<=k&&e-d<=k)
    cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
}

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

using namespace std;

typedef long long ll;

ll a[100005],b[100005];
int q[100005];

int main() {
  int n,s;
  scanf("%d%d",&n,&s);
  int id=0;
  for(int i=1;i<=n;i++) {
  	scanf("%lld%lld",&a[i],&b[i]);
  	if (a[i]<s) id=i;
  }
  int cnt=0,l=1,r=n;
  while ((l<=id)^(r<=id))
    if (b[l]>=b[r]) {
    	q[++cnt]=a[r];
    	b[l]+=b[r];
    	r--;
	}
	else {
		q[++cnt]=a[l];
		b[r]+=b[l];
		l++;
	}
  if (r<=id) {
  	for(int i=l;i<=r;i++) q[++cnt]=a[i];
  }
  else {
  	for(int i=r;i>=l;i--) q[++cnt]=a[i];
  }
  q[cnt+1]=s;
  ll ans=0;
  for(int i=1;i<=cnt;i++) ans+=abs(q[i]-q[i+1]);
  printf("%lld\n",ans);
  return 0;
}

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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(b, n * a) << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n;
    std::cin >> n;

    vll v(n);
    for (ll i = 0; i < n; i++)
        std::cin >> v[i];

    std::map<ll, ll> emap, omap;
    for (ll i = 0; i < n; i++)
        ~i & 1 ? emap[v[i]]++ : omap[v[i]]++;

    vpll e; for (auto i : emap) e.push_back({ i.first, i.second });
    vpll o; for (auto i : omap) o.push_back({ i.first, i.second });

    auto compare = [](pll x, pll y) -> bool {
        return x.second != y.second ? x.second > y.second
                                    : x.first < y.first;
    };

    std::sort(e.begin(), e.end(), compare);
    std::sort(o.begin(), o.end(), compare);

    auto func = [&](auto &func, ll x, ll y) -> ll {
        if (e[x].first == o[y].first) {
            ll res = -1;
            if (x + 1 < e.size()) chmax(func(func, x + 1, y), res);
            if (y + 1 < o.size()) chmax(func(func, x, y + 1), res);

            if (res == -1) return n / 2;
            return res;
        }

        return e[x].second + o[y].second;
    };

    ll ans = n - func(func, 0, 0);

    std::cout << ans << '\n';
}


Measured memory_bytes: 12440
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a)+min(b)
for i in range(M):
    X, Y, C = map(int, input().split())
    if(ans > a[X-1]+b[Y-1]-C):
        ans = a[X-1]+b[Y-1]-C

print(ans)

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

public class Main {

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        StringBuilder s = new StringBuilder();
        
        for(int i = 0; i < str.length(); i++){
        if(Character.isUpperCase(str.charAt(i))){
          
 s.append(Character.toLowerCase(str.charAt(i)));
        }else if((Character.isLowerCase(str.charAt(i)))){
            s.append(Character.toUpperCase(str.charAt(i)));
        }else{
            s.append(str.charAt(i));
        }
            }
        String str2 = s.toString();
        System.out.println(str2);
    }
    
}

Measured memory_bytes: 24356
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int k; cin >> k;
    if (k % 2 == 0) {
        cout << k * k / 4 << endl;
    } else {
        cout << (k / 2) * (k / 2 + 1) << endl;
    }
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

#define log2(x) (31 - __builtin_clz(x))

int n;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n;
  if (n == (1 << log2(n))) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  cout << 1 << " " << 2 << "\n";
  for (int i = 2; i < n; i += 2) {
    cout << i << " " << i + 1 << "\n";
    cout << i + 1 << " " << n + 1 << "\n";
    cout << n + 1 << " " << n + i << "\n";
    cout << n + i << " " << n + i + 1 << "\n";
  }
  if (n % 2 == 0) {
    int a = (1 << log2(n));
    int b = n ^ a ^ 1;
    cout << n << " " << n + a << "\n";
    cout << n + n << " " << b << "\n";
  }
}


Measured memory_bytes: 2816
import sys
input = sys.stdin.readline

N,W = map(int,input().split())
v = [0]
w = [0]
for _ in range(1,N+1):
    a,b = map(int,input().split())
    v.append(a)
    w.append(b)

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,W+1):
        if j >= w[i]:
            dp[i][j] = max(dp[i-1][j],dp[i][j-w[i]] + v[i])
        else:
            dp[i][j] = dp[i-1][j]

print (dp[N][W])


Measured memory_bytes: 16132
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U>& p) {
  os << p.first << " " << p.second;
  return os;
}
template<typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template<typename T>
ostream &operator<<(ostream &os, const vector< T > &v) {
  rep(i, v.size())
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T>
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}
#line 2 "c.cpp"

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

  if (n > k) n %= k;
  ll ans = n;
  ll d = abs(n-k);
  cmin(ans, d);
  cmin(ans, abs(k-d));
  if (k == 1) ans = 0;
  cout << ans << el;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n, k;cin>>n>>k;
  vector<int> v(n);
  for(auto &e: v)cin>>e;
  vector<int> r(n), l(n);
  r[0]=v[0];l[0]=v[n-1];
  for(int i=1;i<n;i++){
  	r[i]=r[i-1]+v[i];
    l[i]=l[i-1]+v[n-1-i];
  }
  int ans=0;
  for(int t=1;t<=min(n, k);t++){
  	for(int right=0;right<=t;right++){
      int count=(right==0?0:r[right-1])+(right==t?0:l[t-right-1]);
      vector<int> tmp;tmp.assign(&v[0], &v[right]);
      tmp.insert(tmp.end(), v.end()-(t-right), v.end());
      // for(auto &e: tmp)cout<<e<<" ";cout<<endl;
      // cout<<"count: "<<count<<" ";
      sort(tmp.begin(), tmp.end());
      for(int i=0;i<min(t, k-t);i++){
      	count -= min(0, tmp[i]);
      }
      // cout<<count<<endl;
      ans = max(ans, count);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
# include<stdio.h>
int main()
{
	char str[100];
	int i,t=1;
	gets(str);
	for(i=0;str[i]!='\0';i++)
	{
		if((i+1)%2!=0)
		{
	    	if(str[i]!='R'&&str[i]!='U'&&str[i]!='D')
			{
				t=0;
				break;
			}
		}
		if((i+1)%2==0)
		{
			if(str[i]!='L'&&str[i]!='U'&&str[i]!='D')
			{
				t=0;
				break;
			}
		}
	}
	if(t==0)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}




Measured memory_bytes: 128
// Here we preserve all points of hull
//assuming no overlapping points, else use set to distinguish points first
//verified against CGL_4_A AOJ
#include <bits/stdc++.h> 
using namespace std; 

struct point {
  int x;
  int y;
  point() : x(0), y(0) { }
  point(int _x, int _y) : x(_x), y(_y) { }
  bool operator < (const point &b) const {
    return x < b.x || (x == b.x && y < b.y);
  } 
};

string to_string(const point& p) {
  return "{" + to_string(p.x) + ", " + to_string(p.y) + "}";
}

ostream& operator<<(ostream& out, const point& p) {
  out << to_string(p);
  return out;
}
 
istream& operator>>(istream& in, point& p) {
  in >> p.x >> p.y;
  return in;
}

int euclid(point p1, point p2) { 
  int x1 = p1.x;
  int y1 = p1.y;
  int x2 = p2.x;
  int y2 = p2.y;
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); 
}  

const int L = -1;
const int S = 0;
const int R = 1; 
int orientation(const point &p, const point &q, const point &r) { 
  int val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); 
  if (val == 0) return S;
  return (val > 0) ? R : L;
}  

vector <point> graham(vector <point> &arr) { 
  int n = arr.size();  
  int ymin = arr[0].y, start = 0; 
  for (int i = 1; i < n; i++) { 
    int y = arr[i].y; 
    if ((y < ymin) || (ymin == y && arr[i].x < arr[start].x)) {
      ymin = arr[i].y;
      start = i; 
    }
  }
  auto swap = [&] (point &p1, point &p2) { 
    point temp = p1; 
    p1 = p2; 
    p2 = temp;
  }; 
  swap(arr[0], arr[start]);
  point p0 = arr[0]; 
  auto comp = [&](const point &p1, const point &p2) { 
    int o = orientation(p0, p1, p2); 
    if (o == S) return euclid(p0, p1) < euclid(p0, p2);
    return o == L;
  };
  sort(arr.begin() + 1, arr.end(), comp); 
  stack<point> st; 
  st.push(arr[0]); 
  st.push(arr[1]); 
  auto prev = [&]() { 
    point p = st.top(); 
    st.pop(); 
    point res = st.top(); 
    st.push(p); 
    return res; 
  };  
  for (int i = 2; i < n; i++) {  
    while (st.size() > 1 && orientation(prev(), st.top(), arr[i]) == R) {
      st.pop(); 
    }
    st.push(arr[i]); 
  } 

  point left_top = st.top();
  vector <point> left_wall;
  for (int i = n - 2; i >= 1; i--) {
    if (orientation(p0, left_top, arr[i]) == S) {
      left_wall.push_back(arr[i]);
    } 
  }

  vector <point> ans;
  while (!st.empty()) { 
    point p = st.top(); 
    ans.push_back(p);
    st.pop(); 
  }
  reverse(ans.begin(), ans.end());

  for (point p : left_wall) {
    ans.push_back(p);
  }
  return ans; 
} 

// Driver program to test above functions 
int main() { 
  cout << fixed;
  cout << setprecision(12);

  int n;
  cin >> n;
  vector <point> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i].x >> arr[i].y;
  } 
  vector <point> ans = graham(arr); 
  cout << ans.size() << endl;
  for (int i = 0; i < (int) ans.size(); i++) {
    cout << ans[i].x << " " << ans[i].y << endl; 
  }
  return 0; 
} 



Measured memory_bytes: 4996
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int max = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    if(s[s.length()-1] == 's')
    cout << s << "es";

    else
    cout << s << "s";
}


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

int main(){
  string S,T;
  cin >> S >> T;
  int ans=0;
  for(int i=0;i<3;i++){
    if(S.at(i)==T.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
#define MOD 1000000007
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = 2147493647;
const double pi = acos(-1);
const double EPS = 1e-9;

struct node {
	node* left = NULL;
	node* right = NULL;
	ll atl, atr, val;
	ll lazy = 0;
	ll mn,mx;
	node(node* l, node* r, int v, int al, int ar) {
		left = l; right = r; val = v;
		atl = al; atr = ar; mn = v; mx = v;
	}
	void lazyupdate(int l, int r, ll by) {
		if(lazy != 0) propagate();
		if(l > atr || r < atl) return;
		if(l <= atl && atr <= r) {
			val += (atr-atl+1)*by;
			mx += by; mn += by;
			if(left != NULL) {
				left->lazy += by;
				right->lazy += by;
			}
			return;
		}
		left->lazyupdate(l,r,by);
		right->lazyupdate(l,r,by);
		mn = min(left->mn, right->mn);
		mx = max(left->mx, right->mx);
		val = left->val+right->val;
	}
	ll lazyquery(int l, int r) {
		if(l > atr || r < atl) return 0;
		if(lazy != 0) propagate();
		if(l <= atl && atr <= r) return val;
		return left->lazyquery(l,r)+right->lazyquery(l,r);
	}
	int lazylowest(int l, int r) {
		if(l > atr || r < atl) return INF;
		if(lazy != 0) propagate();
		if(l <= atl && atr <= r) return mn;
		return min(left->lazylowest(l,r), right->lazylowest(l,r));
	}
	int lazyhighest(int l, int r) {
		if(l > atr || r < atl) return 0;
		if(lazy != 0) propagate();
		if(l <= atl && atr <= r) return mx;
		return max(left->lazyhighest(l,r), right->lazyhighest(l,r));
	}
	void propagate() {
		val += (atr-atl+1)*lazy;
		mn += lazy;
		mx += lazy;
		if(left != NULL) {
			right->lazy += lazy;
			left->lazy += lazy;
		}
		lazy = 0;
	}
};
node* build(int l, int r) {
	if(l > r) return NULL;
	if(l == r) return new node(NULL, NULL, 0, l, r);
	int m = (l+r)/2;
	node* left = build(l,m);
	node* right = build(m+1,r);
	node* cur = new node(left,right,0,l,r);
	return cur;
}

vector<int> edg[200100];
bool vis[200100];
vector<int> path;
void dfs(int at){
    if(vis[at]) return;
    vis[at] = true;
    path.pb(at);
    rep(i,0,edg[at].size()){
        dfs(edg[at][i]);
    }
    path.pb(at);
}

int S[200100];
int E[200100];

int main()
{
    int n, q;
    cin >> n >> q;
    rep(i,0,n-1) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        edg[a].pb(b);
        edg[b].pb(a);
    }
    memset(vis,0,sizeof(vis));
    dfs(0);

    memset(S,-1,sizeof(S));
    rep(i,0,2*n){
        if(S[path[i]] == -1) S[path[i]] = i;
        else E[path[i]] = i;
    }

    node* root = build(0,2*n);
    rep(i,0,q){
        int p,x;
        cin >> p >> x;
        p--;
        root->lazyupdate(S[p],E[p],x);
    }
    rep(i,0,n){
        cout << root->lazyquery(S[i],S[i]) << ' ';
    }
}


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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */
bool res(int n)
{
  if(n<=1) return true; 
  else if(n%2==0) res(n/2);
  else return false;
}
signed main() 
{
  int n=in();
  int tmp=1;
  for(int i=n;i>0;--i)
  {
    if(res(i)) 
    {
      tmp=i;
      break;
    }
  }
  print(tmp);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,z,x,c;
string s;
int main()
{
    cin>>n>>z;
    cin>>s;
    for(int i=0;i<n;i++){
        if(i==z-1){
            if(s[i]>=65 && s[i]<=90)
                s[i]+=32;
        }
        cout<<s[i];
    }
}


Measured memory_bytes: 256
import math
 
n=int(input())+1
ans=0
for i in range(1,n):
  for j in range(i,n):
    for k in range(j,n):
      if i==j and i==k:
        buff=1
      elif i==j:
        buff=3
      elif j==k:
        buff=3
      else:
        buff=6
      g1=math.gcd(i,j)
      g=math.gcd(k,g1)
      ans+=g*buff
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)

int ndg(int x, int n){
    return (x % int (pow(10, n))) / pow(10, n-1);
}

int main(){
    int N;
    cin >> N;
    int S=0;
    for(int i=1; i<11; i++) S += ndg(N, i);
    if(N%S==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

//143 D
int main(void) {
	ll n;
	cin >> n;
	vector<ll> t = vector<ll>(n);
	rep(i, 0, n) cin >> t[i];
	sort(t.begin(), t.end());
	ll ans = 0;
	rep(i, 0, n-2) {
		rep(j, i + 1, n-1) {
			auto itr = lower_bound(t.begin() + j + 1, t.end(), t[i] + t[j]);
			ans += distance(t.begin() + j + 1, itr);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())


def prime(k):
    p = [True] * (k+1)
    p[0] = False
    p[1] = False
    for i in range(2, k+1):
        if p[i]:
            for j in range(i*2, k+1, i):
                p[j] = False
    return [i for i in range(k + 1) if p[i]]


def mod5(px):
    return [p for p in px if p % 5 == 1]


px = prime(2000)
qx = mod5(px)

print(' '.join(map(str, qx[0:n])))


Measured memory_bytes: 3064
#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 count = 1;
  rep(i,s.size()) {
    if(count%2 == 1) {
      if(s.at(i) == 'L') {
        cout << "No";
        return 0;
      }
    }
    if(count%2 == 0) {
      if(s.at(i) =='R') {
        cout << "No";
        return 0;
      }
    }
    count++;
  }
  cout << "Yes";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y2 - y1;

    cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx
         << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }

    
    public class Class1
    {
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {

            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);

            if((n+m) %2 ==1)
            {
                Console.WriteLine("IMPOSSIBLE");
                return;
            }

            int res = (n + m) / 2;
            Console.WriteLine(res);

        }

    }


}


Measured memory_bytes: 13140