akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
using namespace std;
int main() {
	int n;
	string w[100];
	bool a = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	for (int i = 0; i < n; i++) {
		if (i) {
			if (w[i].front() != w[i - 1].back())a = false;
		}
		for (int j = 0; j < i; j++) {
			if (w[i] == w[j])a = false;
		}
	}
	if (a)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    graph=[[] for _ in range(n)]
    for i in range(n-1):
        a,b=map(int,input().split())
        graph[a-1].append((b-1,i))
        graph[b-1].append((a-1,i))
    queue=deque([0])
    visited=[False]*n
    visited[0]=True
    colors=[0]*n
    ans=[0]*(n-1)
    while queue:
        node=queue.popleft()
        c=1
        for xnode,edge in graph[node]:
            if visited[xnode]:continue
            if colors[node]==c:c+=1
            ans[edge]=c
            colors[xnode]=c
            visited[xnode]=True
            queue.append(xnode)
            c+=1
    print(max(ans))
    for a in ans:
        print(a)

if __name__=='__main__':
    main()

Measured memory_bytes: 70304
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> c(n-1), s(n-1), f(n-1);
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i,n-1){
        ll t = s[i];
        for(int j = i; j < n-1; ++j){
            ll nex = max(t - s[j], 0LL) / f[j] * f[j] + s[j];
            if(t > nex) nex += f[j];
            t = nex + c[j];
        }
        std::cout << t << endl;
    }
    std::cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val panels = readLine()!!.trim()
    val rightArrow = IntArray(n){if (panels[it] == '>') 1 else 0}
    val leftArrow = IntArray(n){if (panels[it] == '<') 1 else 0}
    for (i in 1 until n) {
        rightArrow[i] += rightArrow[i - 1]
        leftArrow[n - i - 1] += leftArrow[n - i]
    }
    println((0 until n).map{mid ->
        if (rightArrow[mid] == leftArrow[mid]) if (panels[mid] == '<') n - lowerBoundAsc(rightArrow, 1) else upperBoundDec(leftArrow, 1)
        else if (rightArrow[mid] > leftArrow[mid]) n - lowerBoundAsc(rightArrow, rightArrow[mid] - leftArrow[mid] + (if (panels[mid] == '>') 0 else 1))
        else upperBoundDec(leftArrow, leftArrow[mid] - rightArrow[mid] + (if (panels[mid] == '<') 0 else 1))
    }.max())
}
fun lowerBoundAsc(array: IntArray, target: Int): Int {
    var left = 0
    var right = array.size
    while(left < right){
        val mid = (left + right) / 2
        if (array[mid] < target) left = mid + 1
        else right = mid
    }
    return right
}
fun upperBoundDec(array: IntArray, target: Int): Int {
    var left = 0
    var right = array.size
    while(left < right){
        val mid = (left + right) / 2
        if (array[mid] >= target) left = mid + 1
        else right = mid
    }
    return right
}


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

using namespace std;
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 1;
    for (int c = n - 2; c > 0; c--)
    {
        int t = 0;
        int val = n - c;
        for (int i = 1; i <= sqrt(val); i++)
        {
            if (val % i == 0)
            {
                int k = val / i;
                if (k == i)
                {
                    ans++;
                }
                else
                {
                    ans += 2;
                }
            }
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a<=111) cout<<111;
	if(a>111&a<=222) cout<<222;
	if(a>222&a<=333) cout<<333;
	if(a>333&a<=444) cout<<444;
	if(a>444&a<=555) cout<<555;
	if(a>555&a<=666) cout<<666;
	if(a>666&a<=777) cout<<777;
	if(a>777&a<=888) cout<<888;
	if(a>888) cout<<999;
	return 0;
}

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

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}




long long  H, W, ans, N,x,y, A,X[8002],Y[8002],xnum,ynum, num,sum,B,now,chain[100000];
string s,t,tt,ss;

int main() {
	cin >>s;
	cout << "2018";

	for (int i = 4; i < 10; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define n_max 10000
#define q_max 500
#define S_MAX 1000000000
#define T_MAX 1000000000

int main(){
  int n, i, j, q, count=0;
  int S[n_max], T[q_max], c[q_max];

  scanf("%d",&n);//n個の数列

  for(i=0;i<n;i++){//数列の要素
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);//q個の数
  
  for(i=0;i<q;i++){//数列の要素
    scanf("%d",&T[i]);
  }

  
  for(i=0;i<n;i++){
    for(j=0;j<q;j++){
      if(S[i]==T[j]){
	count++;
        T[j]=-1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2144
#include<stdio.h>

int main(void)
{
	unsigned long int a, r, g, b, N;
	unsigned long long int sum = 0;
	long int sumR, sumB, sumG;
	char mozi[4001];
	int tab;

	scanf("%ld", &N);
	scanf("%s", &mozi);

	sumR = 0;
	sumB = 0;
	sumG = 0;

	for (a = 0; a < N; a++) {
		if ('R' == mozi[a]) {
			sumR++;
		}

		if ('B' == mozi[a]) {
			sumB++;
		}
		if ('G' == mozi[a]) {
			sumG++;
		}
	}

	sum = sumR * sumB * sumG;

	for (a = 0; a < N; a++) {
		for (b = 0; (b + 2 * a) < N; b++) {
			if ((mozi[b] != mozi[b + a]) && (mozi[b + 2 * a] != mozi[b + a]) && (mozi[b] != mozi[b + a * 2])) {
				sum--;
			}
		}
	}

	printf("%lld", sum);

	return 0;
}

Measured memory_bytes: 1740
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
long long ks[41000];
long long dp[110][2][41000];
int main(){
	long long a,b;scanf("%lld%lld",&a,&b);
	for(int i=1;i<30000;i++){
		ks[i]=max(39999LL,a/i)-max(39999LL,a/(i+1));
	}

	int LIM=40000;
	for(int i=1;i<min((long long)LIM,a+1);i++){
		dp[1][0][i]=1;
	}
	for(int i=1;i<30000;i++){
		dp[1][1][i]=ks[i];
	}
	for(int i=1;i<b;i++){
		long long cur=0;

		for(int j=1;j<40000;j++){
//			if(dp[i][0][j])printf("%d %d %d: %lld\n",i,0,j,dp[i][0][j]);
			cur=(cur+dp[i][0][j])%mod;
			dp[i+1][1][j]=cur*ks[j]%mod;
		}
		cur=0;
		long long at=1;
		for(int j=LIM-1;j>=1;j--){
			while(at<LIM&&at*j<=a){
				cur=(cur+dp[i][0][at])%mod;
				at++;
			}
			cur=(cur+dp[i][1][j])%mod;
			if(j<=a)dp[i+1][0][j]=cur;
		}
	}
	long long ret=0;
	for(int i=0;i<2;i++)for(int j=0;j<41000;j++)
		ret+=dp[b][i][j];
	ret%=mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 66944
#include<stdio.h>
int main(void)
{
        int a,b,c,i,count=0;
        scanf("%d %d %d",&a,&b,&c);
        for(i = a;i <= b;i++){
                if(c % i == 0){
                        count++;
                }
        }
        printf("%d\n",count);
        return 0;
}

Measured memory_bytes: 596
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = vec![];

    for _ in 0..n {
        let ai = read();
        a.push(ai);
    }
    let mut sum = 0;
    let mut head = 0;

    for i in 0..n {
        let ai = a[i];
        sum += (head - ai).abs();
        head = ai;
    }
    sum += head.abs();

    // println!("sum:{}", sum);

    let mut prev = 0;
    for i in 0..n {
        let current = a[i];
        let mut next = 0;
        if i != n - 1 {
            next = a[i + 1];
        }
        println!(
            "{}",
            sum - (prev - current).abs() - (current - next).abs() + (prev - next).abs()
        );
        prev = current;
    }
}


Measured memory_bytes: 5244
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n,m;
    cin>>n>>m;
    ll by=pow(2,m);
    cout<<(1900*m+100*(n-m))*by<<endl;

//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#define MAX(x,y) (x > y ? x : y)

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    string s;
    int res=0,tmp=0;
    cin >> s;
    for(int i=0;i<s.length();i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'T' || s[i] == 'G'){
            tmp++;
            res = MAX(res,tmp);
        }else{
            tmp = 0;
        }
    }
    cout << res;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> S(N,0);
  vector<int> s(M),c(M);
  map<int,int> m;
  for(int i=0;i<M;i++){
    cin >> s.at(i) >> c.at(i);
    if(m.count(s.at(i))){
      if(m.at(s.at(i))!=c.at(i)){
        cout << -1 << endl;
        return 0;
      }
    }else{
      m[s.at(i)]=c.at(i);
    }
    if(N!=1){
      if(s.at(i)==1){
        if(c.at(i)==0){
          cout << -1 << endl;
          return 0;
        }
      }
    }
    S.at(s.at(i)-1)=c.at(i);
  }
  if(N!=1){
    if(S.at(0)==0){
      S.at(0)=1;
    }
  }
  for(int i=0;i<N;i++){
    cout << S.at(i);
    if(i==N-1){
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define fr first
#define sc second
int main(){
  int a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f && (a+b+c+d+e+f)){
    int BT = 5 * a + 3 * b;
    int Csum = 15 * a + 15 * b + 7 * c + 2 * d + 15 * BT;
    int Crsum = 3 * ( f - e - BT) + 2 * BT;
    cout << 100 + Csum - Crsum << endl;
  }
}

Measured memory_bytes: 1160
Module a
  
  Sub Main()
  
    Dim input1 as string
    input1 = Console.ReadLine()

    Dim input2 as string
    input2 = Console.ReadLine()
    
    dim s1() as string = Split(input1," ")
    dim cnt as integer = Cint(s1(0))
    dim k as integer = Cint(s1(1))
    
    dim s2() as string = Split(input2," ")
    
    dim result as integer = 0
  	For i as integer = 1 to cnt 
      if k <= Cint(s2(i-1)) then
      result += 1
      end if
  	Next 

  Console.WriteLine(result)
    
  End Sub
 
End Module
    

Measured memory_bytes: 19424
n = (input().split(" "))
nn = int(n[0])
t = int(n[1])
min = 100000000
ans = 0
for i in range(nn):
    aa = (input().split(" "))
    a = int(aa[0])
    b = int(aa[1])
    if b<=t and min>a:
        ans = a
        min = a
if ans ==0:
    print("TLE")
else:
    print(ans)




Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){
  char s[11];
  scanf("%s",s);
  int a=0,b=strlen(s),c=0,d=0,e=1;
  for(int i=0; i<b; i++){
    if(i==0&&s[i]!='A'){
      e=0;break;
    }
    if(2<=i&&i<=b-2){
      if(s[i]=='C'){c++;}
      else if(!('a'<=s[i]&&s[i]<='z')){e=0;break;}
    }
    if((i==b-1||i==1)&&!('a'<=s[i]&&s[i]<='z')){e=0;break;}
  }
  if(c!=1){e=0;}
  printf(e?"AC":"WA");
  return 0;}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int cost(int A,int B){
 if(A>=13){
   return B;
 }
else if(A>=6&&A<=12){
    return B/2;
}
else if(A<=5){
    return 0;
}
}


int main()
{
int a,b;
cin>>a>>b;
cout<<cost(a,b)<<endl;
    return 0;
}


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

void solve(){
  std::vector<int> v(3);
  for(int i=0; i<3; i++){
    cin>>v[i];
  }
  sort(v.begin(), v.end());
  if(v[0] == 5 && v[1] == 5 && v[2] == 7){
    cout<<"YES";
  } else {
    cout<<"NO";
  }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();

    return 0;
}


Measured memory_bytes: 3620
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector<double> vd;
typedef std::vector<std::string> vs;
typedef std::vector<pii> vpii;
typedef std::vector<vi> vvi;
typedef std::vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { rep(i,v.size()) is >> v[i]; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

template<typename InputIterator> std::string join(InputIterator first, InputIterator last, const std::string &sep) {
  if (first == last) return "";
  std::stringstream ss;
  ss << *(first++);
  for_each(first, last, [&](typename InputIterator::value_type &x) { ss << sep << x; });
  return ss.str();
}

main {
  string s;
  int p;
  map<string, vi> m;
  while (cin >> s >> p) m[s].push_back(p);
  for_each(m.begin(), m.end(), [](pair<string, vi> p) {
    cout << p.first << endl;
    sort(all(p.second));
    cout << join(all(p.second), " ") << endl;
  });
}

Measured memory_bytes: 3164
/*
 * sto Qingyu orz
 * 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴,
 * 使其天天爆零
 * 我不由自主地膜拜真神sqy。
 * Author: RainAir
 * Time: 2019-10-17 09:33:50
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define P std::pair
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
#define int LL
const int MAXN = 16 + 1;
const int MAXM = 1e5 + 5;
const int ha = 1e9 + 7;
int f[MAXN+3][(1<<MAXN)+3];
int a[MAXN+3];
int fac[MAXM],inv[MAXM],pc[(1<<MAXN)+3];
int n,m;

inline int qpow(int a,int n=ha-2){
    int res = 1;
    while(n){
        if(n & 1) res = 1ll*res*a%ha;
        a = 1ll*a*a%ha;
        n >>= 1;
    }
    return res;
}

inline void prework(){
    fac[0] = 1;
    FOR(i,1,MAXM-1) fac[i] = 1ll*fac[i-1]*i%ha;
    inv[MAXM-1] = qpow(fac[MAXM-1]);
    ROF(i,MAXM-2,0) inv[i] = 1ll*inv[i+1]*(i+1)%ha;
}

inline int C(int n,int m){
    if(n < m) return 0;
    return 1ll*fac[n]*inv[m]%ha*inv[n-m]%ha;
}

signed main(){
    prework();
    scanf("%lld%lld",&n,&m);
    FOR(i,1,MAXM-1) pc[i] = pc[i>>1]+(i&1);
    FOR(i,1,m) scanf("%lld",a+i);
    std::sort(a+1,a+m+1);
    // f[i][S] 表示填到前 i 个数，S 区间最小值是这个数
    f[m+1][0] = 1;
    ROF(i,m,1){
        FOR(S,0,(1<<n)-1){
            (f[i][S] += f[i+1][S]) %= ha;
            int t = (1<<n)-S-a[i]; // 可以放的数
//            if(S == 0 && i == 1) DEBUG(t);
            FOR(j,0,n-1){
                if(S&(1<<j)) continue;
             //   if(S == 0 && i == 1) DEBUG(j),DEBUG((S|(1<<j))),DEBUG(t),DEBUG((1<<j)-1);
                (f[i][S|(1<<j)] += 1ll*f[i+1][S]*C(t,(1<<j)-1)%ha*fac[(1<<j)]%ha) %= ha;
            //    if(S == 0 && i == 1) DEBUG(f[i][S|(1<<j)]),DEBUG(f[1][1]);
            }
        }
    }
    int ans = 0;
    FOR(S,0,(1<<n)-1){
        (ans += (1ll*(pc[S]&1?ha-1:1)*f[1][S]%ha*fac[(1<<n)-S-1]%ha)) %= ha;
    }
    printf("%lld\n",1ll*ans*(1<<n)%ha);
    return 0;
}


Measured memory_bytes: 20608
S = str(input())

no_ans = "None"
ans_list = []
arufabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

for i in range(len(arufabet)):
    if arufabet[i] not in S:
        ans_list.append(arufabet[i])

if len(ans_list) == 0:
    print(no_ans)
else:
    print(ans_list[0])


Measured memory_bytes: 9036
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define SZ(x) ((int)(x).size())
#define prts(x) return puts(x),0
#define pirtf(x) return printf("%d\n",x),0
#define re return
typedef long long LL;
typedef double ld;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline LL Gcd(LL X,LL Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int B,LL E,int M){if(!(B%=M))return 0;int A=1;for(;E;E>>=1,B=(LL)B*B%M)E&1?A=(LL)A*B%M:0;return A;}
inline LL Pow(LL B,LL E,LL M){if(!(B%=M))return 0;LL A=1;for(;E;E>>=1,B=B*B%M)E&1?A=A*B%M:0;return A;}
const int INF=0x3f3f3f3f;

map<int,int> mp;
set<int> st;

int n,q,m,k;
int a[300005],b[300005];
int f[300005],g[300005];
int M[3005][3005];
char str[300005];

int h[300005],nxt[600005],to[600005],tot;
inline void ins(int x,int y){nxt[++tot]=h[x];to[tot]=y;h[x]=tot;}

int main(){
	scanf("%d%d",&n,&q);printf("%d\n",n+q/2);
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> ab(n);
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        ab[i] = make_pair(b, a);
    }

    sort(ab.begin(), ab.end());
    bool z = true;
    ll sum = 0;
    rep(i, n){
        sum += ab[i].second;
        if(sum > ab[i].first) z = false;
        //cout << sum << " " << ab[i].first << endl;
    }
    if(z) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3328
n = int(input())
l = list(map(int, input().split()))

cnt = 0
for i in range(n-2):
    for j in range(1, n-1):
        for k in range(2, n):
            ijk = sorted([l[i], l[j], l[k]])
            if not i < j < k:
                continue
            if len(set(ijk)) != 3:
                continue
            if ijk[0]+ijk[1] > ijk[2]:
                cnt += 1

print(cnt)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int N;
	cin>>N;
	vi A(N);
	int x[N][N]={0},y[N][N]={0};
	rep(i,0,N){
		cin>>A[i];
		rep(j,0,A[i]){
			cin>>x[i][j];	cin>>y[i][j];
		}
	}
	int ans=0;
	rep(bit,0,(1<<N)){
		int ng=0;
		int cnt=0;
		DBG("bit=",bit,"","");
		rep(i,0,N){
			if (bit & (1<<i)){
				rep(m,0,A[i]){
					DBG("i=",i,"m=",m);
					DBG("y[i][m]=",y[i][m],"x[i][m]=",x[i][m]);
					DBG("bit=",bit,"1<<x=",(1<<(x[i][m]-1)));
					int calc=bit&(1<<(x[i][m]-1));
					DBG("calc=",calc,"","");
					if(y[i][m]==1&& calc==0  ){
//					if(y[i][m]==1&& (bit&(1<<(x[i][m]-1))==0)  ){
						ng=1;break;
					}
					if(y[i][m]==0&&calc){
//					if(y[i][m]==0&&(bit&(1<<(x[i][m]-1)))){
						ng=1;break;
					}
				}
				if(ng) break;
				cnt++;
			}
		}
		DBG("cnt=",cnt,"ng=",ng);
		if(ng==0){
			ans=max(ans,cnt);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3596
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif


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

    ll X, Y;  cin >> X >> Y;

    vi A;
    ll n = X;
    A.push_back(n);
    while(true){
        n *= 2;
        if (n > Y) break;
        A.push_back(n);
    }

    int ans = A.size();
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int solve(int n){
  int i, s, total, min, max;
  scanf("%d", &s);
  min = s;
  max = s;
  total = s;
  for(i = 1; i < n; i++){
    scanf("%d", &s);
    if(s < min) min = s;
    if(s > max) max = s;
    total += s;
  }

  total -= min;
  total -= max;

  return total / (n - 2);
}

int main(void){
  int n;
  while(1){
    scanf("%d", &n);
    if(n == 0) return 0;
    else printf("%d\n", solve(n));
  }
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,k,x,y;
  cin>>n;
  cin>>k;
  cin>>x;
  cin>>y;
  int m=n-k;
  int z=0;
  if(m>0){
    z=x*k+y*m;
  } else {
    z=x*n;
  }
  cout<<z<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <cstdio>

int main() {
  int n; scanf("%d", &n);

  int a[100];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }

  for (int i = n -1; i >= 0; --i) {
    if ( i != n -1) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 20000000

using namespace std;

// input
int n,x,y;
int ad_list[2001][2001];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
   cin >> n >> x >> y;

   rep(i,2001) rep(j,2001) ad_list[i][j] = INF;

   rep(i,n) {
	 rep(j,n) {
	   if(i == j) continue;
	   ad_list[i][j] = min(abs(i-j),ad_list[i][j]);
	   ad_list[i][j] = min(ad_list[i][j],abs(i-x+1) + abs(j-y+1) +1);
	   ad_list[i][j] = min(ad_list[i][j],abs(i-y+1) + abs(j-x+1) +1);
	 }
   }
   int ans[2001];
   rep(i,2001) ans[i] = 0;
	rep(i,n) rep(j,n) {
	  if(i == j) continue;
	  ans[ad_list[i][j]] += 1;
	}

   rep(i,n-1) {
	 cout << ans[i+1]/2 <<endl;
   }
}



Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010;
int n1,n2,x[maxn],y[maxn],a,b;
int main(){
    scanf("%d%d%d%d",&n1,&n2,&a,&b);
    if(a>=b){
        printf("War\n");return 0;
    }
    for(register int i=1;i<=n1;i++) scanf("%d",&x[i]);
    for(register int i=1;i<=n2;i++) scanf("%d",&y[i]);
    sort(x+1,x+n1+1);sort(y+1,y+n2+1);
    if(max(x[n1],a)<min(y[1],b)) printf("No War\n");
    else printf("War\n");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if (x >= r && y >= r && (W-r) >= x && (H-r) >= y)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	long double distence(pair<int,int>x,pair<int,int>x1){
		long double tmp1 = (x1.first-x.first)*(x1.first-x.first)+(x1.second-x.second)*(x1.second-x.second);
		return sqrt(tmp1);
	}
	int factorial(unsigned int n) 
	{ 
    if (n == 0) 
        return 1; 
    return n * factorial(n - 1); 
	} 

	void solve(){

		cout<<setprecision(14);
		ini(n);
		vpii morty(n);
		FOR(i,0,n){
			in(morty[i].first,morty[i].second);
		}
		vi order(n);
		FOR(i,0,n){
			order[i] = i;
		}
		long double tmp = 0;
		do{
			FOR(i,0,n-1){
				tmp+=distence(morty[order[i]],morty[order[i+1]]);
			}
		}while(next_permutation(all(order)));
		tmp/=factorial(n);
		out(tmp);

		
	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int a,b,c;
    cin>>a>>b>>c;

    cout<<max(0ll,c-(a-b));

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;


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

int N; cin >> N;
vi A(N),B(N),C(N);
rep(i,N) cin >> A[i];
rep(i,N) cin >> B[i];
rep(i,N) cin >> C[i];

sort(all(A));
sort(all(B));
sort(all(C));

ll ans = 0;
rep(i,N) {
    ll small = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    ll large = C.end() - upper_bound(C.begin(), C.end(), B[i]);
    ans += small * large;
}

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

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    string S;
    cin >> S;
    int n = S.size();
    vector<int> num(n-2);
    for(int i=0;i<(n-2);i++){
        string test;
        test[0]=S[i];
        test[1]=S[i+1];
        test[2]=S[i+2];
        int num_1 = stoi(test);
        num[i] = num_1;
    }
    int min_diff;
    int diff;
    for(int i=0;i<n-2;i++){
        diff = abs(num[i] - 753);
        if(i==0){
            min_diff = diff;
        }
        else if(min_diff > diff){
            min_diff = diff;
        }
    }
    cout << min_diff << endl;
}

Measured memory_bytes: 3620
fun main(args:Array<String>):Unit {
    while (true) {
        val n = readLine()!!.toInt()
        if (n == 0) return
        val scores = Array(n) { readLine()!!.split(' ').map(String::toInt).sum() }
        println("${scores.max()} ${scores.min()}")
    }
}


Measured memory_bytes: 37592
N,M,C=gets.split.map(&:to_i)
bs=gets.split.map(&:to_i)
as=Array.new
N.times do
  as << gets.split.map(&:to_i)
end
ans=0
as.each do |es|
  cnt=0
  M.times do |i|
    cnt+=es[i]*bs[i]
  end
  cnt+=C
  ans+=1 if cnt>0
end
puts ans

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

int main() {
    int a, b, c, x;
    int count = 0;
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                int sum = 500 * i + 100 * j + 50 * k;
                if (sum == x) count++;
            }
        }
    }
    cout << count << endl;
}


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

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  int A[100];

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N, greater<>());

  int ret = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      ret += A[i];
    } else {
      ret -= A[i];
    }
  }
  cout << ret << endl;

  return 0;
}


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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif

#define FI ios_base::sync_with_stdio(0); cin.tie(NULL);

#define LL long long

const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const int MX = 1e5 + 5;

int n, inp[105];

int main() {
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> inp[i];
	}
	int ans = 0;
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++) {
			for(int k=j+1;k<n;k++) {
				set<int> st;
				st.insert(inp[i]);				
				st.insert(inp[j]);
				st.insert(inp[k]);

				if(st.size() != 3) 
					continue;

				if((inp[i] < inp[j] + inp[k]) && (inp[j] < inp[i] + inp[k]) && (inp[k] < inp[i] + inp[j])) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3644
n,a,b = map(int, input().split())
mod = 10**9 + 7
def power_(n, p, mod):
    if p == 1:
        return n
    if p % 2 == 0:
        return (power_(n, p//2, mod) ** 2) % mod
    else:
        return n * (power_(n, p//2, mod) ** 2) % mod
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
def mod_cmb(p,q,mod):
    #pCqを計算
    res = 1
    for i in range(q):
        res *= (p - i) * mod_inv(q - i, mod)
        res %= mod
    return res % mod
p = power_(2,n, mod)
sub = mod_cmb(n,a,mod) + mod_cmb(n,b,mod)
print((p - sub - 1) % mod)

Measured memory_bytes: 41068
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

map<char, int> table = {
    {'m', 1000},
    {'c', 100},
    {'x', 10},
    {'i', 1}
};

int to_int(string s){
    int i = 0;
    int sum = 0;
    while(i<s.length()){
        int d = 1;
        if('0'<=s[i] && s[i]<='9'){
            d = s[i]-'0';
            i++;
        }
        sum += d*table[s[i++]];
    }
    return sum;
}

string to_mcxi(int a){
    string s = "mcxi";
    string res = "";
    for(char c: s){
        int d = a / table[c];
        a -= d * table[c];
        if(1<d)
            res += d+'0';
        if(0<d)
            res += c;
    }
    return res;
}

int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    
    int T;
    cin >> T;
    while(T--){
        string a, b;
        cin >> a >> b;
        cout << to_mcxi(to_int(a)+to_int(b)) << endl;
    }
    return 0;
}

Measured memory_bytes: 1208
n, m = [int(elem) for elem in input().split()]
ac = [0] * n
wa = [0] * n
 
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        ac[p] = 1
    if not ac[p] and s == 'WA':
        wa[p] += 1

c = 0
for i in range(n):
    c += wa[i] * ac[i]
print(sum(ac), c)

Measured memory_bytes: 4596
import sys
n = int(input())
a = [int(input()) for _ in range(n)]
check = [0] * n
count = 0
button = a[0]
while(True):
    count += 1
    if button == 2:
        break
    if check[button-1] == 1:
        print(-1)
        sys.exit()
    check[button-1] = 1
    button = a[button-1]
print(count)


Measured memory_bytes: 7852
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//-----------------------
const int MOD = (int)1e9 + 7;
struct mint { int n; mint(int n_ = 0) : n(n_ % MOD) { if (n < 0) n += MOD; } };
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + MOD : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &os, mint a) { return os << a.n; }
istream &operator>>(istream &is, mint& a) { return is >> a.n; }
mint inv(mint x) { long long a = x.n, b = MOD, u = 1, v = 0;
    while (b) { long long t = a/b; swap((a -= t*b), b); swap((u -= t*v), v); }
    return mint(u); }
mint operator^(mint a, long long n) { mint r = 1;
    while (n) { if (n & 1) r *= a; a *= a; n >>= 1; } return r; }
bool operator<(const mint &a, const mint &b) { return a.n < b.n; }
//-----------------------

using edge = pair<int, long long>;
using Graph = vector<vector<edge>>;

vector<long long> dijkstra(const Graph &g, int s, vector<mint> &pat) {
    vector<long long> dist(g.size(), INF);
    using Pi = pair<long long, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    dist[s] = 0; pat[s] = 1; que.emplace(dist[s], s);
    while (!que.empty()) {
        long long cost; int u; tie(cost, u) = que.top(); que.pop();
        if (dist[u] < cost) continue;
        for (auto &e: g[u]) {
            int v; long long nc; tie(v, nc) = e;
            if (chmin(dist[v], dist[u] + nc)) {
                que.emplace(dist[v], v), pat[v] = pat[u];
            } else if (dist[v] == dist[u] + nc) {
                pat[v] += pat[u];
            }
        }
    }
    return dist;
}

int main() {
    int n, m; cin >> n >> m;
    int s, t; cin >> s >> t; s--, t--;
    Graph g(n);
    while (m--) {
        int u, v, d; cin >> u >> v >> d; u--, v--;
        g[u].emplace_back(v, d);
        g[v].emplace_back(u, d);
    }
    vector<mint> patS(n);
    auto distS = dijkstra(g, s, patS);
    vector<mint> patT(n);
    auto distT = dijkstra(g, t, patT);
    mint ans = patS[t] * patT[s];
    long long d = distS[t];
    for (int u = 0; u < n; u++) {
        if (distS[u] + distT[u] == d && distS[u] == distT[u]) {
            ans -= (patS[u] * patT[u]) * (patT[u] * patS[u]);
        }
    }
    for (int u = 0; u < n; u++) for (auto &e: g[u]) {
        int v = e.first;
        long long c = e.second;
        if (distS[u] + c + distT[v] != d) continue;
        if (distS[u] * 2 < d && distT[v] * 2 < d) {
            ans -= (patS[u] * patT[v]) * (patT[v] * patS[u]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18004
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll x,y,z;
            cin>>x>>y>>z;
            swap(x,y);
            swap(x,z);
            cout<<x<<" "<<y<<" "<<z<<endl;
        }
        return 0;
    }


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


namespace CSTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var strings = Console.ReadLine().Split(' ');
            var H = int.Parse(strings[0]);
            var W = int.Parse(strings[1]);
            strings = Console.ReadLine().Split(' ');
            var h = int.Parse(strings[0]);
            var w = int.Parse(strings[1]);
            Console.WriteLine((H - h) * (W - w));
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main()
{
    double a, b, c, d, e, f;
    double x, y;
    while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)!=EOF)
    {
        y= ((a*f)-(c*d))/((a*e)-(b*d));
        //x= ((c*d)-(a*f))/((b*d)-(a*c));
        x= (c-(b*y))/a;
        printf("%.3lf %.3lf\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 652
n = int(input())
m = "MARCH"
l = {}
cnt = 0
for _ in range(n):
    init = input()[0]
    if init not in m:
        continue
    if init not in l:
        cnt += 1
        l[init] = 0
    l[init] += 1
if cnt <= 2:
    print(0)
    exit()
l = list(l.values())
n = len(l)
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            ans += l[i] * l[j] * l[k]
print(ans)

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

int main(){

    int r,D,x;
    scanf("%d%d%d",&r,&D,&x);

    for(int i=0;i<10;i++)
    {
        x = r*x - D;
        printf("%d\n",x);
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

def solve():
    n = int(input())

    def num_divisors_table(n):
        table = [0] * (n + 1)
        
        for i in range(1, n + 1):
            for j in range(i, n + 1, i):
                table[j] += 1
        
        return table


    table = num_divisors_table(n)

    ans = 0

    for i in range(n + 1):
        ans += i * table[i]

    print(ans)
solve()


Measured memory_bytes: 145896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e9;
int main(){
	int N,K;cin>>N>>K;
	long A[N+1];A[0]=0;
	rep(i,1,N+1){
		cin>>A[i];
		A[i]=(A[i-1]+A[i]-1)%K;
	}
	long ans=0;
	if(N<K){
		map<long,long> cnt;
		rep(i,0,N+1) cnt[A[i]]++;
		for(pair<long,long> p:cnt){
			long u=p.second;
			ans+=u*(u-1)/2;
		}cout<<ans<<endl;
	}else{
		long cnt[K]={};
		rep(i,0,N+1){
			ans+=cnt[A[i]];
			if(i-K+1>=0) cnt[A[i-K+1]]--;
			cnt[A[i]]++;
		}cout<<ans<<endl;
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<long> a(100100);
  long s[3] = {0};
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int i = 0,j = 0;
  while(j <= 2){
    if(a.at(i) == a.at(i+1)){
      s[j] = a[i];
      j++;
      i++;
    }
    i++;
    if(i == n){
      break;
    }
  }
  cout << s[0]*s[1] << endl;
}

Measured memory_bytes: 1024
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"abc"# => r#"d"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: chars,
    }

    let mut a = vec![false; 26];
    let mut ans = "None".to_string();

    for i in 0..s.len() {
        a[s[i] as usize - 'a' as usize] = true;
    }

    for i in 0..a.len() {
        if a[i] == false {
            ans = ((i + 'a' as usize) as u8 as char).to_string();
            break;
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    rep(i, 0, n) cin >> t[i];
    sort(t.begin(), t.end());

    ll ans = 1, bcnt = 1, tmin = t[0];
    rep(i, 1, n) {
        if (bcnt < c && t[i]-tmin <= k) {
            bcnt++;
        }
        else {
            bcnt = 1;
            tmin = t[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));

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

    int k;
    cin >> k;
    string s;
    cin >> s;
    string ans;
    if(s.length()<=k){
        cout << s <<endl;
    }
    else{
        ans = s.substr(0,k);
        ans += "...";
    }
    cout << ans << endl;

    cout << endl;
    return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int t , p;
string s[MAXX];
int n[MAXX];
int x[MAXX];

int main()
{
    _FastIO;
    cin >> t >> p;
    vector<pair<int , int> > v[MAXX];
    for(int i = 0; i < p; i++){
        cin >> n[i] >> x[i];
        v[n[i]].push_back({x[i] , i});
    }
    vector<pair<int , int> > path[MAXX];
    for(int k = 0; k <= 100000; k++){
        sort(v[k].begin() , v[k].end());
      for(int i = 0; i < v[k].size(); i++){
        path[k].push_back({v[k][i].second , i + 1});
    }
    sort(path[k].begin() , path[k].end());
    }
    vector<int> used(100005 , 0);
    for(int i = 0; i < p; i++){
        int y = n[i];
        string h = "";
        while(y > 0){
            int tp = y % 10;
            h += char(tp + 48);
            y /= 10;
        }
        reverse(h.begin() , h.end());
        while(h.size() < 6){
            h = '0' + h;
        }
        cout << h;
        int m = path[n[i]][used[n[i]]].second;
        h = "";
        while(m > 0){
            int tp = m % 10;
            h += char(tp + 48);
            m /= 10;
        }
        reverse(h.begin() , h.end());
        while(h.size() < 6){
            h = '0' + h;
        }
        cout << h << endl;
        used[n[i]]++;
        }
        return 0;
    }


Measured memory_bytes: 18380