akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> red(h, vector<int>(w));
    vector<vector<int>> blue(h, vector<int>(w));

    rep(y, h)rep(x, w)cin >> red[y][x];
    rep(y, h)rep(x, w)cin >> blue[y][x];

    const int MAX = (80 + 80) * 80;

    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(MAX, false)));
    dp[0][0][abs(red[0][0] - blue[0][0])] = true;

    rep(y, h) {
        rep(x, w) {
            // 上から
            int k = red[y][x] - blue[y][x];

            if (y != 0) {
                rep(p, MAX) {
                    if (!dp[y - 1][x][p]) continue;
                    dp[y][x][abs(p + k)] = true;
                    dp[y][x][abs(p - k)] = true;
                }
            }

            if (x != 0) {
                rep(p, MAX) {
                    if (!dp[y][x - 1][p]) continue;
                    dp[y][x][abs(p + k)] = true;
                    dp[y][x][abs(p - k)] = true;
                }
            }
        }
    }

    int ans = INT_MAX;
    rep(i, MAX) if (dp[h - 1][w - 1][i]) cmin(ans, i);
    cout << ans << endl;

}


Measured memory_bytes: 13964
s = input()
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
ans = 'Yes'
if len(d.keys()) != 2:
    ans = 'No'
for i in d.keys():
    if d[i] != 2:
        ans = 'No'
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;


int main(){
    double t,x;
    cin >> t >> x;
    double ans = t / x;
    printf("%.12lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
import numpy as np
from numba import jit


@jit
def main(n):
    dp = np.zeros(n+1,np.int64)
    #dp[1]=1
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            dp[j]+=1
    dp*=np.arange(n+1)
    return dp.sum()

n = int(input())
print(main(n))

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 10;

int n;
set<int> S;

int main()
{
	cin >> n;
	while (n -- )
	{
		int x;
		cin >> x;
		if (S.count(x))
		{
			puts("NO");
			return 0;
		}
		S.insert(x);
	}
	puts("YES");
	return 0;
}

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

using namespace std;

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

    vector<char> r(0);
    for (long long i = n; i > 0; i = (i - 1) / 26) {
        r.push_back('a' + (i - 1) % 26);
    }

    for (int i = r.size() - 1; i >= 0; i--) {
        cout << r[i];
    }
    cout << endl;
}


Measured memory_bytes: 3604
n=int(input())
a=[int(i) for i in input().split()]
flag=0
for i in range(0,len(a)):
    if(a[i]%2==0 and (a[i]%3==0 or a[i]%5==0)):
        pass
    elif(a[i]%2==0 and (a[i]%3!=0 or a[i]%5!=0)):
        flag=1
        break
if(flag==1):
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 61744
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7
INF = 10**18

A,B,Q = MAP()
s = [-INF] + [INT() for _ in range(A)] + [INF]
t = [-INF] + [INT() for _ in range(B)] + [INF]

for i in range(Q):
    cur = INT()
    s_idx = bisect.bisect_right(s,cur)
    t_idx = bisect.bisect_right(t,cur)
    res = INF
    for S in [s[s_idx-1],s[s_idx]]:
        for T in [t[t_idx-1],t[t_idx]]:
            d1,d2 = abs(S-cur) + abs(T-S),abs(T-cur)+abs(S-T)
            res = min(res,d1,d2)
    print(res)

Measured memory_bytes: 14300
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
#include<string.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

struct edge{
	int to;
	int cap;
	int rev;
};

struct flow{
	vector<edge> G[1002];
	bool used[1002];
	void add_edge(int from,int to,int cap){
			edge a = {to,cap,(int)G[to].size()};
			edge b = {from,0,(int)G[from].size()};
		G[from].push_back(a);
		G[to].push_back(b);
	}
	int dfs(int v,int t,int f){
		if(v == t)return f;
		used[v] = true;
		for(int i = 0 ; i < G[v].size() ; i ++){
			edge &e = G[v][i];
			if(!used[e.to] && e.cap > 0){
				int d = dfs(e.to,t,min(f,e.cap));
				if(d > 0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	int max_flow(int s,int t){
		int flow = 0;
		while(1){
			rep(i,1002)used[i] = false;
			int f = dfs(s,t,INF);
			if(f == 0)return flow;
			flow += f;
		}
	}
	void init(){
		rep(i,1002)G[i].clear();
	}
}F;

int flag[1002];
void dfs(int v){
	if(flag[v] == 1)return;
	flag[v] = 1;
	rep(i,F.G[v].size()){
		edge ed = F.G[v][i];
		if(ed.cap > 0)dfs(ed.to);
	}
}
void dfs_rev(int v){
	if(flag[v] == -1)return;
	flag[v] = -1;
	rep(i,F.G[v].size()){
		edge ed = F.G[v][i];
		if(ed.cap == 0)dfs_rev(ed.to);
	}
}

int main(){
	while(1){
		int n,m,s,t;
		cin >> n >> m >> s >> t;
		if(n == 0)return 0;
		int a[10002],b[10002];
		rep(i,m){
			scanf("%d%d",&a[i],&b[i]);
		}
		
		F.init();
		rep(i,m){
			F.add_edge(a[i],b[i],1);
		}
		int ret = F.max_flow(s,t);
		rep1(i,n)flag[i] = 0;
		dfs(s);
		dfs_rev(t);
		int cnt = 0;
		rep(i,m){
			if(flag[a[i]] == -1 && flag[b[i]] == 1)cnt ++;
		}
		printf("%d %d\n",ret+(cnt==0?0:1),cnt);
	}
}

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

int main() {
  int N,M;
  cin >> N >> M;
  string A = "";
  string B = "";
  for( int c = 0; c < M; c++ ) {
    A += to_string(N);
  }
  for( int c = 0; c < N; c++ ) {
    B += to_string(M);
  }

  if( A <= B ) {
    cout << A << endl;
  }
  else {
    cout << B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
data = [int(s) for s in input()]
count1 = 0
if data[0] == 0:
  
  
  for s in range(1,len(data)):
    
    
    
    if s % 2 == 0:
        if data[s] != 0:
            count1 += 1
    else :
        if data[s] != 1:
            count1 += 1
            
else:
  
  
  for s in range(1,len(data)):
    
    if s % 2 == 0:
      if data[s] != 1:
        count1 += 1
        
    else:
      if data[s] != 0:
        count1 += 1
          


print(count1)


Measured memory_bytes: 3956
n=int(input())
s=len(bin(n))-2
if 2**(s-1)==n:
  print("No")
elif n==3:
  print("Yes")
  for i in range(1,6):
    print(i,i+1)
else:
  print("Yes")
  print(2**(s-1)-1,1+n)
  for i in range(1,2**(s-1)-1):
    print(i,i+1)
    print(i+n,i+n+1)
  print(2**(s-1),2**(s-1)+1)
  print(2**(s-1)+1+n,1)
  print(2**(s-1),1)
  print(2**(s-1)+n,2**(s-1)+1+n)
  for i in range(2**(s-1)+2,n+1):
    print(i,i-1+n)
    print(i+n,i-2**(s-1))
    
      


Measured memory_bytes: 5892
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	while (true) {
		LL n = -1;
		cin >> n;
		if (n <= 0) break;
		string s;
		cin >> s;
		int len = s.length();
		int ans = 0;
		for (int i = 1; i < len; ++i) {
			int cnt = 0;
			for (int j = 0; i + j < len; ++j) {
				if (s[j] == s[i + j]) {
					ans = max(ans, ++cnt);
					if (cnt >= i) {
						break;
					}
				} else {
					cnt = 0;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n,k;
      	cin>>n>>k;
      	int a[n],dp[n];
      	for (int i=0;i<n;i++) dp[i]=1000000000;
      	for (int i=0;i<n;i++) cin>>a[i];
      	if(n>2) dp[0]=0;
      	else { cout<<abs(a[1]-a[0]); return 0; }
      	for (int i=0;i<n;i++)
      	{
      	    for (int j=i+1;j<=i+k;j++)
      	    {

  	        if(j<n)
  	            dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
  	    }
  	}
  	cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;
 
public class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] S = new string[2];
        double a = 0;
        string b = " ";
        double jpy=0;
        
       for(int i=0;i<N;i++)
       {
       S= Console.ReadLine().Split(' ');
       a = double.Parse(S[0]);
       b = S[1];
       if(b=="JPY")jpy+=a;
       else     jpy+=380000.0*a;
        }
      Console.WriteLine(jpy);
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve() {
    int ans = 0;

    bool V[MAX];
    for (int i = 0; i < n; i++) {
        B[i] = A[i];
        V[i] = false;
    }
    sort(B, B+n);
    for (int i = 0; i < n; i++) {
        T[B[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        if ( V[i] ) continue;
        int cur = i;
        int S = 0;
        int m = VMAX;
        int an = 0;
        while (1) {
            V[cur] = true;
            an++;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if (V[cur] ) break;
        }
        ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
    }
    return ans;
}

int main() {
    cin >> n;
    s = VMAX;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        s = min(s, A[i]);
    }
    int ans = solve();
    cout << ans << '\n';
}




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

using namespace std;
using int64 = long long int;

template<typename T> class BinaryIndexedTree
{
private:
	int n;
	vector<T> pSum;

public:
	BinaryIndexedTree(int size) : n(size), pSum(size) {}

	void Add(int no, const T &value)
	{
		for (int i = no; i < n; i |= i + 1)
		{
			pSum[i] += value;
		}
	}

	// endは含まない
	T Sum(int end)
	{
		T sum = 0;
		for (int i = end - 1; i >= 0; i = (i & (i + 1)) - 1)
		{
			sum += pSum[i];
		}
		return sum;
	}
};


int main()
{
	int n, q;
	string s;

	cin >> n >> s >> q;

	vector<BinaryIndexedTree<int>> trees(30, BinaryIndexedTree<int>(s.length() + 10));
	for (int i = 0; i < s.length(); i++)
	{
		trees[s[i] - 'a'].Add(i + 1, 1);
	}

	for (int _ = 0; _ < q; _++)
	{
		int no;
		cin >> no;
		if (no == 1)
		{
			int i;
			string c;
			cin >> i >> c;
			i--;

			trees[s[i] - 'a'].Add(i + 1, -1);
			s[i] = c[0];
			trees[s[i] - 'a'].Add(i + 1, 1);
		}
		else
		{
			int l, r;
			cin >> l >> r;
			l--;
			// [l, r)
			// [l + 1, r + 1)

			int answer = 0;
			for (int i = 0; i < ('z' - 'a' + 1); i++)
			{
				int sum = trees[i].Sum(r + 1) - trees[i].Sum(l + 1);
				if (sum > 0)
				{
					answer++;
				}
			}
			cout << answer << endl;
		}
	}
}

Measured memory_bytes: 61444
N = int(input())

rs, bs = [], []  # (x, y, pair_flag)

for _ in range(N):
    rs.append(list(map(int, input().split())) + [0])

for _ in range(N):
    bs.append(list(map(int, input().split())) + [0])

rs.sort(key=lambda x: x[1])
bs.sort()

npair = 0
ir, ib = 0, 0
while ib < N:
    bx, by, _ = bs[ib]
    ir = N-1
    while ir >= 0:
        rx, ry, paired = rs[ir]
        if not paired and rx < bx and ry < by:
            rs[ir][2] = bs[ib][2] = 1
            npair += 1
            break
        ir -= 1
    ib += 1

print(npair)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j);a×b行列の入力
 
int main() {
  ll a;
  ci(a);
  vec h(a);
  for(i,0,a)
    ci(h[i]);
  ll b=0,c=0;
  for(i,1,a){
    if(h[i-1]>=h[i]){
      b++;
      c=max(c,b);
    }
    else
      b=0;
  }
  co(c);
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
  long long n, m;
  std::cin >> n >> m;
  long long result = 1;
  for (long long i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      long long j = m / i;
      if (n <= m / j) {
        result = std::max(result, j);
      }
      if (n <= m / i) {
        result = std::max(result, i);
      }
    }
  }
  std::cout << result << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, i, j, k;

    while(1){

    scanf("%d %d", &a, &b);

    if(a == 0 && b == 0)
    break;

    for(i = 1; i <= a; i++)
    {
        if(i % 2 == 0)
        {
            for(k = 1; k <= b; k++)
            {
                if(k % 2 == 0)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                } 
            }
        }
        else
        {
            for(j = 1; j <= b; j++)
            {
            if(j % 2 == 0)
                {
                    printf(".");
                }
                else
                {
                    printf("#");
                } 
            }
        }
        

        printf("\n");
    }

    printf("\n");

    }

    return 0;
}


Measured memory_bytes: 2696
N = gets.to_s.to_i

f = Array.new(N){ gets.to_s.split.map{|t|t.to_i} }
r = Array.new(N){ gets.to_s.split.map{|t|t.to_i} }

ans = -(10**7)*N

[0, 1].repeated_permutation(10).with_index(0) do |a,i|
  next if i == 0
  
  tmp = 0
  N.times do |j|
    cnt = 0
    10.times{ |k| cnt += 1 if a[k] == 1 && f[j][k] == 1 }
    tmp += r[j][cnt]
  end
  
  ans = tmp if ans < tmp
end

puts ans

Measured memory_bytes: 1916
#include<iostream>
using namespace std;
int main(void){
   int n,a,b,c;
   cin >> n;
      for(int i=0;i<n;i++){
            cin>>a>>b>>c;
            if(a*a + b*b == c*c)    cout<<"YES"<<endl;
            else if(c*c + a*a == b*b )    cout<<"YES"<<endl;
            else if(b*b + c*c == a*a)    cout<<"YES"<<endl;
            else    cout<<"NO"<<endl;
        }
    return 0;
}


Measured memory_bytes: 2988
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, m;
    scan(n, m);
    auto from = new bool[](n);
    auto to = new bool[](n);
    foreach (_; iota(m))
    {
        long a, b;
        scan(a, b);
        if (a == 1)
            to[b - 1] = true;
        if (b == n)
            from[a - 1] = true;
    }
    long ans;
    foreach (i; iota(n))
    {
        ans |= (from[i] && to[i]);
    }
    if (ans)
        writeln("POSSIBLE");
    else
        writeln("IMPOSSIBLE");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 4188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N,K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  rep(i,N-K) {
    if (A[i]<A[K+i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
#define MOD 1'000'000'007LL

int n, x;
int s[N];
ll p[N]={}, q[N];
int main(){
	scanf("%d%d", &n, &x);
	REP(i, n) scanf("%d", s+i);
	sort(s, s+n, greater<int>());
	p[x]=1;
	REP(i, n){
		fill(q, q+N, 0);
		REP(j, N){
			int k = j%s[i];
			q[j]+=p[j]*(n-i-1);
			q[j]%=MOD;
			q[k]+=p[j];
			q[k]%=MOD;
		}
		swap(p, q);
	}
	ll ans = 0;
	REP(j, N){
		ans += ((ll)j)*p[j];
		ans %= MOD;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 2176
main :: IO()
main = do
    [a,b,c] <- map read . words <$> getLine
    putStrLn $ if (getsolve a b c 1) then "YES" else "NO"

getsolve :: Int -> Int -> Int -> Int -> Bool
getsolve a b c count
    | mod (a * count ) b == c			= True
    | mod (a * count ) b == 0			= False
    | otherwise							= getsolve a b c (count + 1)
    where modul = mod (a * count) b

Measured memory_bytes: 508
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  cout << (a * b);
}
#endif


Measured memory_bytes: 3648
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll L, R, d;
    cin >> L >> R >> d;
    ll ans = 0;
    rep(L, i, R + 1)
    {
        if (i % d == 0)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
int main(){
  ll n,m;cin>>n>>m;
  vector<pair<ll,pll> >v={};
  ll p[m],y[m];for(ll i=0;i<m;i++){
    cin>>p[i]>>y[i];
    pll pp=make_pair(y[i],i);
    pair<ll,pll> q=make_pair(p[i],pp);
    v.push_back(q);
  }
  string s[100000];
  string t[100000];
  string ans[m];
  for(ll i=0;i<100000;i++){
    s[i]="000000";t[i]="000000";
  }
  sort(v.begin(),v.end());
  ll cnt=0;
  for(ll i=0;i<v.size();i++){
    cnt++;
    ll fi=v[i].first;ll sef=cnt;ll ses=v[i].second.second;
    char a[6],b[6];
    for(int j=0;j<6;j++){
      a[j]=fi%10-49+'a';
      b[j]=sef%10-49+'a';
      fi/=10;sef/=10;
      s[ses][5-j]=a[j];
      t[ses][5-j]=b[j];
    }
  
    ans[ses]=s[ses]+t[ses];
    if(v[i].first!=v[i+1].first){
      cnt=0;
    }
  }
  for(ll i=0;i<m;i++){
    cout<<ans[i]<<endl;
  }
}
    
    
  

Measured memory_bytes: 23280
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int find(int a[][3],int n)
{
	int dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
		dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
		dp[i][2]=max(dp[i-1][1]+a[i][2],dp[i-1][0]+a[i][2]);
	}
	return max({(dp[n-1][0]),(dp[n-1][1]),(dp[n-1][2])});
}
int main()
{
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	cout<<find(a,n);
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <queue>


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> vec(n);
    rep(i, n) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end(), greater<ll>());
    ll ans = numeric_limits<ll>::max();
    for (ll i = 0; i <= n - k; ++i) {
        ll this_num = (vec[i] - vec[i + k - 1]);
        if (this_num < ans) {
            ans = this_num;
        }
    }
    cout << ans << endl;
    return 0;
}

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

ll int func(ll int h){
    if(h==1){
        return 1;
    }
    return 1+2*func(h/2);
}

int main(){
    ll int h;
    cin>>h;
    cout<<func(h)<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
N,Y=map(int,input().split())

if 10_000*N < Y:
  print(-1,-1,-1)
  sys.exit()
elif 1_000*N > Y:
  print(-1,-1,-1)
  sys.exit()
else:
  Y-=1_000*N
  for i in range(2001):
    for j in range(2000-i+1):
      if 4_000*i+9_000*j>Y:
        break
      if i+j<=N and 4_000*i+9_000*j==Y:
        print(j,i,N-i-j)
        sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 9200
N = int(input())

ans = ""
i = 0
if N == 0:
    print(0)
    exit()
while N != 0:
    if N % 2 == 0:
        ans = "0" + ans
        N = N // 2
    else:
        ans = "1" + ans
        if i == 1:
            N = (N + 1) // 2
        else:
            N = (N - 1) // 2
    i = 1 - i

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int i,j,k;
	int n,key;
	int a[1000];
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		key=a[i];
		j=i-1;
		while(j>=0 && a[j]>key)
		{
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=key;

		for(k=0;k<n;k++)
		{
			if(k!=n-1)
			{
				printf("%d ",a[k]);
			}
			else
			{
				printf("%d",a[k]);
			}
		}

		printf("\n");
		}
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n), c(n);
    rep(i,n) { cin >> p[i]; p[i]--;}
    rep(i,n) cin >> c[i];
    ll ans = -1e18;
    rep(i,n){
        int pos = i;
        vector<int> score;
        ll total = 0;
        while(1){
            pos = p[pos];
            score.push_back(c[pos]);
            total+=c[pos];
            if(pos==i) break;
        }
        //この周期の中でどこできるか
        int len = score.size();
        ll sum = 0;
        rep(j,len){
            if(j+1 > k) break;
            sum += score[j];
            ll t = sum;
            if(total > 0){
                ll cnt = (k-(j+1))/len;
                t+=cnt*total;
            }
            ans = max(ans, t);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3704
# include <bits/stdc++.h>
using namespace std;
long long dp[4000][4000],a,b,c,d,mod=998244353,x;
int main()
{
     cin>>a>>b>>c>>d;
     dp[a][b]=1;
     for (long long i=a; i<=c; i++)
     {
          for (long long j=b; j<=d; j++)
          {
               if (a==i && b==j) continue;
               dp[i][j]=dp[i][j-1]*i;
               dp[i][j]%=mod;
               dp[i][j]+=dp[i-1][j]*j;
               dp[i][j]%=mod;
               x=dp[i-1][j-1]*(i-1);
               x%=mod;
               x*=(j-1);
               x%=mod;
               dp[i][j]-=x;;
               dp[i][j]+=mod;
               dp[i][j]%=mod;
          }
     }
     cout<<dp[c][d]%mod<<endl;
}

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

ll calc(ll n) {
    if (n == 1) return 1;
    else return 2*calc(n/2)+1;
}

int main(){
    ll H;
    cin >> H;
    cout << calc(H) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        if (a % 2 == 0 && b % 2 == 0
                || a % 2 == 1 && b % 2 == 1) {
            System.out.println((a + b) / 2);
            return;
        }
        System.out.println("IMPOSSIBLE");
    }

}


Measured memory_bytes: 23764
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	s := make([]int, N)
	SUM := 0
	for i := 0; i < N; i++ {
		s[i] = scanInt()
		SUM += s[i]
	}

	ans := SUM
	if SUM%10 == 0 {
		ans = 0
	}
	for _, point := range s {
		if tmp := (SUM - point); tmp%10 != 0 {
			ans = intMax(ans, tmp)
		}
	}

	fmt.Println(ans)
}


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


ll f(int x, int y, int z) {
    return x*x + y*y + z*z + x*y + y*z + z*x;
}

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

    for (int n = 1; n <= N; n++)
    {
        ll m = sqrt(n);

        int ans = 0;

        int ans1 = 0;
        for (int x=1; x<=m; x++)
        for (int y=x+1; y<=m; y++)
        for (int z=y+1; z<=m; z++)
        {
            if (x==0 || y==0 || z==0) continue;
            ll res = f(x, y, z);
            if (res > n) break;
            if (res == n) ans1++;
        }
        ans += 6*ans1;

        int ans2 = 0;
        for (int x=1; x<=m; x++)
        for (int y=1; y<=m; y++)
        {
            if (x==y) continue;
            ll res = x*x + 3*y*y + 2*x*y;
            if (res > n) break;
            if (res == n) ans2++;
        }
        ans += 3*ans2;

        if (n%6 == 0) {
            int ans3=0;
            for (int x=1; x<=m; x++) {
                if (x*x == n/6) ans3++;
            }
            ans += ans3;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define si set<int>
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vi a(n), b(m);
    cin >> a >> b;
    vvi pref(2, vi());
    pref[0].push_back(a[0]);
    pref[1].push_back(b[0]);
    for (int i = 1; i < n; i++)
        pref[0].push_back(pref[0].back() + a[i]);
    for (int i = 1; i < m; i++)
        pref[1].push_back(pref[1].back() + b[i]);
    int i = 0, j = m - 1, res = 0;
    while (i < n)
    {
        if (pref[0][i] > k)
            break;
        while (j >= 0 && pref[1][j] > k - pref[0][i])
            j--;
        if (j < 0)
            res = max(res, i + 1);
        else
            res = max(res, i + j + 2);
        i++;
    }
    j = 0, i = n - 1;
    while (j < m)
    {
        if (pref[1][j] > k)
            break;
        while (i >= 0 && pref[0][i] > k - pref[1][j])
            i--;
        if (i < 0)
            res = max(res, j + 1);
        else
            res = max(res, i + j + 2);
        j++;
    }
    cout << res << endl;
    GAME_OVER;
}

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

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

    for (int i = 1; i <= 9; i++){
        for (int j = i; j <= 9; j++){
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

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

int main(){
  string A, B;
  cin >> A >> B;
  int len_A = A.length(), len_B = B.length();
  
  if (len_A > len_B) cout << "GREATER";
  else if (len_A < len_B) cout << "LESS";
  else {
    for (int i = 0; i < len_A; i++) {
      if (A[i] > B[i]) {
        cout << "GREATER";
        return 0;
      }
      else if (A[i] < B[i]) {
        cout << "LESS";
        return 0;
      }
    }
    cout << "EQUAL";
  }
  return 0;
}

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

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    map<ll, ll> mp;
    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    int q;
    cin >> q;
    ll sum = 0;
    for (auto m : mp)
    {
        sum += (m.first * m.second);
    }

    rep(i, q)
    {
        int b, c;
        cin >> b >> c;
        int tmp = mp[b];
        sum += (c - b) * tmp;
        mp[b] = 0;
        mp[c] += tmp;
        cout << sum << endl;
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 9524
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

const int MOD = (int)1e9 + 7;

int add(int x, int y) {
	return (x + y >= MOD ? x + y - MOD : x + y);
}

int mult(int x, int y) {
	return (x * 1LL * y) % MOD;
}

int binpow(int x, int y) {
	if(y == 0 || x == 1)
		return 1;

	if(x == 0)
		return 0;

	int rez = binpow(x, y / 2);
	rez = mult(rez, rez);

	if(y & 1)
		rez = mult(rez, x);

	return rez;
}

int divide(int x, int y) {
	return mult(x, binpow(y, MOD - 2));
}

const int MAX_N = 1033;

int dp[MAX_N][MAX_N];
int A, B, C, D, N;

int fact[MAX_N], inv_fact[MAX_N];
int P[MAX_N][MAX_N];

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

void precalc() {
	fact[0] = 1;

	for(int i = 1; i < MAX_N; ++i) {
		fact[i] = mult(i, fact[i - 1]);
	}

	for(int i = 0; i < MAX_N; ++i) {
		inv_fact[i] = divide(1, fact[i]);
	}

	for(int i = 0; i < MAX_N; ++i) {
		for(int j = 0; j < MAX_N; ++j) {
			P[i][j] = divide(1, binpow(fact[i], j));
		}
	}
}

int choose(int k, int n) {
	if(k > n)
		return 0;

	int rez = fact[n];
	rez = mult(rez, inv_fact[k]);
	rez = mult(rez, inv_fact[n - k]);

	return rez;
}

void solve() {
	cin >> N >> A >> B >> C >> D;
	dp[0][0] = 1;

	for(int i = 0; i <= B - A; ++i) {
		int sz = A + i;
		//DBG(i);

		for(int j = 0; j <= N; ++j) {
			if(dp[i][j] == 0)
				continue;

			dp[i + 1][j] = add(dp[i + 1][j], dp[i][j]);

			for(int to_add = C; to_add <= D; ++to_add) {
				int j2 = j + sz * to_add;

				if(j2 > N)
					break;

				int ways = choose(sz * to_add, N - j);
				ways = mult(ways, fact[sz * to_add]);
				/*ways = divide(ways, binpow(fact[sz], to_add));
				ways = divide(ways, fact[to_add]);*/

				ways = mult(ways, P[sz][to_add]);
				ways = mult(ways, inv_fact[to_add]);

				/*DBG(to_add); DBG(sz); DBG(N); DBG(j);
				DBG(ways); DBG(j2); DBG(dp[i][j]);*/

				dp[i + 1][j2] = add(dp[i + 1][j2], mult(dp[i][j], ways));
			}
		}
	}

	/*for(int i = 0; i <= B - A + 1; ++i) {
		cout << i << ": ";

		for(int j = 0; j <= N; ++j) {
			cout << dp[i][j] << ' ';
		}

		cout << '\n';
	}*/

	cout << dp[B - A + 1][N] << '\n';
}

int main() {
	init_IO();

	precalc();
	solve();

	return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    // Your code here!
    int A,B,i;
    scanf("%d %d", &A, &B);
    int flag = 0;
    
    for(i = 1; i < 1263 && flag == 0; i++)
    {
        if(floor(i*0.08) == A && floor(i*0.1) == B)
            flag = 1;
    }
    
    printf("%d\n", (flag == 1)? i-1:-1);
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int x,y,z,temp_a,temp_b;
  scanf("%d%d%d",&x,&y,&z);
  temp_a = x;
  x = y;
  y= temp_a;
  temp_b = x;
  x = z;
  z = temp_b;
  printf("%d %d %d",x,y,z);
  
  return 0;
}

Measured memory_bytes: 1736
n = gets.to_i
words = Array.new(n){ gets.chomp.bytes.sort.pack("U*") }

h = Hash.new
ans = 0
words.each do |s|
  
  if h.has_key?(s)
    h[s] += 1
    ans += h[s]
    p 
  else
    h[s] = 0
  end
end

puts ans

Measured memory_bytes: 38780
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = ReadLine();
		Console.WriteLine("{0}{1}{2}", S[0], S.Length - 2, S.Last());
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 13268
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

ll input(){
  int a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll k;
    cin >> k;
    REP(i,k){
      if(s[i]!='1'){
        cout << s[i] << endl;
        return 0;
      }
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char contest[3];
	scanf("%s", contest);
	
	if(contest[1] == 'B'){
		contest[1] = 'R';
	}
	else{
		contest[1] = 'B';
	}
	printf("%s\n", contest);
	return 0;
}

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

int main() {
  // ここにプログラムを追記
int N;//total
int A;//1yen

cin>>N >>A;

int S = N % 500;
int P = A - S;

if(P >= 0){
  cout<<"Yes"<<endl;
  }
if (P < 0){
  cout<<"No"<<endl;
  }

}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char

step (a,b,c) x
    | x <= a = (x, max b (c+1), c+1)
    | otherwise = (x, max b c, 0)

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    let (_,res,_) =  VU.foldl' step (VU.head xs,0,0) (VU.tail xs)
    print res

Measured memory_bytes: 18812
while True:
  a, op, b = input().split()   
  a = int(a)                   
  b = int(b) 
   
  if op == "?":
    break
 
  if op == "+":
      print("%d"%(a+b))
  elif op == "-":
      print("%d"%(a-b))
  elif op == "*":
      print("%d"%(a*b))
  elif op == "/":
      print("%d"%(a/b))
  else:
      break


Measured memory_bytes: 5592
#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_N(605);
const int MOD(1000000000 + 7);

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

inline void inc(int &a, int b)
{
	a = Sub(a, b);
}

int N, K, P[Max_N], F[Max_N][Max_N], H[Max_N], Cnt[Max_N][Max_N];

int main()
{
	scanf("%d%d", &N, &K), N <<= 1;
	for (int i = 1;i <= N;++i)
		Cnt[i][i] = 1;
	for (int a, b, i = 1;i <= K;++i)
		scanf("%d%d", &a, &b), P[a] = b, P[b] = a;
	for (int a = 1;a <= N;++a)
		for (int b = a;b <= N;++b)
			Cnt[a][b] = Cnt[a][b - 1] + (P[b] == 0);
	H[0] = 1;
	for (int n = 2;n <= N;n += 2)
		H[n] = Mult(n - 1, H[n - 2]);
	for (int ad = 1;ad <= N;++ad)
		for (int i = 1, j = ad;j <= N;++i, ++j)
		{
			for (int k = i;k <= j;++k)
				if (P[k] && (P[k] < i || P[k] > j))
					goto loop;
			F[i][j] = H[Cnt[i][j]];
			for (int k = i + 1;k <= j - 1;++k)
				inc(F[i][j], Mult(F[i][k], H[Cnt[k + 1][j]]));
			loop :
			;
		}
	int Ans = 0;
	for (int i = 1;i <= N;++i)
		for (int j = i + 1;j <= N;++j)
			upd(Ans, Mult(F[i][j], H[(N / 2 - K) * 2 - Cnt[i][j]]));
	printf("%d", Ans); 
	return 0;
}

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

class ORDER {
public:
	char temp;
	void CHANGE() {
		while (temp = cin.get()) {
			if (temp == EOF) {
				cin.clear();
				cin.seekg(0, ios::end);
				break;
			}
			if (0x41 <= temp && temp <= 0x5A) {  // 0x41 = 'A', 0x5A = 'Z'
				temp += 0x20;
			}
			else if (0x61 <= temp && temp <= 0x7A) {  // 0x61 = 'a', 0x7A = 'z'
				temp -= 0x20;
			}
			cout << temp << flush;
		}
	}
};

int main() {
	ORDER x;
	x.CHANGE();
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define PI 3.14159265
using namespace std;
using ld = long double;
const ld EPS = 0.0000000001;
ld a, b, x;

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

void solve() {
    cin >> a >> b >> x;
    ld r = PI / 2.0;
    ld l = 0.0;
    for (int i = 0; i < 100000; ++i) {
        ld mid = (l + r) / 2.0;
        if (f(a, b, mid) < x) r = mid;
        else l = mid;
    }
    cout << fixed << setprecision(10) << r / PI * 180 << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	int w,h,cnt;
	int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	char m[100][101];
	queue<pii> q;
	for(;;){
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)break;
		cnt=0;
		rep(i,h)scanf("%s",m[i]);
		rep(i,h)rep(j,w){
			if(m[i][j]!=0){
				char c=m[i][j];
				cnt++;
				m[i][j]=0;
				q.push(pii(i,j));
				while(!q.empty()){
					int x=q.front().second,y=q.front().first;
					q.pop();
					rep(k,4){
						if(in(x+dx[k],0,w-1)&&in(y+dy[k],0,h-1)
							&& m[y+dy[k]][x+dx[k]]==c){
								m[y+dy[k]][x+dx[k]]=0;
								q.push(pii(y+dy[k],x+dx[k]));
						}
					}
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> P;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

double n;
cin >> n;
fin(ceil(n/2.0));

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	int n, k;
	cin >> n >> k;
	cout << n * k + 1 - n - k << endl;
	return 0;
}


Measured memory_bytes: 256