akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair

#define shosu(X) setprecision(X) << fixed
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	long double a,b,c;
	cin >> a >> b >> c;
	/*to radian*/
	c = M_PI *c / 180;
	cout << shosu(20) << a*b*sin(c)/2<< endl;;
	long double tmp = sqrt(a*a+b*b-2*a*b*cos(c));
	cout << a+b+tmp << endl;;
	cout << b*sin(c) << endl;
}

Measured memory_bytes: 1296
#include<stdio.h>
int main(){
  long int i,a,b,len,ta,tb;
  scanf("%ld %ld",&a,&b);
  len = (a>b) ? a : b;
  for(i=0;i<len;i++){
    ta = (a-i>0) ? a-i : i-a;
    tb = (b-i>0) ? b-i : i-b;
    if(ta==tb){
      printf("%ld\n",i);
      return 0;
    }
  }
  printf("IMPOSSIBLE\n");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>  
using namespace std;  
int main()  
{  
    long long int x,t;  
    cin>>x>>t;  
    if(x-t==0)  
    {  
        cout<<0<<endl;  
    }  
    if(x-t>0)  
    {  
        cout<<x-t<<endl;  
    }  
    if(x-t<0)  
    {  
        cout<<0<<endl;  
    }  
    return 0;  
}  

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  //input
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  //集計numa[x] を用意
  const int NMAX = 200010;
  vector<int> numa(NMAX);
  REP(i,n){
    numa[a[i]]++;
  }
  //sumの計算
  ll sum = 0;
  REP(i,NMAX){
    if(numa[i] == 0) continue;
    int na = numa[i];
    sum += (ll)na*(na-1)/2;
  }

  //各数字について出力　先に計算すると定数倍早いけど必要ない
  REP(i,n){
    int na = numa[a[i]];
    if(na == 1){
      cout << sum << endl;
    }
    else{
      ll sum2 = sum - na*(na-1)/2 + (na-1)*(na-2)/2;
      cout << sum2 << endl;
    }
  }
  return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b;
    char op;
    while (true) {
        cin >> a >> op >> b;
        if (op == '+') cout << a+b <<  endl;
        else if(op == '-') cout << a-b <<  endl;
        else if(op == '*') cout << a*b <<  endl;
        else if(op == '/') cout << a/b <<  endl;
        else if(op=='?') break;
    }
    
    return 0;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,sum=0;
    c_p_c();
    string s,str;
    cin>>s>>str;
    for (int i = 0; i < max(s.size(),str.size()); ++i)
    {
    	/* code */
    	if(i<s.size())
    		cout<<s[i];
    	if(i<str.size())
    		cout<<str[i];
    }
    
 	return 0;

   }

Measured memory_bytes: 3584
# coding: utf-8
# Your code here!

from collections import deque
def diameter(g):
    def bfs(start): # v からの最長点と距離を求める
        q = deque([(0,start,-1)])
        while q:
            d,v,p = q.popleft()
            for c in g[v]:
                if c == p: continue
                q.append((d+1,c,v)) #重みつきのときはm+1でなく m+cost(v,c)
        return (d,v)

    d0,v0 = bfs(0)
    d1,v1 = bfs(v0)
    return d1 # i0, i1 が最遠頂点対


##################################################
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
n = int(input())
#n,q = [int(i) for i in readline().split()]
 
g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

d = diameter(g)
if d%3 != 1:
    print("First")
else:
    print("Second")
    
    
    
    







Measured memory_bytes: 57140
n = int(input())
arr = list(map(int, input().split()))

c = 0
h = set([])

for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      t = [arr[i], arr[j],arr[k]]
      t.sort()
      if t[0] + t[1] > t[2]:
        if t[0]!=t[1]!=t[2]:#if (i,j,k) not in h:
          h.add((i,j,k))
          c+=1
        
print(c)

Measured memory_bytes: 99580
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String str = sc.next();
    int count = 0;
    for(int i = 0; i < n-2;i++){
      if(str.charAt(i)=='A'){
        if(str.charAt(i+1)=='B'){
          if(str.charAt(i+2)=='C'){
            count++;
          }
        }
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#define swap(a, b, type) {type t; t=a; a=b; b=t;}

typedef struct {
  int num;
  char suit;
} CARD;

char getSuit(CARD *card);
int getNumber(CARD *card);
void setSuit(CARD *card, char suit);
void setNumber(CARD *card, int num);
void printCard(CARD *card);
int compCard(CARD *c1, CARD *c2);
CARD *createCard();
void deleteCard(CARD *card);

int main()
{
  int i, j, n, num, flg, min, stable;
  char suit;
  scanf("%d", &n);
  CARD **card1 = (CARD **)malloc(sizeof(CARD *) * n);
  CARD **card2 = (CARD **)malloc(sizeof(CARD *) * n);
  for(i=0; i<n; i++){
    scanf(" %c%d", &suit, &num);
    card1[i] = createCard();
    setSuit(card1[i], suit);
    setNumber(card1[i], num);
    card2[i] = createCard();
    setSuit(card2[i], suit);
    setNumber(card2[i], num);
  }

  //bubble sort
  flg=1;
  while(flg){
    flg=0;
    for(i=n-1; i>0; i--){
      int n1 = getNumber(card1[i-1]);
      int n2 = getNumber(card1[i]);
      if(n1 > n2){
        swap(card1[i-1], card1[i], CARD*);
        flg=1;
      }
    }
  }

  for(i=0; i<n; i++){
    if(i>0) putchar(' ');
    printCard(card1[i]);
  }
  printf("\nStable\n");

  //Selection sort
  for(i=0; i<n-1; i++){
    min = i;
    for(j=i; j<n; j++){
      int n1 = getNumber(card2[min]);
      int n2 = getNumber(card2[j]);
      if(n1 > n2){
        min = j;
      }
    }
    swap(card2[i], card2[min], CARD*);
  }

  stable = 1;
  for(i=0; i<n; i++){
    if(i>0) putchar(' ');
    printCard(card2[i]);
    if(!compCard(card1[i], card2[i])) stable = 0;
  }
  printf(stable ? "\nStable\n" : "\nNot stable\n");

  return 0;
}

char getSuit(CARD *card)
{
  return card->suit;
}
int getNumber(CARD *card)
{
  return card->num;
}

void setSuit(CARD *card, char suit)
{
  card->suit = suit;
  return;
}
void setNumber(CARD *card, int num)
{
  card->num = num;
  return;
}

void printCard(CARD *card)
{
  printf("%c%d", getSuit(card), getNumber(card));
  return;
}

int compCard(CARD *c1, CARD *c2)
{
  if(getSuit(c1) != getSuit(c2)) return 0;
  if(getNumber(c1) != getNumber(c2)) return 0;
  return 1;
}

CARD *createCard()
{
  CARD *new;
  new = (CARD *)malloc(sizeof(CARD));
  return new;
}
void deleteCard(CARD *card)
{
  if(card != (CARD *)NULL)
    free(card);
  return;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int a,b,c;
	cin>>a>>b>>c;
	int z=0;
	cout<<max(z,c-(a-b));
	
	








	
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Og")
#pragma GCC push_options
#pragma GCC pop_options
bool S[1000000];
int p[10000000];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, a, WA = 0, AC = 0;
    string s;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> s;
        if (S[a] == false)
        {
            if (s == "WA")
                p[a]++;
            else
            {
                AC++;
                S[a] = true;
            }
        }
    }
    for (int i = 0; i <= n; i++)
    {
        if (S[i] == true)
            WA += p[i];
    }
    cout << AC << " " << WA;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define M 1000000007
#define eb emplace_back
#define watch(x) cout << (#x) <<" is "<< x <<"\n";


using namespace std;
//const int N = 1e6;

int32_t main(){
  boost;
  int tc = 1; //cin >> tc;
  while(tc--)
  {
    string s, t; cin >> s >> t;
    int ans = 0;
    for(int i=0; i<s.size(); i++)
    {
      if(s[i] != t[i])
        ans++;
    }
    cout << ans <<"\n";
  }
}



Measured memory_bytes: 3792
import sys

sys.setrecursionlimit(100000)

N=int(input())
tree_dict={i:0 for i in range(N)}
tree_map=[[] for i in range(N)]
start=set([i for i in range(N)])

edge=[]

#数字の若いほうから見ていくとする
for i in range(N-1):
    u,v,w = map(int, input().split())
    tree_map[u-1].append([v-1,w])
    tree_map[v-1].append([u-1,w])

def fill(index, now_color, dist):
    for v,w in tree_map[index]:
        
        if tree_dict[v] == 0:
            if w%2==0:
                tree_dict[v] = now_color
                fill(v, tree_dict[v], w)
            else:
                tree_dict[v] = -1*now_color
                fill(v, tree_dict[v],w)


now_color=1
tree_dict[0]=now_color
fill(0,now_color, 0)

for i in tree_dict.values():
    if i==-1:
        print(0)
    else:
        print(1)

Measured memory_bytes: 100624
n, a, b = (int(i) for i in input().split())
ans = 0
for i in range(1, n+1):
    A = str(i)
    _sum = 0
    for c in A:
        _sum += int(c)
        
    if _sum >= a and _sum <= b:
        ans += i
print(ans)


Measured memory_bytes: 2940
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      s: chars,
    }

    let n = s.len();
    let mut l = 0;
    let mut r = n-1;
    let mut ans = 0;
    while l < r {
        let lc = s[l];
        let rc = s[r];
        if lc == rc {
            l += 1;
            r -= 1;
        } else if lc == 'x' {
            l += 1;
            ans += 1;
        } else if rc == 'x' {
            r -= 1;
            ans += 1;
        } else {
            return puts!("{}\n", -1);
        }
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>

//構造体を利用
//最も身長の高い人を出力
int main(void)
{
	int a;		
	int b;
	char op[2];
	int iCount=0;
	int iResult[1000];
	int iRoop;

	scanf("%d", &a);
	scanf("%s", op);
	scanf("%d", &b);



	while (strcmp(op, "?") != 0)
	{
		if (strcmp(op, "+") == 0)
		{
			iResult[iCount] = a + b;
		}
		else if (strcmp(op, "-") == 0)
		{
			iResult[iCount] = a - b;
		}
		else if (strcmp(op, "*") == 0)
		{
			iResult[iCount] = a * b;
		}
		else if(strcmp(op, "/") == 0)
		{
			iResult[iCount] = a / b;
		}
		else
		{
			printf("error");
			break;
		}
		iCount++;
		scanf("%d", &a);
		scanf("%s", op);
		scanf("%d", &b);
	}

	for (iRoop = 0; iRoop < iCount; iRoop++)
	{
		printf("%d\n",iResult[iRoop]);
	}

	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdio>
using namespace std;
#define loop(i,n) for (int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define VEC vector<int>
// vector<VEC> v (n, VEC(n))
static const int INF = 1e9;
int main()
{
	int n, m; cin >> n >> m;
	VEC d(n);
	loop(i, n)cin >> d[i];
	VEC c(m);
	loop(i, m)cin >> c[i];
	int dp[1001][1001];
	loop(i, 1001)loop(j, 1001)dp[i][j] = INF;
	loop(i, m)dp[0][i] = 0;
	loops(i, 1, n + 1)loop(j, m)dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + d[i - 1] * c[j]);
	int ans = INF;
	loop(i, m)ans = min(ans, dp[n][i]);
	printf("%d\n", ans);
	return 0;
}

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

struct dice{
    int x[6];
    void roll(char c){
        int a;
        if(c=='N'){
            a=x[0];
            x[0]=x[1];
            x[1]=x[5];
            x[5]=x[4];
            x[4]=a;
        }
        if(c=='S'){
            a=x[0];
            x[0]=x[4];
            x[4]=x[5];
            x[5]=x[1];
            x[1]=a;
        }
        if(c=='E'){
            a=x[0];
            x[0]=x[3];
            x[3]=x[5];
            x[5]=x[2];
            x[2]=a;
        }
        if(c=='W'){
            a=x[0];
            x[0]=x[2];
            x[2]=x[5];
            x[5]=x[3];
            x[3]=a;
        }
    }
    int top(void){
        return x[0];
    }
};

int main(){
    dice d,d2;
    for(int i=0; i<6; ++i)cin>>d.x[i];
    for(int i=0; i<6; ++i)cin>>d2.x[i];
    string s="ENESNESNESNESENESNESNESNESENESNESNESNESENESNESNESNESNNESNESNESNESNNESNESNESNES";
    int n=s.size();
    bool ok=false;
    for(int i=0; i<n; ++i){
        d.roll(s[i]);
        bool ng=false;
        for(int j=0; j<6; ++j){
            if(d.x[j]!=d2.x[j])ng=true;
        }
        if(!ng)ok=true;
    }
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a>b?b:a;}




int main(void) {
  ll N;
  cin >> N;
  string s;
  cin >> s;
  ll i;
  
  ll bl=0, wl=0;
  ll br=0, wr=0;
  
  for(i=0; i<N; i++) {
    if(s[i]=='.') wr++;
    if(s[i]=='#') br++;
  }
  
  
  ll ans=bl+wr;
  for(i=0; i<N; i++) {
    if(s[i]=='.') {
      wl++;
      wr--;
    }
    if(s[i]=='#') {
      bl++;
      br--;
    }
    
    chmin(ans, bl+wr);
    
  }
  
  pt(ans);
  
}






Measured memory_bytes: 640
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 600000 
#define MAXCARDS 100000
#define MAXNUM 100000
int alNumber[MAXCARDS];
int alTimes[MAXNUM];
char sInput[MAX_STRING];
int compare(const int *val1, const int *val2);

int main() {

	char* psInput;
	int l=0;
	int i=0;
	int j=0;
	int lTemp2=0;
	int lKinds=0;
	int  lCardsNumber =0;
	int  lMax = 0;
	int  lTop = 0;
	int  lSecond = 0;
	int  lSquare = 0;
	int  lTarget=0;
	int  lFound=0;
	int  lAnswer=0;
	int  lTimes=0;
	int  lNumber=0;
	int  lBefore=0;
	int  lCount=0;
	int nFlag=0;

	// read line 1
	gets(sInput);
	lCardsNumber = atol(sInput);
	//format
	for (i=0;i<MAXNUM;i++){
		alNumber[i]=-1;
		alTimes[i]=0;
	}
	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<lCardsNumber;i++){
		lTemp2=atol(psInput);
		alNumber[i]=lTemp2;
		if(lMax<lTemp2){
			lMax=lTemp2;
		}
		psInput = strtok(NULL," ");
	}
    qsort(alNumber, lCardsNumber, sizeof(int),
        (int (*)(const void *, const void *))compare
    );

	for (i=0;i<=lMax;i++){
		lCount=0;
		while(j<lCardsNumber && alNumber[j]==i){
			lCount++;
			j++;
		}
		alTimes[i]=lCount;
	}
	if(lMax>=2){
		for (i=2;i<=lMax;i++){
			lTemp2=alTimes[i-2]+alTimes[i-1]+alTimes[i];
			if (lAnswer<lTemp2){
				lAnswer=lTemp2;
			}
		}
	} else {
		lAnswer=alTimes[0];
		if(lMax==1){
			lAnswer=lAnswer+alTimes[1];
		}
	}

	printf("%d\n",lAnswer);

    return 0;
}

int compare(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

Measured memory_bytes: 1916
#include <cstdio>
#include <algorithm>

using namespace std;

using ll = long long int;


int main(){
    ll a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);

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

    return 0;
}

Measured memory_bytes: 1736
#!/usr/bin/env python3
import sys

YES = "Possible"  # type: str
NO = "Impossible"  # type: str

def solve(N: int, L: int, a: "List[int]"):
    pair_length = [a[i] + a[i+1] for i in range(N-1)]
    longest_pair = max(pair_length)
    
    if longest_pair < L:
        print(NO)
        return
    
    print(YES)
    last_knot = pair_length.index(longest_pair)
    for i in range(last_knot):
        print(i+1)
    for i in range(N-2, last_knot-1, -1):
        print(i+1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, L, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20056
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){

    ll N;
    cin >> N;
    if(N == 2){
        cout << 1 << "\n";
        return 0;
    }

    int c = 1;
    for(ll i = 2; i * i <= N; i++){
        if(N % i == 0){
            ll n = N;
            while(n % i == 0)
                n /= i;
            n %= i;
            if(n == 1)
                c++;
            
            ll j = N / i;
            if(j == i) continue;
            n = N;
            while(n % j == 0)
                n /= j;
            n %= j;
            if(n == 1)
                c++;
        }
    }
    N--;
    for(ll i = 2; i*i <= N; i++){
        if(N % i == 0){
            c++;
            ll j = N / i;
            if(j != i) c++;
        }
    }
    c++;

    cout << c << "\n";
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
signed main(){
	int a,b=0,c,cnt=0,ans=0;
	cin>>a;
	f(i,a){
		cin>>c;
		if(b>=c)cnt++;
		else{
			ans=max(ans,cnt);
			cnt=0;
		}
		b=c;
	}
	ans=max(ans,cnt);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import numpy as np
n,k = map(int,input().split())
h = np.array(list(map(int, input().split())))
dp = np.array([np.inf] * n)
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    if i-k > 0:
        dp[i] = min(dp[i-k:i]+abs(h[i]-h[i-k:i]))
    else:
        dp[i] = min(dp[0:i]+abs(h[i]-h[0:i]))
print(int(dp[n-1]))

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

int main(){
  int n;
  string s, t;
  cin >> n >> s >> t;
  string mix = "";
  for (int i=0; i<n; i++){
    mix = mix + s.at(i) + t.at(i);
  }
  cout << mix << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <queue>
#include <cstdio>
#include <algorithm>

using namespace std;

const int N=1e5+10;

int n,f[N];
set<int>B[N],R[N];
queue< pair<int,int> >Q;

void Init()
{
	scanf("%d",&n);
	int a,b;
	for (int i=1;i<n;++i)
	{
		scanf("%d%d",&a,&b);
		B[a].insert(b); B[b].insert(a);
	}
	for (int i=1;i<n;++i)
	{
		scanf("%d%d",&a,&b);
		R[a].insert(b); R[b].insert(a); 
		if (B[a].count(b)) Q.push(make_pair(a,b));
	}
}

int find(int a) { return a==f[a]?a:f[a]=find(f[a]); }

void Union(int x,int y)
{
	if (R[x].size()>R[y].size()) swap(x,y);
	f[x]=y;
	for (auto a:R[x]) if (B[a].count(y)) Q.push(make_pair(a,y));
	for (auto a:B[x]) if (R[a].count(y)) Q.push(make_pair(a,y));
	for (auto a:R[x]) { R[a].erase(x); R[a].insert(y); R[y].insert(a); }
	for (auto a:B[x]) { B[a].erase(x); B[a].insert(y); B[y].insert(a); }
}

void Solve()
{
	for (int i=1;i<=n;++i) f[i]=i;
	int cnt=0;
	while (!Q.empty())
	{
		int x=Q.front().first,y=Q.front().second; Q.pop();
		x=find(x); y=find(y);
		if (x==y)  continue;
		++cnt;
		R[x].erase(y); R[y].erase(x); B[x].erase(y); B[y].erase(x);
		Union(x,y);
	}
	if (cnt==n-1) printf("YES\n");
	else printf("NO\n");
}

int main()
{
	Init();
	Solve();
	return 0;
}

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

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for(ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for(ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007 
#define MAXR 100000 

signed main() {
    ll A, B, C, K; cin >> A >> B >> C >> K;

    if (A >= K) {
        cout << K << endl;
        return 0;
    } else {
        K -= A;
    }

    if (B >= K) {
        cout << A << endl;
        return 0;
    } else {
        K -= B;
    }

    if (C >= K) {
        cout << A - K << endl;
    } else {
        cout << A - C << endl;
    }
}

Measured memory_bytes: 3644
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
Mod = 1000000007




def main(): #startline--------------------------------------------
    N,M = map(int,input().split())
    AB = [list(map(int,input().split())) for i in range(N)]
    AB.sort(reverse = True)
    heap = []
    ans = 0
    for i in range(1,M+1):
        while AB and AB[-1][0]<=i:
            heappush(heap,-AB.pop()[1])
        if heap:
            ans -= heappop(heap)
    print(ans)
        
if __name__ == "__main__":
    main() #endline===============================================





def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

Measured memory_bytes: 30044
N = int(input())
W = list(map(int, input().split()))

total = 0
for wk in W:
    total += wk


S1, S2 = 0, 0
ans = 1000
for wk2 in W:
    S1 += wk2
    S2 = total - S1
    ans = min(ans, abs(S1 - S2))

print("{}".format(ans))


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

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

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

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

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


int main()
{
    int n;
    cin >> n;
    ll res = 1;
    REP(i,1,n+1) {
        res = (res*i)%MOD;
    }
    P(res);
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
struct node{
	int pre, to;
}edge[N << 1];
int head[N], tot;
int n, m, k;
int fa[N], sz[N];
int out[N];
int Find(int x) {
	return fa[x] == x ? x : fa[x] = Find(fa[x]);
}
void Merge(int x, int y) {
	int fy = Find(y), fx = Find(x);
	fa[fy] = fx;
	sz[fx] += sz[fy];
}
void add(int u, int v) {
	edge[++tot] = node{head[u], v};
	head[u] = tot;
}
int main() {
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) fa[i] = i, sz[i] = 1;
	for (int i = 1, u, v; i <= m; i++) {
		cin >> u >> v;
		if (Find(u) != Find(v)) Merge(u, v);
		out[u]++;
		out[v]++;
	}
	for (int i = 1, u, v; i <= k; i++) {
		cin >> u >> v;
		add(u, v);
		add(v, u);
	}
	for (int i = 1; i <= n; i++) {
		int val = sz[Find(i)] - 1 - out[i];
		for (int j = head[i]; j; j = edge[j].pre) {
			if (Find(i) == Find(edge[j].to)) {
				val--;
			}
		}
		cout << val << " ";
	}
	return 0;
}

Measured memory_bytes: 7840
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
int color[N];
vector < pair < int , int > > adj[N];

void dfs(int u , int dist , int p){
    if(dist & 1){
        color[u] = 0;
    } else {
        color[u] = 1;
    }
    for(auto v : adj[u]){
        if(v.first == p)
            continue;
        dfs(v.first , (dist + v.second) % 2 , u);
    }
}

int main(){
    scanf("%d" , &n);
    for(int i = 1; i < n; i++){
        int u , v , w;
        scanf("%d%d%d" , &u , &v , &w);
        adj[u].push_back({v , w});
        adj[v].push_back({u , w});
    }
    dfs(1 , 0 , -1);
    for(int i = 1; i <= n; i++){
        printf("%d\n" , color[i]);
    }
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int left = 0, right = 0;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    if (a < x) left++;
    else right++;
  }
  cout << min(left, right) << endl;
  return 0;
}

Measured memory_bytes: 3576
function Main(input) {
    var N = parseInt(input,10);
    var sum = 0;
    for(var i=1;i<=N;i++){
        if(i%3 != 0 && i%5 !=0){
            //console.log(i);
            sum += i;
        }
    }
    console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 35144
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    printf("%10lf", (N-N/2)/(double)N);


}

/*
座標圧縮の例
int compress(int *x1, int *x2, int w) {
    vector<int> xs;

    for (int i = 0; i < N; i++ {
        for (int d = -1; d <= 1; d++) {
            int tx1 = x1[i] + d; tx2 = x2[i] + d;
            if (1 <= tx1 && tx1 <= W) xs.push_back(tx1);
            if (1 <= tx2 && tx2 <= H) xs.push_back(tx2);
        }
    }
    sort(xs.begin());
    xs.erase(unique(xs.begin(), xs.end(), x1[i]) - xs.begin());

    for (int i = 0; i < N; i++) {
        x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }

    return xs.size();
}

*/


/*
組み合わせ計算アルゴリズム
v[i][j]がiCjを意味する
std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % R;
    }
  }
  return v;
}
*/

/*
行列べき乗  mat A(m,vec(n)); からAに何かしら代入して A = pow(A,n);

typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A, mat &B) {
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++) {
        for (int k = 0; k < B.size(); k++) {
            for (int j = 0; j < B[0].size(); j++) {
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
            }
        }
    }
    return C;
}

mat pow(mat A, ll n) {
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++) {
        B[i][i] = 1;
    }
    while (n > 0) {
        if (n & 1) B = mul(B,A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

//ctoi関数　stringを扱いたくてバグが酷い時にどうぞ
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}
*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=12e5,mo=1e9+7;

int a[N],n,b[N],c[N],d[N];
int qz[N],hz[N];
int lx[N];
int bh[N];

ll f[N];

inline bool kmp(int x,int y)
{return (c[x]!=c[y])?c[x]<c[y]:((b[x]!=b[y])?(b[x]>b[y]):(a[x]<a[y]));}

int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	scanf("%d",&n);
	fo(i,1,n)scanf("%d",&a[i]);
	fo(i,1,n)qz[i]=qz[i-1]^a[i];
	fd(i,n,1)hz[i]=hz[i+1]^a[i];
	fd(i,n,1)lx[i]=lx[i+1]+(hz[i]==0);
	fo(i,1,n*2)bh[i]=i;
	fo(i,1,n)a[i]=1,b[i]=i,c[i]=qz[i];
	fo(i,1,n)a[i+n]=2,b[i+n]=i,c[i+n]=hz[i];
	sort(bh+1,bh+n+n+1,kmp);
	int j=0;
	b[0]=-1;
	ll ans=1;
	fd(i,n*2,1)if(c[bh[i]]!=0)j=i-1;
	fo(i,1,n*2)if(c[bh[i]]!=c[bh[i+1]]&&c[bh[i]]!=0){
		fo(l,j+1,i)d[l-j]=bh[l];
		int cd=i-j,sz=c[bh[i]];
		ll l1=0,l2=0,k1=0,k2=0;
		int las=n+1;
		fo(l,1,cd)if(a[d[l]]==1){
			int po=b[d[l]]+1;
			if(hz[po]!=0&&hz[po]!=sz)continue;
			if(hz[po]==0)ans=(ans+k2)%mo;
			if(hz[po]==sz)ans=(ans+k1)%mo;
		} else {
			int po=b[d[l]];
			ll j2=(l2+l1*(lx[po]-lx[las]))%mo;
			k1=(1+j2)%mo;
			ll j1=(l1+j2+1)%mo;
			k2=j1;
			l2=j2;
			l1=j1;
			las=po;
		}
		j=i;
	}
	int gs=0;
	if(qz[n]==0){
		fo(i,1,n-1)if(qz[i]==0)++gs;
		ll lj=1;
		fo(l,1,gs)lj=lj*2%mo;
		ans=(ans+lj-1)%mo;
	}
	cout<<ans;
}

Measured memory_bytes: 34048
package main

import "fmt"

func main() {
	var length int
	fmt.Scan(&length)
	numbers := scanNums(length)

	answer := "YES"
	count := 0
	for k, v := range numbers {
		if numbers[k] == k+1 {
			continue
		} else if numbers[v-1] == k+1 {
			count++
		} else {
			answer = "NO"
			break
		}
		if count > 2 {
			answer = "NO"
			break
		}
	}
	fmt.Println(answer)
}

func scanNums(length int) (numbers []int) {
	var number int
	for i := 0; i < length; i++ {
		fmt.Scan(&number)
		numbers = append(numbers, number)
	}
	return
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll x,k,d,m;
    cin>>x>>k>>d;
    x=abs(x);
    m=min(k,x/d);
    x-=(m*d);
    if((k-m)&1) x-=d;
    cout<<abs(x);
}

Measured memory_bytes: 3648
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=1e6+10;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
    if(x>9) out(x/10);   
    putchar(x%10+'0'); 
}
const int mod=1e9+7;
ll p[200000],c[200000];
int main(){
    string s,s1;
    cin>>s>>s1;
    int cnt=0;
    for(int i=0;i<s.size();++i){
        if(s[i]!=s1[i])cnt++;
    }
    out(cnt);
    return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
typedef long long int ll;
int  main(){
	int n,m;
	ll k,l;
	cin >> n>> m;
	vector <pair<ll,ll>> a,c;
  for(int i=0;i<n;i++){
		cin >> k>>l;
		a.push_back(make_pair(k,l));
	}
	for(int i=0;i<m;i++){
		cin >> k>> l;
		c.push_back(make_pair(k,l));
	}
	for(int i=0;i<n;i++){
		l=0;ll ans=1e9;
    for(int j=0;j<m;j++){
			k=abs(a[i].first-c[j].first)+abs(a[i].second-c[j].second);
			if(k<ans){
				   l=j;
           ans=k;
			}
		}
		cout << l+1<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define fr first
#define sc second
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	string ss,s;
	stringstream str;
	getline(cin,ss);
	if(cin.eof())break;
	ss += " E";
	str.str(ss);
	double ans = 0.0;
	stack<double> st;
	int x = -1;

	while(true){
	str >> s;
	if(s == "E") break;
	if(s == "+"){
	    double a,b,c;
	    a = st.top();
	    st.pop();
	    b = st.top();
	    st.pop();
	    c = a + b;
	    st.push(c);
	}else if(s == "*"){
	    double a,b,c;
	    a = st.top();
	    st.pop();
	    b = st.top();
	    st.pop();
	    c = a * b;
	    st.push(c);
	}else if(s == "-"){
	    double a,b,c;
	    a = st.top();
	    st.pop();
	    b = st.top();
	    st.pop();
	    c = b - a;
	    st.push(c);
	}else if(s == "/"){
	    double a,b,c;
	    a = st.top();
	    st.pop();
	    b = st.top();
	    st.pop();
	    c = b / a;
	    st.push(c);
	}else{
	    st.push(stod(s));
	}
	}
	printf("%lf\n",st.top());
    }
    return 0;
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;



int32_t main(){
    vaibhavv06;
	int a,b,k; cin>>a>>b>>k;
	int x = max(0LL,a-k);
	k-=(a-x);
	int y = max(0LL,b-k);

	cout<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    u64 H;
    cin >> N >> H;

    u64 a, b;
    vector< pair<u64, u64> > dm(2 * N);
    rep (i, N)
    {
        cin >> a >> b;
        dm[2 * i] = make_pair(a, u64(1e9));
        dm[2 * i + 1] = make_pair(b, u64(1)); 
    }

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

    u64 ans = 0;
    u64 sum = 0;
    int idx = 2 * N - 1;
    while (sum < H)
    {
        if (sum + dm[idx].first * dm[idx].second >= H)
        {
            ans += CEIL(H - sum, dm[idx].first);
            sum = H;
        }
        else
        {
            ans += dm[idx].second;
            sum += dm[idx].first * dm[idx].second;
        }
        --idx;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3328
import sys
from heapq import*
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S]=0
 H=[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
def s():
 for e in iter(r,'0 0\n'):
  n,k=map(int,e.split())
  E=[[]for _ in[0]*-~n]
  for _ in[0]*k:
   f=r()
   if'0'==f[0]:print(g(n,E,*map(int,f[2:].split())))
   else:
    c,d,e=map(int,f[2:].split())
    E[c]+=[(e,d)];E[d]+=[(e,c)]
s()


Measured memory_bytes: 6308
def resolve():
    import re
    W = input()
    s = input()
    r = re.compile(r"\b" + W + r"\b", flags=re.IGNORECASE)
    sumA = 0
    while s != "END_OF_TEXT":
        sumA += len(r.findall(s))
        s = input()
    print(sumA)


resolve()



Measured memory_bytes: 6492
N = int(input())
T = [tuple(map(int, input().split())) for _ in range(N - 1)]

ans = [0] * N
for i in range(N - 1):
    for j in range(i, N - 1):
        C, S, F = T[j]
        now = ans[i] if S <= ans[i] else S
        ans[i] = now + (F - now % F) % F + C

print(*ans, sep='\n')


Measured memory_bytes: 40432
N=int(input())
nt=0
nx=0
ny=0
for i in range(N):
    t,x,y=map(int,input().split())
    d=t-nt
    dxy=abs(x-nx)+abs(y-ny)
    if(d<dxy or d%2!=dxy%2):
        print("No")
        exit()
    else:
        nt=t
        nx=x
        ny=y
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    
    if (A <= 5) {
        cout << 0 << endl;
        return 0;
    }
    if (A <= 12) {
        cout << B/2 << endl;
        return 0;
    }
    
    cout << B << endl;
    return 0;
}


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

using namespace std;

string s;

int main(void)
{
	cin >> s;
	
	if(s == "keyence"){
		cout << "YES" << endl;
		return 0;
	}
	
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < s.size(); j++){
			if(i > j) continue;
			if(s.substr(0, i) + s.substr(j+1) == "keyence"){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

bool visit[10];

bool check(int n) {
  for (; n; n /= 10) {
    if (visit[n % 10]) return false;
  }
  return true;
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    visit[x] = true;
  }
  for (int i = n; ; ++i) {
    if (check(i)) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

static const int MAX = 200000;

int main() {
	
	int R[MAX],n;
	
	cin>>n;
	for(int i=0;i<n;i++) cin>>R[i];
	
	int maxv=-2000000000;
	int minv=R[0];
	
	for(int i=1;i<n;i++){
		maxv=max(maxv,R[i]-minv);
		
		minv=min(minv,R[i]);
	}
	
	cout<<maxv<<endl;
	
	return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  
  int A_min, A_max, B_min, B_max;
  
  if (A % 2 == 0) {
    A_min = A / 2 * 25;
    A_max = A / 2 * 25 + 12;
  } else {
    A_min = A / 2 * 25 + 13;
    A_max = A / 2 * 25 + 24;
  }
  B_min = B * 10;
  B_max = (B + 1) * 10 - 1;
  
  for (int i = A_min; i <= A_max; ++i) {
    if (B_min <= i && i <= B_max) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c;
  int max,ans;
  scanf("%d%d%d",&a,&b,&c);
  max=a;
  max=(max<b)?b:max;
  max=(max<c)?c:max;
  ans=max*3-a-b-c;
  if(ans%2==0)
    printf("%d\n",ans/2);
  else
    printf("%d\n",(ans+1)/2+1);
  return 0;
}

Measured memory_bytes: 128
# 元ソースコード：http://abc057.contest.atcoder.jp/submissions/1183710
# 初心者の実験用です

import math
N,A,B = map(int,input().split())
V = list(map(int,input().split()))
V.sort()
S = V[-A:]
avgmax = sum(S) / A
print(avgmax)
 
Vs = V.count(min(S))
Ss = S.count(min(S))
if min(S) != max(S):
	C = math.factorial(Vs) // (math.factorial(Vs -Ss) * math.factorial(Ss))
	print(C)
else:
	i = A
	C = 0
	while i <= B and V[-i] == min(S):
		c = math.factorial(Vs) // (math.factorial(Vs -i) * math.factorial(i))
		C = C + c
		i = i + 1
	print(C)

Measured memory_bytes: 3064