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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<long long> vll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1]+=32;
    cc(s);
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = Integer.parseInt(sc.next());

		int[] d = new int[N + 1];
		for(int i = 1;i <= N;i++) {
			d[i] = Integer.parseInt(sc.next());
		}

		sc.close();

		int sum = 0;
		for(int i = 1;i <= N - 1;i++) {
			for(int j = i + 1;j <= N;j++) {
				sum += d[i] * d[j];
			}
		}

		System.out.println(sum);

	}
}



Measured memory_bytes: 21844
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

a = int(input())
count = 0
for i in range(a+1):
    b = make_divisors(i)
    if len(b) == 8 and i % 2 != 0:
        count += 1
print(count)        

Measured memory_bytes: 3444
/*
 * main.c
 *
 *  Created on: 2016/12/23
 *      Author: stoneriver
 */

#include <stdio.h>

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

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  string s, t; cin >> s >> t;
  for (ll i = 0; i < N; i++) {
    cout << s[i] << t[i];
  }
  cout << endl;

  return 0;
}



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

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

    switch (N % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon";
        return 0;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon";
        return 0;
    case 3:
        cout << "bon";
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
const int MAXN = 1000050;
int N;
char s[MAXN];
int main() {
    scanf("%s", s);
    int ans = N = strlen(s);
    for (char c = 'a'; c <= 'z'; ++c) {
        int last = -N, cnt = 0;
        for (int i = 0; i < N; ++i) {
            if (s[i] == c) last = i;
            else {
                if (last + cnt >= i) continue;
                ++cnt;
            }
        }
        ans = min(ans, cnt);
    }
    printf("%d\n", ans);
}

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

int a[550][550], h, w;
vector<string> v;

int main(){
    cin >> h >> w;
    for(int i = 0; i < h; i++)for(int j = 0; j < w; j++)cin >> a[i][j];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w - 1; j++){
            if(a[i][j] % 2 == 1){
                a[i][j + 1]++;
                string s = to_string(i + 1) + " " + to_string(j + 1) + " " + to_string(i + 1) + " " + to_string(j + 2);
                v.push_back(s);
            }
        }
    }
    for(int i = 0; i < h - 1; i++){
        if(a[i][w - 1] % 2 == 1){
            a[i + 1][w - 1]++;
            string s = to_string(i + 1) + " " + to_string(w) + " " + to_string(i + 2) + " " + to_string(w);
            v.push_back(s);
        }
    }
    cout << v.size() << endl;
    for(int i = 0; i < v.size(); i++)cout << v[i] << endl;
}

Measured memory_bytes: 12020
N = int(input())
S = input().split()

while True:
    s = ''.join([S[i] for i in range(1, len(S)) if S[i] != S[i-1]])
    s = S[0]+s
    if len(s) == len(S):
        break
    else:
        S = s

print(len(S))

    

Measured memory_bytes: 46960
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n,m;
  
  while(1){
    vector<int> num(20005,0);
    cin>>n>>m;
    if(n+m==0)break;
  
    for(int i=0;i<n;i++) cin>>num[i];
    for(int j=n;j<n+m;j++) cin>>num[j];

    stable_sort(num.begin(),num.end());

    int ans=0;
    for(int i=0;i<num.size()-1;i++){
      ans=max(ans,num[i+1]-num[i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1344
#include <iostream>
using namespace std;
int main(){
  string a;
  cin >> a;
  int flag = 0;
  for(int i = 0;i<a.size();i++){
    
    if(i%2==0){
      if(a.at(i)!='R'&&a.at(i)!='U'&&a.at(i)!='D') flag = 1;
    }
    else{
      if(a.at(i)!='L'&&a.at(i)!='U'&&a.at(i)!='D') flag = 1;
    }
  }
  if(flag)cout << "No";
  else cout << "Yes";
}

Measured memory_bytes: 3592
import java.util.*;
public class Main {

	public static long gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	
	public static long lcm(int a, int b) {
		return a / gcd(a, b) * b;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(lcm(sc.nextInt(), sc.nextInt()));

	}

}

Measured memory_bytes: 25172
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int inu = int.Parse(input[0]);
            int saru = int.Parse(input[1]);
            int Max = inu < saru ? saru : inu;
            int Min = inu < saru ? inu : saru;
            if( Max - Min > 1)
            {
                Console.WriteLine("0");
                return;
            }
            long result = 1;      
            for (int i=1; i <= Max; ++i)
            {
                result = (result * i) % 1000000007;
            }
            for (int i = 1; i <= Min; ++i)
            {
                result = (result * i) % 1000000007;
            }
            if(Max == Min)
            {
                result = (result * 2) % 1000000007;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
//0067

#include<stdio.h>


const int N = 12;
const int P = 4;
char a[N+P][N+P];

void Sink(int x, int y)
{
	if(a[x][y] == '1')
	{
		a[x][y] = '0';
		Sink(x+1,y);
		Sink(x-1,y);
		Sink(x,y+1);
		Sink(x,y-1);
	}
}

int main(void)
{
	int i,j;
	int count = 0;
	for(;;)
	{
		count = 0;
		for(i = 0; i < N; i++)
		{
			if(!fgets(a[i+1]+1, N+2, stdin))
			{
				return 0;
			}
			if(a[i+1][1] == '\n')
				i--;
		}

		for(i = 0; i < N; i++)
		{
			for(j = 0; j < N; j++)
			{
				if(a[i+1][j+1] == '1')
				{
					Sink(i+1, j+1);
					count++;
				}
			}
		}
		printf("%d\n", count);
	}
	return 1;
}


/*
101111111101
001111111100
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
001111111100
101111111101


*/

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
string s;
cin>>s;
ll a,z;
bool flag=false;
for(int i=0;i<s.size();i++){
    if(s[i]=='A'&&flag==false){
       a=i;
       flag=true;
    }
    if(s[i]=='Z'){
        z=i;
    }
}
cout<<z-a+1<<endl;
}










Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int A[2000];
void Calc(){
	long oricount = 0;
	long diff = 0;
	int N = rei();
	long K = rei();
	for(int i=0;i<N;i++){
		A[i] = rei();
	}
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(A[i] > A[j]){
				oricount++;
			}
			if(A[i] != A[j]){
				diff++;
			}
		}
	}
	long ans = (oricount*K%mod + K*(K-1)/2%mod*diff%mod) % mod;
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a==b)
    {
        printf("%d",c);
    }

     else if (b==c)
        {
            printf("%d",a);
        }

        else printf("%d",b);



    return 0;

}


Measured memory_bytes: 128
import Data.List

main = do  
  s <- getLine
  putStrLn $ if solve s then "AC" else "WA"

  where
    solve s = or $ map (\i -> solve' i s) [3..length s-1]
    solve' i s = (s !! 0 == 'A') && (s !! (i-1) == 'C') && (and [elem c ['a'..'z'] | (j,c)<-(zip [1..] s), j/=1, j/=i])


Measured memory_bytes: 380
use v5.26; # strict say state biwise
use warnings;
use List::Util qw(reduce any all none notall first max maxstr min minstr product sum sum0 pairs unpairs pairkeys pairvalues pairfirst pairgrep pairmap shuffle uniq uniqnum uniqstr);

chomp (my $k = <STDIN>);
my $ans = 0;
my @memo;
sub gcd {
  my ($x, $y) = @_;
  return $memo[$x][$y] if $memo[$x][$y] > 0;
  my ($u, $v) = ($x, $y);
  while ($y) {
    my $r = $x % $y;
    $x = $y;
    $y = $r;
  }
  $memo[$u][$v] = $x;
  $x;
}
for my $i (1..$k) {
  for my $j (1..$k) {
    my $c = gcd($i, $j);
    for my $l (1..$k) {
      $ans += gcd($c, $l);
    }
  }
}
say $ans;

Measured memory_bytes: 6728
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>


using namespace std;


int main() 
{
	string input;
	int num;
	int counter[28] = {};
		
	while (cin >> input)
	{
		for (auto a : input)
		{
			a = tolower(a);

			num = a - 97;

			counter[num]++;
		}
	}

	for (char a = 'a';  a <= 'z'; a++)
	{
		cout << a << " : " << counter[a - 'a'] << endl;
	}

	return 0;
}

Measured memory_bytes: 3136
n = int(input())
a = list(map(int,input().split()))
a.sort()
ret = 0
method = []

ret = a[0]
d = 2
while d < n and a[-d] > 0:
  method.append((ret, a[-d]))
  ret -= a[-d]
  d += 1
method.append((a[-1], ret))
ret = a[-1] - ret
for i in range(1, n-d+1):
  method.append((ret, a[i]))
  ret -= a[i]

print(ret)
for t in method: print(*t)


Measured memory_bytes: 23664
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

#define mod 998244353
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	FASTIO

	ll n, k;
	cin >> n >> k;

	ll l[k], r[k];
	for(ll i = 0; i < k; i ++)
	{
		cin >> l[i] >> r[i];
	}	

	ll dp[n + 1] = {0};
	ll pref[n + 1] = {0};
	pref[1] = 1;
	dp[1] = 1;
	for(ll i = 2; i <= n; i ++)
	{
		for(ll j = 0; j < k; j ++)
		{
			if(i <= l[j])
				continue;
			int left = l[j];
			int right = min(r[j], i - 1);
			int val = ((pref[i - left] % mod) - (pref[i - right - 1] % mod) + mod) % mod;
			dp[i] = (dp[i] % mod + val % mod) % mod;
		}
		// debug2(i, dp[i])
		pref[i] = (pref[i - 1] % mod + dp[i] % mod) % mod;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 6732
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define YY cout<<"YES\n"
#define NN cout<<"NO\n"
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#ifdef leowang
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
int a[maxn];
multiset<int> st;
int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin >> a[i];
	int mx = *max_element(a,a+n);
	REP(i,n) st.insert(a[i]);
	REP(i,mx+1){
		int cur = max(i,mx-i);
		if(!st.count(cur)){
			cout<<"Impossible\n";
			return 0;
		}
		st.erase(st.lower_bound(cur));
	}
	for(int i:st){
		if(i<(mx+1)/2+1){
			cout<<"Impossible\n";
			return 0;
		}
	}
	cout<<"Possible\n";
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 10000000

struct tester{
	int a,b,c,R;
	bool operator<( const tester& right ) const {
        return R == right.R ? a < right.a : R < right.R;
    }
};
int ac[301],wa[301];
int main(){
	int A,B,C,n;
	while(cin>>A>>B>>C){
		if(A==0&&B==0&&C==0)return 0;
		cin>>n;
		vector<tester>test;
		CLR(ac);CLR(wa);
		REP(i,n){
			int ta,tb,tc,tr;
			cin>>ta>>tb>>tc>>tr;
			tester t={ta,tb,tc,tr};
			test.PB(t);
		}
		SORT(test);
		int j;
		for(j=SZ(test)-1;j>=0,test[j].R==1;j--){
			ac[test[j].a]++;
			ac[test[j].b]++;
			ac[test[j].c]++;
		}
		for(j;j>=0;j--){
			if(ac[test[j].a]*ac[test[j].b]!=0){
				wa[test[j].c]++;
			}else if(ac[test[j].b]*ac[test[j].c]!=0){
				wa[test[j].a]++;
			}else if(ac[test[j].a]*ac[test[j].c]!=0){
				wa[test[j].b]++;
			}
		}
		FOR(i,1,A+B+C+1){
			if(ac[i]!=0)cout<<"1"<<endl;
			else if(wa[i]!=0)cout<<"0"<<endl;
			else cout<<"2"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	cin >> N;
	map<int,int> ma;
	for(int i = 0;i < N;i++) {
		int A;
		cin >> A;
		ma[A]++;
	}
	int two1 = 0;
	int two2 = 0;
	int four = 0;
	for(auto x:ma) {
		int key = x.first;
		int value = x.second;
		if(value >= 2) {
			two1 = two2;
			two2 = key;
		}
		if(value >= 4) {
			four = key;
		}
	}
	cout << max(four * four,max(four * two2,two1 * two2)) << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define maxn 1010
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize(2)
#define ll long long
#define makefa(n) for(int i=1;i<=(n);i++)f[i]=i;
#define hh puts("");
int main(){
    ll h,w;
    cin>>h>>w;
    if(w==1||h==1){cout<<"1";return 0;}
    ll x=w/2,y=h/2;
    if(w%2!=0)x++;
    if(h%2!=0)y++;
    ll ans=x*y;
    ans+=(w-x)*(h-y);
    cout<<ans;
    return 0;
}


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

int main(){

    int N, M;
    cin >> N >> M;
    vector<pair<int, pair<int, int> > > PYindex(M); 
    for(int i = 0; i < M; i++){
        cin >> PYindex[i].first >> PYindex[i].second.first;
        PYindex[i].second.second = i;
    }
    sort(PYindex.begin(), PYindex.end());

    int count = 1;
    for(int i = 0; i < M; i++){
        PYindex[i].second.first = count;
        count++;
        if(PYindex[i].first != PYindex[(i + 1) % M].first) count = 1;
    }

    sort(PYindex.begin(), PYindex.end(), [](pair<int, pair<int, int> > x, pair<int, pair<int, int> > y) -> int {return (x.second.second < y.second.second);});

    for(int i = 0; i < M; i++){
        cout << setfill('0') << setw(6) << PYindex[i].first;
        cout << setfill('0') << setw(6) << PYindex[i].second.first << endl;
    }

    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <map> 
using namespace std;
 
const int MAX= 10000100;
 
int main(void){
  int t,n;
  int ans;
  while(cin>>t,t){
    ans = 0;
    cin>>n;
    for(int i = 0 ; i < n ; i ++){
      int s,e;
      cin>>s>>e;
      ans+=e-s;
    }
    //cout<<t<<" "<<ans<<endl;
    if(ans>=t)cout<<"OK"<<endl;
    else cout<<t-ans<<endl;
   }
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String tile = sc.nextLine();
		sc.close();
		int ans = tile.length();

		for (int i = 0; i < 2; i++) {
			int cnt = 0;

			for (int j = 0; j < tile.length(); j++) {
				int current = Integer.parseInt(String.valueOf(tile.charAt(j)));
				if (j % 2 == 0 && tile.charAt(j) != (char) (i + '0')) {
					cnt++;
				}
				if (j % 2 == 1 && tile.charAt(j) == (char) (i + '0')) {
					cnt++;
				}
			}
			ans = Math.min(ans, cnt);

		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 36528
import sys
def input(): return sys.stdin.readline().rstrip()
def run_length(s):
    ans=[]
    if len(s)==1:
        ans.append((s,1))
        return ans
    s_pre=s[0]
    cunt=1
    for i,ss in enumerate(s[1:],1):
        if ss==s_pre:
            cunt+=1
        else:
            ans.append((s_pre,cunt))
            cunt=1
            s_pre=ss
    ans.append((s_pre,cunt))
    return ans
    
def main():
    s=input()
    run_s=run_length(s)
    n=len(s)
    ans=[0]*n
    index=-1
    for i in range(len(run_s)//2):
        index+=run_s[2*i][1]
        ans[index]+=(run_s[2*i][1]+1)//2+run_s[2*i+1][1]//2
        ans[index+1]+=run_s[2*i][1]//2+(run_s[2*i+1][1]+1)//2
        index+=run_s[2*i+1][1]
    print(*ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 13444
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

// An IntHeap is a min-heap of ints.
type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()

	h := &IntHeap{}
	heap.Init(h)

	for i := 0; i < n; i++ {
		heap.Push(h, nextInt())
	}

	for i := 0; i < m; i++ {
		n := heap.Pop(h).(int)
		heap.Push(h, n/2)
	}

	/*fmt.Printf("minimum: %d\n", (*h)[0])
	for h.Len() > 0 {
		fmt.Printf("%d ", heap.Pop(h))
	}*/
	ans := 0
	for h.Len() > 0 {
		ans += heap.Pop(h).(int)
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 7552
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int R = nextInt();
        int G = nextInt();
        int B = nextInt();
        int N = nextInt();

        int count = 0;
        for(int r=N/R; r>=0; r--){
            for(int g=(N-r*R)/G; g>=0; g--){
                if((N-r*R-g*G)%B == 0)
                    count++;
            }
        }
        println(count);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>

using namespace std;

int main(){
   int count2, count4, n, a;
   string ans = "No";

   cin >> n;
   count2 = 0;
   count4 = 0;
   for(int i = 0; i < n; i++){
      cin >> a;
      if(a % 2 == 0){
         if(a % 4 == 0){
            count4++;
         }else{
            count2++;
         }
      }
   }

   if(count4 >= n / 2 || (n - count4 * 2 <= count2)) ans = "Yes";
   cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define edge pair<ll,ll>
#define mod 1000000007
using namespace std;
 
 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦


int main(){

	fast;
	double n,a,b,c;
	
	ll i,j,k;
	double pi=3.1415926535;
	cin>>n;
	cout<<2*pi*n<<endl;
	



	return 0;
}

Measured memory_bytes: 3800
import java.util.Scanner;

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

        if (n % 7 != 0) {
            for (int k = n; k >= 0; k = k - 4) {
                if (k % 7 == 0) {
                    System.out.println("Yes");
                    return;
                }
            }
            System.out.println("No");

        } else {
            System.out.println("Yes");
        }


    }

}




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

int main() {
    int A, B; cin >> A >> B;
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if(!((i<A && s[i]<='9' && s[i]>='0') || (i==A && s[i]=='-') || (i>=A+1 && s[i]<='9' && s[i]>='0'))){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    vi c(N + 1);
    FOR(a, A)
    {
        ++c[a];
    }
    ll s = 0;
    REP1(i, N)
    {
        s += c[i] * (c[i] - 1) / 2;
    }
    FOR(a, A)
    {
        OUT(s - (c[a] - 1));
    }
}

Measured memory_bytes: 5760
#include<stdio.h>

#define SENTINEL 2000000000

long int cnt=0;//case#19で解がint型の最大値を越えるためlongを用いる

void merge(int *A,int left,int mid,int right)//分割した配列を小さい順に結合
{
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1],R[n2+1];
  int k,i,j;
  for (i=0;i<n1;i++) L[i] = A[left + i];
  for (i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = SENTINEL;//EOF
  R[n2] = SENTINEL;//EOF
  i = 0;
  j = 0;
    
  for(k=left;k<right;k++){//iが左の要素番号,jが右の要素番号
    if(L[i]<=R[j]){//左が小さい場合
      A[k] = L[i];
      i=i+1;
    }else{ //右が小さい場合
      A[k] = R[j];
      if(L[i]!=SENTINEL) cnt+=(n1-i);//SENTINELと比較する場合を除いて左側の未ソート部分の要素数をcntに加算
      j = j + 1;
    }
  }
}

void mergeSort(int *A,int left,int right)
{
  int mid,i;
  if(left+1<right){//二分探索のように左端が右端を超えたら終了
    mid = (left + right)/2;
    mergeSort(A, left, mid);//左半分で再帰
    mergeSort(A, mid, right);//右半分で再帰
    merge(A, left, mid, right);//結合
  }
}

int main(void)
{
    int n,i;
    int A[500001];
    int left,right;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    left=0;
    right=n;
    mergeSort(A,left,right);
    printf("%ld\n",cnt);
    
    return 0;
}


Measured memory_bytes: 3280
## atcoder problem 4 ever
dr = [0, -1, 0, 1]
dc = [1, 0, -1, 0]

def get_child(M, i, j, h, w, vis):
    child = []
    for k in range(4):
        x = i + dr[k]
        y = j + dc[k]
        if 0<= x< h and 0 <= y < w and (x, y) not in vis and M[x][y]!='#':
            child.append((x, y))

    return child

def bfs(M, i, j, h, w):
    vis = {(i, j): True}
    li = [(i, j, 0)]
    mx = 0
    while li:
        tp = li.pop(0)
        mx = max(mx, tp[2])
        ch = get_child(M, tp[0], tp[1], h, w, vis)
        vis.update( {}.fromkeys(ch, True) )
        
        ch = [(t[0], t[1], tp[2]+1) for t in ch]
        li.extend(ch)

    return mx
        
        
def solve(M, h, w):
    ans = 0
    for r in range(h):
        for c in range(w):
            if M[r][c]=='.':
                ## start bfs from this point
                depth = bfs(M, r, c, h, w)
                ans = max(ans, depth)
    print(ans)
h, w = map(int, input().split())
Mat = []
for row in range(h):
    Mat.append(input())


solve(Mat, h, w)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);


void solve(int T){
    ll a,b;
    cin>>a>>b;
    ll x=a+b;
    if(x%2==0){
        cout<<x/2<<"\n";
    }
    else cout<<"IMPOSSIBLE\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





Measured memory_bytes: 3620
using System;
using System.Collections.Generic;

class Program
    {
        static void Main(string[] args)
        {
            double N = int.Parse(Console.ReadLine());
            string[] vals = Console.ReadLine().Split();

            List<int> nums = new List<int>();

            for (int i = 0; i < N; i++)
            {
                nums.Add(int.Parse(vals[i]));
            }

            nums.Sort();

            double ans = (nums[0] + nums[1]) / Math.Pow(2.0 , N-1);

            for (int i = 2; i < N; i++)
            {
                ans += nums[i] / Math.Pow(2.0, N - i);
            }

            Console.WriteLine(ans);

        }
    }

Measured memory_bytes: 13268
sample = input() # two numbers in a string
new_sample = sample.split(" ")

ball = int(new_sample[0]) # number of balls
color = int(new_sample[1]) # number of colors
if ball > 1 and color == 1:
  print(0)
else:
  product = color
  for i in range(1, ball):
    product *= (color-1)
  print(product)

  
# 3 balls, 10 colors
# 1st spot, 10 choices
# 2nd spot, 9 choices
# 3rd spot, 9 choices


Measured memory_bytes: 9040
from collections import defaultdict
import sys
def calc(l,m,r,f,dp):
    a = f[l][m]
    b = f[m][r]
    res = dp[l][m]+dp[m][r]
    c = 0
    while a or b or c:
        a0 = a%10
        b0 = b%10
        res += a0*b0+c
        if res >= dp[l][r]:
            return dp[l][r]
        c = (a0+b0+c >= 10)
        a //= 10
        b //= 10
    return res

def solve():
    n = int(sys.stdin.readline())
    a = [int(x) for x in sys.stdin.readline().split()]
    dp = [[float("inf")]*(n+1) for i in range(n)]
    for i in range(n-1):
        a[i+1] += a[i]
    a.insert(0,0)
    f = [[0]*(n+1) for i in range(n)]
    for l in range(n):
        dp[l][l+1] = 0
        for r in range(l+1,n+1):
            f[l][r] = a[r]-a[l]
    for le in range(2,n+1):
        for l in range(n-le+1):
            r = l+le
            for m in range(l+1,r):
                dp[l][r] = calc(l,m,r,f,dp)
                
    print(dp[0][n])

if __name__ == "__main__":
    solve()



Measured memory_bytes: 10212
#include <iostream>
using namespace std;
 
int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if(x-r<0 || y-r<0 || x+r>w || y+r>h){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
     
    return 0;
}


Measured memory_bytes: 3104
n = int(input())
ans = float('inf')
# √nから１ずつ減らしていく
for i in range(int(n**0.5), 0, -1):
    # a*b=nになるところで、移動最初内なら更新
    if n%i == 0:
        ans = min(ans, (i - 1)+ (n // i - 1))  # a-1 + b-1が移動回数
print(ans)

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

int main() {
  int n, tmp, count = 1;
  cin >> n;
  tmp = n;
  for (int i = 0; i < 5; i++) {
    tmp /= 10;
    if (tmp == 0) break;
    count++;
  }
  if (count == 1) {
    cout << n << endl;
  } else if (count == 2) {
    cout << 9 << endl;
  } else if (count == 3) {
    if (n >= 200) tmp = ((n / 100) * 100) - 100;
    cout << tmp + (n % 100 + 1) + 9 << endl;
  } else if (count == 4) {
    cout << 909 << endl;
  } else if (count == 5) {
    if (n >= 20000) tmp = ((n / 10000) * 10000) - 10000;
    cout << tmp + (n % 10000 + 1) + 909 << endl;
  } else {
    cout << 90909 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
s = input()
K = int(input())
k = K

ans = ""
for i in range(len(s)-1):
    if(s[i] == "a"):
        ans += s[i]
        continue
    if(ord(s[i])+k >= ord("z")+1):
        ans += "a"
        k -= ord("z")+1-ord(s[i])
    else:
        ans += s[i]

a = ord(s[-1])+k%26
if(a > ord("z")):
    a -= 26
ans += chr(a)
    
print(ans)

Measured memory_bytes: 9336
import sys
lines = sys.stdin.readlines()
cnt = [0 for i in range(26)]
for line in lines:
    line = line.lower()
    alph = [chr(ord('a') + i) for i in range(26)]
    for idx, i in enumerate(alph):
        for k in line:
            if i == k:
                cnt[idx] += 1
for idx, i in enumerate(alph):
    print("{0} : {1}".format(i, cnt[idx]))


Measured memory_bytes: 5572
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  string s,t;
  cin >> s >> t;
  string ans = "";
  int start = -1;
  for(int i = 0 ; i < s.size() - t.size() + 1 ; i++ ){
    //cout << "i:" << i << endl;
    if(s[i] == t[0] || s[i] == '?' ){
      if(t.size() + i > s.size()){
        //P("continue done");
        continue;
      }
      bool f = false;
      for(int j = 0 ; j < t.size()  ; j++ ){
        //cout << "j:" << j << endl;
        //printf("s:%c t:%c\n",s[j+i],t[j]);
        if(s[i+j] != t[j] && s[i+j] != '?'){
          //cout << "done break" << endl;
          f = true;
          break;
        }
      }      
      if(!f){
        //P("done");
        //printf("start:%d i:%d\n",start , i);
        start = max(i,start);     
        //printf("start:%d i:%d\n",start , i);
      }
    }
  }

  if(start>=0){
    //P("start:"+start);
    for(int i = 0 ; i < t.size() ; i++ ){
      s[start+i] = t[i];
    }
    
    for(int i = 0 ; i < s.size() ; i++ ){
      if(s[i] == '?')
        s[i] = 'a';
    }

    P(s);
  }
  else{
    P("UNRESTORABLE");
  }
  ret 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vs= vector<string>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

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

  cout << (k/2)*((k+1)/2);
  
  return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;

    int ans = 0;
    for (int tsumugi = 0; tsumugi < 3; tsumugi++){
        if (s[tsumugi] == t[tsumugi]){
            ans++;
        }
    }

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

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

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::priority_queue;
using std::greater;
using std::max;
using std::min;

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

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int i = 1, N;
int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
	cin >> N;
	int cnt = 0;
	if(N == 1) cout << 1;
	else{
		while(i < N){
			cnt++;
			i*=2;
		}
		if(N < i) i/=2;
		cout << i;
	}
  return 0;
}


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

int main()
{
  int N;
  cin >> N;
  
  int d[110];
  rep(i, N)
  {
    cin >> d[i];
  }
  
  int bucket[110] = {0};
  for (int i = 0; i < N; i++)
  {
    bucket[d[i]]++;
  }
  
  int counter = 0;
  for (int i = 1; i <= 100; i++)
  {
    if (0 < bucket[i])
    {
      counter++;
    }
  }
  
  cout << counter << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int M; 
  cin >> M;

  int keta = 0, sum = 0;
  REP(i, M){
    int d, c;
    cin >> d >> c;
    sum += d*c;
    keta += c;
  }

  cout << (sum-1)/9+keta-1 << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,j,high[11]={0,0,0,0,0,0,0,0,0,0,'\0'};
	int change,judge;
	
	for(i=0;i<10;i++){
			scanf("%d",&high[i]);
	}
	for(j=0;j<20;j++){
	for(i=0;i<10;i++){
		judge = high[i]-high[i+1];
		if(judge < 0){
			change = high[i];
			high[i] = high[i+1];
			high[i+1] = change;
		}
	}
	}
		printf("%d\n",high[0]);
		printf("%d\n",high[1]);
		printf("%d\n",high[2]);
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>

int main(void)
{
  int n;
  char str[1024];

  scanf("%d%*c", &n);
  while (n--){
    str[0] = '\0';
    fgets(str, sizeof(str), stdin);
    while (strstr(str, "Hoshino") != NULL){
      *(strstr(str, "Hoshino") + 6) = 'a';
    }
    printf("%s", str);
  }

  return (0);
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

//SとS[i,|S|]の最長共通接頭辞の長さを記録した配列を
//線形時間で構築するアルゴリズム
vector<int> z_algorithm(const string &s) {
    int n = sz(s);
    vector<int> prefix(n);
    for (int i=1, j=0; i<n; i++) {
        if (i+prefix[i-j] < j+prefix[j]) {
            prefix[i] = prefix[i-j];
        }
        else {
            int k = max(0, j+prefix[j]-i);
            while (i+k < n && s[k] == s[i+k]) k++;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = n;
    return prefix;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    
    int ans = 0;
    rep(i, n) {
        vector<int> z = z_algorithm(s.substr(i, n-i));
        rep(j, sz(z)) {
            ans = max(ans, min(z[j], j));
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll t=n-1;
	ll res=0;
	for(ll i=1;i<=sqrt(n);i++)
	{
		if(t%i)
			continue;
		res++;
		if(t/i!=i)
			res++;
	}
	for(ll i=2;i<=sqrt(n);i++)
	{
		if(n%i)
			continue;
		ll z=n;
		while(z%i==0)
			z/=i;
		if(z%i==1)
			res++;
		if(n/i==i)
			continue;
		z=n;
		ll j=n/i;
		while(z%j==0)
			z/=j;
		if(z%j==1)
			res++;
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>


typedef long long ll;
typedef unsigned long long ull;

using namespace std;

#define drobucs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

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

	vector<int> v(n);

	for (auto &t : v) {
		cin >> t;
	}

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

	cout << v[n / 2] - v[n / 2 - 1];

	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   int n,a,b; scanf("%d%d%d",&n,&a,&b);
   if(n==1&&a!=b)puts("0");
   else if(a>b)puts("0");
   else{
      ll res=1LL*(b-a)*(n-2)+1;
      printf("%lld ",res);
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main()
{
	ll n,m,x,y,r,a,b,i;
     cin>>n>>m>>a>>b;
     x=INT_MIN,y=INT_MAX;
     for(i=0;i<n;i++)
     {
          cin>>r;
          x=max(x,r);
     }
     for(i=0;i<m;i++)
     {
          cin>>r;
          y=min(y,r);
     }
     for(i=a+1;i<=b;i++)
     {
          if(x<i and y>=i)
          break;
     }
     if(i<=b)
     cout<<"No War";
     else
     cout<<"War";
}


Measured memory_bytes: 256