akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,m,c;
  cin >> n >> m >> c;

  vi b(m);
  rep(i,m) cin >> b[i];

  int cnt = 0;

  rep(i,n)
  {
    int sum = 0;
    rep(i,m)
    {
      int x;
      cin >> x;
      sum += b[i] * x;
    }
    sum += c;
    if(sum > 0)
      cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
using System;
using System.Linq;

static class D
{
    private const long M = 1000000007;

    static long Solve(int[] a, int[] b)
    {
        int n = a.Length;
        int m = b.Length;

        if (a.Distinct().Count() != n) return 0;
        if (b.Distinct().Count() != m) return 0;

        long ans = 1;
        int k = n * m;
        for (; k >= 1; k--) {
            int r = 0, c = 0;

            for (int i = 0; i < n; i++) {
                if (a[i] == k) { r = -1; break; }
                if (a[i] >  k) { r++; }
            }
            for (int i = 0; i < m; i++) {
                if (b[i] == k) { c = -1; break; }
                if (b[i] >  k) { c++; }
            }
            if (r == n && c == m)
                break;

            int rc = Math.Abs(r) * Math.Abs(c);
            if (r > 0 && c > 0) {
                rc -= n * m - k;
            }
            if (rc == 0) return 0;
            ans = (ans * rc) % M;
        }
        for (; k >= 1; k--) {
            ans = (ans * k) % M;
        }
        
        return ans;
    }

    static void Main()
    {
        Console.ReadLine();
        int[] a = Console.ReadLine().Split().Select(Int32.Parse).ToArray();
        int[] b = Console.ReadLine().Split().Select(Int32.Parse).ToArray();
        Console.WriteLine(Solve(a, b));
    }
}


Measured memory_bytes: 13536
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

constexpr int MOD = (int)1e9 + 7;
int H, W;
int dp[1005][1005];
char mat[1005][1005];

int slv(int y, int x)
{
  if (y == H-1 && x == W-1) { return 1; }
  if (y >= H || x >= W) { return 0; }
  int &ret = dp[y][x];
  if(~ret) { return ret; }

  ret = 0;
  if (mat[y+1][x] != '#') ret = (ret + slv(y+1, x)) % MOD;
  if (mat[y][x+1] != '#') ret = (ret + slv(y, x+1)) % MOD;
  return ret;
}

signed main()
{
  cin >> H >> W;
  for (int i = 0;i < H; ++i) {
    cin >> mat[i];
  }

  memset(dp, -1, sizeof(dp));
  cout << slv(0, 0) << endl;

  return 0;
}



Measured memory_bytes: 5248
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vll A(N); REP(i, N) cin >> A[i];

    multiset<ll> s;
    REP(i, N) s.insert(A[i]);

    ll m = 0;
    REP(i, N) {
        if (m > A[i]) {
            print("No");
            return 0;
        }

        m = max(m, A[i] - 1);
    }
    print("Yes");
    
}


Measured memory_bytes: 8740
from collections import deque
import sys
input = sys.stdin.buffer.readline

N = int(input())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

que = deque()
que.append(1)
root = [-1] * (N+1)
root[1] = 0
while que:
    v = que.popleft()
    for u in adj[v]:
        if root[u] < 0:
            root[u] = v
            que.append(u)

i = N
path = []
while True:
    path.append(i)
    if i == 1:
        break
    i = root[i]
path.reverse()

first = path[(len(path)-1)//2]
second = path[(len(path)-1)//2 + 1]
cnt = 0
que.append(first)
seen = [0] * (N+1)
seen[first] = 1
seen[second] = 1
while que:
    v = que.pop()
    cnt += 1
    for u in adj[v]:
        if seen[u] == 0:
            seen[u] = 1
            que.append(u)

if cnt > N-cnt:
    print('Fennec')
else:
    print('Snuke')



Measured memory_bytes: 60592
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			int n = in.nextInt();
			int W = in.nextInt();
			int H = in.nextInt();
			if (n == 0 && W==0 && H==0){
				break;
			}
			ArrayList<Point> piece = new ArrayList<>();
			piece.add(new Point(W, H));
			for (int i = 0; i < n; i++) {
				int p = in.nextInt();
				int s = in.nextInt();
				Point trg = piece.remove(p - 1);
				s %= (trg.w + trg.h) * 2;
				Point new1, new2;
				if (s < trg.w) {
					new1 = new Point(Math.min(s, trg.w - s), trg.h);
					new2 = new Point(Math.max(s, trg.w - s), trg.h);
				} else if (s < trg.w + trg.h) {
					new1 = new Point(trg.w, Math.min(s - trg.w, trg.w + trg.h - s));
					new2 = new Point(trg.w, Math.max(s - trg.w, trg.w + trg.h - s));
				} else if (s < trg.w * 2 + trg.h) {
					new1 = new Point(Math.min(s - trg.w - trg.h, trg.w * 2 + trg.h - s), trg.h);
					new2 = new Point(Math.max(s - trg.w - trg.h, trg.w * 2 + trg.h - s), trg.h);
				} else {
					new1 = new Point(trg.w, Math.min(s - trg.w*2 - trg.h, trg.w * 2 + trg.h * 2 - s));
					new2 = new Point(trg.w, Math.max(s - trg.w*2 - trg.h, trg.w * 2 + trg.h * 2 - s));
				}
				piece.add(new1);
				piece.add(new2);
			}
			PriorityQueue<Integer> que = new PriorityQueue<Integer>();
			for (int i = 0; i < piece.size(); i++) {
				que.add(piece.get(i).w * piece.get(i).h);
			}
			while (!que.isEmpty()) {
				System.out.print(que.poll()+((que.isEmpty())?"\n":" "));
			}
		}
	}
}

class Point {
	int w;
	int h;

	public Point(int w, int h) {
		this.w = w;
		this.h = h;
	}
}

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

int main() {
	int n;
	cin>>n;
	int arr[n];
	int brr[100001]={};
	long long sum=0;
	for (int i=0; i<n; i++){
		cin >> arr[i];
		sum += arr[i];
		brr[arr[i]]++;
	}
	int cnt;
	cin >> cnt;
	long long total = sum;
	for (int i=0; i<cnt; i++){
		int a, b;
		cin>>a>>b;
		if(brr[a]>0){
			int temp = brr[a];
			brr[a]=0;
			brr[b]+=temp;
			//total -= temp*a;
			total += temp*(b-a);
		}
		cout << total << endl;

	}	
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

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 int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    REP(i,N){
        string S;
        cin >> S;
        if(S == "E869120") ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3212
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
    input! {
        s:Chars,
        t:Chars,
    }
    let mut ans = 999999;
    for i in 0..=s.len() - t.len() {
        let mut buf = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                buf += 1;
            }
        }
        ans = std::cmp::min(ans, buf);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2148
N = int(input())
A = [int(e) for e in input().split()]

isApproved = True
for a in A:
    if (a % 3 != 0) and (a % 5 != 0) and (a % 2 == 0):
        isApproved = False

if isApproved:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include<stdio.h>

#include<string.h>

int main ()
{
    int n,i,flag=0,j,k;
    scanf("%d",&n);
    char a[100][100],x;

    for(i=0; i<n; i++)
    {
        scanf("%s",a[i]);
    }
    

    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(strcmp(a[i],a[j])==0)
            {
                flag=1;
                break;
                
            }
        
        if(flag==1){
            break;
        }
    }
    }
    
    if(flag==0)
    {
        for(i=0;i<n-1;i++)
        {
            if(a[i][strlen(a[i])-1]!=a[i+1][0])
            {
                flag=1;
                break;
            }
        }
        
    }
    
    
        if(flag==0)
            printf("Yes\n");
        else
            printf("No\n");

}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;
int e[300001];
int w[300001];
string s;


int main() {
	cin >> n >> s;
	
	inc(i, n) { e[i + 1] = e[i] + (s[i] == 'E' ? 1 : 0); }
	inc(i, n) { w[i + 1] = w[i] + (s[i] == 'W' ? 1 : 0); }
	
	int mi = n;
	inc(i, n) {
		setmin(mi, (w[i] - w[0]) + (e[n] - e[i + 1]));
		
	}
	
	cout << mi << endl;
	
	return 0;
}


Measured memory_bytes: 3076
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

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

        long inu =  sc.nextLong();
        long saru = sc.nextLong();
        long ans = 1;

        if (inu == saru) {
            for (int i = 1; i <= inu; i++) {
                ans = (ans * i) % 1000000007;
            }
            for (int i = 1; i <= saru; i++) {
                ans = (ans * i) % 1000000007;
            }
            ans = (ans * 2) % 1000000007;

            System.out.println(ans);
        } else {
            if (Math.abs(inu - saru) >= 2) {
                System.out.println(0);
            } else {
                for (int i = 1; i <= inu; i++) {
                    ans = (ans * i) % 1000000007;
                }
                for (int i = 1; i <= saru; i++) {
                    ans = (ans * i) % 1000000007;
                }
                System.out.println(ans);
            }
        }

        sc.close();
    }

}





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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4

int po(int x, int n) { return n == 1 ? x : x * po(x, n - 1); }

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

    int n, m;
    cin >> n >> m;
    vector<vector<P>> tb(n + 1);

    vec p(m), y(m);
    init(p, y);

    rep (i, m)
        tb[p[i]].push_back({y[i], i});

    vec order(m);
    repall (v, tb) {
        sort(all(v));
        rep (i, v.size())
            order[v[i].second] = i + 1;
    }

    rep (i, m)
        printf("%012lld\n", p[i] * po(10, 6) + order[i]);

    return 0;
}

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

int main() {
  int x;
  cin >> x;
  if (400 <= x && x <= 599) {
    cout << 8 << endl;
  } else if (600 <= x && x <= 799) {
    cout << 7 << endl;
  } else if (800 <= x && x <= 999) {
    cout << 6 << endl;
  } else if (1000 <= x && x <= 1199) {
    cout << 5 << endl;
  } else if (1200 <= x && x <= 1399) {
    cout << 4 << endl;
  } else if (1400 <= x && x <= 1599) {
    cout << 3 << endl;
  } else if (1600 <= x && x <= 1799) {
    cout << 2 << endl;
  } else if (1800 <= x && x <= 1999) {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int n,A,B,C,D;
	scanf("%d %d %d %d %d",&n,&A,&B,&C,&D);
	ll x=llabs(B-A);
	for(int i=0;i<n;i++)
	{
		ll a=i,b=n-i-1;
		ll low=a*(ll) C-b*(ll) D;
		ll up=a*(ll) D-b*(ll) C;
		if(low<=x&&x<=up)
		{
			//printf("%lld %lld\n",a,b);
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 128
//70　B - Two Switches 2017/08/12
#include <bits/stdc++.h>
using namespace std;

int main(){
    int a , b , c , d;
    cin >> a >> b >> c >> d;
    if(b<=c || d<=a) cout << 0 ;
    else if(a<=c && d<=b) cout << d - c ;
    else if(c<=a && b<=d) cout << b - a ;
    else if(a<c && b>c && b<d) cout << b - c ;
    else if(c<a && a<d && d<b) cout << d - a ;
    cout << endl;
}

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 x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b)){
        cout<<'B';
    }else{
        cout<<'A';
    }
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    double min_diff = 999999;
    int min_idx = -1;
    for (int i = 0; i < N; ++i) {
        int h = H[i];
        double t = T - h * 0.006;
        if (min_diff > (abs(double(A) - double(t)))) {
            min_diff = abs(double(A) - double(t));
            min_idx = i;
        }
    }
    cout << min_idx + 1 << endl;
    return 0;
}

Measured memory_bytes: 3172
st = []
while 1:
    n,m = list(map(int, input().split()))
    max = -1
    if n==0:
        break
    
    a = list(map(int, input().split()))
    
    for i in range(len(a)):
        for j in range(i+1,len(a)):
            sum = a[i]+a[j]
            if sum<=m:
                if sum>max:
                    max = sum
    
    if max==-1:
        st.append("NONE")
    else:
        st.append(max)
            
for i in range(len(st)):
    print(st[i])


Measured memory_bytes: 5716
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    long long N, M;
    std::cin >> N >> M;

    std::vector<std::pair<long long, long long>> AB(N);

    long long A, B;
    for (long long i = 0; i < N; i++) {
        std::cin >> A >> B;
        AB[i] = std::make_pair(A, B);
    }

    std::sort(std::begin(AB), std::end(AB));

    long long r = 0;
    long long m = M;
    for (int i = 0; i < N; i++) {
        if (M > AB[i].second) {
            M -= AB[i].second;
            r += (AB[i].second * AB[i].first);
        }
        else {
            r += (M * AB[i].first); 
            break;
        }
    }

    std::cout << r << std::endl;
    
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt(),L=sc.nextInt();
		int min =100000;
		int sum=0;
		int eat=0;

		for(int i=1;i<=N;i++) {
			int tastes = L+i-1;
			sum+=tastes;
			if(Math.abs(tastes)<min) {
				min=Math.abs(tastes);
				eat=tastes;
			}
		}
		System.out.println(sum-eat);
	}
}


Measured memory_bytes: 21716
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		string str = line.to!string.chomp;
  		foreach (i; 0..26) {
  			if (str.caesar(i).split.count!(s => s == "the" || s == "this" || s == "that") > 0) {
  				str = str.caesar(i);
  				break;
  			}
  		}
  		str.writeln;
  	}
}


string caesar(string str, int n) 
{
	string ret = "";
	foreach (c; str) {
		if (c == '.' || c == ' ') ret ~= c;
		else if (c + n >= 'a' && c + n <= 'z') ret ~= c + n;
		else ret ~= 'a' + c + n - 1 - 'z';
	}
	return ret;
}

Measured memory_bytes: 1060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <functional>
using namespace std;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


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

int main() {
  int A;
  cin >> A;
  int64_t B, N;
  cin >> B >> N;
  if (N < B) {
    cout << A * N / B << endl;
  }
  else {
    cout << A * (B - 1) / B << endl;
  }
}

Measured memory_bytes: 3600
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int N;

int main(){
	cin>>N;
	for(int i=0;i<=N;i++){
		if((i*108)/100==N){
			cout<<i<<endl;
			return 0;
		}

	}
	cout<<":("<<endl;
}





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

using namespace std;

int Poz[500005],DNF[500005],D[500005];

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

    int n,d;
    cin>>n>>d;
    for(int i=1; i<=n; i++)
        cin>>D[i];

    Poz[0]=d;
    for(int i=1; i<=n; i++)
        Poz[i]=min(Poz[i-1],abs(Poz[i-1]-D[i]));

    //DNF[i]=dist minima de d cu prop ca nu pot termina din DNF cu mutarile ramase
    DNF[n+1]=1;
    for(int i=n; i>=1; i--)
    {
        if(DNF[i+1]<=D[i]/2)
            DNF[i]=DNF[i+1]; //practic daca sunt in DNF[i+1] se va da skip la mutare
        else
            DNF[i]=DNF[i+1]+D[i]; //daca pun mai incolo vine in contradictie cu DNF[i+1]-minim
    }

    int q;
    cin>>q;
    for(int i=1; i<=q; i++)
    {
        int x;
        cin>>x;
        if(DNF[x+1]<=Poz[x-1])
            cout<<"YES\n";
        else
            cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N, K;
	cin >> N >> K;
	vl P(N);
	vl C(N);
	rep(i, N) {
		cin >> P[i];
		P[i]--;
	}
	rep(i, N)
		cin >> C[i];
	ll ans = -InfLL;
	rep(i, N) {
		ll anstmp = 0;
		vb Pin(N, 0);
		Pin[i] = 1;
		ll k = 0;
		ll p = i;
		while (1) {
			k++;
			p = P[p];
			anstmp += C[p];
			ans = max(ans, anstmp);
			if (Pin[p])
				break;
			Pin[p] = 1;
			if (k >= K)
				break;
		}
		if (k >= K)
			continue;
		if (anstmp > 0) {
			anstmp *= (K / k - 1);
			ans = max(ans, anstmp);
			ll K1 = K % k;
			K1 += k;
			k = 0;
			p = i;
			while (1) {
				k++;
				p = P[p];
				anstmp += C[p];
				ans = max(ans, anstmp);
				if (k >= K1)
					break;
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
vector<ll> tree[100010];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll u[100010], v[100010];
    rep(i,0,M){
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
        tree[u[i]].push_back(v[i]);
    }
    ll S,T;
    cin >> S >> T;
    S--; T--;
    priority_queue<lpair, vector<lpair> ,greater<lpair> > pq;
    ll dist[100010][3] = {};
    rep(i,0,N){
        rep(j,0,3){
            dist[i][j] = INF;
        }
    }
    dist[S][0] = 0;
    rep(i,0,N){
        rep(j,0,3){
            pq.push(make_pair(dist[i][j], i + 1000000 * j));
        }
    }
    while(!pq.empty()){
        lpair l1 = pq.top();
        ll dd = l1.first;
        ll idx = l1.second % 1000000;
        ll mode = l1.second / 1000000;
        pq.pop();
        for(auto &e: tree[idx]){
            ll nxt = (mode + 1) % 3;
            if(dist[e][nxt] > dist[idx][mode] + 1){
                dist[e][nxt] = dist[idx][mode] + 1;
                pq.push(make_pair(dist[e][nxt], e + 1000000 * nxt));
            }
        }
    }
    if(dist[T][0] == INF){
        print(-1);
    }else{
        print(dist[T][0]/3);
    }

    
}

Measured memory_bytes: 19308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    string s, t;
    cin >> s >> t;
    map<char, int> m;
    rep (i, 26) {
        int c = 'a' + i;
        vector<int> places;
        rep (j, s.size()) {
            if (s[j] == c) {
                places.push_back(j);
            }
        }
        if (places.empty()) {
            continue;
        }
        if (m[t[places[0]]] == 1) {
            cout << "No" << endl;
            exit(0);
        }
        rep (j, places.size()) {
            if (t[places[0]] != t[places[j]]) {
                cout << "No" << endl;
                exit(0);
            }
        }
        m[t[places[0]]] = 1;
    }
    cout << "Yes" << endl;
}

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

using namespace std;
const int N = 1e5+10;
int main()
{
    set<int>st;
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        int k;
        scanf("%d",&k);
        if(st.count(k) == 0)st.insert(k);
        else 
        {
            printf("NO");
            return 0;
        }
    }
    printf("YES");

    return 0;
}

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

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

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    int H,W; cin >> H >> W;
    char s[H][W]; REP(i,H)REP(j,W) cin >> s[i][j];

    REP(i,H)REP(j,W){
        if(s[i][j] == '.') continue;
        char c[4] = {'.','.','.','.'};
        if(i) c[0] = s[i-1][j];
        if(j) c[1] = s[i][j-1];
        if(i<H-1) c[2] = s[i+1][j];
        if(j<W-1) c[3] = s[i][j+1];

        if(c[0]=='.' && c[1]=='.' && c[2]=='.' && c[3]=='.'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws java.io.IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String M = in.readLine();
		String k[] = new String[M.length()];
		for(int a = 0;a<M.length();a++){
			k[a] = M.substring(a,a+1);
			if(k[a].matches( "[a-z]+" )){
				k[a] = k[a].toUpperCase();
			}else{
				k[a] = k[a].toLowerCase();
			}
			System.out.print(k[a]);
		}
		System.out.println("");
	}
}

Measured memory_bytes: 22724
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    ll n;
    cin >> n;
    ll dp[61][3] = {};
    dp[60][0] = 1;
    for(int d = 59; d >= 0; d--) {
        rep(s, 3) rep(k, 3) {
            int s2 = min<int>(2, 2 * s + (n >> d & 1) - k);
            if(s2 >= 0) (dp[d][s2] += dp[d + 1][s]) %= mod;
        }
    }
    cout << (dp[0][0] + dp[0][1] + dp[0][2]) % mod << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class E { static void Main() { new K(); } }
class K
{
	public K()
	{
		var N = int.Parse(Console.ReadLine());
		var ps = GetPrimes(100100);
		var p2 = new Dictionary<long, int>();
		foreach (var p in ps) p2.Add(p * (long)p, p);
		var z = new long[N];
		var cnt = new Dictionary<long, int>();
		var w = new Dictionary<long, long>();
		for (var i = 0; i < N; i++)
		{
			var num = long.Parse(Console.ReadLine());
			var fact = new List<int>();
			var t = 1L;
			for (var j = 0; j < ps.Count; j++)
			{
				var x = ps[j];
				var cube = x * (long)x * x;
				if (cube > num) break;
				if (num % x == 0)
				{
					fact.Add(x);
					while (num % cube == 0) num /= cube;
					if (num % (x * (long)x) == 0) t *= x;
					else if (num % x == 0) t *= x * (long)x;
				}
			}
			z[i] = num;
			if (!w.ContainsKey(z[i]))
			{
				foreach (var p in fact) while (num % p == 0) num /= p;
				if (p2.ContainsKey(num))  t *= p2[num];
				else { if (num < 100100) t *= num * num; else t = -1; }
				w[z[i]] = t;
				cnt[z[i]] = 1;
			}
			else cnt[z[i]]++;
		}
		var sum = 0;
		var set = new HashSet<long>(z);
		var done = new HashSet<long>();
		if (set.Contains(1)) { sum++; set.Remove(1); }
		foreach (var x in set)
		{
			if (done.Contains(x)) continue;
			var y = w[x];
			if (cnt.ContainsKey(y)) sum += Math.Max(cnt[x], cnt[y]);
			else sum += cnt[x];
			done.Add(x);
			done.Add(y);
		}
		Console.WriteLine(sum);
	}
	List<int> GetPrimes(int n)
	{
		var m = (n - 1) >> 1;
		var primes = new List<int>((int)(n / Math.Log(n)));
		primes.Add(2);
		var composites = new bool[m];
		composites[0] = false;
		for (var p = 0; p < m; p++)
			if (!composites[p])
			{
				var pnum = 2 * p + 3;
				primes.Add(pnum);
				for (var k = 3 * p + 3; k < m; k += pnum) composites[k] = true;
			}
		return primes;
	}
}

Measured memory_bytes: 28288
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

int main() {
	// 入力
	ll N,X;cin>>N>>X;
    ll L[N];REP(i,N)cin>>L[i];

    // 解法
    ll sum = 0;
    ll ans = 1;
    REP(i,N){
        sum += L[i];
        if (sum>X) break;
        ans++;
    }    

    // 出力
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n)    for(uint i = 0; i < n; ++i)
#define comp(a, b) int comp(const void *a, const void *b)
typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

typedef struct{
    int element;
    int index;
}s;

comp(a, b){
    s s_a = *(s*)a, s_b = *(s*)b;
    return s_a.element - s_b.element;
}
int main(){
    int N; cin >> N;
    s X[N];
    REP(i, N){
        int temp;
        cin >> temp;
        X[i].element = temp;
        X[i].index = i;
    }

    qsort(X, N, sizeof(s), comp);
    int ans[N];

    REP(i, N){
        if(i + 1 < (N + 1)/2 + 1){
            ans[X[i].index] = X[(N + 1)/2].element;
        }else{
            ans[X[i].index] = X[(N + 1)/2 - 1].element;
        }
    }
    REP(i, N){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4576
#include <iostream>
#include <fstream>
#include <climits>
using namespace std;
const int nmax=2005;
int a[nmax][nmax],b[nmax];
long long sum[nmax];
long long mn,x;
int n,i,j;
int main()
{
   // freopen("data.in","r",stdin);
    cin>>n>>x;mn=LLONG_MAX;
    for(i=1;i<=n;i++)
    {
        cin>>b[i];
        a[i][0]=b[i];
    }
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
        {
            a[i][j]=a[i][j-1];
            if(j<i) a[i][j]=min(a[i][j],b[i-j]);
            else a[i][j]=min(a[i][j],b[i-j+n]);
        }
    for(i=1;i<=n;i++)
        for(j=0;j<=n;j++)
          sum[j]+=a[i][j];
    for(i=0;i<=n;i++)
    {
        sum[i]+=1LL*i*x;
        if(sum[i]<mn)
            mn=sum[i];
    }
    cout<<mn;
    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    ll a[n];
    vector<ll> s(n+1,0);
    vector<ll> ps(n+1,0);
    rep(i,n) {
        cin >> a[i];
        s[i+1] = s[i] + a[i];
        if(a[i] > 0) ps[i+1] = ps[i] + a[i];
        else ps[i+1] = ps[i];
    }
    ll ans = 0;
    for(int i = 1; i <= n-k+1; i++){
        ans = max(ans,ps[i-1]-ps[0]+max(s[i+k-1]-s[i-1],(ll)0)+ps[n]-ps[i+k-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::collections::*;

fn prime_factorization<T: num::PrimInt>(x: T) -> std::collections::BTreeMap<T, i64> {
    let two = T::from(2).unwrap();
    let three = T::from(3).unwrap();
    (std::iter::once(two).chain(num::iter::range_step(three, x, two)))
        .scan(x, |state, i| {
            if *state == T::one() {
                None
            } else {
                let divisor = if i * i <= *state { i } else { *state };
                let mut index = 0;
                while *state % divisor == T::zero() {
                    *state = *state / divisor;
                    index += 1;
                }
                Some((divisor, index))
            }
        })
        .filter(|&(_, index)| index > 0)
        .collect()
}

fn main() {
    input! {
        n:i64
    }
    let ans: i64 = prime_factorization(n)
        .iter()
        .map(|(_, &index)| {
            (1..)
                .take_while(|&i| index >= i * (i + 1) / 2)
                .last()
                .unwrap()
        })
        .sum();
    println!("{}", ans);
}

Measured memory_bytes: 2172
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int H,W;
	while (cin >> H >> W, H||W) {
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if ((i+j)%2 == 0) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3116
import re
import math

if __name__ == '__main__':
    
    a, b, c = [int(x) for x in input().split()]
    k = int(input())

    ns = [a, b, c]
    ns = sorted(ns)
    for i in range(k):
        ns[2] = ns[2]*2

    print(sum(ns))



Measured memory_bytes: 3188
#!/usr/local/gnu/bin/bash
read n
read -a p
c=0
for i in `seq 2 $((n-1))`
do
    ((p[i-2]<p[i-1]&&p[i-1]<p[i]||p[i-2]>p[i-1]&&p[i-1]>p[i])) && c=$((c+1))
done
echo $c

Measured memory_bytes: 664
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;
	rep(i, 0, N) {
		ll a;
		std::cin >> a;
		if (a & 1) {
			std::cout << "first" << endl;
			return 0;
		}
	}
	std::cout << "second" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[1010][20202];
int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    rep(i,n)cin>>a[i]>>b[i]>>c[i];
    int ord[n];
    rep(i,n)ord[i]=i;
    sort(ord,ord+n,[&](int x,int y){
        return a[x]+b[x]<a[y]+b[y];
    });
    rep(i,n){
        int idx=ord[i];
        rep(j,b[idx]+1){
            dp[i+1][j+a[idx]]=dp[i][j]+c[idx];
        }
        rep(j,20001)dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
    ll ans=0;
    rep(i,20001)ans=max(ans,dp[n][i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 158080
#include <cstdio>
int main(){
    int n, m, l;
    int i, j, k;
    scanf("%d%d%d", &n, &m, &l);
    
    int A[100][100] = {};
    int B[100][100] = {};
    long C[100][100] = {};
    
    for (i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            scanf("%d", &A[i][j]);
        }
    } 
    for (i = 0; i < m; i++){
        for (j = 0; j < l; j++){
            scanf("%d", &B[i][j]);
        }
    } 
    for (i = 0; i < n; i++){
        for (j = 0; j < l; j++){
            for (int k = 0; k < m; k++){
                C[i][j] += A[i][k] * B[k][j];
            }
            printf("%ld", C[i][j]);
            if (j < l -1){
                printf(" ");
            }
        }
        printf("\n");
    } 
    return 0;
}

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

typedef long long ll;
int main(void){
    int X, N;
    cin >> X >> N;
    vector<bool> ex(102, false);
    int p;
    for (int i = 0; i < N; i++) {
        cin >> p;
        ex[p] = true;
    }
    
    int left = X, right = X;
    int ans;
    while (true) {
        if (!ex[left]) {
            ans = left;
            break;
        }
        left--;
        if (!ex[right]) {
            ans = right;
            break;
        }
        right++;
    }
    cout << ans;
}

Measured memory_bytes: 3628
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int D = N % 10; N /= 10;
        int C = N % 10; N /= 10;
        int B = N % 10; N /= 10;
        int A = N % 10; N /= 10;

        string op = "+-";
        for (int i = 0; i < 2; i++)
        {
            for (int j = 0; j < 2; j++)
            {
                for (int k = 0; k < 2; k++)
                {
                    if(A + B * (1 - 2 * i) + C * (1 - 2 * j) + D * (1 - 2 * k) == 7)
                    {
                        Console.WriteLine($"{A}{op[i]}{B}{op[j]}{C}{op[k]}{D}=7");
                        return;
                    }
                }
            }
        }
    }

    int[] uni;
    void init(int N)
    {
        uni = new int[N];
        for (int i = 0; i < N; i++)
        {
            uni[i] = -1;
        }
    }

    int root(int a)
    {
        if (uni[a] < 0) return a;
        else return uni[a] = root(uni[a]);
    }

    bool connect(int a, int b)
    {
        a = root(a);
        b = root(b);
        if (a == b) return false;
        if (uni[a] > uni[b]) swap(ref a, ref b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    void swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    }  


}



class Scanner
{
    string[] s;
    int i;

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

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

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
int main (){
	char s[4];
	scanf("%s",s);
	
	if( s[0] == s[1] && s[1] == s[2]){
		
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
		
	return 0;
}


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

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

    ll N, C;
    cin >> N >> C;

    vector<ll> x(N);
    vector<ll> v(N);

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

    ll ans = 0;

    vector<ll> l(N);
    vector<ll> r(N);

    vector<ll> ld(N);
    vector<ll> rd(N);

    l[0] = v[N - 1] - (C - x[N - 1]);
    ld[0] = max(l[0], 0LL);

    ll b = x[N - 1]; 

    for(int i = 1; i < N; i++) {
        l[i] = l[i - 1] + v[N - i - 1] - (b - x[N - i - 1]);
        ld[i] = max(l[i], ld[i - 1]);
        b = x[N - i - 1];
    }

    ans = max(ans, ld[N - 1]);

    r[0] = v[0] - x[0];
    rd[0] = max(r[0], 0LL);

    b = x[0];

    for(int i = 1; i < N; i++) {
        r[i] = r[i - 1] + v[i] - (x[i] - b);
        rd[i] = max(r[i], rd[i - 1]);
        b = x[i];
    }

    ans = max(ans, rd[N - 1]);

    for(int i = 0; i < N - 1; i++) {
        ans = max(ans, l[i] - (C - x[N - 1 - i]) + rd[N - i - 2]);
        ans = max(ans, r[i] - x[i] + ld[N - i - 2]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992