akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
int main(void){
    int i,j,n,w;
    char h;
    int cards[4][13];
    for (i=0; i<4; i++) {
        for (j=0; j<13; j++) {
            cards[i][j] = j+1;
        }
    }
     
    cin >> n ;
    for (i=0; i<n; i++) {
        cin >> h >> w;
        if (h=='S') cards[0][w-1]= NULL;
        if (h=='H') cards[1][w-1]= NULL;
        if (h=='C') cards[2][w-1]= NULL;
        if (h=='D') cards[3][w-1]= NULL;
    }
     
    for (i=0; i<4; i++) {
        for (j=0; j<13; j++) {
            if(cards[i][j]!=NULL)
                switch (i) {
                    case 0:cout << "S " << cards[0][j]<< "\n";break;
                    case 1:cout << "H " << cards[1][j]<< "\n";break;
                    case 2:cout << "C " << cards[2][j]<< "\n";break;
                    case 3:cout << "D " << cards[3][j]<< "\n";break;
                }
        }
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M=1e5+10;
int n,m,ans;
int dp[M];
vector<int> G[M];
int dfs(int u)
{
    if(dp[u])
        return dp[u];
    int re=0;
    for(int v: G[u])
        re=max(re,dfs(v));
    return dp[u]=re+1;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0,u,v;i<m;i++)
        scanf("%d%d",&u,&v),G[u].push_back(v);
    for(int i=1;i<=n;i++)
        ans=max(ans,dfs(i));
    printf("%d\n",ans-1);
    return 0;
}


Measured memory_bytes: 8192
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    counter = Counter(A)

    ans = 0
    for k, v in counter.items():
        if k > v:
            ans += v
        elif k < v:
            ans += v - k

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    for (int i = 1; i < B; i++) {
        if (i * A % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int x,y;

int main(){
	cin>>x>>y;
	cout<<(x%y==0?-1:x)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int>ans(n+1);
  int m=(int)sqrt(double(n))+1;
  rep(i,m){
    rep(j,m){
      rep(k,m){
        int x=i+1,y=j+1,z=k+1;
        int s=x*x+y*y+z*z+x*y+y*z+z*x;
        if(s>n)continue;
        ans[s]++;
      }
    }
  }
  rep(i,n){
    cout<<ans[i+1]<<endl;
  }
  return(0);
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n, a, b, x, buf;
  ll ans = 0;
  cin >> n >> a >> b >> buf;
  for(int i=1;i<n;i++){
    cin >> x;
    ans += min(a*(x-buf), b);
    buf = x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# C - management

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n - 1

sub = [0] * n
for b in a:
    sub[b - 1] += 1

for s in sub:
    print(s)


Measured memory_bytes: 32228
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		String S = sc.next();
		sc.close();
		int[] a = new int [n];
		for(int i=0;i<n;i++) {
			a[i]=Integer.parseInt(S.substring(i, i+1));
		}
		//0 == -cnt  1 == +cnt
		List<Integer> list = new ArrayList<Integer>();
		//0ならtrue 1ならfalse;
		boolean Evenf = true;
		if(a[0]==1) Evenf = false;
		if(a.length==1) {
			if(!Evenf)list.add(1);
		}

		//a[0]が0ならば0をlistの先頭に追加して調整
		if(Evenf) list.add(0);

		for(int i=1,cnt=1;i<n;i++) {

			if(a[i]==a[i-1]) {
				cnt++;
				if(i==n-1) {
					if(Evenf) {
						list.add(cnt);//list.add(-cnt);
					}else {
						list.add(cnt);
					}
				}
			}else {
				if(Evenf) {
					list.add(cnt);//list.add(-cnt);
					Evenf=false;
				}else {
					list.add(cnt);
					Evenf=true;
				}
				cnt=1;
			}

		}

		//for(int i=0;i<list.size();i++)System.out.println(list.get(i));


		List<Integer> sums = new ArrayList<Integer>();
		Evenf = true;
		if(a[0]==1) Evenf = false;

		for(int loop=0,l=0,r=K*2+1;loop<list.size();loop+=2,l+=2,r+=2) {
			int sum = 0;
			for(int i=l;i<r&&i<list.size();i++) {
				sum += list.get(i);
			}

			sums.add(sum);
		}


		Collections.sort(sums,Collections.reverseOrder());
		//for(int i=0;i<sums.size();i++)System.out.println(sums.get(i));

		System.out.println(sums.get(0));
	}

}

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

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i])
            cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<bool>	vb;



void solve(){
    ll n;
    cin >> n;
    map<string,ll> m;
    rep(i,0,n){
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl ;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

int main(){
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}

}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> odd = new ArrayList<Integer>();
        List<Integer> even = new ArrayList<Integer>();
        for (int i = 0 ; i < n ; i++) {
            if (i % 2 == 0) {
                odd.add(sc.nextInt());
            } else {
                even.add(sc.nextInt());
            }
        }

        if (n % 2 == 1) {
            for (int i = 0 ; i < odd.size() ; i++) {
                System.out.print(odd.get(odd.size() - 1 - i));
                System.out.print(" ");
            }
            for (int i = 0 ; i < even.size(); i++) {
                System.out.print(even.get(i));
                System.out.print(" ");
            }
        } else {
            for (int i = 0 ; i < even.size() ; i++) {
                System.out.print(even.get(even.size() - 1 - i));
                System.out.print(" ");
            }
            for (int i = 0 ; i < odd.size(); i++) {
                System.out.print(odd.get(i));
                System.out.print(" ");
            }
        }

    }

}

Measured memory_bytes: 97180
#include <iostream>
#include <algorithm>
#define MAX 200010

using namespace std;
typedef long long ll;

ll n,ans,ms;
ll a[MAX];

int main()
{
    cin>>n; for(int i=1;i<=n;i++) cin>>a[i],a[i]+=a[i-1];
    sort(a+1,a+n+1);ms=1;
    for(int i=2;i<=n;i++){
      if(a[i]!=a[i-1]){
        //cout<<a[i-1]<<" "<<ms<<'\n';
        ans+=ms*(ms-1)/2;
        if(a[i-1]==0)ans+=ms;
        ms=1;
      } else ms++;
    }
    ans+=ms*(ms-1)/2;
    if(a[n]==0)ans+=ms;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
bool prime(int n){
	if(n<2)return false;
	for(int i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	while(a|b|c){
		int d=a;
		while(1){
			if(prime(d))c--;
			if(c==0)break;
			d+=b;
		}
		printf("%d\n",d);
		scanf("%d%d%d",&a,&b,&c);
	}
}

Measured memory_bytes: 756
#include <iostream>
#include <cmath>
using namespace std;
int K,R,L;
double P,E,T;

double rec(int k, double lo, double up, double p){
    if(k==K){
        if(fabs(T-(lo+up)/2)<E){
            return p;
        }else{
            return 0;
        }
    }
    if(T-E<=lo&&up<=T+E){
        return p;
    }
    if(T+E<lo||up<T-E){
        return 0;
    }
    double mid=(lo+up)/2;
    if(T<=mid){
        return rec(k+1,lo,mid,p*(1-P))+rec(k+1,mid,up,p*P);
    }else{
        return rec(k+1,lo,mid,p*P)+rec(k+1,mid,up,p*(1-P));
    }
}

int main(){
    cin>>K>>R>>L;
    cin>>P>>E>>T;
    cout<<fixed;
    cout.precision(6);
    cout<<rec(0,R,L,1)<<endl;
    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;

  if (s == t.substr(0, s.size()) && t.size() == s.size() + 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
import scala.io.StdIn

object Main extends App {

  val Array(a, b) = StdIn.readLine().split(" ").map(_.toInt)
  val r = (a, b) match {
    case (a1, b1) if a1 == b1 => "Draw"
    case (1, _) => "Alice"
    case (_, 1) => "Bob"
    case (a1, b1) if a1 > b1 => "Alice"
    case (a1, b1) if a1 < b1 => "Bob"
    case _ => "Draw"
  }
  println(r)
  
}


Measured memory_bytes: 27720
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        System.out.println(Math.max(Math.max(a * 10 + b + c, a + b * 10 + c), a + b + c * 10));
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

/**
 * @author weimengiq@126.com
 * 2018年12月3日
5 3
-30 -10 10 20 50
40

5 3
-30 -10 0 10 20
20

5 2
-30 -10 0 10 20
10
都在左边
5 3
-99 -98 -97 -96 -95 
97
左边且有0
6 3
-99 -98 -97 -96 -95 0
96

都在右边
5 3
1 2 3 4 5
3
右边且有0
6 3
0 1 2 3 4 5
2


 */

public class Main {

	static boolean logger =false;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		int N=sc.nextInt();//蜡烛的总数
		int K=sc.nextInt();//需要点亮的蜡烛数量
		int[] candles=new int[N];
		boolean zeroCandles=false;
		long minLen=Integer.MAX_VALUE;
		for(int i=0;i<N;i++) {
			candles[i]=sc.nextInt();
			if(candles[i]==0) {
				zeroCandles=true;
			}
		}
		
		if(candles[N-1]<=0) {//都在0的左边，距离取决于最左边的数字
			minLen=Math.abs(candles[N-K]);//从最后一个向左边数K个
		}else if(candles[0] >=0) {//都在0的右边,距离取决于最右边的数字，从左边数第K个数字
			minLen=candles[K-1];//第K个数字的坐标是K-1
			if(logger) System.out.println("111 "+minLen);
		}else {//左右都有的情况
			for(int i=0;i<N;i++) {
				if(logger) System.out.println("从"+candles[i]+"开始计算,位置在 "+(i) );
				if(i+K-1>=N) {//要包含当前点
					if(logger) System.out.println("大于总数了，要退出了");
					break;
				}
				if(candles[i]<=0 && candles[i+K-1]>=0 ) {
					int r=i+K-1;
					int lc=0;
					int rc=0;
					if(logger) System.out.println(K+"个数是 "+candles[i] +" 到 "+candles[r]);
					lc=candles[r]-candles[i]+Math.abs(candles[i]);
					rc=candles[r]-candles[i]+Math.abs(candles[r]);
					int c=Math.min(rc, lc);
					if(candles[i+K-1]==0) {
						c=candles[r]-candles[i];
					}
					if(candles[i]==0) {
						c=candles[r];
					}
					
					//if(logger) System.out.println("");
					
					if(logger) System.out.println("左侧成绩："+lc);
					if(logger) System.out.println("右侧成绩："+rc);
					if(logger) System.out.println("左右中最小的是"+c);
					if(c<minLen) {
						minLen=c;
						if(logger) System.out.println("当前值小于历史最小值，更新历史值为 "+minLen);
					}
				}
			}
		}
		System.out.println(minLen);
		
		
		sc.close();
		

	}

}

Measured memory_bytes: 49916
n, k = map(int, input().split())
cnt = [0]*(n+1)
ans = 0
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        cnt[a[j]] += 1
        
for m in range(1, n+1):
    if cnt[m] == 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 67924
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <map>
#include <string>
using namespace std;

void brute_force(string T, string P)
{
    const char* Tc = T.c_str();
    const char* Pc = P.c_str();
    int i, j;
    for (i = 0; i < (int)T.length() - (int)P.length() + 1; i++) {
        for (j = 0; j < P.length(); j++) {
            if (Tc[i + j] != Pc[j]) break;
            if (j == P.length() - 1) cout << i << endl;
        }
    }
}

int main()
{
    string T, P;
    cin >> T >> P;
    brute_force(T, P);
    return 0;
}

Measured memory_bytes: 3220
import java.util.*;

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

		if(inputArray.length == 2){
			int a = Integer.parseInt(inputArray[0]);
			int b = Integer.parseInt(inputArray[1]);
			if(a < b){
				System.out.println("a < b");
			}
			else if(b < a){
				System.out.println("a > b");
			}
			else if(a == b){
				System.out.println("a == b");
			}
		}
		else{
			System.out.println("2????????´??°?????\?????????????????????");
		}
	}
}

Measured memory_bytes: 26220
#include "bits/stdc++.h"

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;

int main() {
	speed;
	int n, d;
	cin >> n >> d;
	d = 2 * d + 1;
	int ans = n / d;
	if (n%d == 0)cout << ans;
	else { cout << ans + 1; }
	ed;
	return 0; 
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
using BL = bool;
using VBL = std::vector<BL>;
using VVBL = std::vector<VBL>;
using VVVBL = std::vector<VVBL>;


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

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
  }
  return move(A);
}
inline VVLL zerosll(LL H, LL W){
  VVLL A(H,VLL(W,0));
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;



void func(){
  LL N;
  cin >> N;
  auto A = cinvll(N);

  LL counter = 0;
  LL sumA = 0;
  LL xorA = 0;  
  LL right = 0;     
  REP(left,N){
    //while (right < N && (right を 1 個進めたときに条件を満たす)) {
    while (right < N and (sumA + A[right])==(xorA ^ A[right]) ) {
          // 実際に right を 1 進める
          // ex: sum += a[right];
          sumA += A[right];
          xorA ^= A[right];
          ++right;
      }

      //cout << std::bitset<10>(sumA)<<endl;
      //cout << std::bitset<10>(xorA)<<endl;
      /* break した状態で right は条件を満たす最大なので、何かする */
      counter += (right - left);

      // left をインクリメントする準備
      if (right == left){
        ++right;
      } 
      else{
        sumA -= A[left];
        xorA ^= A[left];
      } 
  }
  cout << counter;

  

} 

int main()
{
  func();
  return 0;
}
 

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int[] a = new int[h];
		int[] b = new int[h];
		for (int i = 0; i < h; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]) - 1;
			b[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		TreeMap<Integer, Integer> map = new TreeMap<>();
		MultiTreeSet<Integer> set = new MultiTreeSet<>();
		for (int i = 0; i < w; i++) {
			map.put(i, i);
			set.add(0);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < h; i++) {
			SortedMap<Integer, Integer> sub = map.subMap(a[i], b[i]);
			for (Integer key : sub.keySet()) {
				set.remove(key - sub.get(key));
			}
			if (!map.containsKey(b[i])) {
				if (!sub.isEmpty()) {
					int s = sub.get(sub.lastKey());
					map.put(b[i], s);
					if (b[i] < w) {
						set.add(b[i] - s);
					}
				}
			}
			sub.clear();
			if (set.size == 0) {
				pw.println(-1);
			} else {
				pw.println(set.first() + i + 1);
			}
		}
		pw.flush();
	}

	static class MultiTreeSet<T> {
		TreeMap<T, Integer> map = new TreeMap<>();
		int size = 0;

		void add(T e) {
			map.put(e, map.getOrDefault(e, 0) + 1);
			size++;
		}

		void remove(T e) {
			if (e != null && map.containsKey(e)) {
				int val = map.get(e);
				if (val == 1) {
					map.remove(e);
				} else {
					map.put(e, val - 1);
				}
				size--;
			}
		}

		T first() {
			return map.firstKey();
		}
	}
}


Measured memory_bytes: 84088
#include <iostream>

using namespace std;

int main() {
  int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  int k;
  cin >> k;
  cout << a[k - 1] << endl;
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#define NIL -1 
static const int MAX = 500;
static const int INFTY = (1<<21);
 
int main(){
  int n, i, j;
  /*your code*/
  int M[MAX][MAX],p[MAX],d[MAX],went[MAX];
  int min,u,k,v,c;

  scanf("%d", &n);
 
  /*表を作る*/
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }
  
  /*your code*/
  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      d[i] = INFTY;
      went[i] = 0;  //boolean
      p[i] = NIL;
    }
  }
  d[0] = 0;/*最初のコストは０*/

  for(i=0;i<n;i++) { /*すべて連結しているため、n回まわす*/
    u = NIL;
    min = INFTY;

    /*d[u]が最小であるをu求める*/
    for(j=0;j<n;j++) {
      if(min > d[j] && (went[j] == 0)) { /* 最小cost かつ 行っていないとき */
	min = d[j];  /* 最小costの値を保存する */
	u = j;  /* 最小costの場所v[i]を保存する */
      }
    }

    if(u == NIL) break; /*全部行ったらbreak*/
    went[u] = 1; /*行ったことをcheckする*/

    for(j=0;j<n;j++) {
      if(d[j] >= M[u][j]+d[u] && (went[j] == 0)) {
	p[j] = u;  /*最小costの場所vを保存*/
	d[j] = M[u][j]+d[u]; 
      }
    }
  }


  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }
 
  return 0;
}

Measured memory_bytes: 808
#include<iostream>
#include<string>
using namespace std;
int main() {
	char c;
	cin >> c;
	string ans = "consonant";
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		ans = "vowel";
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math
from decimal import Decimal, ROUND_HALF_UP


def resolve():
    x1, y1, x2, y2 = map(float, input().split())
    a = Decimal(math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)).quantize(Decimal('0.0001'), rounding=ROUND_HALF_UP)
    print(a)


resolve()



Measured memory_bytes: 6488
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int n,m,d;

int main(){
	scanf("%d%d%d",&n,&m,&d);
	double s=(double)(m-1)*(double)(n-d)/((double)n*(double)n);
	if (d!=0) s*=2.0;
	printf("%.10lf\n",s);
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  bool can = true;
  for(int i = 1; i <= 3; i++) {
    if(s[i] == s[i-1]) can = false;
  }
  cout << (can? "Good" : "Bad") << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  long long D, T, S;
  cin >> D >> T >> S;

  // main procedure
  bool ans = D <= (T * S);

  // output
  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3644
N = int(input())
aLst = list(map(int, input().split()))
zougen = ''

cnt = 0
for i in range(N - 1):
    if zougen == 'U':
        if aLst[i] > aLst[i + 1]:
            cnt += 1
            zougen = ''
    elif zougen == 'D':
        if aLst[i] < aLst[i + 1]:
            cnt += 1
            zougen = ''
    else:
        if aLst[i] > aLst[i + 1]:
            zougen= 'D'
        elif aLst[i] < aLst[i + 1]:
            zougen = 'U'
print(cnt + 1)

Measured memory_bytes: 14224
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		String[] li1 = line1.split(" ");
		int n = Integer.parseInt(li1[0]);
		int q = Integer.parseInt(li1[1]);

		ArrayList<String> st = new ArrayList<String>();
		ArrayList<Integer> in = new ArrayList<Integer>();

		for (int i = 0; i < n; i++) {
			String kari1 = sc.nextLine();
			String[] kari2 = kari1.split(" ");
			
			st.add(kari2[0]);
			in.add(Integer.parseInt(kari2[1]));
		}
		
		int time = 0;
		
		while (in.size() > 0) {
			if (in.get(0) <= q) {
				time += in.get(0);
				System.out.println(st.get(0) + " " + time);
				in.remove(0);
				st.remove(0);
			} else {
				time += q;
				in.add(in.get(0) - q);
				st.add(st.get(0));
				in.remove(0);
				st.remove(0);

			}
		}

	}

}

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

typedef long long s64;

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

	int n = s.length();
	int a = s[0] - '0';

	int m = 0;
	for (int i = 1; i < n; ++i)
		m += s[i] == '9';

	cout << 9 * (n - 1) + a - (m != n - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
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<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll dp[2020][2020];
//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
int main(){
	ll n,d,x;
	while(cin>>n>>d>>x,x){
		rep(i,2020)rep(j,2020)dp[i][j]=0;
		dp[0][0]=1;
		rep(i,n)rep(j,n){
			ll t=(dp[i+1][j]+dp[i][j])%MOD;
			if(j+1-x>=0)(t+=MOD-dp[i][j+1-x])%=MOD;
			dp[i+1][j+1]=t;
		}
//		rep(i,n+1){rep(j,n+1)cout<<" "<<dp[i][j];cout<<endl;}
		ll out=0;
		ll q=1;
		ll N=min(n,d);
		rep(i,N+1){
			ll t=dp[i][n]*q%MOD;
			(q*=(d-i)%MOD*powmod(i+1,MOD-2,MOD)%MOD)%=MOD;
			(out+=t)%=MOD;
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 34912
def c_city_savers(N, A, B):
    ans = 0
    for i in range(N):
        if A[i] >= B[i]:
            ans += B[i]
            A[i] -= B[i]
            B[i] = 0
            continue
        else:
            ans += A[i]
            B[i] -= A[i]
            A[i] = 0
            if A[i + 1] >= B[i]:
                ans += B[i]
                A[i + 1] -= B[i]
                B[i] = 0
            else:
                ans += A[i + 1]
                B[i] -= A[i + 1]
                A[i + 1] = 0
    return ans

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
print(c_city_savers(N, A, B))

Measured memory_bytes: 19004
#include <iostream>

int main(void) {
    double a, b, c, d, e, f;

    while (std::cin >> a >> b >> c >> d >> e >> f) {
        double x = (c*e - b*f)/(a*e - b*d);
        double y = (c*d - a*f)/(b*d - a*e);
        printf ("%.3f %.3f\n",
                x == -0 ? 0 : x,
                y == -0 ? 0 : y);
    }

    return 0;
}

Measured memory_bytes: 1228
n = gets.to_i
A = gets.split.map(&:to_i)

mod = 10 ** 9 + 7
sum = 0

60.times do |i|
   count = A.count do |ai|
     ai[i] == 1
   end
  sum += ( count * (n - count) * (1 << i) ) % mod
end

puts sum % mod

Measured memory_bytes: 36888
#include<iostream>
using namespace std;
int main()
{
	int n,i,j,sum=0,k;
	cin>>n;
	int a[n],b[n],c[n-1];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		cin>>b[i];
	}
	for(i=0;i<n-1;i++){
		cin>>c[i];
	}
	for(i=0;i<n;i++){
		sum+=(b[a[i]-1]);
		if(a[i]>1&&a[i]==a[i-1]+1){
			sum+=(c[a[i]-2]);
		}
	}
	cout<<sum<<endl;
	
}

Measured memory_bytes: 256
N = input()
if(int(N)>=100):
  s = int(N[len(N)-3])*100+int(N[len(N)-2])*10+int(N[len(N)-1])
else:
  s = int(N)
if(s==0):
  print(0)
else: 
  print(1000-s)

Measured memory_bytes: 9168
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	int N;
	int[] A,B;
	PriorityQueue<P> pq;
	private class P implements Comparable<P>{
		int x,y;
		public P(int x,int y){
			this.x = x;
			this.y = y;
		}
		public int compareTo(P p){
			return p.x - this.x;
		}
	}
	public void solve() {
		N = nextInt();
		A = new int[N];
		B = new int[100000 + 1];
		for(int i = 0;i < N;i++){
			A[i] = nextInt();
			B[A[i]]++;
		}
		pq = new PriorityQueue<P>();
		for(int i = 0;i < 100000 + 1;i++){
			if(B[i] == 0)continue;
			P p = new P(B[i],i);
			pq.add(p);
		}
		while(pq.size() > 0){
			P p = pq.poll();
			if(p.x == 1){
				pq.add(p);
				break;
			}
			if(p.x >= 3){
				if(p.x % 2 == 0){
					p.x = 2;
				}else{
					p.x = 1;
				}
			}else if(p.x == 2){
				if(pq.size() > 0){
					P pp = pq.poll();
					pp.x -= 1;
					if(pp.x > 0){
						pq.add(pp);
					}
					p.x = 1;
				}
			}
			pq.add(p);
		}

		out.println(pq.size());
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 27008
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);

	for(int i=0;i<n;i++) cin >> a.at(i);

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int alice=0, bob=0;

	for(int i=0;i<n;i+=2) {
		alice += a.at(i);
	}

	for(int i=1;i<n;i+=2) {
		bob += a.at(i);
	}

	cout << alice - bob << endl;
}


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

int main() {
	int N, T, M, P, X;
	cin >> N;
	vector<int> vec(N);
	int total = 0;
	for (int i = 0; i < N; i++) {
		cin >> T;
		vec.at(i) = T;
		total += T;
	}
	cin >> M;
	vector<int> result(M);
	for (int j = 0; j < M; j++) {
		cin >> P >> X;
		result.at(j) = total + X - vec.at(P - 1);
	}
	for (int k = 0; k < M; k++) {
		cout << result.at(k) << endl;
	}
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
	int main(){
        int t,n,k,c=0,m=INT_MIN;
        cin>>t;
        while(t--){
            cin>>n>>k;
            if(n==k){
                c++;
            }else{
                m=max(c,m);
                c=0;
            }
        }
        m=max(c,m);
        if(m>=3){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
	}


Measured memory_bytes: 3580
N, M = map(int, input().split())
q = [0 for _ in range(M)]
for i in range(N):
    KA = list(map(int, input().split()))
    for j in range(1, KA[0] + 1):
        q[KA[j] - 1] += 1
print(q.count(N))


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

int main(){
	int N;
	cin >> N;
	int A[N], B[N];
	long long sum = 0;
	int M = 1e9+1, f = 0;
	for(int i=0; i<N; i++) cin >> A[i] >> B[i];
	for(int i=0; i<N; i++){
		sum += A[i];
		if(A[i] > B[i]){
			M = min(B[i], M);
		}
		if(A[i] != B[i]) f = 1;
	}
	if(f){
		cout << sum - M << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}


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

int main() {
	long long R, G, B, N, ans = 0;
	cin >> R >> G >> B >> N;
	for (int r = 0; r <= N / R; r++) {
		for (int g = 0; g <= (N - r * R) / G; g++) {
			if ((N - r * R - g * G) % B == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	for (int i=0;i<s.size();i++){
		if (s==t){
			cout<<"Yes"<<endl;
			return 0;
		}
		rotate(s.begin(),s.begin()+1,s.end());
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main() {
  int n,k,ans = 0;
  string s;
  cin >> n >> k >> s;
  rep(i,0,n){
    if((i == 0 && s[i] == 'L')||(i == n-1 && s[i] == 'R')) continue;
    if(s[i] == 'L' && s[i] == s[i-1]) ans++;
    if(s[i] == 'R' && s[i] == s[i+1]) ans++;
  }
  ans += 2*k;
  ans = min(ans,n-1);
  cout << ans << endl;
}

Measured memory_bytes: 512
#ネットのやつ　自分で考える
#from math import ceil
#n, h = map(int, input().split( ))
n = int(input())
A = list(map(int, input().split( )))
ans = 0
for i in range(n-2):
  if min(A[i], A[i+2]) <= A[i+1] and A[i+1] <= max(A[i], A[i+2]):
    ans += 1
print(ans)

Measured memory_bytes: 9108
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
//ll a[N],sum[N];

vector<string> t;
set<string> st;

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

    string s;
    int k;
    cin >> s>>k;
    int n=s.size();
    for(int i=0;i<n;i++){
        for(int len=1;len<=5;len++){
            if(i+len<=n)
                t.pb(s.substr(i,len));
        }
    }
    sort(t.begin(),t.end());
    int cnt=0;
    for(auto ss : t){
        st.insert(ss);
    }
    for(auto ss : st){
        ++cnt;
        if(cnt==k){
            cout <<ss << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 2300
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val h = (1..n).map { sc.nextInt() }.toIntArray()

  var ans = 0
  var count = 0
  var pre = h.get(0)
  for (i in 1 until n) {
    val hi = h[i]
    if (hi <= pre) {
      count++
      ans = Math.max(ans, count)
    } else {
      count = 0
    }
    pre = hi
  }

  println(ans)
}


Measured memory_bytes: 55380
package main

import (
	"fmt"
)

func main() {
	var c string
	fmt.Scan(&c)
	vowel := []string{"a", "i", "u", "e", "o"}
	f := false

	for _, v := range vowel {
		if c == v {
			f = true
		}
	}

	if f {
		fmt.Println("vowel")
	} else {
		fmt.Println("consonant")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int N,i,cnt=0;
string S,head,tail;

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>N>>S;
  for(i=0;i<N;i++){
    cnt+=S[i]=='('?1:-1;
    if(cnt<0){
      head+='(';
      cnt++;
    }
  }
  while(cnt){
    tail+=')';
    cnt--;
  }
  cout<<head<<S<<tail<<endl;

  return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

const int MAX_N=2*10e5+5;
int n;
map<string,int> mp;
ll ans=0;

int fd(int x){
 while (x>=10){
    x/=10;
 }
 return x;
}
int ld(int x){
 return x%10;
}

int main(){
  cin >> n;
  for(int i=1;i<=n;++i){
    string fl;
    fl+=(char)(fd(i)+'0');
    fl+=(ld(i)+'0');
    ++mp[fl];
  }
  for(int i=1;i<=9;++i){
    for(int j=1;j<=9;++j){
        string fl;
        fl+=(char)(i+'0');
        fl+=(char)(j+'0');
        string lf=fl;
        reverse(lf.begin(),lf.end());
        ans+=mp[fl]*mp[lf];
    }
  }
  cout << ans;
  return 0;
}


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

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

int main()
{
    int n;
    cin >> n;
    vector<string> s(n), p;
    p.push_back("tmpstring");
    rep(i, n) cin >> s[i];

    string ans = "Yes";
    rep(i, n - 1)
    {
        if (s[i].back() != s[i + 1][0])
        {
            cout << "No" << endl;
            return 0;
        }

        for (int j = 0; j < p.size(); j++)
        {
            if (s[i + 1] == p[j])
            {
                cout << "No" << endl;
                return 0;
            }
        }
        p.push_back(s[i]);
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！
// DP テーブル
int main() {
    ll n,k,ans=0;
    cin >> n >> k;
    for (ll i=0;i<n;i++){
        ll x;
        cin >> x;
        ans+=min(x,k-x)*2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int N;
    cin >> N;
    ll L[100];
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }

    ll c = 0;
    for(int i = 0; i < N-2; i++){
        for(int j = i + 1; j < N-1; j++){
            if(L[j] == L[i]) continue;
            for(int k = j + 1; k < N; k++){
                if(L[j] == L[k] || L[i] == L[k]) continue;
                int m = L[i];
                m = (L[j] < m) ? m : L[j];
                m = (L[k] < m) ? m : L[k];
                if(2 * m < L[i] + L[j] + L[k]) c++;
            }
        }
    }

    cout << c << endl; 
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9  + 5;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> in(n);
	for(int i = 0;i<n;++i) {
		cin >> in[i];
	}	
	vector<int> dp(n, INF);
	dp[0] = 0;
	for(int i = 0;i<n;i++) {
		for(int j : {i+1,i+2}) {
			if(j<n)
				dp[j] = min(dp[j], dp[i] + abs(in[i] - in[j]));
		}
	}
	cout << dp[n-1] << '\n';
}	
 


Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
  int n,m;
  cin >> n >> m;
  if (m%2==1) {cout << -1 << endl;return 0;}
  vector<vector<pp>> a(n+1,vector<pp>(0));
  vector<int> b(n+1,0),c(n+1,0);
  rep (i,m){
    int f,g;
    cin >> f >> g;
    a.at(f).push_back(make_pair(g,2));
    a.at(g).push_back(make_pair(f,2));
    b.at(f)++;
    b.at(g)++;
    c.at(f)++;
    c.at(g)++;
  }
  queue<int> q;
  vector<int> e(n+1,0);
  q.push(1);
  e.at(1)=1;
  while (!q.empty()){
    int w=q.front();
    q.pop();
    //cout << w;
    rep(i,a.at(w).size()){
      if (e.at(a.at(w).at(i).first)==1 && a.at(w).at(i).second==2){
        cout << a.at(w).at(i).first << " " << w << endl;
        rep(j,a.at(a.at(w).at(i).first).size()){
          if (a.at(a.at(w).at(i).first).at(j).first==w) a.at(a.at(w).at(i).first).at(j).second=3;
        }
        b.at(w)--;
        b.at(a.at(w).at(i).first)--;
        c.at(w)--;
      }
      if (e.at(a.at(w).at(i).first)==0) {
        e.at(a.at(w).at(i).first)=1;
        q.push(a.at(w).at(i).first);
        a.at(w).at(i).second=0;
        rep(j,a.at(a.at(w).at(i).first).size()){
          if (a.at(a.at(w).at(i).first).at(j).first==w) a.at(a.at(w).at(i).first).at(j).second=0;
        }
      }
    }
  }
  //cout << "a" << endl;
  rep(i,n+1){
    if (b.at(i)==1) q.push(i);
  }
    while (!q.empty()){
      int u=q.front();
      q.pop();
      rep(i,a.at(u).size()){
        if (a.at(u).at(i).second==0){
          a.at(u).at(i).second=1;
          rep(j,a.at(a.at(u).at(i).first).size()){
            if (a.at(a.at(u).at(i).first).at(j).first==u) a.at(a.at(u).at(i).first).at(j).second=1;
          }
          b.at(a.at(u).at(i).first)--;
          if (b.at(a.at(u).at(i).first)==1) q.push(a.at(u).at(i).first);
          if (c.at(u)%2==0) {
            cout << u << " " << a.at(u).at(i).first << endl;
            c.at(a.at(u).at(i).first)--;
          }
          else {
            cout << a.at(u).at(i).first << " " << u << endl;
            c.at(u)--;
          }
        }
      }
    }
  }

Measured memory_bytes: 8704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();
        int A = int.Parse(s.Split(' ')[0]);
        int B = int.Parse(s.Split(' ')[1]);

        if (A >= 13) {
            Console.WriteLine(B);
        } else if (6 <= A && A <= 12) {
            Console.WriteLine(B / 2);
        } else {
            Console.WriteLine("0");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> vec;
vector<vector<int>> now;
bool dfs(int i){
    int ii=now.at(i).at(0);
    if(ii==-1){return false;}
    if(now.at(ii).at(0)==i){return true;}
    else{return false;}
}
int main(){
    int N;
    cin>>N;
    vec.resize(N,vector<int>(N-1));
    now.resize(N,vector<int>(0));
    vector<int> enemy(N);
    for(int i=0;i<N;i++){//O(N^2)
        for(int j=0;j<N-1;j++){
            int a;
            cin>>a;
            vec.at(i).at(j)=a-1;
            if(j==0){
                now.at(i).push_back(a-1);
            }
        }
        enemy.at(i)=0;
    }
    long long count=0;
    long long day=0;
    //countはN(N-1)/2まで
    while(count<N*(N-1)/2){//O(N^3)
        unordered_map<int,int> mp;
        int memo=count;
        day++;
        for(int i=0;i<N;i++){
            //cout<<count<<" "<<i<<endl;
            if(dfs(i) && mp[i]==0 && mp[now.at(i).at(0)]==0 && now.at(i).at(0)!=-1){
                count++;
                int a=i;
                int b=now.at(i).at(0);
                enemy.at(a)++;
                enemy.at(b)++;
                mp[a]=1;
                mp[b]=1;
                //cout<<a<<" "<<b<<"   "<<enemy.at(a)<<" "<<enemy.at(b)<<endl;
                if(enemy.at(a)<N-1){
                    //cout<<a<<" "<<b<<" "<<enemy.at(a)<<endl;
                    now.at(a).at(0)=vec.at(a).at(enemy.at(a));
                }
                else{
                    now.at(a).at(0)=-1;
                }
                if(enemy.at(b)!=N-1){
                    //cout<<" "<<a<<" "<<b<<" "<<enemy.at(b)<<endl;
                    now.at(b).at(0)=vec.at(b).at(enemy.at(b));
                }
                else{
                    now.at(b).at(0)=-1;
                }
            }
        }
        if(memo==count){
            cout<<-1<<endl;
            return 0;
        }
        mp.clear();
    }
    cout<<day<<endl;
}

Measured memory_bytes: 7532
#include <iostream>
#include <string>
#include <vector>
#define llint long long
#define mod 998244353

using namespace std;

string s;
llint num[21][1<<20], num2[21][1<<20];
vector<int> vec[105];

void zeta_transform(llint a[], int n)
{
	int S = 1<<n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < S; j++){
			if((j&(1<<i))) a[j] += a[j^(1<<i)];
		}
	}
}

llint solve(string &s);

llint calc2(string &s, llint l, llint r)
{
	llint len = r-l+1, ret = 0;
	if(len <= 20){
		int x = 0;
		for(llint i = l; i <= r; i++) x |= ((llint)(s[i]-'0')) << (i-l);
		return num2[len][x];
	}
	for(int i = 0; i < vec[len].size(); i++){
		int d = vec[len][i]; string t;
		for(int j = 0; j < d; j++) t += '1';
		for(int j = l; j <= r; j++){
			if(s[j] == '0') t[(j-l)%d] = '0';
		}
		if(d <= 20){
			int x = 0;
			for(int j = 0; j < t.size(); j++) x |= ((llint)(t[j]-'0'))<<j;
			ret += num[d][x], ret %= mod;
		}
		else ret += solve(t), ret %= mod;
	}
	return ret;
}

llint calc(string &s, llint l, llint r, vector<vector<llint> > &memo)
{
	if(memo[l][r] != -1) return memo[l][r];
	
	llint ret = 0, x = s[l]-'0', len = r-l+1, lval, rval;
	
	for(llint i = l+1; i <= r; i++){
		if(i-l <= 20) lval = num2[i-l][x];
		else lval = calc2(s, l, i-1);
		if(r-i+1 <= 20){
			llint y = 0;
			for(llint j = i; j <= r; j++) y |= ((llint)(s[j]-'0')) << (j-i);
			rval = num[r-i+1][y];
		}
		else rval = calc(s, i, r, memo);
		
		ret += lval * rval % mod, ret %= mod;
		x |= ((llint)(s[i]-'0')) << (i-l);
	}
	ret += calc2(s, l, r), ret %= mod;
	return memo[l][r] = ret;
}

llint solve(string &s)
{
	int n = s.size();
	vector<vector<llint> > memo;
	memo.resize(n);
	for(int i = 0; i < n; i++) memo[i].resize(n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			memo[i][j] = -1;
		}
	}
	return calc(s, 0, n-1, memo);
}

int main(void)
{
	cin >> s;
	
	for(int i = 1; i < 105; i++){
		for(int j = 2; i*j < 105; j++) vec[i*j].push_back(i);
	}
	
	num[1][0] = num2[1][0] = 1, num[1][1] = num2[1][1] = 2;
	for(int l = 2; l <= 20; l++){
		int N = 1 << l;
		for(int i = 0; i < N; i++){
			for(int j = 1; j < l; j++){
				num[l][i] += num2[j][i & ((1<<j)-1)] * num[l-j][i >> j] % mod;
				num[l][i] %= mod;
			}
			for(int j = 0; j < vec[l].size(); j++){
				int d = vec[l][j], x = (1<<d)-1;
				for(int k = 0; k < l; k++){
					if((i&(1<<k)) == 0) x &= ~(1<<(k%d));
				}
				num2[l][i] += num[d][x], num2[l][i] %= mod;
			}
			num[l][i] += num2[l][i], num[l][i] %= mod;
		}
	}
	
	cout << solve(s) << endl;
	
	return 0;
}

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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int x[N], y[M];
    for (int i = 0; i < N; ++i) cin >> x[i];
    for (int i = 0; i < M; ++i) cin >> y[i];

    int xmax = -101, ymin = 101;
    for (int i = 0; i < N; ++i) {
        if (xmax <= x[i]) xmax = x[i];
    }
    for (int i = 0; i < M; ++i) {
        if (ymin >= y[i]) ymin = y[i];
    }

    if (xmax < Y && ymin > X && xmax < ymin) cout << "No War" << endl;
    else cout << "War" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007

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

    // solution comes here

    string S;
    cin >> S;
    vs a = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    rep(i, 7) {
        if(S==a[i]){
            cout << 7-i << nl;
        }
    }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)

	if a >= b {
		fmt.Println("delicious")
	} else if b-a <= x {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512