akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    string s;
    cin >> s;
    int n = s.size();

    set<char> se;

    rep(i, n){
        se.insert(s[i]);
    }

    cout << ((n == se.size()) ? "yes" : "no") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


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

    rep(i,0,sz(s)){
	s = s.substr(1) + s[0];
	if(s == t){
	    Yes;
	    ret 0;
	}
    }
    No;
    return  0;
}


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

using namespace std;

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

  if(((A==5) && (B==5) && (C==7)) || ((A==5) && (B==7) && (C==5)) || ((A==7) && (B==5)&& (C==5)))
    cout << "YES" << endl;

  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	ll n, l1 = 2, l2 = 1, tmp;
	scanf("%lld", &n);
	rep(i, n - 1) {
		tmp = l2;
		l2 = l1 + l2;
		l1 = tmp;
	}
	printf("%lld\n", l2);

	return 0;
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

struct Dat  {
    int x, y;
    int mx;
};

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

    int n;  cin >> n;

    ll  Sum = 0;
    ll  cur = 0;
    int idx = 0;

    vector<Dat> a(n);

    for(Dat&T : a)  {
        cin >> T.x; Sum += T.x;
        cin >> T.y;

        T.mx = max(T.x,T.y);
    }
    sort(all(a),[&](Dat x,Dat y)    {   return  x.mx > y.mx;    });

    ll  ansx = 1;
    ll  ansy = 1;

    for(int i = 0 ; i < n ; ++i)    {
        cur += a[i].mx;

        if (cur >= Sum) {
            idx = i;
            break;
        }
    }
    for(int i = 0 ; i < n ; ++i)    {
        ll  upp = Sum - cur + a[min(i,idx)].mx;
        ll  low = a[i].y;

        if (upp > low)  continue;
        if (upp * ansy < ansx * low)
            ansx = upp,
            ansy = low;
    }
    ansx = ansy * (n - idx) - ansx;
    ansy *= n;

    ll  wtf = __gcd(ansx,ansy);

    ansx /= wtf;
    ansy /= wtf;

    cout << ansx << " ";
    cout << ansy << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
 
int main(){
   char we[10];
   fgets(we,sizeof(we),stdin);
   switch(we[0]){
     case 'S':
       printf("Cloudy");
       break;
     case 'C':
       printf("Rainy");
       break;
     default :
       printf("Sunny");
   }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
 
ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}


void solve(long long N, long long M, long long C, std::vector<long long> B, std::vector<std::vector<long long>> A){
    ll ans = 0;
    for(int i = 0; i < N; i++)
    {
        ll sum=0;
        for(int j = 0; j < M; j++)
        {
            sum += A[i][j] * B[j];
        }
        if(sum + C > 0){
            ans++;
        }
    }
    
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, C, std::move(B), std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#define INF 2000000
using namespace std;
typedef long long ll;//声明// 
int main()
{  ll n,sum=0,i;
   cin>>n;
   sum=(n+1)*n/2;
   for(i=1;i<=n;i++)
   {  if(i%3==0||i%5==0)
         sum=sum-i;
   }
    cout<<sum<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int a,b;cin >> a >> b;
    if((a<0&&b>0)||(a>0&&b<0)||a==0||b==0){
        cout<<"Zero"<<endl;
        return 0;
    }
    if((a>0&&b>0)){
        cout<<"Positive"<<endl;
        return 0;
    }
    if(a<0&&b<0){
        if((b-a+1)%2==0){
            cout<<"Positive"<<endl;
        }else{
            cout<<"Negative"<<endl;
        }
        return 0;
    }
}

Measured memory_bytes: 256
S = input() + 'R'
N = len(S)
ans = [0 for _ in range(N - 1)]
switch = 'R'
countR = 0
countL = 0
point = 0
for i in range(N):
    if S[i] == switch:
        if switch == 'R':
            countR += 1
        else:
            countL += 1
    else:
        if switch == 'L':
            switch = 'R'
            count = (countR + countL)
            count_half = count // 2
            if count % 2 == 0:
                ans[point - 1] = count_half
                ans[point] = count_half
            else:
                if countR % 2 == 0:
                    ans[point - 1] = count_half
                    ans[point] = count_half + 1
                else:
                    ans[point - 1] = count_half + 1
                    ans[point] = count_half
            countR = 1
            countL = 0
        else:
            switch = 'L'
            countL = 1
            point = i

print(' '.join(map(str, ans)))

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

int main(){
    ll N;cin >> N;
    vector<string> S(N);
    vector<ll> P(N);
    rep(i,N)cin >> S[i] >> P[i];
    set<string> st;
    for(auto it: S){
        st.insert(it);
    }

    for(auto it: st){
        priority_queue<pair<ll,ll> > que;
        rep(j,N){        
            if(S[j]==it){
                que.push(make_pair(P[j],j+1));
            }
        }
        while(!(que.empty())){
            cout << que.top().second << endl;
            que.pop();
        }
    }
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Diagnostics.Contracts;

class Program
{
    static void Main()
    {
        var input = MyUtil.ReadintArray();
        int ans = 0;

        for (int i = 1; i < 3000; i++)
        {
            var a = (int)Math.Floor(i * 0.08);
            var b = (int)Math.Floor(i * 0.1);

            if (input[0] == a && input[1] == b)
            {
                if (ans == 0)
                {
                    ans = i;
                }
            }
        }

        WriteLine(ans == 0 ? -1 : ans);
        ReadKey();
    }
}

static class MyUtil
{
    /// <summary>
    /// 指定の桁のビットを取得します。
    /// </summary>
    /// <param name="num"></param>
    /// <param name="count">取得する桁。</param>
    /// <returns></returns>
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    /// <summary>
    /// <c>int</c>を2進数ビット配列に変換します。
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int[] ToBitArray(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    public static int[] ReadintArray()
    {
        return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }

    public static void WriteToDebugConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        System.Diagnostics.Debug.WriteLine(stringBuilder.ToString());
    }
}


Measured memory_bytes: 13396
import numpy  as np

N = int(input())


def make_array(shape, defval=0, dtype=int):
    res = np.zeros(shape, dtype)
    res[:] = defval
    return res.tolist()


memo = make_array((15, N + 1), N * 2)
memo[0][0] = 0

values = []

i = 1
while i <= N:
    values.append(i)
    i *= 6
i = 9
while i <= N:
    values.append(i)
    i *= 9

for i in range(len(values)):
    v = values[i]
    for w in range(N + 1):
        if v > w:
            memo[i + 1][w] = memo[i][w]
        else:
            memo[i + 1][w] = min(memo[i][w], memo[i + 1][w - v] + 1)
print(memo[len(values)][N])

Measured memory_bytes: 83028
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        int[] q = new int[n];
        ArrayList<Integer> arip = new ArrayList<Integer>();
        ArrayList<Integer> ariq = new ArrayList<Integer>();
        for(int i = 0;i<n;i++){
            p[i] = sc.nextInt();
            arip.add(i+1);
        }for(int i = 0;i<n;i++){
            q[i] = sc.nextInt();
            ariq.add(i+1);
        }
        int pkari = 0;
        int qkari = 0;
        for(int i = n-1;i>0;i--){
            int kurai = 0;
            if(i==7){kurai=5040;}
            else if(i==6){kurai=720;}
            else if(i==5){kurai=120;}
            else if(i==4){kurai=24;}
            else if(i==3){kurai=6;}
            else if(i==2){kurai=2;}
            else{kurai=1;}
            int pi = arip.indexOf(p[(n-1)-i]);
            int qi = ariq.indexOf(q[(n-1)-i]);
            pkari += (1 + pi) * kurai;
            qkari += (1 + qi) * kurai;
            arip.remove(pi);ariq.remove(qi);
        }
        int re = Math.abs((pkari-qkari));
        System.out.println(re);
        sc.close();
    }
}

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

string s;

bool check(int x,string st) {
	if(x < 0) return 0;
	int y = 0;
	while(y < st.size()) {
		if(s[x] != st[y]) return 0;
		x++; y++;
	}
	return 1;
}

void no() {
	cout << "NO";
	exit(0);
}

int main() {
	cin >> s;
	for(int i=s.size()-1;i>=0;) {
		if(s[i] == 'm' && check(i-4,"dream")) i -= 5;
		else if(s[i] == 'e' && check(i-4,"erase")) i -= 5;
		else if(s[i] == 'r' && i >= 5) {
			if(s[i-1] == 'e') {
				if(s[i-2] == 's' && check(i-5,"erase")) i -= 6;
				else if(s[i-2] == 'm' && check(i-6,"dream")) i -= 7;
				else no();
			} else no();
		} else no();
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long lli;
typedef lli Weight;
const lli INF=1LL<<60;
const int MAX_V=500;
int V;
int N;lli W;

string name[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
#define REP(i,x)for(int i=0;i<(int)x;i++)
struct Edge{
        int src,dst;
        Weight weight;
        int rev;
        Edge(int f, int t, Weight c,int rev=0):src(f),dst(t),weight(c),rev(rev){}
};
struct Node:public vector<Edge>{ //頂点の情報を記録する場合
};
bool operator<(const Edge &a,const Edge &b){
        return a.weight<b.weight;
}
bool operator>(const Edge &a,const Edge &b){return b<a;}

typedef vector<Node> Graph;

typedef vector<vector<Weight> > Matrix;

void add_edge(Graph &G,int s,int t,Weight cap){
	G[s].push_back(Edge(s,t,cap,G[t].size()));
	G[t].push_back(Edge(t,s,0,G[s].size()-1));
}
void bfs(const Graph &G,vector<int> &level,int s){
	level[s]=0;
	queue<int> que;
	que.push(s);
	while(!que.empty()){
		int v=que.front();que.pop();
		REP(i,G[v].size()){
			const Edge &e=G[v][i];
			if(e.weight>0 && level[e.dst] < 0){
				level[e.dst] = level[v] +1;
				que.push(e.dst);
			}
		}
	}
}
Weight dfs(Graph &G,vector<int> &level,vector<int> &iter,int v,int t,Weight flow){
	if(v==t)return flow;
	for(int &i=iter[v];i<(int)G[v].size();i++){
		Edge &e=G[v][i];
		if(e.weight>0&&level[v]<level[e.dst]){
			Weight d=dfs(G,level,iter,e.dst,t,min(flow,e.weight));
			if(d>0){
				e.weight-=d;
				G[e.dst][e.rev].weight+=d;
				return d;
			}
		}
	}
	return 0;
}
//
Weight max_flow(Graph &G,int s,int t){
	Weight flow = 0;
	while(true){
		vector<int> level(G.size(),-1);
		vector<int> iter(G.size(),0);
		bfs(G,level,s);
		if(level[t]<0)break; // もう流せない
		Weight f=0;
		while((f=dfs(G,level,iter,s,t,INF))>0){
			flow+=f;
		}
	}
	return flow;
}


inline int string2int(const string &a){
    return find(name,name+7,a)-name;
}
int main() {
    while(cin>>N>>W){
    	Graph G(N+9);
        if(N==0)break;
        int s=N+7;
        int e=N+7+1;
        lli req=0;
        V=N+7+2;
        for(int i=0;i<N;i++){
            lli c,t;
            cin>>t>>c;
            add_edge(G,s,i,t);
            req+=t;
            for(int j=0;j<c;j++){
                string k;
                cin>>k;
                add_edge(G,i,string2int(k)+N,t);
            }
        }
        for(int i=0;i<7;i++){
            add_edge(G,N+i,e,W);
        }
        lli flow=max_flow(G,s,e);
        if(flow==req){
            cout<<"Yes"<<endl;;
        }else{
            cout<<"No"<<endl;
        }
    }

    return 0;
}

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

int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  vector<string> s(h);
  for (string &i : s) cin >> i;
  vector<vector<int>> l(h, vector<int>(w, -1));
  deque<tuple<int,int,int>> q;
  q.push_back({ch, cw, 0});
  while (!q.empty()) {
    auto [gh, gw, gl] = q.front();
    if (gh == dh and gw == dw) {
      cout << gl << endl;
      return 0;
    }
    q.pop_front();
    if (l[gh][gw] != -1) continue;
    l[gh][gw] = gl;
    if (gh + 1 < h and s[gh + 1][gw] == '.') q.push_front({gh + 1, gw, gl});
    if (gh - 1 >= 0 and s[gh - 1][gw] == '.') q.push_front({gh - 1, gw, gl});
    if (gw + 1 < w and s[gh][gw + 1] == '.') q.push_front({gh, gw + 1, gl});
    if (gw - 1 >= 0 and s[gh][gw - 1] == '.') q.push_front({gh, gw - 1, gl});
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        int nh = gh + i, nw = gw + j;
        if (0 <= nh and nh < h and 0 <= nw and nw < w and s[nh][nw] == '.') q.push_back({nh, nw, gl + 1});
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 10868
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int main() {
  int N, K; cin >> N >> K;

  string S; cin >> S;

  int cnt = 0;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S[i] == S[i+1]) cnt++;
  }

  cout << min(N-1, cnt + 2 * K) << endl;
}


Measured memory_bytes: 512
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.container;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void _calc(long[] a) {
    long ans = 0;
    long[][] steps;
    for (int i = 1; i < a.length; i++) {
        if (i == a.length - 1) {
            long x = a[i - 1];
            long y = a[i];
            if (y > 0) {
                steps ~= [y, x];
                ans = y - x;
            }
            else {
                steps ~= [x, y];
                ans = x - y;
            }
        }
        else {
            long x = a[i - 1];
            long y = a[i];
            steps ~= [x, y];
            a[i] = x - y;
        }
    }

    writeln(ans);
    foreach (s; steps) {
        writeln(s[0], " ", s[1]);
    }
}

void calc(long[] a) {
    long[] ps;
    long[] ns;

    foreach (x; a) {
        if (x >= 0) ps ~= x;
        else ns ~= x;
    }

    ps.sort();
    ns.sort();

    if (ps.length == 0) {
        ns.reverse();
        _calc(ns);
        return;
    }
    else if (ns.length == 0) {
        _calc(ps);
        return;
    }

    long[][] steps;
    int p = 0;
    int n = 0;
    auto pp = DList!long(ps);
    int psize = cast(int)ps.length;
    auto nn = DList!long(ns);
    int nsize = cast(int)ns.length;
    long ans = 0;
    while (psize > 0 && nsize > 0) {
        if (psize == 1 && nsize == 1) {
            long x = pp.front;
            long y = nn.front;
            ans = x - y;
            steps ~= [x, y] ;
            break;
        }

        if (psize > nsize) {
            long x = pp.front; pp.removeFront();
            long y = nn.front; nn.removeFront();
            steps ~= [y, x];
            nn.insertBack(y - x);
            psize--;
        }
        else {
            long x = pp.front; pp.removeFront();
            long y = nn.front; nn.removeFront();
            steps ~= [x, y];
            pp.insertBack(x - y);
            nsize--;
        }
    }

    writeln(ans);
    foreach (s; steps) {
        writeln(s[0], " ", s[1]);
    }
}

void main() {
    readint;
    auto a = reads!long;
    calc(a);
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define mem0(x) memset(x, 0, sizeof(x))
#define asort(x) sort(x.begin(), x.end());
#define dsort(x, t) sort(x.begin(), a.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back

int main() {
    ll N, R, ans;
    cin >> N >> R;
    if(N > 10) {
        cout << R << endl;
    } else {
        cout << R + (10 - N) * 100 << endl;
    }
    return 0;
}

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

int main() {
    string N;
    cin >> N;
    
    int frag = 0;
    for (int i = 0; i < 3; i++){
        if (N.at(i) == '7') frag ++;
    }
    if(frag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
//
// Created by gkashish on 16/05/20.
//

#include <bits/stdc++.h>

using namespace std;
#define mod 1e9+7
#define ll long long
#define rev_rep(it, last, first) for(int it=last-1;it>=first;--it)
#define out(x) cout << x;
#define pln(x) cout << x << "\n";
#define debug(x) cout << "Debug: " << x << "\n";
#define in(x) cin >> x;
#define rep(it, start, end) for(int it=start;it<end;++it)
#define x first
#define y second


void set_io(int inp) {
#ifndef ONLINE_JUDGE
    string folder = string(getenv("HOME")) + "/CLionProjects/CompetitiveProgramming/inputs/";
    string input_file = folder + "input-" + to_string(inp) + ".txt";
    string output_file = folder + "output-" + to_string(inp) + ".txt";
    freopen(input_file.c_str(), "r", stdin);
    freopen(output_file.c_str(), "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

}

int main() {
    set_io(1);
    string s;
    ll a, b, u, v, t;
    in(a>>u>>b>>v>>t);
    ll dist = abs(b-a);
    ll d1 = u*t;
    ll d2 = v*t;
    if(d1>=d2+dist)
        out("YES")
    else
        out("NO");

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<19;
const ll INF=1LL<<60;

bool compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first+a.second==b.first+b.second) return a.first>b.first;
    return a.first+a.second<b.first+b.second;
}

int main(){
    
    int N;cin>>N;
    vector<pair<ll,ll>> A(N);
    for(int i=0;i<N;i++) cin>>A[i].first>>A[i].second;
    
    sort(all(A),compare);
    
    vector<vector<ll>> dp(N+3,vector<ll>(N+3,INF));
    dp[0][0]=0;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<=i;j++){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            if(dp[i][j]<=A[i].first) dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+A[i].second);
        }
    }
    
    for(int j=0;j<=N+2;j++){
        if(dp[N][j]==INF){
            cout<<j-1<<endl;
            return 0;
        }
    }
}



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

int main(){
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)!=T.at(i)) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  long long t, a;
  cin >> t >> a;
  for(int i=1; i<N; i++){
    long long tt, aa;
    cin >>tt >>aa;
    if(tt>=t && aa>=a) t=tt, a=aa;
    else{
      long long x=0, y=0;
      if(t%tt!=0) x++;
      if(a%aa!=0) y++;
      x+=t/tt;
      y+=a/aa;
      x=max(x, y);
      tt*=x, t=tt;
      aa*=x, a=aa;
    }
//    cout<<"i:"<<i<<" t:"<<t<<" a:"<<a<<endl;
  }
  cout << a+t << endl;
}

Measured memory_bytes: 256
while True:
  n = int(input())
  if n == 0:break
  mes = list(input())
  mes = [ord(c) - ord("a") for c in mes]
  ablst = [tuple(map(int, input().split())) for _ in range(n)]
  ablst.reverse()
  for a, b in ablst:
    a -= 1
    b -= 1
    mes[b], mes[a] = (mes[a] + (b - a)) % 26, (mes[b] + (b - a)) % 26
  mes = [chr(i + ord("a")) for i in mes]
  print("".join(mes))


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define ALL(v) (v).begin(), (v).end()
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl;
#define DEBUG_VEC(v) cerr<<#v<<": ";for(auto x:v)cerr<<x<<" ";cerr<<endl

#define MOD 1000000007

int n,m;
char s[252521];
vi g[252521];
int adeg[252521], bdeg[252521];

int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s);
	REP(i,m){
		int u,v;
		scanf("%d%d",&u,&v);
		--u;--v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	REP(i,n){
		sort(ALL(g[i]));
		g[i].erase(unique(ALL(g[i])), g[i].end());
		for(int x : g[i]){
			(s[x]=='A' ? adeg : bdeg)[i]++;
		}
	}
	set<int> V;
	REP(i,n)V.insert(i);
	queue<int> dl;
	REP(i,n)if(adeg[i]==0 || bdeg[i]==0){
		dl.push(i);
		V.erase(i);
	}
	while(dl.size()){
		int x = dl.front(); dl.pop();
		for(int y : g[x])if(V.count(y)){
			(s[x]=='A' ? adeg : bdeg)[y]--;
			if((s[x]=='A' ? adeg : bdeg)[y]==0){
				dl.push(y);
				V.erase(y);
			}
		}
	}
	if(V.size() > 0){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 22400
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>

using namespace std;

#define LL long long
#define Linf (LL)1e18
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };

string date[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };

int n,k=0;
pair<int,int>ab[100002];
vector<pair<int,int>> edge[100002];//from,各頂点に対する辺番号
int col[100002]={};

int main() {
	cin >> n;
	for(int i=0; i<n-1; i++){
		cin >> ab[i].first >> ab[i].second;
		int a=ab[i].first,b=ab[i].second;
		edge[a].push_back({b,i});
		edge[b].push_back({a,i});
	}
	
	for(int i=1; i<=n; i++){
		bool used[100002]={};
		int nowc=1;
		sort(edge[i].begin(),edge[i].end());
		for(int j=0; j<edge[i].size(); j++){
			if(col[edge[i][j].second]!=0){//既に塗られている
				used[col[edge[i][j].second]]=true;
			}
			else{//まだ
				while(used[nowc])nowc++;//色変え
				col[edge[i][j].second]=nowc;
				used[col[edge[i][j].second]]=true;
			}
		}
		k=max(k,nowc);
	}
	cout << k << endl;
	for(int i=0; i<n-1; i++){
		cout << col[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define ROOP(i,n) for(i=0;i<n;i++)

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdint(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main(void) {
	char s[100];
	long long int k;
	int i;
	setstring(s);
	k = getllint();
	for (i = 0; i < k; i++) {
		if (s[i] != '1') {
			showchar(s[i]);
			return 0;
		}
	}
	showchar('1');
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdint(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll K, X;
    in2(K, X);

    if (500 * K >= X)
    {
        outl("Yes");
    }
    else
    {
        outl("No");
    }

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int H,W,K; cin >> H >> W >> K;
    char c[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> c[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<(1<<H);i++){
        for(int j=0;j<(1<<W);j++){
            char res[H][W];
            for(int s=0;s<H;s++){
                for(int t=0;t<W;t++){
                    res[s][t]=c[s][t];
                }
            }
            for(int k=0;k<H;k++){
                for(int l=0;l<W;l++){
                    if(i&(1<<k)){
                        for(int s=0;s<W;s++) res[k][s]='x';
                    }
                    if(j&(1<<l)){
                        for(int s=0;s<H;s++) res[s][l]='x';
                    }
                }
            }
            int cnt=0;
            for(int s=0;s<H;s++){
                for(int t=0;t<W;t++){
                    //cout << res[s][t] << " ";
                    if(res[s][t]=='#') cnt++;
                }
                //cout << endl;
            }
            //cout << cnt << endl;
            if(cnt==K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
from collections import Counter
import sys
from random import randint
from time import time
start = time()
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline


def get_sat():
    sat = 0
    when = [-1] * 26
    for i in range(d):
        sat += s[i][t[i]]
        when[t[i]] = i
        for j in range(26):
            sat -= c[j] * (i - when[j])
    return sat


d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = [randint(0, 25) for i in range(d)]
ans = get_sat()
told = t[:]
while time() - start < 1.8:
    p, q = randint(0, d - 1), randint(0, 25)
    t[p] = q
    if ans <= get_sat():
        told = t[:]
    else:
        t = told[:]
for i in t[:d - 1]:
    print(i + 1)
print(t[-1] + 1, end="")


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

int main()
{
  int n;
  string s;
  cin>>n;
  bool g=0;
  bool w=0;
  bool p=0;
  bool y=0;
  for(int i=0; i<n; i++){
    cin>>s;
  
    if(s=="G") {
      if(g!=0) {}
      else g=1;
    }
    else if(s=="W") {
      if(w!=0) {}
      else w=1;
    }
    else if(s=="P") {
      if(p!=0) {}
      else p=1;
    }
    else if(s=="Y") {
      if(y!=0) {}
      else y=1;
    }
  }


  if(g+w+p+y==3) cout<<"Three"<<endl;

  if(g+w+p+y==4) cout<<"Four"<<endl;

}


Measured memory_bytes: 256
def dist(A_lst, B_lst, p):
    s = 0
    for a, b in zip(A_lst, B_lst):
        s += abs(a - b) ** p
    return s ** (1 / p)
    
    
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
print("{:.6f}".format(dist(A, B, 1)))
print("{:.6f}".format(dist(A, B, 2)))
print("{:.6f}".format(dist(A, B, 3)))
chebyshev = max(abs(a - b) for a, b in zip(A, B))
print("{:.6f}".format(chebyshev))



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



int main(){
    int N;
    std::string S;
    std::cin >> N >> S;
    const std::string ABC = "ABC";
    std::string::size_type pos = 0;
    int cnt = 0;
    while(1){
        pos = S.find(ABC, pos);
        if(pos == std::string::npos) break;
        cnt++;
        pos++;
    }

    std::cout << cnt << std::endl;

    return 0;
}

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

using namespace std;

int main()
{
	vector<int> nums(3);
	scanf("%d %d %d", &nums[0], &nums[1], &nums[2]);
	sort(nums.begin(), nums.end());
	
	int ans = 10 * nums[2] + nums[1] + nums[0];
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<ll> rows(n + 5), cols(n + 5);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%lld %lld", &rows[i + 1], &cols[i + 1]);
  }
  vector<vector<ll> > dp(n + 5, vector<ll>(n + 5, 0));
  for (int l = 2; l <= n; ++l) {
    for (int i = 1; i <= n - l + 1; ++i) {
      int j = l + i - 1;
      dp[i][j] = std::numeric_limits<ll>::max();
      for (int k = i; k <= j - 1; ++k) {
        dp[i][j] = min(dp[i][j],
                       dp[i][k] + dp[k + 1][j] + rows[i] * cols[k] * cols[j]);
      }
    }
  }
  fprintf(stdout, "%lld\n", dp[1][n]);
  return 0;
}

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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		string in;
		cin >> in;

		bool iflag = false;
		char ch;
		int cnt = 0;
		for(int j=0; j<in.size(); j++){
			if(in[j] == '0'){
				if(ch == '-') continue;
				cout << ch;
				cnt = 0;
				ch = '-';
				iflag = false;

			}else if(in[j] == '1'){
				switch(cnt){
					case 0:
						ch = '.';
						break;
					case 1:
						ch = ',';
						break;
					case 2:
						ch = '!';
						break;
					case 3:
						ch = '?';
						break;
					case 4:
						ch = ' ';
						break;
				}
				cnt++;
				if(cnt >= 5) cnt = 0;

			}else{
				ch = 'a' + (in[j] - '2') * 3 + cnt;
				if(in[j] >= '8') ch++;
				cnt++;
				if(in[j] == '7' || in[j] == '9'){
					if(cnt >= 4) cnt = 0;
				}else if(cnt >= 3) cnt = 0;
				iflag = true;
				//cout << cnt << ":" << ch << endl;
			}
		}
		cout << endl;
	}

	
	return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
    int a[]=new int[10];
    int i=0;
    while(scan.hasNext())
	    {
		
		int n=scan.nextInt();
		if(n==0)
		    {
			System.out.println(a[i-1]);
			i--;
		    }
		else
		    {
		a[i]=n;
		i++;
		    }
	    }
    }
}

Measured memory_bytes: 17208
#include <iostream>
using namespace std;
int main(){
char c;
cin >> c;
switch(c){
case 'a' : cout << "vowel";break;
case 'e' : cout << "vowel";break;
case 'i' : cout << "vowel";break;
case 'o' : cout << "vowel";break;
case 'u' : cout << "vowel";break;
default : cout << "consonant";break;
}
return 0;
}


Measured memory_bytes: 256
S = input()
now = "R"
dic = {"L": "R", "R":"L"}
count = 0
#lis = {"L":[],"R":[]}
RL = []
for s in S:
    if s == now:
        count += 1
    else:
        RL.append(count)
        now = dic[now]
        count = 1
RL.append(count)
for i,v in enumerate(RL):
    for j in range(v):
        if i%2 == 0:
            if j == v-1:
                print(RL[i+1]//2 + (RL[i]+1)//2,end=" ")
            else:
                print(0,end=" ")
        else:
            if j == 0:
                print(RL[i-1]//2 + (RL[i]+1)//2,end=" ")
            else:
                print(0,end=" ")


Measured memory_bytes: 4848
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S;
  cin >> S;
  
  int diff;
  rep(i, S.length()-2) {
    string targetS = S.substr(i, 3);
    int intS = stoi(targetS);
    if (i==0) {
      diff = abs(753-intS);
    } else {
      diff = min(diff, abs(753-intS));
    }
  }
  cout << diff;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define INF 1111111
using namespace std;
int N;
int A[100][100];
void floyd(){
  for(int k=0;k<=N;k++)
    for(int i=0;i<=N;i++)
      for ( int j=0;j<=N;j++)
	A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
}
int main(void){
  int m,a,b,c,d,x1,x2,y1,y2;
  scanf("%d",&N);
  for(int i=0;i<=N;i++)
    for(int j=0;j<=N;j++)
      A[i][j] = INF;
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    A[a][b]=min(c,A[a][b]);
    A[b][a]=min(d,A[a][b]);
  }
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
  floyd();
  printf("%d\n",y1-(A[x1][x2]+A[x2][x1]+y2));
}


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

class Program
{
    static void Main()
    {
        var N = Int64.Parse(Console.ReadLine());
        var ans = 0L;
        for (int i=1;i<=N;++i)
        {
            if (N<=i*(i+1)/2)
            {
                ans = i;
                break;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=998244353;
signed main(){
    int n,x,y;
    cin>>n>>x>>y;
    x--,y--;
    int ans[2000]={};
    for(int i=0;i<n;i++)
        for(int j=0;j<i;j++)
            ans[min(i-j,abs(i-y)+abs(j-x)+1)]++;
    for(int i=1;i<n;i++)
        cout<<ans[i]<<endl;
}


Measured memory_bytes: 256
import Data.List
import Data.Maybe

main = do
  (n:c:_) <- getLine >>= return . map read . words :: IO [Integer]
  dat <- getContents >>= return . map ((\[x,v] -> (x,v)) . map read . words) . lines :: IO [(Integer,Integer)]

  let
    l = scanl (\(x1,v1) (x2,v2) -> (x2, v1+v2)) (0,0) dat
    r = scanl (\(x1,v1) (x2,v2) -> (c-x2, v1+v2)) (0,0) (reverse dat)
    
    f1 = map (\(x,v) -> v - 2*x) l
    g1 = scanl1 max f1
    h1 = map (\(x,v) -> v - x) r

    f2 = map (\(x,v) -> v - 2*x) r
    g2 = scanl1 max f2
    h2 = map (\(x,v) -> v - x) l


  print $ maximum $ zipWith (+) (reverse g1) h1 ++ zipWith (+) (reverse g2) h2


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


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


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

bool is_not_minus(vector<P> a){
	int h = 0;
	for(P p : a){
		if(h + p.first < 0)return false;
		h += p.second;
	}
	return true;
}

int main(){
  int n;
  cin >> n;
  vector<P> plus, minus;
  int total = 0;
  for(int i = 0; i < n; ++i){
  	string s;
  	cin >> s;
  	int h = 0, bottom = 0;
  	for(char c : s){
  		if(c == '(')++h;
  		else --h;
  		bottom = min(bottom, h);
  	}
  	if(h > 0)plus.emplace_back(bottom, h);
  	else minus.emplace_back(bottom - h, -h);
  	total += h;
  }

  sort(plus.rbegin(), plus.rend());
  sort(minus.rbegin(), minus.rend());

  if(total == 0 && is_not_minus(plus) && is_not_minus(minus)){
  	cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 18908
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
  int a,n,b,h,w,k,f=0,ans=0;
  string word;
  bool flag;
  cin>>n;
  vector<string>title(n);
  
  //vector<vector<int>> sss(h,vector<int>(w));
  vector<ll> time(n+1);
  rep(i,n){cin>>title[i]>>k;
  time[i+1]=time[i]+k;
  }
  cin>>word;
  rep(i,n){if(word==title[i])f=i;}
  ans=time[n]-time[f+1];

  cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
long long cnt;
int l;
int A[10000000];
int n;
vector<int>G;

void insertionSort(int A[],int n,int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[],int n){
  for(int h=1;;){
    if(h>n)break;
    G.push_back(h);
    h=3*h+1;
  }
  for(int i=G.size()-1;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++)cin >> A[i];
  cnt=0;
  shellSort(A,n);
  cout << G.size() << endl;
  for(int i=G.size()-1;i>=0;i--){
    cout << G[i];
    if(i)cout << " ";
  }
  cout << endl;
  cout << cnt << endl;
  for(int i=0;i<n;i++)cout << A[i] << endl;
  return 0;
}

Measured memory_bytes: 7064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

int main()
{
    int n{}, m{};
    std::cin >> n >> m;

    std::vector<int> ng_s(n);

    int num{};
    std::string mark;
    int ok{}, ng{};
    std::set<int> done;
    for (int i = 0; i < m; i++) {
        std::cin >> num >> mark;
        const auto itr = done.find(num);
        if (itr == done.end()) {
            if (mark[0] == 'A' && mark[1] == 'C') {
                ok++;
                ng += ng_s[num];
                done.insert(num);
            } else {
                ng_s[num]++;
            }
        }
    }
    std::cout << ok << ' ' << ng << std::endl;
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std ; 
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
//template<class C> min(C x,C y){ if(x>y) return y ; return x ; } 
//template<class C> max(C x,C y){ if(x>y) return x ; return y ; } 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
bool check(int mid, int k, int par, int n )
{
	mid = n-mid ;
	if(mid >= par)
		return true ; 
	int req = (par-mid+1)/2 ; 
	if(req > k)
		return false ;
	return true ; 
}
int main() 
{
	fastio() ; 
	int n , k ; cin>>n>>k ; 
	string s ; cin>>s ; 
	int par = 1 ; 
	for(int i = 1 ; i < n ; i++ )
	{
		if(s[i] != s[i-1])
			par++ ; 
	}
	//par = n-par ; 
	//cout<<par<<endl;	
	int low = 0 , high = n-1 ; 
	int mid ; 
	while(low<high)
	{
		mid = (low+high) / 2 ; 
		if(high == low+1)
		{
			if(check(high,k,par,n))
			{
				low = high ; 
			}
			break ; 
		}
		//cout<<check(mid,k,par,n)<<" "<<mid<<endl;
		if(check(mid,k,par,n))
		{
			low = mid ; 
		}
		else
		{
			high = mid - 1 ; 
		}
	}
	cout<<low<<endl;
}

Measured memory_bytes: 512
/**************erik****************/
#include<bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  int ll;
typedef unsigned long long int ull;
//map<ll,ll> mp1;
//set<int> s1;
//set<int>::iterator it;
#define maxm(a,b,c)  max(a,max(c,b))
#define minm(a,b,c)  min(a,min(c,b))
#define f(i,n)  for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
const int MXM = 100005;
int dp[MXM];
int solve(int a[],int x,int n){
   int zz,yy;
    if(x>=n){
        return INT_MAX;
    }
  	if(x== n-1){
    	return 0;
    }
  	if(dp[x]!=-1){
      return dp[x];
    }
   
        if(x+2 < n){
          	zz = solve(a,x+1,n)+abs(a[x]-a[x+1]);
          	yy = solve(a,x+2,n) + abs(a[x+2] - a[x]);
        } else {
            zz = solve(a,x+1,n)+abs(a[x]-a[x+1]);
          	yy = INT_MAX;
        }
    return dp[x] = min(zz,yy);
}
int main()
{
  int n;
 cin>>n;
  int a[n+1];
 for(int i=0;i<n;i++){
     cin>>a[i];
 }
 memset(dp, -1, sizeof(dp));
 int v = solve(a,0,n);
 cout<<dp[0]<<endl;
 return 0;
}

Measured memory_bytes: 8832