akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int[] A = new int[5];
    int s,o,k,flag;

    for(s = 0;s < 5;s++){
      A[s] = sc.nextInt();
    }
    k = sc.nextInt();
    flag = 0;

    for(s = 0;s < 4;s++){
      for(o = s+1;o < 5;o++){
        if(k < sum(A[s],A[o])){
          flag = 1;
          break;
        }
      }
      if(flag == 1){
        break;
      }
    }

    if(flag == 0)
      System.out.println("Yay!");
    else
      System.out.println(":(");

  }

  public static int sum(int a,int b){
    if(a > b)
      return a-b;
    else
      return b-a;
  }

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

map<ll,ll> mp;
ll n,a,b,c,d;

ll f(ll x){
 if(mp.count(x)) return mp[x]; 
 ll res=(inf/x>d?x*d:inf);

 rep(k,-4,5){ 
  ll y=x+k;
  if(y%2==0&&abs(k)<2&&y/2<n&&y>=0) chmin(res,f(y/2)+a+d*abs(k));
  if(y%3==0&&abs(k)<3&&y/3<n&&y>=0) chmin(res,f(y/3)+b+d*abs(k));
  if(y%5==0&&abs(k)<5&&y/5<n&&y>=0) chmin(res,f(y/5)+c+d*abs(k)); 
 }
 mp[x]=res;
 return res;
}

void solve(){
  ll t;
  cin >> t;
  while(t--){
    cin >> n >> a >> b >> c >> d;
    mp.clear();
    mp[0]=0;
    mp[1]=d;
    cout << f(n) << endl;
  }
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  


Measured memory_bytes: 4396
#!/usr/bin/python3
# abc060_b
"""
Choose Integers
"""

test = False


def answer():
    """
    Aの倍数の中に条件を満たすものがあるか調べる。
    """
    A, B, C = map(int, input().split())

    for i in range(1, A*B+1):
        if (A * i) % B == C:
            if test:
                print(A * i)
            return 'YES'
    return 'NO'


def main():
    """
    main関数
    """
    print(answer())


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	char alpha;
	std::cin >> alpha;
	std::cout << (('A'<=alpha && alpha<='Z')?"A":"a") << std::endl;
	return 0;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long H = scn.nextLong();
		long W = scn.nextLong();
		long m = H * W;
		if (H == 1 || W == 1) {
			System.out.println(1);
		} else {
			if (m % 2 == 0) {
				System.out.println((m / 2));
			} else {
				System.out.println((m / 2) + 1);
			}
		}
	}
}

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

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

using namespace std;
using lint=long long;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	vector<int> sum(n+1);
	do{
		rep(i,n+1) sum[i]=0;
		rep(i,n){
			sum[max(i-a[i],0)]++;
			sum[min(i+a[i]+1,n)]--;
		}
		rep(i,n) sum[i+1]+=sum[i];
		rep(i,n) a[i]=sum[i];

		k--;
	}while(k>0 && count(a.begin(),a.end(),n)<n);

	rep(i,n) printf("%d%c",a[i],i<n-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 4856
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
from collections import defaultdict
#すべてのkeyが用意されてる defaultdict(int)で初期化
from collections import OrderedDict
#順序を保ったdict
from math import ceil
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import Decimal #floatの高精度ver, 渡すのはstr型で
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
n,m=map(int,input().split())
A=100*(n-m)+1900*m
p=pow(2,m)

@lru_cache(maxsize=10**10)
def per(n):
    if n==1:
        return 1/p
    return (1-sum([per(i) for i in range(1,n)]))*(1/p)

ans=0
for i in range(1,2000):
    ans+= i*A*per(i)
print(round(ans))


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

signed main(){

  int N,W;
  cin>>N>>W;
  vector<int> v(N),w(N);
  for(int i=0;i<N;++i)cin>>v[i]>>w[i];

  constexpr int inf = 1<<28;
  auto chmax = [](auto& a,auto b){if(a<b)a=b;};
  // dp[i][j] := i番目 重さj 価値の最大
  vector<vector<int>> dp(N+1,vector<int>(1e5));
  for(int i=0;i<N;++i){
    for(int j=1;j<=W;++j){
      chmax(dp[i+1][j],dp[i][j]);
      chmax(dp[i+1][j],dp[i+1][j-1]);
      if(j>=w[i]){
        chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
        chmax(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
      }
    }
  }
  cout<<(dp[N][W])<<endl;


}


Measured memory_bytes: 42748
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    string s, t; cin >> s >> t;
    bool ret = true;
    FOR(i, 0, s.size()) {
        if (s[i] == t[i]) continue;
        else { ret = false;}
    }
    if (ret) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

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

int main() {
	int N, M, B;
	cin >> N >> M;
	vector<int> A(M), ans(N);
	for (int& i : A) cin >> i;
	for (int i = 0; i < M; ++i) {
		int a = 0;
		for (int j = 0; j < N; ++j) {
			cin >> B;
			if (A[i] == B) ++ans[j];
			else ++a;
		}
		ans[A[i] - 1] += a;
	}
	for (int& i : ans) cout << i << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[3005];
   long long s=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       s=s+a[i];
   }
   cout<<s-n<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define ll long long
const int inf = 1e8;
const ll INF = 1e18;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-9;
const long double pi = acos(-1.0);
using namespace std;

int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1 -1};


void solve() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length() - 1; i++){
        if (s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return;
        }
        if (i + 2 <= s.length() - 1){
            if (s[i] == s[i + 2]){
                cout << i + 1 << " " << i + 3 << endl;
                return;
            }
        }
    }

    cout << - 1 << " " << - 1 << endl;
    return;
}



int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(40);
    //freopen("inevit.in", "r", stdin);
    //freopen("inevit.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++)
        solve();


}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {    

int a ,b ,c ,d;    

scanf("%d %d %d\n" ,&a ,&b ,&c);    

if(a>b){      

d = b;   

b = a;   

a = d;     

}    

if(a>c){      

d = c;   

c = a;   

a = d;     

}    

if(b>c){      

d = c;   

c = b;   

b = d;     

}    

printf("%d %d %d\n" ,a ,b ,c);    

return 0;  

}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#define INF 100000000
using namespace std;

int main(){
  int w,n;
  while(cin >> w >> n){
    int amida[31][31][31];
    for(int i=0; i<31; i++)
    for(int j=0; j<31; j++)
    for(int k=0; k<31; k++)
      amida[i][j][k] = 0;

    for(int i = 1 ; i <= n ; i++ ){
      int a,b;
      char ch;
      cin >> a >>ch>> b;
      amida[i][a][b]=amida[i][b][a]=1;
    }

    int from;
    for(int i = 1; i <= w ; i++ ){
      from = i;
      for(int depth = w ; depth >= 1 ; depth-- ){

	for(int to = 1 ; to <= w ; to++ ){
	  if(amida[depth][from][to] == 1){
	    from = to;
	    break;
	  }
	}

      }
      cout << from << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 1276
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, k, a[N], dp[101][N];

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   if (a < 0) a += mod;
   return a;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> k;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   dp[0][0] = 1;
   for (int i = 1; i <= n; i ++) {
      for (int used = 0; used <= k; used ++) {
         int l = used, r = used + a[i];
         if (r > k) r = k;
         dp[i][l] = add (dp[i][l], dp[i - 1][used]);
         dp[i][r + 1] = add (dp[i][r + 1], -dp[i - 1][used]);
      }
      for (int j = 1; j <= k; j ++)
         dp[i][j] = add (dp[i][j], dp[i][j - 1]);
   }
   cout << dp[n][k];
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

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

#define SZ(x) (int)(x).size()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i, a, b) for (int i=a;i>=b;--i)

const int MX_N = 2e5+5;

int N, A[MX_N], B[MX_N];
queue<int> q;

inline int prv(int i) { return i == 1 ? N : i-1; }
inline int nxt(int i) { return i == N ? 1 : i+1; }
inline bool bad(int i) { return B[i] - (B[prv(i)] + B[nxt(i)]) >= A[i]; }

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

    cin >> N;
    FOR(i,1,N){
        cin >> A[i];
    }
    FOR(i,1,N){
        cin >> B[i];
    }
    FOR(i,1,N){
        if (bad(i)) q.push(i);
    }
    long long op = 0;
    while (!q.empty()) {
        int i = q.front(); q.pop();
        int x = prv(i), y = nxt(i);
        int cur = (B[i]-A[i])/(B[x]+B[y]);
        op += cur;
        B[i] -= cur*(B[x]+B[y]);
        if (bad(x)) q.push(x);
        if (bad(y)) q.push(y);
    }

    bool good = 1;
    FOR(i,1,N) if (A[i] != B[i]) { good = 0; break; }
    if (good) cout << op;
    else cout << -1;
}



Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

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

    vector<ll> A(N);
    for (auto& a : A) { cin >> a; }

    sort(A.begin(), A.end());

    {
        ll M = A[A.size() - 1] - A[0];

        ll index = 1;
        while (index < N - 1 && A[index] <= 0) { M -= A[index]; ++index; }
        while (index < N - 1) { M += A[index]; ++index; }

        cout << M << endl;
    }

    {
        ll M = A[A.size() - 1];

        ll index = 1;

        while (index < N - 1 && A[index] <= 0)
        {
            cout << M << " " << A[index] << endl;
            M -= A[index];
            ++index;
        }

        ll t = A[0];

        while (index < N - 1)
        {
            cout << t << " " << A[index] << endl;
            t -= A[index];
            ++index;
        }

        cout << M << " " << t << endl;
        M -= t;
    }

    return 0;
}


Measured memory_bytes: 2688
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 998244353
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

ll pw10[maxn+5],L[maxn+5];
struct segtree
{
    #define ls i*2
    #define rs i*2+1
    ll a[maxn*4+5],lz[maxn*4+5];
    void push(int i,int l,int r,int x)
    {
        a[i]=L[r-l+1]*x%mod;
        lz[i]=x;
    }
    void pu(int i,int l,int r) 
    {   
        int mid=(l+r)>>1;
        a[i]=(a[ls]*pw10[r-mid]+a[rs])%mod;
    }
    void pd(int i,int l,int r)
    {
        if(lz[i]!=-1)
        {
            int mid=(l+r)>>1;
            push(ls,l,mid,lz[i]);
            push(rs,mid+1,r,lz[i]);
            lz[i]=-1;
        }
    }
    void build(int i,int l,int r)
    {
        lz[i]=-1;
        if(l==r) a[i]=1;
        else
        {
            int mid=(l+r)>>1;
            build(ls,l,mid);
            build(rs,mid+1,r);
            pu(i,l,r);
        }
    }
    void chg(int i,int l,int r,int ql,int qr,int x)
    {
        if(ql<=l && r<=qr) 
        {
            push(i,l,r,x);
            return;
        }
        if(qr<l || r<ql) return;
        pd(i,l,r);
        int mid=(l+r)>>1;
        chg(ls,l,mid,ql,qr,x);
        chg(rs,mid+1,r,ql,qr,x);
        pu(i,l,r);
    }
}T;

int a[maxn+5];

int main()
{
    pw10[0]=1;
    rep(i,1,maxn) pw10[i]=pw10[i-1]*10%mod;
    rep(i,1,maxn) L[i]=(L[i-1]*10+1)%mod;
    int n,q; scanf("%d%d",&n,&q);
    T.build(1,1,n);
    while(q--)
    {
        int l,r,x; scanf("%d%d%d",&l,&r,&x);
        T.chg(1,1,n,l,r,x);
        printf("%lld\n",T.a[1]);
    }
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    char X = 'A';
    int ans = -1;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] != X){
            X = S[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int S = cin.nextInt();
		int s = S%60;
		int m = (S/60)%60;
		int h = (S/60)/60;
		System.out.println(h + ":" + m + ":" + s);
	}
}


Measured memory_bytes: 26232
def area(p,q):return p[0]*q[1]-p[1]*q[0]
 
n=int(input())
point=[]
x_1,y_1=[int(i) for i in input().split(" ")]
 
for _ in range(n-1):
    x,y=[int(i) for i in input().split(" ")]
    point.append([x-x_1,y-y_1])
a=0
for i in range(n-2):a+=area(point[i],point[i+1])
print(a*0.5)

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

int main() {
  int s1, s2, s3, ans, num;

  cin >> num;
  s1 = num / 100;
  s2 = (num / 10) % 10;
  s3 = num % 10;
  ans = s1 + s2 + s3;

  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
n, k = map(int, input().split())
dic = defaultdict(int)
for _ in range(n):
  a, b = map(int, input().split())
  dic[a] += b
cnt = 0
for key in sorted(dic):
  if cnt + dic[key] < k:
    cnt += dic[key]
  else:
    print(key)
    break

Measured memory_bytes: 10844
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 + y1 - y2
y3 = y2 - x1 + x2
x4 = x3 + y2 - y3
y4 = y3 - x2 + x3
print(' '.join( map(str, [x3, y3, x4, y4]) ))

Measured memory_bytes: 2940
#include<iostream>
#include <unordered_map>

using namespace std;

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

    unordered_map<char, long long> charMap;
    for (int i = 0; i < N; ++i)
    {
        string s;
        cin >> s;
        char c = s[0];
        switch (c)
        {
            case 'M':
            case 'A':
            case 'R':
            case 'C':
            case 'H':
                if (charMap.find(c) != charMap.end())
                {
                    charMap[c]++;
                }
                else
                {
                    charMap[c] = 1;
                }
                break;
            default:
                break;
        }
    }

    long long result = 0;
    string target = "MARCH";
    for (int i = 0; i < target.size(); ++i)
    {
        if (charMap.find(target[i]) == charMap.end()) continue;
        for (int j = i + 1; j < target.size(); ++j)
        {
            if (charMap.find(target[j]) == charMap.end()) continue;
            for (int k = j + 1; k < target.size(); ++k)
            {
                if (charMap.find(target[k]) == charMap.end()) continue;
                result += charMap[target[i]] * charMap[target[j]] * charMap[target[k]];
            }
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import Control.Monad (replicateM_)
import Numeric (readFloat,readSigned)

type Point = (Rational, Rational)
type Vector = (Rational, Rational)

main = do
    n <- readLn
    replicateM_ n (input >>= return . solve >>= output)

input :: IO (Point,Point,Point,Point)
input = do
    line <- getLine
    let
        [x1,y1,x2,y2,x3,y3,x4,y4] = map (fst.head.(readSigned readFloat)) $ words line
    return ((x1,y1),(x2,y2),(x3,y3),(x4,y4))

output :: Bool -> IO ()
output r = putStrLn (if r then "YES" else "NO")

solve :: (Point,Point,Point,Point) -> Bool
solve (p1,p2,p3,p4) = isParallel (vector p1 p2) (vector p3 p4)

vector :: Point -> Point -> Vector
vector o p = (px-ox, py-oy)
    where
    (ox,oy) = o
    (px,py) = p

isParallel :: Vector -> Vector -> Bool
isParallel a b = ab * ab == aa * bb
    where
    aa = ax * ax + ay * ay
    bb = bx * bx + by * by
    ab = ax * bx + ay * by
    (ax,ay) = a
    (bx,by) = b

Measured memory_bytes: 4440
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        StringBuilder debug = new StringBuilder();
        Scanner sc = new Scanner(System.in);
        int period = sc.nextInt();//D
        debug.append(period+"\n");

        int[] cost = new int[26];//c
        for (int i = 0;i<cost.length;++i)
        {
            cost[i] = sc.nextInt();
            debug.append(cost[i]+" ");
        }
        debug.append("\n");

        int[][] score = new int[period][26];//s
        for (int i = 0;i<score.length;++i)
        {
            for (int j = 0;j<score[i].length;++j)
            {
                score[i][j] = sc.nextInt();
                debug.append(score[i][j]+" ");
            }
            debug.append("\n");
        }

        //System.err.println(debug.toString());

        Map<Integer,Integer> lastDay = new HashMap<>();//contestType,lastDay
        for (int type = 0;type < 26;++type) lastDay.put(type,0);

        long satisfaction = 0L;
        for (int date = 0;date < period;++date)
        {
            //select
            long maxSatisfaction = Long.MIN_VALUE;
            int bestContestType = -1;
            long minus = 0L;
            for (int type = 0;type < 26;++type)
            {
                long tmp = satisfaction + score[date][type];
                long tmp2 = 0L;
                for (int type2 = 0;type2 < 26;++type2)
                {
                    tmp2 += cost[type2] * ((date+1) - lastDay.get(type2));
                }
                tmp -= tmp2;

                if (maxSatisfaction < tmp)
                {
                    maxSatisfaction = tmp;
                    bestContestType = type;
                    minus = tmp2;
                }
            }
            //calc
            satisfaction += maxSatisfaction;
            lastDay.put(bestContestType,(date+1));
            satisfaction -= minus;

            //output
            System.out.println(bestContestType+1);
        }
        sc.close();
    }
}

Measured memory_bytes: 50136
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

ll x[55], y[55];

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

	rep(i, n) cin >> x[i] >> y[i];

	int cmax = 0;
	rep(j, n) rep(i, j){
		const ll p = x[j] - x[i];
		const ll q = y[j] - y[i];

		int cnt = 0;
		rep(b, n) rep(a, n){
			if(x[a] + p == x[b] and y[a] + q == y[b]){
				cnt++;
			}
		}
		chmax(cmax, cnt);
	}

	cout << n - cmax << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
  int n;
  string s;
  vector<vector<int>> a(3,vector<int>(3));
    rep(i,3){
     rep(j,3){
      cin>>a.at(i).at(j);
    }
  }
  cin>>n;
  vector<int> b(n);
  vector<vector<int>> c(3,vector<int>(3));
  rep(k,n){
   cin>>b.at(k);
    rep(i,3){
     rep(j,3){
   if(a.at(i).at(j)==b.at(k)){
    c.at(i).at(j)=1;
     }
    }
   }
  }
  s="No";
  rep(i,3){
  if((c.at(i).at(0))+(c.at(i).at(1))+(c.at(i).at(2))==3)
    s="Yes";
  }
  rep(i,3){
  if((c.at(0).at(i))+(c.at(1).at(i))+(c.at(2).at(i))==3)
    s="Yes";
  }
  if((c.at(0).at(0))+(c.at(1).at(1))+(c.at(2).at(2))==3)
    s="Yes";
  if((c.at(0).at(2))+(c.at(1).at(1))+(c.at(2).at(0))==3)
    s="Yes";
   
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int n, m;
vector<vector<int>> edge;

vector<bool> isVisited;
vector<int64_t> dp1, dp2;
void dfs1(int node)
{
    isVisited[node] = true;
    dp1[node] = 1;

    for (int e : edge[node]) {
        if (!isVisited[e]) {
            dfs1(e);
            dp1[node] *= dp1[e] + 1;
            dp1[node] %= m;
        }
    }
}

void dfs2(int node, int64_t p)
{
    isVisited[node] = true;
    dp2[node] = (p + 1) * dp1[node] % m;

    int n = edge[node].size();
    vector<int64_t> tmp(n + 1), rtmp(n + 1);
    tmp[0] = rtmp[n] = 1;

    rep(i, n)
    {
        int e = edge[node][i];
        if (isVisited[e]) {
            tmp[i + 1] = tmp[i];
        } else {
            tmp[i + 1] = tmp[i] * (dp1[e] + 1);
            tmp[i + 1] %= m;
        }

        int re = edge[node][n - 1 - i];
        if (isVisited[re]) {
            rtmp[n - 1 - i] = rtmp[n - i];
        } else {
            rtmp[n - 1 - i] = rtmp[n - i] * (dp1[re] + 1);
            rtmp[n - 1 - i] %= m;
        }
    }

    rep(i, n)
    {
        int e = edge[node][i];
        if (!isVisited[e]) {
            dfs2(e, tmp[i] * rtmp[i + 1] % m * (p + 1) % m);
        }
    }
}

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

    edge.resize(n);
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    isVisited.resize(n);

    dp1.resize(n);
    fill(isVisited.begin(), isVisited.end(), false);
    dfs1(0);

    dp2.resize(n);
    fill(isVisited.begin(), isVisited.end(), false);
    dfs2(0, 0);

    rep(i, n)
    {
        cout << dp2[i] << endl;
    }

    return 0;
}

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

using namespace std;
int d[303];
int cc[1002][3];
int main(){
while(1){
	int a,b,c,n;
	scanf("%d%d%d",&a,&b,&c);
	if(a == 0 && b == 0&& c == 0)break;
	scanf("%d",&n);
	int sum = a+b+c;
	for(int i = 1;i <= sum;i++){
		d[i] = 2;
	}
	int co = 0;
	while(n--){
		int i,j,k,r;
		cin >> i >> j >> k >> r;
		if(r == 0){
			cc[co][0] = i;
			cc[co][1] = j;
			cc[co++][2] = k;
		}else{
			d[i] = 1;
			d[j] = 1;
			d[k] = 1;
		}
	}
	for(int i = 0;i < co;i++){
		int ch = 0;
		for(int j = 0;j < 3;j++){
			if(d[cc[i][j]] == 1){
				ch++;
			}
		}
		if(ch == 2){
			for(int j = 0;j < 3;j++){
				if(d[cc[i][j]] != 1){
					d[cc[i][j]] = 0;
				}
			}
		}
	}

	for(int i = 1;i <= sum;i++){
		printf("%d\n",d[i]);
	}
	}
	return 0;
	
}


Measured memory_bytes: 1240
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String N = scanner.next();
    int SN = 0;
    for (int i = 0; i < N.length(); i++) {
      SN += Character.getNumericValue(N.charAt(i));
    }
    if (Integer.parseInt(N) % SN == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22740
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  s:string;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s);
    Write('A');
    Write(s[9]);
    Writeln('C');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
#include<stdio.h>

int n,A[20000000];

int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

int main(){//1//
  
  int a,q,i,j,M,p;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
      scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
  }//2//
  
  
  return 0;
}//1//



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
#define coutv(v) for (int i = 0; i < (v).size(); ++i) cout << v[i] << ' '; cout << endl;
#define coutvv(v) for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cout << v[i][j] << ' '; cout << endl;}
#define debugv(v) {for (int i = 0; i < (v).size(); ++i) cerr << v[i] << ' '; cerr << endl;}
#define debugvv(v) {for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cerr << v[i][j] << ' '; cerr << endl;}}
#define TC int TESTCASE; cin >> TESTCASE; while (TESTCASE--)
typedef long long ll;


int main() {
	int a,b;
	cin >> a >> b;
	cout << max(0, a - 2*b);
}
 


Measured memory_bytes: 3492
#!/usr/bin/python3

import sys
from bisect import bisect_left

sys.setrecursionlimit(1000000)

n = int(input())
a = [int(i) for i in input().split()]

nbs = [ [] for _ in range(n) ]

for _ in range(n - 1):
    (u, v) = map(int, input().split())
    nbs[u - 1].append(v - 1)
    nbs[v - 1].append(u - 1)


mlen = [ 0 ] * n

def getmlen(cur, p):
    for ch in nbs[cur]:
        if ch == p:
            continue

        if a[ch] > dp[-1]:
            dp.append(a[ch])
            mlen[ch] = len(dp)
            getmlen(ch, cur)
            dp.pop(-1)
        else:
            idx = bisect_left(dp, a[ch])
            ov = dp[idx]
            dp[idx] = a[ch]
            mlen[ch] = len(dp)
            getmlen(ch, cur)
            dp[idx] = ov
            

dp = []
dp.append(a[0])
mlen[0] = 1
getmlen(0, -1)

for i in range(n):
    print(mlen[i])


Measured memory_bytes: 345652
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif


static void A_OnTheWay();

int main()
{
	A_OnTheWay();
	
	fflush(stdout);
	return 0;
}


static void A_OnTheWay()
{
	int A = 0, B = 0, C = 0;

	scanf(" %d %d %d", &A, &B, &C);

	const char* ans = "No";
	if ((C >= A) && (C <= B) && (A <= B)) {
		ans = "Yes";
	}
	else if ((C <= A) && (C >= B) && (B <= A)) {
		ans = "Yes";
	}

	printf("%s\n", ans);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define mx 200001
//#define y 20
using namespace std;
typedef long long int ll;
# define f(i, n) for(int i = 0;i < n; ++i)
#define pb push_back
typedef long long int ll;
ll k, p = 0, ans = 1;
void dfs_until(ll u, vector<bool>&visited, ll n, vector<ll>adj[], ll level, ll  i){
    visited[u] = true;
    if(level == 0)ans = (ans * k) % mod;
    else if(level == 1){
       if(k - 1 - i <= 0)p = 1;
      ans = (ans * (k -1 - i) % mod) % mod;
    }
    else {
       if(k - 2 - i <= 0)p = 1;
       ans = (ans * (k -2 - i) % mod) % mod;
    }
   // cout << u << " " << level << " " << ans << "\n" ;
    i = 0;
    for(auto& it : adj[u]){
        if(!visited[it]){
            dfs_until(it, visited, n, adj, level + 1, i++);
        }
    }
}
void dfs(vector<ll>adj[], ll n){
    vector<bool>visited(n, 0);
   dfs_until(0, visited, n, adj, 0, 0);
}
void input()
{
   ll n;
    cin >> n >> k;
    vector<ll>adj[n];
    f(i, n - 1){
       ll s, d;
         cin >> s >> d;
         adj[s - 1].pb(d - 1);
         adj[d - 1].pb(s - 1);
    }
    dfs(adj, n);
    if(p == 1)cout << 0 << endl;
    else cout << ans % mod << endl;

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


Measured memory_bytes: 11648
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

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

  vector<int> D;
  int sum = 0;
  
  for (int n=0; n<N; ++n) {
    int d;
    cin >> d;
    D.push_back(d);
    sum += d;
  }

  int64_t ans = 0;

  for (auto d : D) {
    ans += d * (sum-d);
  }

  cout << ans/2 << endl;

  return 0;
}


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

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

    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (auto &b : B) cin >> b;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int res = C;
        for (int j = 0; j < M; ++j) {
            int A;
            cin >> A;
            res += A * B.at(j);
        }
        if (res > 0) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    if(K>(N-1)*(N-2)/2){
        cout << -1 << endl;
        return 0;
    }

    int cnt=(N-1)*(N-2)/2-K;
    cout << N-1+cnt << endl;
    for(int i=2; i<=N; i++){
        cout << 1 << ' ' << i << endl;
    }

    for(int i=2; i<=N; i++){
        for(int j=i+1; j<=N; j++){
            if(cnt==0)break;
            cout << i << ' ' << j << endl;
            cnt--;
        }
        if(cnt==0)break;
    }
}

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

bool doublet(int a, int b){
	return a==b;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int t; cin>>t;
	vector<int> die1(t),die2(t);
	for(int i = 0 ; i < t ; i++)
	{
		int d1,d2;cin>>d1>>d2;die1[i]=d1;die2[i]=d2;	
	}
	int counter=0,flag=0;
	for(int i = 0 ; i < t ; i++)
	{
		if( doublet(die1[i],die2[i]))counter++;
		else counter=0;
		if(counter==3)
		{
				flag=1;
				break;
		}
	}
	if(flag)cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 3628
D, G= map(int, input().split())
P = [[int(x) for x in input().split()] for d in range(D)]
Score = [[] for d in range(D)]
for d in range(D):
  for i in range(P[d][0] + 1):
    Score[d].append(100 * (d + 1) * i)
  Score[d][-1] += P[d][1]
DP = [[] for d in range(D)]
DP[0] = [x for x in Score[0]]
p_all = P[0][0]
for d in range(1, D):
  p_all += P[d][0]
  DP[d] = [0 for i in range(p_all + 1)]
  for p in range(p_all + 1):
    for s in range(min(P[d][0], p) + 1):
      if p - s < p_all - P[d][0] + 1:
        DP[d][p] = max(Score[d][s] + DP[d - 1][p - s], DP[d][p])
for i, s in enumerate(DP[D - 1]):
  if s >= G:
    print(i)
    break

Measured memory_bytes: 3288
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=2e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	int n,a,b;
	cin>>n>>a>>b;
	int ans=n/(a+b)*a;
	ans+=min(a,n%(a+b));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int n,m,Max,Max1,i,j,k,poz,l[304],nr[304],u[304],a[304][304];
bool b[304];
int main()
{
    scanf ("%d %d", &n, &m);
    Max=n;
    for (i=1;i<=n;i++)
        for (j=1;j<=m;j++)
            scanf ("%d", &a[i][j]);
    for (i=1;i<=n;i++)
        u[i]=1;
    for (i=1;i<=m;i++)
        b[i]=false;
    for (i=1;i<=m;i++)
    {
        nr[i]=0;
        l[i]=0;
    }
    for (i=1;i<=m;i++)
    {
        if (Max==1)
            break;
        Max1=0;
        poz=0;
        for (j=1;j<=n;j++)
        {
            for (k=u[j];k<=m;k++)
            {
                if (b[a[j][k]]==false)
                    break;
            }
            u[j]=k;
            if (l[a[j][k]]<i)
            {
                nr[a[j][k]]=1;
                l[a[j][k]]=i;
            }
            else
                nr[a[j][k]]++;
            if (nr[a[j][k]]>Max1)
            {
                Max1=nr[a[j][k]];
                poz=a[j][k];
            }
        }
        if (Max1<Max)
            Max=Max1;
        b[poz]=true;
    }
    Max1=0;
    for (i=1;i<=n;i++)
    {
        for (j=u[i];j<=m;j++)
        {
            if (b[a[i][j]]==false)
                break;
        }
        if (l[a[i][j]]<(n+1))
        {
            nr[a[i][j]]=1;
            l[a[i][j]]=n+1;
        }
        else
            nr[a[i][j]]++;
        if (nr[a[i][j]]>Max1)
            Max1=nr[a[i][j]];
    }
    if (Max1<Max)
        Max=Max1;
    printf ("%d\n", Max);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int check(int p, int x){
  return p * (100 + x) / 100;
}


int main() {
  int x, y, s;
  while(cin >>x >>y >>s && s){
    int ans = 0;
    FOR(i, 1, s) FOR(j, 1, s) if(check(i, x) + check(j, x) == s) ans = max(ans, check(i, y) + check(j, y));
    cout <<ans <<endl;
  }
  return 0;
}

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

const ll m=1000000007;




int main(){
    int n;
    cin>>n;
    int ans=0;
    int p[10005];
    for(int i=0;i<n;i++){
        cin>>p[i];
        ans+=p[i];
    }
    int p0=0;
    for(int i=0;i<n;i++){
        if(p0<p[i]) p0=p[i];
    }
    ans-=p0/2;
    cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 256
N, M = map(int, input().split())

if M == 0:
    A = [-1]
else:
    A = [-1] * M
    for i in range(M):
        A[i] = int(input())
A = set(A)

root = [0] * (N+1)  # N danme madeno root
root[0] = 1  # start is 1

if N == 1:
    if 1 in A:
        print(0)
    else:
        print(1)
    exit()

if N == 2:
    if 2 in A:
        print(0)
    else:
        if 1 in A:
            print(1)
        else:
            print(2)
    exit()

root[1] = 0 if 1 in A else 1
root[2] = 0 if 2 in A else (root[0] + root[1])

for i in range(3, N+1):
    root[i] = 0 if i in A else (root[i-1] + root[i-2])

print(root[N] % 1000000007)

Measured memory_bytes: 460020
#include <stdio.h>

int main() {
    int n, a, b, totalSum = 0;
    scanf("%d %d %d", &n, &a, &b);
    for (int i = 1 ; i <= n; i++) {
        int temp = i, digitSum = 0;
        while (temp != 0) {
            digitSum += (temp % 10);
            temp /= 10;
        }
        if (digitSum >= a && digitSum <= b) {
            totalSum += i;
        }
    }
    printf("%d", totalSum);
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

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

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


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

    i64 s = 0;
    REPS(i, N) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        s += i;
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int a,b,les,k,i,count=0,res[20];
    scanf("%d%d%d",&a,&b,&k);
    if(a>b)
    les=b;
    else
    les=a;
    for(i=1;i<=les;i++)
    {
        if(a%i==0&&b%i==0)
        {
            res[count]=i;
            count++;
            
        }
    }

    count=count-k;
    printf("%d",res[count]);
    
}

Measured memory_bytes: 128
s = input()
t = input()
ans = len(t)
for i in range(len(s)):
    if len(t)> len(s)-i:
        break
    else:
        cnt=0
        for j in range(len(t)):
            if s[i+j]==t[j]:
                cnt+=1
    ans=min(ans,len(t)-cnt)
print(ans)


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

int main(){
	int n;
	while(cin >> n){
		int count = 0;
		for(int i = 0; i <= 9; i++){
			for(int j = 0; j <= 9; j++){
				for(int k = 0; k <= 9; k++){
					for(int l = 0; l <= 9; l++){
						if(i+j+k+l == n){
							count++;
						}
					}
				}
			}
		}
		cout << count << endl;
	}
    return 0;
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        ll A, B, V, W, T;
        cin >>A >>V >>B >>W >>T;
        ll C=abs(A-B);
        ll D=V-W;
        if (D<=0) {
                cout <<"NO" <<endl;
                return 0;
        }
        if (D*T>=C)
                cout <<"YES" <<endl;
        else
                cout <<"NO" <<endl;
        return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 17;
char dn[dm], *di = dn, dt;
inline void putcha(char c) {
	*di++ = c;
	if (di == dn + dm) { fwrite(dn, 1, dm, stdout); di = dn; }
}

inline void putint(ll X) {
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	if (di + 20 > dn + dm) {
		for (int i = keta - 1; i >= 0; i--) putcha(*(C + i));
		putcha('\n');
	}
	else {
		for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
		*di++ = '\n';
	}
}

int N;
ll D[100001];
vector<pair<int, int>> E[100001];
void dfs(int A, ll B) {
	*(D + A) = B;
	for (auto p : *(E + A)) if (!(*(D + p.first))) dfs(p.first, B + p.second);
}

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


	int N = getint();
	rep(i, N - 1) {
		int a = getint();
		int b = getint();
		int c = getint();
		(*(E + a)).pb(mp(b, c));
		(*(E + b)).pb(mp(a, c));
	}
	int Q = getint();
	int K = getint();
	dfs(K, 1);
	rep(i, Q) {
		int x = getint();
		int y = getint();
		putint(*(D + x) + *(D + y) - 2);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 11392
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

for i in range(n):
    p_list[i] = (1 + p_list[i]) / 2

wa = sum(p_list[0:k])
ans = wa

for j in range(n-k):
    wa = wa + p_list[j+k] - p_list[j]
    ans = max(ans, wa)
    
print(ans)

Measured memory_bytes: 25060
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = numeric_limits<int>::infinity();

int main(void)
{
    LL a, b;
    cin >> a >> b;
    if ((a*b) % 2 == 0){
        puts("Even");
    }
    else{
        puts("Odd");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char string[4];
    int count = 0;
    int i;
    
    scanf("%s", string);
    
    for(i = 0; i < 3; i++){
        if (string[i] == 'o'){
            count += 1;
        }
    }
    
    printf("%d\n",700 + 100 * count);
    
    return 0;
}


Measured memory_bytes: 128