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

#define deb(x) cout << #x << "=" << x << endl
#define ll long long

const int mod = 1000000007;
const int N = 3e5, M = N;
const ll mx = LLONG_MAX;

int n, k;
vector<ll> h, dp;
void solve() {
	ll a, b, n, k;
	ll input;
	cin >> n >> k;
	h.resize(n); dp.resize(n, mx);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		for (int j = i - 1; j >= i - k && j >= 0; j--) {
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
		}
	}
	ll res = dp[n - 1];
	cout << res << endl;








}



int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}



Measured memory_bytes: 4816
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/


void Main()
{
	int n; cin>>n;
	vector<int> a(n); 
	priority_queue<int> que;
	rep(i,n) {
		cin>>a.at(i);
		que.push(a.at(i));
	}
	int bound1 = que.top();
	que.pop();
	int bound2 = que.top();
	rep(i,n){
		if(a.at(i)==bound1)
			cout<<bound2<<endl;
		else
			cout<<bound1<<endl;
	}
}

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

Measured memory_bytes: 3316
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int d[] = new int[N];

        for (int i = 0; i < N; i++) {
            d[i] = scan.nextInt();
        }

        boolean yes = true;

        int maxX = 0;
        for (int i = 0; i < N; i++) {
            int x = 10 * i;

            if (x > maxX) {
                yes = false;
            }

            int hikyori = x + d[i];

            if (hikyori > maxX) {
                maxX = hikyori;
            }
        }

        maxX = 0;
        for (int i = 0; i < N; i++) {
            int x = 10 * i;

            if (x > maxX) {
                yes = false;
            }

            int hikyori = x + d[N - 1 -i];

            if (hikyori > maxX) {
                maxX = hikyori;
            }
        }

        if (yes) {
            System.out.println("yes");
        } else {
            System.out.println("no");
        }
    }

}



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

vector<int> adj[200000];
int score[200000];


void dfs(int r,int p){
    for(int i=0;i<adj[r].size();i++){
        if(adj[r][i]!=p){
            score[adj[r][i]] += score[r];
            dfs(adj[r][i],r);
        }
    }
}

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

    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >>b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for(int i=0;i<q;i++){
        int p,x;
        cin >> p >>x;
        p--;
        score[p] += x;
    }

    dfs(0,-1);
    for(int i=0;i<n;i++){
        cout << score[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 26624
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

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

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<tuple<string, int, int>> as(N);
  F0R(i, N) {
    cin >> get<0>(as[i]) >> get<1>(as[i]);
    get<2>(as[i]) = i;
  }
  sort(rng(as), [](const tuple<string, int, int>& a, const tuple<string, int, int>& b) {
    return get<0>(a) != get<0>(b) ? get<0>(a) < get<0>(b) : get<1>(a) > get<1>(b);
    });

  F0R(i, N) {
    cout << (get<2>(as[i]) + 1) << newl;
  }
}
#endif


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N, T;

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

  cin >> N >> T;
  int ans = INF;
  int a, b;
  rep(i, N){
    cin >> a >> b;
    if (T>=b){
      ans = min(ans, a);
    }
  }
  if (ans<INF){
    cout << ans << "\n";
  }else {
    cout << "TLE" << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int n,power=1;cin>>n;
    for(int i=1;i<=n;++i) power=((power%MOD)*(i%MOD))%MOD;
    cout<<power;
    return 0;
}
    

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int partition(int *, int, int);

int main(){
  int n = 0, kijyun = 0;
  int i = 0;
  int A[N];
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  kijyun = partition(A, 0, n-1);

  for(i = 0; i < n; i++){
    if(i == kijyun)printf("[%d]",A[i]);
    else printf("%d",A[i]);
    
    if(i < n-1)printf(" ");
    else printf("\n");

  }
  return 0;
}

int partition(int *A, int p, int r){
  int x = 0;
  int i = 0, j = 0;
  int keep = 0;
  
  x = A[r];
  i = p-1;
  
  for(j = p; j < r; j++){
    keep = 0;
    if(A[j] <= x){
      i++;
      
      /*swap A[i] and A[j]*/
      keep = A[i];
      A[i] = A[j];
      A[j] = keep;
      
    }
  }
  
  /*swap A[i+1] and A[r]*/
  keep = 0;
  keep = A[i+1];
  A[i+1] = A[r];
  A[r] = keep;

  return i+1;
}



Measured memory_bytes: 2156
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
char board[12][13];//島のボード
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

void dfs(int a,int b){//幅優先探索で解く。
  board[a][b] ='0';//ボードを書き換える
  for(int i = 0;i < 4;i++){//四方向で調べる
      int nx = a +dx[i];
      int ny = b +dy[i];
      if(nx >= 0&& ny >= 0&& nx <12 && ny <12 && board[nx][ny] == '1'){
	dfs(nx,ny);
      }
    
  }
}


int main()
{
  while(1){
    int ans = 0;
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	cin >> board[i][j];
            }
        }
    if(cin.eof()) break;
  for(int i = 0; i <12;i++){
    for(int j = 0;j <12;j++){
      if(board[i][j] =='1'){
	ans++;
	dfs(i,j);
      }
    }
  }
  cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1140
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  int a,b;
  
  cin >> a >> b;
  
  int sum;
  if(b < 10) 			sum = a*10   + b;
  else if(b < 100) 		sum = a*100  + b;
  else					sum = a*1000 + b;
  
  if(sum == (int)sqrt(sum)*(int)sqrt(sum)) cout << "Yes" << endl;
  else							 cout << "No"  << endl;


 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

std::vector<ll> sieve(ll n) {
  std::vector<ll> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (ll i = 2; i*i < n; ++i) {
    if (res[i] < i) continue;
    for (ll j = i*i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}

std::set<ll> factor(ll n, const std::vector<ll>& min_factor) {
  // min_factor は sieve() で得られたものとする
  std::set<ll> res;
  while (n > 1) {
    res.insert(min_factor[n]);
    n /= min_factor[n];
    // 割った後の値についても素因数を知っているので順次求まる
  }
  return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    const vll min_factor=sieve(1000010);
    vll d(1000010); 
    rep(i,n){
        set<ll> t=factor(a[i],min_factor);
        auto itr=t.begin();
        while(itr!=t.end()){
            d[*itr]++;
            ++itr;
        }
    }
    ll maxf=d[0];
    repi(i,2,1000000){
        maxf=max(maxf,d[i]);
    }
    if(maxf<=1){
        cout<<"pairwise coprime"<<endl;
    }
    else if(maxf!=n){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<pair<int, int>> R(N), B(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &R[i].first, &R[i].second);
  }
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &B[i].first, &B[i].second);
  }
  sort(B.begin(), B.end());

  vector<int> used(N, 0);
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int bx = B[i].first, by = B[i].second;
    int diff = INF, ix = -1;
    for (int j = 0; j < N; ++j) {
      if (used[j]) { continue; }
      if (bx <= R[j].first or by <= R[j].second) { continue; }
      if (by - R[j].second < diff) {
        ix = j;
        diff = by - R[j].second;
      }
    }
    if (ix != -1 ) {
      used[ix] = 1;
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n,m) for (int i = (n); i <= (m); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

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

    int ans = 0;
    int deg = 0;
    rep(i, 1000) {
        deg += x;
        ans++;
        if (deg % 360 == 0) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        for (int i = 0; i < M; ++i) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }

        System.out.println(solve(N, a, b));

        sc.close();
    }

    static int solve(int N, int[] a, int[] b) {
        @SuppressWarnings("unchecked")
        List<Integer>[] adjLists = new List[N];
        for (int i = 0; i < adjLists.length; ++i) {
            adjLists[i] = new ArrayList<>();
        }

        for (int i = 0; i < a.length; ++i) {
            adjLists[a[i]].add(b[i]);
            adjLists[b[i]].add(a[i]);
        }

        return search(adjLists, new boolean[N], N, 0);
    }

    static int search(List<Integer>[] adjLists, boolean[] visited, int rest, int node) {
        if (rest == 1) {
            return 1;
        }

        int result = 0;
        visited[node] = true;
        for (int adj : adjLists[node]) {
            if (!visited[adj]) {
                result += search(adjLists, visited, rest - 1, adj);
            }
        }
        visited[node] = false;

        return result;
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,n;
  cin>>h>>n;
  int i=0;
  if(h%n == 0)
    i=h/n;
  else
    i=(h/n)+1;
  cout<<i<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n=0,x;
    cin>>n>>x;
    int b=0;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<x;i++){
        b=b+a[i];
    }
    cout<<b<<endl;
}


Measured memory_bytes: 3148
url = "https://atcoder.jp//contests/abc093/tasks/abc093_a"

def main():
    t = input()
    alp = ['a', 'b', 'c']
    for a in alp:
        if a in t:
            pass
        else:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
from collections import deque

N, Q = map(int, input().split())

# N個の頂点について、隣接要素を格納
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

# 各piにxiを追加しておく（子要素は見ない）
points = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x

# 答え
result = [0] * N

# 訪れたら1, まだ訪れていなかったら0
visited = [0] * N
visited[0] = 1

# [ [頂点、累計ポイント], [頂点、累計ポイント], ...]
dq = deque([[0, points[0]]])

# 深さ優先探索(DFS)
while dq:
    node, count = dq.pop()
    result[node] = count
    # 今見ている頂点が持つ隣接要素について
    for ni in G[node]:
        # 未訪問の要素がある場合
        if visited[ni] != 1:
            visited[ni] = 1
            dq.append([ni, points[ni] + count])

print(*result)


Measured memory_bytes: 137668
use std::io::Read;


fn input() -> (usize,Vec<i64>,Vec<i64>) {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n:usize = iter.next().unwrap().parse().unwrap();
    let (a,b) = (0..n).map(|_|{
            let a:i64 = iter.next().unwrap().parse().unwrap();
            let b:i64 = iter.next().unwrap().parse().unwrap();
            (a,b)
        }).unzip();
    (n,a,b)
}

fn main() {
    let (n,mut a,mut b) = input();

    if n%2==0 {
        a.iter_mut().for_each(|v|{*v*=2});
        b.iter_mut().for_each(|v|{*v*=2});
    }


    a.sort();
    b.sort();
    let med_a = (a[n/2]+a[(n-1)/2])/2;
    let med_b = (b[n/2]+b[(n-1)/2])/2;
    let res = med_b-med_a+1;
    println!("{}",res);
}



Measured memory_bytes: 9316
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    string s;
    cin>>s;
    ll a=0;
    for(auto x:s)
    {
        if(x=='+')
            a++;
        else
        {
                a--;
        }
        
    }
    cout<<a<<endl;
}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200000+100;
long long a[N]; 
long long siz[N];
long long sum;
set<long long>s;
int main(){
	long long n,num;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]),siz[a[i]]++;
		s.insert(a[i]);
	} 
	for(auto i:s){
		sum+=siz[i]*(siz[i]-1)/2;
	}
	long long tem;
	for(int i=0;i<n;i++){
		tem=sum;
		tem-=siz[a[i]]*(siz[a[i]]-1)/2;
		tem+=(siz[a[i]]-1)*(siz[a[i]]-2)/2;
		cout<<tem<<endl;
	}
	
	
} 

Measured memory_bytes: 10624
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<b){
            int c;
            c=a;
            a=b;
            b=c;
        }
        int r = a%b;
        while(r!=0){
            a=b;
            b=r;
            r=a%b;
        }
        System.out.println(b);
    }
}


Measured memory_bytes: 26256
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <string>
using namespace std;

int main(){
    int A, B, C;
    int fc=0, sc=0;
    cin >> A >> B >> C;
    if(A==5)fc++;
    if(B==5)fc++;
    if(C==5)fc++;
    if(A==7)sc++;
    if(B==7)sc++;
    if(C==7)sc++;
    if(fc==2 && sc==1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

const ll MOD = 1e9 + 7;

int mpow(int base, int exp);
typedef  vector<int> vi;
typedef  vector<ll> vll;
typedef  vector<pair<ll,ll>> vpll;
typedef  vector<pair<int, int>> vpii;
typedef  pair<int, int> pii;
typedef  pair<ll, ll> pll;
typedef  unordered_map<ll, ll> umpll;
typedef  unordered_map<int, int> umpii;
typedef  unordered_map<ll, int> umpli;
typedef  unordered_set<int> usi;
typedef  unordered_set<ll> usll;
typedef  set<int> si;
typedef  set<ll> sll;
typedef  set<pair<int, int>> spii;
typedef  set<pair<ll, ll>> spll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fo(i,n) for(i = 0;i < n; i++)
#define Fo(i,k,n) for(i = k;k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", "<< #z << " = " << z << endl

ll randGen(ll lower, ll upper) { return (rand() % (upper - lower + 1)) + lower; }
ll dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
// cout << fixed;
// cout.precision(10);
//******************          Function here          *********************//

   void test_case(){
      string s;
      cin >> s;
      if(s[s.size() - 1] == 's') s += "es";
      else s += "s";
      cout << s << endl;
   }

//*********************************************************************//

int main()
{
    #ifndef ONLINE_JUDGE
      string inputFile, outputFile;
      inputFile = "input.txt";
      outputFile = "output.txt";
      freopen(inputFile.c_str(), "r", stdin);
      freopen(outputFile.c_str(), "w", stdout);
    #endif

    int t = 1;
    // cin >> t;
    while(t-- > 0){
      test_case();
    }
    return 0;
}



/**********************   Utility Functions  *****************************/
   int mpow(int base, int exp) {
     base %= MOD;
     int result = 1;
     while (exp > 0) {
       if (exp & 1) result = ((ll)result * base) % MOD;
       base = ((ll)base * base) % MOD;
       exp >>= 1;
     }
     return result;
   }
/***********************************************************************/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

struct Gauss 
{
	static const int bits = 60;

	int table[bits];

	Gauss() 
	{
		for(int i = 0; i < bits; i++) 
			table[i] = 0;
	}

	int size() 
	{
		int ans = 0;
		for(int i = 0; i < bits; i++) 
		{
			if(table[i]) 
				ans++;
		}
		return ans;
	}

	bool can(int x) 
	{
		for(int i = bits-1; i >= 0; i--) 
			x = min(x, x ^ table[i]);
		return x == 0;
	}

	void add(int x) 
	{
		for(int i = bits-1; i >= 0 && x; i--) 
		{
			if(table[i] == 0) 
			{
				table[i] = x;
				x = 0;
			} 
			else 
				x = min(x, x ^ table[i]);
		}
	}

	int getBest() 
	{
		int x = 0;
		for(int i = bits-1; i >= 0; i--) 
			x = max(x, x ^ table[i]);
		return x;
	}

	void merge(Gauss &other)
	{
		for(int i = bits-1; i >= 0; i--)
			add(other.table[i]);
	}
};

int n;
int a[N];
Gauss g;

int32_t main()
{
	IOS;
	cin >> n;
	int curXor = 0;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		curXor ^= a[i];
	}
	for(int i = 1; i <= n; i++)
	{
		a[i] = a[i] & (((1LL << 60) - 1) ^ curXor);
		g.add(a[i]);
	}
	cout << curXor + g.getBest() * 2;
	return 0;
}

Measured memory_bytes: 4404
from functools import reduce
n = (int)(input())
a = (list)(map(int, input().split()))


def gcd(a, b):
    # a>b
  while(b):
    c = a % b
    a = b
    b = c
  return a


def calcMod(a, m):
  return sum([m % v for v in a])


def lcm(a, b):
  return a*b/gcd(a, b)


def lcm_list(l):
  g = reduce(lcm, l)
  return g


def mul(a, b):
  return a*b


#print(calcMod(a, (int)(lcm_list(a)-1)))
print(calcMod(a, reduce(mul, a)-1))


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<vector<int>> p(n,vector<int>(10));
  vector<vector<ll>> q(n,vector<ll>(11));
  rep(i,n){
    rep(j,10){
      cin>>p[i][j];
    }
  }
  rep(i,n){
    rep(j,11){
      cin>>q[i][j];
    }
  }

//——————————————bit全探索——————————————
  ll ans=-INF;
  repo(i, (1<<10)){
    ll sum=0;
    vector<int> r(10);
    rep(j,10){
      if(i & (1<<j)) r[j]=1;
    }
    rep(j,n){
      int cnt=0;
      rep(k,10){
        if(p[j][k]&&r[k]) cnt++;
      }
      sum+=q[j][cnt];
    }
    chmax(ans,sum);
  }

  cout << ans << endl;

//——————————————————————————————————————

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL; //番兵のことかーーー！
    int i = 0, j = 0;
    for(int k = left; k < right; k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i++]; //なぜインクリメントするのだろうか。。。
        }else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[],int n,int left,int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int main(){
    int A[MAX],n,i;
    cnt = 0;
    cin >> n;
    for(i = 0; i < n; i++) cin >> A[i];

    mergeSort(A,n,0,n);

    for(i = 0; i < n; i++){
        if(i) cout << " "; //0以外、こりは画期的でやんす
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6892
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

ll gcb(ll a, ll b){/// ユークリッドの互除法: O(log)
    
    if(b == 0) return a;
    
    return gcb(b,a%b);
}


ll lcm(ll a, ll b){
    
    return  a/gcb(a,b) * b; ///gcbは約数
}

int getDigit(ll num){
    return log10(abs(num))+1;
}


int main() {
    int n;cin>>n;vector<int>a(n);cin>>a;
    
    int c = 0;
    
    for(auto i = 1;i<n;i++){
        
        if(a[i] == a[i-1]) {a[i] = -c; c++;}
        
    }
    cout<<c<<endl;
    
    return 0;
}










Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll du[200100];
ll dd[200100];
ll dl[200100];
ll dr[200100];

int main(){
  ll h,w,n;
  cin>>h>>w>>n;
  ll sy,sx;
  cin>>sy>>sx;
  sy--;sx--;
  string s1,s2;
  cin>>s1>>s2;
  // D
  {
    ll p = 0;
    per(i,0,n){
      if(i!=n-1&&s2[i]=='U'){
        p--;
      }
      if(s2[i]=='D')p++;
      dd[i] = p;
    }
  }
  // U
  {
    ll p = 0;
    per(i,0,n){
      if(i!=n-1&&s2[i]=='D'){
        p++;
      }
      if(s2[i]=='U')p--;
      du[i] = p;
    }
  }
  // L
  {
    ll p = 0;
    per(i,0,n){
      if(i!=n-1&&s2[i]=='L'){
        p--;
      }
      if(s2[i]=='R')p++;
      dl[i] = p;
    }
  }
  // R
  {
    ll p = 0;
    per(i,0,n){
      if(i!=n-1&&s2[i]=='R'){
        p++;
      }
      if(s2[i]=='L')p--;
      dr[i] = p;
    }
  }
  // U
  {
    ll p = sy;
    rep(i,0,n){
      if(s1[i]=='U')p--;
      if(p<0){
        cout << "NO" << endl;
        return 0;
      }
      if(s2[i]=='D'){
        if(p+1+dd[i+1]<h){
          p++;
        }
      }
    }
  }
  // D
  {
    ll p = sy;
    rep(i,0,n){
      if(s1[i]=='D')p++;
      if(p>=h){
        cout << "NO" << endl;
        return 0;
      }
      if(s2[i]=='U'){
        if(p-1+du[i+1]>=0){
          p--;
        }
      }
    }
  }
  // L
  {
    ll p = sx;
    rep(i,0,n){
      if(s1[i]=='L')p--;
      if(p<0){
        cout << "NO" << endl;
        return 0;
      }
      if(s2[i]=='R'){
        if(p+1+dr[i+1]<w){
          p++;
        }
      }
    }
  }
  // R
  {
    ll p = sx;
    rep(i,0,n){
      if(s1[i]=='R')p++;
      if(p>=w){
        cout << "NO" << endl;
        return 0;
      }
      if(s2[i]=='L'){
        if(p-1+dl[i+1]>=0){
          p--;
        }
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 7048
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = input()
k = I()
where = 0
while where < len(s):
    if s[where] == '1':
        where += 1
    else:
        break
print('1' if k <= where else s[where])


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

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

	int *a = new int[n];
	int *b = new int[n];

	int *a_sum = new int[n];
	int *b_sum = new int[n];
	for (int a = 0; a < n; a++) {
		a_sum[a] = 0;
		b_sum[a] = 0;
	}

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int ii = 0; ii <= i; ii++) {
			a_sum[i] += a[ii];
		}
	}
	for (int j = 0; j < n; j++) {
		cin >> b[j];
	}
	for (int j = 0; j < n; j++) {
		for (int jj = 0; jj <= j; jj++) {
			b_sum[j] += b[n - 1 - jj];
		}
	}

	int max = 0;
	for (int k = 0; k < n; k++) {
		if (max <= (a_sum[k] + b_sum[n - 1 - k])) {
			max = (a_sum[k] + b_sum[n - 1 - k]);
		}
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for(int tmp = 1; tmp <= a || tmp <= b; tmp++) {
			if(a % tmp == 0 && b % tmp == 0) {
				list.add(tmp);
			}
		}
		System.out.println(list.get(list.size() - c));
	}
}

Measured memory_bytes: 23764
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll mod = 1000000007;

int n,m;
ll a[100005],b[100005];
vector<pair<ll,ll>>vec;
vector<ll>zax,zay;
vector<int>query[100005];
ll ans=1;

struct RMQ{
	#define s (1<<18)
	ll seg[s];
	void update(int k,ll a){
		k+=s/2-1; seg[k]=(seg[k]+a)%mod;
		while(k>0){
			k=(k-1)/2;
			seg[k]=(seg[k*2+1]+seg[k*2+2])%mod;
		}
	}
	ll query(int a,int b,int k,int l,int r){
		if(r<a || b<l || a > b) return 0;
		if(a<=l && r<=b) return seg[k];
		else{
			ll vl=query(a,b,k*2+1,l,(l+r)/2);
			ll vr=query(a,b,k*2+2,(l+r)/2+1,r);
			return (vl+vr)%mod;
		}
	}
}kaede;

int main(){
	scanf("%d%d",&n,&m);
	rep(i,n) scanf("%lld",&a[i]);
	rep(i,m) scanf("%lld",&b[i]);
	
	rep(i,n){
		if(a[i] < b[0] || b[m-1] < a[i]) continue;
		int x = upper_bound(b,b+m,a[i])-b;
		ll L = a[i]-b[x-1];
		ll R = b[x]-a[i];
		vec.pb(mp(L,R));
		zax.pb(L); zay.pb(R);
	}
	zax.pb(-1); zay.pb(-1);
	SORT(zax); ERASE(zax);
	SORT(zay); ERASE(zay);
	SORT(vec); ERASE(vec);

	kaede.update(0,1);
	rep(i,vec.size()){
		int id = POSL(zax,vec[i].fi);
		int id2 = POSL(zay,vec[i].sc);
		query[id].pb(id2);
	}
	repn(i,zax.size()-1){
		vector<ll>ans;
		rep(j,query[i].size()){
			int v = query[i][j];
			ans.pb(kaede.query(0,v-1,0,0,s/2-1));
		}
		rep(j,query[i].size()){
			int v = query[i][j];
			kaede.update(v,ans[j]);
		}
	}
	
	cout << (kaede.query(0,s/2-1,0,0,s/2-1)%mod+mod)%mod << endl;
}

Measured memory_bytes: 11124
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    in_arr(int, a, n);
    int sum = 0;
    rep(i, n - 1){
        if(a[i] == a[i + 1]){
            a[i + 1] = 101;
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

ll powll(ll base,ll power){
    ll ans = 1;
    while (power){
        if (power&1) ans = (base*ans)%mod;
        base = (base*base)%mod;
        power >>= 1;
    }
    return ans;
}

ll facts[1000010],invs[1000010];
signed main(){
    ll n = 1000000;
    ll f = 1;
    facts[0] = 1;
    FOR(i,1,n+1){
        f *= i;
        f %= mod;
        facts[i] = f;
    }
    ll inv = powll(f,mod-2);
    invs[n] = inv;
    REPNS(i,n){
        inv *= i;
        inv %= mod;
        invs[i-1] = inv;
    }
    int x,y;
    cin >> x >> y;
    if ((x+y)%3 != 0 || 2 * x < y || 2 * y < x){
        cout << 0 << endl;
        return 0;
    }
    int move = (x+y) / 3;
    x -= move;
    y -= move;
    int ans = facts[move] * invs[x] % mod * invs[y] % mod;
    cout << ans << endl;
}

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

using namespace std;

const int mod = 1e9 + 7;

int dp[70005], prefiksy[70005];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int> > przedzialy;
    for (int i = 1; i * i <= n; i++){
        int l = n / (i + 1) + 1;
        int r = n / i;
        if ((long long)l * l > n)
            przedzialy.emplace_back(l, r - l + 1);
        przedzialy.emplace_back(i, 1);
    }
    sort(przedzialy.begin(), przedzialy.end());
    n = przedzialy.size();
    for (int i = 0; i < n; i++)
        dp[i] = przedzialy[i].second;
    for (int i = 1; i < k; i++){
        for (int j = 0; j < n; j++)
            prefiksy[j + 1] = ((long long)prefiksy[j] + dp[j]) % mod;
        for (int j = 0; j < n; j++)
            dp[j] = ((long long)prefiksy[n - j] * przedzialy[j].second) % mod;
    }
    int suma = 0;
    for (int i = 0; i < n; i++)
        suma = (long long)(suma + dp[i]) % mod;
    cout << suma << "\n";
    return 0;
}

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

int main(){
  int n; cin>>n;
  int max=1;
  
  for(int i=2;i<10;i++){
    if(n%i==0){max=i;}
  }
  
  if(n/max>=10){cout<<"No";}
  else{cout<<"Yes";}
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int flag=0,a,b,s,f,n;
  cin>>a>>b>>n;
  for(int i=0;i<n;++i){
    cin>>s>>f;
    if(!(f<=a||s>=b)) flag=1;
  }
  cout<<flag<<endl;
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[100005];

int main(void){
    scanf("%d",&n);
    int cnt=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%2==1)cnt++;
    }
    printf("%s\n",(cnt==0)?"second":"first");
    return 0;
}

Measured memory_bytes: 640
/*
 * C.cpp
 *
 *  Created on: 2020/06/14
 *      Author: admin
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;




int main(){
	long X,N;
	cin >> X >> N;

	long P[N];

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

	sort(P, P + SIZE_OF_ARRAY(P));

	long min = 210;
	bool Flag;
	for(int i=101; i>=-1; i--){
		Flag = true;
		for(int m=0; m<N; m++){
			if(i == P[m]){
				Flag = false;
				break;
			}
		}
		if(Flag){
			if (abs(X-i) <= abs(min-X)){
				min = i;
			}
		}
	}
	cout << min;
}




Measured memory_bytes: 3636
n,d = map(int,input().split())
c = 0
a = [[0 for i in range(d)] for i in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))
for i in range(n-1):
    for j in range(i+1,n):
        D = 0
        for k in range(d):
            D += (a[i][k]-a[j][k])**2
        D = D**0.5
        if D.is_integer() == 1:
            c += 1
print(c)

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

long long int k[41] = {};
long long int cnt[41][2] = {};
long long int result[41][2];

long long int getresult(int i, bool alreadyLessThanK)
{
	// alreadyLessThanK : 2^40の位 ~ 2^(i + 1)の位までですでにkより小さくなっているか
	// 2^iの位 ~ 2^0の位のfの最大値

	if(i < 0) return 0;
	if(result[i][alreadyLessThanK] >= 0) return result[i][alreadyLessThanK];

	long long int tmp = (long long int)1 << i;
	if(alreadyLessThanK){
		// すでにkより小さいので01を自由に選んで良い
		return result[i][alreadyLessThanK] = max(cnt[i][0], cnt[i][1]) * tmp + getresult(i - 1, true);
	} else if(k[i] == 0){
		// xとして0を選ばないといけない
		return result[i][alreadyLessThanK] = cnt[i][1] * tmp + getresult(i - 1, false);
	} else {
		// k[i] == 1の場合
		// xとして0も1も選べる
		// 0を選んだ時はalreadyLessThanKがtrueになる
		return result[i][alreadyLessThanK] = max(cnt[i][1] * tmp + getresult(i - 1, true), cnt[i][0] * tmp + getresult(i - 1, false));
	}
}

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

	long long int a[100001];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 40; i >= 0; i--){
		// resultの初期化
		result[i][0] = result[i][1] = -1;

		long long int tmp = (long long int)1 << i;

		// kの初期化
		if(tmpk >= tmp){
			tmpk -= tmp;
			k[i] = 1;
		}
		// cntの初期化
		for(int j = 0; j < n; j++){
			if(a[j] >= tmp){
				cnt[i][1]++;
				a[j] -= tmp;
			} else {
				cnt[i][0]++;
			}
		}
	}
	cout << getresult(40, false) << endl;
}

Measured memory_bytes: 1024
"use strict";
    
const main = arg => {
  	const N = arg.split("\n")[0]*1;
    const Nums = arg.split("\n")[1].split(" ");
  	let ans = 0;
  	for(let i = 0; i < N - 2;  i++){   
    	if(
          ((Nums[i]*1 < Nums[i+1]*1 ) && (Nums[i+1]*1 < Nums[i+2]*1))
          ||
          ((Nums[i]*1 > Nums[i+1]*1 ) && (Nums[i+1]*1 > Nums[i+2]*1))
        )
      	{
        	ans++;
        }
    }
  	console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  
  int c = (a*b)%2;
 
  if (c == 0) {
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
}
  
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main(){
    ll n,a,b,c;cin >>n>>a>>b>>c;
    vector<char> ans;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >>s[i];
    }
    bool flg=true;
    for (int j = 0; j < n; ++j) {
        if(s[j]=="AB"){
            if(a>b){
                a--;b++;
                ans.push_back('B');
            }
            else if(a<b){
                a++;b--;
                ans.push_back('A');
            }
            else {
                if(j==n-1){
                    a--;b++;
                    ans.push_back('B');
                }
                else {
                    if(s[j+1]=="AB"){
                        a++;b--;
                        ans.push_back('A');
                    }
                    if(s[j+1]=="AC"){
                        a++;b--;
                        ans.push_back('A');
                    }
                    if(s[j+1]=="BC"){
                        a--;b++;
                        ans.push_back('B');
                    }
                }
            }
        }
        if(s[j]=="AC"){
            if(a>c){
                a--;c++;
                ans.push_back('C');
            }
            else if(a<c){
                a++;c--;
                ans.push_back('A');
            }
            else {
                if(j==n-1){
                    a--;c++;
                    ans.push_back('C');
                }
                else {
                    if(s[j+1]=="AB"){
                        a++;c--;
                        ans.push_back('A');
                    }
                    if(s[j+1]=="AC"){
                        a++;c--;
                        ans.push_back('A');
                    }
                    if(s[j+1]=="BC"){
                        a--;c++;
                        ans.push_back('C');
                    }
                }
            }
        }
        if(s[j]=="BC"){
            if(b<c){
                b++;c--;
                ans.push_back('B');
            }
            else if(b>c){
                b--;c++;
                ans.push_back('C');
            }
            else {
                if(j==n-1){
                    c--;b++;
                    ans.push_back('B');
                }
                else {
                    if(s[j+1]=="AB"){
                        c--;b++;
                        ans.push_back('B');
                    }
                    if(s[j+1]=="AC"){
                        c++;b--;
                        ans.push_back('C');
                    }
                    if(s[j+1]=="BC"){
                        c--;b++;
                        ans.push_back('B');
                    }
                }
            }
        }
        if(a<0||b<0||c<0)flg=false;
    }
    if(flg){
        puts("Yes");
        for(char v:ans){
            cout <<v<<endl;
        }
    }
    else puts("No");
    return 0;
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if (a + b == 15) {
        cout << "+" << endl;
    } else if (a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
ll n,m,i,j,dp[205][100005],a[205],mod=1e9+7,ans;
int main()
{
	cin>>n>>m;
	rep(i,n) cin>>a[i];
	sort(a+1,a+n+1);
	rep(i,m) dp[1][i]=i%a[1];
	rep(i,n-1) rep(j,m) dp[i+1][j]=(dp[i][j%a[i+1]]+dp[i][j]*i)%mod;
	cout<<dp[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 157184
import java.util.*;
public class Main {

	/*
	 * 122B - 1st Solution
	 * 
	 * Idea is to try all substrings of string s
	 * Every substring is defined from character i to character j
	 * To check if a substring is AGCT is by keeping a boolean good and check whether or not any character has it
	 * If it's good then update the answer if the length of the substring is bigger
	 * The length of the substring is j - i + 1 (+1 because we include the i-th character
	 * 
	 */
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.length();
		int ans = 0;
		for(int i = 0; i<N; i++) {
			for(int j = i; j<N; j++) {
				boolean good = true;
				for(int k = i; k<=j; k++) {
					if(s.charAt(k) != 'A' && s.charAt(k) != 'G' && s.charAt(k) != 'C' && s.charAt(k) != 'T') {
						good = false;
					}
				}
				if(good) {
					ans = Math.max(ans, j - i + 1);
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35604