akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int sum = 0, harf = 0, n;
    cin >> n;
    vector<int>pn(n);
    for(int i = 0; i < n; i++){
        cin >> pn.at(i);
        sum += pn.at(i);
        harf = max(harf, pn.at(i));
    }
    sum -= (harf / 2);
    cout << sum << endl;
    return 0;
}



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

int main(){
    string S, T;
    cin >> S >> T;
    vector<vector<int>> a(26), b(26);
    for(unsigned long i =  S.size(); i--; a[S[i] - 97].push_back(i))b[T[i] - 97].push_back(i);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    puts(equal(a.begin(), a.end(), b.begin()) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 2952
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 文字列の入力
        String s = sc.next();
        int count = 0;

        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'o') count++;
        }

        if(15 - s.length() + count >= 8){
            System.out.println("YES");
        }else{
            System.out.println("NO");    
        }

    }

}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string N;
cin >> N;
if (N.at(0) == '9' || N.at(1) == '9') {
  cout << "Yes"<< endl;
} else cout << "No" << endl;



return 0;
}

Measured memory_bytes: 256
import copy
n,k = map(int,input().split())
rsp = list(map(int,input().split()))
t = str(input())
count = 0
def win(h):
  if h == "r":
    return 2
  if h == "s":
    return 0
  if h == "p":
    return 1
for i in range(k):
  j = 0
  pre = [0,0,0]
  new = [0,0,0]
  while i + j*k < n:
    h = win(t[i+j*k])
    new[0] = max(pre[1],pre[2])
    new[1] = max(pre[0],pre[2])
    new[2] = max(pre[0],pre[1])
    new[h] += rsp[h]
    pre = copy.deepcopy(new)
    j += 1
  count += max(pre)
print(count)
    
    
    
    
  

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);
void solve()
{
	int n;
	cin >> n;
	int h[n];
	rep(i, n) cin >> h[i];
	int move = 0, mx = 0;;
	rep(i, n){
		if(i == 0) continue;
		if(h[i - 1] - h[i] >= 0) move++;
		else move = 0;
		mx = max(mx, move);
	}
	cout << mx;


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


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <sstream>

using namespace std;


int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int prev_max = 0;
    int count = 0;
    for (int i = 0; i < N; i++) {
        int tmp; cin >> tmp;
        if (prev_max <= tmp) {
            count++;
        }
        prev_max = max(prev_max, tmp);
    }
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int dx8[9] = { -1,-1,-1, 0, 1, 1, 1, 0 ,0};
int dy8[9] = { -1, 0, 1, 1, 1, 0,-1,-1,0 };
int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>>field(H + 2, vector<int>(W + 2));
	for (int i = 0; i < H; ++i) {
		string st; cin >> st;
		for (int j = 0; j < W;++j){
			auto ch(st[j]);
			if (ch == '-') {

			}
			else if (ch == 'o') {
				for (int x = j; x < j + 3; ++x) {
					field[i + 1][x] = true;
				}
			}
			else {
				for (int way = 0; way < 9; ++way) {
					field[i + 1 + dy8[way]][j + 1 + dx8[way]] = true;
				}
			}

		}
	}
	int ans = 0;
	ans = accumulate(field.begin() + 2, field.end() - 1, 0, [](const int a, const vector<int>v){
		return accumulate(v.begin() + 1, v.end() - 1, 0) + a;
		
	});
	cout << (H-1)*W-ans << endl;
	return 0;
}

Measured memory_bytes: 3212
#include<stdio.h>

int main(){
	int a[5],b[5],h,z,i,j;
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=-1){
		scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
		h=z=0;
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(a[i]==b[j]&&i==j) h++;
				if(a[i]==b[j]&&i!=j) z++;
			}
		}
		printf("%d %d\n",h,z);
	}
	return 0;
}
		

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

const int MAX = 55;
int main(){
  int n; cin >> n;
  int sum[MAX]; // sum[i+1] := p[i] までの和
  pair<string,int> p[MAX];  
  string s;
  sum[0] = 0;
  for(int i=0;i<n;i++){
    cin >> p[i].first >> p[i].second;
    sum[i+1] = sum[i] + p[i].second;
  }
  cin >> s;
  for(int i=0;i<n;i++){
    if(s==p[i].first) cout << sum[n] - sum[i+1];
  }
  return 0;
}

Measured memory_bytes: 256
x = list(input())
n = int(input())
for i in range(n):
    com = input().split()
    a = int(com[1])
    b = int(com[2])
    if com[0] == "print":
        print("".join(x[a:b+1]))
    elif com[0] == "reverse":
        x[a:b+1] = x[a:b+1][::-1]
    elif com[0] == "replace":
        x[a:b+1] = list(com[3])
		
		

Measured memory_bytes: 7652
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int y, m, d;
		cin >> y >> m >> d;
		int sumDay = 0;
		int month1[10] = { 0,20,39,59,78,98,117,137,156,176 };
		int month2[10] = { 0,20,40,60,80,100,120,140,160,180 };
		int ly = 0, nly = 0;
		for (int i = 1; i < y; i++)
			(i % 3 == 0) ? (ly++) : (nly++);
		sumDay += sumDay + (ly * 200 + nly * 195);
		if (y % 3 != 0)
			sumDay += month1[m - 1];
		else
			sumDay += month2[m - 1];
		sumDay += d;
		int millDay = 196470;
		int day = millDay - sumDay+1;
		cout << day << endl;
	}
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD 998244353
typedef long long int lli;

void swap(lli &a, lli &b);

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

    vector<int> a(n);
    bool has1 = false;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] == 1) has1 = true;
    }

    if(!has1){
        cout << -1 << endl;
        return 0;
    }

    int cnt = 0;
    int target = 1;
    for(int i = 0; i < n; ++i){
        if(a[i] == target){
            ++target;
        }else{
            ++cnt;
        }
    }
    cout << cnt << endl;
}

void swap(lli &a, lli &b){
    lli tmp = a;
    a = b;
    b = tmp;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
O = [0] + [1] * N
for _ in range(M):
    A, B = map(int, input().split())
    if H[A] <= H[B]:
        O[A] = 0
    if H[A] >= H[B]:
        O[B] = 0
print(sum(O))

Measured memory_bytes: 20140
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c,d,e,s,i,ans,k;
	cin>>a>>b>>c>>d>>e;
	s=a*e;
	if(e<=c)k=b;
	else 
	{
		k=((e-c)*d)+b;
	}
	if(k>=s)cout<<s<<endl;
	else cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
using namespace std;
int p[2000];
int main(){
	int n,m;
	cin >> n >> m;
	for(int i=0;i<n;++i)
		cin >> p[i];
	sort(p,p+n);
	int sum = 0;
	for(int i=0;i<m;++i)
		sum+=p[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[100005];
signed main()  {
    int N,X,Y;
    cin >> N >> X >> Y;
    vector<int>ans(N+1);
    for(int i = 1; i < N; i++) {
        for(int j = i+1; j <= N; j++) {
            ans[min(j-i,abs(X-i)+abs(Y-j)+1)]++;
        }
    }
    for(int i = 1; i < N; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3560
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);*/
#endif
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	//File();
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 2e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

int main()
{
	fast();
	ll n, m;
	cin >> n >> m;
	ll sum = 0;
	for (int i = 0; i < m; i++)
	{
		int x;
		cin >> x;
		sum += x;
	}
	if (sum>n)
		cout << -1 << endl;
	else
		cout << n - sum << endl;
	return 0;
}

Measured memory_bytes: 3660
import Control.Monad
import Text.Printf
import Control.Applicative
import Data.List as L

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO()
main = do
  s <- getLine
  [k] <- getInts
  printf "%s" $ slv s k

slv :: String -> Int -> String
slv s k = subStrs !! (k - 1)
  where subStrs = map head $ group $ sort $ concat [subStrings y (length s - (y - 1)) s [] | y <- [1..10]]


subStrings :: Int -> Int -> String -> [String] -> [String]
subStrings k cnt str ret | cnt <= 0 = ret
                         | otherwise = subStrings k (cnt-1) (tail str) (take k str:ret)

Measured memory_bytes: 17020
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string w;cin>>w;
    map<char,int> k;
    REP(i,w.size()){
        if(k.find(w[i])!=k.end()){
            k[w[i]]++;
        } else {
            k[w[i]]=1;
        }
    }
    for(auto i=k.begin();i!=k.end();i++){
        if(i->second%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import numpy as np

dp = np.zeros([10+1, 2, 8], dtype=int)

# 桁DPで解く
dp[0, 0, 0] = 1
dp[1:, 1, 0] = 1

N = input()
for i in range(len(N)):  # 桁
    for j in range(2):  # less
        v = 9 if j else int(N[i])
        for k in range(8):  # 3,7,5 含むかどうか

            for l in [l for l in (3, 5, 7) if l <= v]:

                j_idx = int(j or l < v)

                if l == 3:
                    k_idx = (k | 1)
                elif l == 5:
                    k_idx = (k | 2)
                else:
                    k_idx = (k | 4)

                dp[i + 1][j_idx][k_idx] += dp[i][j][k]
    # print(dp[i+1])
# print(dp[len(N)][1][7])
# print(dp[len(N)][0][7])
print(dp[len(N), :, 7].sum())


Measured memory_bytes: 12496
#include <stdio.h>
int main(void){
  int a,op,b;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?')
      break;
    else if(op=='+')
      printf("%d\n",a+b);
    else if(op=='-')
      printf("%d\n",a-b);
    else if(op=='*')
      printf("%d\n",a*b);
    else
      printf("%d\n",a/b);
  }
  return 0;
}

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

int N;
int M;
int x[100005];
int y[100005];
pair<int, char> boxes[100005];
int counter=0;

int main()
{
    cin>>N>>M;
    
    for (int i=1; i<=M; i++)
    {
        cin>>x[i]>>y[i];
    }

    for (int i=1; i<=N; i++)
    {
        boxes[i].first=1;
        boxes[i].second='W';
    }

    boxes[1].second='R';



    for (int i=1; i<=M; i++)
    {
        boxes[x[i]].first--;
        boxes[y[i]].first++;
        if (boxes[x[i]].second=='R')
        {
            boxes[y[i]].second='R';
        }

        if (boxes[x[i]].first==0)
        {
            boxes[x[i]].second='W';
        }
    }   

    for (int i=1; i<=N; i++)
    {
        if (boxes[i].first>=1 && boxes[i].second=='R')
        {
            counter++;
        }
    }

    cout<<counter<<endl;
}

Measured memory_bytes: 5060
#include <stdio.h>

int main(){

 char X[3];

    scanf("%s",&X);

    if(X[0]=='7'){


        printf("Yes\n");

    }
    
    else if(X[1]=='7'){


        printf("Yes\n");

    }
    else if(X[2]=='7'){


        printf("Yes\n");

    }
    
    else{

       printf("No\n");

    }



return 0;

}



Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;} 


int main(){
  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << v[k-1] << endl;
}



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

int main(){
    int n, m;
    bool ans = false;
    cin >> n >> m;
    vector<int> aa;
    vector<int> nn;
    for(int i = 0 ; i < m ; i++){
        int a, b;
        cin >> a >> b;
        if(a == 1){
            aa.push_back(b);
        }
        if(b == n){
            nn.push_back(a);
        }
    }
    sort(nn.begin(), nn.end());
    int j = 0;
    while(j < aa.size() && !ans){
        int left = 0, right = nn.size(), mid;
        while(left < right){
            mid = (left + right) / 2;
            if(aa[j] == nn[mid]){
                ans = true;
                break;
            }else if(aa[j] < nn[mid]){
                right = mid;
            }else{
                left = mid + 1;
            }
        }
        j++;
    }
    if(ans){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
    	int a,b;
      cin>>a>>b;
      int ans = 0;
      if(a>=13) ans = b;
      else if(a>=6) ans = b/2;
      else ans = 0;
      cout<<ans<<endl;
      return 0;
    }

Measured memory_bytes: 256
s = gets.chomp
l = s.length
q = gets.to_i
for i in 1..q
  t = gets.split
  a = t[1].to_i
  b = t[2].to_i
  case t[0]
  when "replace"
    p = t[3]
    s = s[0,a] + p + s[b+1,l-b-1]
  when "reverse"
    u = s[a, b-a+1].reverse
    s = s[0,a] + u + s[b+1,l-b-1]
  when "print"
    puts s[a,b-a+1]
  end
end

Measured memory_bytes: 6256
#include<bits/stdc++.h>
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    int a=0,b=0,c=0;
    for(int i=0;i<3; i++)
    {
        if(s[i]=='a')
            a++;
        else if(s[i]=='b')
            b++;
        else
            c++;
    }
    if(a!=0&&b!=0&&c!=0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int n; scanf("%d", &n);
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
  }
  vector<int> ans;
  if (n % 2 == 1) {
    for (int i = n - 1; i >= 0; i -= 2) {
      ans.push_back(A[i]);
    }
    for (int i = 1; i < n; i += 2) {
      ans.push_back(A[i]);
    }
  }
  else {
    for (int i = n - 1; i > 0; i -=2) {
      ans.push_back(A[i]);
    }
    for (int i = 0; i < n; i += 2) {
      ans.push_back(A[i]);
    }
  }
  printf("%d", ans[0]);
  for (int i = 1; i < n; ++i) {
    printf(" %d", ans[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 3828
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut m = 0;
    let mut x = a[0];
    for &a in a.iter() {
        x = gcd(x, a);
        m = max(m, a);
    }

    if x != 1 {
        println!("not coprime");
        return;
    }

    let mut exist = vec![false; m + 1];
    for &a in a.iter() {
        if exist[a] && a != 1 {
            println!("setwise coprime");
            return;
        }
        exist[a] = true;
    }

    let mut yet = vec![true; m + 1];
    for i in 2..=m {
        if !yet[i] {
            continue;
        }
        let mut count = 0;
        for j in 1..=m / i {
            yet[i * j] = false;
            if exist[i * j] {
                count += 1;
                if count == 2 {
                    println!("setwise coprime");
                    return;
                }
            }
        }
    }
    println!("pairwise coprime");
}


Measured memory_bytes: 18416
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110000],s[110000];
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
    ll n,k;
    cin>>n;
    string s=to_string(n);
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')cout<<"Yes";
    else cout<<"No";
    
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
string str,s1="dream",s2="dreamer",s3="erase",s4="eraser";
bool flag=false;
void solve(int cnt);

int main(){
    cin >> str;
    solve(0);
    if(flag==false)cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

void solve(int cnt){

    if(cnt>=str.size()){
            flag=true;
            return ;
    }else {
        int ff=0;
        while(ff<s1.size()){
            if(s1[ff]==str[ff+cnt]);
            else break;
            ff++;
            }
            if(ff==s1.size())solve(cnt+s1.size());
        ff=0;
        while(ff<s2.size()){
            if(s2[ff]==str[ff+cnt]);
            else break;
            ff++;
            }
            if(ff==s2.size())solve(cnt+s2.size());
        ff=0;
        while(ff<s3.size()){
            if(s3[ff]==str[ff+cnt]);
            else break;
            ff++;
            }
            if(ff==s3.size())solve(cnt+s3.size());
        ff=0;
        while(ff<s4.size()){
            if(s4[ff]==str[ff+cnt]);
            else break;
            ff++;
            }
            if(ff==s4.size())solve(cnt+s4.size());
        ff=0;
        }
}


Measured memory_bytes: 1152
/**
 *  author: mahfuzz
 *  created: 01.05.2020
**/
 
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
 
int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    ll n, x; cin >> n >> x;
    
    cout << min(n, min(n % x, abs(x - (n % x)))) << "\n";
    
    
    return 0;
} 


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

int
main()
{
    std::ios::sync_with_stdio(false);
    std::array<std::string, 4> verdicts{ "AC", "WA", "TLE", "RE" };
    std::vector<int> counts(4, 0);

    std::size_t verdictCount;
    std::cin >> verdictCount;
    for (std::size_t i = 0; i<verdictCount; ++i)
    {
        std::string verdict;
        std::cin >> verdict;
        for (std::size_t vi = 0; vi<verdicts.size(); ++vi)
        {
            if (verdict==verdicts[vi])
            {
                ++counts[vi];
                break;
            }
        }
    }

    for (std::size_t i = 0; i<verdicts.size(); ++i)
    {
        std::cout << verdicts[i] << " x " << counts[i] << "\n";
    }
    return 0;
}


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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e9)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

void solve(int &test) {
    int n;
    cin >> n;
    int a[n];
    int tot = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        tot ^= a[i];
    }
    for(int i = 0; i < n; i++){
        cout << (tot^a[i]) << " ";
    }cout << endl;

}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;

    start = clock(); 

    cout << fixed << setprecision(20);
    
    
    // cin >> t;
     
    for(int i = 1; i <= t; ++i){
        solve(i);
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 5092
import math
Q = int(input())

li = [0]
cnt = 0
for i in range(3, 10**5+1, 2):
  flag = True
  for j in range(2, int(math.sqrt(i))+1):
    if i % j == 0:
      flag = False
  if flag:
    for j in range(2, int(math.sqrt((i+1)//2)+1)):
      if ((i+1)//2) % j == 0:
        flag = False
  if flag:
    cnt += 1
  li.append(cnt)
  
for i in range(Q):
  l, r = map(int, input().split())
  if l == 1:
    ans = li[r//2]
  else:
    ans = li[r//2] - li[l//2-1]
  print(ans)


Measured memory_bytes: 72284
#include<iostream>
using namespace std;
int main()
{
	int n, m, o, k, A[101][101] = {};
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> o >> k;
		o--;
		for (int j = 0; j < k; j++)
		{
			cin >> m;
			m--;
			A[o][m] = 1;
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (j)cout << " ";
			cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

string s,t;

int main(){
    cin >> s >> t;
    int ans = 0;
    for(int i=0 ; i<3 ; ++i)
        if(s[i] == t[i])ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
  string s;
  cin>>s;
  int result = 0;
  char prev = s[0];
  for(int i = 1; i < s.size(); i ++) {
    if(prev != s[i]) {
      result ++;
      prev = s[i];
    }
  }
  cout<<result<<endl;
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			int n = s.Length;
			string key = "keyence";
			int m = n - 7;

			string left = s.Substring(0, 7);
			if (left == key) {
				Console.WriteLine("YES");
				return;
			}

			string right = s.Substring(n - 7, 7);
			if (right == key) {
				Console.WriteLine("YES");
				return;
			}

			if (m > 0) {
				for (int i = 0; i < 7; i++) {
					string left2 = s.Substring(0, i + 1);
					string right2 = s.Substring(n - 7 + i + 1, n - m - i - 1);
					if (left2 + right2 == key) {
						Console.WriteLine("YES");
						return;
					}
				}
			}

			Console.WriteLine("NO");
		}
	}
}

Measured memory_bytes: 11092
while true
  e = gets.to_i
  break if e==0

  m = e
  for z in 0..100
    z3 = z**3
    next if z3>e
    for y in 0..1000
      x = e - z3 - y**2
      next if x < 0
      m = x+y+z if m > x+y+z
    end
  end
  puts m
end

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    vl v(n),c(n);
    rep(i,n)cin>>v[i];
    rep(i,n)cin>>c[i];
    ll res = 0;
    rep(i,n){
        if(v[i] > c[i])res+=v[i]-c[i];
    }
    out(res);
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int solve(int n) 
{
    int cnt = 0;
    for(int x = 1; x*x <= n; x++) {
        for(int y = 1; y*y <= n; y++) {
                int a = 1;
                int b = x+y;
                int c = x*x+y*y+x*y-n;
                int d = b*b-4*a*c;
                if(d<0) { continue; }
                double d2 = sqrt(d);
                int d3 = sqrt(d);
                if(fabs(d2*d2 - d3*d3) < 1e-10) { 
                    int z = (-b+sqrt(d))/2;
                    if(z>=1) { 
                        cnt++; 
                        //printf("%d,%d,%d,%d\n",x,y,z,d);
                    }
                }
        }
    }
    return cnt;
}

int main(void)
{
    int n;
    cin >> n;
    
    irep2(i,1,n) {
        cout << solve(i) << endl;
    }
    
    return 0;
}
/*atcoder*/


Measured memory_bytes: 3524
#include <stdio.h>
 
int main(void) {
  
  int i,n;
  int A[100];
  scanf("%d",&n);
  for(i=0; i<n; i++){
      scanf("%d",&A[i]);
  }
  
  for(i=n-1; i >=0; i--){
      if(i !=n-1) printf(" %d",A[i]);
      else printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2068
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <chrono>
#include <numeric>

using namespace std;
using namespace std::chrono;

typedef long long int lo;
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 
    
int main() {
    fast
    lo n;
    cin >> n;
    printf("%f\n", n * 3.1415926 * 2);
    return 0;
}

Measured memory_bytes: 3824
a,b=map(int,input().split())
if a>0 and b>0:
    print('Positive')
elif a==0 or b==0:
    print('Zero')
else:
    if a<0 and b>0:
        print('Zero')
    elif a<0 and b<0:
        if (a-b)%2==0:
            print('Negative')
        else:
            print('Positive')

Measured memory_bytes: 9088
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N = int(input())
As = list(map(int, input().split()))

four = 0
two = 0
other = 0
for a in As:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 0:
        two += 1
    else:
        other += 1

prev = 4

def use_other():
    global other, prev
    other -= 1
    prev = 0

def use_two():
    global two, prev
    two -= 1
    prev = 2

def use_four():
    global four, prev
    four -= 1
    prev = 4

def func():
    if prev == 4:
        if other > 0:
            use_other()
        elif two > 0:
            use_two()
        elif four > 0:
            use_four()
    elif prev == 2:
        if two > 0:
            use_two()
        elif four > 0:
            use_four()
        else:
            return False
    elif prev == 0:
        if four > 0:
            use_four()
        else:
            return False
    return True

ok = True
for n in range(N):
    ret = func()
    if not ret:
        ok = False
        break
if ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 16356
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 234567;
int a[MAXN], tmpa[MAXN];
vector<int> b[29];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        for (int j = 0; j <= 28; j++) {
            b[j].push_back(tmp % (1 << (j + 1)));
        }
    }
    for (int j = 0; j <= 28; j++)
        sort(b[j].begin(), b[j].end());
    int sum = 0;
    for (int j = 0; j <= 28; j++) {
        int lw1 = 0, up1 = 0, lw2 = 0;
        int K = (1 << j);
        for (int i = 0; i < N; i++) tmpa[i] = a[i] % (2 * K);
        sort(tmpa, tmpa + N);
        int cnt = 0;
        for (int i = N - 1; i >= 0; i--) {
            while (lw1 < N && tmpa[i] + b[j][lw1] < K) lw1++;
            while (up1 < N && tmpa[i] + b[j][up1] < 2 * K) up1++;
            while (lw2 < N && tmpa[i] + b[j][lw2] < 3 * K) lw2++;
            cnt += N - lw2 + up1 - lw1;
            cnt %= 2;
        }
        if (cnt) sum += (1 << j);
    }
    printf("%d\n", sum);
    return 0;
}


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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int a;
    cin >> a;
    int t = 0;
    int i = 1;
    while(true) {
        t += i;
        if(t>=a) break;
        i++;
    }
    P(i);
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  int V[N], C[N];
  int value = 0;
  int total = 0;
  for(int i = 0; i < N; i++){
    cin >> V[i];
  }
  for(int i = 0; i < N; i++){
    cin >> C[i];
  }
  for(int i = 0; i < N; i++){
    value = V[i] - C[i];
    if(value > 0){ 
      total += value;
    }
  }
  cout << total << endl;
}
      

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	int n, k;
	while (cin >> n >> k, n) {
		vector<int> v(k);
		rep(i, k) {
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		if (v[0] > 0) {
			int ans = 0;
			rep(i, k) {
				int le = i;
				while (i + 1 < k&&v[i + 1] - v[i] == 1) {
					i++;
				}
				ans = max(ans, i - le + 1);
			}
			cout << ans << endl;
		}
		else {
			int ans = 0;
			vector<P> vl;
			vector<int> u;
			rep1(i, k - 1) {
				int le = i;
				while (i + 1 < k&&v[i + 1] - v[i] == 1) {
					i++;
				}
				vl.push_back({ le,i });
				ans = max(ans, i - le + 1);
				u.push_back(i - le + 1);
			}
			rep(i, vl.size() - 1) {
				int le = v[vl[i].second];
				int ri = v[vl[i + 1].first];
				if (ri - le == 2) {
					ans = max(ans, u[i] + u[i + 1] + 1);
				}
			}
			cout << ans << endl;
		}
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(7);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3568
from heapq import heappop, heappush

n, m = map(int, input().split())
graph = [list() for _ in range(n)]

for i in range(1, n):
    graph[i].append((i-1, 0))

for _ in range(m):
    f, t, c = map(int, input().split())
    f -= 1; t -= 1
    graph[f].append((t, c))

INF = float("inf")
s = 0
d = [0] + [INF] * (n-1)
q = []
heappush(q, (0, s))

while q:
    dist, v = heappop(q)
    if d[v] < dist: continue
    for nv, cost in graph[v]:
        if d[nv] > d[v] + cost:
            d[nv] = d[v] + cost
            heappush(q, (d[nv], nv))

print(-1 if d[n-1] == INF else d[n-1])


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll p[n] = {};
    ll cnt[3] = {};
    rep(i,0,n){
        cin >> p[i];
        if(p[i] <= a) cnt[0]++;
        else if(p[i] <= b) cnt[1]++;
        else cnt[2]++;
    }

    cout << min(cnt[0],min(cnt[1],cnt[2])) << endl;
    return 0;
}


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

int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  int x=60*a+b;
  int y=60*c+d;
  cout << y-x-e << endl;

}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,W;
ll dp[100010];
int main(){
	scanf("%lld%lld",&n,&W);
	rep(i,0,n){
		ll w,v;
		scanf("%lld%lld",&w,&v);
		for(int j=W-w;j>=0;j--)dp[j+w]=max(dp[j+w],dp[j]+v);
	}
	ll ans=0;
	rep(i,0,W+1)ans=max(ans,dp[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
N,A,B,K=map(int,input().split())
r=0
m=998244353
max_n=3*10**5
fac=[1]*(max_n+1)
inv=[1]*(max_n+1)
ifac=[1]*(max_n+1)
for n in range(2,max_n+1):
    fac[n]=(fac[n-1]*n)%m
    inv[n]=m-inv[m%n]*(m//n)%m
    ifac[n]=(ifac[n-1]*inv[n])%m
def comb(n,k):
    if n<k or n<0 or k<0:
        return 0
    return (fac[n]*ifac[k]*ifac[n-k])%m
for a in range(N+1):
    Bb=K-A*a
    if Bb>=0 and Bb%B==0:
        b=Bb//B
        if b<=N:
            r=(r+comb(N,a)*comb(N,b))%m
print(r)

Measured memory_bytes: 38644
import java.util.Scanner;

public class Main {

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

//入力変数
int N = sc.nextInt();
int a[] = new int[N];
for(int i = 0;i<N;i++){
a[i]=sc.nextInt();
}

//入力値変換
boolean order = false;
int tempofa = 0;
int change =0;
for(;order == false;){
change = 0;
for(int i = 0;i<N-1;i++){
if(a[i]<a[i+1]){
tempofa=a[i];
a[i] = a[i+1];
a[i+1]=tempofa;
change++;
}}
if(change == 0){
order = true;
}}


//出力変数
int ans=0;

//計算
for(int i = 0;i<N;i++){
ans += Math.pow(-1,i)*a[i];
}

//出力
System.out.println(ans);

}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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 n;cin>>n;
	string s;cin>>s;
	vector<ll> ans(n),ins(n);

	ll dx[4]={1,1,-1,-1};
	ll dy[4]={1,-1,1,-1};//最初の二匹がどちらの動物か

	bool can=false;
	rep(i,4){
		ans[0]=dx[i];
		ans[1]=dy[i];

		for(ll j=1;j<n-1;j++){
			if(s[j]=='o' && ans[j]==1 || s[j]=='x' && ans[j]==-1){//羊がoといっている または　オオカミがxといっている　なら
				ans[j+1]=1*ans[j-1];//jに隣り合うのは同じ動物
			}else if(s[j]=='o' && ans[j]==-1 || s[j]=='x' && ans[j]==1){//オオカミがoといっている または　羊がxといっている　なら
				ans[j+1]=-1*ans[j-1];//jに隣り合うのは違う動物
			}
		}

		if(((s[0]=='o' && (ans[0]==1 && ans[1]==ans[n-1] || ans[0]==-1 && ans[1]!=ans[n-1]))//s[0]がoのとき
		||  (s[0]=='x' && (ans[0]==1 && ans[1]!=ans[n-1] || ans[0]==-1 && ans[1]==ans[n-1])))//s[0]が×のとき
		&& ((s[n-1]=='o' && (ans[n-1]==1 && ans[0]==ans[n-2] || ans[n-1]==-1 && ans[0]!=ans[n-2]))//s[n-1]がoのとき
		||  (s[n-1]=='x' && (ans[n-1]==1 && ans[0]!=ans[n-2] || ans[n-1]==-1 && ans[0]==ans[n-2])))//s[n-1]がxのとき
		){//0番とn-1番の証言が一致するか
			can=true;
			break;
		}
	}

	if(can){
		rep(i,n){
			if(ans[i]==1){
				cout<<'S';
			}else{
				cout<<'W';
			}
		}
		cout<<endl;
	}else{
		cout<<-1<<endl;
	}

	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;



int main() {
	int h, w;
	char s[50][50];
	bool flag = true;
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> s[i][j];
		}
	}
	if (s[0][0] == '#' && (s[0][1] == '.' && s[1][0] == '.')) flag = false;
	if (s[0][w - 1] == '#' && (s[0][w - 2] == '.' && s[1][w - 1] == '.')) flag = false;
	if (s[h - 1][0] == '#' && (s[h - 1][1] == '.' && s[h - 2][0] == '.')) flag = false;
	if (s[h - 1][w - 1] == '#' && (s[h - 1][w - 2] == '.' && s[h - 2][w - 1] == '.')) flag = false;

	for (int i = 1; i < h-1; ++i) {
		if (s[i][0] == '#' && s[i][1] == '.' && s[i - 1][0] == '.' && s[i + 1][0] == '.') flag = false;
	}
	for (int i = 1; i < h - 1; ++i) {
		if (s[i][w-1] == '#' && s[i][w-2] == '.' && s[i - 1][w-1] == '.' && s[i + 1][w-1] == '.') flag = false;
	}

	for (int i = 1; i < w - 1; ++i) {
		if (s[0][i] == '#' && s[1][i] == '.' && s[0][i-1] == '.' && s[0][i+1] == '.') flag = false;
	}
	for (int i = 1; i < w - 1; ++i) {
		if (s[h-1][i] == '#' && s[h-2][i] == '.' && s[h-1][i-1] == '.' && s[h - 1][i+1] == '.') flag = false;
	}


	for (int i = 1; i < h-1; ++i) {
		for (int j = 1; j < w-1; ++j) {
			if (s[i][j] == '#' && s[i-1][j] == '.' && s[i+1][j] == '.' && s[i][j + 1] == '.'&& s[i][j - 1] == '.') flag = false;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define rep(i,n)    FOR(i,0,n)
#define rep_one(i,n)    FOR(i,1,n+1)
#define rrep(i,n)   for(int i=n-1;i<=0;--i)
#define loop        while(true)
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define sd(n) scanf("%lf", &n)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const ll MAX = 10000000;
const ll MIN = 0;
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; }
using pl = pair<ll, ll>;
using ps = pair<int, string>;

int main() {
    ll N; sl(N);
    ll ans = 0;

    rep_one(i,N) {
        ll c = N/i;
        ans += c*i*(c+1)/2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3732