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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> x(n);
    forn(i, 0, n) {
        cin >> x[i].fs;
        --x[i].fs;
        x[i].sn = i + 1;
    }
    sort(all(x));
    vector<int> st, fn;
    forn(i, 0, n) {
        forn(j, 0, x[i].sn - 1)
            st.eb(x[i].sn);
    }
    forn(i, 0, n) {
        forn(j, 0, n - x[i].sn)
            fn.eb(x[i].sn);
    }
    vector<int> ans(n * n);
    vector<char> ok(n + 1, 0);
    int itx = 0, itst = 0, itfn = 0;
    forn(q, 0, n * n) {
        if (itx < n && x[itx].fs == q) {
            ans[q] = x[itx].sn;
            ok[x[itx].sn] = 1;
            ++itx;
        } else if (itst < st.size() && !ok[st[itst]]) {
            ans[q] = st[itst];
            ++itst;
        } else if (itfn < fn.size() && ok[fn[itfn]]) {
            ans[q] = fn[itfn];
            ++itfn;
        } else {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    forn(i, 0, n * n) cout << ans[i] << ' ';
}


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

int main(void){
	
	int ans,i,j;
	
	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
			
			ans=i*j;
			
			cout<<i<<"x"<<j<<"="<<ans<<endl;
			
		}
}
}

Measured memory_bytes: 1116
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] counts = new int[n + 1];
        for (int i = 1; i < n; i++) {
            counts[sc.nextInt()]++;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= n; i++) {
            sb.append(counts[i]).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 62060
package main

import (
	"fmt"
)

func lastDayOfTheMonth(m1, d1, m2, d2 int) int {
	if m1+1 == m2 {
		return 1
	}
	return 0
}

func main() {
	var m1, d1, m2, d2 int
	fmt.Scan(&m1, &d1)
	fmt.Scan(&m2, &d2)
	fmt.Println(lastDayOfTheMonth(m1, d1, m2, d2))
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int n;cin>>n;
    string s;
    cin>>s;
    int ans=0,mx=0;
    for(int i=0;i<n;i++){
        if(s[i]=='I')ans++;
        else ans--;
        if(ans>mx)mx=ans;
    }
    cout<<mx<<endl;
}

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

int judge(string WordT, string WordH){
	int j = 0;
	int Judge = 0;
	while(j < WordT.size() && j < WordH.size()){
		if(WordT[j] != WordH[j]){
			if(WordT[j] > WordH[j]) Judge = 1;
			if(WordT[j] < WordH[j]) Judge = -1;
			break;
		}
		j++;
	}
	if(Judge == 0 && WordT.size() > WordH.size()) Judge = 1;
	if(Judge == 0 && WordT.size() < WordH.size()) Judge = -1;
	return Judge;
}

int main(){
	//???????????????????????°n????????????
	int n;
	cin >> n;
	//??????????????????????????????????????????
	vector<string> T;
	vector<string> H;
	for(int i = 0; i < n; i++){
		string WordT;
		string WordH;
		cin >> WordT;
		cin >> WordH;
		T.push_back(WordT);
		H.push_back(WordH);
	}
	//????¨???????????¨??????????
	int PointT = 0;
	int PointH = 0;
	for(int i = 0; i < n; i++){
		int Judge = judge(T[i], H[i]);
		if(Judge == 1) PointT +=3;
		if(Judge == 0) PointT++, PointH++;
		if(Judge == -1) PointH +=3;
	}
	//????¨????????????¨?????????
	cout << PointT << " " << PointH << endl;
//	system("pause");
	return 0;
}

Measured memory_bytes: 1324
if __name__ == '__main__':
    n = int(input())
    moji =[[],[' ','.',',','!','?'],['c','a','b'],['f','d','e'],['i','g','h'],['l','j','k'],['o','m','n'],['s','p','q','r'],['v','t','u'],['z','w','x','y']]
    for _ in range(n):
        line = list(input().strip().replace('0',' ').split())
        ans = []
        for i in line:
            m=int(i[0])
            ans.append(moji[m][len(i)%len(moji[m])])
        print(''.join(ans))

Measured memory_bytes: 7604
O = input()
E = input()
t = ""
n = min(len(O), len(E))
for i in range(n):
  t += O[i] + E[i]
if len(O) > len(E):
  t += O[len(O)-1]
elif len(O) < len(E):
  t += E[len(E)-1]
print(t)


Measured memory_bytes: 9084
package main
import (
  "fmt"
  "os"
)
func main() {
  const mod int64 = 1000000007
  var n int
  fmt.Scan(&n)
  if n == 3 {
    fmt.Println(61)
    os.Exit(0)
  }
  var m int64 = 0
  var h []string = []string{"A","C","G","T"}
  var ng []string = []string{"AGCA","AGCC","AGCG","AGCT","ACGA","ACGC",
                            "ACGG","ACGT","GACA","GACC","GACG","GACT",
                            "AAGC","CAGC","GAGC","TAGC","AACG","CACG",
                            "TACG","AGAC","CGAC","GGAC","TGAC","AGGC",
                            "AGTC","ATGC"}
  set := make(map[string]struct{})
  for i:=0;i<26;i++ {
    set[ng[i]] = struct{}{}
  }
  s := map[string]int64{}
  for i:=0;i<4;i++ {
    for j:=0;j<4;j++ {
      for k:=0;k<4;k++ {
        for l:=0;l<4;l++ {
          var t string = h[i]+h[j]+h[k]+h[l]
          s[t] = 1
        }
      }
    }
  }
  for i:=0;i<26;i++ {
    delete(s,ng[i])
  }
  for i:=4;i<n;i++ {
    x := map[string]int64{}
    for u,v := range s {
      for j:=0;j<4;j++ {
        var t string = h[j]+u[0:3]
        if _,ok := set[t]; ok { continue }
        x[t] += v
        x[t] %= mod
      }
    }
    s = x
  }
  for _,v := range s {
    m += v
  }
  fmt.Println(m%mod)
}

Measured memory_bytes: 3840
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();

		int[][] c = new int[h][w];
		for ( int i=0; i<h; i++ ) {
			String c1 = sc.next();
			for ( int j=0; j<w; j++ ) {
				if ( c1.charAt(j)=='#' ) c[i][j] = 1;
			}
		}

		int maxh = 1;
		for ( int i=0; i<h; i++ ) {
			maxh *= 2;
		}
		int maxw = 1;
		for ( int i=0; i<w; i++ ) {
			maxw *= 2;
		}

		int[] row = new int[h];
		int[] column = new int[w];
		int g = 0;
		for ( int i=0; i<maxh; i++ ) {
			getbit(i, row, h);

			for ( int j=0; j<maxw; j++ ) {
				getbit(j, column, w);

				int k1 = 0;
				for ( int p=0; p<h; p++ ) {
				for ( int q=0; q<w; q++ ) {
 					if ( c[p][q]==1 && row[p]==0 && column[q]==0 ) k1++;
				}
				}

				if ( k1==k ) g++;
			}
		}

		System.out.println(g);
	}

	private static void getbit(int num, int[] ary, int sz) {
		int tmp = num;
		for ( int i=sz-1; i>=0; i-- ) {
			ary[i] = tmp%2;
			tmp /= 2;
		}
	}
}


Measured memory_bytes: 36780
/* Filename: B.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {

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

		while (input.hasNext()) {
			int N = input.nextInt();
			int[] a = new int[N + 1];
			
			for(int i = 1; i < a.length; ++i){
				a[i] = input.nextInt();
			}
			
			int friendlyPair = 0;
			for(int i = 1; i < a.length; ++i){
				if(a[a[i]] == i){
					++friendlyPair;
				}
			}
			
			System.out.println(friendlyPair / 2);
		}
	}

}


Measured memory_bytes: 31480
def exhaustivesearch(array):
    length = len(array)
    answers = []
    for i in range(2**length):
        sums = 0
        for j in range(length):
            if ((i >> j)&1):
                sums += array[j]
        answers.append(sums)
    return answers 
n = int(input())
a = list(map(int,input().split()))
ans = exhaustivesearch(a)
q = int(input())
m = list(map(int,input().split()))
for i in m:
    if i in ans:
        print('yes')
    else:
        print('no')


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

int main(){
	int a,b,c,d,e,f;
	while(true){
		b=0;
		cin>>c>>d>>e;
		if((c==0 && d==0) && e==0){
			break;
		}
		for(int i=1;i<=e;i++){
			for(int j=1;j<=e;j++){
				a=(i*(100+c))/100+(j*(100+c))/100;
				if(a==e){
					f=(i*(100+d))/100+(j*(100+d))/100;
					if(b<f){
						b=f;
					}
				}
			}
		}
		cout<<b<<endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> D(N, vector<int>(2));
  
  for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
      cin >> D.at(i).at(j);
    }
  }
  
  bool b = false;
  int c = 0;
  
  for(int i=0;i<N;i++){
    if(D.at(i).at(0) == D.at(i).at(1)){
      c++;
    }
    else{
      c = 0;
    }
      
    if(c == 3){
      b = true;
      break;
    }
  }
  
  if(b){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  vector<int> abc(3); REP(i, 3) cin >> abc[i];
  sort(ALL(abc));
  cout << (abc[0] == abc[1] ? abc[2] : abc[0]) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<ll> calc(ll x){
    vector<ll> vec(40);
    rep(i,0,40){
        ll rem = x + 1;
        vec[i] = rem / (1LL << (i+1)) * (1LL << i);
        rem -= vec[i] * 2;
        vec[i] += max(0LL, rem - (1LL << i)); 
    }
    return vec;
}  
main(){
    ll A,B;
    cin >> A >> B;
    auto va = calc(max(0LL,A-1));
    auto vb = calc(B);
    //rep(i,0,10)cout << va[i] << " \n"[i==9];
    //rep(i,0,10)cout << vb[i] << " \n"[i==9];
    ll ans = 0;
    rep(i,0,40){
        if((vb[i] - va[i]) % 2)ans += 1LL << i;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int n, l;
    string k, ans;
    cin >> n >> l;

    vector<string> v = {};
    for (int i = 0; i < n; ++i) {
        cin >> k;
        v.push_back(k);
    }
    sort(v.begin(), v.end());
    for (const auto &a : v) {
        ans += a;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N, M;

int main()
{
  scanf( "%lld%lld", &N, &M );

  ll x = std::min( N, M/2 );
  N -= x;
  M -= 2*x;

  x += M/4;

  printf( "%lld\n", x );

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int h, w;
	cin >> h >> w;
	
	vector<string> s(h);
	for(int i = 0; i < h; ++i) {
		cin >> s[i];
	}
	
	vector<int> dx = {0, 1, -1, 0}, dy = {1, 0, 0, -1};
	
	bool yes = true;
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			bool ok = false;
			
			if( s[i][j] == '.' ) continue;
			
			else {
				for(int k = 0; k < 4; ++k) {
					if( i + dx[k] < 0 || i + dx[k] >= h || j + dy[k] < 0 || j + dy[k] >= w ) continue;
					
					if( s[i + dx[k]][j + dy[k]] == '#' ) {
						ok = true;
						break;
					}
				}
			}
			
			if( !ok ) {
				yes = false;
				break;
			}
		}
	}
	
	if( yes ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3508
n = int(input())
ta = [list(map(int, input().split())) for x in range(n)]


def fit(a, b):
    for i in range(1000, 1, -1):
        if a%i == b%i == 0:
            return a // i, b // i
    return a, b


def to(a, b, limit):
    cnt = (limit[0] + a - 1) // a
    ac = a * cnt
    bc = b * cnt
    if limit[0] <= ac and limit[1] <= bc:
        return ac, bc

    cnt = (limit[1] + b - 1) // b
    ac = a * cnt
    bc = b * cnt
    if limit[0] <= ac and limit[1] <= bc:
        return ac, bc


now = [1, 1]
for t, a in ta:
    t, a = fit(t, a)
    now = to(t, a, now)
print(sum(now))


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  ll n,k;
  cin >> n >> k;
  vector<vector<ll>> next(n,vector<ll>(70,0));
  rep(i,n)cin >> next[i][0],next[i][0]--;
  rep(j,62){
    rep(i,n){
      next[i][j+1] = next[next[i][j]][j];
    }
  }
  ll now = 0;
  for(int i = 62;i >= 0;i--)if(k >> i & 1)now = next[now][i];
  cout << now+1 << endl;






  

  return 0;
}

Measured memory_bytes: 120476
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
using namespace std;
 
#define ll long long

int main() {
	string S; cin >> S;
	int ans=0, now=0;
	char p[]={'A', 'C', 'T', 'G'};
	for(int i=0; i<S.size(); ++i){
	    bool flag=false;
	    for(int j=0; j<4; ++j) if(p[j]==S[i]) flag=true;
	    if(flag){
	        ++now;
	        ans=max(ans, now);
	    }
	    else now=0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>

using namespace std;

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

	int ans = 0;
	if (k <= a) {
		ans = k;
	}
	else if (k <= a + b) {
		ans = a;
	}
	else {
		k -= a + b;
		ans = a - k;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <math.h>
#include <stdio.h>
int main() {
	int n, m, x;
	scanf("%d%d", &n, &m);
	x = m * 1900 + (n - m) * 100;
	x = x * pow(2, m);
	printf("%d\n", x);
	return 0;
}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] sp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            Console.WriteLine((sp[0] + 1) / 2 >= sp[1] ? "YES" : "NO");
        }
    }
}


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

int main() {
  string s, p;
  bool ok = false;
  cin >> s >> p;
  s +=s;

  rep(i, s.size()) if(s.substr(i, p.size()) == p) ok = true;

  if(ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3236
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let n: usize = get_vec_input()[0];
    let s = get_string_input();
    let target = "ABC";
    let count = (0..n - 2)
        .map(|i| &s[i..i + 3])
        .filter(|x| x == &target)
        .collect::<Vec<_>>()
        .len();
    println!("{}", count);
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d",&a);
	b=a/3600;
	c=(a-3600*b)/60;
	d=a-((b*60+c)*60);
	printf("%d:%d:%d\n",b,c,d);
	return 0;
}


Measured memory_bytes: 2756
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(K):
    visited = [False] * K
    p = 7 % K
    for i in range(K):
        if p == 0:
            return i + 1
        if visited[p]:
            return - 1
        visited[p] = True
        p = (p * 10 + 7) % K


def main():
    # parse input
    K = int(input())
    print(solve(K))


# tests
T1 = """
101
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
4
"""
T2 = """
2
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
-1
"""
T3 = """
999983
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
999982
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 16740
package main

import (
  "fmt"
  "math"
)

func main() {
  var n int
  fmt.Scan(&n)
  t := make([]int, n)
  x := make([]float64, n)
  y := make([]float64, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&t[i], &x[i], &y[i])
  }
  bt, bx, by := 0, 0.0, 0.0
  for i := 0; i < n; i++ {
    distance := int(math.Abs(x[i]-bx) + math.Abs(y[i]-by))
    dt := t[i] - bt
    if distance > dt || distance%2 != dt%2 {
      fmt.Println("No")
      return
    }
    bt, bx, by = t[i], x[i], y[i]
  }
  fmt.Println("Yes")
}

Measured memory_bytes: 5504
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 5005 , P = 1e9 + 7;
inline void pp(int &x,int d) {if((x+=d)>=P)x-=P;}
int n , m , f[N] , g[N];
string s;

int main(){
  cin >> n >> s;
  f[0] = 1;
  rep(i,0,n) {
    rep(i,0,n+1) g[i] = 0;
    rep(j,0,i+1) if(f[j]) {
      pp(g[j + 1] , f[j]);
      if(j) pp(g[j - 1] , 2 * f[j] % P);
      else pp(g[j] , f[j]);
    }
    rep(i,0,n+1) f[i] = g[i];
  }
  printf("%d\n",f[sz(s)]);
  return 0;
}


Measured memory_bytes: 256
while True:
    N, M, P = map(int, raw_input().split())

    if N == 0 and M == 0 and P == 0:
        break

    X = [int(raw_input()) for _ in range(N)]

    print 0 if X[M-1] == 0 else sum(X) * (100-P) / X[M-1] 



Measured memory_bytes: 4636
#include <iostream>
#include <algorithm>
#include <array>

#define RED		0	//RED 	: 1-9
#define GREEN	10	//GREEN : 11-19
#define BLUE	20	//BLUE	: 21-29

#define is_eq(x,y,z) ((x==y)&&(y==z))
#define is_seq(x,y,z) (((x)+1==y)&&((y)+1==z))
#define is_set(x,y,z) (is_eq(x,y,z)||is_seq(x,y,z))

using namespace std;

bool is_3set(array<int, 9> &card)
{
	bool ret = true;
	for(int i=0; i<3 ; i++){
		ret = ret && is_set(card[3*i], card[3*i+1], card[3*i+2]);
	}
	return ret;
}

bool win(array<int, 9> &card)
{
	do{
		if (is_3set(card)) return true;
	}while(next_permutation(card.begin(), card.end()));

	return false;
}

int main(void)
{
	int T;
	cin >> T;
	for(int i=0; i<T; i++){
		array<int, 9> card;
		//カードの番号入力
		for(int j=0; j<9; j++){
			cin >> card[j];
		}
		//カードの色入力
		for(int j=0; j<9; j++){
			char color;
			cin >> color;
			switch(color){
				case 'R':
					card[j] += RED;
					break;
				case 'G':
					card[j] += GREEN;
					break;
				case 'B':
					card[j] += BLUE;
			}
		}
		//識別番号でソート
		sort(card.begin(), card.end());
		//出力
		cout << win(card) << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define pls +
#define mod %
#define E =
#define EE ==
#define le <=
#define ge <=
int mx=9999999;
/**  '' "\n" - ^ **/

class Template{
    public:
    void yes()
    {
        cout<<"Yes\n";
    }

    void no()
    {
        cout<<"No\n";
    }
    void YES()
    {
        cout<<"YES\n";
    }

    void NO()
    {
        cout<<"NO\n";
    }

    void Case(int i,int n)
    {
        cout<<"Case:"<<i<<" "<<n<<endl;
    }
    /**  '' "\n" x ^ **/
    /** printf("\n") */
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a[3],k;
    cin>>a[0]>>a[1]>>a[2]>>k;
    ll sum=0;
    for(int i=0;i<3;i++)
    {
        if(k>a[i])
        {
            if(i==0)sum+=(a[i]);
            if(i==2)sum+=(a[i]*(0 mn 1));
            k=k mn a[i];
        }
        else
        {
            if(i==0)sum+=(k);
            if(i==2)sum+=(k*(0 mn 1));
            k=k mn a[i];
            break;
        }
    }
    pf(sum);
}


Measured memory_bytes: 3608
import copy
S = list(input())

str = list("abcdefghijklmnopqrstuvwxyz")
ans = 1e9

for ch in str:
  if not ch in S:
    continue
  
  T = copy.copy(S)

  L = len(T)
  flg = True
  for i in range(L):
    if T[i] != ch:
      flg = False
      break
      
  if flg:
    print(0)
    exit(0)
    
  for cnt in range(1,100):
    flg = True
    for i in range(L-1):
      if T[i+1] == ch:
        T[i] = ch
      elif T[i] == ch:
        pass
      else:
        flg = False
        
    L -= 1
    #print(T[:L],cnt)
    if flg:
      #print(ch,cnt,ans)
      ans = min(ans, cnt)
      break
      
print(ans)


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  string str;cin>>str;
  int cnt[3]={};
  for(int i=0;i<str.size();i++)
    cnt[str[i]-'a']++;
  int ma=0;
  ma=max(ma,abs(cnt[0]-cnt[1]));
  ma=max(ma,abs(cnt[1]-cnt[2]));
  ma=max(ma,abs(cnt[0]-cnt[2]));
  if(ma<=1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 512
n, a, b = map(int, input().split())

MOD = 10**9 + 7

def comb(n, r, mod):
    if r > n-r:
        r = n - r
    
    res_X = 1
    for i in range(n-r+1, n+1):
        res_X = (res_X * i)%mod
    
    res_Y = 1
    for i in range(1, r+1):
        res_Y = (res_Y * i)%mod
    
    return (res_X * pow(res_Y, mod-2, mod))%mod

base = (pow(2, n, MOD) - 1)%MOD
a = comb(n, a, MOD)
b = comb(n, b, MOD)

print((base - a - b)%MOD)

Measured memory_bytes: 9152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A_Duplex_Printing
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans;
            int n = int.Parse(Console.ReadLine());
            ans = n / 2;
            if (n % 2 != 0)
            {
                ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
int ans=0;
 int R,G,B,N;
  cin>>R>>G>>B>>N;
  for(int i=0;i<=N;i++)
  {
  for(int j=0;j<=N;j++)
  {
  if(N-i*R-j*G<0)break;
    if((N-i*R-j*G)%B==0)ans++;
  }
  }
cout<<ans;
}


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

int main() {
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double x=m/60.00000000000;
  double y=(h*60.0000000000+m)/720.00000000000;
  cout << fixed << setprecision(15);
  cout << sqrt(a*a+b*b-2*a*b*cos(abs((x-y)*2)*pi)) << endl;
}

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

int n,wmax;
int w[101],v[101] ;
ll dp[101][100001] ;


ll bag(int ,int) ;
ll max(ll,ll);

int main()
{
	ll result;
	cin>>n>>wmax;
	for(int i=1;i<=n;i++) cin>>w[i]>>v[i] ;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=wmax;j++)
		dp[i][j]=-1;
	}
	
	result=bag(n,wmax) ;
	cout<<result ;
	return 0;
}

ll bag(int i,int j)
{
	if(dp[i][j]!=-1)
	{
		return(dp[i][j]) ;
	}
	
	if(i==0 || j==0) dp[i][j]=0;
	
	else if(j<w[i]) 
	{
		dp[i][j]=bag(i-1,j) ;
	}
	
    else dp[i][j]=max(bag(i-1,j),v[i]+bag(i-1,j-w[i])) ;
	
	return(dp[i][j]) ;
	
}

ll max(ll a,ll b)
{
	if(a>=b) return a;
	return b ;
}

Measured memory_bytes: 79104
#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(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL 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 inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(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  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
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; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
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; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	string s;
	cin >> s;
	LL n = SI(s) + 1, INF = 1e7;
	s = ">" + s + "<";
	
	vector<LL> v(n, INF);
	inc(i, n) { if(s.substr(i, 2) == "><") { v[i] = 0; } }
	inc(i, n) { if(s.substr(i, 2) == "<<") { v[i] = v[i - 1] + 1; } }
	dec(i, n) { if(s.substr(i, 2) == ">>") { v[i] = v[i + 1] + 1; } }
	inc(i, n) { if(s.substr(i, 2) == "<>") { v[i] = max(v[i - 1], v[i + 1]) + 1; } }
	
	LL ans = 0;
	RF(e, v) { ans += e; }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int loop = sc.nextInt();
		String comnd;
		for(int i=0;i<loop;i++) {
			comnd = sc.next();
			int n,m;
			n=sc.nextInt();
			m=sc.nextInt();
			if(comnd.equals("print")) {

				for(int j=n;j<=m;j++) {
					System.out.print(str.charAt(j));
				}
                System.out.println();
			}else if(comnd.equals("replace")) {

				String rep = sc.next();
				String tmp =str.substring(0, n) + rep + str.substring(m+1,str.length());
				str = tmp;
			}else if(comnd.equals("reverse")) {
				
				StringBuffer sb = new StringBuffer(str.substring(n,m+1));
				
				str = str.substring(0, n) + sb.reverse().toString() + str.substring(m+1,str.length());
			}
		}
		sc.close();

	}

}


Measured memory_bytes: 32704
//nameishere.cpp
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i(0);i<n;i++)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 100-back0000007
#define pb push
#define all(v) v.begin(), v.end()

int dp(int a[], int n, int k){
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	for(int i(2);i<n;i++){
		int mina=INT_MAX;
		for(int x(1);x<=k && x<=i;x++){
			mina = min(mina, dp[i-x] + abs(a[i-x] - a[i]));
		}
		dp[i] = mina;
	}
	return dp[n-1];
}

int32_t main() {
    fast;
    
    
	int n,k;
	cin>>n>>k;
	int h[n];
	rep(i,n)cin>>h[i];
	cout<<dp(h,n,k);


	return 0;
}


Measured memory_bytes: 1792
N=int(input())

H=[]
c=0
t=0
for i in range(N):
    h=list(input())
    h.sort(reverse=False)
    H.append(h)

H.sort(reverse=False)

for j in range(N-1):
    
    if H[j]==H[j+1]:
        c+=1

    else:
        t+=int((c)*(c+1)/2)
        c=0

if c:
    t+=int(((c)*(c+1)/2))
        

print(t)


Measured memory_bytes: 24652
#include<bits/stdc++.h>
using namespace std;
const int mxN = 2e5+10;
vector<vector<int> > edges(mxN);
vector<bool> visited(mxN);
int Max, sz;
void dfs(int node){
    visited[node] = true;
    sz++;
    for(auto child : edges[node]){
        if(!visited[child]){
            dfs(child);
        }
    }
    return;
}
int main(){
    int n;
    cin >> n;
    int m;
    cin >> m;
    Max = 0;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(!visited[i]){
            sz = 0;
            dfs(i);
            Max = max(Max, sz);
        }
    }
    cout << Max << "\n";
    return 0;
}

Measured memory_bytes: 20380
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{int a,b,c;
 bool ok;
 cin>>a>>b;
 if (b/100==0 and b/1>10)
 c=100;
 if (b/100==1)
 c=1000;
 if (b/1<10)
 c=10;
 for (int i=1;i<=a*c+b;i++){
 if (a*c+b==i*i){
 ok=true;
 cout<<"Yes";
 system("pause");
 return 0;}
 else {ok=false;}}
 if (!ok)
 cout<<"No"; 
 system("pause");
 return 0;
}        

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define ll long long

using namespace std;



int main()
{
    ll a,b,c;  cin >> a >> b >> c;
    if(c <= (a + b))  cout << "No";
    else  cout << ((4 * a * b) < ((c - b - a) * (c - b - a)) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int n; cin >> n;
    n--;

    cout << a[n] << endl;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

const int mod = 998244353;

struct segment_tree
{
    int n;
    vector<int> a;

    segment_tree(int n) : n(n), a(2 * n, -1) {}

    void update(int p, int v)
    {
        for (a[p += n] = v; p /= 2;)
            a[p] = max(a[2 * p], a[2 * p + 1]);
    }

    int query(int l, int r)
    {
        int g = -1;

        for (l += n, r += n; l < r; l /= 2, r /= 2)
        {
            if (l & 1) g = max(g, a[l++]);
            if (r & 1) g = max(g, a[--r]);
        }

        return g;
    }
};

inline void add(int &x, int y)
{
	x += y;
	if (x >= mod)
		x -= mod;
}

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

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

	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	for (auto &i : a) cin >> i.F >> i.S;
	sort(a.begin(), a.end());

	vector<int> dp(n+1);
	dp[n] = 1;
	segment_tree st(n+1);
	for (int i = n-1; i >= 0; --i)
	{
		auto j = lower_bound(a.begin(), a.end(), make_pair(a[i].F + a[i].S - 1, 1<<30)) - a.begin();
		int go = j;
		go = max(go, st.query(i, j));
		add(dp[i], dp[i+1]);
		add(dp[i], dp[go]);
		st.update(i, go);
	}
	cout << dp[0] << "\n";

	return 0;
}


Measured memory_bytes: 4224
use std::io;

fn main() {
    let mut first_line = String::new();
    let mut second_line = String::new();

    io::stdin().read_line(&mut first_line).unwrap();
    io::stdin().read_line(&mut second_line).unwrap();

    if second_line.find("Y").is_some() {
        println!("Four")
    } else {
        println!("Three")
    }
}

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

using namespace std;

int main() {
    int a[5];

    for(int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    
    int ans = 1000000;
    do{
        int sum = 0;
        int total = 0;
        for(int i = 0; i < 4; i++)
        {
            total += a[i];
            total += (a[i] % 10 == 0) ? 0 : 10 - (a[i] % 10);
        }
        ans = min(ans, total + a[4]);
    }while (next_permutation(a, a + 5));
        
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long n, std::vector<long long> p)
{
    int ans = 0;
    for (int i = 1; i < n-1; i++)
    {
        vector<ll> a = {p[i - 1], p[i], p[i + 1]};
        SORT(a);
        if(a[1] == p[i]){
            ans++;
        }
    }   
    cout << ans << endl;
    return;
}

int main()
{
    long long n;
    scanf("%lld", &n);
    std::vector<long long> p(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &p[i]);
    }
    solve(n, std::move(p));
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector <long long> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int b,e;
        cin>>b>>e;
        reverse(a.begin()+b,a.begin()+e);
    }
    int j;
    for(j=0;j<n-1;j++)
    {
        cout<<a[j]<<" ";
    }
    cout<<a[j]<<endl;
    return 0;
}



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

int main(){
  int N,mod=1e9+7;
  cin >> N;
  vector<int> A(N);
  long long sum=0,res=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  }
  for(int i=0;i<N;i++){
    sum-=A.at(i);
    long long B=sum%mod;
    long long C=B*A.at(i)%mod;
    res=(res+C)%mod;
  }
  cout << res << endl;
}
    

Measured memory_bytes: 4024
#include<iostream>

using namespace std;

long long int n;
long long int answer = 0;
long long int cell[6];
long long int tmp;

int main(){
  cin >> n;
  tmp = n;
  for(int i = 0; i < 5; ++i){
    cin >> cell[i];
    answer += 1;
  }
  for(int i = 0; i < 5; ++i){
    if(cell[i] < tmp){
      /*
      if((tmp % cell[i]) != 0){
        answer += (tmp / cell[i]);
      }else{
        answer += (tmp / cell[i]) - 1;
      }
      */
      tmp = cell[i];
    }
  }
  if(n > tmp){
    if(n % tmp != 0){
      answer += (n / tmp);
    }else{
      answer += (n / tmp) - 1;
    }
    
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;

//main
int main(){
    double W, H, x, y; cin >> W >> H >> x >> y;
    int judge;
    if(W/2 == x && H/2 == y) judge = 1;
    else judge = 0;
    cout << W*H/2 << " " << judge << endl;
}



Measured memory_bytes: 256
import java.lang.Math.*
import kotlin.math.pow
import kotlin.math.sqrt

fun main(args: Array<String>) {
    val n = readLong()
    var cnt = 0
    var soinsu = mutableListOf<Long>()
    var divs = mutableSetOf<Long>()



    var a = n
    val sqrt = sqrt(n.toDouble()).toLong()
    for (i in 2 until sqrt + 1) {
        while (a % i == 0L) {
            soinsu.add(i)
            divs.add(i)
            a /= i
        }
    }

    if (a > 1) {
        soinsu.add(n)
        divs.add(n)
    }

    for (i in divs) {
        var b = soinsu.count { it == i }
        var c = 1
        while (c <= b) {
            cnt++
            b -= c
            c++
        }
    }
    println(cnt)

}

private fun myPow(a: Long, b: Int): Long {
    var x = a
    for (i in 1 until b) {
        x *= a
    }
    return x
}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



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

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

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
int main() 
{
    long double w, h, x, y;
    cin >> w >> h >> x >> y;
    if(x == w / 2 && y == h / 2) {
        cout << fixed << setprecision(9) << (w * h) / 2 << ' ' << 1;
    } else {
        cout << fixed << setprecision(9) << (w * h) / 2 << ' ' << 0;
    }
    return 0;
} 


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define foreach(a,A) for(auto &a:A)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n, k; cin >> n >> k;
    ll max_kind = 0;
    priority_queue<pll> heap;
    rep(_, n){
        ll t, d; cin >> t >> d;
        t--;
        heap.emplace(d, t);
        chmax(max_kind, t + 1);
    }
    auto counter = make_vector(max_kind, (ll)0);
    ll score = 0;
    priority_queue<pll, vector<pll>, greater<pll>> candidate;
    rep(_, k){
        ll t, d; tie(d, t) = heap.top(); heap.pop();
        counter[t] ++;
        score += d;
        candidate.emplace(d, t);
    }
    ll kind = 0;
    foreach(cnt, counter){
        kind += (cnt > 0);
    }
    score += kind * kind;
    ll res = score;

    while(!heap.empty() and !candidate.empty()){
        bool flag = false;
        while(!candidate.empty()){
            ll tmp_t, tmp_d; tie(tmp_d, tmp_t) = candidate.top(); candidate.pop();
            if(counter[tmp_t] <= 1) continue;
            counter[tmp_t] --;
            score -= tmp_d;
            flag = true;
            break;
        }
        if(!flag) break;
        flag = false;
        while(!heap.empty()){
            ll tmp_t, tmp_d; tie(tmp_d, tmp_t) = heap.top(); heap.pop();
            if(counter[tmp_t]) continue;
            counter[tmp_t] ++;
            kind ++;
            score += tmp_d;
            flag = true;
            break;
        }
        if(flag){
            score -= (kind - 1) * (kind - 1);
            score += kind * kind;
            chmax(res, score);
        }
    }


    cout << res << endl;
}

Measured memory_bytes: 5744
i = gets.to_i
ary = gets.split(" ").map(&:to_i)
count =0
(0..i-3).each do |n|
    if ary[n] < ary[n + 1] && ary[n + 1] < ary[n + 2]
            count +=1
    elsif ary[n] > ary[n+1] && ary[n+1] > ary[n +2]
            count +=1
    end
end
puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std; 
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define N (ll)2e5+10 




int main(){
    
    ios::sync_with_stdio(0);
    
    int n ,i , j , ans =0  ;
    cin >>  n ;
    int a[n] ;
    for(i=0 ; i<n ; i++){
    	cin >> a[i] ;
    }
    sort(a , a+n) ;
    
    for(i=0 ; i<n ; i++){
      for(j=i+1 ; j<n ; j++){
      	 int p = lower_bound(a, a+n ,a[i]+a[j] ) - a ;
      	 if(p==n || a[p]>=a[i]+a[j])p-- ;
      	 
      	 ans += (p-j) ;
      }
    }

    cout << ans ;

    return 0 ;
 }

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

int main(){
    string S;
    cin>>S;

    string keye="keyence";

    int i=0;

    for( i=0;i<keye.size();++i){
        if(S[i]!=keye[i]){
            break;
        }
    }

    for(;i<keye.size();++i){
        if(S[S.size()-(keye.size()-i)]!=keye[i]){
            cout<<"NO"<<endl;  
            return 0;
        }
    }

    cout<<"YES"<<endl;



}

Measured memory_bytes: 256