akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

// ALL_PERM ここから
// 引数の関数にすべての順列を渡して実行する 実行した関数がtrueを返すと打ち切る
template <typename T, typename F>
void call_with_all_permutations(T a, F proc) {
#ifndef ALL
	static_assert(false, "ALL() is not defined.");
#endif

	do {
		if(proc(a)) {
			return;
		};
	} while(next_permutation(ALL(a)));
}
// ALL_PREM ここまで

int abs_diff(int a, int b) {
	if(a > b) {
		return a - b;
	}
	return b - a;
}

int main() {
	int n;
	scanf("%d", &n);
	VI p(n);
	VI q(n);
	EACH(e, p) { scanf("%d", &e); }
	EACH(e, q) { scanf("%d", &e); }
	int p_order = 0;
	int q_order = 0;
	VI perm(n);
	iota(ALL(perm), 1);
	call_with_all_permutations(perm, [&](auto v) {
		p_order++;
		if(v == p) {
			return true;
		}
		return false;
	});
	call_with_all_permutations(perm, [&](auto v) {
		q_order++;
		if(v == q) {
			return true;
		}
		return false;
	});
	printf("%d\n", abs_diff(p_order, q_order));
	return 0;
}

Measured memory_bytes: 256
N, M = (int(i) for i in input().split()) 

outs = [[] for i in range(N)]
ins = [0] * N

for _ in range(M):
    x, y = (int(i) for i in input().split())
    x -= 1
    y -= 1
    outs[x].append(y)
    ins[y] += 1

q = []
for i in range(N):
    if ins[i] == 0:
        q.append(i)

last = [0] * N
while q != []:
    qn = q.pop()
    for v in outs[qn]:
        ins[v] -= 1
        last[v] = max(last[v], last[qn] + 1)
        if ins[v] == 0:
            q.append(v)

print(max(last))


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


int main(void) {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  rep(i, n - k) {
    if (a[i] < a[i + k]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    string day[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT" };
    string S; cin >> S;
    int idx = 0; rep(i, 7) if(S == day[i]){idx = i; break;}
    cout << 7-idx << endl;
    return 0;
}

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

int main()
{
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    
    
    
    cout << a[2] << " "<< a[0] << " "<< a[1] << endl;
    
    
    
    return 0;
}

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

using namespace std;

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

    int red=0;
    int blue =0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1')
            red++;
        else if(s[i]=='0')
            blue++;
    }

    cout<<min(red,blue)*2<<endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

s=input()
n=len(s)
S=set()
k=int(input())
for j in range(1,k+1):
    for i in range(n-j+1):
        S.add(s[i:i+j])
L=sorted(S)
# print(L)
print(L[k-1])

Measured memory_bytes: 4464
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n)
    cin >> v[i];
  sort(v.begin(), v.end());
  cout << v[n/2] - v[n/2-1];
}


Measured memory_bytes: 640
package main
 
import (
  "fmt"
)
 
func main() {
  var n, k int
  fmt.Scan(&n, &k)
  ans := 0
  for c := k; c < n + 2; c++ {
    ans += c * (n - c + 1) + 1
    ans %= 1e9 + 7
  }
  fmt.Println(ans)
}

Measured memory_bytes: 1756
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string>

int main() 
{
	int n;
	scanf("%d", &n);
	int cnt = 0;
	for (int i = 1; i <= n / 2; i++) {
		int tmp = 2 * ((n - 1) / i) - ((i * 2) - 1);
		cnt += (tmp < 0) ? 0 : tmp;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 3011
#define mod 1000000007

int n, m, i, j, k;
ll dp[maxN][maxN][2];

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d%d", &n, &m);
    for (i = 0; i <= n; i++) dp[0][i][0] = 1;
    for (i = 0; i < m; i++) {
        for (j = 0; j <= n; j++) {
            for (k = 0; k < 2; k++) {
                dp[i][j][k] %= mod;

                if (j == 0) {
                    dp[i + 1][j][1] += dp[i][j][k];
                    dp[i + 1][j + 1][1] += dp[i][j][k];
                    continue;
                }

                if (j == 1) {
                    if (j != n) dp[i + 1][j][k] += dp[i][j][k];
                    dp[i + 1][j + 1][k] += dp[i][j][k];

                    dp[i + 1][j - 1][1] += dp[i][j][k];
                    dp[i + 1][j][1] += dp[i][j][k];
                    continue;
                }

                dp[i + 1][j - 1][k] += dp[i][j][k];
                dp[i + 1][j][k] += (j != n ? 2LL : 1LL) * dp[i][j][k];
                dp[i + 1][j + 1][k] += dp[i][j][k];
            }
        }
    }

    ll ans = 0;
    for (i = 0; i <= n; i++) ans += dp[m][i][1] % mod;
    ans %= mod;

    printf("%lld", ans);



    return 0;
}


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

namespace AtCoder
{
	public class Program
	{
		// ABC106-B
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			int result = 0;
			for (int i = 1; i <= N; i += 2) {
				int c = 0;
				for (int j = 1; j <= N; j += 2) {
					if (i%j==0) {
						c++;
					}
				}
				if (c == 8) {
					result++;
				}
			}
			Console.WriteLine(result);
		}
	}
}


Measured memory_bytes: 11092
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if a < b:
  if a+v*t >= b+w*t:
    print("YES")
  else:
    print("NO")
else:
  if a-v*t <= b-w*t:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 61656
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    vector<i64> a(N);
    vector<i64> cum(N + 1);

    read(a);
    rep(i, 0, N) {
        cum[i + 1] = cum[i] + a[i];
    }

    i64 ans = LINF;
    for (int i = 1; i <= N-1; ++i) {
        chmin(ans, abs((cum[i] - cum[0]) - (cum[N] - cum[i])));
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int a;
  int b;
  cin >> a >> b;
  
  if(a >= b){
    for(int i = 0;i < a;++i){
      cout << b;
    }
  }
  else{
    for(int i = 0;i < b;++i){
      cout << a;
    }
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, M = map(int,input().split())
    K = []
    A = []
    for n in range(N):
        d = list(map(int,input().split()))
        K.append(d[0])
        A.append(set(d[1:]))

    res = A[0]
    for a in A:
        res = res & a

    print(len(res))





if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]!='A')
		cout<<"WA";
	else
	{
		int len=s.length();
		if(s[1]>='a'&&s[1]<='z'&&s[len-1]>='a'&&s[len-1]<='z')
		{
			int flag=0;
			for(int i=2;i<len-1;i++)
			{
				if(s[i]=='C')
					flag++;
				else
				{
					if(s[i]<'a'||s[i]>'z')
					{
						flag=0;
						break;
					}
				}
			}
			if(flag==1)
				cout<<"AC";
			else
				cout<<"WA";
		}
		else
		cout<<"WA";
	} 
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int A = line[0], B = line[1];

            Console.WriteLine($"{(B % A == 0 ? A + B : B - A)}");
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(void)
{
	int m, d;
	int d1, d2;
	int temp, cnt = 0;

	scanf("%d %d", &m,&d);
	for (int i = 1; i <= m; i++) {
		for (int j = 10; j <= d; j++) {
			temp = j;
			d1 = temp % 10;
			temp /= 10;
			d2 = temp % 10;
			//printf(" %d %d %d\n", i,d2, d1);
			if (d1 >= 2 && d2 >= 2) {
				if (d1 * d2 == i) {
					cnt++;
				}
			}
		}
	}
	printf("%d\n", cnt);
	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair

using namespace std;

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

int main()
{

    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    //freopen("input.txt", "r", stdin);

    string s;
    cin >> s;

    for (int i = 0; i + 1 < sz(s); ++i) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << '\n';
            return 0;
        }
    }

    for (int i = 0; i + 2 < sz(s); ++i) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << "\n";
            return 0;
        }
    }
    cout << "-1 -1\n";

}


Measured memory_bytes: 512
#051
import sys

k, s = map(int,sys.stdin.readline().split())
cnt=0;

for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if(0<=z<=k):
            #print(x,y,z)
            cnt+=1
else:
    print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int n, maxnum, ansnum = 0;
    long long a[50], b[50];
    long long max;
    queue<int> quex,quey;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b,b+n);
    if(abs(b[n-1]) > abs(b[0])) max = b[n-1];
    else max = b[0];
    for(int i = 0; i < n; i++){
        if(a[i] == max){
            maxnum = i + 1;
            break;
        }
    }
    for(int i = 0; i < n; i++){
        if(max >= 0){
                quey.push(i+1);
                quex.push(maxnum);
        }else{
                quey.push(n-i);
                quex.push(maxnum);
        }
        ansnum++;
    }
    for(int i = 0; i < n-1; i++){
        if(max > 0){
            quey.push(i+2);
            quex.push(i+1);
        }
        else{
            quey.push(n-i-1);     
            quex.push(n-i);
        }
        ansnum++;
    }

    cout << ansnum << '\n';
    while(quey.size()){
        cout << quex.front() << ' ' << quey.front() << '\n';
        quex.pop();quey.pop();
    }
}

Measured memory_bytes: 256
program main
 implicit none
 character*80 s,a
 integer*8 i,j
 
 read(*,*) s
 a = s(1:1)
 j = 0
 do i=2,len_trim(s)
  if (a == s(i:i))then
   j = 1
  end if
  a = s(i:i)
 end do
 if(j==0) then
  write(*,*) 'Good'
 else
  write(*,*) 'Bad'
 end if
end program main

Measured memory_bytes: 768
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
    int N=0, M=0, C=0;
    cin >> N >> M >> C;
    int B[M], A[N][M];
    for(int i=0; i<M; ++i)
        B[i]=0;
    for(int i=0; i<N; ++i)
        for(int j=0; j<M; ++j)
            A[i][j]=0;
    for(int i=0; i<M; ++i)
        cin >> B[i];
    for(int i=0; i<N; ++i)
        for(int j=0; j<M; ++j)
            cin >> A[i][j];
    
    int ans=0;
    for(int i=0; i<N; ++i){
        int tmp=0;
        for(int j=0; j<M; ++j){
            tmp += A[i][j]*B[j];
        }
        tmp += C;
        if(tmp>0) ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[41],d[41][22],f[41],g,h[41],i,j,z,x;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a;i++){
			scanf("%d",&s[i]);
			f[i]=0;
			g=1;
			h[i]=0;
			while(1){
				scanf("%d",&d[i][f[i]]);
				h[i]+=d[i][f[i]];
				if(d[i][f[i]]==10&&g%2==1){
					g++;
				}
				g++;
				f[i]++;
				if(g==19) break;
			}
			scanf("%d %d",&d[i][f[i]],&d[i][f[i]+1]);
			h[i]+=d[i][f[i]]+d[i][f[i]+1];
			if(d[i][f[i]]+d[i][f[i]+1]>=10){
				scanf("%d",&d[i][f[i]+2]);
				h[i]+=d[i][f[i]+2];
			}
			z=0;
			for(j=0;j<f[i];j++){
				if(d[i][j]==10&&z==0){
					h[i]+=d[i][j+1]+d[i][j+2];
				}
				else if(z==0) z=1;
				else if(d[i][j-1]+d[i][j]==10&&z==1){
					h[i]+=d[i][j+1];
					z=0;
				}
				else if(z==1) z=0;
			}
		}
		x=0;
		for(i=0;i<a-1;i++){
			for(j=i+1;j<a;j++){
				if(h[i]<h[j]){
					x=h[i];
					h[i]=h[j];
					h[j]=x;
					x=s[i];
					s[i]=s[j];
					s[j]=x;
				}
				if(h[i]==h[j]){
					if(s[i]>s[j]){
						x=h[i];
						h[i]=h[j];
						h[j]=x;
						x=s[i];
						s[i]=s[j];
						s[j]=x;
					}
				}
			}
		}
		for(i=0;i<a;i++) printf("%d %d\n",s[i],h[i]);
	}
	return 0;
}

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

#define int long long

signed main(){

  while(true){
    int R0, W0, C, R;

    cin>>R0>>W0>>C>>R;

    if(!R0 && !W0 && !C && !R) break;

    if(R0 >= C * W0) {
      cout<<0<<endl;
      continue;
    }

    int ans = max(0ll, (C * W0 - R0 + R - 1) / R);

    cout<<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }


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

    ll r; cin >> r;
    cout << r * r << '\n';
}



Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
int n,a[303030];
int ans = 0, cnt[500];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    for(int j=0;j<=60;j++){
      if(a[i]&(1LL<<j)){
        cnt[j]++;
      }
    }
  }
  for(int i=0;i<61;i++){
    ans = ( ans + ((1LL<<i)%mod*cnt[i]%mod*(n-cnt[i])%mod) )%mod;
  }
  cout << ans << endl;
  



return 0;
}
///....


Measured memory_bytes: 2560
function main(input) {
  var n = input[0].split(" ")[0]-0;
  var m = input[0].split(" ")[1]-0;
  var x = input[1].split(" ").sort((a,b)=>a-b);

  var lens = [];
  for(var i=1;i<m;i++){
    lens.push(Math.abs(x[i]-x[i-1]));
  }
  lens.sort((a,b)=>a-b);
  var ans = 0;
  for(var i=0;i<=m-1-n;i++){
    ans += lens[i];
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 28952
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  
  for (int i = n; i < 1000; i++) {
    string s = to_string(i);
    
    if (s[0] == s[1] && s[0] == s[2]){
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os
import math

def print_square(A):
    print('---')
    for row in A:
        print(row)

# input square
A = []
for s in sys.stdin:
    lst = list(map(int, s.split(',')))
    A.append(lst)

# accumulated sum square
S = []
for a in A:
    S.append([None] * len(a))

S[0][0] = A[0][0]
for i in range(1, len(A) // 2 + 1):
    for j in range(len(A[i])):
        if j == 0:
            S[i][j] = S[i - 1][j] + A[i][j]
        elif j == len(A[i]) - 1:
            S[i][j] = S[i - 1][j - 1] + A[i][j]
        else:
            S[i][j] = max(S[i-1][j-1] + A[i][j], S[i-1][j] + A[i][j])

for i in range(len(A) // 2 + 1, len(A)):
    for j in range(len(A[i])):
        left = S[i - 1][j]
        right = S[i - 1][j + 1]
        S[i][j] = max(left, right) + A[i][j]

print(S[-1][0])

Measured memory_bytes: 7760
num = int(input())

town = [int(x) for x in input().split()]

fighter = [int(x) for x in input().split()]

ans = 0

for i in reversed(range(num)):
  if town[i+1] >= fighter[i]:
    ans += fighter[i]
    continue
  else:
    ans += town[i+1]
    amari = fighter[i] - town[i+1]
    
  if town[i] >= amari:
    ans += amari
    town[i] -= amari
  else:
    ans += town[i]
    town[i] = 0

print(ans)
    

Measured memory_bytes: 19648
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        mut s:Chars,
    }
    let n = s.len();

    //5  mod 13
    let mut dp = vec![vec![0; 13]; n + 1];

    s.reverse();
    if s[0] == '?' {
        for i in 0..=9 {
            dp[0][i] = 1;
        }
    } else {
        dp[0][charconv(s[0], '0')] = 1;
    }
    let mut keta = 10;
    for i in 1..n {
        if s[i] == '?' {
            for j in 0..=9 {
                for k in 0..13 {
                    let mm = (k + j * keta) % 13;
                    dp[i][mm] += dp[i - 1][k];
                    dp[i][mm] %= MOD;
                }
            }
        } else {
            let nm = charconv(s[i], '0');
            for k in 0..13 {
                let mm = (k + nm * keta) % 13;
                dp[i][mm] += dp[i - 1][k];
                dp[i][mm] %= MOD;
            }
        }
        keta = (keta * 10) % 13;
    }
    let mut ans = 0;
    // for i in 0..13 {
    //     ans += dp[n - 1][i];
    // }
    println!("{}", dp[n - 1][5]);
}
const MOD: usize = 1000000007;
pub fn charconv(c: char, base: char) -> usize {
    return (c as u8 - base as u8) as usize;
}


Measured memory_bytes: 15736
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    ll res = 0;
    FOR(i,1,n)
        FOR(j,1,n)
            FOR(k,1,n) res += gcd(i, gcd(j, k));
    cout << res;
    return 0;
}


Measured memory_bytes: 3668
import java.util.Scanner;
import java.util.Arrays;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i =0; i<N; i++) {
      A[i] = sc.nextInt();
    }
    Arrays.sort(A);
    boolean[] dp = new boolean[1000001];
    int count =0;
    for (int i =0; i<N; i++) {
      dp[A[i]] = true;
    }
    for (int i =0; i<N; i++) {
      if (i >0 && A[i] == A[i-1]) continue;
      int j = A[i] * 2;
      while (j < 1000001) {
        dp[j] = false;
        j+= A[i];
      }
    }
    for (int i =0; i<N; i++) {
      if (i <N-1 && A[i] == A[i+1]) {
        dp[A[i]] = false;
      }
      if (dp[A[i]] == true) {
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 49932
N = int(input())
S = input()

R = []

for i in range(N):
    s1 = list(set(list(S[:(i+1) ])))
    s2 = list(set(list(S[ (i+1):])))
    r = 0
    for s in s1:
        if (s in s2) == True:
            r += 1
    R.append(r)

print(max(R))


Measured memory_bytes: 3060
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;


ll N, ans;
bool flag = false;
ll H[100005];

int main() {

	cin >> N;
	FOR(i, 0, N) {
		cin >> H[i];
	}
	for (int i = N - 2; i >= 0; i--) {
		if (H[i] > H[i + 1]) {
			H[i]--;
		}
		if (H[i] > H[i + 1]) {
			flag = true;
			break;
		}
	}
	if (flag)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>

int main(){
	int n = 1;
	
	while(n){
		scanf("%d", &n);
		if(n == 0)break;
		int ac, bc;
		ac = bc = 0;
		for(int i = 0;i < n;i++){
		int a, b;
		scanf("%d%d", &a, &b);
			if(a > b){ac += a + b;}
			else if(a == b){ac += a, bc += b;}
			else {bc += a + b;}
		}
		printf("%d %d\n", ac, bc);
	}
	return 0;
}

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

int main(){
    uint_fast32_t N, W;
    scanf("%u%u", &N, &W);

    vector<int_fast64_t> ans(W + 1);

    {
        int_fast64_t w, v;
        for(auto i = 0; i < N; ++i){
            scanf("%lld%lld", &w, &v);

            for(auto j = W; j >= w; --j){
                ans[j] = max(ans[j], ans[j - w] + v);
            }
        }
    }

    printf("%lld\n", *ans.rbegin());
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59
 
ll h,w;
ll s[70][70];

bool valid(ll a,ll b){
  if(s[a][b]==1&&a>=0&&a<h&&b>=0&&b<w) return 1;
  else return 0;
}
 
int main(){
  
  ll i,j;
  cin>>h>>w;
  ll white=0;
 
  char x;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin>>x;
      if(x=='.') {
        s[i][j]=1;
        white++;
      }
      else s[i][j]=0;
    }
  }
  VVI used(h+10,VI(w+10,0));
 
  queue <pair<ll,P> > p;
  p.push(make_pair(1,P(0,0)));
  used[0][0]=1;
 
  P d[4];
  d[0]=P(1,0);
  d[1]=P(0,1);
  d[2]=P(-1,0);
  d[3]=P(0,-1);
  
  ll v,vv;
 
  while(!p.empty()){
    auto x=p.front();
    p.pop();
    P z=x.se;
    for(ll k=0;k<4;k++){
      v=z.fi+d[k].fi;
      vv=z.se+d[k].se;
      if(valid(v,vv)&&used[v][vv]==0){
        if(v==h-1&&vv==w-1){
          cout<<white-(x.fi+1)<<endl;
          return 0;
        }
        p.push(make_pair(x.fi+1,P(v,vv)));
        used[v][vv]=1;
      }
    }
  }
  cout<<-1<<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll n;
ll f[10000007];
ll ans=0;
int main() {
	cin>>n;
	for(int i=1; i<=n; i++)
		for(int j=1; j*i<=n; j++)
			f[i*j]++;
	for(int i=1; i<=n; i++)
		ans+=i*f[i];
	cout<<ans;
	return 0;
}

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

using namespace std;

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

	vector<vector<int>> num(N, vector<int>(2));
	if (N == 1) num.at(0).at(0) = 0;
	else num.at(0).at(0) = 1;
	num.at(0).at(1) = 0;

	for (int i = 1; i < N; i++) {
		num.at(i).at(0) = 0;
		num.at(i).at(1) = 0;
	}

	bool ans = true;
	for (int i = 0; i < M; i++) {
		int s, c;
		cin >> s >> c;

		if (num.at(s - 1).at(1) > 0) {
			if (num.at(s - 1).at(0) != c) {
				ans = false;
			}
		}
		
		num.at(s - 1).at(0) = c;
		num.at(s - 1).at(1)++;
	}

	if (num.at(0).at(0) == 0 && N != 1) ans = false;
	int x = 1;

	if (ans) {
		x = num.at(0).at(0);
		if (N > 1) {
			for (int i = 1; i < N; i++) {
				x *= 10;
				x += num.at(i).at(0);
			}
		}
	}
	else {
		x = -1;
	}

	cout << x << endl;

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    vector<int> sub(n-1);
    for(int i = 0; i < n-1; i++){
        sub[i]=v[i+1]-v[i];
        //cout << "sub:" << sub[i] << endl;
    }
    vector<int> count;
    int num = 0;
    for(int i = 0; i < sub.size(); i++){
        if(sub[i] <= 0){
            num++;
        }
        else {
            /*
            if(num!=0){
                //num++;
            }
            */
            count.push_back(num);
            num=0;
        }

    }
    count.push_back(num);
    sort(count.begin(), count.end());
    cout << count[count.size()-1] << endl;
}

Measured memory_bytes: 1660
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		Iroha solver = new Iroha();

//		System.out.println(solver.solve(input));
		System.out.println(solver.anotherSolve(input));

    }

    static class Iroha {

    	public String anotherSolve(String input) {
    		List<Integer> inputList = new ArrayList<Integer>();
    		int five = 0;
    		int seven = 0;

    		for(String s:input.split(" ")) {
    			if(Integer.parseInt(s)== 5) {
    				five++;
    			} else if (Integer.parseInt(s)==7) {
    				seven++;
    			}
    		}
    		if (five == 2 && seven == 1) {
    			return "YES";
    		} else {
    			return "NO";
    		}
    	}
    }

}


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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    int lastDigit = n % 10;
    n /= 10;
    if (lastDigit == 7) {
      cout << "Yes\n";
      exit(0);
    }
  }
  cout << "No\n";
}
  

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;



ll n,k;
ll dp[3000010];
const ll mod=1000000007;
int main(){
FLASH;
cin.tie(0);
cout.tie(0);
cin>>n;
dp[0]=1;
for(ll i=0;i<=n;i++)
{
  for(ll j=3;j<=n;j++)
  {
	  dp[i+j]=(dp[i]+dp[i+j])%mod;
  }
}
cout<<dp[n]<<endl;
 
 
 
 
 
 
return 0;
} 

Measured memory_bytes: 3632
h,w=map(int, input().split())
S=['']*h
for i in range(h):
    S[i]=list(map(str, input().split()))
for i in range(h):
    for j in range(w):
        if S[i][j]=='snuke':
            f=chr(65+j)
            g=str(i+1)
            print(f+g)
            exit()
exit()


Measured memory_bytes: 3060
import scala.io.StdIn
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val a = StdIn.readInt
    REP(3) {_ => StdIn.readInt}
    val e = StdIn.readInt
    val k = StdIn.readInt

    println(if (e - a <= k) {"Yay!" } else ":(")
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while (i < N) { f(i); i += 1 }
  }
}

Measured memory_bytes: 27208
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while (true){
            int r = sc.nextInt();
            int c = sc.nextInt();
            if (r == 0 || c==0) break;
            if (r*c %2 ==0) System.out.println("yes");
            else System.out.println("no");
        }
    }
}


Measured memory_bytes: 29116
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <iostream>
#include <limits>
#include <random>
#include <utility>
#include <vector>

namespace procon {
  class UnionFind {
  private:
    struct nodeinfo {
      int par;
      int rank;
      nodeinfo(int par) : par(par), rank(0) {}
    };
    std::vector<nodeinfo> node;

  public:
    UnionFind(int n) : node() {
      node.reserve(n);
      for (int i = 0; i < n; ++i) {
	node.push_back(nodeinfo(i));
      }
    }
    int root(int x) {
      if (node[x].par == x) {
	return x;
      }
      return node[x].par = root(node[x].par);
    }
    void unite(int x, int y) {
      x = root(x);
      y = root(y);
      if (x == y) {
	return;
      }
      if (node[x].rank < node[y].rank) {
	node[x].par = y;
      } else {
	node[y].par = x;
	if (node[x].rank == node[y].rank) {
	  ++node[x].rank;
	}
      }
    }
    bool is_same_set(int x, int y) { return root(x) == root(y); }
  };
}
  
int main(void) {
  int size, n_query, n_block;
  std::cin.read((char *)&size, sizeof(int));
  std::cin.read((char *)&n_query, sizeof(int));
  std::cin.read((char *)&n_block, sizeof(int));

  std::vector<uint64_t> query(n_query);
  std::vector<int> block(n_block);
  std::cin.read((char *)query.data(), sizeof(uint64_t) * n_query);
  std::cin.read((char *)block.data(), sizeof(int) * n_block);
  

  const int mask = (1 << 30) - 1;

  uint64_t res = 123456789;
  for(int b: block) {
    procon::UnionFind uf(size);
    for (int i = 0; i < n_query; ++i) {
      uint64_t q = query[(b + i) % n_query];
      const int com = q >> 60;
      const int x = (q >> 30) & mask;
      const int y = (q >> 0) & mask;
      assert(0 <= x && x < size);
      assert(0 <= y && y < size);
      if (com) {
        res = res * 17 + (uf.is_same_set(x, y) ? 1 : 0);
      } else {
        uf.unite(x, y);
      }
    }
  }
  std::cout << res << std::endl;
  return 0;
}



Measured memory_bytes: 11476
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int t=0;
	int r;	
	while(n>0){
		r=n%10;
		if(r==7){
			cout << "Yes";
			t=1;
			break;
		}
		n=n/10;		
	}
	
	if(t==0)
		cout << "No";
		
	return 0;
}


Measured memory_bytes: 3588
n = gets.to_i
a = gets.split.map(&:to_i)

min = 1000000001

count = 0
a.each do |i|
  count += 1 if i < 0
  min = i.abs if i.abs < min
end

abs_a = a.map(&:abs)
sum = 0
abs_a.each do |i|
  sum += i
end
sum -= min*2 if count%2 == 1

puts sum

Measured memory_bytes: 11396
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};
const main=()=>{
  let s=ts(),c=0
  for(let i=0;i<s.length;i++){
    if(i%2===0&&s[i]==='0'){
      c++
    }else if(i%2===1&&s[i]==='1'){
      c++
    }
  }
  if(c>=s.length/2){
    to(s.length-c)
  }else{
    to(c)
  }
}
main()


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	vector<lint> sum(n+1);
	rep(i,n) sum[i+1]=sum[i]+a[i];

	lint ans=INF;
	rep(i,n-1){
		lint left=sum[i+1];
		lint right=sum[n]-left;
		ans=min(ans,abs(right-left));
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		long N = Int64.Parse(args[0]);
		long M = Int64.Parse(args[1]);

		long ans = 0;
		if((N == 1) && (M == 1))
			ans = 1;
		else if(N == 1)
			ans = M - 2;
		else if(M == 1)
			ans = N - 2;
		else
			ans = (M - 2) * (N - 2);
		Console.WriteLine(ans);
	}
}





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


#define rep(i, c) for (int i = 0; i < c; i++)
#define rep_neg(i, c) for (int i = c - 1; i > -1; i--)
#define MOD 1000000000 + 7


int main(){
    int H, W;
    cin >> H >> W;
    string S[H];
    rep(i, H){
        cin >> S[i];
    }
    int Left[H][W];
    int Right[H][W];
    int Up[H][W];
    int Down[H][W];

    rep(h, H){
        rep(w, W){
            if (S[h][w] == '#'){
                Left[h][w] = -1;
                Up[h][w] = -1;
            } else {
                if (w == 0) Left[h][w] = 0;
                else Left[h][w] = Left[h][w - 1] + 1;
                if (h == 0) Up[h][w] = 0;
                else Up[h][w] = Up[h - 1][w] + 1;
            }
        }
    }
    rep_neg(h, H){
        rep_neg(w, W){
            if (S[h][w] == '#'){
                Right[h][w] = -1;
                Down[h][w] = -1;
            } else {
                if (w == W - 1) Right[h][w] = 0;
                else Right[h][w] = Right[h][w + 1] + 1;
                if (h == H - 1) Down[h][w] = 0;
                else Down[h][w] = Down[h + 1][w] + 1;
            } 
        }
    }
    int ans_grid[H][W];
    int ans_max[H];
    int res = 1;
    rep(h, H){
        rep(w, W){
            ans_grid[h][w] = Up[h][w] + Down[h][w] + Left[h][w] + Right[h][w] + 1;
            if (res < ans_grid[h][w]){
                res = ans_grid[h][w];
            }
        }
    }
    cout << res << endl;

}

Measured memory_bytes: 82432
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18
# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}



int main(){
    IOS;
    make2(ll,a,b);
    cout<<a*b<<endl;




    return 0;
}


Measured memory_bytes: 3636
var objStr={};
var objNum={};
var abc="abcdefghijklmnopqrstuvwxyz".split("");
abc.forEach(function(v,i){
   objStr[v]=i;
   objNum[i]=v;
});

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var N=Arr.shift()-0;
   if(N==0)break;
   var str=Arr.shift();
   var AB=[];
   for(var i=0;i<N;i++){
      var ab=(Arr.shift()).split(" ").map(Number);
      AB.push(ab);
   }
   AB.reverse();
   var s=str.split("");
   for(var i=0;i<N;i++){
      var ab=AB[i];
      var plus=ab[1]-ab[0];
      var m1=s[ab[0]-1];
      var m2=s[ab[1]-1];
      var n1=objStr[m1]+plus;
      var n2=objStr[m2]+plus;
      s[ab[0]-1]=objNum[n2%abc.length];
      s[ab[1]-1]=objNum[n1%abc.length];
   }
   console.log(s.join(""));
}

Measured memory_bytes: 9452
#include<cstdio>
#define ll long long
using namespace std;
inline ll read()
{
    ll x=0;bool f=1;char c=getchar();
    if(c==EOF) return 0;
    while(c<'0' || c>'9'){if(c=='-') f=0;c=getchar();}
    while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return f?x:-x;
}
ll n,m;
int main()
{
    n=read(),m=read();
    if(n==1 || m==1) puts("1");
    else printf("%lld\n",(n*m+1)/2);
    return 0;
}


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


int main(){
        int N;
        std::cin >> N ;
        std::vector<int> heights(N);
        for(int i = 0; i< N ; i++){
            std::cin >> heights[i] ; 
            // std::cout << heights[i] << std::endl;
        }
        // std::cout << heights[0] << "\n";
        // std::cout << heights[1] << "\n";


        // Writing the dp funcction 
        const int INF = 10e9 + 5 ;

        std::vector<int> dp(N,INF);
        dp[0] = 0;
        for(int i=0; i< N; i++){
            for(int j :{i+1, i+2}){
                if(j < N){
                    dp[j] =std::min(dp[j], dp[i] + abs(heights[j] -heights[i]));

                }
            }
        }
        // std::vector<int> dp(n, INF);
    //      dp[0] = 0;
    // for(int i = 0; i < n; ++i) {
    //     for(int j : {i + 1, i + 2}) {
    //         if(j < n) {
    //             dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
    //         }
    //     }
    // }
        std::cout << dp[N-1] << std::endl;


        return 0;


}

Measured memory_bytes: 1152
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N, X, Y = input_nums()
    dist = {}
    for i in range(1, N):
        dist[i] = 0
    for s in range(1, N):
        for g in range(s+1, N+1):
            if X == s and Y == g:
                dist[1] += 1
                continue
            a = abs(X - s) + abs(Y - g) + 1
            b = g - s
            if a < b:
                dist[a] += 1
            else:
                dist[b] += 1
    for i in range(1, N):
        print(dist[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 45916
S = input()
N = len(S)
first = int(S[0:3])
minDis = abs(753 - first)
for i in range(1, N-2, 1):
    Now = int(S[i:i+3])
    disNow = abs(753 - Now)
    if disNow < minDis:
        minDis = disNow
print(minDis)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if  (b>a)   swap(a,b);
    if  (c>a)   swap(a,c);
    a*=1<<k;
    printf("%d\n",a+b+c);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int now = 0;
    rep(i,4) {
        if(s[i] == '+') now++;
        else now--;
    }
    cout << now << endl;
}


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

int n={},m={},map[92][92]={};
int checked[92][92]={};
int i={},t={},p={},w={};
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};



int ices(int x,int y){
    
    priority_queue<int>sum_of_ices;
    
    if(map[x][y]==0)return 0;
    
    if(checked[x][y]==1)return 0;
    
    checked[x][y]=1;
    
    for(int i=0;i<=3;i++){
    	sum_of_ices.push(ices(x + dx[i],y + dy[i]));
    }
	
	checked[x][y]=0;
	
	return sum_of_ices.top() +1;
}


int main(){

	for(int i=0;i<=1;i--){
		
    cin >> m >> n;
    
    if(m==0&&n==0)break;
    
    for(int i=1;i<=n;i++){
        for(int p=1;p<=m;p++){
            cin >> map[i][p];
        }
    }
    
    priority_queue<int>sum_of_sum;
    
    for(int i=1;i<=n;i++){
        for(int p=1;p<=m;p++){
            sum_of_sum.push(ices(i,p));
        }
    }
    
    cout << sum_of_sum.top() << endl;
    
	}
    
    return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <map>
using namespace std;
int n, m, mx;
string s[105], t;
map<string, int> mp;
int main() {
	int i;
	cin>>n;
	for(i=0; i<n; i++) cin>>s[i], mp[s[i]]++;
	cin>>m;
	while(m--) cin>>t, mp[t]--;
	for(i=0; i<n; i++) mx = max(mx, mp[s[i]]);
	cout<<mx;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i=0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i=0; i < N; i++) {
    for (int j=i+1; j < N; j++) {
      int a = L.at(i); int b = L.at(j);
      int d = lower_bound(L.begin(), L.end(), a + b) - L.begin();
      ans += max(0, d - j - 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# E
B, W = map(int, input().split())

LARGE = 10**9 + 7

# pre compute
modulo = [0]*(2*10**5+1)
modulo[0] = 1
for i in range(1, 2*10**5+1):
    modulo[i] =(5*10**8 + 4) * modulo[i-1] % LARGE

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m    
    
frac_mod = [0]*(2*10**5+1)
frac_inv_mod = [0]*(2*10**5+1)
frac_mod[0] = 1
frac_inv_mod[0] = 1
frac_mod[1] = 1
frac_inv_mod[1] = 1

for i in range(2, 2*10**5+1):
    frac_mod[i] = frac_mod[i-1]*i % LARGE
    frac_inv_mod[i] = frac_inv_mod[i-1]*modinv(i, LARGE) % LARGE

B_lost_list = [0]*(B+W)
W_lost_list = [0]*(B+W)

def nCk_mod(n, k):
    return frac_mod[n]*frac_inv_mod[k]*frac_inv_mod[n-k] % LARGE

for n in range(B, B+W):
    B_lost_list[n] = nCk_mod(n-1, B-1)*modulo[n]
    
for n in range(W, B+W):
    W_lost_list[n] = nCk_mod(n-1, W-1)*modulo[n]
    
# must be B
b = 0
w = 0
for i in range(B+W):
    b = (b + B_lost_list[i]) % LARGE
    w = (w + W_lost_list[i]) % LARGE
    
    print((500000004 + w * 500000004 - b * 500000004) % LARGE)

Measured memory_bytes: 124348