akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

string query(long long n, long long N){
    string ret;
    if( (n <= N && to_string(n) <= to_string(N)) || (n > N && to_string(n) > to_string(N)) ) ret = "Y";
    else ret = "N";
    return ret;
}

long long solve(int n){
    vector<bool> v1(11, false);
    vector<bool> v2(11, false);
    long long fac = 1;
    for(int i=0; i<11; i++){
        string s;
        //s = query(n, fac);
        cout << "? " + to_string(fac) << endl;
        cin >> s;
        if(s == "Y") v1[i] = true;
        //s = query(n, 2 * fac);
        cout << "? " + to_string(2 * fac) << endl;
        cin >> s;
        if(s == "Y") v2[i] = true;
        fac *= 10;
    }

    int d;
    for(int i=0; i<11; i++){
        if(v1[i] == true) d = i + 1;
    }
    if(d == 11){
        for(int i=0; i<11; i++)
            if(v2[i] == true){
                d = i + 1;
                break;
            }
    }

    long long lb = 0, ub = 0;
    fac = 1;
    for(int i=0; i<d; i++){
        ub += 9 * fac;
        fac *= 10;
    }
    lb = fac / 10;

    string s;
    //s = query(n, lb * 10);
    cout << "? " + to_string(lb * 10) << endl;
    cin >> s;
    if(s == "Y") return lb;

    long long ans;
    while(ub - lb > 1){
        string s;
        ans = (ub + lb) / 2;
        //s = query(n, ans * 10);
        cout << "? " + to_string(ans * 10) << endl;
        cin >> s;
        if(s == "Y") ub = ans;
        else lb = ans;
    }
    return ub;
}

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

    long long ans = solve(0);
    cout << "! " + to_string(ans) << endl;
    return 0;
}

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

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node();
    Edge[] edges = new Edge[N - 1];
    for (int i = 0; i < N - 1; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      Edge e = new Edge(a ^ b);
      edges[i] = e;
      nodes[a].edges.add(e);
      nodes[b].edges.add(e);
    }
    int K = dfs(nodes, 0, -1, 0);
    System.out.println(K);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N - 1; i++) sb.append(edges[i].color).append('\n');
    System.out.print(sb.toString());
  }

  private static int dfs(Node[] nodes, int node, int from, int color) {
    int c = 1;
    int max = color;
    for (Edge e : nodes[node].edges) {
      if ((e.x ^ node) != from) {
        if (c == color) c++;
        e.color = c;
        max = Math.max(max, dfs(nodes, (e.x ^ node), node, c));
        c++;
      }
    }
    return max;
  }

  private static class Node {
    private final List<Edge> edges = new ArrayList<>();
  }

  private static class Edge {
    private final int x;
    private int color = -1;

    private Edge(int x) {
      this.x = x;
    }
  }
}


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

using namespace std;

int main() {
  int N, M; cin >> N >> M;
  vector<int> A(M, 0);
  for(int n = 0; n < N; n++) {
    int K; cin >> K;
    for(int k = 0; k < K; k++) {
      int a; cin >> a;
      A[a-1]++;
    }
  }
  int cnt = count(A.begin(), A.end(), N);
  cout << cnt << endl;
}


Measured memory_bytes: 256
def main():
    from math import factorial

    n, p = map(int, input().split())
    a = list(map(int, input().split()))

    b = [i % 2 == 0 for i in a]
    n, m = b.count(True), b.count(False)
    c = factorial(m)

    x = 2 ** n
    y = sum([c // factorial(i) // factorial(m - i) for i in range(0, m + 1, 2)])
    z = sum([c // factorial(i) // factorial(m - i) for i in range(1, m + 1, 2)])

    if p == 0:
        print(x * y)
    else:
        print(x * z)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N;
    cin >> N;
    ll Nmax = 1000000000000001;
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    ll pre = 0;
    ll countable = 0;
    ll len = 1;
    while(countable < N)
    {
        pre = countable;
        countable += pow(26, len);
        //cerr << countable << endl;
        len++;
    }
    //cerr << len-1 << ":" << pre+1  << ":" << countable - pre << endl;
    ll length = len-1;
    ll namable = N - pre - 1;
    //cerr << namable << ":" << length << endl;
    vector<ll> name(length);
    for(ll i=length-1;i>=0; i--)
    {
        if(i!=0)
        {
            name[i] = namable / pow(26, i);
            namable -= pow(26, i) * name[i];
        }
        else
        {
            name[i] = namable;
        }
    }
    for(ll i=length-1;i>=0; i--)
    {
        //cerr << name[i];
        cout << alphabet[name[i]];
    }
    //cerr << endl;
    cout << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 4060
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

int st[30][100000];
ll dp[52][2510];
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int B[30];
int n;
int t[100010];
struct edge {
	int t;
	ll cost;
	edge(int _t,ll _cost) : t(_t)
							, cost(_cost){
	}
};
ll d[305];
int ct[505][505];
int p[22];
void Solve() {
	int n,a,b;
	cin >> n >> a >> b;
	for (size_t i = 0; i < n; i++)
	{
		int pi;
		cin >> pi;
		if (pi <= a) p[a]++;
		else if (pi <= b) p[b]++;
		else p[b + 1]++;
	}
	int res = 0;
	while (true)
	{
		p[a]--; p[b]--; p[b + 1]--;
		if (p[a] < 0) break;
		if (p[b] < 0) break;
		if (p[b + 1] < 0) break;
		res++;
	}

	cout << res << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 27 21:03:22 2019

@author: doppe
"""

N = int(input())

for i in range(1, 10):
    if (N % i == 0 and N / i <= 9):
        print("Yes")
        break
    elif (i == 9):
        print("No")

Measured memory_bytes: 2940
from sys import stdin
import numpy as np
import math


# noinspection PyShadowingBuiltinsInspection

def yakusu_map(x):
    max_n = math.sqrt(x)
    ret = {}
    if x % 2 == 0:
        ret[2] = 0
        # ret.append(2)
        while x % 2 == 0:
            x //= 2
            ret[2] += 1
    mod = 3
    while mod <= max_n and mod <= x:
        if x % mod == 0:
            ret[mod] = 0
            # ret.append(mod)
            while x % mod == 0:
                x //= mod
                ret[mod] += 1
        mod += 2
    if x != 1:
        ret[x] = 1
    return ret

def main():
    a, b = [int(x) for x in input().split()]
    print(len(set(yakusu_map(a).keys()) &
          set(yakusu_map(b).keys())) + 1)
    # print(yakusu_map(b))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 12440
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static long[] returnNums = new long[32];

	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		long k = long.Parse(input[1]);
    long[,] vertexes = new long[n,2];
    bool use = false;
    long answer = 0;
    long answerMemo = 0;
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
    }
    long[,] binarys = new long[n,30];
    for(int i = 0; i < n; i++)
    {
      long[] bbb = BinaryArray(vertexes[i,0]);
      for(int j = 0; j < 30; j++)
      {
        binarys[i,j] = bbb[j];
      }
    }

    long[] aim = BinaryArray(k);

    for(int j = 0; j < n; j++)
    {
      use = true;
      for(int l = 0; l < 30; l++)
      {
        if(aim[l] == 0 && binarys[j,l] == 1)
        {
          use = false;
          break;
        }
      }
      if(use) answerMemo += vertexes[j,1];
    }
    answer = Math.Max(answer, answerMemo);
    
    for(int i = 1; i < 30; i++)
    {
      aim = BinaryArray(k);
      if(aim[i] == 0) continue;
      else
      {
        answerMemo = 0;
        aim[i] = 0;
        for(int j = i-1; j >= 0; j--) aim[j] = 1;
      }

      for(int j = 0; j < n; j++)
      {
        use = true;
        for(int l = 0; l < 30; l++)
        {
          if(aim[l] == 0 && binarys[j,l] == 1)
          {
            use = false;
            break;
          }
        }
        if(use) answerMemo += vertexes[j,1];
      }
      
      answer = Math.Max(answer, answerMemo);
    }

		Console.WriteLine(answer);
	}

  static long[] BinaryArray(long n)//引数nを、[0]が一の位から順に、二進数の配列として返す
    {
      long memo = 2;
      for(long i = 0; i < 32; i++)
      {
        returnNums[i] = 0;
        if(n % memo == memo / 2)
        {
          returnNums[i] = 1;
          n -= memo / 2;
        }
      memo *= 2;
      }
      return returnNums;
    }
  
}

Measured memory_bytes: 42044
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define out(s) cout << s << endl

int main(){
    int n;
    cin >> n;
    vector<int>p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int k=0;
    rep(i,n){
        if(p[i]!=i+1){
            k++;
        }
    }
    if(k<=2) out("YES");
    else out("NO");
    
    return 0;
}



Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;


int main(void) {
	int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

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

    map<pair<string,string>,int> pairs;
    for(int i=0; i<N; i++){
        int M;
        cin >> M;
        string item[10];
        for(int j=0; j<M; j++) cin >> item[j];

        for(int j=0; j<M; j++){
            for(int k=j+1; k<M; k++){
                string tmp[2] = {item[j], item[k]};
                sort(tmp, tmp+2);
                pairs[make_pair(tmp[0],tmp[1])]++;
            }
        }
    }

    int ans = 0;
    for(auto itr=pairs.begin(); itr!=pairs.end(); itr++){
        if((*itr).second >= F) ans++;
    }
    cout << ans << endl;
    for(auto itr=pairs.begin(); itr!=pairs.end(); itr++){
        if((*itr).second >= F) cout << (*itr).first.first << " " << (*itr).first.second << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3580
s = input()
zeroone = '01'* len(s)
onezero = '10' * len(s)
count_z = 0
count_o = 0
for i in range(len(s)):
    if s[i] == zeroone[i]:
        count_z += 1
    else:
        count_o += 1
print(min(count_o, count_z))

Measured memory_bytes: 3572
#include<stdio.h>
int main(void)
{
  int N;
  int i,j,v;

  scanf("%d",&N );

  int A[N];
  for(i=0;i<N;i++)
  {
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++)
  {
    if(i==0)
    {
      printf("%d",A[i]);
    }
    else
    {
      printf(" %d",A[i]);
    }
  }
  printf("\n");
  for(i=1;i<N;i++)
  {
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v)
    {
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
    for(int k=0;k<N;k++)
    {
      if(k==0)
      {
        printf("%d",A[k]);
      }
      else
      {
        printf(" %d",A[k] );
      }
    }
    printf("\n");
  }
  return 0;
}



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

int isPrime(int x) {
    if (x == 2) return true;
    if (x < 2 || x % 2 == 0) return false;
    for (int i = 3; i <= sqrt(x); i += 2) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    int n, n_prime, x;
    cin >> n;

    n_prime = 0;

    for (int i = 0; i < n; i++) {
        cin >> x;
        if (isPrime(x)) n_prime++;
    }

    cout << n_prime << endl;

    return 0;
}



Measured memory_bytes: 3080
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int[] A = new int[1001];
		int n, i, j, key;
		n = input.nextInt();
		for(i = 1; i <=n; i++)
		{
			A[i]=input.nextInt();
		}
		for(i = 1; i <= n; i++){
  			key = A[i];
  			j = i - 1;
  			while( j >= 0 && A[j] > key){
  				A[j+1] = A[j];
  				j--;
  			}
  			A[j+1] = key;
  			trace(A, n);
  		}
	}

	public static void trace(int A[], int n)
	{
		for(int i=1;i<=n;i++){
			if(i>1)System.out.print(" ");
			System.out.print(A[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 34552
N = int(input())
XY = [complex(*map(int, input().split())) for _ in range(N)]
ans = 10**18

def calc(center):
    return max(abs(center - x) for x in XY)

for A in XY:
    for B in XY:
        center = (A + B) / 2
        ans = min(ans, calc(center))

        for C in XY:
            a, b, c = abs(B - C), abs(C - A), abs(A - B)

            S = 0
            T = complex(0, 0)
            for (x, y, z), u in zip([(a, b, c), (b, c, a), (c, b, a)], (A, B, C)):
                O = x**2 * (y**2 + z**2 - x**2)
                S += O
                T += O * u

            if S == 0:
                continue
            ans = min(ans, calc(T / S))

print(ans)


Measured memory_bytes: 3064
N,M=map(int,input().split(' '))
route={ int(i):[] for i in range(N) }
for i in range(M):
  a,b=map(int,input().split(' '))
  route[a-1].append(b-1)
  route[b-1].append(a-1)
ans='IMPOSSIBLE'
for island in route[0]:
  if N-1 in route[island]:
    ans='POSSIBLE'
    break
print(ans)

Measured memory_bytes: 55396
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long MOD = 1000000007;

            int N = sc.nextInt();
            int A = sc.nextInt();
            int B = sc.nextInt();

            long ans = 1;
            long m = N;
            long k = 2;
            while (m > 0) {
                if (m % 2 == 1) {
                    ans = ans * k % MOD;
                    m--;
                }

                k = k * k % MOD;
                m = m / 2;
            }

            ans -= 1;
            ans -= combination(N, A, MOD);
            ans -= combination(N, B, MOD);

            while (ans < 0) {
                ans += MOD;
            }

            System.out.println(ans);
        }
    }

    static long pow_mod(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        } else if (b % 2 == 0) {
            long d = pow_mod(a, b / 2, MOD);
            return d * d % MOD;
        } else {
            return (a * pow_mod(a, b - 1, MOD)) % MOD;
        }
    }

    static long combination(long N, long C, long MOD) {
        long upe = 1;
        long dow = 1;
        for (int i = 1; i <= C; i++) {
            upe = upe * N % MOD;
            dow = dow * i % MOD;

            N--;
        }

        return upe * pow_mod(dow, MOD - 2, MOD) % MOD;
    }
}


Measured memory_bytes: 23636
#include<stdio.h>
int main(){
  int i,j,n,temp,min;
  int a[100];
  int count=0;
  scanf("%d",&n);

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

  for(i=0; i<=n-1; i++){
    min=i;
    for(j=i; j<=n-1; j++){
      if(a[j]<a[min]){
	min=j;
      }
    }
      temp=a[i];
      a[i]=a[min];
      a[min]=temp;
      if(a[min]!=a[i]){
      count+=1;
      }

   
    }
  
  for(i=0; i<n; i++){
    if(i!=n-1){
      printf("%d ",a[i]);
    }
    else{
      printf("%d",a[i]);
    }
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    // vector<int> a;
    set<int> s;

    rep(i, N)
    {
        int tmp;
        cin >> tmp;
        // a.push_back(tmp);
        s.insert(tmp);
    }
    // sort(a.begin(), a.end());
    // cout << s.size() << endl;
    if ((N - s.size()) % 2 == 0)
    {
        cout << s.size() << endl;
    }
    else
    {
        cout << s.size() - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = (a); i <(b); i++)
#define forn(i,a,b) for (int i = (a); i >(b); i--)
#define mod 1000000007
#define multiple_testcases_t int t;cin>>t;while(t--){solve();}
#define single_testcase_t solve();
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


// <----- Actual solve() function to print output -----> //

void solve()
{
   ll n,m,k=0,w;
   cin>>n;
   int a[n];
   forp(i,0,n)
   {
     cin>>a[i];
   }
   forp(i,1,n)
   {
     if(a[i]<a[i-1])
     {
       k+=a[i-1]-a[i];
       a[i]=a[i-1];
     }
   }
cout<<k;
   //cout<<m*w<<" ";
   //cout<<"\n";      //if t>1 uncomment this
}

// MAIN function --------------------------------------------------------------------------//
int main()
{
    fast_io
//  if taking input from input.txt then uncomment below line
//    freopen("input.txt", "r", stdin);
//  if writing output to output.txt then uncomment below line
//    freopen("output.txt", "w", stdout);

    single_testcase_t   //Uncomment this if only single testcase & single answer to print
  //multiple_testcases_t  //Uncomment this if t>1(t is given in question)(multiple testcases)
return 0;
}





Measured memory_bytes: 4368
while True:
    m, f, r = (int(x) for x in input().split())
    if m == -1 and f == -1 and r == - 1:
        break
    
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f>= 65 and m + f < 80:
        print("B")
    elif m + f >= 50 and m + f < 65:
        print("C")
    elif m + f >= 30 and m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif m + f < 30:
        print("F")


Measured memory_bytes: 5604
#include<iostream>
#include<vector>
#include<algorithm>
#define MAX_V 100
#define INF 1e9
using namespace std;
int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;
void dijkstra(int s) {
	for (int i = 0; i < V; i++) {
		d[i] = INF;
		used[i] = false;
	}
	d[s] = 0;
	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] && ((v == -1) || d[u] < d[v])) {
				v = u;
			}
		}
		//全ての頂点が到達済み
		if (v == -1) {
			break;
		}
		//集合に新たに頂点を追加
		used[v] = true;
		for (int u = 0; u < V; u++) {
			if (cost[v][u] != -1) {
				d[u] = min(d[u], d[v] + cost[v][u]);
			}
		}
	}
}

int main() {   
	cin >> V;
	for (int i = 0; i < V; i++) {     
		for (int j = 0; j < V; j++) { 
			cost[i][j] = -1;               
		}                                 
	}                                      
	
	for (int i = 0; i < V; i++) {
		int u;
		cin >> u;
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			int c;
			cin >> c;
			cost[u][v] = c;
		}
	}
	dijkstra(0);

	for (int i = 0; i < V; i++) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}



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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

num l, r;

num inline calc(num a) {
    if (a % 4 == 0)  return a;
    if (a % 4 == 1)  return 1;
    if (a % 4 == 2)  return a + 1;
    if (a % 4 == 3)  return 0;
    return 0;
}

int inline chk(int l, int r) {
    int res = 0;
    circ (i, l, r) {
        res ^= i;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> l >> r;
    cout << (num) (calc(r) ^ calc(l - 1)) << endl;
}

// pre[a] = {
//     a        (mod 4 = 0)
//     1        (mod 4 = 1)
//     a + 1    (mod 4 = 2)
//     0        (mod 4 = 3)
// }


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

struct P
{
  int x;
  int y;
};

using Q = std::queue<std::pair<P, int>>;
using Maze = std::vector<std::string>;
using Map = std::vector<std::vector<int>>;

void try_push(Q& queue, const Maze& maze, Map& map, const P& p, int count)
{
  if (p.y < 0 || p.y >= static_cast<int>(maze.size())) return;
  if (p.x < 0 || p.x >= static_cast<int>(maze[0].size())) return;
  if (maze[p.y][p.x] == '#') return;
  if (map[p.y][p.x] > 0) return;
  map[p.y][p.x] = 1;
  queue.push({p, count});
}

int go(const Maze& maze, Map& map, Q& queue)
{
  const auto pair = queue.front();
  queue.pop();
  const auto p = pair.first;
  const auto count = pair.second + 1;
  try_push(queue, maze, map, P{p.x + 1, p.y}, count);
  try_push(queue, maze, map, P{p.x - 1, p.y}, count);
  try_push(queue, maze, map, P{p.x, p.y + 1}, count);
  try_push(queue, maze, map, P{p.x, p.y - 1}, count);
  return queue.empty() ? pair.second : go(maze, map, queue);
}

int count(const Maze& maze, const P& s)
{
  Map map(maze.size(), std::vector<int>(maze[0].size(), 0));
  Q queue;
  try_push(queue, maze, map, s, 0);
  return go(maze, map, queue);
}

int solve(int h, int w, const Maze& maze)
{
  int result = 0;
  for (int y = 0; y < static_cast<int>(maze.size()); ++y) {
    for (int x = 0; x < static_cast<int>(maze[0].size()); ++x) {
      if (maze[y][x] == '.') {
        result = std::max(result, count(maze, {x, y}));
      }
    }
  }
  return result;
}

int main()
{
  int h, w;
  std::cin >> h >> w;
  Maze maze(h);
  for (auto& s : maze) {
    std::cin >> s;
  }

  std::cout << solve(h, w, maze) << std::endl;
}


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

ll H, W, Ch, Cw, Dh, Dw;
vector<string> S; 
vector<vector<ll>> V;

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

queue<ll> Qy, Qx;
queue<ll> Qjx, Qjy;

queue<ll> init(){
    queue<ll> Q;
    return Q;
}
ll cnt = 0;

int dfs(int y, int x){
    Qy.push(y), Qx.push(x);
    for(int i = 0; i < 4; i++){
        int nx = x+dx[i], ny = y+dy[i];
        if(0 <= nx && nx < W && 0 <= ny && ny < H && S[ny][nx] != '#' && V[ny][nx] == -1){
            V[ny][nx] = cnt;
            dfs(ny, nx);
        }
    }
    return 0;
}


int main(){
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    Ch--; Cw--; Dh--; Dw--;
    S.resize(H);
    for(int i = 0; i < H; i++) cin >> S[i];
    V.resize(H);
    for(int i = 0; i < H; i++) V[i].resize(W, -1);
    
    V[Ch][Cw] = 0;
    dfs(Ch, Cw);
    while(!Qx.empty()){
        //cout << Qx.size() << endl;
        while(!Qx.empty()){
            ll x = Qx.front(); Qx.pop();
            ll y = Qy.front(); Qy.pop();
            for(int i = x-2; i <=x+2; i++){
                for(int j = y-2; j <= y+2; j++){
                    if(0 <= i && i < W && 0 <= j && j < H && V[j][i] == -1 && S[j][i] != '#'){
                        Qjx.push(i);
                        Qjy.push(j);
                    }
                }
            }
        }
        //cout << Qx.size() <<  " "  << Qjx.size() << endl;

        Qx = init();
        Qy = init();
        cnt++;

        while(!Qjx.empty()){
            ll x = Qjx.front(); Qjx.pop(); 
            ll y = Qjy.front(); Qjy.pop();
            if(V[y][x] == -1) {
                V[y][x] = cnt;
                dfs(y, x);
            }
        }


    }
    cout << V[Dh][Dw] << endl;


}

Measured memory_bytes: 13468
using System;
using System.Linq;

class Test
{
    static void Main()
    {
        int[,,] t = new int[4, 3, 10];
        

        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int b = d[0] - 1;
            int f = d[1] - 1;
            int r = d[2] - 1;
            int v = d[3];

            t[b, f, r] += v;

        }

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                for (int k = 0; k < 10; k++)
                {
                    if (t[i, j, k] < 0) t[i, j, k] = 0;
                    else if (t[i, j, k] > 10) t[i, j, k] = 10;
                    Console.Write(" " + t[i, j, k]);
                }
                Console.Write("\n");
            }
            if (i != 3) Console.WriteLine("####################");
        }
    }
}


Measured memory_bytes: 18360
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class B {
	int n, k;
	vi a;
public:
	B()
	{
		cin >> n >> k;
		a.resize(n);

		REP(i, n)
			cin >> a[i];

		sort(ALL(a), greater<>());

	}
	void solve()
	{
		cout << accumulate(a.begin(), a.begin() + k, 0) << endl;

	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll N; cin >> N;

    for (ll i = sqrt(N); i > 0; --i) {
        if (N % i == 0) { cout << i + N / i - 2 << endl;
        break;
        }
    }

}

Measured memory_bytes: 632
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int l,n,x[N],y[N];
ll ans=0,sx[N],sy[N];
ll sum(ll *s,int p,int c) {
    return s[p]-s[p-c];
}
void work() {
    for(int i=1;i<=n;i++) sx[i]=sx[i-1]+x[i],sy[i]=sy[i-1]+y[i];
    for(int i=1;i<=n;i++) {
        int cnt=min(i-1,n-i);
        chkmax(ans,x[i]+sum(sx,i-1,cnt)*2+sum(sy,n-i,cnt+(i-1<n-i))*2);
        chkmax(ans,l-x[i]+sum(sx,i-1,cnt+(i-1>n-i))*2+sum(sy,n-i,cnt)*2);
    }
}
int main() {
    l=gi(),n=gi();
    for(int i=1;i<=n;i++) x[i]=gi(),y[n-i+1]=l-x[i];
    work();
    for(int i=1;i<=n;i++) x[i]=l-x[i],y[i]=l-y[i];
    reverse(x+1,x+n+1),reverse(y+1,y+n+1);
    work(),cout<<ans;
    return 0;
}


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

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

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll a,b,c;cin>>a>>b>>c;
  judge=(a==7&&b==5&&c==5)||
    (a==5&&b==7&&c==5)||
    (a==5&&b==5&&c==7);
  ans2(judge);

  return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int a,b,c;
    cin>>a>>b>>c;
    set<int> st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    if(st.size()==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int dp[1000000];
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n;
   cin>>n;
  ll sum=0; 
  int k=0;
  for(int i=1;i<=n;i++)
  {
  for(int j=1;j<=n;j++)
  {
  	dp[k++]=__gcd(i,j);
  }
  }
  for(int i=1;i<=n;i++)
  for(int j=0;j<k;j++)
  sum+=__gcd(i,dp[j]);
  cout<<sum<<endl;
return 0;
}



Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5,M=2e5+5;
int n,m;

inline int in(){
	int x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}

int cnt,head[N],to[2*M],wi[2*M],nxt[2*M];
inline void adds(int x,int y,int z){
	to[++cnt]=y,wi[cnt]=z,nxt[cnt]=head[x],head[x]=cnt;
	return ;
}

inline void solve_in(){
	int a,b,c;
	n=in(),m=in();
	for(int i=1;i<=m;i++){
		a=in(),b=in(),c=in();
		adds(a,b,c),adds(b,a,-c);
	}
	return ;
}

bool co[N];
int dis[N];
bool vis[N];
queue< int > Q;
inline bool SPFA(int st){
	int mis=0,mas=0;
	dis[st]=0,vis[st]=true,Q.push(st);
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		vis[u]=false,co[u]=true;
		for(int i=head[u];i;i=nxt[i]){
			int v=to[i],w=wi[i];
			co[v]=true;
			if(dis[v]==0x3f3f3f3f){
				dis[v]=dis[u]+w;
				mas=max(mas,dis[v]);
				mis=min(mis,dis[v]);
				if(mas-mis>1e9) return false;
				if(!vis[v]) vis[v]=true,Q.push(v);
			}
			else if(dis[v]!=dis[u]+w) return false;
		}
	}
	return true;
}

int main(){
	solve_in();
	memset(dis,0x3f,sizeof(dis));
	for(int i=1;i<=n;i++){
		if(!co[i]){
			if(!SPFA(i)){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define int long long

using namespace std;

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

int n, K, f[N][N];
int fac[N*N], rev[N*N];

int quick_pow(int x, int times)
{
	if(x == 0) return 0;
	int ans = 1, mult = x;

	while(times)
	{
		if(times & 1)
			ans *= mult, ans %= MOD;
		mult *= mult, mult %= MOD, times >>= 1;
	}
	return ans;
}

void init()
{
	fac[0] = fac[1] = 1;
	for(register int k = 2; k <= n * K; k++)
		fac[k] = fac[k - 1] * k % MOD;

	rev[n * K] = quick_pow(fac[n * K], MOD - 2);
	for(register int k = n * K - 1; k >= 0; k--)
		rev[k] = (rev[k + 1] * (k + 1)) % MOD;
}

int C(int up, int down)
{
	return ((fac[down] * rev[up] % MOD) * rev[down - up]) % MOD;
}

signed main()
{
	scanf("%lld %lld", &n, &K), init();
	if(K == 1)
	{
		printf("1");
		return 0;
	}

	f[0][0] = 1;
	for(register int i = 1; i <= n; i++)
		for(int j = 0; j <= i; j++)
		{
			f[i][j] += f[i - 1][j];
			if(j - 1 >= 0)
				f[i][j] += (f[i][j - 1] * (n - j + 1) % MOD) * C(K - 2, n * K - i - (j - 1) * (K - 1) - 1) % MOD, f[i][j] %= MOD;
		}

	printf("%lld", f[n][n]);

	return 0;
}

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

int main() {
  int a[3], n = 3;
  cin >> a[0] >> a[1] >> a[2];
  for (int i = n-1; i > 0; i--) {
    for (int j = 0; j < i; j++) {
      if (a[i] < a[j]) {
        int tmp = a[i];
        a[i] =a[j];
        a[j] = tmp;
      }
    }
  }
  cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int compareMultiple(int a, int b) {
    if (a == b) {
        return a;
    }
    if (a > 0) {
        return 1;
    }
    if (a <= 0 && b >= 0) {
        return 0;
    }
    if (b < 0) {
        return (-a + b) % 2 == 0 ? -1 : 1;
    }
}

int main() {
    long a, b;
    std::cin >> a >> b;
    int res = compareMultiple(a, b);
    std::cout << (res == 0 ? "Zero" : (res > 0 ? "Positive" : "Negative"));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

string s;
string ans = "YES";
string t[4] = {
	"dream",
	"dreamer",
	"erase",
	"eraser"
};

void solve() {
	int size = s.size();
	for (int i = size; i > 0;) {
		int j = 0;
		for (; j < 4; j++) {
			int k =  i - t[j].size();
			//if (k >= 0 ) cout << s.substr(k, t[j].size()) << " " << t[j] << endl;
			if (k >= 0 && s.substr(k, t[j].size()) == t[j]) {
				i -= t[j].size();
				break;
			}
		}
		if (j == 4) {
			ans = "NO";
			break;
		}
	}
	cout << ans << endl;
}

int main() {
	cin >> s;
	solve();
	return 0;
}




Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int h,a;
	int cnt,i;
	scanf("%d %d",&h,&a);
	cnt=0;
	while(1){
		if(0>=h){
			break;
		}
		h=h-a;
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
const double PI = acos(-1.0), EPS = 1e-9;
const int MX=2*1e5 + 10;
int N, Q, M, k;
int arr[MX];
int main()
{
    ll a, b, c;
    cin>>a;
    b=a;
    c=0;
    while(b)
    {
        c+=b%10;
        b/=10;
    }
    if(a % c == 0)
    {
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  double ans = 0;
  for (int i = 0; i < N; i++) {
    ans += 1.0 / A[i];
  }
  ans = 1.0 / ans;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a,b,c;

    scanf("%d %d %d", &a, &b, &c);

    if(a <= b &&  b <= c){
    	printf("%d %d %d\n", a, b, c);
    }else if(a <= c && c <= b){
    	printf("%d %d %d\n", a, c, b);
    }else if(b <= a && a <= c){
    	printf("%d %d %d\n", b, a, c);
    }else if(b <= c && c <= a){
    	printf("%d %d %d\n", b, c, a);
    }else if(c <= a && a <= b){
    	printf("%d %d %d\n", c, a, b);
    }else if(c <= b && b <= a){
    	printf("%d %d %d\n", c, b, a);
    }

    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;

	ll ans = 100000 * 100000;
	if (H % 3 == 0 || W % 3 == 0)
	{
		ans = 0;
	}
	else
	{
		ll minS = 0, maxS = 0;
		//! hを3分割
		minS = std::min(W*(H / 3), W*(H - (H / 3) * 2));
		maxS = std::max(W*(H / 3), W*(H - (H / 3) * 2));
		ans = std::min(ans, maxS - minS);
		minS = std::min(W*(1 + H / 3), W*(H - (1 + H / 3) * 2));
		maxS = std::max(W*(1 + H / 3), W*(H - (1 + H / 3) * 2));
		ans = std::min(ans, maxS - minS);
		//! wを3分割
		minS = std::min(H*(W / 3), H*(W - (W / 3) * 2));
		maxS = std::max(H*(W / 3), H*(W - (W / 3) * 2));
		ans = std::min(ans, maxS - minS);
		minS = std::min(H*(1 + W / 3), H*(W - (1 + W / 3) * 2));
		maxS = std::max(H*(1 + W / 3), H*(W - (1 + W / 3) * 2));
		ans = std::min(ans, maxS - minS);
		//! hを2分割
		FOR(w, W, 1)
		{
			ll s1 = H*w, s2 = (H / 2)*(W - w), s3 = (H - H / 2)*(W - w);
			minS = std::min(s1, std::min(s2, s3));
			maxS = std::max(s1, std::max(s2, s3));
			ans = std::min(ans, maxS - minS);
		}
		//! wを2分割
		FOR(h, H, 1)
		{
			ll s1 = W*h, s2 = (W / 2)*(H - h), s3 = (W - W / 2)*(H - h);
			minS = std::min(s1, std::min(s2, s3));
			maxS = std::max(s1, std::max(s2, s3));
			ans = std::min(ans, maxS - minS);
		}
	}
	cout << ans << endl;
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in);) {
			
			StringBuilder sb = new StringBuilder();
			
			while(true) {
				String input = sc.next();
				
				if(input.equals("-")) break;
				
				int m = sc.nextInt();
				List<Integer> hList = new ArrayList<>();
				for(int i = 0; i < m; i++) {
					hList.add(sc.nextInt());
				}
				
				String shuffle = input;
				for(int i : hList) {
					shuffle = shuffle.substring(i) + shuffle.substring(0, i);
				}
				
				sb.append(shuffle);
				sb.append("\n");
			}
			
			System.out.print(sb.toString());
		}
	}
}


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

int main()
{
    int A, B;
    cin >> A >> B;
    if((A + B) % 2 == 0)
    {
        cout << (A + B) / 2;
    }
    else
    {
        cout << "IMPOSSIBLE";
    }

    return 0;
    
}

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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int>v(2*m);
  for(int i=0;i<m;i++){
  cin>>v.at(2*i)>>v.at(2*i+1);
  }
  for(int i=1;i<n+1;i++){int num=0;
  for(int j=0;j<2*m;j++){
  if(i==v.at(j)){
  num++;}}cout<<num<<endl;}
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b;

int main(void) {
  // Here your code !
  scanf("%d %d", &a, &b);
  
  if ((a * b) % 2 == 0) printf("Even\n");
  else printf("Odd\n");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <sstream>

using namespace std;

string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

void x2n (string & s, int n )
{
	string cn = itos (n );

	while (s.find ('X' ) != string::npos )
		s = s.replace(s.find('X'), 1, cn );
}

string longlongadd (string str1, string str2 )
{
	string res = "";
	
	reverse (str1.begin(), str1.end() );
	reverse (str2.begin(), str2.end() );
	int len1 = str1.length();
	int len2 = str2.length();

	while (len1 != len2 ){
		if (len1 < len2 ){
			str1 += '0';
			len1 = str1.length();
		}else if (len1 > len2 ){
			str2 += '0';
			len2 = str2.length();
		} // end if
	} // end while

	bool carry = false;
	for (int i = 0; i < len1; i++ ){
		int num1 = str1[i] - '0';
		int num2 = str2[i] - '0';
		int sum = num1 + num2;

		sum += (carry ? 1 : 0 );
		if (sum < 10 ){
			res += sum + '0';
			if (carry){
				carry = false;
			} // end if
		}else{
			sum %= 10;
			res += sum + '0';
			carry = true;
		} // end if
	} // end for

	if (carry)
		res += '1';

	reverse (res.begin(), res.end());

	return res;
}

int main()
{
	string str = "";

	while (cin >> str ){
		string a = str.substr (0, str.find('+') );
		string b = str.substr (str.find ('+' )+1, str.find ('=' ) - str.find('+') - 1 );
		string c = str.substr (str.find ('=')+1 );
		bool found = false;

		for (int i = 0; i < 10;  i++ ){
			string ca = a, cb = b, cc = c;
			x2n (ca, i ), x2n(cb, i ), x2n (cc, i );
			string add = longlongadd (ca, cb );
			if (add == cc ){
				cout << i << endl;
				found = true;
			} // end if
		} // end for
		if (!found )
			cout << "NA" << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0