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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    pair<int,int>v[6];
    rep(i,6){
        cin>>v[i].fi>>v[i].se;
        if(v[i].fi>v[i].se)swap(v[i].fi,v[i].se);
    }

    sort(v,v+6);
    if(v[0]==v[1]&&v[2]==v[3]&&v[4]==v[5]&&v[0].fi==v[2].fi&&v[0].se==v[4].fi&&v[2].se==v[4].se)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    return 0;
}

Measured memory_bytes: 3056
#include<stdio.h>
using namespace std;

int main(void)
{
	int N;
	scanf("%d", &N);
	long long int S[100];
	for (int i = 0; i <= N; i++) {
		if (i == 0)
			S[i] = 2;
		else if (i == 1) 
			S[i] = 1;
		else
			S[i] = S[i - 1] + S[i - 2];
	}
	printf("%lld", S[N]);

	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;

void solve()
{
  int H,W,h,w;
  cin >> H >> W >> h >> w;
  cout << H*W - (h*W + w*H - w*h);
}

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t = 1;
  //  cin >> t;
  while (t--)
    solve();
  return 0;
}


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

int main(){
  int n,s,w,q,a[100100];
  while(cin>>n>>s>>w>>q, n){
    int g=s;
    for(int i=0;i<n;i++){
      a[i] = (g/7) % 10;
      g = (g/2) ^ (g%2*w);
    }

    int x=0, z=0;
    if(q==2 || q==5){
      for(int i=0;i<n;i++){
	if(a[i])z++;
	if(a[i]%q==0)x += z;
      }
    }else{
      unordered_map<int,int> m(400400);
      m[0]=1;
      int r=0, k=1;
      for(int i=n-1;i>=0;i--){
	(r += a[i]*k) %= q;
	(k *= 10) %= q;
	if(a[i])x += m[r];
	m[r]++;
      }
    }
    cout<<x<<endl;
  }
}

Measured memory_bytes: 7616
#include <stdio.h>
#include <string.h>
int main(void){
	char s[11];
	scanf("%s",s);
	int ans = 0;
	int i;
	int max = 0;
	int n = strlen(s);
	for(i=0;i<n;i++){
		ans = 0;
		while(s[i]=='A'||s[i]=='C'||s[i]=='G'|| s[i]=='T'){
			ans ++;
			i++;
		}
		if(max<ans)max=ans;
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int a, b;
	
	scanf("%d %d", &a, &b);

	if ((a % 3 == 0) || (b % 3 == 0) || ((a + b) % 3 == 0)) printf("Possible\n");
	else printf("Impossible\n");

	return 0;
}

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

int main (){
    int x,f500,f5,ans;
    cin >> x;
    f500 = x / 500;
    x = x - 500 * f500;
    f5 = x / 5;
    ans = f500 * 1000 + f5 * 5;
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
import numpy as np
N = int(input())

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

    divisors.sort()
    return divisors

l = make_divisors(N)

if len(l)%2 == 0:
    print(l[int(len(l)/2)]+l[int(len(l)/2)-1]-2)
else:
    print(l[int(len(l)/2)]*2-2)


Measured memory_bytes: 12488
#include "bits/stdc++.h"
using namespace std;

string a;

bool pal(string a)
{
	string r=a;
	reverse(r.begin(),r.end());
	return r==a;
}

int main()
{
	cin>>a;


	int n=a.size();
	if(a.size()%2==0 or !pal(a)) cout<<"No";
	else
	{
		if(pal(a.substr(0,(n-1)/2)) && pal(a.substr((n+1)/2))) cout<<"Yes";
		else cout<<"No";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
using namespace std;

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> lines;
    for(int i = 0; i < N; ++i)
    {
        int l = 0;
        cin >> l;
        lines.push_back(l);
    }
    int pos = 0;
    int bound = 1;
    for(int i = 0; i < N; ++i)
    {
        pos += lines[i];
        if(pos > X)
        {
            break;
        }
        ++bound;
    }
    cout << bound;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);




int main(){
    ll A,B,m;cin>>A>>B>>m;
    ll a[A],b[B];
    ll ma=inf;
    ll mb=inf;
    rep(i,0,A-1){
        cin>>a[i];
        ma=min(a[i],ma);
    }
    rep(i,0,B-1){
        cin>>b[i];
        mb=min(b[i],mb);
    }
    ll x[m],y[m],c[m];
    rep(i,0,m-1)cin>>x[i]>>y[i]>>c[i];
    ll ans=ma+mb;
    rep(i,0,m-1){
        ans=min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
    }
    cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;
const double PI=acos(-1);

int main(){
  int i,j;
  double a,b,x;
  cin>>a>>b>>x;
  if(a*a*b<=2*x){
    double d=2*x/(a*a)-b;
    d=b-d;
    cout<<setprecision(15)<<atan(d/a)*180.0/PI<<endl;
  }
  else{
    double d=(2*x)/(a*b);
    cout<<setprecision(15)<<atan(b/d)*180.0/PI<<endl;
  } 

}

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

//dp[i] true if player can win 
int main(){
	int n,k;
cin>>n>>k;
vector<int> inp(n);
for(int i=0;i<n;i++){
	cin>>inp[i];
}
vector<bool> dp(k+1);

for(int i=0;i<=k;i++){
	for(int v:inp){
		if((i-v)>=0 && !dp[i-v]){
			dp[i]=true;
		}
	}
}

if(dp[k])cout<<"First"<<endl;
else
cout<<"Second"<<endl;

}

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

using namespace std;

typedef long long int lli;

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

    int n, a;
    cin >> n;
    vector<int> vec(200000, 0);
    auto ibegin = vec.end();
    for (int i=0; i<n; i++) {
        cin >> a;
        auto itr = lower_bound(ibegin, vec.end(), a);

        // cout << " " << itr-ibegin << endl;

        if (itr == ibegin) {
            // cout << "begin" << endl;
            ibegin--;
            *ibegin = a;
        }
        else {
            itr--;
            *itr = a;
        }
    }

    // for (int i=l; i<=r; i++) cout << vec[i] << endl;

    cout << vec.end()-ibegin << endl;

    return 0;
}


Measured memory_bytes: 1024
#ITP1_7_C
r,c=map(int,input().split())
A=[[0 for i in range(c)]for j in range(r)]
for i in range(r):
  D=list(map(int,input().split()))
  for j in range(c):
    A[i][j]=D[j]
B=[[0 for i in range(c+1)]for j in range(r+1)]
for i in range(r):
  for j in range(c):
    B[i][j]=A[i][j]
for i in range(r):
  a=int(0)
  for j in range(c):
    a=a+A[i][j]
  B[i][j+1]=a
for i in range(c):
  b=int(0)
  for j in range(r):
    b=b+A[j][i]
  B[j+1][i]=b
  
f=int(0)
for j in range(c):
  f=f+B[r][j]
B[r][c]=f
for i in range(r+1):
  for j in range(c+1):
    print(B[i][j],end="")
    if j != c:
      print(" ",end="")
  print("")


Measured memory_bytes: 6772
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back

class state{
public:
  short cost;
  char y1,x1,y2,x2;
  bool operator<(const state & a)const{
    if (y1 != a.y1)return y1 < a.y1;
    if (x1 != a.x1)return x1 < a.x1;
    if (x2 != a.x2)return x2 < a.x2;
    if (y2 != a.y2)return y2 < a.y2;
    return false;
  }
};

//bool vis[50][50][50][50];
bool m[100][100];

char dx[] ={0,0,1,-1};
char dy[] ={1,-1,0,0};
char dx2[]={0,0,-1,1};
char dy2[]={-1,1,0,0};

void bfs(int r,int c,char sy,char sx,char gy,char gx){
  set<state> S;
  queue<state> Q;
  S.insert((state){0,sy,sx,gy,gx});
  Q.push(  (state){0,sy,sx,gy,gx});
  while(!Q.empty()){
    state now = Q.front();Q.pop();
    if (now.cost >= 100)break;
    if (now.x1==now.x2 && now.y1==now.y2){
      cout << now.cost << endl;
      return;
    }

    rep(i,4){
      char nex =now.x1+dx[i] ,ney =now.y1+dy[i];
      char nnex=now.x2+dx2[i],nney=now.y2+dy2[i];
      if (nex ==-1||ney==-1 ||nex==c ||ney==r ||m[ney][nex]){
	nex=now.x1;
	ney=now.y1;
      }
      if (nnex==-1||nney==-1||nnex==c||nney==r||m[nney][nnex]){
	nnex=now.x2;
	nney=now.y2;
      }
      
      //      if (vis[ney][nex][nney][nnex]){
      //	continue;
      //      }
      //      vis[ney][nex][nney][nnex]=true;
      state next=(state){now.cost+1,ney,nex,nney,nnex};
      //Q.push((state){now.cost+1,ney,nex,nney,nnex});
      if (S.find(next) == S.end()){
	S.insert(next);
	Q.push(next);
      }
    }



  }
  cout <<"NA"<<endl;
}

main(){
  int c,r;
  while(cin>>c>>r&& c){
    int sy,sx,gy,gx;
    cin>>sx>>sy>>gx>>gy;
    sx--;sy--;gx--;gy--;
    rep(i,r){
      rep(j,c)cin>>m[i][j];
    }

    bfs(r,c,sy,sx,gy,gx);
  }
}

Measured memory_bytes: 6464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int INF = 1e9;

int main(){
  int n;
  cin >> n;
  int t[n + 4];
  t[0] = 0;
  t[1] = 0;
  for (int i = 2; i <= n + 1; i++) {
    cin >> t[i];
    t[i] += t[i - 1];
  }
  t[n + 2] = t[n + 1];
  t[n + 3] = t[n + 1];
  int v[n + 2];
  v[0] = 0;
  v[1] = 0;
  for (int i = 2; i <= n + 1; i++) {
    cin >> v[i];
  }
  v[n + 2] = 0;
  v[n + 3] = 0;
  double left = 0;
  double ans = 0;
  for (double x = 0.5; x <= t[n + 1]; x += 0.5) {
    double right = 1e9;
    for (int i = 1; i <= n + 3; i++) {
      double vv;
      if (x < t[i - 1]) {
        vv = -x + t[i - 1] + v[i];
      } else if (x >= t[i - 1] && x <= t[i]) {
        vv = v[i];
      } else {
        vv = x + v[i] - t[i];
      }
      right = min(right, vv);
    }
    //cout << left << " " << right << endl;
    ans += (left + right) * 0.25;
    left = right;
  }
  cout << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vector<lint> p(A + 1), q(B + 1), r(C + 1);
	for (int i = 0; i < A; i++) cin >> p[i];
	for (int i = 0; i < B; i++) cin >> q[i];
	for (int i = 0; i < C; i++) cin >> r[i];
	sort(p.begin(), p.end(), greater<>());
	sort(q.begin(), q.end(), greater<>());
	sort(r.begin(), r.end(), greater<>());
	p[X] = 0, q[Y] = 0;

	int cnt = 0;
	lint ans = 0;
	auto pi = p.begin(), qi = q.begin(), ri = r.begin();
	while (cnt++ < X + Y) {
		DMP(max({ *pi, *qi, *ri }));
		ans += max({ *pi, *qi, *ri });
		if (*pi > *qi && *pi > *ri) pi++;
		else if (*qi > *ri) qi++;
		else ri++;

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(){
	int S,h,m,s,a;
	scanf("%d",&S);
	h = S/3600;
	m = S/60-60*h;
	a = S/60;
	s = S-60*a;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

using namespace std;

int main(){
    string s;int length = 0;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
            int length_ = 1;
            for(int j = i+1;j < s.size();j++){
                if(s[j] == 'A' || s[j] == 'T' || s[j] == 'C' || s[j] == 'G'){
                    length_++;
                }else{
                    break;
                }
            }
            length = max(length,length_);
        }
    }
    cout << length;
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp

tmp = 0
s.size.times do |i|
  if i.odd?
    if s[i] == '0'
      tmp += 1
    end
  else
    if s[i] == '1'
      tmp += 1
    end
  end
end

tmp2 = 0
s.size.times do |i|
  if i.odd?
    if s[i] == '1'
      tmp2 += 1
    end
  else
    if s[i] == '0'
      tmp2 += 1
    end
  end
end

p [tmp, tmp2].min


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

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

  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S.at(i) == 'R' || S.at(i) == 'U' || S.at(i) == 'D') {
        continue;
      } else {
        printf("No");
        return 0;
      }
    } else {
      if (S.at(i) == 'L' || S.at(i) == 'U' || S.at(i) == 'D') {
        continue;
      } else {
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
ll recursion(ll arr[],ll i,ll j,vector<vector<ll> > &dp)
{

	if(i>j)
	{
		return 0;
	}
	if(dp[i][j]!=-1)
	{
		return dp[i][j];
	}
	if(i==j)
	{
		return dp[i][j]=arr[i];
	}
	else if(i+1==j)
	{
		return dp[i][j]=max(arr[i],arr[j]);
	}
	else
	{
		return dp[i][j]=max(arr[i]+min(recursion(arr,i+1,j-1,dp), recursion(arr,i+2,j,dp)) , arr[j] + min(recursion (arr , i , j -2,dp), recursion (arr , i +1, j -1,dp) ));
	}
}
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll N;
	cin>>N;
	ll arr[N];
	ll sum=0;
	for(auto &it:arr)
	{
		cin>>it;
	}
	for(auto it:arr)
	{
		sum+=it;
	}
	vector<vector<ll> > dp(N,vector<ll> (N,-1) );
	ll score=recursion(arr,0,N-1,dp);
	cout<<2*score-sum;

}

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

int main(){
    int64_t n;
    cin >> n;
    int64_t ans = 100000000000000;
    for(int i=1; i<=(int)sqrt(n); i++){
        if(n%i==0){
            ans = min(ans, i+(n/i)-2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(N: Int, M: Long, A: LongArray) {
    // cumSum[i]のMで割った余りについて、それぞれの個数を求める
    val cumSum = A.toList().scanLeft(0L) { a, b -> a + b }.toList()
    val pairs = cumSum.map { it % M }
        .groupBy { it }.map { it.key to it.value.size.toLong() }
    val ans = pairs
        .map { (it.second * (it.second - 1)) / 2 + if (it.first == 0L) it.second else 0L }
        .sum()
    println(ans)
    return
}

fun <T, R> Iterable<T>.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence<R> {
    var last = initial
    return this.asSequence().map { last = operation(last, it); last }
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val M = sc.next().toLong()
    val A = LongArray(N)
    for (i in 0 until N) {
        A[i] = sc.next().toLong()
    }
    solve(N, M, A)
}


Measured memory_bytes: 70548
package main
  
import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    as := make([]int, n)
    var ans float64
    for i := range as {
        fmt.Scan(&as[i])
        ans += 1.0 / float64(as[i])
    }
    fmt.Println(1.0 / ans)
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.length();
    if (n<=k) out(s);
    s=s.substr(0,k)+"...";
    out(s);

    return 0;
}


Measured memory_bytes: 3604
n = int(input())
a = [int(i) for i in input().split()]
for i in range(1,n):
    a[i] += a[i-1]
l,r = 0,0
ans = float("inf")
# data = []
for c in range(1,n-2):
    while l < c-1:
        if 2 * a[l+1] > a[c]:
            if a[l+1] + a[l] < a[c]:
                l += 1
            break
        l += 1
    while r < n-2:
        if 2 * (a[r+1]-a[c]) > a[n-1] - a[c]:
            if a[r+1] + a[r] < a[n-1] + a[c]:
                r += 1
            break
        r += 1
    pqrs = [a[l],a[c]-a[l],a[r]-a[c],a[n-1]-a[r]]
    if ans > max(pqrs)-min(pqrs):
        ans = max(pqrs)-min(pqrs)
        # data = [l,c,r]
print(ans)
# print(data)


Measured memory_bytes: 25672
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    std::cin >> s;
    if (s.find("a")<4 and s.find("b")< 4 and s.find("c")<4 ) {
            std::cout << "Yes" << '\n';
    }
    else std::cout << "No" << '\n';
}


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

int main() {
  int N;
  cin>>N;
  int A[2][N];
  for (int i=0; i<2; i++) {
    for (int j=0; j<N; j++) {
      cin>>A[i][j];
    }
  }
  int ans=0;
  for (int i=0; i<N; i++) {
    int ame=0;
    for (int k=0; k<i+1; k++) {
      ame+=A[0][k];
    }
    for (int j=i; j<N; j++) {
      ame+=A[1][j];
    }
    ans=max(ans,ame);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//C
#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 <cstdalign>
#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

//ここまで標準include
//以下プログラム

using namespace std;

int main() {
	string S;
	cin >> S;
	int e, w, s, n;
	e = 0;
	w = 0;
	s = 0;
	n = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) == 'E') {
			e++;
		}
		else if (S.at(i) == 'W') {
			w++;
		}
		else if (S.at(i) == 'S') {
			s++;
		}
		else if (S.at(i) == 'N') {
			n++;
		}
	}
	if (e == 0 && w != 0) {
		cout << "No" << endl;
	}
	else if (e != 0 && w == 0) {
		cout << "No" << endl;
	}
	else if (s == 0 && n != 0) {
		cout << "No" << endl;
	}
	else if (s != 0 && n == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int mod = 1000000007;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
vector<int> f = {1},fi = {1};
int fact(int x){
    while((int)f.size() <=x)f.push_back((f.back()*f.size())%mod);
    return f[x];
}
int ifact(int x){
    return modpow(fact(x),mod-2,mod);
}
int C(int x,int y){
    if(x < y)return 0;
    return fact(x)*ifact(y)%mod*ifact(x-y)%mod;
}
signed main(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    int ret = 0;
    rep(i,n){
        int tmp = a[i];
        tmp = (tmp*modpow(2,2*n-2,mod))%mod;
        tmp = (tmp*(n-i+1))%mod; 
        ret = (ret+tmp)%mod;
    }
    cout << ret << endl;
    return 0;
}

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

int main() {
    int n, q, t;
    string s;
    queue<pair<string,int> > Q;
    cin >> n >> q;
    for (int i=0; i<n; i++) {
        cin >> s >> t;
        Q.push(make_pair(s,t));
    }
    pair<string,int> u;
    int ans=0, a;
    while (!Q.empty()) {
        u=Q.front();
        Q.pop();
        a=min(u.second,q);
        u.second-=a;
        ans+=a;
        if (u.second>0) {
            Q.push(u);
        } else {
            cout << u.first << " " << ans << endl;
        }
    }
    return 0;
}

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
const ll mod = 1e9+7;

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<ll> a(3*n);
	rep(i,3*n) cin >>a[i];
	
	vector<ll> x(3*n), y(3*n);
	
	priority_queue<ll> qa;
	ll smx = 0;
	rep(i, 3*n){
		qa.push(-a[i]);
		smx += a[i];
		if(sz(qa) >n){
			smx += qa.top(); qa.pop();
		}
		x[i] = smx;
	}

	priority_queue<ll> qb;
	ll smy = 0;
	repr(i, 3*n-1, 0){
		qb.push(a[i]);
		smy += a[i];
		if(sz(qb) >n){
			smy -= qb.top(); qb.pop();
		}
		y[i] = smy;
	}
	//for(auto z :x) printf("%lld, ",z); puts("");
	//for(auto z :y) printf("%lld, ",z); puts("");

	ll ans = -1LL<<50;
	rep2(i, n-1, 2*n){
		ans = max(ans,  x[i] - y[i+1]);
	}
	cout << ans <<endl;
	return 0;
}



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

using namespace std;
#define ll long long
#define ld long double

ll gcd(ll a, ll b) {
    return b ? gcd(b,a % b) : a;    
}

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

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    double n, k;
    cin >> n >> k;
    cout << (int)(ceil(n / k) - floor(n / k)) << endl;     
    return 0;
}


Measured memory_bytes: 256
k= int(input())
x,y = map(int,input().split())
if 1<=x<=y<=1000 and 1<=k<=1000:
    pass



    if x%k>>0 :
        if x<= (x//k+1)*k <=y :
            print('OK')
        else:
            print('NG')
    else:
        print('OK')

else:
    print('NG')

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF = 1LL<<60;
int N,M;
vector<vector<int>> G;

int dp[100100];
int rec(int v) {
  if (dp[v] != -1) return dp[v];
  int res = 0;
  for (auto nv : G[v]) {
    chmax(res, rec(nv) + 1);
  }
  return dp[v] = res;
}

int main() {
  cin >> N >> M;
  G.assign(N, vector<int>());
  rep(i,M) {
    int x,y; cin >> x >> y;
    --x; --y;
    G[x].push_back(y);
  }

  rep(v,N) dp[v] = -1;

  int res = 0;
  rep(v,N) chmax(res, rec(v));
  cout << res << endl;
}


Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#include <limits.h>
#include <stack>
#include <queue>
#define maxn 10000000
#define pi acos(-1)
using namespace std;
struct node{
char x[17];
int time;	
}a[100007];
int main()
{
	queue<node>qu;
	int t,n;
	cin>>n>>t;
	int tt=0;
	for(int i=1;i<=n;i++){
		cin>>a[i].x>>a[i].time;
		qu.push(a[i]);
	}
	while (!qu.empty()) {
		node x=qu.front();
		qu.pop();
		if(x.time-t<=0)
		{
			tt+=x.time;
			cout<<x.x<<" "<<tt<<endl;
		}
		else
		{
			tt+=t;
			x.time-=t;
			qu.push(x);
		}
	}
	return 0;
}



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

#define ll long long
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1000000007;

using namespace std;

vector<int>v[100100];
int d[100100];

int dfs(int s){
    if (d[s])return d[s];

    d[s]=1;
    for (auto i:v[s]){
        d[s]=max(d[s],1+dfs(i));
    }
    return d[s];
}

int main(){
    memset(d,0,sizeof(d));
    int n,m;
    cin>>n>>m;
    for (int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    int ans=0;
    for (int i=1;i<=n;i++){
        ans=max(ans,dfs(i));
    }
    cout<<ans-1;
	return 0;
}
/*
AGGTAB
GXTXAYB
*/


Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;

	if (n == 22)
		cout << "Christmas Eve Eve Eve" << endl;
	if (n == 23)
		cout << "Christmas Eve Eve" << endl;
	if (n == 24)
		cout << "Christmas Eve" << endl;
	if (n == 25)
		cout << "Christmas" << endl;

	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    string a, b, c;
    cin >> a >> b >> c;
  string ans = "YES";
    if((a.back() != b[0]) || (b.back() != c[0] )){
ans = "NO";
    }
cout << ans << endl;
    return 0;
}


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

vector<int> Prime(1000000),Matsuzaki(100000);

int judge(int n){
  if(n<2)return 0;
  if(n==2)return 1;
  if(n%2==0)return 0;
  for(int i=3;i<=n/i;i+=2){
    if(n%i==0)return 0;
  }
  return 1;
}

int main()
{
  int a=0,b=0,N,P,ii;
  for(int i=2;i<1000000;i++){
    if(judge(i))Prime[b++]=i;
  }
  while(1){
    cin>>N>>P;
    if(N==-1&&P==-1)break;
    a=0; 
    for(int i=0;i<b;i++){
      if(Prime[i]>N){
	ii=i;
	break;
      }
    }
    for(int i=ii;i<ii+100;i++){
      for(int j=i;j<ii+100;j++){
	Matsuzaki[a]=Prime[i]+Prime[j];
	a++;
      }
    }
    sort(Matsuzaki.begin(),Matsuzaki.begin()+a);
    cout<<Matsuzaki[P-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 5428
h, w = map(int, input().split())

s1 = (h // 3) * w
s2 = (h - (h // 3)) * (w // 2)
s3 = h * w - s1 - s2
diff_sh1 = max(s1, s2, s3) - min(s1, s2, s3)

s1 = (h // 3 + 1) * w
s2 = (h - (h // 3 + 1)) * (w // 2)
s3 = h * w - s1 - s2
diff_sh2 = max(s1, s2, s3) - min(s1, s2, s3)

s1 = (h // 3) * w
s2 = ((h - (h // 3)) // 2) * w
s3 = h * w - s1 - s2
diff_sh3 = max(s1, s2, s3) - min(s1, s2, s3)

s1 = (h // 3 + 1) * w
s2 = ((h - (h // 3 + 1)) // 2) * w
s3 = h * w - s1 - s2
diff_sh4 = max(s1, s2, s3) - min(s1, s2, s3)


s1 = h * (w // 3)
s2 = (h // 2) * (w - (w // 3))
s3 = h * w - s1 - s2
diff_sw1 = max(s1, s2, s3) - min(s1, s2, s3)

s1 = h * (w // 3 + 1)
s2 = (h // 2) * (w - (w // 3 + 1))
s3 = h * w - s1 - s2
diff_sw2 = max(s1, s2, s3) - min(s1, s2, s3)

s1 = h * (w // 3)
s2 = h * ((w - (w // 3)) // 2)
s3 = h * w - s1 - s2
diff_sw3 = max(s1, s2, s3) - min(s1, s2, s3)

s1 = h * (w // 3 + 1)
s2 = h * ((w - (w // 3 + 1)) // 2)
s3 = h * w - s1 - s2
diff_sw4 = max(s1, s2, s3) - min(s1, s2, s3)

min_sh = min(diff_sh1, diff_sh2, diff_sh3, diff_sh4)
min_sw = min(diff_sw1, diff_sw2, diff_sw3, diff_sw4)
print(min(min_sh, min_sw))

Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include<vector>
using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i =0;i<n;++i)
//#define mod (ll)(1e9+7)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,P;
    cin >> N >> M >> P;
    int x[3] = {abs(N-M), abs(M-P),abs(P-N)};
    sort(x,x+3);
    cout << x[0]+x[1] << endl;
    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;

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

  long long ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
A,B,C,X,Y = map(int, input().split())

ans = 0

if A+B<2*C:
  ans += (A+B)*min(X,Y)
else:
  ans += 2*C * min(X,Y)
  
if X>Y:
  ans += min(A,2*C )*(X-Y)
else:
  ans += min(B,2*C )*(Y-X)
  
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

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

	int H = scan.nextInt();
	int W = scan.nextInt();
	int h = scan.nextInt();
	int w = scan.nextInt();

	int black = H*W;
	int white = H*w+W*h-h*w;
	System.out.println(black-white);
    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibutan(auto a,auto b);
void print(int a,int b,int c){
    cout << a << " " << b << " " << c << endl;
}
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}


signed main(){
    int n;
    cin >> n;
    vector<int> a;
    REP(i,1001){
        if(IsPrime(i)){
            a.push_back(i);
        }
    }
    int ans = 1;
    REP(i,a.size()){
        int tmp = n;
        int count = 0;
        while(tmp>=a[i]){
            count+= tmp / a[i];
            tmp /= a[i];
        }
        ans *= count + 1;
        ans %= max_int;
    }
    cout << ans << endl;
    
    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibutan(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    return x-1;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++)
    cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  int ans = 0;
  int num = 0;
  for(int i = 0; i < N; i++) {
    if(num != vec.at(i)) {
      ans++;
      num = vec.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s =  list(input())
nucleotide = ['A', 'C', 'G', 'T']
paircount, maxpair = 0, 0
for i in s:
  if (i in nucleotide) == True:
    paircount += 1
  else:
    paircount = 0
  if maxpair <= paircount:
    maxpair = paircount
print(maxpair)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    int cnt[100010]={};
    for(int i=0; i<n; i++){
        int d; cin>>d; cnt[d]++;
    }
    int c=0;
    int ans=0;
    for(int i=1; i<=100001; i++){
        if(c==n/2) ans++;
        c+=cnt[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

int main() {

    int A,B;

    cin >> A >> B;

    if(A >= 13){
        cout << B << endl;
    }
    else if((A >= 6)&&(A <= 12)){
        cout << B/2 << endl;
    }
    else{
        cout << 0 << endl;
    }

}

Measured memory_bytes: 3624
#include <bits//stdc++.h>
#define rep(i,k) for(int i=0;i<k;i++)
#define int unsigned long long
using namespace std;
signed main(void){
    int n,m,a,b,c,ans;
    cin>>n;
    
    for(int i=1;i<n;i++){
        if(i*i>n){
        ans=i;
        break;
        }
    }
    b=1;
    for(int i=ans;i>0;i--){
        if(n%i==0){
            b=i;
            break;
        }
    }
    
    cout<<n/b+b-2<<endl;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/dp/tasks/dp_b

import sys
def b_frog2(l,k):
    dp=[0]*len(l)
    dp[0],dp[1]=0,abs(l[1]-l[0])
    for i in xrange(1,len(l)):
        mi=sys.maxint
        for j in xrange(1,k+1):
            if (i-j)<0: continue
            cost=dp[i-j]+abs(l[i]-l[i-j])
            if cost<mi:
                mi=cost
                dp[i]=cost
    return dp[-1]
n,k=map(int,raw_input().split())
l=list(map(int,raw_input().split()))
print b_frog2(l,k)

Measured memory_bytes: 11196
#!/usr/bin/env python3
import sys
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
TH = 1e18
for i in range(n):
	ans = ans * a[i]
	if ans > TH:
		print(-1)
		sys.exit()
print(ans)


Measured memory_bytes: 21788
n = int(input())
data = [input() for _ in range(n)]
a = data.count("AC")
b = data.count("WA")
c = data.count("TLE")
d = data.count("RE")
print("AC x " + str(a))
print("WA x " + str(b))
print("TLE x " + str(c))
print("RE x " + str(d))

Measured memory_bytes: 16208
#include <stdio.h>
#include <inttypes.h>

int ketasu(int hoge) {
	if (hoge < 10) return 1;
	else if (hoge < 100) return 2;
	else if (hoge < 1000) return 3;
	else if (hoge < 10000) return 4;
	else if (hoge < 100000) return 5;
	else if (hoge < 1000000) return 6;
	else if (hoge < 10000000) return 7;
	else if (hoge < 100000000) return 8;
	else if (hoge < 1000000000) return 9;
	else return 10;
}

int delta(int hoge) {
	if (hoge < 10) return 1;
	else if (hoge < 100) return 10;
	else if (hoge < 1000) return 100;
	else if (hoge < 10000) return 1000;
	else if (hoge < 100000) return 10000;
	else if (hoge < 1000000) return 100000;
	else if (hoge < 10000000) return 1000000;
	else if (hoge < 100000000) return 10000000;
	else if (hoge < 1000000000) return 100000000;
	else return 1000000000;
}

int saizyoui(int hoge) {
	return hoge / delta(hoge);
}

int keisan(int enu, int hazime, int owari) {
	if (hazime == 0) {
		return 0;
	} else if(enu < 10) {
		return hazime == owari && hazime <= enu;
	} else {
		int result = (hazime == owari);
		int k = ketasu(enu), s = saizyoui(enu), d = delta(enu);
		int i, sumipe;
		for (i = 2, sumipe = 1; hazime >= s ? (i < k) : (i <= k); i++) {
			result += sumipe;
			sumipe *= 10;
		}
		if (hazime == s) {
			int mamegu = enu - s * d;
			result += (mamegu - owari + 10) / 10;
		}
		return result;
	}
}

int main(void) {
	int N;
	uint64_t kotae = 0;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		kotae += keisan(N, i % 10, saizyoui(i));
	}
	printf("%" PRIu64 "\n", kotae);
	return 0;
}


Measured memory_bytes: 1708
#include<stdio.h>

int main(){
  int x,y,z,q;
  scanf("%d %d",&x,&y);
  if(x<y){
    q = x;
    x = y;
    y = q;
  }
  z = x % y;
  while(z!=0){
    x = y;
    y = z;
    z = x % y;
  }
  printf("%d\n",y);
  return 0;
}
    



Measured memory_bytes: 2128
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int N = 110;

int n;
int x[N], y[N], a[N];
int nonzero;

int check(int cx, int cy, int h) {
    for (int i = 0; i < n; i++) {
        int altitude = max(h - abs(cx - x[i]) - abs(cy - y[i]), 0);
        if (altitude != a[i]) {
            return 0;
        }
    }
    return 1;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d%d", x + i, y + i, a + i);
        if (a[i] != 0) {
            nonzero = i;
        }
    }
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            int cur_h = a[nonzero] + abs(cx - x[nonzero]) + abs(cy - y[nonzero]);
            if (check(cx, cy, cur_h)) {
                printf("%d %d %d\n", cx, cy, cur_h);
                return 0;
            }
        }
    }
    return 0;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;

string s,t;

int main(){
  cin >>  s >>  t;
  string ans = "UNRESTORABLE";
  per(i,0,s.size()-t.size()+1){
    bool flag = true;
    rep(j,0,t.size()){
      if(s[i+j]!='?'&&s[i+j]!=t[j])flag=false;
    }
    if(flag){
      rep(j,0,t.size()){
        s[i+j]=t[j]; // sの部分をtに置換
      }
      while(s.find("?")!=string::npos){
        s.replace(s.find("?"), 1, "a");
      }
      ans = s;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
u = []
v = []
for _ in range(N):
    x,y = map(int,input().split())
    u.append(x+y)
    v.append(x-y)

umax = max(u)
umin = min(u)
vmax = max(v)
vmin = min(v)

print(max(umax-umin,vmax-vmin))


Measured memory_bytes: 100640
// https://atcoder.jp/contests/abc140/tasks/abc140_c
// 番兵(sentinel)を置くことでループの端を気にせずに処理する
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)
#define SENTINEL 1000000;
int main()
{
    int N;
    cin >> N;
    vector<int> B(N + 1);
    B[0] = B[N] = SENTINEL;
    for (int i = 1; i < N; ++i) cin >> B[i];
    int ans = 0;
    REP(i, N)
    {
        ans += min(B[i], B[i + 1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] str = s.split(" ", 0);
        for(int i = 0; i<str.length; i++) {
            System.out.print(str[i].charAt(0));
        }
        System.out.println();
    }
}

Measured memory_bytes: 21204
using System;
using System.Collections.Generic;
using System.IO.Pipes;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            int N = cin.nextInt();
            int M = cin.nextInt();
            List<long> count = new List<long>();
            long sum = 0;
            for (int i = 0; i < N; i++)
            {
                long x = cin.nextInt();
                count.Add(x);
                sum += x;
            }

            double border = 1.0 / 4 / M * sum;
            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                if (count[i] >= border)
                {
                    ans++;
                }
            }

            if (ans >= M)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

    }
}


Measured memory_bytes: 27740
#include<cstdio>
#include<stack>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 200000
stack <char> st;
char str[MAXN + 5];
int main() {
	cin >> str;
	int len = strlen(str), Ans = 0;
	for (int i = 0; i < len; i++)
		if (str[i] == 'S') st.push('S');
		else if (st.size() > 0) {
			Ans += 2;
			st.pop();
		}
	cout << len - Ans;
	getchar(); getchar(); getchar();
}

Measured memory_bytes: 512
#include <iostream>

#define LEN 3

using namespace std;

int main() {
 int nums[LEN];

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

 for(int i= 0;i < LEN - 1;i++) {
  for(int j = i + 1;j < LEN;j++) {
   int tmp;

   if(nums[i] > nums[j]) {
    tmp = nums[i];
    nums[i] = nums[j];
    nums[j] = tmp;
   }
  }
 }

 for(int i = 0;i < LEN;i++) {
  cout << nums[i];

  if(i < LEN - 1) {
   cout << " ";
  }
 }

 cout << endl;

 return 0;
}

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

using namespace std;

int main()
{
  int n,ans=0;
  cin >> n;
  vector <int> a(n);
  
  while(n!=0){
    if(n%10==7){
      ans++;
    }
    n /= 10;
  }


  if(ans>0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    

}

Measured memory_bytes: 3572
<?php
$s = trim(fgets(STDIN));

switch ($s) {
	case 'SUN':
		$ret = 7;
		break;
	case 'MON':
		$ret = 6;
		break;
	case 'TUE':
		$ret = 5;
		break;
	case 'WED':
		$ret = 4;
		break;
	case 'THU':
		$ret = 3;
		break;
	case 'FRI':
		$ret = 2;
		break;
	case 'SAT':
		$ret = 1;
		break;
}

echo $ret;

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int a, b;
  cin >> a >> b;
  string A(a, b+'0'), B(b, a+'0');
  cout << min(A, B) << endl;
  return 0; 
}

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

using namespace std;

const int N = 103, B = 31625, MOD = 1e9 + 7;

int x[B];
int sum[N][B][2], dp[N][B][2];

int main()
{
    int k, n;
    cin >> k >> n;
    int b = sqrt(k);
    for (int i = 1; i <= b; ++i)
        x[i] = k / i - max(b, k / (i + 1));
    dp[0][0][0] = sum[0][0][0] = 1;
    for (int i = 1; i <= b; ++i)
        sum[0][i][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= b; ++j) {
            dp[i][j][0] = sum[i - 1][b][0] + sum[i - 1][b][1] - sum[i - 1][j - 1][1];
            if (dp[i][j][0] < 0)
                dp[i][j][0] += MOD;
            if (dp[i][j][0] >= MOD)
                dp[i][j][0] -= MOD;
            dp[i][j][1] = 1LL * x[j] * sum[i - 1][j][0] % MOD;
        }
        for (int j = 1; j <= b; ++j) {
            for (int t = 0; t < 2; ++t) {
                sum[i][j][t] = sum[i][j - 1][t] + dp[i][j][t];
                if (sum[i][j][t] >= MOD)
                    sum[i][j][t] -= MOD;
            }
        }
    }
    cout << (sum[n][b][0] + sum[n][b][1]) % MOD;
    return 0;
}


Measured memory_bytes: 50560