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

int main(){
    int N, K;
    cin>> N >> K;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        cin>>a[i];
    }
    
    int x=0;
    if((N-1)%(K-1)>0){
        x=1;    
    }

    cout<<(N-1)/(K-1)+x<<endl;
    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
//        int ans = N % 2 == 0 ? N / 2 : N / 2 + 1;
        System.out.println(N % 2 == 0 ? N / 2 : N / 2 + 1);
    }
}

Measured memory_bytes: 21844
import math

from functools import lru_cache


@lru_cache(maxsize=4096)
def get_cost(x, y):
    return int(math.pow((x - y), 2))


def get_costs(target, numbers):
    return sum([get_cost(target, n) for n in numbers])


def check(n, numbers):
    n_max = max(numbers)
    n_min = min(numbers)
    costs = []
    for target in range(n_min, n_max + 1):
        costs.append(get_costs(target=target, numbers=numbers))

    return min(costs)


def main():
    N = int(input())
    numbers = list(map(int, input().split()))
    print(check(n=N, numbers=numbers))


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,wmax;
int w[125];
int v[125];
vi yo[4];
vl sm[4];

int main(){
  scanf("%d%d",&n,&wmax);
  REP(i,n)scanf("%d%d",w+i,v+i);
  int base = w[0];
  REP(i,n){
    yo[w[i]-base].push_back(v[i]);
  }
  REP(i,4)sort(ALL(yo[i]));
  REP(i,4)reverse(ALL(yo[i]));
  REP(x,4){
    ll sum = 0;
    sm[x].push_back(0);
    REP(i,yo[x].size()){
      sum += yo[x][i];
      sm[x].push_back(sum);
    }
  }
  ll ans = 0;
  REP(a,sm[0].size())REP(b,sm[1].size())REP(c,sm[2].size()){
    ll wsum = (ll)a*base + (ll)b*(base+1) + (ll)c*(base+2);
    if(wsum > wmax)break;
    int rest = wmax - wsum;
    int d = min((int)yo[3].size(), rest / (base+3));
    ll tmp = sm[0][a] + sm[1][b] + sm[2][c] + sm[3][d];
    CHMAX(ans,tmp);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

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

    ArrayList<Integer[]> inputList = new ArrayList<>();

    while (input.ready())
    {
      final String[] inputStrArray = input.readLine().split(",");
      final Integer[] inputIntArray =
      { Integer.parseInt(inputStrArray[0]), Integer.parseInt(inputStrArray[1]) };

      inputList.add(inputIntArray);
    }
    final int[] ans = solver(inputList);
    System.out.println(ans[0]);
    System.out.println(ans[1]);

  }

  private static int[] solver(ArrayList<Integer[]> list)
  {
    int prodSum = 0;
    double sum = 0;
    for (Integer[] each : list)
    {
      prodSum += each[0] * each[1];
      sum += each[1];
    }
    final int[] ret =
    { prodSum, (int) Math.round(sum / list.size()) };
    return ret;
  }

}

Measured memory_bytes: 24236
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(non_snake_case)]
fn main() {
    input!{
        r: usize,
        D: usize,
        x: usize,
    };

    let mut xs = vec![r*x-D];
    for _ in 0..9 {
        let px = xs[xs.len()-1];
        xs.push(px*r-D)
    }
    for i in 0..10 {
        println!("{}", xs[i]);
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 112345;
ll dp[MAXN], v[111], w[111];
int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i<=n; ++i) {
        scanf("%lld %lld", w+i, v+i);
    }
    for (int i = 1; i<=n; ++i) {
        for (int j = m; j>=w[i]; --j) {
            dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
        }
    }
    printf("%lld\n", dp[m]);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		long k = scanner.nextLong();
		long ans = k % 2 == 1 ? b - a : a-b; 
		if(Math.abs(ans) > Math.pow(10, 18)) {
			System.out.println("Unfair");
		}else {
			System.out.println(ans);
		}
		
	}

}

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

namespace AOJ1_9_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int Counter = 0;
            string W = Console.ReadLine();
            string S;
            string[] T;

                for (int n = 0; (S = Console.ReadLine()) != null; n++)
                {
                    if (S == "END_OF_TEXT") break;
                    T = S.Split(' ');
                    for (int i = 0; i < T.Length; i++)
                    {
                        if (T[i].ToUpper() == W.ToUpper()) Counter++;
                    }
                }
                Console.WriteLine(Counter);

           
        }
    }
}




Measured memory_bytes: 15804
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
wa = 0
for i in range(N):
    wa += B[A[i]-1]
    if(i > 0 and A[i]-A[i-1] == 1):
        wa += C[A[i-1]-1]
print(wa)
        

Measured memory_bytes: 3060
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
  string s;
  int count = 0;
  
  cin >> s;
  if(s[0] == '1') count++;
  if(s[1] == '1') count++;
  if(s[2] == '1') count++;
  
  cout << count << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toLong)
    var ans = 0L
    if (k == 0L) {
        println(n * n)
        return
    }
    for (b in (k + 1)..n) {
        val last = n % b
        val countK = Math.min(n / b + if (last >= k) 1 else 0, n)
        val leftSmaller = countK * k - 1
        val rightSmaller = if (last < k) last + 1 else 0
        val smaller = leftSmaller + rightSmaller
        ans += n - smaller
    }
    println(ans)
}


Measured memory_bytes: 36324
#include<stdio.h>

int main(void)
{
	int i,j,n,x,m[30],dp[1000001],S,p[1000001];
	
	for(i=0;i<=1000000;i++)
	{
		p[i]=1;
	}
	for(i=4;i<=1000000;i++)
	{
		for(j=2;j*j<=i && p[i]==1;j++)
		{
			if(i%j==0) p[i]=0;
		}
	}
	
	while(1)
	{
	   scanf("%d%d",&n,&x);
	   if(n==0 && x==0) break;
	   for(i=0;i<=n-1;i++)
	   {
		   scanf("%d",&m[i]);
	   }
	   dp[0]=1;
	   for(i=1;i<=x;i++)
	   {
	   	   dp[i]=0;
	   }
	   S=-1;
	   for(i=1;i<=x;i++)
	   {
	   	for(j=0;j<=n-1;j++)
		{
			if(i-m[j]>=0 && dp[i-m[j]]==1)
			{
				dp[i]=1;
				if(p[i]==1) S=i;
			}
		}
	   }
	   if(S==-1)
	   {
	      printf("NA\n");
	   }
	   else
	   {
	   	  printf("%d\n",S);
	   }
	}
	return 0;
}

Measured memory_bytes: 8424
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
const int maxn = 1e5+50;
typedef long long ll;
int n;
int a[maxn];
bool vis[maxn];
int main(){
 //   freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> n){
        int cnt = 0;
        mem(vis,false);
        for(int i = 1; i <= n; i++) {cin >> a[i]; if(a[i] == i) {cnt++;vis[i]=true;}}
        for(int i = 2; i <= n; i++)
        {
            if(vis[i] && vis[i-1]){
                cnt--;
                i++;
            }
        }
        cout << cnt << endl;
    }
    return 0; 
}

Measured memory_bytes: 768
#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>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int n,m;
int a[maxn];
struct P{
  int x,y,v;
  bool operator<(const P&a)const {
    return v<a.v;
  }
}p[maxn];
vector<int>e[maxn];

int f[maxn];
ll sum[maxn];
int pd(int x){
  if(f[x]!=x)f[x]=pd(f[x]);
  return f[x];
}
bool can[maxn], vis[maxn];

void dfs(int x,int lim){
  vis[x]=true;
  for(int i=0;i<e[x].size();i++){
    int idx = e[x][i];
    if(p[idx].v>lim)continue;
    if(!vis[p[idx].x])dfs(p[idx].x, lim);
    if(!vis[p[idx].y])dfs(p[idx].y, lim);
  }
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  cin>>n>>m;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=m;i++){
    cin>>p[i].x>>p[i].y>>p[i].v;
  }
  sort(p+1,p+m+1);
  for(int i=1;i<=m;i++){
    e[p[i].x].push_back(i);
    e[p[i].y].push_back(i);
  }
  for(int i=1;i<=n;i++){
    f[i]=i;
    sum[i]=a[i];
    vis[i]=false;
  }
  for(int i=1;i<=m;i++){
    can[i]=false;
    int px = pd(p[i].x);
    int py = pd(p[i].y);
    if(px!=py){
      f[px]=py;
      sum[py]+=sum[px];
      sum[px]=0;
    }
    if(sum[py]>=p[i].v){
      can[i]=true;
    }
  }
  int ret = 0;
  for(int i=m;i>=1;i--){
    if(vis[p[i].x])continue;
    if(!can[i]){
      ret++;
      continue;
    }
    dfs(p[i].x, p[i].v);
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    int k;
    int a, b;
    cin >> k;
    cin >> a >> b;
    for(int i=0; i<=1000; i++){
        if(a <= k*i && k*i <= b){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<unordered_set>
#include<string>
#define MAX 10001

using namespace std;
int main(){
	int n,m,sum=0;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int temp;
		cin>>temp;
		sum+=temp;
	}
	cout<<(n-sum<0?-1:n-sum)<<endl;
	
	return 0;
} 

Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>

int main() {
	constexpr long long int MOD = 1000000007;
	int n, m, k; std::cin >> n >> m >> k;
	std::vector<long long int> factorial(n * m + 1, 1);
	auto inv = factorial;
	auto inverse = factorial;
	for (auto i = 2; i < factorial.size(); ++i) {
		factorial[i] = i * factorial[i - 1] % MOD;
		inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
		inverse[i] = inv[i] * inverse[i - 1] % MOD;
	}
	long long int result = 0;
	for (long long int y = 0; y < n; ++y) {
		for (long long int x = -m + 1; x < m; ++x) {
			if (y == 0 && x <= 0) continue;
			const auto h = n - y;
			const auto w = m - std::abs(x);
			const auto d = y + std::abs(x);
			const auto comb = factorial[n * m - 2] * inverse[k - 2] % MOD * inverse[n * m - k] % MOD;
			result += h * w * d % MOD * comb % MOD;
			result %= MOD;
		}
	}
	std::cout << result << std::endl;
}


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

int main() {
  int x;
  cin >> x;
  
  int a = x / 1000;
  int b = (x / 100) % 10;
  int c = (x / 10) % 10;
  int d = x % 10;

  if (a == b && b == c) cout << "Yes" << endl;
    
  else if (b == c && c == d) cout << "Yes" << endl;
  
  else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a, b;

	scanf("%d", &a);

	if(a % 2 == 0){
		b = (a/2) * (a/2);
	}
	else{
		b = (a/2) * (a/2 + 1);
	}

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


	return 0;
}

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

#define ll long long

signed main()
{
  string s,t; cin >> s >> t;
  int cnt=0;
  for(int i = 0; i<s.size(); ++i){
    cnt += (s[i]!=t[i]);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3920
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <cmath>
#include "string.h"
#define OPEN 0
#define MAXN 100010
long long A[MAXN];

using namespace std;
int main() {
	ios::sync_with_stdio(false);
#if OPEN
	freopen("input.txt", "r", stdin);
#endif
	int N;
	stringstream ss;
	//N for the array length
	//A for the array
	while (cin >> N) {
		string str;
		memset(A, 0, sizeof(A));
		getline(cin, str);	//eat the space
		getline(cin, str);
		ss << str;
		long long t;
		int j = 0;
		while (ss >> t) {
			A[j] = t;
			j++;
		}
		ss.str("");
		ss.clear();

		//each case
		//minus_v.erase(minus_v.begin(), minus_v.end());
		
		long long max_abs_c_z = 10000000000;
		int t_idx = -1;
		int count_mi = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] < 0) {
				count_mi++;
				//minus_v.push_back(A[i]);
			
				
			}
			if (llabs(A[i]) < max_abs_c_z ) {
				t_idx = i;
				max_abs_c_z = llabs(A[i]);
			}
		}
		if (count_mi % 2 == 0) {
			long long sum = 0;
			for (int i = 0; i < N; i++) {
				if (A[i] < 0)sum += -A[i];
				else sum += A[i];
			}
			cout << sum << endl;
		}
		else {
			long long sum = 0;
			for (int i = 0; i < N; i++) {
				if (i == t_idx) {
					if (A[i] < 0) {
						sum += A[i];
					}
					else
						sum += -A[i];
				}
				else {
					if (A[i] < 0) {
						sum += -A[i];
					}
					else
						sum += A[i];
				}
			}
			cout << sum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5276
fn main() {
    let (n,m) = read_pair();
    let s: Vec<i32> = read_vec();
    let t: Vec<i32> = read_vec();

    let mut dp = vec![vec![F(0); m]; n];
    let mut ds = vec![vec![F(0); m+1]; n+1];

    for i in 0..n { for j in 0..m {
        if s[i] == t[j] {
            dp[i][j] = F(1);
            if i!=0 && j!=0 {
                dp[i][j] += ds[i][j];
            }
        }
        ds[i+1][j+1] = ds[i][j+1] + ds[i+1][j] - ds[i][j] + dp[i][j];
    }}

    println!("{}", dp.iter().fold(F(0), |s,v| s + v.iter().sum())+F(1));
}

fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T>{
    get_line().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_pair<T: std::str::FromStr + Copy>() -> (T,T){
    let v:Vec<T> = read_vec(); (v[0], v[1])
}

const MOD: u64 = 1_000_000_007;

#[derive(Copy, Clone, PartialEq, Eq)]
struct F(u64);

impl F {
    pub fn new(n: i32) -> Self { F((MOD as i32 + n)as u64%MOD) }
    pub fn pow(self, mut exp: u32) -> Self {
        let mut base = self.0;
        let mut acc = 1;
        while exp > 1 {
            if (exp & 1) == 1 { acc *= base; acc %= MOD; }
            exp /= 2; base *= base; base %= MOD;
        }
        if exp == 1 { acc *= base;acc %= MOD; }
        F(acc)
    }
}
impl std::fmt::Display for F {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}
use std::ops::*;
impl Mul for F {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {F((self.0 * rhs.0)%MOD)}
}
impl MulAssign for F {
    fn mul_assign(&mut self, rhs: Self) {*self = F((self.0 * rhs.0)%MOD)}
}
impl Add for F {
    type Output = Self;
    fn add(self, rhs: Self) -> Self {F((self.0 + rhs.0)%MOD)}
}
impl AddAssign for F {
    fn add_assign(&mut self, rhs: Self) {*self = F((self.0 + rhs.0)%MOD)}
}
impl Neg for F {
    type Output = Self;
    fn neg(self) -> Self {if self.0==0 {F(0)} else {F(MOD - self.0)}}
}
impl Sub for F {
    type Output = Self;
    fn sub(self, rhs: Self) -> Self {F((MOD + self.0 - rhs.0)%MOD)}
}
impl SubAssign for F {
    fn sub_assign(&mut self, rhs: Self) {*self = F((MOD + self.0 - rhs.0)%MOD)}
}
impl Div for F {
    type Output = Self;
    fn div(self, rhs: Self) -> Self {F(self.0 * rhs.pow(MOD as u32-2).0 %MOD)}
}
impl DivAssign for F {
    fn div_assign(&mut self, rhs: Self) { *self = F(self.0 * rhs.pow(MOD as u32 - 2).0 % MOD) }
}
impl std::iter::Sum<F> for F {
    fn sum<I: Iterator<Item=F>>(iter: I) -> F { iter.fold(F(0), |a,b| a + b) }
}
impl<'a> std::iter::Sum<&'a F> for F {
    fn sum<I: Iterator<Item=&'a F>>(iter: I) -> F { iter.fold(F(0), |a, b| a + *b) }
}

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

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

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	string s;
	getline(cin, s);

	for (int i = 0; i < s.size(); i++) {
		if (islower(s[i])) s[i] = toupper(s[i]);
		else s[i] = tolower(s[i]);
	}
	cout << s << endl;
}


Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
  
  int n; cin >> n;
  vector<string> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
    sort(v[i].begin(), v[i].end());
  }

  map<string, int> mp;
  for(int i = 0; i < n; i++){
    mp[v[i]]++;
  }
  
  int ans = 0;
  for(auto x : mp){
    int add = x.second;
    ans += (add * (add - 1)) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ms1 = m1+h1*60,ms2 = m2+h2*60;
    int sta = max(0,ms2-k-ms1);
    cout << sta << endl;
}


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

using namespace std;

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

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, m;
    cin >> n >> m;
    int mi = 1, ma = n;
    for (int i = 0; i < m; i++)
    {
        int l, r;
        cin >> l >> r;
        mi = max(mi, l);
        ma = min(ma, r);
    }
    cout << max(0, ma - mi + 1) << endl;
}


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

long long ctoi(char c)
{
	if ('0' <= c && c <= '9')
	{
		return (long long)(c - '0');
	}
	else
	{
		return 0;
	}
}

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

	long long A;
	char B1, B2, B3;
	scanf("%lld %c.%c%c", &A, &B1, &B2, &B3);
	// cout << B1 << " " << B2 << " " << B3;
	long long B_100 = ctoi(B1) * (long long)100 + ctoi(B2) * (long long)10 + ctoi(B3);
	// cout << B_100 << "\n";
	long long C = A * B_100;

	cout << (C - C % (long long)100) / (long long)100;
	return 0;
}

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

// 	long long A;
// 	double B;
// 	scanf("%lld %lf", &A, &B);
// 	long long C;
// 	C = floor(B * 100.0);
// 	// cout << C << "\n";
// 	cout << (long long)(A * C) / (long long)100;
// 	return 0;
// }

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

int main()
{
    string S;
    cin >> S;

    int less_cnt = 0;
    int bigger_cnt = 0;

    int start = 0;

    long ans = 0;
    rep(i, S.size())
    {
        if (S.at(i) == '<')
        {
            less_cnt = 0;
            ans += ++bigger_cnt;
        }
        else if (S.at(i) == '>')
        {
            less_cnt++;
            if (less_cnt == 1)
            {
                start = bigger_cnt;
                bigger_cnt = 0;
                if (start == 0)
                {
                    ans += 1;
                }
            }
            else if (less_cnt > 1)
            {
                if (start >= less_cnt)
                {
                    ans += less_cnt - 1;
                }
                else
                {
                    ans += less_cnt;
                }
            }
        }
    }

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

Measured memory_bytes: 4308
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int N = 5e3 + 11;
const int mod = 1e9 + 7;
int g[N], f[N][N];
int sz[N], n;
vector<int> G[N];
inline int A(int x, int y){
	return x + y - (x + y >= mod ? mod : 0);
}
inline int M(int x, int y){
	return 1LL * x * y % mod;
}
void dfs(int u, int fa){
	sz[u] = 1;
	f[u][1] = 1;
	for(int v : G[u]){
		if(v == fa)continue;
		dfs(v, u);
		int sum = 0;
		for(int i = 1;i <= sz[v]; i++)sum = A(sum, M(f[v][i], g[i]));
		for(int i = sz[u];i >= 1; i--){
			int F = f[u][i];
			f[u][i] = 0;
			for(int j = sz[v];j >= 0; j--){
				f[u][i+j] = A(f[u][i+j], M(F, f[v][j]));
			}
			f[u][i] = A(f[u][i], mod - M(F, sum));
		}		
		sz[u] += sz[v];

	}
}
int main(){
	cin>>n;
	int u, v;
	g[0] = 1;
	for(int i = 2;i <= n; i++){
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
		g[i] = M(g[i-2], i - 1);
	}
	dfs(1, 1);
	int ans = 0;
	for(int i = 1;i <= n; i++){
		ans = A(ans, M(g[i], f[1][i]));
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int k,a,b;
  cin >> k >> a >> b; 
  bool ans = false;
  for (int i = a; i <= b; ++i){
	if (i % k == 0) ans = true;
  }
  cout << ((ans) ? "OK" : "NG");
  cout << "\n";
return 0;
}


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

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

  vector<long long> L;
  L.push_back(2);
  L.push_back(1);
  for (int i=2; i<=N; i++) {
    L.push_back(L[i-1] + L[i-2]);
  }

  cout << L[N] << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

class Program {
    static void Main(string[] args) {

        string s = Console.ReadLine();
        string result = "Yes";

        for(int a = 0; a < s.Length; a++) {
            if (a % 2 == 0) {
                if (s[a] != 'R'&& s[a] != 'U'&& s[a] != 'D') {
                    result = "No";
                    a = s.Length;
                }
            } else {
                if (s[a] != 'L' && s[a] != 'U' && s[a] != 'D') {
                    result = "No";
                    a = s.Length;
                }
            }
        }

        Console.WriteLine(result);
    }
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int64_t n, k;
	std::cin >> n >> k;
	int64_t l = 0, r = 1000000000000000001;
	while (r - l > 1) {
		int64_t m = l + (r - l) / 2;
		int64_t needed = m;
		int64_t last = m;
		for (int i = 1; i < n; i++) {
			needed += last / 2;
			last /= 2;
			if (!last) break;
		}
		if (needed <= k) l = m;
		else r = m;
	}
	std::cout << l << std::endl;
	return 0;
}




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

#define L 6
#define putchar_buf(X) putchar_unlocked(X)
#define putlong_buf(X) \
    do{ \
        long n=X; \
        char c[L]; \
        long i=L-1; \
        do{ c[i]=n%10+'0'; n/=10; i--; }while(n>0); \
        for(i++;i<L;i++){ putchar_buf(c[i]); } \
    }while(0)
#define puts_buf(X) \
    do { \
        for(size_t i=0; X[i]!='\0'; i++){ \
            putchar_buf(X[i]); \
        } \
        putchar_buf('\n'); \
    }while(0)

static void solve(const long a, const long b, const size_t sp, const size_t ep, long mask, const long common){
    if(ep-sp<=2){
        putlong_buf(common|a);
        putchar_buf(' ');
        putlong_buf(common|b);
        putchar_buf(' ');
    }else{
        const long t = a^b;
        const long d = t&(-t);
        mask ^= d;
        const long aa = a & mask;
        const long ab = aa ^ (mask&(-mask));
        const size_t mp = (sp+ep)/2;
        solve(aa,     ab, sp, mp, mask, common|(a&d));
        solve(ab, b&mask, mp, ep, mask, common|(b&d));
    }
}

int main(void){
    long n, a, b;
    scanf("%ld %ld %ld", &n, &a, &b);
    if(__builtin_parity(a) == __builtin_parity(b)){
        puts("NO");
    }else{
        const size_t m = 1<<n;
        puts_buf("YES");
        solve(a, b, 0, m, 0xFFFFFFFFFFFFFFFF, 0);
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
#define MAX 200000
#define INF 2000000000

struct cards
{
	int value = 0;
	int num = 0;
};

cards a[MAX];
cards L[MAX / 2 + 2];
cards R[MAX / 2 + 2];

void merge(int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) {
		L[i] = a[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = a[mid + i];
	}
	L[n1].value = INF;
	R[n2].value = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (L[i].value <= R[j].value) {
			a[k] = L[i++];
		}
		else
		{
			a[k] = R[j++];
		}
	}
}

void mergeSort(int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(left, mid);
		mergeSort(mid, right);
		merge(left, mid, right);
	}
}

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

	for (int i = 0; i < n; i++) {
		cin >> a[i].value;
		a[i].num = 1;
	}

	for (int i = n; i < (n + m); i++) {
		cin >> a[i].num >> a[i].value;
	}

	mergeSort(0, n + m);

	long long sum = 0;
	int j = n + m;
	for (int i = 0; i < n; i++) {
LABEL:
		if (a[j].num > 0) {		// a[j]が1枚以上ある
			sum += a[j].value;
			a[j].num--;			// １枚減らす
		}
		else
		{
			j--;
			goto LABEL;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

constexpr int MOD = 1000000007;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

mint modpow(mint a, long long b) {
  mint res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

mint modinv(mint n) {
  int a = (int)n, b = MOD;
  int s = 1, t = 0;
  while (b != 0) {
    int q = a / b;
    a -= q * b;
    s -= q * t;
    swap(a, b);
    swap(s, t);
  }
  return s >= 0 ? s : s + MOD;
}

mint C(int n, int r) {
  mint res = 1;
  rep(i, r) {
    res *= n - i;
    res *= modinv(i + 1);
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b; cin >> n >> a >> b;
  mint ans = modpow(2, n) - 1;
  ans -= C(n, a);
  ans -= C(n, b);
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

class Graph(n: Int, reversible: Boolean) {
  private val cost = Array.fill[Int](n, n)(Int.MaxValue)
  private val connected = Array.fill[Boolean](n, n)(false)
  private val N = n
  private val Reversible = reversible

  def connect(from: Int, to: Int, cost: Int): Unit = {
    connected(from)(to) = true
    this.cost(from)(to) = cost

    if (Reversible) {
      connected(to)(from) = true
      this.cost(to)(from) = cost
    }
  }

  def warshall_floyd(): Unit = {
    (0 until N).foreach(k => {
      (0 until N).foreach(i => {
        (0 until N).foreach(j => {
          if (connected(i)(k) && connected(k)(j))
            cost(i)(j) = math.min(cost(i)(j), cost(i)(k) + cost(k)(j))
        })
      })
    })
  }

  def getCost(from: Int)(to: Int): Int = {
    cost(from)(to)
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)

    val H, W = sc.nextInt
    val g = new Graph(10, false)
    (0 to 9).foreach(i => {
      (0 to 9).foreach(j => {
        g.connect(i, j, sc.nextInt)
      })
    })

    g.warshall_floyd()

    var ans = 0
    (0 until H).foreach(_ => {
      (0 until W).foreach(_ => {
        val x = sc.nextInt
        if (x != -1) {
          ans += g.getCost(x)(1)
        }
      })
    })

    println(ans)
  }
}

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

#define ll long long
#define endl "\n"
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define f first
#define s second
#define vecll vector<ll>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<ll,ll>>
#define mapllll map<ll,ll>
#define mapstrll map<string,ll>
#define mapllvecll map<ll,vecll>
#define setll set<ll>
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL); cout.tie(NULL);

using namespace std;

ll const N=1e5+5;
ll const inf=1e18+5;
ll const MOD=1e9+7;

ll t,n,m,x,y,z,w,k;

int main()
{
    fio

    cin>>n;

    ll ans = 10000000000000000;

    for(ll i=1;i*i<=n;i++)
    {
        if(n%i == 0)
        {
            x = i;
            y = n/i;
            ans = min(ans,x-1+y-1);
        }
    }
    cout<<ans;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

ll calc(const ll &x, ll wj, ll wt, ll ej, ll et) {
    ll D[2][2];
    D[0][0] = wj; D[0][1] = ej; D[1][0] = wt; D[1][1] = et;
    ll ret = LINF*3;
    REP(i,2) {
        REP(j,2) {
            REP(k,2) {
                if (i == k) continue;
                REP(l,2) {
                    ll f = D[i][j];
                    ll la = D[k][l];
                    ret = min(abs(x-f)+abs(f-la), ret);
                }
            }
        }
    }
    return ret;
}

int main(int argc, char const *argv[]) {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s; vector<ll> t;
    s.push_back(-LINF); t.push_back(-LINF);
    REP(i,a) {ll S; cin >> S; s.push_back(S);}
    REP(i,b) {ll T; cin >> T; t.push_back(T);}
    s.push_back(LINF); t.push_back(LINF);
    REP(i,q) {
        ll x; cin >> x;
        auto Ej = upper_bound(s.begin(), s.end(), x);
        auto Et = upper_bound(t.begin(), t.end(), x);
        ll wj, ej, wt, et;
        ej = *Ej; --Ej;
        wj = *Ej;
        et = *Et; --Et;
        wt = *Et;
        //printf("x = %lld: Wj = %lld Ej = %lld, Wt = %lld Et = %lld\n", x, wj, ej, wt, et);
        ll ans = calc(x, wj, wt, ej, et);
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  if((N-N/1000)%111==0){
    cout << "Yes" << endl;
  }
  else if((N-N%10)%111==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> A(N);
    REP(i, 0, N) {
        cin >> A[i];
        A[i] -= X;
        A[i] = abs(A[i]);
    }
    if (N == 1) {
        cout << A[0] << endl;
    } else {
        int ans = gcd(A[0], A[1]);
        REP(i, 2, N) {
            ans = gcd(ans, A[i]);
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define pb push_back
#define scd second
#define fst first

using namespace std;
typedef long long int ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	map<int,int> mp;
	int n;
	cin>>n;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		mp[a]++;
	}

	vector<pair<int,int>> sd;
	ll ans=0;
	for(auto x=mp.begin(); x!=mp.end(); x++){
		if(x->scd>=4){
			sd.pb(*x);
			ans=max(ans,x->fst*(ll)x->fst);
		}else if(x->scd>=2){
			sd.pb(*x);
		}
	}
	
	int k=sd.size();
	for(int i=k-1; i>0; i--){
		ans=max(ans,sd[i].fst*(ll)sd[i-1].fst);
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 4992
from sys import stdin
input1=stdin.readline().rstrip().split()
N=int(input1[0])
L=int(input1[1])
input=[]
for n in range(N):
  input.append(stdin.readline().rstrip())

input.sort()
output=""
for i in range(len(input)):
  output+=input[i]

print(output)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N, M;
  cin >> N >> M;
  int k = M/N;
  int ans = 1;
  int work;
  if(N==1){
    cout << M << endl;
    return 0;
  }
  for(int i = 2; i<k+1; ++i){
    if((M-N*i)%i ==0) ans = i;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
n = int(input())
if n <= 3:
  print([n,n**2,n*(2*n-1)][n-1])
  exit()
mod = 10**9+7
dp = [0]*(n+1)
dp[1] = n
dp[2] = n**2
dp[3] = n*(2*n-1)
acc = sum(dp)
for i in range(4,n+1):
  dp[i] = acc-dp[i-2]+(n-1)**2+n-i+2
  dp[i] %= mod
  acc = (acc+dp[i])%mod
print(dp[n])

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

using namespace std;

int a, b;
char c[105][105];

int main()
{
    scanf("%d%d", &a, &b);
    printf("100 100\n");
    for(int i = 0; i < 100; i++)
    {
        for(int j = 0; j < 50; j++)
        {
            c[j][i] = '.';
        }
        for(int j = 50; j < 100; j++)
        {
            c[j][i] = '#';
        }
    }
    for(int i = 0; i < b - 1; i++)
    {
        int x = i % 50 * 2;
        int y = i / 50 * 2;
        c[y][x] = '#';
    }
    for(int i = 0; i < a - 1; i++)
    {
        int x = i % 50 * 2;
        int y = i / 50 * 2 + 51;
        c[y][x] = '.';
    }
    for(int i = 0; i < 100; i++)
    {
        puts(c[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

vector<int> g[303];
vector<int> v[303];

bool visg[303];
bool visv[303];

void dfsg(int now){
  visg[now]=true;
  for(auto nex:g[now]){
    if(visg[nex]) continue;
    dfsg(nex);
  }
}

void dfsv(int now){
  visv[now]=true;
  for(auto nex:v[now]){
    if(visv[nex]) continue;
    dfsv(nex);
  }
}


int N,M;
vector<int> A,B;

int main(){
  cin>>N>>M;
  A.resize(M);
  B.resize(M);

  for(int i=0;i<M;i++) cin>>A[i]>>B[i];

  for(int i=0;i<M;i++){
    g[A[i]].push_back(B[i]);
    v[B[i]].push_back(A[i]);
  }

  for(int i=1;i<=N;i++){
    dfsg(i);
    dfsv(i);

    vector<int> ans;
    for(int j=1;j<=N;j++){
      if(visg[j]&&visv[j]) ans.push_back(j);
      visg[j]=false;
      visv[j]=false;
    }

    for(int j=0;j<ans.size();j++){
      cout<<ans[j];
      if(j+1<ans.size()) cout<<" ";
    }
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 4820
#include <math.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    string S, T;
    cin >> S >> T;
    int min = S.size(), count, ssize = S.size(), tsize = T.size();
    for (int i = 0; i < (ssize-tsize+1); i++) {
        count = 0;
        string W = S.substr(i, T.size());
        for (int j = 0; j < tsize; j++) {
            char P = W[j], Q = T[j];
            if (P != Q) count++;
        }
        if (min > count) min = count;
    }

    cout << min<<endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] list = str.split(" ");
		int a = Integer.parseInt(list[0]);
		int b = Integer.parseInt(list[1]);
		int c = Integer.parseInt(list[2]);
		String answer = "";
		if(b-a == c-b){
			answer = "YES";
		}else{
			answer = "NO";
		}
		System.out.println(answer);

	}

}


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

int main(){
    int n; cin>>n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
        b[i] = a[i];
    }

    sort(b.begin(), b.end());

    int match = 0;
    for(int i=0; i<n; i++){
        if(a[i] == b[i]) match++;
    }

    int q; cin>>q;
    vector<int> x(q), y(q);
    for(int i=0; i<q; i++){
        cin>>x[i]>>y[i];
        x[i]--;
        y[i]--;
    }

    if(match == n){
        cout << 0 << endl;
        return 0;
    }

    for(int i=0; i<q; i++){
        if(a[x[i]] == b[x[i]]) match--;
        if(a[y[i]] == b[y[i]]) match--;

        swap(a[x[i]], a[y[i]]);

        if(a[x[i]] == b[x[i]]) match++;
        if(a[y[i]] == b[y[i]]) match++;

        if(match == n){
            cout << i + 1 << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 7576
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);

        // 入力
        //final int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();

        // 処理
        String out = "Yes";
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) != t.charAt(i)){
                out = "No";
            }
        }

        // 出力
        System.out.println(out);
    }
}


Measured memory_bytes: 35672
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

#define MOD 1000000007LL
ll memo[100005];

ll go(ll n) {
	ll ans = 1LL;
	for(int i=1;i<=n; i++)
		ans = ans*i%MOD;
	return ans;
}

int main(){
	ll a, b;
	cin >> a >> b;
	if (abs(a - b) >= 2)
		cout << "0" << endl;
	else if (abs(a - b) == 1) {
		cout << go(a)*go(b) % MOD << endl;
	}
	else {
		cout << 2 * go(a)*go(b) % MOD << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import random
import copy


def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]

    t = [0] * D

    # 貪欲法でまず求める
    penalty = copy.deepcopy(c)
    for i in range(D):
        ind = 0
        tmp = 0
        for j in range(26):
            if penalty[j] + s[i][j] > tmp:
                tmp = penalty[j] + s[i][j]
                ind = j
        penalty[ind] = 0
        t[i] = ind + 1
        for j in range(26):
            penalty[j] += c[j]

    # 適当なtをスワップしてスコアが伸びればそれを採用する
    ans = calc(s, c, t)
    rand = list(range(365))
    for i in range(20000):
        swap = random.sample(rand, 2)
        t[swap[0]], t[swap[1]] = t[swap[1]], t[swap[0]]
        tmp = calc(s, c, t)
        if tmp < ans:
            # 元に戻す
            t[swap[0]], t[swap[1]] = t[swap[1]], t[swap[0]]
        else:
            ans = tmp
    return t


def output(t):
    for tt in t:
        print(tt)


def calc(s, c, t):
    d = [0] * 26

    ans = 0
    days = 0
    for tt in t:
        for i in range(26):
            d[i] += 1
        d[tt-1] = 0
        ans += s[days][tt-1]
        for i in range(26):
            ans -= d[i] * c[i]
        days += 1
        # print(ans)

    return ans


if __name__ == "__main__":
    t = main()
    output(t)


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    long long i,temp1,temp2;
    for(i=0;i<s.size();i++){
        if(s[i]=='A'){
            temp1=i;
            break;
        }
    }
    for(i=(s.size()-1);i>=0;i--){
        if(s[i]=='Z'){
            temp2=i;
            break;
        }
    }
    cout<<temp2-temp1+1;
    return 0;
}


Measured memory_bytes: 640
#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, d;
    cin >> n >> d;
    int x = 2*d + 1;
    int ans = (n+x-1)/x;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int x = a + b + c;

  if (x >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# GCD
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

def main():
  n=I()
  l=LI()

  l1=l[:]
  l2=l[:]

  for i in range(1,n):
    l1[i]=gcd(l1[i-1],l1[i])

  for i in range(n-1,0,-1):
    l2[i-1]=gcd(l2[i],l2[i-1])

  n+=1
  l1=[0]+l1
  l2=l2+[0]

  # print(l1)
  # print(l2)

  mx=0
  for i in range(n-1):
    mx=max(mx,gcd(l1[i],l2[i+1]))

  return mx

print(main())


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



int main(int argc, char const *argv[])
{
    int a,b;
    cin >> a >> b;
    if (a<b)
    {
        cout << "a < b" <<endl;
    }
    else if (a>b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a == b" << endl;

    }
    
    return 0;



}



Measured memory_bytes: 3084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

int main(void){
char s[1500];
fgets(s,1500,stdin);

for(int i=0;s[i]!='\0';i++){
    if(islower(s[i])!=0){s[i]=toupper(s[i]);}
    else if(isupper(s[i])!=0){s[i]=tolower(s[i]);}
    //printf("%s\n",s);
}
printf("%s",s);
}






Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
int func(int N){
    if(N<10) return N;
    return func(N/10)+N%10;
}
int main() {
    int N;
    cin>>N;
    int s = func(N);
    if(N%s==0){
        cout<<"Yes"<<endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
#define Test ll q ; cin>>q ; while (q--)
#define ph push_back
#define f first
#define s second
using namespace std ;
int main ()
{
    ll a, b , c ;
    cin>>a>>b>>c ;
    ll cnt = a/(b+c) ;
    ll ans = cnt * b ;
    cnt=  a%(b+c) ;
    if (cnt>b)
        ans+=b ;
    else
        ans+=cnt ;
    cout<<ans ;
}


Measured memory_bytes: 256