akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int sum = A + B;
		int dif = A - B;
		int pro = A * B;
		System.out.println(Math.max(sum,Math.max(dif, pro)));
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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


////////// 	Template structure for debugging

#define tr(...) trace(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void trace(const char* name, Arg1&& arg1){
cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void trace(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cout.write(names, comma-names) << " : " << arg1 << " | " ; 

trace(comma+1, args...);
}

#define print(...) pr(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void pr(const char* name, Arg1&& arg1){
cout << arg1 << endl;
}
template <typename Arg1, typename... Args>
void pr(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cout << arg1 << " "; 
pr(comma+1, args...);
}

void printV(vector<int> &arr)
{
	for(int i=0;i<arr.size();i++)cout << arr[i] << " \n"[ i == arr.size()-1 ];
}
void printArr(int *arr,int n)
{
	for(int i=0;i<n;i++)cout << arr[i] << " \n"[ i == n-1 ];
}
void printVL(vector<long long> &arr)
{
	for(int i=0;i<arr.size();i++)cout << arr[i] << " \n"[ i == arr.size()-1 ];
}

///////////////// Fenwick Tree 
// void update(int index,int num){

// 	while(index<=N){
// 		arr[index] += num;
// 		index += index & (-index);
// 		//cout << index << endl;
// 	}

// }

// int sum(int index){

// 	int s = 0;
// 	while(index){
// 		s += arr[index];
// 		index -= index & (-index);
// 	}
// 	return s;
// }

//////////////////////////////////////////////

/////////////////// Type definitions
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<long,long> pl;
typedef pair<double,double> pd;
#define f first
#define s second
////////////////////////////////////////////////////////////////////////////

int t;
void solve(){}	

int main(){

	string s1,s2;
	cin >> s1 >> s2;
	int n = s1.length(), m = s2.length();
	int dp[n+1][m+1];
	memset(dp, 0, sizeof dp);

	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			if(s1[i] == s2[j]) dp[i+1][j+1] = dp[i][j] + 1;
			else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]); 
		}
	}

	//for(int i=0; i<=n; i++)printArr(dp[i], m+1);
	int i = n, j = m;
	string s;
	while(i>0 && j>0)
	{
		if(s1[i-1] == s2[j-1])s += s1[i-1],i--,j--;
		else if(dp[i-1][j] > dp[i][j-1])i--;
		else j--;
	}
	reverse(s.begin(),s.end());
	print(s);
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

const ll MOD = 1e9+7;

ll dp[2100][2100] = {0};
ll sum[2100][2100] = {0};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<int> S(N);
    vector<int> T(M);

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

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

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

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

    ll ans = 1;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            if(S[i] == T[j]){
                dp[i+1][j+1] = (sum[i][j])%MOD;
                ans = (ans + dp[i+1][j+1])%MOD;
            }
            sum[i+1][j+1] = (sum[i][j+1] + sum[i+1][j] + MOD - sum[i][j] + dp[i+1][j+1])%MOD;
        }
    }


    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 67968
#Binary search
N=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

def Binary_Search(item,list):
    low=0
    high=len(list)-1
    while low<=high :
        mid=(high+low)//2
        if item == list[mid]:
            return 1
        elif item < list[mid]:
            high=mid-1
        else:
            low=mid+1
    return 0

cnt=0
for i in T:
    cnt+=Binary_Search(i,S)
print(cnt)


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

int main(){
	int n;
	char w[100][11];
	scanf("%d\n", &n);
	for(int i=0; i<n; i++) {
		scanf("%s\n", w[i]);
	}
	for(int i=1; i<n; i++) {
		int j=0;
		while(w[i-1][j]) j++;
		if(w[i-1][j-1] != w[i][0]) {
			printf("No\n");
			return 0;
		}
		for(j=0; j<i; j++){
			int k=0;
			while(w[i][k] == w[j][k]){
				if(w[i][k] == '\0'){
					printf("No\n");
					return 0;
				}
				k++;
			}
		}
	}
	printf("Yes\n");
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  set<string> m;
  for(int i=0;i<N;++i){
    string s;
    cin>>s;
    m.insert(s);
  }

  cout<<(int)m.size()<<endl;
}

Measured memory_bytes: 19228
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
A = getList()

fore = A[:N]
back = A[2 * N:]
back = [-i for i in back]
for_sum = sum(fore)
back_sum = sum(back)
heapq.heapify(fore)
heapq.heapify(back)

fore_list = []
back_list = []
for i in range(N):
    fore_list.append(for_sum)
    back_list.append(back_sum)
    in_fore = A[N + i]
    heapq.heappush(fore, in_fore)
    out_fore = heapq.heappop(fore)
    for_sum += in_fore - out_fore

    in_back = (-1) * A[-N - i - 1]
    heapq.heappush(back, in_back)
    out_back = heapq.heappop(back)
    back_sum += in_back - out_back

fore_list.append(for_sum)
back_list.append(back_sum)

ans = -float('inf')
for i in range(N + 1):
    opt = fore_list[i] + back_list[N - i]
    ans = max(ans, opt)
print(ans)

Measured memory_bytes: 127296
#include<iostream>
#include<algorithm>

using namespace std;

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

int main() {
  string d;
  cin >> d;
  string aid = "AIDUNYAN";
  sort(aid.begin(), aid.end());
  rep (i, d.size()) {
    string sub = d.substr(i, 8);
    sort(sub.begin(), sub.end());
    if (sub == aid) {
      cout << "AIZUNYAN";
      i += 7;
    } else {
      cout << d[i];
    }
  }
  cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i <= pow(10,8); i++){
    int tmp = a * i;
    if (tmp % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
typedef long long ll;

int N,M,R;
int land[205][205];
int sea[205][205];
int order[1005];

void floydWarshall()
{
    for(int k=1;k<=N;k++){
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                if(i==j)
                    land[i][j] = sea[i][j] = 0;
                if(land[i][k]+land[k][j]<land[i][j]) 
                    land[i][j] = land[i][k]+land[k][j];
                if(sea[i][k]+sea[k][j]<sea[i][j])
                    sea[i][j] = sea[i][k]+sea[k][j];
            }
        }
    }
}

int solve()
{
    int dp[1005][205];
    memset(dp,0x3f3f,sizeof(dp));
    dp[0][order[0]] = 0;
    for(int i=0;i+1<R;i++){
        for(int j=1;j<=N;j++){
            if(dp[i][j]==0x3f3f3f3f)
                continue;
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]+land[order[i]][order[i+1]]);
            for(int k=1;k<=N;k++){
                dp[i+1][k] = min(dp[i+1][k],dp[i][j]+land[order[i]][j]+sea[j][k]+land[k][order[i+1]]);
            }
        }
    }

    int ans = 0x3f3f3f3f;
    for(int j=1;j<=N;j++)
        ans = min(ans,dp[R-1][j]);
    return ans;
}




int main()
{   
    // freopen("in","r",stdin);
    while(scanf("%d%d",&N,&M) && (N+M)){
        memset(land,0x3f3f,sizeof(land));
        memset(sea,0x3f3f,sizeof(sea));
        for(int i=0;i<M;i++){
            int u,v,d;
            char c;
            scanf("%d%d%d %c",&u,&v,&d,&c);
            if(c=='L')
                land[u][v]=land[v][u]=d;
            else
                sea[u][v]=sea[v][u]=d;
        }
        scanf("%d",&R);
        for(int i=0;i<R;i++)
            scanf("%d",&order[i]);
        floydWarshall();
        int ans = solve();
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 4328
H, W = map(int, input().split())
H_list = [list(input()) for i in range(H)]
import numpy as np

H_list = np.array(H_list)

w_cnt = 0
b_cnt = 0
for i in H_list:
    for j in i:
        if j == '.':
            w_cnt += 1
        if j == '#':
            b_cnt += 1
    
dis_mat = np.zeros((H, W))
dis_mat[0, 0] = 1
queue = []
queue.append([0,0])

while queue != []:
    v = queue.pop(0)

    v_new = [[v[0], v[1]+1],
             [v[0], v[1]-1],
             [v[0]+1, v[1]],
             [v[0]-1, v[1]]]

    for i in v_new:
        if 0 <= i[0] < H and 0 <= i[1] < W:
            if dis_mat[i[0], i[1]] == 0 and H_list[i[0], i[1]] == '.':
                dis_mat[i[0], i[1]] = dis_mat[v[0], v[1]] + 1
                queue.append(i)
        
dis = dis_mat[H-1][W-1]
if dis == 0:
    print(-1)
else:
    print(int(w_cnt - dis))

Measured memory_bytes: 12484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll l, r, d;
    cin >> l >> r >> d;
    cout << r / d - (l - 1) / d << endl;
}

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

int main()
{
  int N;
  cin >> N;
  
  int a, cnt=0;
  for(int i=1; i<=N; i++)
  {
    cin >> a;
    if (i % 2 && a % 2) cnt++;
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<vector<int> > g(n);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> d(n,-1);
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
	int k;
	cin>>k;
	while(k--)
	{
		int v,p;
		cin>>v>>p;
		v--;
		d[v]=p;
		pq.push(make_pair(p,v));
	}
	while(!pq.empty())
	{
		pair<int,int> q=pq.top();
		pq.pop();
		int u=q.second;
		for(int v:g[u])
			if(d[v]==-1)
			{
				d[v]=d[u]+1;
				pq.push(make_pair(d[v],v));
			}
	}
	for(int u=0;u<n;u++)
		for(int v:g[u])
			if(abs(d[u]-d[v])!=1)
			{
				cout<<"No"<<endl;
				return 0;
			}
	cout<<"Yes"<<endl;
	for(int u=0;u<n;u++) cout<<d[u]<<endl;
	return 0;
}


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

using namespace std;

int main()
{
	int n,a[200004],i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int dp[100002];
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);

	for(i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	printf("%d\n",dp[n] );
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  set<int> a;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    auto r=a.insert(x);
    if(r.second)continue;
    else a.erase(x);
  }
  cout << a.size();
}



Measured memory_bytes: 4864
#include<stdio.h>

int binarySearch(int A[],int key, int n){
    int left = 0;
    int right = n;
	int mid;
	while (left < right){
        mid = (left + right) / 2;
		if (A[mid] == key){
            return mid;
		}
	
		else if (key < A[mid]){
            right = mid;
		}
		else{
            left = mid + 1;
		}
	}
	
    return n;
}

int main(void){

	int n;
	
	scanf("%d",&n);
	
	int S[n+1];
	int i;
	
	for(i=0;i<n;i++){
	
		scanf("%d",&S[i]);
	
	}
	
	int q;
	scanf("%d",&q);
	
	int T[q];
	
	for(i=0;i<q;i++){
	
		scanf("%d",&T[i]);
	
	}
	
	int Sum=0;
	
	for(int j=0;j<q;j++){
		if(binarySearch(S,T[j],n)!=n){
			Sum++;
		}
	}
	
	printf("%d\n",Sum);
	
}



Measured memory_bytes: 2364
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define VEC() vector<ll int>v
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;strRescan ing mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}
//string add(string s,int n){ string res; int c=n,x; for(int i=s.size()-1;i>=0;i--)   { x=s[i]-'0'+c;res+=(x%10+'0'); c=x/10; }    while(c)    { res+=(c%10+'0'); c=c/10;} reverse(res.begin(),res.end()); return res;}

int main()
{
    FAST();
  ll int n,m,res=0,cnt=0;
  string s;
  cin>>n;
  VEC(n);
 //_sort(v);
 for(int i=0;i<n-1;i++)
 {
     if(v[i]>v[i+1]){res+=v[i]-v[i+1];v[i+1]=v[i];}
 }
 cout<<res<<endl;





    return 0;
}



Measured memory_bytes: 5324
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    
    vector<string> pic;
    for (int i=0; i<h; i++) {
        string tmp;
        cin >> tmp;
        pic.push_back(tmp);
    }

    for (int i=0; i<w+2; i++)
        cout << "#";
    cout << endl;

    for (int i=0; i<h; i++) {
        cout << "#" << pic[i] << "#" << endl;
    }

    for (int i=0; i<w+2; i++)
        cout << "#";
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 105;
const int V = 1e5 + 5;
int w[N], v[N];
int dp[N][V];
int n, wt;

int dynamic(int pos, int val)
{
    if (val == 0)
        return 0;
    if (val < 0 || pos < 0)
        return INT_MAX;
    if (dp[pos][val] != -1)
        return dp[pos][val];
    int ans;
    ans = min(dynamic(pos - 1, val - v[pos]) + w[pos], dynamic(pos - 1, val));
    dp[pos][val] = ans;
    return ans;
}

void solve()
{
    cin >> n >> wt;
    mem1(dp);
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    int ans = INT_MIN;
    for (int i = 0; i <= V - 1; i++)
    {
        if (dynamic(n - 1, i) <= wt)
            ans = max(i, ans);
        // mem1(dp);
    }
    cout << ans;
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 82304
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	vector <int> x,y;
	for (int i=1;i<=n;i++){
		if (i%k==0) x.push_back(i);
		if (i%k==k/2) y.push_back(i);
	}
    int	a=x.size(),b=y.size();
	if (k%2==0)
		cout<<1ll*a*a*a+1ll*b*b*b;
	else
		cout<<1ll*a*a*a;
	return 0;
}

Measured memory_bytes: 2036
#include "stdio.h"
 
 
int main()
{
	int a;
	int b;
	int c;
	int cnt = 0;
	int maxnum;
	int i, j, k;
	scanf("%d %d %d", &a, &b, &c);
	scanf("%d", &maxnum);
	for (i = 0; i < a + 1; i++) {
		for (j = 0; j < b + 1; j++) {
			for (k = 0; k < c + 1; k++){
				if ((i * 500 + j * 100 + k * 50) == maxnum) {
					cnt++;
				}
 
			}
		}
	}
	printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}
void submain();

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

char s; cin >> s;

if (s >= 'a') cout << "a\n";
else cout << "A\n";



return 0;
}

// 制限が緩い場合での愚直解を書く。
void submain(){

}

// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

int main() {
  double l;
  cin >> l;

  cout << fixed << setprecision(12) << pow(l * 1.0 / 3, 3) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

struct Point {
  double x;
  double y;
};

void koch(int n, Point a, Point b){
  if (n == 0) {
    return ;
  }

  double th = M_PI * 60.0 / 180.0;

  Point s, t, u;
  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);  
}


int main(int argc, char const *argv[]) {
  Point a, b;
  int n;
  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,M,Q;
    scanf("%d%d%d",&N,&M,&Q);
    vector<vector<int>>group(Q,vector<int>(4));
    
    for(int i=0 ; i<Q ; i++)
    {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        group.at(i).at(0) = a;
        group.at(i).at(1) = b;
        group.at(i).at(2) = c;
        group.at(i).at(3) = d;
    }
    
    vector<int>A(N,1);
    int e = N-1;
    int sum = 0;
    int current_max=0;
    A.at(e)=0;
    do
    { 
       
        //Aの更新
        sum=0;
        for(int i =0;i<N;i++)
        {
            if(A.at(e-i)!=M)
            {
                A.at(e-i)+=1;
                for(int j =0;j<i;j++)
                {
                    A.at(e-j)=A.at(e-i);
                }
                break;
            }
        }
        //生成されたAについての処理
        for(int i = 0 ; i<Q;i++)
        {
            if(A.at( group.at(i).at(1)-1 )-A.at( group.at(i).at(0)-1 )==group.at(i).at(2) )
            {
                sum+= group.at(i).at(3);
            }
        }
        if(current_max < sum)
        {
            current_max = sum;
        }
    }while(A.at(0)!=M);
    cout<<current_max<<endl;
}   

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    int time = 0;
    int pos = 0;
    while (pos < N)
    {
        time++;
        pos = (time * (time + 1)) / 2;
    }
    cout << time << "\n";
}

Measured memory_bytes: 256
while True:
    m, f, r = list(map(int, input().split(" ")))
    if (m == -1) and (f == -1) and (r == -1):
        break
    elif (m == -1) or (f == -1):
        print ("F")
    elif m + f >= 80:
        print ("A")
    elif (m + f >= 65) and (m + f < 80):
        print ("B")
    elif (m + f >= 50) and (m + f < 65):
        print ("C")
    elif (m + f >= 30) and (m + f < 50):
        if r >= 50:
            print ("C")
        else:
            print ("D")
    else:
        print ("F")
        

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int dp[100010][3];

int main()
{
	int n;
	cin >> n;
	int a[n+10][3];
	rep(i,n) rep(j,3) cin >> a[i][j];
	rep(i,3) dp[0][i] = a[0][i];
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(j == k) continue;
				dp[i][k] = max(dp[i][k],dp[i-1][j]+a[i][k]);
			}
		}
	}
	cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long long GCD(long long a,long long b){return b ? GCD(b,a%b):a;}
int main(){
    int N;cin>>N;
    long long t=1,a=1;
    for(int i=0;i<N;i++){
        long long T,A;cin>>T>>A;
        long long a1=A/GCD(T,A);
        long long t1=T/GCD(T,A);
        long long j=max((t-1+t1)/t1,(a-1+a1)/a1);
        t=j*t1;
        a=j*a1;
        //cout<<t<<" "<<a<<endl;

    }
    cout<<t+a<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            String s = reader.readLine();

            s = s.replaceFirst("2017/", "2018/");

            System.out.println(s);
        }
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    string s; cin >> s;
    int a = s.size()-2;
    while(a>=2){
        if(s.substr(0,a/2)==s.substr(a/2,a-a/2)){
            cout << a << endl;
            a = 0;
        }else{
            a-=1;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n;
long long ans=0;
int main()
{
	scanf("%lld",&n);
	if (n<=9) 
	{
		printf("%lld\n",n);
		return 0;
	}
	n+=1;
	while (n>=10)
	{
		ans+=9;
		n/=10;
	}
	ans+=n-1;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <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)

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    vector<pair<int, int>> cnts;
    REP(i, N)
    {
        cnts.push_back(pair<int, int>(A[i], (int)i));
    }
    sort(cnts.begin(), cnts.end(), [](pair<int, int>& a, pair<int, int>& b){ return a.first > b.first;});
    vector<int> res(N);
    REP(i, N)
    {
        auto it = cnts.begin();
        if (it->second == i)
        {
            ++it;
            res[i] = it->first;
        }
        else
        {
            res[i] = it->first;
        }
        
    }
    REP(i, N)
    {
        cout << res[i] << endl;
    }
    return 0;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N); REP(i, N) cin >> A[i];

	ll res{0};

	ll pre{0};
	REP(i, N)
	{
		ll sum = pre + A[i];
		res += sum / 2;
		if ((sum & 1) && A[i] != 0)
			pre = 1;
		else
			pre = 0;

		// std::cout << "----------"<< std::endl;
		// std::cout << "i : " << i << std::endl;
		// std::cout << "sum : " << sum << std::endl;
		// std::cout << "res : " << res << std::endl;
	}

	std::cout <<  res << std::endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define int long long
 
using namespace std;
 
int a[1010][1010];
 
int32_t main()
{
    int n,m;
    cin >> n >> m;
 
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin >> a[i][j];
            a[i][j] %= 2;
        }
    }
 
    vector <vector <int> > v;
 
    for(int i=1;i<=n;)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j] == 1)
            {
                vector <int> p(4,0);
                p[0] = i;
                p[1] = j;
                p[2] = i;
                p[3] = j+1;
 
                if(p[3] == m+1)
                {
                    p[2]++;
                    p[3]--;
                }
 
                a[p[2]][p[3]]++;
                a[p[2]][p[3]] %= 2;
 
                if(p[2] <= n)
                    v.push_back(p);
            }
        }
 
        i++;
 
        if(i > n)
            break;
 
        for(int j=m;j>=1;j--)
        {
            if(a[i][j] == 1)
            {
                vector <int> p(4,0);
                p[0] = i;
                p[1] = j;
                p[2] = i;
                p[3] = j-1;
 
                if(p[3] == 0)
                {
                    p[2]++;
                    p[3]++;
                }
 
                a[p[2]][p[3]]++;
                a[p[2]][p[3]] %= 2;
 
                if(p[2] <= n)
                    v.push_back(p);
            }
        }
 
        i++;
    }
 
    cout << v.size() << endl;
 
    for(int i=0;i<v.size();i++)
    {
        cout << v[i][0] << " " << v[i][1] << " " << v[i][2] << " " << v[i][3] << endl;
    }
}

Measured memory_bytes: 15024
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

int main(){

    long n;
    long u,v;
    long a;

    scanf("%ld", &n);
    a = n*(n+1)*(n+2)/6;
    for(ll i = 1;i < n;i++){
        scanf("%ld %ld", &u, &v);
        if(u < v) a -= u * (n-v+1);
        else a -= v * (n-u+1);
    }
    printf("%ld\n", a);
}


Measured memory_bytes: 3824
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

string s;
Int k;
vector<P> nums;
Int ans;

Int solve(Int x){
    return x/2;
}

int main(){
    cin >> s;
    cin >> k;
    int cnt = 0;
    char last;
    for(int i = 0;i < s.size();i++){
        if(i == 0 || last == s[i]){
            cnt++;
            last = s[i];
        }
        else{
            nums.push_back(P(cnt, k));
            last = s[i];
            cnt = 1;
        }
    }
    nums.push_back(P(cnt, k));
    if(nums.size() == 1){
        cout << solve(s.size() * k) << endl;
        return 0;
    }
    if(s[0] == s[s.size() - 1]){
        P tmp = P(nums[0].first + nums.back().first,
                  k-1);
        
        nums[0].second = 1;
        nums.back().second = 1;
        nums.push_back(tmp);
    }
    for(auto p:nums){
        ans += p.second * solve(p.first);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;
    cin>>N;
    std::vector<long long>A(N);
    vector<long long>B(N);
    for(long long i=0;i<N;i++){
        cin>>A[i];
        B[i]=0;
    }
    for(long long i=0;i<N-1;i++){
        B[A[i]-1]++;
    }
    for(long long i=0;i<N;i++){
        cout<<B[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 6384
import math
import bisect
import copy
#import time
import itertools
#map(int,input().split())
#int(x) for x in input().split()
#for _ in range(int(input()))

n=int(input())
l=[int(x) for x in input().split()]
l.sort(reverse=True)
ans=0
if n%2==0:
	n=n-2
	ans+=l[0]
	for i in range(1,len(l)):
		if n==0:
			break
		else:
			ans+=2*l[i]
			n-=2
else:
	n=n-2
	ans+=l[0]
	for i in range(1,len(l)):
		if n==1:
			break
		else:
			ans+=2*l[i]
			n-=2
	ans+=l[i]
print(ans)




Measured memory_bytes: 93988
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($i = 0; $i < $H; $i++){
  foreach(str_split(trim(fgets(STDIN))) as $char){
    if(!isset($map[$char]))$map[$char] = 0;
    $map[$char]++;
  }
}
$ff = $tt = $s = 0;
foreach($map as $char => $count){
  $f = intdiv($count, 4)*4;
  $ff += $f; $count -= $f;
  $t = intdiv($count, 2)*2;
  $tt += $t; $count -= $t;
  $s += $count;
}
$center = ($H%2) * ($W%2);
$two = intdiv($H,2)*2*($W%2) + intdiv($W,2)*2*($H%2);
$four = $H*$W-$center-$two;
//echo $two,"-",$four,"\n";
//echo $tt,"-",$ff,"\n";
$flag = true;
if($ff < $four){
  $flag = false;
}else{
  $tt += $ff - $four;
}
if($tt < $two){
  $flag = false;
}
echo $flag ? "Yes" : "No";

Measured memory_bytes: 4856
package main

import (
	"container/heap"
	"fmt"
	"runtime"
)

type Node struct {
	NowPosition          int
	DiscountTicketTCount int
	Amount               int
}

type PriorityQueueNode []*Node

func (pq PriorityQueueNode) Len() int {
	return len(pq)
}

func (pq PriorityQueueNode) Less(i, j int) bool {
	return pq[i].Amount < pq[j].Amount
}

func (pq PriorityQueueNode) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueueNode) Push(node interface{}) {
	*pq = append(*pq, node.(*Node))
}

func (pq *PriorityQueueNode) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

type Point struct {
	NextPoint int
	Fee       int
}

type Memo struct {
	NowPoint             int
	DiscountTicketTCount int
}

func main() {
	var c, n, m, s, d int
	var a, b, f int

	for {
		fmt.Scan(&c, &n, &m, &s, &d)
		if c == 0 && n == 0 && m == 0 && s == 0 && d == 0 {
			break
		}
		s--
		d--
		pointMap := make([][]Point, n)
		for i := 0; i < n; i++ {
			pointMap[i] = make([]Point, 0, n)
		}
		for i := 0; i < m; i++ {
			fmt.Scan(&a, &b, &f)
			a--
			b--
			pointMap[a] = append(pointMap[a], Point{NextPoint: b, Fee: f})
			pointMap[b] = append(pointMap[b], Point{NextPoint: a, Fee: f})
		}
		pq := make(PriorityQueueNode, 0, m)
		start := Node{NowPosition: s, DiscountTicketTCount: c, Amount: 0}
		heap.Push(&pq, &start)
		memo := make(map[Memo]int)
		for len(pq) != 0 {
			now := heap.Pop(&pq).(*Node)
			if now.NowPosition == d {
				fmt.Println(now.Amount)
				break
			}
			memo[Memo{NowPoint: now.NowPosition, DiscountTicketTCount: now.DiscountTicketTCount}] = now.Amount
			for _, v := range pointMap[now.NowPosition] {
				next := &Node{v.NextPoint, now.DiscountTicketTCount, now.Amount + v.Fee}
				if memoAmount, ok := memo[Memo{NowPoint: v.NextPoint, DiscountTicketTCount: now.DiscountTicketTCount}]; !ok || (ok && memoAmount > next.Amount) {
					memo[Memo{NowPoint: v.NextPoint, DiscountTicketTCount: now.DiscountTicketTCount}] = next.Amount
					heap.Push(&pq, next)
				}
				if now.DiscountTicketTCount > 0 {
					next = &Node{v.NextPoint, now.DiscountTicketTCount - 1, now.Amount + v.Fee/2}
					if memoAmount, ok := memo[Memo{NowPoint: v.NextPoint, DiscountTicketTCount: now.DiscountTicketTCount}]; !ok || (ok && memoAmount > next.Amount) {
						memo[Memo{NowPoint: v.NextPoint, DiscountTicketTCount: now.DiscountTicketTCount}] = next.Amount
						heap.Push(&pq, next)
					}
				}
			}
		}
		runtime.GC()
	}
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  i64 x; cin >> x;
  cout << min((x + 4) / 11 * 2 + 1, (x + 10) / 11 * 2) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int W, H, T;
    cin >> W >> H >> T;
    int p;
    cin >> p;
    vvi a(H, vi(W));
    rep(i, p) {
        int c, r, t;
        cin >> c >> r >> t;
        a[r][c]++;
    }
    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            int b;
            cin >> b;
            ans += b * a[i][j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int n;
    cin>>n;
    bool ok=false;
    rep(i,9){
        rep(j,9){
            if((i+1)*(j+1)==n) ok=true;
        }
    }
    cout<<(ok? "Yes": "No")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N_MAX 200000

int main(void) {
	int stack[N_MAX+100];
	int stack_pos=0;
	int N,i;
	int count=0;
	if(scanf("%d",&N)!=1)return 1;
	stack[stack_pos++]=0;
	for(i=0;i<N;i++) {
		int a;
		if(scanf("%d",&a)!=1)return 1;
		while(stack[stack_pos-1]>a)stack_pos--;
		if(stack[stack_pos-1]<a) {
			stack[stack_pos++]=a;
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

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

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

  int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  int tmp_x = x1-x2, tmp_y = y2-y1;

  int x3 = x2-tmp_y;
  int y3 = y2-tmp_x;
  int x4 = x1-tmp_y;
  int y4 = y1-tmp_x;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << '\n';
  return 0;
}


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

int main() {
	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	int ans_X = B * ((int)(N / A) + (N % A == 0 ? 0 : 1));
	int ans_Y = D * ((int)(N / C) + (N % C == 0 ? 0 : 1));
	cout << min(ans_X, ans_Y) << endl;
	return 0;
}


Measured memory_bytes: 3044
def calc(s, n):
    if n == 0:
        ans = int(s[0])
        for i in range(2, len(s), 2):
            if s[i-1] == "+":
                ans += int(s[i])
            else:
                ans -= int(s[i])
        if ans == 7:
            global answer
            answer = s[0:len(s)-1] + "=7"
    if(n != 0): calc(s[0:n]+"+"+s[n:], n-1)
    if(n != 0): calc(s[0:n]+"-"+s[n:], n-1)

s = input()
answer = ""
calc(s, len(s))
print(answer)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B; cin >> A >> B;
    if (B % A == 0){
        cout << A + B << endl;
    } else {
        cout << B - A << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3644
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N = int(input())
s = list(input().rstrip())
s.append(s[0])
a = [-1]*(N+2) # 0==N 1==N+1

def d(self,f,ans):
    if ans == "o":
        return (self + f)%2
    else:
        return (self + f +1)%2

flag = 0
for p in [(0,0),(0,1),(1,0),(1,1)]:
    a[0],a[1] = p
    for i in range(1,N+1):
        a[i+1] = d(a[i],a[i-1],s[i])
    if a[0] == a[N] and a[1] == a[N+1]:
        break
else:
    flag = -1

if flag == -1:
    print(-1)
else:
    ans = [None]*N
    for i in range(N):
        if a[i] == 0:
            ans[i] = "S"
        else:
            ans[i] = "W"
    output = "".join(ans)
    print(output)

Measured memory_bytes: 51568
#include<bits/stdc++.h>
using namespace std;
int main(){
  int W,a,b;
  cin>>W>>a>>b;
  
  int A=a+W;
  int B=b+W;

  if(a<b){
    if(A>=b){
cout<<0<<endl;
    }
    
    else{
cout<<b-A<<endl;
    }
  }
  
 else if(b<a){
   if(B>=a){
     cout<<0<<endl;
   }
   
   else{
     cout<<a-B<<endl;
   }
 }
  
  else if(a==b){
cout<<0<<endl;
  }
}
    

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  int now = 1, cnt = 0;
  while (1) {
    if (now == 2) {
      cout << cnt << endl;
      break;
    }
    if (cnt > n) {
      cout << "-1" << endl;
      break;
    }
    now = a[now];
    cnt++;
  }

  return 0;
}

Measured memory_bytes: 640
import sys
#import numpy as np
stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

A, B, K = rl()

if A > K:
    A -= K
else:    
    B = max(0, B - (K-A))
    A = 0

print(A, B)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		boolean f = false;
		for(int i = A ; i <= B ; ++i){
			if(i % K == 0){
				f = true;
			}
		}
		if(f){
			System.out.println("OK");
		}else{
			System.out.println("NG");			
		}
	}
}


Measured memory_bytes: 27076