akhauriyash/Code-Regression huggingface dataset:
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
ll in(){ ll x; cin >> x; return x; }
vector<ll> in(size_t n){ vector<ll> v(n); each(x, v) cin >> x; return v; }
/* }}} */

int main(){
  int a[3];
  rep(i, 3) cin >> a[i];
  cout << set<int>(a, a + 3).size() << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] x = new int[n][d];
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < d; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		
		int count = 0;
		for(int i = 0; i < n; i++) {
			for(int j = i; j < n; j++) {
				int dist = 0;
				for(int k = 0; k < d; k++) {
					dist += Math.abs(x[i][k]- x[j][k])*Math.abs(x[i][k]- x[j][k]);	
				}
				if(Math.sqrt(dist) == (int)Math.sqrt(dist)&& dist != 0) {
					++count;
				}
			}
		}
		
		System.out.println(count);

	}
	
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG if(1)
#define MAX INT_MAX
#define MAXLL LLONG_MAX
#define MAXU ULLONG_MAX
#define MIN -2000000
#define endl "\n"
#define INF 99999999
#define MOD 1000000007
#define s(n) scanf("%d", &n)
#define ss(a,b) scanf("%d %d",&a,&b)
#define pb push_back
#define mp make_pair
#define M_PI 3.14159265358979323846
#define sz(a) int(a.size())
#define lli long long int
#define rep(i,a,n) for (int i=a;i<n;i++)
#define ler(a,n,vec) for(int i=0;i<n;i++)s(a), vec.pb(a)
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<string, pair<int, char> > ps;
#define DEBUG if(1)
#define F first
#define S second
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ddx[] = {1, 0};
int ddy[] = {1, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int a, b;
  cin >> a >> b;
  if(a > b) swap(a, b);
  for(int i=a;i<=b;i++){
  	if((a*i*b)%2!=0){
  		cout << "Yes" << endl;
  		return 0;
  	}
  }

cout << "No" << endl;
  return 0;
}

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

int main(){
	int n;cin>>n;
  map<string,int > votes;
  for(int i=0;i<n;i++){
  	string s;
    cin>>s;
    votes[s]+=1;
  }
  int maxi=0;
  for(map<string, int>::iterator it=votes.begin();it!=votes.end();it++){
  	maxi = max(it->second,maxi);
  }
  for(map<string, int>::iterator it=votes.begin();it!=votes.end();it++){
  	if(it->second==maxi)cout<<it->first<<'\n';
  }
}

Measured memory_bytes: 25216
N = int(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'

total = []
for i in range(1, 12):
    total.append(int(26 * (26 ** i - 1) / 25))

digits = 1
for i in range(11):
    if N > total[i]:
        digits += 1
    else:
        break

# digits が番号の長さ

if digits > 1:
    N -= total[digits-2]

N -= 1
# digits桁の26進数でNを表せば良い。
ans = [0] * digits


rem = N
for i in range(digits, 1, -1):
    if rem > 26 ** (i-1):
        ans[digits-i] = rem // 26 ** (i-1)
        rem = rem % (26 ** (i-1))

ans[digits-1] = rem
name = []

for digits in ans:
    name.append(alphabet[digits])

for s in name:
    print(s, end="")


Measured memory_bytes: 9232
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int H,W,K;
char c[10][10];

int main() {
  INCANT;
  cin >> H >> W >> K;
  rep(i, H) rep(j, W) cin >> c[i][j];
  int ans=0;
  rep(i, 1<<H) {
    rep(j, 1<<W) {
      int cnt=0;
      rep(k, H) {
        int maskh = 1 << k;
        if (maskh & i) continue;
        rep (l, W) {
          int maskw = 1 << l;
          if (maskw & j) continue;
          if (c[k][l]=='#') cnt++;
        }
      }
      if (cnt==K) ans++;
    }
  } 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3668
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * Integer Cards
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();

            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
            }

            List<BC> list = new ArrayList<>();
            for (int i = 0; i < M; i++) {
                BC bc = new BC();
                bc.B = sc.nextInt();
                bc.C = sc.nextLong();
                list.add(bc);
            }

            Arrays.sort(A);
            Collections.sort(list, (o1, o2) -> Long.compare(o2.C, o1.C));

            long sum = 0;
            long count = 0;

            for (int i = N - 1; i >= 0; i--) {
                long a = A[i];

                while (list.size() > 0 && list.get(0).C >= a) {
                    BC bc = list.get(0);

                    if (count + bc.B >= N) {
                        sum += bc.C * (N - count);
                        count = N;
                        break;
                    }

                    sum += bc.C * bc.B;
                    count += bc.B;
                    list.remove(0);
                }

                if (count == N) {
                    break;
                }

                sum += a;
                count++;

                if (count == N) {
                    break;
                }
            }

            System.out.println(sum);
        }
    }

    static class BC {

        int B;

        long C;

    }

}


Measured memory_bytes: 96172
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
 
int main()
{
    double px = 0, py = 0, cx = 0, cy = 0, r = 0,
        vx = 0, vy = 0, wx = 0, wy = 0;
 
    cin >> px >> py >> cx >> cy >> r;
 
    if (py == cy) {
        vx = cx + (r * r) / (px - cx);
        wx = vx;
        vy = cy - r * sqrt(1 - (r * r) / pow(px - cx, 2));
        wy = cy + r * sqrt(1 - (r * r) / pow(px - cx, 2));
    }
    else {
        double a = 0, b = 0, s = 0, t = 0, u = 0;
 
        a = (cx - px) / (py - cy);
        b = (px * cx - cx * cx + r * r) / (py - cy) + cy;
 
        s = 1 + pow(a, 2);
        t = cx - a * b + a * cy;
        u = pow(cx, 2) + pow(b - cy, 2) - pow(r, 2);
         
        vx = (t - sqrt(t * t - s * u)) / s;
        wx = (t + sqrt(t * t - s * u)) / s;
        vy = a * vx + b;
        wy = a * wx + b;
    }
 
    cout << setiosflags(ios::showpoint | ios::fixed) << setprecision(10)
        << vx << " " << vy << endl << wx << " " << wy << endl;
 
    return 0;
}


Measured memory_bytes: 3312
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
const long INF = 1000000009;

long n;
long dig[16];
int main(){
	scanf("%ld", &n);
	long ans = 0;
	long num = 0;
	long n1 = n;
	long len = 0;
	for(int i = 0; n1 > 0; i++){
		dig[i] = n1 % 10;
		n1 /= 10;
		len = i;
	}
	for(int i = 0; i <= len; i++){
		ans += dig[i];
	}
	for(int i = 0; i <= len; i++){
		if(dig[i] != 0){
			long upsum = 0;
			for(int j = i+1; j <= len; j++){
				upsum += dig[j];
			}
			ans = std::max(ans, upsum + (dig[i]-1) + i*9);
			//printf("%d %ld\n", i, ans);
		}
	}
	printf("%ld\n", ans);
	return 0;
}


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

int main(){
	int n;
	cin>>n;
	lp(i,n){
		int y,m,d;
		cin>>y>>m>>d;
		int ans=0;
		while(1){
			if(y%3!=0 && m%2==0){
				if(d==20) break;
			}
			else if(d==21) break;
			ans++;
			d++;
		}
		m++;
		while(m!=11){
			if(y%3==0){
				ans+=20;
			}
			else if(m%2==0){
				ans+=19;
			}
			else ans+=20;
			m++;
		}
		y++;
		while(y!=1000){
			if(y%3==0) ans+=200;
			else ans+=195;
			y++;
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define MOD 1e9+7;

using ll = long long;
using namespace std;

int h[100010];
int dp[100010] = {0};

int main() {
    int N, K;
    cin >> N >> K;
    rep1(i, N) cin >> h[i];
    
    rep1(i, N) {
        if(i == 1) dp[i] = 0;
        else {
            dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
            for(int j = 2; j <= K && i-j >= 1; j++) {
                dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
            }
        }
    }
    
    cout << dp[N];
    cout << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

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

  int64_t res = 0;
  for (size_t i = 0, size = S.size(); i < size; ++i) {
    if (S[i] != T[i]) {
      ++res;
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3916
#include <iostream>

#include <iomanip>

using std::cin;
using std::cout;
using std::endl;

using std::setprecision;

int
main()
{
  int N;
  cin >> N;
  double sum = 0;
  for (int n = 0; n < N; n++)
  {
    int A;
    cin >> A;
    sum += 1.0 / A;
  }
  cout << setprecision(10) << 1 / sum << endl;
  return 0;
}


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

#ifdef INPUT
#include <sstream>
stringstream input_(R"(
999
)");
#define cin input_
#endif

int main()
{
	int x;
	cin >> x;
	int max = 1;

	if (x == 1)
		cout << x << endl;
	
	else
	{
		for (int i=2; i<x; i++)
		{
			int y = i*i;

			while (y <= x)
				y *= i;

			if (max < y/i)
				max = y/i;

			if (i > 31)
				break;
		}

		cout << max << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [int(input())-1 for _ in range(n)]

push = set([])
ans = 0
b = 0

while 1:
  if b in push:
    print(-1)
    exit()
  push.add(b)
  b = A[b]
  ans += 1

  if b== 1:
    print(ans)
    break
  



Measured memory_bytes: 13220
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

//
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;
}
//

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

  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i, N) cin >> h[i];

  int res = 0;
  rep(i, N) {
    if (h[i] >= K) res++;
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int             long long
int dp[3001][3001];
 
    int ff(string &a, string &b,int n,int m,  int i, int j) {
 
 
  if (dp[i][j] != -1) {
 
    return dp[i][j];
  }
  if (i >= n || j >= m) {
 
    return 0;
  }
  if (a[i] == b[j]) {
    return dp[i][j] = 1 + ff(a, b,n,m,  i + 1, j + 1);
 
  }
  else {
    return dp[i][j] = max(ff(a, b,n,m, i + 1, j), ff(a, b,n,m, i, j + 1));
 
  }
}
    string f(string &a,string &b) {
 int n=a.length();
      int m= b.length();
        memset(dp, -1, sizeof dp);
  int len = ff(a, b,n,m, 0, 0);
  
  int i = 0;
  int j = 0;
  string c;
  while (len) {
    if (a[i] == b[j]) {
      c.push_back( a[i]);
      i++;
      j++;
      len--;
    } else {
      if (dp[i + 1][j] > dp[i][j + 1])
        i++;
      else j++;
    }
 
  }
  return c;
    }
int32_t main() {
 
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
  string a,b;
  getline(cin, a);
 getline(cin, b);
 
 
  cout << f(a,b);
 
  return 0;
}


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

#define EPS (1e-10)
#define equals(a,b) (fabs( (a)-(b) ) < EPS)

class Point{

public:
  double x,y;
  
  Point(double x=0,double y=0): x(x),y(y) {}
  
  Point operator + (Point p) { return Point(x+p.x,y+p.y); }
  Point operator - (Point p) { return Point(x-p.x,y-p.y); }
  Point operator * (double a) { return Point(a*x,a*y); }
  Point operator / (double a) { return Point(x/a,y/a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }
  
  bool operator < (const Point &p) const{
    return x != p.x ? x<p.x : y<p.y;
  }
  
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
  
};
typedef Point Vector;

double dot(Vector a,Vector b){
  return a.x*b.x + a.y*b.y;
}

double cross(Vector a,Vector b){
  return a.x*b.y - a.y*b.x;
}

Point project(Point p1,Point p2,Point p){
  Vector base = p2-p1;
  double r = dot(p-p1,base) / base.norm();
  return p1 + base * r;
}

int main(){
  int q;
  double x1,y1,x2,y2,x,y;
  Point p1,p2,p,pro,sa;
  
  scanf("%lf %lf %lf %lf %d",&x1,&y1,&x2,&y2,&q);
  p1 = Point(x1,y1);
  p2 = Point(x2,y2);
  
  while(q--){
    scanf("%lf %lf",&x,&y);
    p = Point(x,y);
    pro = project(p1,p2,p);
    sa = pro-p;
    pro = pro+sa;
    printf("%.10lf %.10lf\n",pro.x,pro.y);
  }

  return(0);
}



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

#ifdef LOCAL
 #include <bits/debugger.hpp>
 // #define __int64 __int64_t
#else 
 #define debug(a...) //
#endif

#define __int64 long long int 

string s = "abcdefghijklmnopqrstuvwxyz";

int main()
{
 ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
 __int64 n;
 cin >> n;
 string ans = "";
 while(n) {
  int mm = ((n % 26 - 1) + 26) % 26;
  ans += s[mm];
  n -= mm;
  n /= 26;
 }
 reverse(ans.begin() , ans.end());
 cout << ans << '\n';
 return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  for(int i = 1; i < 1251; i++){
    int ans_A = i * 0.08;
    int ans_B = i * 0.1;
    if((ans_A == A) && (ans_B == B)){
      cout << i << endl;
      exit(0);
    }
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    ll n;
    IN n;
    vll v(n);
    loop(i,0,n)
    {
        IN v[i];
    }
    ll dp[n][2];
    memset(dp,0,sizeof(dp));
    dp[0][0]=v[0];
    dp[0][1]=0;
    dp[1][0]=max(v[0],v[1]);
    dp[1][1]=(ll)(-1e15);
    loop(i,2,n) 
    {
        if(i%2==0) 
        {
            dp[i][0]=dp[i-2][0]+v[i];
            dp[i][1]=max(dp[i-1][0],dp[i-2][1]+v[i]);
        } 
        else 
        {
            dp[i][0]=max(dp[i-1][0],dp[i-2][0]+v[i]);
            dp[i][1]=(ll)(-1e15);
        }
    }
    // loop(i,0,n)
    // {
    //     OUT dp[i][0]<<" "<<dp[i][1]<<endl
    // }
    OUT dp[n-1][n%2]<<endl
    return 0;
}

Measured memory_bytes: 7952
import math
from functools import reduce
k_ = int(input())
ans = 0


def gcd(*numbers):
    return reduce(math.gcd, numbers)


for i in range(1, k_ + 1):
    for j in range(i, k_ + 1):
        for k in range(j, k_ + 1):
            if i == j == k:
                ans += gcd(i, j, k)
            elif i == j or j == k or i == k:
                ans += gcd(i, j, k) * 3
            else:
                ans += gcd(i, j, k) * 6

print(ans)

Measured memory_bytes: 9644
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define pb push_back
using namespace std;
const int P=139;
const int mod=998244353;
const int maxn=1e6+5;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int minn=0xc0c0c0c0;
ll k,n,l[maxn],r[maxn],dp[maxn],sum[maxn];
int main()
{
    scanf("%lld%lld",&n,&k);
	for(int i=1;i<=k;i++)
		scanf("%lld%lld",&l[i],&r[i]);
	dp[1]=1;
	sum[1]=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
			dp[i]=(dp[i]+sum[max((ll)0,i-l[j])]-sum[max((ll)0,i-r[j]-1)])%mod;
		sum[i]=(sum[i-1]+dp[i])%mod;
	}
	printf("%lld\n",(dp[n]+mod)%mod);
    return 0;
}

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

int main() {
    
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    long long result = LLONG_MIN;
    if (a * c > result) {
        result = a * c;
    }
    if (a * d > result) {
        result = a * d;
    }
    if (b * c > result) {
        result = b * c;
    }
    if (b * d > result) {
        result = b * d;
    }
    cout << result << endl;
    

    return 0;
}

Measured memory_bytes: 3624
//OPTIMIZATIONS
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
//#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//OPTIMIZATIONS
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long uu;
typedef long long int lll;
typedef unsigned long long int uuu;
using namespace std;

#define watch(x) cerr << "\n" \
                      << (#x) << " is " << (x) << endl
#define cel(x, y) 1 + ((x - 1) / y)
const double PI = 3.141592653589793238463;
const int MOD = 1000000007;
const long long int INF = 0x3f3f3f3f3f3f3f3f;

/*
$alil03

URL: url

Solution Begins here
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(max(a*c,a*d), b*c), b*d);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())

int main()
{
	int l;
	cin >> l;
	cout << fixed << setprecision(12) << l * l * l / 27.;
		
}


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

int main(){
    string s;
    cin >> s;
    if(s == "SUN"){
        cout << 7 << endl;
    }
    else if(s == "MON"){
        cout << 6 << endl;
    }
    else if(s == "TUE"){
        cout << 5 << endl;
    }
    else if(s == "WED"){
        cout << 4 << endl;
    }
    else if(s == "THU"){
        cout << 3 << endl;
    }
    else if(s == "FRI"){
        cout << 2 << endl;
    }
    else if(s == "SAT"){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
require 'prime'

M = 1_000_000_007
N = gets.to_i 
h = Hash.new(0)
(2..N).each do |i|
  i.prime_division.each do |x|
    h[x[0]] += x[1] 
  end
end
puts h.values.inject(1) {|tot, x| tot * (x + 1) % M}

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

using namespace std;


int main(void){
  int h, w;
  cin >> h >> w;
  vector<string> v(h);

  for (int i=0; i<h; i++) {
    cin >> v[i];
  }

  for (int i=0; i<h; i++) {
    cout << v[i] << endl;
    cout << v[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class EDoubleFactorial {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      if (n%2==1) {
        cout << 0 << endl;
        return;
      }
      ll tmp = n/2;
      ll ans = 0;
      while(tmp > 0) {
        ans += tmp/5;
        tmp /= 5;
      }
      cout << ans << endl;
    }
};

signed main() {
  EDoubleFactorial solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    M = 0
    Ans = []
    if N % 2 == 0:
        for i in range(1, N):
            for j in range(i + 1, N + 1):
                if i + j != N + 1:
                    Ans.append([i, j])
                    M += 1
    else:
        for i in range(1, N):
            for j in range(i + 1, N + 1):
                if i + j != N:
                    Ans.append([i, j])
                    M += 1
    print(M)
    for i, j in Ans:
        print(i, j)


    return 0

if __name__ =="__main__":
    solve()

Measured memory_bytes: 4124
# C
S = input()
K = int(input())

idx = len(S)
# first not 2
for i in range(len(S)):
    if S[i] != "1":
        idx = i
        res_inf = int(S[i])
        break
if K <= idx:
    print(1)
else:
    print(res_inf)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int a, b; 
    char op;
    cin >> a >> op >> b;
    if (op == '+') cout << a+b << endl;
    else cout << a-b << endl;
}

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

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> s(n + 1, 0);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }
  ll ans = 1e18;
  for (ll i = 1; i <= n; i++) {
    ll x = s[i] - s[0];
    ll y = s[n] - s[i];
    if (llabs(x - y) < ans) {
      ans = llabs(x - y);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
x, y = input().split()
a = ['4', '6', '9', '11']
b = ['1', '3', '5', '7', '8', '10', '12']

if (x == y == '2'):
	print('Yes')
elif (a.count(x) == a.count(y) == 1):
	print('Yes')
elif (b.count(x) == b.count(y) == 1):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = a; (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= b; (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long, long>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

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

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	double _max = -1;
	int sato_water = -1, sato = -1;

	rep2 (a, 0, 31) rep2 (b, 0, 31) rep2 (c, 0, 3001) {
		if (!a && !b) continue;
		int water = 100 * A * a + 100 * B * b;
		if (water + C * c > F) break;
		int ok = min(E * A * a + E * B * b - C * c, F - water - C * c);
		if (ok < 0) break;
		int Dd = ok / D * D;
		if (chmax(_max, (double)(C * c + Dd)/(water + C * c + Dd))) {
			sato_water = water + C * c + Dd;
			sato = C * c + Dd;
		}
	}

	cout << sato_water << " " << sato << endl;
	return 0; 
}

Measured memory_bytes: 3660
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0

for i in range(n-1):
  if a[i+1]==a[i]+1:
    ans+=c[a[i]-1]

print(sum(b)+ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld q,h,s,d,n;

	cin >> q >> h >> s >> d >> n;

	q *= 4;
	h *= 2;

	if (n == 1)
	{
		cout << min(q,min(h,s)) << endl;
	}else
	{
		lld x = n / 2;
		lld l = min(q,min(h,s));

		lld sol = 0;

		if (d < 2 * l)
		{
			sol += d * x;
			if (n % 2 != 0)
			{
				sol += l;
			}
		}else
		{
			sol = l * n;
		}

		cout << sol << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

ll H,W;
ll c[10][10];
vector<vector<ll>>A(210,vector<ll>(210,-1));
vector<vector<ll>>G(10,vector<ll>(10,inf));
vector<vector<ll>>K(10,vector<ll>(10,inf));
vector<ll>cnt(10,0);


int main() {
    cin >> H >> W;
    rep(i,10){
        rep(j,10){
            cin >> c[i][j];
            G[i][j] = c[i][j];
            K[i][j] = c[i][j];
        }
    }
    rep(i,H){
        rep(j,W){
            cin >> A[i][j];
            if (A[i][j] != -1){
                cnt[A[i][j]]++;
            }
        }
    }
    rep(k,10){
        rep(i,10){
            rep(j,10){
                if (K[i][j] > K[i][k]+K[k][j]){
                    K[i][j] = K[i][k]+K[k][j];
                }
            }
        }
    }
    ll ans=0;
    rep(i,10){
        ans += K[i][1]*cnt[i];
    }
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

bool odd(int a){
	if(a % 2 != 0)
		return true;
	else
		return false;
}

int main() {
	int a,b,c;
	cin >> a >> b;
	for(c = 1;c <= 3;c++){
		if(odd(a * b * c)){
			cout << "Yes" << endl;
			break;
		}
		else{
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<double, bool> P;
char f[600][601];
const LL MOD = 1000000007LL;
int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> f[i];
	}
	vector<P> v;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (f[i][j] == '#' && (i + 1 >= H || f[i + 1][j] == '.') && (j + 1 >= W || f[i][j + 1] == '.')) {
				v.emplace_back(atan2(H - i - 1, j + 1), 1);
				//+1
			}
			if (f[i][j] == '#' && (i == 0 || f[i - 1][j] == '.') && (j == 0 || f[i][j - 1] == '.')) {
				v.emplace_back(atan2(H - i, j), 0);
				//-1
			}
			if (f[i][j] == '.' && (i >0 && f[i - 1][j] == '#') && (j > 0 && f[i][j - 1] == '#')) {
				//-1
				v.emplace_back(atan2(H - i, j), 0);
			}
			if (f[i][j] == '.' && (i + 1 < H && f[i + 1][j] == '#') && (j + 1 < W && f[i][j + 1] == '#')) {
				//+1
				v.emplace_back(atan2(H - i - 1, j + 1), 1);
			}
		}
	}
	sort(v.begin(), v.end());
	int cnt = 1;
	int ans = 1;
	for (int i = 0; i < v.size(); i++) {
		if (v[i].second) cnt++;
		else cnt--;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 5588
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let (N, A, B) = read!(usize, i64, i64);
    let X = read![[i64]];

    let mut s = 0;
    for i in 0..N - 1 {
        let d = X[i + 1] - X[i];
        s += min(A * d, B);
    }

    println!("{}", s);
}


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

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

    for(int i = k; i < n; i++){
        if(a[i] > a[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
   
    return 0;
}

Measured memory_bytes: 4052
sx, sy, tx, ty = map(int, input().split())

gx, gy = tx-sx, ty-sy

r1 = 'U'*gy + 'R'*gx
r2 = 'D'*gy + 'L'*gx
r3 = 'L' + 'U'*(gy+1) + 'R'*(gx+1) + 'D'
r4 = 'R' + 'D'*(gy+1) + 'L'*(gx+1) + 'U'
print(r1 + r2 + r3 + r4)


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

using namespace std;

using int64 = long long;

int main() {
  int64 N, S;
  cin >> N >> S;

  if(N == S) {
    cout << N + 1 << endl;
    return 0;
  }

  for(int64 b = 2; b * b <= N; b++) {
    int64 t = N, ret = 0;
    while(t > 0) {
      ret += t % b;
      t /= b;
    }
    if(ret == S) {
      cout << b << endl;
      return 0;
    }
  }

  //  pb+q == N かつ q<b
  //-)p +q == S
  //p(b-1) == N-S

  vector< int64 > divisor;
  if(N - S > 0) {
    for(int64 i = 1; i * i <= N - S; i++) {
      if((N - S) % i == 0) {
        divisor.push_back(i);
        divisor.push_back((N - S) / i);
      }
    }
    sort(begin(divisor), end(divisor));
    for(auto b : divisor) {
      ++b;
      auto p = (N - S) / (b - 1);
      auto q = S - p;
      if(0 <= p && p < b && 0 <= q && q < b) {
        cout << b << endl;
        return 0;
      }
    }
  }


  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<string.h>
#include<algorithm>

using namespace std;

int timecount[86400];

int stoi(string str){
	stringstream ss;
	int num;
	ss << str;
	ss >> num;
	return num;
}

int hmstot(string str){
	return stoi(str.substr(0,2)) * 3600 + stoi(str.substr(3,2)) * 60 + stoi(str.substr(6,2));
}

int main(){
	while(1){
		memset(timecount, 0,sizeof(timecount));
		int n;
		cin >> n;
		if(n == 0) break;
		
		for(int i = 0;i < n;i++){
			string shms,ghms;
			cin >> shms >> ghms;
			int st,gt;
			st = hmstot(shms);
			gt = hmstot(ghms);
			for(int j = st;j < gt;j++){
				timecount[j]++;
			}
		}
		
		int ans = 0;
		for(int i = 0;i < 86400;i++){
			ans = max(ans,timecount[i]);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3476
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<string.h>

int abs(int t){
    return t>0 ? t:-t;
}

int main(){
    int A1,A2,A3;
    scanf("%d %d %d",&A1,&A2,&A3);
    int max=0;
    max = max>abs(A1-A2) ? max:abs(A1-A2);
    max = max>abs(A2-A3) ? max:abs(A2-A3);
    max = max>abs(A3-A1) ? max:abs(A3-A1);
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 128
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C++ (GCC 9.2.1)
*/

#include <bits/stdc++.h>
using namespace std;

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod int(1e9+7)

int main(int argc, char const *argv[])
{
	// DON'T CHANGE
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	// here
	int n;
	int ans = 0;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++)	cin >> l[i];
	
	if(n < 3){
	  OUT(0) BR;
	  RET;
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if((l[i] != l[j] and l[j] != l[k] and l[k] != l[i]) and (l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]))	++ans;
			}
		}
	}
	OUT(ans) BR;
	RET;
}


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

using ll=long long;
const ll MOD=1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> to(n,-1);
    for(int i=0;i<m;i++){
        int s,d;
        cin>>s>>d;
        s--,d--;
        to[s]=d;
    } 
    int k=0;
    vector<int> t(n,-1);
    vector<int> real(n);
    iota(real.begin(),real.end(),0);
    int x=-1;
    function<bool(int)> dfs=[&](int v){
        t[v]=k;
        if(to[v]==-1) return true;
        if(t[to[v]]==-1){
            bool ret=dfs(to[v]);
            if(ret) return true;
            else{
                real[v]=x;
                if(v==x){
                    x=-1;
                    return true;
                }
                return false;
            }
        }
        else{
            if(t[to[v]]==k){
                x=to[v];
                real[v]=x;
                return false;
            }
            else{
                return true;
            }
        }
    };
    for(int i=0;i<n;i++){
        if(t[i]==-1) dfs(i),k++;
    }
    for(int i=0;i<n;i++){
        if(real[i]==i && to[i]!=-1){
            if(real[to[i]]==i) to[i]=-1;
            else to[i]=real[to[i]];
        }
    }
    vector<vector<int>> rg(n);
    for(int i=0;i<n;i++){
        if(real[i]==i && to[i]!=-1){
            rg[to[i]].push_back(i);
        }
    }
    function<pair<ll,ll>(int)> dfs2=[&](int v){
        pair<ll,ll> res={1,1};
        for(auto &to:rg[v]){
            auto tmp=dfs2(to);
            res.first*=tmp.first;
            res.second*=(tmp.first+tmp.second);
            res.first%=MOD;
            res.second%=MOD;
        }
        return res;
    };
    ll res=1;
    for(int i=0;i<n;i++){
        if(real[i]==i && to[i]==-1){
            auto tmp=dfs2(i);
            res*=(tmp.first+tmp.second);
            res%=MOD;
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3208
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    var (A, B, C) = nextIntList()
    val max = Math.max(A, Math.max(B, C))
    val a = (max - A) / 2
    val b = (max - B) / 2
    val c = (max - C) / 2
    A += 2 * a
    B += 2 * b
    C += 2 * c
    val d = when (max * 3 - (A + B + C)) {
        0 -> 0
        1 -> 2
        2 -> 1
        else -> 0
    }
    println(a + b + c + d)
}

Measured memory_bytes: 37768
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        N:usize,
        M:usize,
        A:[usize; M]
    }
    let sum: usize = A.iter().sum();
    println!("{}", if sum > N { -1 } else { (N - sum) as isize })
}


Measured memory_bytes: 2224
n = int(input())
a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a.sort()
b.sort()
if n%2 == 1:
    print(b[n//2]-a[n//2]+1)
else:
    print(b[n//2]+b[n//2-1]-(a[n//2]+a[n//2-1])+1)

Measured memory_bytes: 99024
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	int n, B, pi, i, j, MAX;
	ll ans = 0;
	cin >> n;
	vector<int> a(100001);
	REP(i, n)
		cin >> a[i];
	MAX = a[0];
	REP(i, n)
		MAX = MAX > a[i] ? MAX : a[i];
	ans = a[0];
	REP(i, n)
		ans = (double)abs(((double)MAX / 2.0) - ans) < (double)abs(((double)MAX / 2.0) - a[i] )? ans : a[i];
	cout << MAX << " " << ans << endl;
	

}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N, K;
    private int[] L;
    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        K = int.Parse(line[1]);
        L = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }

 
    public void Solve()
    {
        Scan();
        Array.Sort(L,(a,b)=>-a.CompareTo(b));
        int ans = 0;
        for (int i = 0; i < K; i++)
        {
            ans += L[i];
        }
        Console.WriteLine(ans);
    }
}


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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 999;
	int num;
	for (int i = 0; i < n - 2; i++) {
		num = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0' - 753);
		ans = min(ans,abs(num));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string S;
    cin>>S;
    if (S=="SUN"){
        cout<<7;
    }
   else if (S=="MON"){
        cout<<6;
   }
   else if (S=="TUE"){
      cout<<5;
   }
   else if (S=="WED"){
    cout<<4;
   }
   else if (S=="THU"){
    cout<<3;
   }
   else if (S=="FRI"){
    cout<<2;
   }
   else {
     cout<<1;
  }

}


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7

def fact_table(N, MOD):
    inv = np.empty(N, np.int64)
    inv[0] = 0
    inv[1] = 1
    for n in range(2, N):
        q, r = divmod(MOD, n)
        inv[n] = inv[r] * (-q) % MOD
    fact = np.empty(N, np.int64)
    fact[0] = 1
    for n in range(1, N):
        fact[n] = n * fact[n - 1] % MOD
    fact_inv = np.empty(N, np.int64)
    fact_inv[0] = 1
    for n in range(1, N):
        fact_inv[n] = fact_inv[n - 1] * inv[n] % MOD
    return fact, fact_inv, inv

def main(N, M, MOD):
    fact, fact_inv, inv = fact_table(N + 1, MOD)
    x = fact[N] * fact_inv % MOD * fact_inv[::-1] % MOD
    x[1::2] *= (-1)
    x = x[::-1]
    p = 1  # M-N+1 * M-N+2 * ... *
    ret = 0
    for k in range(N + 1):
        ret += x[k] * p % MOD
        if k != N:
            p = p * (M - N + 1 + k) % MOD
    ret %= MOD
    return ret * p % MOD

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    fact_table = cc_export(fact_table, (i8, i8))
    main = cc_export(main, (i8, i8, i8))
    cc.compile()

from my_module import main

N, M = map(int, read().split())
print(main(N, M, MOD))

Measured memory_bytes: 38544
#include <stdio.h>

int main(void){
  int i, j, k = 3, n, s, sosu[78500];
  int max, min, mid;

  sosu[0] = 1;
  sosu[1] = 2;
  sosu[2] = 3;
  for(i = 5; i <= 999999; i += 2){
    s = 0;
    for(j = 2; sosu[j] * sosu[j] <= i; j++){
      if(i % sosu[j] == 0){
	s++;
	break;
      }
    }
    if(s == 0){
      sosu[k++] = i;
    }
  }
  
  while(scanf("%d", &n) != EOF){
    min = 0;
    max = k;
    mid = (min + max) / 2;
    while(min+1 != max){
      if(sosu[mid] < n){
	min = mid;
      }else if(sosu[mid] > n){
	max = mid;
      }else{
	break;
      }
      mid = (min + max) / 2;
    }
    printf("%d\n", mid);
  }
  return 0;
}

Measured memory_bytes: 900