akhauriyash/Code-Regression huggingface dataset:
//#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#define REL
//#endif
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

//#pragma GCC optimize("Ofast")
//#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

//#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);
//mt19937_64 gen(41);

int gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//----------------------------------------------//
	set<string> S;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		S.emplace(s);
	}
	cout << S.size();
	//----------------------------------------------//

	return 0;
}




Measured memory_bytes: 19204
import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int[] b = new int[a];
        int answer = 0;

        for(int i=0;i<a;i++){
            if(sc.nextInt() == answer + 1)
                answer++;
        }
        if(answer == 0)
            System.out.println(-1);
        else
            System.out.println(a-answer);
    }
}

Measured memory_bytes: 79416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

const ll inf = 1e18;

template < typename T >
void min_self (T & a, T b) {
	if (a > b) a = b;
}

int main() {
	int n;
	scanf ("%d", &n);
	vector < int > a (n);
	for (int & x : a) scanf ("%d", &x);
	vector < ll > P (n + 1);
	for (int i = 1; i <= n; i++) {
		P[i] = P[i - 1] + a[i - 1];
	}
	std :: function < ll (int, int ) > sum = [&] (int i, int j) {
		return P[j + 1] - P[i];
	};
	vector < vector < ll > > dp (n, vector < ll > (n, inf));
	for (int len = 1; len <= n; len++) {
		for (int i = 0; i <= n - len; i++) {
			int j = i + len - 1;
			if (len == 1) {
				dp[i][j] = 0;
			} else {
				for (int k = i; k < j; k++) {
					// join from i to k
					// join from k + 1 to j
					min_self (dp[i][j], dp[i][k] + dp[k + 1][j] + sum (i, j));
				}
			}
		}
	}
	printf ("%lld\n",dp[0][n - 1]);
	return 0;
}



Measured memory_bytes: 1536
loopcnt = int(input())
dic = {}
for i in range(0, loopcnt):
    tmp = input()
    #print(dic[tmp])
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1

dic_sorted = sorted(dic.items(),key=lambda x:(-x[1],x[0]))
limit = dic_sorted[0][1]
#debug
#print()
for nametpl in dic_sorted:
    if nametpl[1] == limit:
        print(nametpl[0])
    else:
        break


Measured memory_bytes: 60440
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n;
char str[100005];
int main()
{
	scanf("%s",str);
	n=strlen(str);
	int chkp=n/2;
	int l=chkp,r=chkp;
	while(l>=0 && str[l]==str[chkp])	l--;
	while(r<n && str[r]==str[chkp])	r++;
	int ans=min(n-1-l,r);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
static const int WHITE = 1;
static const int BLACK = 0;
int P[10000];
int color[10000];
int cnt = 0;

void prime(int n){
    for(int i=0; i<n; i++){
        if(color[i]!=BLACK){
            for(int j=3; j*j<=P[i]; j+=2){
                if(P[i]%j==0){
                    color[i]=BLACK;
                }
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> P[i];
        color[i] = WHITE;
    }
    
    for(int i=0; i<n; i++){
        if(P[i]==2) continue;
        if(P[i]%2==0){
            color[i] = BLACK;
        }
    }
    
    prime(n);
    
    for(int i=0; i<n; i++){
        if(color[i]==WHITE){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <queue>

using namespace std;

int W, H;
int field[100][100];
bool visited[100][100];

void init() {
  fill(&field[0][0], &field[99][100], 1);
  fill(&visited[0][0], &visited[99][100], false);
}

typedef pair<int, int> P;

struct State {
  int cost, x, y;
  State(int cost, int x, int y) : cost(cost), x(x), y(y) {}
  void print() {
    printf("%d %d %d\n", cost, x - 2, y - 2);
  }
};

int dx[] = {-2, 0, 2, 0};
int dy[] = {0, 2, 0, -2};
int wx[] = {-1, 0, 1, 0};
int wy[] = {0, 1, 0, -1};

void solve() {
  queue<State> Q;
  Q.push(State(1, 1 + 2, 1 + 2));
  field[1 + 2][1 + 2] = true;
  while (!Q.empty()) {
    State cur = Q.front();
    Q.pop();
    //cur.print();

    int x = cur.x;
    int y = cur.y;
    
    if (cur.x == 2 * W + 1 && cur.y == 2 * H + 1) {
      printf("%d\n", cur.cost);
      return;
    }

    if (visited[cur.y][cur.x]) {
      continue;
    }
    visited[cur.y][cur.x] = true;
    
    for (int i = 0 ; i < 4; i++) {
      int nx = dx[i] + x;
      int ny = dy[i] + y;
      int wallx = wx[i] + x;
      int wally = wy[i] + y;
      if (field[wally][wallx] == 0 && !visited[ny][nx]) {
        Q.push(State(cur.cost + 1, nx, ny));
      }
    }
  }
  printf("%d\n", 0);
}

int main() {
  while (true) {
    scanf("%d %d ", &W, &H);
    init();
    if (W == 0 && H == 0) {
      return 0;
    }
    for (int i = 1; i <= 2 * H - 1; i++) {
      int t;
      if (i % 2 == 0) {
        t = W;
      } else {
        t = W - 1;
      }
      for (int j = 1; j <= t; j++) {
        int w;
        scanf("%d ", &w);
        if (i % 2 == 0) {
          field[i + 2][2 * j - 1 + 2] = w;
        } else {
          field[i + 2][2 * j + 2] = w;
        }
      }
    }
    solve();
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
#define MAXN 100005
#define pi pair<int,int>
#define pl pair<ll,ll>
#define int ll
#define F first
#define S second
#define sz size()

int n, t, a, ind, minim = 1e9;
signed main(){
    cin >> n >> t >> a;
    t *= 1000;
    a *= 1000;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        if (abs(a-t+6*x) < minim){
            minim = abs(a-t+6*x);
            ind = i;
        }
    }
    cout << ind;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
/*
int n;

for(n =1;;n++){
	if(x==0 && y==0) break;
	
}
*/
int a,b,c,r;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
for(a;a <= b;a++){
	if(c%a==0){
		r++;
	}
	
}
printf("%d\n",r);

return 0;
	}




Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	int N;
	int A[100];
	cin>>N;
	FOR(i,0,N){
		cin>>A[i];
	}
	int ans=0;
	int now=0;
	while(now<N){
		int c=1;
		while(now<N-1&&A[now]==A[now+1]){
			now++;
			c++;
		}
		now++;
		ans+=c/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007


int main(void)
{
	CIN;
	ll tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	string s;
	cin>>s;
	int t[2]={};
	for(ll i=0;i<s.size();i++)
		t[s[i]-'0']++;
	cout<<min(t[0],t[1])*2<<nw;
}

Measured memory_bytes: 3780
import numpy as np
h, w = map(int, input().split())

li= np.array([input() for _ in range(h)])
del_count= 0
for i in range(h):
     if li[i-del_count] == "." * w:
         li = np.delete(li, i-del_count, 0)
         del_count+=1

del_count = 0
for i in range(len(li[0])):
    for j in range(len(li)):
        if li[j][i-del_count] == "#":
            break
        elif j == len(li)-1:
            for k in range (len(li)):
                li[k] = li[k][:i-del_count]+li[k][i-del_count+1:]
            del_count+= 1
for i in li:
    print(i)

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

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int m = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            m = max(m, abs(a[i] - a[j]));
        }
    }
    cout << m << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll n;
ll dp[1000][5][5][5];

int main(){
	cin >> n;
	rep(i,4)dp[1][i+1][0][0] = 1;
	rep(i,4)rep(j,4)dp[2][i+1][j+1][0] = 1;
	FOR(i,3,n+1){
		FOR(j,1,5){
			rep(k,5){
				rep(l,5){
					rep(m,5){
						if(j == 3 && k == 2 && l == 1)continue;
						if(j == 3 && k == 1 && l == 2)continue;
						if(j == 2 && k == 3 && l == 1)continue;
						if(j == 3 && l == 2 && m == 1)continue;
						if(j == 3 && k == 2 && m == 1)continue;
						dp[i][j][k][l] += dp[i-1][k][l][m];
						dp[i][j][k][l] %= MOD;
					}
				}
			}
		}
	}
	// rep(k,n+1){
	// 	cout << "!" << k << endl;
	// 	rep(i,4){
	// 		rep(j,4)cout << dp[k][i][j] << " ";
	// 		cout << endl;
	// 	}
	// }
	ll ans = 0;
	rep(i,4){
		rep(j,4){
			rep(k,4){
				ans += dp[n][i+1][j+1][k+1];
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
/* SmartCoder Apr 7, 2019 */
#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end();i++)
#define present(c,x)  ( (c).find(x) !=(c).end())
#define cpresent(c,x) (find(all(c),x)!= (c).end() )
#define minei(x)  min_element(x.begin(),x.end())-(x).begin()
#define maxei(x)  max_element(x.begin(),x.end())-(x).begin()

#define uns(v)     sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define acusum(x)  accumulate(x.begin(),x.end(),0)
#define acumul(x)  accumulate(x.begin(),x.end(),1, multiplies<int>());
#define bits(x)     __builtin_popcount( x )
#define oo INT_MAX
#define inf 1000000000

const double pi = acos(-1.0);
const double eps = 1e-11;
#define MAXN 1007
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
void fastIO() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll dp[MAXN][MAXN];
char mat[MAXN][MAXN];
int main() {
	fastIO();
	int h, w;
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++)
			cin >> mat[i][j];
	}
	dp[1][1] = 1;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (i == 1 && j == 1)
				continue;
			if (mat[i][j] == '.') {
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] %= MOD;
			}
		}
	}
	cout << dp[h][w] << endl;

	return 0;
}


Measured memory_bytes: 9088
import java.util.*;
import java.math.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static double x,h;
    static double S;
    public static void main(String[] args) {
        while(read()){
            slove();
        }
    }
    static boolean read(){
        if(!sc.hasNextInt())return false;
        x = h = 0;
        x = sc.nextDouble();
        h = sc.nextDouble();
        S = 0;


        if(x == 0 && h == 0){
            return false;
        }

        return true;
    }
    static void slove(){
        double square = x*x;
        double height_tri = Math.sqrt(x*x/4 + h*h);
        double Sum_tri = x*height_tri*2;
        S = Sum_tri + square;
        System.out.printf("%.6f\n", S);
    }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int N, P[200005];
int DP[200005], Pos[200005];
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> P[i], Pos[P[i]] = i;
}

void Solve()
{
    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        int pos = Pos[i - 1];
        if(pos > 0 && pos < Pos[i])
            DP[i] = DP[i - 1] + 1;
        else
            DP[i] = 1;
        ans = max(ans, DP[i]);
    }
    cout << N - ans << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 2560
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

A, B = map(int, input().split())

cnt = 0
for num in range(A, B+1):
    num = str(num)
    if num[0]==num[-1] and num[1]==num[-2]:
        cnt += 1
print(cnt)

Measured memory_bytes: 73844
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	double s;
	for(int i=1;i<=n;i++){
		double x;
		scanf("%lf",&x);
		s+=1./x;
	}
	printf("%lf\n",1./s);
	return 0;
}

Measured memory_bytes: 384
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int same(vector<int> &v){
  unordered_map<int,int> cnt;
  int re=0;
  for(int x:v) if(cnt[x]++%2) ++re;
  return re;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m;
  cin>>n>>m;
  rep(i,n)rep(j,m){
    string s;
    cin>>s;
    if(s=="snuke"){
      cout<<char(j+'A')<<i+1<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
	int sum = 0;
	int[] k = new int[3];
	for(int i = 0;i < 3;i++){
	    k[i] = scanner.nextInt();
	    sum += k[i];
	}
	if(sum > 21)
	    System.out.println("bust");
	else
	    System.out.println("win");
    }
}


Measured memory_bytes: 22612
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
// use ascii::Chars;
use libm::*;
use proconio::marker::{Bytes, Chars};
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

use lazy_static::lazy_static;
use std::sync::Mutex;

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")
}

lazy_static! {
    static ref PARENTS: Mutex<Vec<usize>> = Mutex::default();
    static ref CHILDS: Mutex<Vec<Vec<usize>>> = Mutex::default();
}

//abc177-B
// #[fastout]
fn main() {
    input![s: Chars, t: Chars];

    let mut ans = t.len();

    for i in 0..s.len() {
        let mut mid_ans = t.len();
        if i + (t.len() - 1) >= s.len() {
            break;
        }

        for j in 0..t.len() {
            if s[i + j] == t[j] {
                mid_ans -= 1;
            }
        }

        ans = min(ans, mid_ans);
    }
    println!("{}", ans);
}

// fn go2(start: usize, plus_val: usize, anss: &mut Vec<usize>, dcc: &Vec<usize>) {
//     let childrens = CHILDS.lock().unwrap()[start].clone();

//     // let mut ans = plus_val;
//     for c in childrens.iter() {
//         go2(*c, plus_val + dcc[start], anss, dcc);
//     }

//     anss[start] = plus_val + dcc[start];
// }

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000


Measured memory_bytes: 2092
#include <iostream>
#include <cmath>

using namespace std;

int main()
{

    int i, j, k, n, m, l;

    cin >> n >> m >> l;

    int A[100][100], B[100][100];
    long C[100][100] = {};

    for(i = 0; i < n; ++i){
        for(j = 0; j < m; ++j){
            cin >> A[i][j];
        }
    }

    for(i = 0; i < m; ++i){
        for(j = 0; j < l; ++j){
            cin >> B[i][j];
        }
    }

    for(i = 0; i < n; ++i){
        for(j = 0; j < l; ++j){
            for( k = 0; k < m; ++k ){
                C[i][j] += A[i][k] * B[k][j];
            }
            if ( j == l-1 ) {
                cout << C[i][j] << endl;
            } else {
                cout << C[i][j] << " ";
            }
        }
    }


}

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

void fnInput(vector<string>& rvsSortBbl, vector<string>& rvsSortSel)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  
  rvsSortBbl.resize(nMaxSiz);
  rvsSortSel.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
  {
    cin >> rvsSortBbl[i];
    rvsSortSel[i] = rvsSortBbl[i];
  }
}

void fnBubbleSort(vector<string>& rvsSortBbl)
{
  int nSorting = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int j = rvsSortBbl.size() - 1; j > nSorting; j--)
    {
      if (rvsSortBbl[j].at(1) < rvsSortBbl[j - 1].at(1))
      {
        swap(rvsSortBbl[j], rvsSortBbl[j - 1]);
        bSorting = true;
      }
    }
    nSorting++;
  }
}

void fnOutputBbl(const vector<string>& cnrvsSortBbl)
{
  for (int i = 0; i < cnrvsSortBbl.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvsSortBbl[i];
  }
  cout << endl;
  cout << "Stable" << endl;
}

void fnSelectionSort(vector<string>& rvsSortSel)
{
  for (int nSorting = 0; nSorting < rvsSortSel.size() - 1; nSorting++)
  {
    int nMin = nSorting;
    bool bSorting = false;
    for (int j = nSorting + 1; j < rvsSortSel.size(); j++)
    {
      if (rvsSortSel[j].at(1) < rvsSortSel[nMin].at(1))
      {
        nMin = j;
        bSorting = true;
      }
    }
    if (bSorting == true)  swap(rvsSortSel[nSorting], rvsSortSel[nMin]);
  }
}

void fnOutputSel(const vector<string>& cnrvsSortSel, const vector<string>& cnrvsSortBbl)
{
  string sSortEnd = "Stable";

  for (int i = 0; i < cnrvsSortSel.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvsSortSel[i];
    
    if (cnrvsSortSel[i] != cnrvsSortBbl[i]) sSortEnd = "Not stable";
  }
  cout << endl;
  cout << sSortEnd << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  vector<string> vsSortBbl, vsSortSel;

  fnInput(vsSortBbl, vsSortSel);
  fnBubbleSort(vsSortBbl);
  fnOutputBbl(vsSortBbl); 

  fnSelectionSort(vsSortSel);
  fnOutputSel(vsSortSel, vsSortBbl);

  return 0;
}

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

int main(){
    long long n;
    cin>>n;
    long int dp[n+1][3],cost[n+1][3];//represents nth day max work
    memset(dp,0,sizeof(dp));
    
    for(long int i=1;i<=n;i++)
        for(long int j=0;j<3;j++)
            cin>>cost[i][j];



    for(long int i=1;i<=n;i++){
        for(long int j=0;j<3;j++){
            dp[i][j]=max(dp[i][j],max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+cost[i][j]);
        }
    }
    
    cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<endl;    
    
    
    
    
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	string s1, s2, s3;
	
	cin >> s1 >> s2 >> s3;
	
	cout << s1[0] << s2[0] << s3[0];
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
int main(){
 
  using namespace std;
  
  string a;
  cin >> a;
  
  string arr[] = {"ABC", "ARC"};
  
  for (int i = 0; i<2; i++){
    if (arr[i] != a){
      cout << arr[i];
    }
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define revrep(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define pii pair<int, int>

int INF = 1e14;
int mod = 1e9 + 7;

int power(int x, unsigned int y)
{
    int temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2) % mod;
    if (y & 1 == 0)
        return (temp * temp) % mod;
    else
        return x * ((temp * temp) % mod) % mod;
}

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n, m, k;
        cin >> n >> m >> k;
        vector<int> a(n + 1, 0), b(m + 1, 0);
        rep(i, 1, n + 1)
        {
            cin >> a[i];
            a[i] += a[i - 1];
        }
        rep(i, 1, m + 1)
        {
            cin >> b[i];
            b[i] += b[i - 1];
        }
        int ans = 0;
        rep(i, 0, n + 1)
        {
            auto ptr = lower_bound(b.begin(), b.end(), k - a[i]);
            int dist = distance(b.begin(), ptr);
            if (ptr != b.end())
            {
                if (*ptr + a[i] == k)
                    ans = max(ans, dist + i);
                else if (b[dist-1] + a[i] < k)
                    ans = max(ans, dist + i - 1);
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 6360
#include <iostream>
#include <vector>

using namespace std;

struct Req
{
  int a;
  int b;
  int c;
  int d;
}reqs[50];

int n, m, q;

int score(vector<int>& v)
{
  int s = 0;
  for (int i = 0; i < q; ++i)
    if (v[reqs[i].b] - v[reqs[i].a] == reqs[i].c)
      s += reqs[i].d;
  return s;
}

int combis(vector<int> cur, int val)
{
  if (cur.size() == n)
    return score(cur);
  int best = 0;
  for (int i = val; i <= m; ++i)
  {
    cur.push_back(i);
    best = max(best, combis(cur, i));
    cur.pop_back();
  }
  return best;
}

int main()
{
  cin >> n >> m >> q;
  for (int i = 0; i < q; ++i)
  {
    cin >> reqs[i].a >> reqs[i].b >> reqs[i].c >> reqs[i].d;
    --reqs[i].a;
    --reqs[i].b;
  }
  vector<int> ori;
  cout << combis(ori, 1) << '\n';
}


Measured memory_bytes: 3604
#include <stdio.h>

int main(void)
{
	int n, a, b;
	int flag = 0;

	scanf("%d", &n);

	//九九で表せるか判定する
	for (a = 1; a <= 9; a++) 
	{
		for (b = 1; b <= 9; b++) 
		{
			if (n == a * b) 
			{
				flag = 1;//九九で表せるならflagを1にする
			}
		}
	}

	if (flag == 1) //九九で表せるとき
	{
		printf("Yes\n");
	}
	else //表せないとき
	{
		printf("No\n");
	}

	return 0;
}

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

int main() {
    long long n, b, r;
    cin >> n >> b >> r;
    long long sum = b + r;
    if(sum > n)
    {
        if(b > n)
            cout << n;
        else
            cout << b;
        }
    else{
        if(n % sum >= b)
            cout << (n / sum) * b + b;
        else
            cout << (n / sum) * b + n % sum;
    }
    
//     long long seg = n/sum;
    
//     cout << (seg * b) + min(b, n % sum);
    return 0;
}

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

using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");

#define hello cout << "hello" << endl
#define dbg(var) cout << #var << " --> " << var << endl
#define mset(a, b)  memset(a, b, sizeof(a))
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define boost ios_base::sync_with_stdio(false)

const int MOD = 1e9 + 7;
const double EPS = 1e-6;

struct Node{
	int x, y;
};
vector<Node> stu;
vector<Node> point;
int main(){
	boost;
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i){
		ll x, y;
		cin >> x >> y;
		stu.pb({x, y});
	}
	for(int i = 0; i < m; ++i){
		ll x, y;
		cin >> x >> y;
		point.pb({x, y});
	}
	for(int i = 0; i < n; ++i){
		ll mi = INT_MAX;
		int ans = 0;
		for(int j = 0; j < m; ++j){
			ll x1 = stu[i].x;
			ll y1 = stu[i].y;
			ll x2 = point[j].x;
			ll y2 = point[j].y;
			ll dist = abs(x1 - x2) + abs(y1 - y2);
			if(dist < mi){
				// dbg(dist);
				mi = dist;
				ans = j + 1;
			}
		}	
		
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> pl(n);
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		pl[i] = pair<ll, ll>(x, y);
	}
	sort(pl.begin(), pl.end());
	ll tmp = 0;
	ll ans = 0;
	rep(i, n) {
		if (m > tmp + pl[i].second) {
			ans += pl[i].second * pl[i].first;
			tmp += pl[i].second;
		}
		else{
			ans += (m - tmp) * pl[i].first;
			break;
		}
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

signed main(void){
    int N,K;
    pair<int,int> dt[114514];
    int t,d;
    cin >> N >> K;
    REP(i,N){
        cin >> t >> d;
        dt[i]={d,t};
    }
    sort(dt,dt+N,greater<>());
    bool al[114514]={};
    vector<int> F,S;
    
    REP(i,N){
        t=dt[i].second,d=dt[i].first;
        if(al[t]==0){
            al[t]=1;
            F.push_back(d);
        }else{
            S.push_back(d);
        }
    }
    int f=F.size(),s=S.size();
    sort(F.begin(),F.end(),greater<>());
    sort(S.begin(),S.end(),greater<>());
    
    //REP(i,f){cout << F[i] << " ";}cout << endl;
    //REP(i,s){cout << S[i] << " ";}cout << endl;
    
    int P[114514]={},Q[114514]={};
    REP(i,f){
        P[i+1]=P[i]+F[i];
    }
    REP(i,s){
        Q[i+1]=Q[i]+S[i];
    }
    f++;s++;
    
    //REP(i,f){cout << P[i] << " ";}cout << endl;
    //REP(i,s){cout << Q[i] << " ";}cout << endl;
    
    int Ans=0;
    REP(i,K+1){
        if(!(0<=i&&i<f))continue;
        if(!(0<=K-i&&K-i<s))continue;
        int num=i*i;
        num+=P[i]+Q[K-i];
        Ans=max(Ans,num);
    }
    
    
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 5112
n = int(input())
s = []
for i in range(n):
    s.append(input()[0])

c = (
    s.count("M"),
    s.count("A"),
    s.count("R"),
    s.count("C"),
    s.count("H"),
)
from itertools import combinations
a = sum(x*y*z for x, y, z in combinations(c, 3))
print(a, flush=True)



Measured memory_bytes: 9848
n = int(input())
e_str = [chr(ord('a') + i) for i in range(26)]
ans = []
while n>0:
    n -= 1
    i = n % 26
    # print(i)
    ans.append(e_str[i])
    n = n// 26
    # print(n)
# print(e_str)
# print(ans)
ans.reverse()
a = ''.join(ans)
print(a)

Measured memory_bytes: 61804
N = int(input())
p = [[] for _ in range(N)]
for i in range(N):
    p[i] = list(map(int, input().split()))
All = []
for v in p:
    for _v in v:
        All.append(_v)
All.sort(reverse=True)
highest = All.pop(0)
total = highest/2
for value in All:
    total += value
print(int(total))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 1005
#define M 30005
#define ll long long 
#define INF 0x3f3f3f3f
#define PI 3.1415926535
#define EPS 1e-6
inline ll rd()
{
	ll f=1ll,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-f;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
double Abs(double m)
{
	if(m>=0.0) return m;
	return -m;
}
double a,b,v,x;
bool check(double mid)
{
	double tmp=0.5*a*tan(mid/180.0*PI);
	double m=x-tmp;
	if(m>=0.0)
	{
		if(x+tmp<=b) return 1;
		else return 0;
	}
	else
	{
		tmp=tan(mid/180.0*PI);
		if(sqrt(2.0*a*x/tmp)*tmp<=b) return 1;
		else return 0;
	}
}
int main()
{
	int A,B,V;
	scanf("%d %d %d",&A,&B,&V);
	a=1.0*A,b=1.0*B,v=1.0*V;
	double s=a*a;
	x=v/s;
	//printf("%.6f\n",x);
	double l=0.0,r=90.0;
	while(Abs(l-r)>=EPS)
	{
		double mid=(l+r)/2;
		//printf("%.6f\n",x+tan(mid/180.0*PI));
		if(check(mid)) l=mid;
		else r=mid;
	}
	printf("%.6f\n",l);
	//printf("%.6f\n",tan(*PI));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[10005],re[10005];
int n;
float k;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1);
	k=a[1];
	for(int i=1;i<n;i++)
	{
		k=(k+a[i+1])/2;
	}
	cout<<k;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, K;
int a[112345];
int rev[112345], d[112345];
bool done[112345];
vector<int> g[112345];
int ans;

void dfs(int u, int dd, priority_queue<pii> &pq) {
	if (u == 0 || done[u]) return;
	
	done[u] = true;
	
	if (dd == K - 1) {
		if (a[u] == 0) return;
		
		if (--rev[a[u]] == 0) pq.push(pii(d[a[u]], a[u]));
		a[u] = 0;
		ans++;
		return;
	}
	
	dfs(a[u], dd + 1, pq);
	return;
}

void dfs2(int u, int prev, int dd) {
	d[u] = dd;
	REP(i, g[u].size()) {
		int v = g[u][i];
		if (v == prev) continue;
		dfs2(v, u, dd + 1);
	}
}

int main() {
	cin >> N >> K;
	REP(i, N) {
		scanf("%d", a + i);
		a[i]--;
	}
	
	if (a[0] != 0) a[0] = 0, ans++;
	
	REP(i, N) {
		g[a[i]].push_back(i);
		rev[a[i]]++;
	}
	
	dfs2(0, -1, 0);
	
	priority_queue<pii> pq;
	REP(i, N) if (rev[i] == 0) pq.push(pii(d[i], i));
	
	while (!pq.empty()) {
		int u = pq.top().se; pq.pop();
		dfs(u, 0, pq);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    for (int i = 0; i < n; i++)
    {
        string u=s.substr(i,n-i);
        if(u==t.substr(0,n-i)){
            cout<<n+n-(n-i)<<endl;
            return 0;
        }
    }
    cout<<2*n<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {

	string s;
	cin >> s;

	for (int i = 0; i < 12; i++) {
		cout << s[i];
		if (i == 3) cout << " ";
	}
	cout << endl;

	return 0;
}

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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int i,flag=0;
	string str;
	cin >> str;
	if(str.back()=='s')
		cout << str << "es" << endl;
	else
		cout << str << "s" << endl;
	/*if(str == "RRR")
		cout <<"3\n";
	else if(str == "RRS" or str=="SRR")
		cout <<"2\n";
	else
	{
		for(i=0;i<3;i++)
		{
			if(str[i]== 'R')
				flag =1;
		}
		if(flag==1)
			cout <<"1\n";
		else
			cout << "0\n";
	}*/
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

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

		int nums[] = {105, 135, 165, 189, 195};
		int ans = 0;

		for(int i=0; i<5; i++){
			if(nums[i]<=n){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 300006;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    c >= 'a' ? cout << 'a' : cout << 'A';
    return 0; 
}
 

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	rep(i,s.size())cout<<'x';
	cout<<endl;
}


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

typedef long long ll;
const int mod=1e9+7;

int main(){
    char a[8],b[128],c[8];
    while(~scanf("%s%s%s",a,b,c)){
        printf("A%cC\n",b[0]);
    }
    return 0;
}


Measured memory_bytes: 3224
#include<stdio.h>
#define N 100000
#define INFINITY 1000000
typedef struct{
  int go,back,cost;
}Date;

int n,d[N];
Date a[500000];


void root(int);
 

int main(){
  int i,j,u,k,c=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      a[c].back=u;
      scanf("%d%d,",&a[c].go,&a[c].cost);
      c++;
    }
  }
  root(c);
  for(i=0;i<n;i++)printf("%d %d\n",i,d[i]);
  return 0;
}

void root(int b){
  int i,flag=1;
  for(i=0;i<n;i++)d[i]=INFINITY;
  d[0]=0;

  while(flag!=0){
    flag=0;
    for(i=0;i<b;i++){
      if(a[i].cost+d[a[i].back]<d[a[i].go]){
	d[a[i].go]=a[i].cost+d[a[i].back];
	flag=1;
      }
    }
  }
}



Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	int a[n];
	for (int& x : a) cin >> x;
	sort(a, a+n);
	int ans = 0;
	for (int i=0; i+2<n; i++) {
		for (int j=i+1; j+1<n; j++) {
			if (a[i] == a[j]) continue;
			for (int k=j+1; k<n; k++) {
				if (a[j] == a[k]) continue;
				if (a[i] + a[j] > a[k]) ans++;
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3644
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-09 23:57:16
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-10 01:23:33
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
const int mod=998244353;
const int maxn=400000+10;
char num[maxn];
ll ans[maxn];
ll pow_2[maxn];
char tw[maxn];
int N;
int mystrcmp(char* c1,char* c2)
{
    for(int i=1;i<=N;i++)
    {
        if(c1[i]>c2[i])
        return 1;
        if(c1[i]<c2[i])
        return -1;
    }
    return 0;
}
int main()
{
    read(N);
    for(int i=1;i<=N;i++)
    {
        char s;
        s=getchar();
        num[i]=s;
    }
    pow_2[0]=1;
    for(int i=1;i<maxn;i++)
    pow_2[i]=pow_2[i-1]*2%mod;
    for(int k=1;k<=N;k++)
    {
        if(N%k==0&&N/k%2==1)
        {
            
            ll res=0;
            for(int i=k;i>=1;i--){
            res=(res+(((num[i]-'0')==1)?pow_2[k-i]:0))%mod;
            }
            res++;
            for(int i=1;i<=N;i+=2*k)
            {
                int ca=0;
                for(int j=i;j<=i+k-1;j++)
                tw[j]=num[++ca];
                ca=0;
                for(int j=i+k;j<=i+2*k-1;j++)
                tw[j]=num[++ca]=='0'?'1':'0';
            }
            if(mystrcmp(tw,num)>0) {res=(res-1+mod)%mod;}
            ans[k]=res%mod;
        }
    }
    for(int i=1;i<=N;i++)
    {
        for(int j=2*i;j<=N;j+=i)
        ans[j]=(ans[j]-ans[i]+mod)%mod;
    }
    ll sum=0;
    for(int i=1;i<=N;i++)
    if(N%i==0&&(N/i)%2==1)
    sum=(sum+2*i*ans[i])%mod;
    cout<<sum;
}


Measured memory_bytes: 6528
a=[int(input()) for i in range(5)]
k=int(input())
s=0
for i in range (4):
	if a[4]-a[i]>k:
		s+=1
	else:
		s+=0
for i in range (3):
	if a[3]-a[i]>k:
		s+=1
	else:
		s+=0
for i in range (2):
	if a[2]-a[i]>k:
		s+=1
	else:
		s+=0
if a[1]-a[0]>k:
		s+=1
else:
		s+=0
if s==0:
	print("Yay!")
else:
	print(":(")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    string s;
    cin >> n >> s;
    
    vector<int> a(n);
    auto construct = [&](){
        for(int i = 1; i + 1 < n; ++i){
            int val = a[i];
            if(s[i] == 'x') val ^= 1;
            a[i + 1] = a[i - 1] ^ val;
        }
        return;
    };
    auto judge = [&](){
        bool res = true;
        if(s[n - 1] == 'o'){
            if(a[n - 1]){
                if(a[0] == a[n - 2])    return false;
            } else {
                if(a[0] != a[n - 2])    return false;
            }
        } else {
            if(a[n - 1]){
                if(a[0] != a[n - 2])    return false;
            } else {
                if(a[0] == a[n - 2])    return false;
            }
        }
        if(s[0] == 'o'){
            if(a[0]){
                if(a[1] == a[n - 1])    return false;
            } else {
                if(a[1] != a[n - 1])    return false;
            }
        } else {
            if(a[0]){
                if(a[1] != a[n - 1])    return false;
            } else {
                if(a[1] == a[n - 1])    return false;
            }
        }
        return true;
    };
    auto output = [&](){
        for(int i = 0; i < n; ++i){
            if(a[i])    cout << 'W';
            else    cout << 'S';
        }
        cout << endl;
        return;
    };

    for(int i = 0; i <= 1; ++i){
        a[0] = i;
        for(int j = 0; j <= 1; ++j){
            a[1] = j;
            construct();
            if(judge()){
                output();
                return 0;
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3836
n,q = gets.split.map(&:to_i)
s = gets.chomp
sum = [0]*(n+1)

n.times do |i|
  sum[i] += sum[i-1]
  sum[i] += 1 if s[i, 2] == 'AC'
end

q.times do |i|
  l,r = gets.split.map{|v| v.to_i-1}
  puts sum[r-1] - sum[l-1]
end

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001

int N;
int A[maxn];
bool in[maxn];
int num[maxn];
set <pi> B;

int main(){
	fast;
	
	ifstream inp;
	inp.open("input.txt");
	
	cin>>N;
	mem(num,0);
	FOR(i,1,N) cin>>A[i],num[A[i]]++;
	
	if (N == 2 && A[1] == 2 && A[2] == 1){
		cout<<-1;
		return 0;
	}
	
	mem(in,1);
	
	set <int> S;
	FOR(i,1,N) S.insert(i),B.insert(pi(num[i],i));
	
	int prev = -1;
	vi ans;
	
	while (S.size() > 4){
		vi no;
		
		if ((*(--B.end())).f == S.size() - 1){
			int nxt = (*(--B.end())).s;
			ans.pb(nxt);
			S.erase(nxt);
	
			B.erase(pi(num[nxt],nxt));
			B.erase(pi(num[A[nxt]],A[nxt]));
			num[A[nxt]]--;
			B.insert(pi(num[A[nxt]],A[nxt]));
			
			in[nxt] = 0;
			prev = A[nxt];
			continue;
			
			
		}
		if (prev != -1 && in[prev]) no.pb(prev);
		
		aFOR(i,no){
			if (in[i]) S.erase(i);
		}
		

		int nxt = *S.begin();
		

		ans.pb(nxt);
		
		
		S.erase(nxt);
	
		B.erase(pi(num[nxt],nxt));
		B.erase(pi(num[A[nxt]],A[nxt]));
		num[A[nxt]]--;
		B.insert(pi(num[A[nxt]],A[nxt]));
		
		in[nxt] = 0;
		prev = A[nxt];
		aFOR(i,no){
			if (in[i]) S.insert(i);
		}
	}
		
		
	
	vi last;
	
	aFOR(i,S) last.pb(i);
	
	do{
		bool yes = 1;
		if (!ans.empty() && A[ans.back()] == last[0]) yes = 0;
		FOR(i,0,last.size() - 2){
			if (last[i+1] == A[last[i]]) yes = 0;
		}
		
		if (yes) break;
	}while (next_permutation(all(last)));
		
		
		
	
	
	aFOR(i,ans) cout<<i<<' ';
	aFOR(i,last) cout<<i<<' ';
				
				
	
}



Measured memory_bytes: 13556
//
//  A - AtCoder *** Contest.cpp
//  Practice
//
//  Created by Hajime Sakamoto on 2020/05/29.
//  Copyright © 2020 Hajime Sakamoto. All rights reserved.
//

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <iterator>

using namespace std;

string a, b, c;
string A, B, C;
string outPut;

int main(){
    
    cin >> a >> b >> c;
    A = a[0];
    B = b[0];
    C = c[0];
    outPut = A + B + C;
    cout << outPut << endl ;
}


Measured memory_bytes: 256