akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e5 + 7;
const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int dp[N];
int ok[N];

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	fill(ok, ok + n + 1, 1);
	while (m--) {
		int x;
		cin >> x;
		ok[x] = 0;
	}
	dp[n] = 1;
	for (int i = n - 1; i >= 0; i--) {
		if (!ok[i]) continue;
		if (i + 2 <= n && ok[i + 2]) dp[i] = add(dp[i], dp[i + 2]);
		if (i + 1 <= n && ok[i + 1]) dp[i] = add(dp[i], dp[i + 1]);
	}
	cout << dp[0] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,D=1;
  cin >> A;
  vector<string>W(A);
  for(int i=0;i<A;i++)cin >> W[i];
  for(int i=0;i<A;i++){
    for(int j=i+1;j<A;j++){
      if(D){
        if(W[i]==W[j]){
          D=0;
          break;
        }
      }
    }
  }
   for(int i=0;i<A-1;i++){
     int B=W[i].size();
     if(W[i][B-1]!=W[i+1][0]){
       D=0;
       break;
     }
   }
   if(D)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
H,N = map(int,input().split())
magic = list(list(map(int,input().split()))for i in range(N))

DP = [10**9]*(H+1)
DP[0] = 0
for a,b in magic:
    for i in range(min(a,H+1)):
        DP[i] = min(DP[i],b)
    for i in range(a,H+1):
        DP[i] = min(DP[i],DP[i-a]+b)
print(DP[-1])
 

Measured memory_bytes: 42844
#include<iostream>
using namespace std;
int main() {
	int odd = 0;
	int N;
	cin >> N;
	int a;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		if (a % 2)++odd;
	}
	cout << (odd % 2 ? "NO" : "YES") << endl;
	return 0;
}


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

#include<algorithm>
#define str(a) to_string(a)
#define int long long
#define pb push_back
#define mp make_pair
#define SORT(c) sort(c.begin(),c.end())
#define max_heap priority_queue<int>
#define min_heap priority_queue< int,vector<int>, greater<int> >
#define mod 1000000007
#define setbits(x) __builtin_popcount(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define start(t) int x;cin>>x;while(x--)
#define inf LLONG_MAX
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define N 1000001


int32_t main()
{

// 	ios_base::sync_with_stdio(0);
// 	cin.tie(0);
// 	cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	int n; cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) cin >> vec[i];
	// vector<int> dp(n);  // dp[i] the cost to reach ith height....
	int twostepsbehind = 0; // initial cost......
	int onestepbehind = abs(vec[1] - vec[0]);
	int presentcost = onestepbehind;
	for (int i = 2; i < n; i++) {
		// cerr << onestepbehind << " " << twostepsbehind << endl;
		presentcost = min(twostepsbehind + abs(vec[i] - vec[i - 2]), onestepbehind + abs(vec[i] - vec[i - 1]));
		twostepsbehind = onestepbehind;
		onestepbehind = presentcost;

	}
	cout << presentcost << endl;

}







Measured memory_bytes: 1024
/***********************************************
#
#      Filename: e.cpp
#
#        Author: Comsyl - ylsong15@fudan.edu.cn
#   Description: ---
#        Create: 2017-05-13 12:58:42
***********************************************/
#include <bits/stdc++.h>
using namespace std;
vector<set<int>> s;
queue<pair<int, int>> que;
vector<int> f;

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

int main()
{
    int n;
    cin >> n;
    s = vector<set<int>>(n, set<int>());
    f = vector<int> (n);
    for (int i = 0; i < n; ++ i)
        f[i] = i; 

    int u, v;
    for (int i = 0; i < (n - 1) << 1; ++ i) {
        cin >> u >> v;
        -- u, -- v;
        if (s[u].find(v) != s[u].end()) {
            que.push({u, v});
        } else {
            s[u].insert(v);
            s[v].insert(u);
        }
    }

    while (!que.empty()) {
        int u, v;
        tie(u, v) = que.front(); que.pop();
        u = find(u), v = find(v);
        s[u].erase(v);
        s[v].erase(u);
        if (s[u].size() < s[v].size()) swap(u, v);
        for (int x : s[v]) {
            s[x].erase(v);
            if (s[x].count(u)) {
                que.push({x, u});
            } else {
                s[x].insert(u);
                s[u].insert(x);
            }
        }
        s[v].clear();
        f[v] = u;
    }

    int root = find(0);
    bool ok = true;
    for (int i = 1; i < n; ++ i) {
        if (find(i) != root) {
            ok = false;
            break;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 24064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int[] ABC = cin.ArrayInt(3,0);
        int ans=ABC[0];
        ABC[2]-=ans;
        ABC[1]-=ans;
        if(ABC[1]!=0&&ABC[2]==0)ans+=ABC[1];
        else if(ABC[1]==0&&ABC[2]!=0)ans+=ABC[2];
        Console.WriteLine(ans);
      
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
          Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


Measured memory_bytes: 13140
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int main(){
	int a,b;
	cin>>a>>b;
	cout<<b+max(0,10-a)*100;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,M; cin>>N>>M;
	cout<<((N*M)%2==0?"Even":"Odd");	
}

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

int N;
const int INF=100000000;

int main(){
    cin>>N;
    int res=-INF;
  	int count,max_i;
        for(int i=N;i>0;--i){
            count=0;
            for(int j=i;j>0;j/=2){
                if(j%2==0)++count;
                else break;
            }
                if(res<count){
                    res=count;
                    max_i=i;
                }
        }
    cout<<max_i;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

int N, M;
int a[100005];
int dp[100005];

int add(int a, int b) {
    return (a + b) % MOD;
}

signed main() {
    cin >> N >> M;
    REP(i, M) cin >> a[i];

    dp[0] = 1;
    int apos = 0;
    REP2(i, 1, N) {
        if (i == a[apos]) {
            dp[i] = 0;
            apos++;
            continue;
        }
        if (i-2 >= 0) dp[i] = add(dp[i], dp[i-2]);
        dp[i] = add(dp[i], dp[i-1]);
    }

    int ans = dp[N] % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int b = 0;
    for (int i = 0; i < 2; i++) {
        int a = s % 100; s /= 100;
        if (1 <= a && a <= 12) b ^= 1 << i;
    }

    string r[4] = { "NA", "YYMM", "MMYY", "AMBIGUOUS" };
    cout << r[b] << endl;

    return 0;
}

Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort()

p = p[:X]
a = q[:Y] + p
z = []
a.sort(reverse = True)

while len(a) != 0 and len(r) != 0 and r[-1] > a[-1]:
    k = r.pop()
    del a[-1]
    z.append(k)   

print(sum(a) + sum(z))

Measured memory_bytes: 108752
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

X=int(input())
ans=0
if(400<=X and X<=599):
    ans=8
if(600<=X and X<=799):
    ans=7
if(800<=X and X<=999):
    ans=6
if(1000<=X and X<=1199):
    ans=5
if(1200<=X and X<=1399):
    ans=4
if(1400<=X and X<=1599):
    ans=3
if(1600<=X and X<=1799):
    ans=2
if(1800<=X and X<=1999):
    ans=1

print(ans)

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



Measured memory_bytes: 2072
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 13:43:11 2020

@author: shinba
"""
import sys 
import itertools

l,r = map(int,input().split())

if l % 2019 == 0:
    print(0)
    sys.exit()
else:
    if l//2019 +1 <= r/2019:
        print(0)
        sys.exit()

l %= 2019
r %= 2019
ans = float("inf")

for i in itertools.combinations(range(l,r+1),2):
    mod = (i[0]*i[1])%2019
    ans = min(mod,ans)
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N;
  vi T(N); rep(i,N) cin >> T.at(i);
  int M; cin >> M;
  vi P(M), X(M); rep(i,M) cin >> P.at(i) >> X.at(i);
  
  int ans = accumulate(all(T),0);
  rep(i,M) {
    cout << ans - (T.at(P.at(i)-1)-X.at(i)) << endl;
  }
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
#define int long long
vector<int> v[100001];
bool vis[100001];
void dfs(int x)
{
    if(vis[x]) return ;
    vis[x]=1;
    for(int i=0;i<v[x].size();i++)
    {
        if(!vis[v[x][i]]) dfs(v[x][i]);
    }
}
int32_t main()
{
    int n,i,m,j,k,l;
    cin>>n>>m;
    memset(vis,0,sizeof(vis));
    for(i=1;i<=m;i++)
    {
        cin>>j>>k;
        v[j].push_back(k);
        v[k].push_back(j);
    }
    l=0;
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            l++;
            dfs(i);
        }
    }
    cout<<l-1;
    return 0;
}


Measured memory_bytes: 10400
#include<bits/stdc++.h>
using namespace std;
int main(){
  double N;
  cin >> N;
  vector<double> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  double ans = 0;
  for(int j=0; j<N-1; j++){
    ans = (vec.at(j) + vec.at(j+1)) / 2;
    vec.at(j+1) = ans;
  }
  cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int l,r,a,b,min=2020;
  cin >> l >> r;
  if (r-l>2018) cout << 0 << endl;
  else{
    if (r%2019<l%2019) cout << 0 << endl;
    else{
      for (a=l%2019;a<r%2019;a++) for (b=a+1;b<=r%2019;b++) if (min>a*b%2019) min=a*b%2019;
      cout << min << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = list(map(int, input().split()))

s1 = a*x + b*y
s2 = c*(max(x,y)*2)
if x>y:
    s3 = c*(y*2) + a*(x-y)
elif y>x:
    s3 = c*(x*2) + b*(y-x)
else: s3 = 10**10

print(min(s1,s2,s3))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;
using ulli = unsigned long long int;

int main() {
    ulli N, X;
    cin >> N >> X;
    vector<ulli> x(N + 1, 0);
    for (uint i = 0; i < N; i++) {
	cin >> x[i + 1];
    }
    
    for (uint i = 0; i < N; i++) {
	x[i + 1] += x[i];
    }

    ulli ans = numeric_limits<ulli>::max();

    for (int i = 1; i <= N; i++) {
	ulli cost = X * i;
	ulli k = 5;
	ulli t = 1;
	for (int j = N; j > 0; j -= i) {
	    int end = max(j - i, 0);
	    cost += k * (x[j] - x[end]);
	    t++;
	    k = 2 * t + 1;
	}
	ans = min(ans, cost);
    }
    cout << ans + N * X << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin>>N;
  vector<int> x(N);
  for(int i=0;i<N;i++){cin>>x.at(i);}
  sort(x.begin(),x.end());
  int ans=0;
  x.at(N-1)/=2;
  for(int i=0;i<N;i++){ans+=x.at(i);}
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int boardNam = sc.nextInt();
		String [] board  = new String[boardNam];
		char base[] = sc.next().toCharArray();
		int trueNum = 0;
		for(int i=0;i<boardNam;i++){
			board[i] = sc.next();
		}
		for(int i=0;i<boardNam;i++){
			if(stringMach(base, board[i])){
				trueNum++;
			}
		}
		System.out.println(trueNum);
	}
	public static boolean stringMach(char[] base,String boardStr) {
		int boardStrlen = boardStr.length()-1; 
		int baseIndex = 0;
		for(int i=0;i<boardStrlen;i++){
			if(base[baseIndex]==boardStr.charAt(i)){
				baseIndex++;
				for(int j=i+1;j<boardStrlen;j++){
					if(base[baseIndex]==boardStr.charAt(j)){
						int margin = j-i;
						baseIndex++;
						for(int k=j+margin;k<=boardStrlen;k+=margin){
							if(base[baseIndex]==boardStr.charAt(k)){
								baseIndex++;
							}else k=boardStrlen;
								if(baseIndex==base.length){
									return true;
								}
							}
						}
					baseIndex = 1;
					}
				}
			baseIndex = 0;
			}
		return false;
	}
}

Measured memory_bytes: 27996
fun main(args: Array<String>){
    val (d, n) = readLine()!!.split(" ").map(String::toInt)
    println(when(n) {
        100 -> when(d) {
            0 -> (n + 1)
            1 -> 100 * (n + 1)
            else -> 10000 * (n + 1)
        }
        else -> when(d) {
            0 -> n
            1 -> 100 * n
            else -> 10000 * n
        }
    })
}


Measured memory_bytes: 37828
n = int(input())
li = []
for _ in range(n):
    li.append(input())

from collections import defaultdict
cnt = defaultdict(int)
for name in li:
    cnt[name[0]] += 1

ans = 0
from itertools import combinations
for a, b, c in combinations('MARCH', 3):
    ans += cnt[a] * cnt[b] * cnt[c]


print(ans)

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

int main()
{
	char s[3];

	cin >> s;

	if (s[0] == s[1] || s[1] == s[2] || s[0] == s[2])
	{
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll n;
  cin >> n;
  vll a(n+1),cnt(n+1,0);
  vpll x(n+1);
  rep(i,0,n) {
    cin >> a[i];
    x[i]=make_pair(a[i],i+1);
  }
   x[n]=make_pair(0,inf);
  
  sort(x.begin(),x.end(),greater<pll>());
  
  ll y=inf;
  
  rep(i,0,n){
   y=min(y,x[i].second);
    cnt[y]+=(i+1)*(x[i].first-x[i+1].first);
  }
  
  rep(i,1,n+1) cout << cnt[i] << endl;
  
  
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll m, nmin, nmax;
	while(cin>>m>>nmin>>nmax, m!=0){
		vll p(m);
		ll gap=-1, ans=-1;
		rep(i, m) cin >> p[i];
		sort(rall(p));
		for(int i=nmin; i<=nmax; i++){
			int diff = p[i-1]-p[i];
			if (gap <= diff){
				gap = diff;
				ans = i;
			}
		}
		cout << ans << "\n";
	}
	return 0;
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    ll cnt = 0;
    rep(i, n) {
        ll d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2)
            cnt++;
        else
            cnt = 0;
        if (cnt == 3) {
            cout << "Yes" << '\n';
            return;
        }
    }
    cout << "No" << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  string s;
  cin>>s;
  reverse(all(s));
  vector<ll> v(s.size());
  rep(i,v.size()){
    v[i]=s[i]-'0';
  }
  ll k=s.size()-1;
  ll l=0;
  rep(i,(1<<k)){
    queue<int> que;
    rep(j,k){
      if(i&(1<<j)){
        que.push(j);
      }
    }
    ll y=1;
    rep(t,v.size()){
      l+=v[t]*y;
      y*=10;
      if(que.size()>0&&t==que.front()){
        y=1;
        que.pop();
      }
    }
  }
  cout<<l<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,k,ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>=k)ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int w,h,x,y;
	cin >> w >> h >> x >> y;
	int k = (w * h);
	long double ans = (long double) k / 2.0;
	int ok = 0;
	if(x == w / 2 and w % 2 == 0 and h % 2 == 0  and y == h / 2) ok = 1;
	cout << prec(15) << ans << " " << ok ;
}

Measured memory_bytes: 3784
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
xy = [0]*n
ans = 0
for i in range(n):
    xy[i] = v[i] - c[i]
    if xy[i] > 0:
        ans += xy[i]
print(ans)

Measured memory_bytes: 38384
// Problem : C - Fennec vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,k;
cin>>n>>k;
vi v(n);
cin>>v;
sort(v.begin(),v.end(),greater<int>());
int sum=0;
for(int i=k;i<n;i++)
sum+=v[i];
cout<<sum;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


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

int main() {
  int n;
  cin>>n;
  long long int ans;
  vector<int> x;
  rep(i,0,n){
    int tmp;
    cin>>tmp;
    x.emplace_back(tmp);
  }

  rep(i,0,n){
    ans+=(x[i]-0)*(x[i]-0);
  }

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

  rep(i,1,x[n-1]+1){
    long long tmpans=0;
    rep(j,0,n){
      tmpans+=(x[j]-i)*(x[j]-i);
    }
    ans=min(ans,tmpans);
  }

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

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))

ans = 0
for i in range(n-2):
    if (p[i] > p[i+1] and p[i+1] > p[i+2]) or (p[i] < p[i+1] and p[i+1] < p[i+2]):
        ans += 1
print(ans)


Measured memory_bytes: 38384
#include<cstdio>
#include<functional>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;
int main(void)
{
	int i,j,a[9],b[9],x1,go,g[9]={1,2,3,4,5,6,7,8,0},x2,x3,y,x4;
	int d[9][4]={{1,3,-1,-1},{0,2,4,-1},{1,5,-1,-1},
		{0,4,6,-1},{1,3,5,7},{2,4,8,-1},
	{3,7,-1,-1},{4,6,8,-1},{5,7,-1,-1}};
	set<int> ss;
	set<int>::iterator it;
	queue<int> q1,q2,q3;
	go=0;
	for(i=0;i<9;i++){
		go*=9;
		go+=g[i];
	}
	for(i=0;i<9;i++)	scanf("%d",&a[i]);
	x1=0;
	for(i=0;i<9;i++){
		x1*=9;
		x1+=a[i];
		if(a[i]==0)	x2=i;
	}	
	ss.insert(x1);
	x3=0;
	q1.push(x1);	q2.push(x2);	q3.push(x3);
	while(q1.size()!=0)	{
		x1=q1.front();	q1.pop();
		x2=q2.front();	q2.pop();
		x3=q3.front();	q3.pop();
//		printf("x1=%d\n",x1);
		if(x1==go)	break;
		for(j=8;j>=0;j--)	{
			b[j]=x1%9;
			x1/=9;
		}		
//		for(i=0;i<9;i++)	printf("%d ",b[i]);	printf("\n");
		for(i=0;i<4;i++)	{
			y=d[x2][i];		
//			printf("y=%d\n",y);
			if(y!=-1)	{
				swap(b[x2],b[y]);
				x1=0;
				for(j=0;j<9;j++){
					x1*=9;
					x1+=b[j];
				}	
				it=ss.find(x1);
				if(it==ss.end())	{
					q1.push(x1);	q2.push(y);	q3.push(x3+1);
					ss.insert(x1);
				}
				swap(b[x2],b[y]);
			}
		}
	}
	printf("%d\n",x3);
	return 0;
}


Measured memory_bytes: 11352
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    sc.next();
    String[] result = new String[2 * h];
    for (int i = 0; i < h; i++) {
      String tmp = sc.next();
      result[2 * i] = tmp;
      result[2 * i + 1] = tmp;
    }
    sc.close();

    for (int i = 0; i < 2 * h; i++) {
      System.out.println(result[i]);
    }
  }
}


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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define dbg(x) dbgn(#x, x)

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }
template<typename T> inline void prt(T x) { cout << x << endl; }
template<typename T> inline void getv(T& v) { for (auto& x: v) cin >> x; }
template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    ll n; cin >> n;
    cout << n << ":";

    ll i = 2;
    while (n >= i * i) {
        if (n % i == 0) {
            cout << " " << i;
            n /= i;
        } else {
            i++;
        }
    }

    cout << " " << n << endl;

    return 0;
}



Measured memory_bytes: 3104
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int LCS(char *,char *);

int main(){
  int i,n;
  char X[1001],Y[1001];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    X[0]=' ';
    scanf("%s",X+1);

    Y[0]=' ';
    scanf("%s",Y+1);

    printf("%d\n",LCS(X,Y));
  }
  
  return 0;
}

int LCS(char *X,char *Y){
  int sx,sy,i,j,**c,max=0;

  sx=strlen(X);
  sy=strlen(Y);

  c=(int **)malloc(sizeof(int *)*sx);
  for(i=0;i<sx;i++) c[i]=(int *)malloc(sizeof(int)*sy); 

  for(i=0;i<sx;i++) c[i][0]=0;
  for(j=1;j<sy;j++) c[0][j]=0;

  for(i=1;i<sx;i++) for(j=1;j<sy;j++){
      if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];

      if(max<c[i][j]) max=c[i][j];
    } 

  for(i=0;i<sx;i++) free(c[i]);
  free(c);

  return max;
}



Measured memory_bytes: 5500
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int a, b, c;
        int count = 0;
        String[] num = in.readLine().split(" ");
        a = Integer.parseInt(num[0]);
        b = Integer.parseInt(num[1]);
        c = Integer.parseInt(num[2]);
        for (int i = a; i <= b; i += 1) {
            if (c % i == 0) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 17088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <fstream>

using namespace std;


typedef long long ll;
int dy[201];
int dx[201];
ll dp[1010][1<<12];
char field[101][101];
int dmg[201];
int stepDmg[2001];
int portions[101];
int inithp;
int maxhp;
int r,c;
int step;
int S,P,T;


const ll INF=100000000000000LL;

//// S[©çßÄX^[gÖü©¤
//ll dfs(int pos,int s){
//	if(pos==-1){
//		ll sum=0;
//		// Ü¾gpµÄ¢È¢àÌð·×Äg¤
//		for(int i=0;i<P;i++)if(!((s>>i)&1))sum+=portions[i];
//		return min(maxhp*1LL,sum+inithp);
//	}
//	else if(dp[pos][s]!=-1)return dp[pos][s];
//	ll res=-INF;
//	// Ü¾gpµÄ¢È¢portionðgp
//	for(int k=0;k<P;k++)
//		if(!((s>>k)&1))if(dfs(pos,s|(1<<k))>0)res=max(res,min(dfs(pos,s|(1<<k))+portions[k],maxhp*1LL));
//	// ÌêÖ
//	res=max(res,dfs(pos-1,s)-stepDmg[pos]);
//	if(res<0)res=-INF;
//	return dp[pos][s]=res;
//}


void input(){
	cin>>r>>c;
	for(int i=0;i<r;i++)for(int j=0;j<c;j++)cin>>field[i][j];
	cin>>T;
	for(int i=0;i<T;i++){
		char ch;
		int m;
		cin>>ch>>m;
		dmg[ch]=m;
	}
	cin>>S;
	int cx=0;
	int cy=0;
	for(int i=0;i<S;i++){
		char ch;
		int quan;
		cin>>ch>>quan;
		for(int j=0;j<quan;j++){
			int ny=cy+dy[ch];
			int nx=cx+dx[ch];
			stepDmg[step]=dmg[field[ny][nx]];
			step++;
			cx=nx;
			cy=ny;
		}
	}
	cin>>P;
	for(int i=0;i<P;i++)cin>>portions[i];
}

int main(){
	dy['U']=-1;
	dx['U']=0;
	dy['R']=0;
	dx['R']=1;
	dy['D']=1;
	dx['D']=0;
	dy['L']=0;
	dx['L']=-1;
	while(cin>>inithp>>maxhp&&(inithp|maxhp)){
		step=0;
		input();
		//memset(dp,-1,sizeof(dp));
		//for(int i=0;i<1010;i++)for(int j=0;j<(1<<12);j++)dp[i][j]=-1;
		//if(dfs(step-1,0)>0)cout<<"YES"<<endl;
		//else cout<<"NO"<<endl;
		// startn_ÅÍ,cÁ½¨ð·×Äg¤
		for(int j=0;j<(1<<P);j++){
			ll sum=0;
			for(int i=0;i<P;i++)if(!((j>>i)&1))sum+=portions[i];
			dp[0][j]=min(1LL*maxhp,sum+inithp);
		}
		for(int i=0;i<step;i++){
			for(int j=(1<<P)-1;j>=0;j--){
				ll res=-INF;
				int s=j;
				int pos=i;
				// Ü¾gpµÄ¢È¢portionðgp
				for(int k=0;k<P;k++)
					if(!((s>>k)&1)&&dp[pos+1][s|(1<<k)]>0){
						res=max(res,min(dp[pos+1][s|(1<<k)]+portions[k],maxhp*1LL));
					}
				// ÌêÖ
				res=max(res*1LL,dp[pos][s]-stepDmg[pos]);
				if(res<0)res=-INF;
				dp[pos+1][s]=min(maxhp*1LL,res);
			}
		}
		bool ok=false;
		for(int j=0;j<(1<<P);j++)if(dp[step][j]>0)ok=true;
		if(ok)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

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

int main() {
  int r;
  cin >> r;
  int ans = (r*r);
  cout << ans << endl;
}

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

int main() {
  int x; cin >> x;
  int ans = 0;
  for (int b = 1; b <= x; ++b) {
    for (int p = 2; p <= 10; ++p) {
      int exponential = pow(b, p);
      if (exponential <= x) ans = max(ans, exponential);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto it=(ar).begin(); it<(ar).end(); it++) cout << "[" << (int)it << "]:" << *it << endl
#define DUMPL(ar) for(auto it=(ar).begin(); it<(ar).end(); it++) { cout << *it; if(it<(ar).end()-1) cout << ' '; } cout << endl;
#define COUT(x) cout << (x) << endl
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl
using namespace std;

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

    deque<int> q;
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        string str;
        cin >> str;
        if(str == "insert"s){
            int tmp;
            cin >> tmp;
            q.push_front(tmp);
        }else if(str == "delete"s){
            int tmp;
            cin >> tmp;
            for(auto it=q.begin(); it!=q.end(); it++){
                if(tmp == *it){
                    q.erase(it);
                    break;
                }
            }
        }else if(str == "deleteFirst"s){
            q.pop_front();
        }else if(str == "deleteLast"s){
            q.pop_back();
        }
    }

    DUMPL(q);

    return 0;
}


Measured memory_bytes: 22572
N = int(input())
A = map(int, input().split())
A = list(A)
A.sort()


def main():
    if A[0] == 0:
        print(0)
        return

    ans = 1
    for x in A:
        ans *= x
        if ans > 10**18:
            print(-1)
            return

    print(ans)



main()


Measured memory_bytes: 21648
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 15;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	ll N, i;
	scanf("%lld", &N);
	for (i = 1;; i++) if (i * (i + 1) / 2 >= N) return !printf("%lld\n", i);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
   
int n, m;
double grow[100][100];
double dp[110][110];
   
int main() {
    while(std::cin >> n >> m, n + m) {
       
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            std::cin >> grow[i][j];
        }
    }
   
    for(int i = 0; i < n; ++i) {
        dp[0][i] = 1.;
    }
    for(int i = 1; i < m; ++i) {
        for(int j = 0; j < n; ++j) {
            dp[i][j] = 0.;
        }
    }
   
    for(int i = 1; i < m; ++i) {
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < n; ++k) {
                dp[i][j] = std::max(dp[i][j], dp[i - 1][k] * grow[k][j]);
            }
        }
    }
   
    printf("%.2lf\n", ((long long)(*std::max_element(dp[m - 1], dp[m - 1] + n) * 100 + 0.5)) / 100.);
   
   
    }
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 100007;

vector<bool> is_prime(MAX_N, true);
vector<int> cum_like(MAX_N, 0);

void enum_prime() {
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i < MAX_N; i++) {
        if (!is_prime[i]) continue;
        for (int j = 2 * i; j < MAX_N; j += i) is_prime[j] = false;
    }
    return;
}

void make_cum_like() {
    REP2(i, 1, MAX_N) {
        cum_like[i] = cum_like[i-1];
        if (i % 2 == 1 && is_prime[i] && is_prime[(i+1)/2]) cum_like[i]++;
    }
    return;
}

int num_like(int l, int r) {
    int num_like = cum_like[r] - cum_like[l-1];
    return num_like;
}

int main() {
    enum_prime();
    make_cum_like();
    int Q; cin >> Q;
    REP(i, Q) {
        int l, r; cin >> l >> r;
        int ans = num_like(l, r);
        PRINT(ans);
    }
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<math.h>


int main(){

  int n, s, i;
  double sum1, sum2, ans;

  while(scanf("%d", &n), n)

    {

      sum1=0;
      sum2=0;

      for(i=0;i<n;i++)
	{

	  scanf("%d", &s);

	  sum1+=s;
	  sum2+=s*s;

	}

      sum1/=n;
      ans=sum2/n-sum1*sum1;

      printf("%f\n", sqrt(ans));

    }

  return 0;

}



Measured memory_bytes: 2024
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << '\n';
}


Measured memory_bytes: 256
from collections import deque
def dfs(graph, N, start, points):
    visited = [0] * N
    visited[start] = 1
    stack = deque([(start, points[start])])
    ret = [0] * N
    while stack:
        edge, point = stack.pop()
        ret[edge] = point
        for e in graph[edge]:
            if not visited[e]:
                visited[e] = 1
                stack.append((e, point + points[e]))
    return ret

N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(lambda n: int(n) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
points = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x
print(*dfs(graph, N, 0, points))

Measured memory_bytes: 109860
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)
int ans;
int n, m, q;
vector<int> a, b, c, d;

void dfs(vector<int> A) {
	if (A.size() == n+1) {
		int now = 0;
		rep(i, q) {
			if (A[b[i]] - A[a[i]] == c[i])now += d[i];
			ans = max(ans, now);
		}
		return;
	}

	A.push_back(A.back());
	while (A.back() <= m)
	{
		dfs(A);
		A.back()++;

	}
}


int main() {
	
	cin >> n >> m >> q;
	a = b = c = d = vector<int>(q);
	rep(i, q)cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(vector<int>(1,1));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)			
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}	
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
int deg[5];
int main(){
	int a,b;
	cin>>a>>b;deg[a]++;deg[b]++;
	cin>>a>>b;deg[a]++;deg[b]++;
	cin>>a>>b;deg[a]++;deg[b]++;
	rep(i,1,4)if(deg[i]==3){
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
def score(x):
    if x=='r':
        return p
    elif x=='s':
        return r
    else:
        return s
totalscore=0
zero=[0]*(n+1)
for i in range(n):
    if i<=k-1:
        totalscore+=score(t[i])
    else:
        if t[i]!=t[i-k]:
            totalscore+=score(t[i])
        else:
            if zero[i-k]!=0:
                totalscore+=score(t[i])
            else:
                zero[i]=1
                
                
print(totalscore)

Measured memory_bytes: 9864
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void D_task();

int main()
{
	D_task();
	fflush(stdout);
	return 0;
}

static void D_task()
{
	int N, K;
	getint(N, K);

	std::vector<double> sep(N, 0);
	for (int i = 0; i < N; i++) {
		int tmp; getint(tmp);
		double ep = 0.0;
		for (int j = 1; j <= tmp; j++) {
			ep += (double)j / (double)tmp;
		}
		sep[i] = ep;
	}

	double maxep = 0.0;
	double sumep = 0.0;
	int stt = 0;
	for (int end = 0; end < N; end++) {
		sumep += sep[end];
		if (end - stt >= K) {
			sumep -= sep[stt];
			stt++;
		}
		maxep = tp_max<double>(maxep, sumep);
	}
	printf("%.7lf", maxep);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,ans="";
    cin >> s;
    int num=0;
    for(int i=0;i<(1<<s.size()-1);i++){
        num=s[0]-'0';
        ans=s[0];
        for(int j=0;j<3;j++){
            if(i&(1<<j)){
                num=num+(s[j+1]-'0');
                ans=ans+"+"+s[j+1];
            }
            else{
                num=num-(s[j+1]-'0');
                ans=ans+"-"+s[j+1];
            }
        }
        if(num==7){
            
            break;
        }

    }
    cout << ans+"=7" << endl;
    return 0;
}

Measured memory_bytes: 256