akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>//ソートなどに必要
using namespace std;

int main() 
{
    int n;
    int answer = 1;
    cin >> n;//改行を気にしない

    while(true)
    {
      if(n >= answer*2)//2倍しても割り切れる
      {
        answer *= 2;
      }else break;
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
Module Program
  Sub Main
    Dim s=GetInts()
    Dim a=s(0),b=s(1),c=s(2)
    Dim ans=If(a<=c And c<=b,"Yes","No")
    Console.WriteLine(ans)
  End Sub

  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int a[4]={0},t;
	for(int i=0;i<6;i++)
	{
		cin>>t;
		a[t-1]++;
		if(a[t-1]==3)
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
flag=False
for i in range(3):
    if(int(N//(10**i))%10==7):
        flag=True

print('Yes' if flag==True else 'No')


Measured memory_bytes: 9200
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <fstream>
#include <climits>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <memory>
#include <set>
#include <map>
#include <list>
#include <cmath>

using namespace std;

int main()
{
    //freopen("/Users/qianjay/Documents/apac/in","r",stdin);
    int dp[128][10];
    int a[128];
    memset(dp,-1,sizeof(dp));
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    dp[0][0]=0;
    for(int i=0;i<n;i++)
    {
        memcpy(dp[i+1],dp[i],sizeof(dp[i]));
        for(int j=0;j<10;j++)
        {
            if(dp[i][j]==-1) continue;
            dp[i+1][(j+a[i])%10]=max(dp[i+1][(j+a[i])%10],dp[i][j]+a[i]);
        }
    }
    //for(int i=0;i<10;i++) cout<<dp[1][i]<<endl;
    int res=*max_element(dp[n]+1, dp[n]+10);
    if(res==-1) cout<<0<<endl;
    else cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
   

}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  
  while(u!=NIL && u->key !=k){ /* u->key を先にかくと Segmentation Fault になる */
    
    if(u->key > k) u=u->left;
    else u=u->right;

  }

  return u;
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(x->key > k) x=x->left;
    else x=x->right;
  }

  z->parent=y;

  if(y==NIL) root=z;
  else if(z->key < y->key) y->left=z;
  else y->right=z;

}

void inorder(Node u){

  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }

}
void preorder(Node u){

  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20452
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++){
        int tmp = (int)(((double)i)*1.08);
        if(tmp == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#pragma optimization_level 3
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

#define int long long
#define MOD 1000000007

struct BIT {
  int n;
  vector<int> xs;

  BIT(int n) : n(n) {
    xs.resize(n+1);
  }

  int sum(int i) {
    int s = 0;
    for (int x=i+1; x>0; x-=x&-x) s = (s + xs[x]) % MOD;
    return s;
  }

  int sum(int a, int b) {
    if (a > b) return 0;
    return (0LL + sum(b) - sum(a-1) + MOD) % MOD;
  }

  void add(int i, int v) {
    for (int x=i+1; x<=n; x+=x&-x) xs[x] = (xs[x] + v) % MOD;
  }

  void reset() {
    memset(&xs[0], 0, (n+1)*sizeof(int));
  }
};

int N, A, B;
long long S[100001];

signed main() {
  cin >> N >> A >> B;
  if (A > B) swap(A, B);
  S[0] = -(1LL<<60);
  for (int i=1; i<=N; i++) cin >> S[i];

  BIT dp0(N+1), dp1(N+1);
  dp0.add(0, 1);
  dp1.add(0, 1);

  int l0 = 0, l1 = 0;
  for (int i=1; i<N; i++) {
    int uj1 = min(i, (int)(upper_bound(S, S+N+1, S[i+1]-A) - S) - 1);
    int uj2 = min(i, (int)(upper_bound(S, S+N+1, S[i+1]-B) - S) - 1);
    long long d = S[i+1] - S[i];
    long long s1 = dp1.sum(l1, uj1), s2 = dp0.sum(l0, uj2);
    if (d < A) l0 = i;
    if (d < B) l1 = i;
    dp0.add(i, s1);
    dp1.add(i, s2);
  }

  int s = dp0.sum(l0, N) + dp1.sum(l1, N);
  if (s >= MOD) s -= MOD;
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 2e5 + 5;

int x;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    while(T--) {
        cin >> x;
        cout << (x < 1200 ? "ABC\n" : x < 2800 ? "ARC\n" : "AGC\n");
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}

Measured memory_bytes: 3624
// ProblemURL : https://atcoder.jp/contests/abc059/tasks/arc072_b
// ---------------------------------------------
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

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

	if abs(x-y) >= 2 {
		fmt.Println("Alice")
	} else {
		fmt.Println("Brown")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int xx[4]={-1,1,0,0};
  int yy[4]={0,0,-1,1};
  int h,w;cin>>h>>w;
  string s[h];
  bool bo[h][w];
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)bo[i][j]=false;
  for(int i=0;i<h;i++) cin>>s[i];
  int cnt=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='.') cnt++;
    }
  }
  queue<int>qx;
  queue<int>qy;
  queue<int>qn;
  qn.push(0);
  qx.push(0);qy.push(0);
  while(qx.size()>0){
    int x=qx.front();
    int y=qy.front();
    int n=qn.front();
    if(x==w-1&&y==h-1){
      cout<<cnt-n-1<<endl;
      return 0;
    }
    
    qn.pop();
    qx.pop();qy.pop();
    for(int i=0;i<4;i++){
      if(bo[y+yy[i]][x+xx[i]]==false&&y+yy[i]>=0&&y+yy[i]<h&&x+xx[i]>=0&&x+xx[i]<w&&s[y+yy[i]][x+xx[i]]=='.'){
        qx.push(x+xx[i]);qy.push(y+yy[i]);qn.push(n+1);
        bo[y+yy[i]][x+xx[i]]=true;
      }
    }
  }
  cout<<-1<<endl;
}
    




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class Program
    {
        static void Main(string[] args)
        {
            string[] Input = Console.ReadLine().Split(' ');
            decimal A = decimal.Parse(Input[0]);
            decimal B = decimal.Parse(Input[1]);
            
            Console.WriteLine(Math.Floor(A * B));
        }
    }

Measured memory_bytes: 18044
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n;
    cin >> n;
    vector<ll> a(n), sa(n);
    ll tot = 0;
    REP(i, n) {
        cin >> a[i];
        tot += a[i];
    }
    REP(i,n-1){
        sa[i] = a[i + 1] - a[i];
    }
    sa[n - 1] = a[0] - a[n - 1];
    ll wari = n;
    wari *= n + 1;
    wari /= 2;
    if (tot % wari == 0)
    {
        ll kai = tot / wari;
        bool flag = true;
        ll kait = 0;
        REP(i, n)
        {
            if ((kai - sa[i]) % n == 0 && (kai-sa[i])/n >= 0){
                kait += (kai - sa[i]) / n;
            }
            else
            {
                flag = false;
                break;
            }
        }
        if (flag && (kait == kai)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt();
        if(Math.abs(a-c)<=d||(Math.abs(a-b)<=d&&Math.abs(b-c)<=d)) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
#define ll long long

int d = 365;
vector<vector<int>> s(d, vector<int>(26, 0));
vector<ll> c(26);

void init() {
    cin >> d;
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    return;
}

ll calc(vector<int> out) {
    ll score = 0;
    vector<ll> last(26, 0);
    for(int i = 0; i < out.size(); i++) {
        last[out[i]] = i+1; // タイプ番号
        //cout << "out[" << i << "] " << out[i] << " ";
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
        score += s[i][out[i]];
        //cout << "score : " << score << endl;
    }

    for(int i = out.size(); i < d; i++) {
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
    }
    return score;
}


int main() {
    init();
    vector<int> out;
    ll ans = 0;
    //ll tmp = 0;
    ll max_v = -1;
    for(int i = 0; i < d; i++) {
        //max_v = -100000000000;
        max_v = LLONG_MIN;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            ll tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            out.pop_back();
        }
        out.push_back(best);
    }
    
    for(int i = 0; i < d; i++) {
        cout << out[i]+1 << endl;
    }
    //cout << max_v << endl;
    return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<cstdio>
using namespace std;
int a[2002][2002];
int b[2002][2002];
char s[4];
inline int f(int (*d)[2002],int sx,int sy,int ex,int ey){
	return d[ex][ey]-d[ex][sy]-d[sx][ey]+d[sx][sy];
}
int main()
{
	int i,j,n,m;
	scanf("%d%d",&n,&m);
	while(n--){
		scanf("%d%d%s",&i,&j,s);
		if(s[0]=='W')a[i%(m+m)+1][j%(m+m)+1]++;
		else b[i%(m+m)+1][j%(m+m)+1]++;
	}
	for(i=1;i<=m+m;i++)for(j=1;j<=m+m;j++){
		a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
		b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
	}
	int ans=0,cnt=0;
	for(i=1;i<=m;i++)for(j=1;j<=m;j++){
		cnt=f(a,0,0,i,j)
		+f(b,i,0,i+m,j)
		+f(a,i+m,0,m+m,j)
		+f(b,0,j,i,j+m)
		+f(a,i,j,i+m,j+m)
		+f(b,i+m,j,m+m,j+m)
		+f(a,0,j+m,i,m+m)
		+f(b,i,j+m,i+m,m+m)
		+f(a,i+m,j+m,m+m,m+m);
		ans=max(ans,cnt);
		cnt=f(b,0,0,i,j)
		+f(a,i,0,i+m,j)
		+f(b,i+m,0,m+m,j)
		+f(a,0,j,i,j+m)
		+f(b,i,j,i+m,j+m)
		+f(a,i+m,j,m+m,j+m)
		+f(b,0,j+m,i,m+m)
		+f(a,i,j+m,i+m,m+m)
		+f(b,i+m,j+m,m+m,m+m);
		ans=max(ans,cnt);
		//cout<<ans<<endl;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 31488
using System;
using System.Reflection;
using System.Linq.Expressions;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder {
    public class Program {
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(' ');
            int[] Ns = new int[Keys.Length];
            for (int i = 0; i < Keys.Length; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        static void Show<T>(IEnumerable<T> ts) {
            foreach (var item in ts) {
                Console.Write(item + " ");
            }
            Console.WriteLine();
        }
        static void Main() {
            var Key = getKeys(' ');
            long N = Key[0];
            long K = Key[1];
            Position[] positions = new Position[N];
            long MIN = long.MaxValue;
            for (int i = 0; i < N; i++) {
                Key = getKeys(' ');
                positions[i] = new Position(Key[0], Key[1]);
            }
            long Left, Top, Bottom, Right;
            for (int i = 0; i < N; i++) {
                Left = positions[i].X;
                foreach (var item in positions.Where(x => Left < x.X)) { 
                    Right = item.X;
                    for (int j = 0; j < N; j++) {
                        Bottom = positions[j].Y;
                        foreach (var item2 in positions.Where(y => y.Y > Bottom)) {
                            Top = item2.Y;
                            if (positions.Where(p => (p.X >= Left && p.X <= Right && p.Y >= Bottom && p.Y <= Top)).Count() >= K) {
                                MIN = Math.Min(MIN, (Right - Left) * (Top - Bottom));
                            }
                        }
                    }
                }
            }
            Console.WriteLine(MIN);
        }
    }
    class Position {
        public int X;
        public int Y;
        public Position(int x,int y) {
            X = x;
            Y = y;
        }
    }
}


Measured memory_bytes: 17496
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  int maxi = *max_element(all(l));
  int sum = accumulate(all(l), 0) - maxi;
  if (maxi < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var inputValues = input.Split(' ');
            var n = int.Parse(inputValues[0]);
            var m = int.Parse(inputValues[1]);

            var input2 = new string[n];

            for (var i = 0; i < n; i++)
            {
                input2[i] = Console.ReadLine();
            }

            var types = input2.Select(s => int.Parse(s));

            var sum = types.Sum();
            var remnant = m - sum;

            var count = n;

            var typesOrderBySmall = types.OrderBy(m => m);

            foreach (var mi in typesOrderBySmall)
            {
                if (remnant < mi)
                {
                    continue;
                }

                var divisionValue = remnant / mi;
                remnant = remnant - mi * divisionValue;
                count += divisionValue;
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 28440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> a(N);
    for (int i=0;i<N;++i) cin >> a[i];
    ll ans=-INF,sum;
    int s,t;
    for (int i=0;i<N;++i){
        sum=0;
        for (int j=i;j<N;j+=2){
            if (j!=i&&a[j]<0) continue;
            sum+=a[j];
            if (ans<sum){ans=sum; s=i,t=j;}
        }
    }
    cout << ans << '\n';
    cout << s+(N-1-t)+(t-s)/2 << '\n';
    for (int i=0;i<N-1-t;++i) cout << N-i << '\n';
    for (int i=0;i<s;++i) cout << 1 << '\n';
    int skip=0;
    for (int i=s;i<t;i+=2) if (a[i]<0){
        cout << i-s+1-2*skip << '\n';
        ++skip;
    }
    for (int i=0;i<(t-s)/2-skip;++i) cout << 2 << '\n';
}


Measured memory_bytes: 256
"use strict";

const permutateWithRepetitions = (
  permutationOptions,
  permutationLength
) => {
  if (permutationLength === 1) {
    return permutationOptions.map(permutationOption => [permutationOption]);
  }

  const permutations = [];

  const smallerPermutations = permutateWithRepetitions(
    permutationOptions,
    permutationLength - 1
  );

  permutationOptions.forEach((currentOption) => {
    smallerPermutations.forEach((smallerPermutation) => {
      permutations.push([currentOption].concat(smallerPermutation));
    });
  });

  return permutations;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("").map(n=>parseInt(n));

    // 最大で1000通りしかありえないので全探索する
    const digits = [0,1,2,3,4,5,6,7,8,9];
    
    const combos = permutateWithRepetitions(digits, 3);
    
    let cnt = 0;
    
    for(let i in combos) {
        let digit1 = combos[i][0];
        let digit2 = combos[i][1];
        let digit3 = combos[i][2];
        
        let flag1 = false;
        let flag2 = false;
        let flag3 = false;

        for(let j=0; j<N; j++) {
            if(S[j] === digit1 && flag1 !== true) {
                flag1 = true;
            } else if(S[j] === digit2 && flag1 && flag2 !== true) {
                flag2 = true;
            } else if(S[j] === digit3 && flag1 && flag2) {
                flag3 = true;
            }
        }
        
        
        if(flag1 && flag2 && flag3) {
            cnt++;
        }
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 10992
n = int(input())
d={}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d.update({s:1})

m = int(input())
for j in range(m):
    t = input()
    if t in d:
        d[t] -= 1
    else:
        d.update({t:-1})
print("0" if max(d.values()) < 0 else max(d.values()))


Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::{min,max};

fn main() {
    let xs = {
        let mut xs = vec![0];
        let mut x = 1;
        for i in 0..5000 {
            x += i;
            xs.push(x);
        }
        xs
    };
    let n = read_i64();
    let mut x = n;
    while x != 0 {
        for (i,ts) in xs.windows(2).enumerate() {
            if ts[0] <= x && x < ts[1] {
                println!("{}", i);
                x -= i as i64;
                break;
            }
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<pair<int,int>>> v(n);
    rep(i,n-1){
        v[i+1].emplace_back(i,0);
    }
    rep(i,m){
        int l,r,c;
        cin>>l>>r>>c;
        --l;--r;
        v[l].emplace_back(r,c);
    }
    vector<ll> dist(n,longinf);
    dist[0]=0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
    pq.emplace(0,0);
    while(pq.size()){
        auto p = pq.top();pq.pop();
        if(dist[p.second]<p.first)continue;
        for(auto to: v[p.second]){
            if(dist[to.first]>dist[p.second]+to.second){
                dist[to.first]=dist[p.second]+to.second;
                pq.emplace(dist[to.first],to.first);
            }
        }
    }
    if(dist[n-1]==longinf)cout<<-1<<endl;
    else cout<<dist[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 8440
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

const string YES = "Yes";
const string NO = "No";


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

  // int n;
  // ll ans = 0;
  // cin >> n;
  // for(int i = 1; i <= n; i++){
  //   if(i % 3 == 0 || i % 5 == 0){
  //     continue;
  //   }else{
  //     ans += i;
  //   }
  // }
  // cout << ans << endl;






  char a[3] = {0};
  cin >> a;
  rep(i, 3){
    if(a[i] == '7'){
      cout << YES << endl;
      return 0;
    }
  }
  cout << NO << endl;

  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

// change minimumのこと
// a>bならばaにbを代入し、trueを返す
// 他の場合はfalseを返す
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;
const long long P = 1000000007;
const int  MAX_N = 110000;

int main() {
int n;
cin >> n;
long long dp[MAX_N][3] = {};
int a[MAX_N][3] = {};
// j=0がa j=1がb j=2がcを示す
for(int i = 0; i < n; i++) {
  for(int j = 0; j < 3; j++) {
    cin >> a[i][j];
    dp[i][j] = 0; 
  }
}

for(int i = 0; i < n; i++) {
  for(int j = 0; j < 3; j++) {
    for(int k = 0; k < 3; k++) {
      if(j != k) chmax(dp[i+1][k], dp[i][j] + a[i][k]);
    }
  }
}
long long ans = 0;
for(int j = 0; j < 3; j++) {
  chmax(ans,dp[n][j]);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
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; }

int main(){
    string s; cin >> s;
    int q; cin >> q;
    int rev = 0;
    string fr = "", ba = "";
    rep(_, q){
        int type; cin >> type;
        if(type == 1){
            rev++;
        }
        else{
            int f; char c; cin >> f >> c;
            if(f == 1){
                if(rev % 2){
                    ba += c;
                }
                else{
                    fr += c;
                }
            }
            else{
                if(rev % 2){
                    fr += c;
                }
                else ba += c;
            }
        }
    }
    if(rev % 2){
        swap(fr, ba);
        reverse(ALL(s));
    }
    reverse(ALL(fr));
    cout << fr + s + ba << endl;
}


Measured memory_bytes: 1348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

int main(){
	double n,k;
	double ans=0.0;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		double t=1;
		int s=i;
		while(k-1>=s){
			t/=2;
			s*=2;
		}
		ans+=t;
	}
	cout<<setprecision(20)<<ans/n<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
sum_A2 = int(sum(A) / 2)
sum_odd = 0
sum_even = 0
cnt = int((N - 1) / 2)
for i in range(-1, N-1):
    if cnt == 0:
        break
    if i % 2 == 1:
        sum_odd += A[i % N]
    else:
        sum_even += A[i % N]
        cnt -= 1

for i in range(-1, N-1):
    if i % 2 == 1:
        sum_odd -= A[i % N]
        sum_odd += A[(N-2+i+1) % N]
        print(2 * (sum_A2 - sum_odd), end=' ')
    else:
        sum_even -= A[i % N]
        sum_even += A[(N-2+i+1) % N]
        print(2 * (sum_A2 - sum_even), end=' ')


Measured memory_bytes: 14400
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main(void){

	int n;
	while (cin >> n && n != 0){

		char t[10];
		int r;
		int win[10] = { 0 }, lose[10] = { 0 };
		memset(win, 0, sizeof(win)); memset(lose, 0, sizeof(lose));

		for (int i = 0; i < n; i++){
			cin >> t[i];
			for (int j = 0; j < n - 1; j++){
				cin >> r;
				if (r == 0) win[i]++;
				if (r == 1) lose[i]++;
			}
		}

		bool flg = true;
		int i = 0;
		while (flg){
			flg = false;
			for (int j = n - 1; j >= i + 1; j--){
				if (win[j] > win[j - 1]){
					swap(win[j], win[j - 1]); swap(lose[j], lose[j - 1]); swap(t[j], t[j - 1]);
					flg = true;
				}
				else if (win[j] == win[j - 1]){
					if (lose[j] < lose[j - 1]){
						swap(win[j], win[j - 1]); swap(lose[j], lose[j - 1]); swap(t[j], t[j - 1]);
						flg = true;
					}
				}
			}
			i++;
		}
		for (i = 0; i < n;i++){
			cout << t[i] << endl;
		}
	}
}

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

int n,m,ans[5004],co;
bool used[5004];
vector<int> maketa[5004];

void dfs(int a){
	if(used[a] == true)return;
	used[a] = true;
	for(int i = 0;i < maketa[a].size();i++){
		dfs(maketa[a][i]);
	}
	ans[co++] = a;
}

int main(){
	scanf("%d%d",&n,&m);

	for(int i = 0;i < m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		maketa[b].push_back(a);
	}

	for(int i = 1;i <= n;i++)dfs(i);

	bool flag = false;
	for(int i = 1;i < co;i++){
		for(int j = 0;j < maketa[ans[i]].size();j++){
			if(maketa[ans[i]][j] == ans[i-1])goto out;
		}
		flag = true;
		break;
		out:
		;
	}

	for(int i = 0;i < co;i++){
		printf("%d\n",ans[i]);
	}
	if(flag){
		printf("1\n");
	}else{
		printf("0\n");
	}
	return 0;
}


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

int N;
int d[100];

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> d[i];
	}
	int ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			ans += d[i]*d[j];
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

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

  int sum = 0;
  bool can = false;
  rep(i, B) {
    sum = A * (i + 1);
    if (sum % B == C) {
      can = true;
      break;
    }
  }

  string res = (can) ? "YES" : "NO";
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 2050;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//繰り返し二乗法
mint f(ll n){
  if(n == 0) return 1;
  mint x = f(n/2);
  x*=x;//2乗
  if(n%2 == 1) x*=2;
  return x;
}

//C
mint choose(ll n,ll a){
  mint x = 1,y = 1;
  rep(i,a){
    x*= n-i;
    y*= i+1;
  }
  return x/y;
}

int main(){
  ll n;
  cin >> n;
  ll a,b;
  cin >> a >> b;
  mint ans = f(n);//2^n
  ans-=1;
  ans-=choose(n,a);
  ans-=choose(n,b);
  cout << ans << endl;
}

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

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

    double al,ar,bl,br;
    al = 12.5*A;
    ar = al + 12.5;
    bl = 10*B;
    br = bl+10;
    
    int ans;
    if(ar <= bl || br <= al){
        cout << "-1" << endl;
    }else if(al <= bl){
        cout << ceil(bl) << endl;
    }else if(bl <= al){
        cout << ceil(al) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSumOfThreeIntegers solver = new BSumOfThreeIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSumOfThreeIntegers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt(), s = in.nextInt();
            out.println(IntStream.rangeClosed(Math.max(0, s - 2 * k), Math.min(k, s))
                    .map(x -> Math.min(k, s - x) - Math.max(0, s - x - k) + 1)
                    .filter(v -> v > 0)
                    .sum());
        }

    }
}



Measured memory_bytes: 26964
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstdio>
#include<stack>
#include<cstring>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;

int main(){
  int ans=0;
  string s;
  char now_color;
  cin>>s;

  now_color=s[0];
  for(int i=1;i<s.size();i++){
    if(now_color!=s[i]){
      ans++;
      now_color=s[i];
    }
  }
  printf("%d\n",ans);

  return 0;
}


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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////



void solve() {
   int n,k;
   cin >> n >> k;
   cout << n-k+1 << '\n';
}


/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
  FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
  clock_t time_start = clock();
	#endif

  ios::sync_with_stdio(false);
  cin.tie(NULL);

  solve();

	#ifndef ONLINE_JUDGE
  fclose(FIN);
  cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

  return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include<stdio.h>
int main (void){
    int a,b[100000],c,i;
    scanf("%d",&a);

    for(i=0;i<100000;i++){
        b[i]=(i+1)*(i+1);
        if(b[i] <= a){
            c = b[i];
        }
        else{
            break;
        }
    }
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 128
n = int(input()) 
d = [int(input()) for i in range(n)] 
k=0
c=0
for i in range(n):
  for j in range(n-i-1):
    if d[j] > d[j+1]:
      k = d[j]
      d[j] = d[j+1]
      d[j+1] = k
      
for i in range(n-1):
  if d[i]==d[i+1]:
    c=c+1
      
print(n-c)      
    

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

using std::max;
using std::min;
const int N=1e5+10;

struct Edge{ int to,next; }way[N<<1];
int n,dep[N],num[N],tot,ans,val[N],cnt[N][21];

void Build(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot; }

void Init() {
	scanf("%d",&n);
	int a,b;
	for (int i=2;i<=n;++i) {
		scanf("%d%d",&a,&b);
		Build(a,b);
		Build(b,a);
	}
}

void Dfs(int x,int fa) {
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (v==fa) continue;
		Dfs(v,x);
		for (int i=val[v];i<=20;++i) cnt[x][i]+=cnt[v][i];
	}
	int value=0;
	for (int i=0;i<=19;++i) if (cnt[x][i]>=2) value=i+1;
	while (cnt[x][value]) ++value;
	val[x]=value; cnt[x][value]++;
	ans=max(ans,value);
}

void Solve() {
	Dfs(1,0);
	printf("%d\n",ans);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 15744
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include<set>

int main()
{
    int n; std::cin >> n;
    std::vector<int> d(n);
    std::set<int> ds;
    for(int i = 0;i < n; i++) {
        std::cin >> d[i];
        ds.insert(d[i]);
    }

    std::cout << ds.size() << std::endl;
}



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

int main(){
	int n;
	while(cin>>n)
		{	if(n!=0){
			int s=0;
			int k;
			for(int i=0;i<n/4;i++){
				cin>>k;
				s+=k;
			}
			cout<<s<<endl;
		}
			else
				break;
		}
}

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

using namespace std;
typedef long long ll;

ll N,M,X;
ll C[20];
ll A[20][20];
ll r[12];

int main(){
    cin >> N >> M >> X;
    for(int i=0;i<N;i++){
        cin >> C[i];
        for(int j=0;j<M;j++) cin >> A[i][j];
    }
    ll min_c = 1e15;
    for(int i=1;i<(1<<N);i++){
        bitset<12> bt(i);
        ll c = 0;
        for(int j=0;j<M;j++) r[j] = 0;
        for(int j=0;j<N;j++){
            if(bt[j] == 0) continue;
            c += C[j];
            for(int k=0;k<M;k++) r[k] += A[j][k];
        }
        bool f = true;
        for(int j=0;j<M;j++){
            if(r[j] < X) f = false;
        }
        if(f){
            min_c = min(min_c, c);
        }
    }
    if(min_c == 1e15) cout << -1 << endl;
    else cout << min_c << endl;
    return 0;
}

Measured memory_bytes: 3648
n=int(input())
h=list(map(int,input().split()))

ans=0
tmp=0
for i in range(n-1):
    if h[i]>=h[i+1] and i==n-2:
        tmp+=1
        ans=max(ans,tmp)
    elif h[i]>=h[i+1]:
        tmp+=1
    else:
        ans=max(ans,tmp)
        tmp=0
print(ans)

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

int c[150],t[150];

int main(){
	int N,T;cin>>N>>T;
	int n = 1;		
	while (n <= N){
		cin>>c[n]>>t[n];
		n += 1;
	}
	int i = 1,min = 10000;
	while (i <= N){
		if (t[i] <= T){
			if (min > c[i]){
				min = c[i];
			}
		}
		i += 1;
	}
	if (min == 10000){
		cout<<"TLE";
	}
	else {
		cout<<min;
	}			
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int H,W;
  char a[100][100];
  int n,m;
  int compH=0,compW=0;
  
  scanf("%d %d",&H,&W);

  for(n=0;n<H;n++){
    scanf(" ");
    for(m=0;m<W;m++)
      scanf("%c",&a[n][m]);
  }
  
  for(n=0;n<H;n++){
    for(m=0;m<W;m++)
      a[n-compH][m]=a[n][m];
    for(m=0;m<W;m++)
      if(a[n][m]=='#')
	break;
    compH+=(m==W);
  }

  for(m=0;m<W;m++){
    for(n=0;n<H;n++)
      a[n][m-compW]=a[n][m];
    for(n=0;n<H;n++)
      if(a[n][m]=='#')
	break;
    compW+=(n==H);
  }
  
  for(int n=0;n<H-compH;n++){
    for(int m=0;m<W-compW;m++)
      printf("%c",a[n][m]);
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <limits>
#include <stack>
#define ll long long
using namespace std;
int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
max=0
ans=0
A.each do|a|
  if max<=a
      max=a
  else
      ans+=max-a
  end
end
puts ans

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

#include <algorithm>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    ll ans = 1000;
    int N;
    cin >> N;
    int A[N + 1];
    // int grad[N];

    rep(i, N) cin >> A[i];
    A[N] = 0;
    // fill(grad,grad+N,0);

    int minA = A[0];
    for (int i = 1; i < N; i++) {
        // 最小値のところで買うほうが良い
        if (minA > A[i]) {
            minA = A[i];
        }
        // 高くで売れる時
        else if (minA < A[i]) {
            int maxA = A[i];

            int j = i;
            // それより後でもっと高く売れるかも
            // 安い値段が来たら、そこで売って、次高くなる時に買いたいので、安くなるまで
            while (j < N && maxA <= A[j]) {
                maxA = A[j];
                j++;
            }
            // そこの添字を戻す
            i = j;

            ll cnt = ans / minA;
            // 一番安くで買う
            ans -= minA * cnt;
            // 買った分を高い値段で売る
            ans += cnt * maxA;
            // 最小値を更新
            minA = A[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
using System;
namespace ABC175
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp = Console.ReadLine();
            string[] vs = inp.Split(' ');
            for(int i = 0; i < 5; i++)
            {
                if (i + 1 != int.Parse(vs[i]))
                {
                    Console.WriteLine(i + 1);
                }
            }
        }
    }
}

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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    int m,n;
    for(int i=0;i<1000010;i++){
        if(i*8/100==a&&i/10==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;

}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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;}

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  rep (i, n) {
    int a, b;
    cin >> a >> b;
    v[i] = make_pair(b, a);
  }
  sort(v.begin(), v.end());
  ll now = 0;
  rep (i, n) {
    now += v[i].second;
    if (now > v[i].first) {
      No;
      return 0;
    }
  }
  Yes;
  return 0;
}



Measured memory_bytes: 1792
/*
	Name: Harshit Jain
	Institution: IIIT Vadodara
*/
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <list>
#include <stack>
#include <cstring>
#include <map>
#include <queue>
#include <ctime>
#include <iomanip>
#include <set>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <climits>

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ull unsigned long long
#define rep(i,a,b) for(ll i = a; i < b; ++i)
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeofa((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define p(a) cout << a << "\n";
#define p1(a) cout << a << " ";

#define PI 3.141592653589793
#define MOD (ll)(1e9 + 7)
#define m(a) ((a)%MOD)

using namespace std;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
//=======================

void solve()
{
	ll n,y;
	cin >> n >> y;
	rep(i,0,2001)
	{
		rep(j,0,2001)
		{
			if(9*i + 4*j == y/1000 - n && n-i-j >= 0)
			{
				cout << i << " " << j << " " << " " << n - i - j << "\n";
				return;
			}
		}
	}
	p("-1 -1 -1")
}	

//=======================
int main()
{
	bool testing = false;
	IOS
	if(testing)
	{
		freopen("test.txt","rt",stdin);
		int start = clock();
		solve();
		int end = clock();
		cout << "time: " << (end - start)/(double)(CLOCKS_PER_SEC)*1000 << " milliseconds\n";
	}
	else
	{
		solve();
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define sz size()
#define FORN(i,j,n) for(int i=j; i<(int)n;i++) 
#define FOR(i,n) FORN(i,0,n)
#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )
#define MOD 998244353LL
#define LIM 262150
#define ones(x) __builtin_popcount(x)
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
using namespace std;
 
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;
ll n , k;
ll dp[100005];
ll arr[100005];
int main() {
	fastio;
	cin>> n >> k;
	FOR(i,n) cin>> arr[i];
	dp[0] = 0;
	FORN(i,1,n){
		dp[i] = 1e12;
	}
	FOR(i,n){
		FORN(j,1,min(k+1,n-i)){
			dp[i+j] = min(dp[i]+abs(arr[i+j]-arr[i]),dp[i+j]);
		}
	}
	cout<< dp[n-1] << "\n";
	return 0;
}

Measured memory_bytes: 5256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    S = input()[:-1]
    print("x" * len(S))


if __name__ == '__main__':
    main()

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    vary(ll,k,n,0);
    bool f = false;
    ll one = 0,more = 0;
    rep(i,n){
      cin >> k[i];
      if(k[i] > 1){
        f = true;
        more++;
      }
      else if(k[i]) ++one;
    }
    if(f){
      cout << more + one + 1 << endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3260