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

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

const long long INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 100010;
long long dp [MAX_N][MAX_V];

int main(void){
  //initialize
  for(int i=0;i<MAX_N;i++){
    for(int j=0;j<MAX_V;j++){
      dp[i][j] = INF; //最初のハマりポイント 最小化なのでINFで初期化
    }
  }
  //initial condition
  dp[0][0] = 0;

  int N;
  long long W, weight[MAX_N], value[MAX_N];
  cin >> N >> W;
  for(int i=0;i<N;i++){
    cin >> weight[i] >> value[i];
  }

  //prob-dと違いW(~10^9)が大きいのでdp[N][W]などとするとメモリが大変
  //各々のiについてobjectを荷物に加えるかいなかを判断し、重さの低い方を採用
  for(int i=0;i<N;i++){
    for(int sum_v=0; sum_v <= MAX_V; sum_v++){
      //select
      if(sum_v + value[i] <= MAX_V){
        chmin(dp[i+1][sum_v+value[i]], dp[i][sum_v] + weight[i]);
      }
      //don't select
      chmin(dp[i+1][sum_v],dp[i][sum_v]);
    }
  }

  long long ans=0;
  //２つ目のハマりポイント sum_vに初期値を与えるのを忘れていた
  for(int sum_v=0; sum_v<MAX_V; sum_v++){
    if(dp[N][sum_v] <= W){
      ans = sum_v;
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 86144
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstring>



using namespace std;




int main()
{
   //IOS;
	int n,a,b;
	cin >> n >> a >>b;
	if(b==(a+1))
	{
		cout << "Borys";
		return 0;
	}
	int dif=(b-a-1);
	if(dif%2==0)
	{
		cout << "Borys";
		return 0;
	}
	else if(dif%2)
	{
		cout << "Alice";
		return 0;
	}

    
    
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	S = input()
	S = S[:-1]

	if N % 2 == 1:
		print("No")
		sys.exit()

	tmp = int(N / 2)
	if S[:tmp] == S[tmp:]:
		print("Yes")
	else:
		print("No")


if __name__ == "__main__":
	main()


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

using namespace std;

int n,k,i,j;
int tablica[100003];
bool dp[100003];

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> tablica[i];
    }
    for(i=0;i<=k;i++)
    {
        for(j=0;j<n;j++)
        {
            if(tablica[j]+i<=k)
            {
                if(dp[i]==false && dp[tablica[j]+i]==false)
                {
                    dp[i+tablica[j]]=true;
                }
            }
        }
    }
    if(dp[k]==true){
        cout << "First";
    }
    else{
        cout << "Second";
    }
    return 0;
}


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

class Test
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Display(A);

        for (int i = 1; i <= N - 1; i++)
        {
            int v = A[i];
            int j = i - 1;
            while (j >= 0 && A[j] > v)
            {
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = v;
            Display(A);
        }
    }

    static void Display(int[] d)
    {
        for (int i = 0; i < d.Length; i++)
        {
            Console.Write(d[i]);
            if (i != d.Length - 1) Console.Write(" ");
            else Console.Write('\n');
        }
    }
}


Measured memory_bytes: 18292
from sys import stdin
import sys
import collections


##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    H, W = rip()
    S = [rs() for i in range(H)]
    #min = np.full((H,W),-1, dtype = 'int')
    min = [[-1] * W for i in range(H)]
    q = collections.deque()
    def enc(h, w): return h * W + w
    def inRange(t, l, r): return l <= t and t < r
    dx = [0,1,0,-1]
    dy = [1,0,-1,0]

    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                q.append(enc(i,j))
                min[i][j] = 0
    while(len(q) > 0):
        rc = q.popleft()
        y = rc // W
        x = rc % W
        for t in range(4):
            nx = x + dx[t]
            ny = y + dy[t]
            if (not inRange(nx,0,W)) or (not inRange(ny,0,H)): continue
            if min[ny][nx] == -1:
                min[ny][nx] = min[y][x] + 1
                q.append(enc(ny,nx))
    
    ma = 0
    for i in range(H):
        for j in range(W):
            ma = max(ma, min[i][j])
    print(ma)





if __name__ == "__main__":
    main()


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

ll help(ll a,ll b){
    if(b==0)return 1;
    if(b==1)return a;
    ll ans = 1;
    if(b&1){
        ans = help(a,b-1)*a;
    }
    else {
        ans  = help(a,b/2);
        ans = ans * ans;
    }
    return ans%mod;
}

int main(){
    ll n;
    cin>>n;
    ll x = help(10,n)%mod;
    ll y = help(9,n)%mod;
    ll z = help(8,n)%mod;
    ll res = (x-2*y+z+2*mod)%mod;
    cout<<res;
    return 0;    
}

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

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

    if (s == u) a--;
    if (t == u) b--;

    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 3628
import std.stdio;

void main(){
	auto cin = new Cin();
	
	cin.line();
	auto L = cin.line();
	L.sort();
	size_t ans = 0;
	
	for( size_t i=0 ; i<L.length ; i+=2 ){
		ans += ( L[i] < L[i+1] ) ? L[i] : L[i+1] ;
	}
	writeln(ans);
}

import std.stdio,std.conv,std.string;
import std.algorithm,std.array;

class Cin
{
	auto line( T = size_t )( string token = " " ){
		T[] arr;
		foreach( elm ; readln().chomp().split(token) ){
			arr ~= elm.to!T();
		}
		return arr;
	}
	/*auto rect( T = size_t )( string token = " " ){
		T[][] arr;
		arr = new
	}*/
}


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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	ll a,b,n;
	cin>>a>>b>>n;

	ll i = min(n,b-1LL);

	cout << ll((i*a)/b) - a*ll(i/b) << endl;
	return 0; 

	if(n>=b-1)
	{
		int i = b-1;
	}

	for(int i=0; i<=n; i++)
	{
		cout << i << " " << ll((i*a)/b) - a*ll(i/b) << endl;
	}
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;
 
#define pai 3.14159265359
#define mod 1000000007

int main()
{
    int n;
    cin >> n;
    vector<int> l;
    for(int i = 0; i < 2 * n; i++){
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    sort(l.begin(), l.end());
    int sum = 0;
    for(int i = 0; i < 2 * n; i += 2){
        sum += l[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int sum = 0;
        int max = 0;
        for (int i = 0; i < n; ++i) {
            int length = reader.nextInt();
            sum += length;
            if (length > max)
                max = length;
        }
        reader.close();
        System.out.println(sum - max > max ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.xml
Imports System.xml.Linq

Module Module1
	public sub main()

		dim SW as string() = Console.ReadLine().split(" ")
    dim S as integer = convert.toint32(SW(0))
    dim W as integer = convert.toint32(SW(1))
    if W >= S then 
      console.writeLine("unsafe")
    else
      console.writeLine("safe")
    end if
    
	end sub 
End Module

Measured memory_bytes: 27512
#include <iostream>

using namespace std;
typedef long long ll;

int main()
{
    ll a, b;
    cin >> a >> b;

    ll x = a * b;

    if(a < b){
        ll temp = b;
        b = a;
        a = temp;
    }

    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }

    cout << x / b << endl;
}


Measured memory_bytes: 256
N = int(input())
points = [list(map(int, input().split())) for i in range(N)]


def dist(cx, cy, nx, ny):
    return ((cx - nx) ** 2 + (cy - ny) ** 2) ** 0.5


def circumcenter(x1, x2, x3, y1, y2, y3):
    # coordinates

    # length of each side squared and area of the triangle
    a2 = (x2 - x3) ** 2 + (y2 - y3) ** 2
    b2 = (x1 - x3) ** 2 + (y1 - y3) ** 2
    c2 = (x2 - x1) ** 2 + (y2 - y1) ** 2
    area = ((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) / 2

    # is_triangle
    if area == 0:
        d1 = dist(x1, y1, x2, y2)
        d2 = dist(x1, y1, x3, y3)
        d3 = dist(x2, y2, x3, y3)
        if max(d1, d2, d3) == d1:
            return (x1 + x2) / 2, (y1 + y2) / 2
        elif max(d1, d2, d3) == d2:
            return (x1 + x3) / 2, (y1 + y3) / 2
        else:
            return (x2 + x3) / 2, (y2 + y3) / 2

    # circumcenter coordinate and radius
    x = (a2 * (b2 + c2 - a2) * x1 + b2 * (c2 + a2 - b2) * x2 + c2 * (a2 + b2 - c2) * x3) / (16 * area * area)
    y = (a2 * (b2 + c2 - a2) * y1 + b2 * (c2 + a2 - b2) * y2 + c2 * (a2 + b2 - c2) * y3) / (16 * area * area)

    # return the equation
    return x, y


ans = float('inf')
for i in range(N):
    for j in range(N):
        for k in range(N):
            x1, y1 = points[i]
            x2, y2 = points[j]
            x3, y3 = points[k]

            cx, cy = circumcenter(x1, x2, x3, y1, y2, y3)
            tmp_ans = 0
            for nx, ny in points:
                tmp_ans = max(tmp_ans, dist(cx, cy, nx, ny))
            ans = min(ans, tmp_ans)

print(ans)


Measured memory_bytes: 55640
from decimal import Decimal
import math
n,d=map(int,input().split())
x=[]
ans=0
for i in range(n):
    x.append(list(map(int,input().split())))
for i in range(n-1):
    for j in range(i+1,n):
        tmp=0
        for k in range(d):
            tmp+=(x[i][k]-x[j][k])**2
        tt=math.sqrt(tmp)
        if tt==int(tt):
            ans+=1
print(ans)

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

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

int N, K, ans = 0;
vint D(10);

bool ok(int n,vint d)
{
	string Str = to_string(n);
	for (int i = 0; i < Str.size(); i++)
	{
		for (int j = 0; j < d.size(); j++)
		{
			if (Str[i] - '0' == d[j])
				return false;
		}
	}
	return true;
}

int main()
{
	
	cin >> N >> K;
	D.resize(K);
	rep(i, K)
	{
		cin >> D[i];
	}
//	string str = to_string(N);
	int i;
	for (i = N; i <= 10 * N; i++)
	{
		if (ok(i, D))
		{
			break;
		}
	}
	cout << i;
	
	//cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
 
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
ll a[maxn];
int main()
{
	IOS;
	int n,d;
	cin>>n>>d;
	REP(i,n) cin>>a[i];
	REP(i,n-1) if(a[i]+a[i+1]>=d){
	    cout<<"Possible\n";
        for(int j=1;j<=i;j++) cout<<j<<'\n';
        for(int j=n-1;j>i+1;j--) cout<<j<<'\n';
        cout<<i+1<<'\n';
        return 0;
	}
	cout<<"Impossible\n";
}

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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

vb prime(1000000, true);

void calc_prime()
{
    prime[0] = false;
    prime[1] = false;

    for (int j = 2; j * j <= (1e5); j++)
    {
        if (prime[j] == false)
            continue;
        int x = j * 2;
        while (1)
        {
            prime[x] = false;
            x += j;
            if (x > 1e5)
                break;
        }
    }
}

int main(void)
{
    calc_prime();
    vll sum(1e5 + 1, 0);
    rep(i, 2, 1e5 + 1)
        sum[i] = sum[i - 1] + (prime[i] && prime[(i + 1) / 2] && (i + 1) % 2 == 0);

    ll q;
    cin >> q;
    rep(i, 0, q)
    {
        ll l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }
}

Measured memory_bytes: 1536
#include<stdio.h>
int abs(int,int);
int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(abs(a,c)<=d || (abs(a,b)<=d && abs(b,c)<=d)){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}
int abs(int x,int y){
  int sub=x-y;
  if(sub<=0){
    sub=-1*sub;
  }
  return sub;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;

	N *= 4;
	vector<ll> tmp(4), size(4), price(4);
	tmp[0] = 8*Q, size[0] = 1, price[0] = Q;
	tmp[1] = 4*H, size[1] = 2, price[1] = H;
	tmp[2] = 2*S, size[2] = 4, price[2] = S;
	tmp[3] = D, size[3] = 8, price[3] = D;
	vector<pll> s(4);
	REP(i, 4){
		s[i].first = tmp[i];
		s[i].second = i;
	}
	sort(s.begin(), s.end());
	ll res = 0;
	ll ind = 0;
	while(1){
		res += (N/size[s[ind].second])*price[s[ind].second];
		N %= size[s[ind].second];
		if(N==0) break;
		ind++;
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (true) {
        int n,r; cin >> n >> r;
        if (n == 0 && r == 0) break;
        vector<vector<int>> card(r+1, vector<int>(n));
        rep(i,n) card[0][i] = n-i;
        rep(i,r) {
            int p,c; cin >> p >> c;
            rep(j,n) {
                if (j < c) {
                    card[i+1][j] = card[i][j+p-1];
                } else if (c <= j && j < p-1+c) {
                    card[i+1][j] = card[i][j-c];
                } else card[i+1][j] = card[i][j];
            }
        }
        cout << card[r][0] << endl;
    }
} 



Measured memory_bytes: 3056
#include <iostream>

const int N = 7;

typedef struct {
  int panels[N];
  int upper;
  int east;
  int south;
} Dice;

void rotate_dice(int *x, int *y, int d) {
  *x = *y;
  *y = d;
}

int main(void) {
  Dice dice;

  for (int i = 1; i < N; i++) {
    std::cin >> dice.panels[i];
  }

  dice.upper = 1;
  dice.east = 3;
  dice.south = 2;

  std::string input;
  std::cin >> input;
  
  for (int i = 0; i < input.size(); i++) {
    char m = input[i];

    if (m == 'E') {
      rotate_dice(&dice.east, &dice.upper, N - dice.east);
    } else if (m == 'W') {
      rotate_dice(&dice.upper, &dice.east, N - dice.upper);
    } else if (m == 'S') {
      rotate_dice(&dice.south, &dice.upper, N - dice.south);
    } else {
      rotate_dice(&dice.upper, &dice.south, N - dice.upper);
    }
  }

  std::cout << dice.panels[dice.upper] << std::endl;
  
  return 0;
}

Measured memory_bytes: 1208
s=gets.chomp.split("")

array=("abcdefghijklmnpoqrstuvwxyz").chomp.split("")
array2=Array.new(26,0)


kk=array.index(s[0])
array2[kk]=1


answer=1
i=0
(s.length-1).times{
    number=array.index(s[i+1])
    answer+=i+1-array2[number]
    array2[number]+=1
    
    i+=1

}
puts answer

Measured memory_bytes: 12796
let count target s =
  let rec f i tmp =
    if i = String.length s then tmp
    else if s.[i] = target then f (i + 1) (tmp + 1)
    else f (i + 1) tmp
  in
  f 0 0


let () = Scanf.scanf "%s" (fun s -> s) 
         |> count '1' |> Printf.printf "%d\n"

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

int main() {
  string s;
  cin >> s;
  if (s[s.size()-1] == 's') cout << s << "es" << endl;
  else cout << s << "s" << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp=0,start=0;
  char s[LIMIT1];
  int u[LIMIT2]={0};
  int cc[2020]={0};
  
  scanf("%s",s);
  n=strlen(s);
  for(i=n-1;i>=0;i--){
    //tmp=1;
    tmp=modpow(10,n-1-i,2019);
    tmp*=(int)(s[i]-'0');
    if(i<n-1) tmp+=u[i+1];
    tmp%=2019;
    u[i]=tmp;
    cc[u[i]]++;
  }
  //qsort(u,n,sizeof(int),upint);
  result=cc[0];
  for(i=0;i<2019;i++){
    if(cc[i]>=2) result+=nCr(cc[i],2);
  }
  //rep(i,n) printf("%d ",u[i]);
  //printf("\n");
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 3832
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<random>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
struct val{
  ll n,c;
  bool mk;
};
const val INV = val{0,0,true};
void next_que(queue<val> &que,val &use){
  if(que.empty()){
    use = INV;
  }else{
    use = que.front();
    que.pop();
  }
}
void timers(chrono::system_clock::time_point start,double tl){
  double time;
  chrono::system_clock::time_point now;
  ll n;
  cin >> n;
  vector<ll> a(n),b(n),ans(n,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  bool can = false;
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> b[i];
    mp[b[i]]++;
  }
  vector<val> mpr;
  for(auto itr=mp.rbegin();itr!=mp.rend();itr++){
    mpr.push_back(val{itr->first,itr->second,false});
  }
  while(!can){
    val fi,se;
    queue<val> que;
    for(auto itr=mpr.begin();itr!=mpr.end();itr++){
      if(itr->n<=a.back()&&itr->n>=a.front()){
        que.push(val{itr->n,itr->c,false});
      }
    }
    for(auto itr=mpr.begin();itr!=mpr.end();itr++){
      if(itr->n>a.back()||itr->n<a.front()){
        que.push(val{itr->n,itr->c,true});
      }
    }
    next_que(que,fi);
    next_que(que,se);
    for(int i=0;i<n;i++){
      if(fi.n!=a[i]){
        ans[i] = fi.n;
        fi.c--;
        if(fi.c==0){
          fi = se;
          next_que(que,se);
        }
      }else{
        if(se.n==0){
          break;
        }
        ans[i] = se.n;
        se.c--;
        if(se.c==0){
          next_que(que,se);
        }
      }
    }
    if(ans.back()!=0){
      can = true;
      break;
    }
    auto tmp = mpr.back();
     std::random_device seed_gen;
  std::mt19937 engine(seed_gen());
    shuffle(mpr.begin(),mpr.end(),engine);
    now = chrono::system_clock::now();
    time = chrono::duration_cast<chrono::milliseconds>(now-start).count();
    if(time>=tl) break;
  }
  if(!can){
    cout <<"No\n";
    return;
  }
  cout << "Yes\n";
  for(int i=0;i<n;i++){
    cout << ans[i]<<" ";
  }
  cout << endl;
}
signed main(){
  init_io();
  timers(chrono::system_clock::now(),1800);
}


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

int main() {
  int n,T,c1,t1;
  cin >> n >> T >> c1 >>t1;
  for(int i = 1;i < n;i++){
    int c,t;
    cin >> c >> t;
    if(t <= T && c < c1){
      c1 = c;
      t1 = t;
    }
  }
  if(t1 > T){
    cout << "TLE" << endl;
  }
  else{
    cout << c1 << endl;
  }
}


Measured memory_bytes: 256
x,y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c =[2]
if x in a and y in a:
  print('Yes')
elif x in b and y in b:
  print('Yes')
elif x==y==2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	for {
		var sum int
		n := next()
		check, _ := strconv.Atoi(n)
		if check == 0 {
			break
		}
		runes := []rune(n)
		for i := 0; i < len(runes); i++ {
			x, _ := strconv.Atoi(string(n[i]))
			sum += x
		}
		fmt.Fprintf(out, "%d\n", sum)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1232
/* AtCoder Beginner Contest diverta2019_2
 * Problem C
 * Au: SJoshua
 */
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector <int> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	
	sort(nums.begin(), nums.end());
	int lop = nums.front();

	int rop = nums.back();
	for (int i = 1; i < n - 1; i++) {
		if (nums[i] < 0) {
			rop -= nums[i];
		} else {
			lop -= nums[i];
		}
	}
	cout << rop - lop << endl;

	lop = nums.front();
	rop = nums.back();
	for (int i = 1; i < n - 1; i++) {
		if (nums[i] < 0) {
			cout << rop << " " << nums[i] << endl;
			rop -= nums[i];
		} else {
			cout << lop << " " << nums[i] << endl;
			lop -= nums[i];
		}
	}
	cout << rop << " " << lop << endl;

	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >>n >>k;
  int x, ans=0;
  for(int i=0; i<n; i++){
    cin>>x;
    if(abs(x-k)<x) ans+=(abs(x-k))*2;
    else ans+=x*2;
  }
  cout <<ans <<endl;
  
}

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

int main(){
   
  int A,B,C,D;
  //,a,b,c,d;
  cin >> A >> B >> C >> D;
  
  
  while(A>0 && C>0){
    A-=D;
    C-=B;
    //cout << A << C<< endl;
  }
  
 // cout << A << C<< endl;
  if(A<=0 && C>0)
    cout << "No" << endl;

  else if(A<=0 && C<=0)
    cout << "Yes" << endl;
  else
    cout << "Yes" << endl;
    

  
  
 /* a=A/D;
  b=C/B;
  c=A%D;
  d=C%B;
  
  if(c!=0)
    a++;
  if(d!=0)
    b++;
  
 if(A/D>C/B)
   cout << "Yes" << endl;
  else if(A/D==C/B){
    if(A%D>=C%B)
      cout << "Yes" << endl;
    else 
      cout << "No" << endl;
  }else{
    cout << "No" << endl;
  }*/
  
}




Measured memory_bytes: 3592
a=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[b-1][f-1][r-1]+=v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" "+str(a[i][j][k]),end="")
        print()
    if (i!=3):
        print("####################")


Measured memory_bytes: 5628
n, m, x = gets.split.map(&:to_i)
a = Array.new
n.times do |i|
    a[i] = gets.split.map(&:to_i)
end
min_cost = 10**7
1.upto(n) do |i|
    a.combination(i).each do |r|
        ps = Array.new(m, 0)
        cost = 0
        r.each do |rr|
            0.upto(m) do |j|
                if j == 0
                    cost += rr[j]
                else
                   ps[j - 1] += rr[j]
               end
            end
        end
        if ps.all?{|s| s >= x}
            min_cost = cost if cost < min_cost
        end
    end
end
min_cost = -1 if min_cost == 10**7
puts min_cost

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,M; cin >> N >> M;
	int s = 0;
	vector<vector<int>> c(N,vector<int>(N,0));
	repp(i,0,M){
		int x,y,z; cin >> x >> y >> z;
		--x; --y;
		c[x][y] = c[y][x] = z;
		s += z;
	}
	vector<int> d(1<<N,0);
	repp(k,1,1<<N){
		int i = 0;
		while(!(k&(1<<i))) ++i;
		d[k] = d[k^(1<<i)];
		repp(j,i+1,N) if(k&(1<<j)) d[k] += c[i][j];
	}
	vector<vector<int>> dp(1<<N,vector<int>(N,-123456789));
	dp[1][0] = 0;
	repp(k,0,1<<(N-1)) repp(i,0,N-1) if((k*2+1)&(1<<i)) repp(j,1,N) if(!((k*2+1)&(1<<j))) if(c[i][j] > 0) dp[(k*2+1)^(1<<j)][j] = max(dp[(k*2+1)^(1<<j)][j],dp[k*2+1][i]+c[i][j]);
	repp(k,0,1<<(N-1)){
		for(int m = k ; m > 0 ; m = (m-1)&k){
			dp[2*k+1][N-1] = max(dp[2*k+1][N-1],dp[2*(k^m)+1][N-1]+d[m*2+1]);
			repp(i,0,N-1) if((m^k)&(1<<i)) dp[2*k+1][N-1] = max(dp[2*k+1][N-1],dp[2*(k^m)+1][N-1]+d[m*2+(1<<(i+1))]);
		}
	}
	cout << s-dp[(1<<N)-1][N-1] << endl;
	return 0;
}


Measured memory_bytes: 3712
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int D = in.nextInt();
        int T = in.nextInt();
        int S = in.nextInt();
        if (D <= T * S)
            out.println("Yes");
        else
            out.println("No");

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}


Measured memory_bytes: 32752
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y, S;

int main()
{
    cin >> K >> S;
    
    ll cnt = 0;
    for (int i = 0; i <= K; ++i) {
        for (int j = 0; j <= K; ++j) {
            int k = S - i - j;
            if (0 <= k && k <= K) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    cout << ( A[A.size()-1] == B[0] && B[B.size()-1] == C[0] ? "YES" : "NO" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,k,a[200005];
double ans,jans;
double work(int w){
	return (double) 1.0*(w+1)*w*0.5/(double) w;
}
int main(){
	scanf ("%d%d",&n,&k);
	for (register int i=1;i<=n;++i){
		scanf ("%d",&a[i]);
	}
	for (register int i=1;i<=k;++i){
		ans+=work(a[i]);
	}
	jans=ans;
	for (register int i=k+1;i<=n;++i){
		int j=i-k;
		ans-=work(a[j]);
		ans+=work(a[i]);
		if (ans>jans) jans=ans;
	}
	printf ("%.12lf\n",jans);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

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

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

int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int ans = 0;
  rep(i,n){
    if(s[i] != t[i]) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3832
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
int A,B,C;

int main()
{
  int n;
  int ret=0;

  cin >> A >> B >> C;

  if (A==B) ret++;
  if (A==C) ret++;
  if (B==C) ret++;
  if (ret == 1)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 256
//B-Palindrome-philia
#include<iostream>
#include<string>
using namespace std;

int main(){
  string str; int count=0;
  cin>>str;

  for(int i=0;i<str.size()/2;i++){
    if(str[i]!=str[str.size()-1-i]){
      count++;
    }
  }
  cout<<count<<endl;

  return 0;
}


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

int main(){
  int N, d;
  cin >> N;
  vector<int> X(N);
  rep(i, N){
    cin >> d;
    X[i] = d;
  }
  sort(X.begin(), X.end());
  cout << X[N/2] - X[N/2-1] << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define FS ios_base::sync_with_stdio(0);
#define FOR(i,s,e) for(int i=s; i<e; ++i)
#define FFOR(i,s,e) for(int i=s; i<=e; ++i)
#define mem(o,s) memset(s,o,sizeof(s));
typedef long long ll;
#define MOD 1000000007
#define pi pair<int,int>
#define fi first
#define se second
#define pb push_back

int main(){
  FS
  int N;
  cin>>N;
  int A[N+3];
  int mx = N+3, ans = 0;
  FOR(i,0,N) {
    cin>>A[i];
    if(mx>=A[i]){
      ans++;
      mx = min(mx,A[i]);
    }
  }
  cout<<ans<<'\n';
      
  
}
    


Measured memory_bytes: 1152
import math
a, b = map(int, input().split())
c = math.gcd(a, b)

def ex_euclid(x, y):
  c0, c1 = x, y
  a0, a1 = 1, 0
  b0, b1 = 0, 1

  while c1 != 0:
      m = c0 % c1
      q = c0 // c1

      c0, c1 = c1, m
      a0, a1 = a1, (a0 - q * a1)
      b0, b1 = b1, (b0 - q * b1)

  return c0, a0, b0

_, a, b = ex_euclid(a, b)
print(a, b)


Measured memory_bytes: 5668
#include <bits/stdc++.h>
    #define int long long
    #define endl '\n'
    #define modulo 1000000007
    using namespace std;
    int32_t main()
    {
    iostream::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    s[m-1]=tolower(s[m-1]);
    cout<<s;
    return 0;
}


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

using namespace std;

int main() {



    // 整数の入力 スペース区切りの整数の入力
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;


    int w_suger_water = 0;
    int w_suger = 0;



    std::vector<int> water_paterrn;
    for (int a = 1; a <= 30; a++) {
        for (int b = 0; b <= 30; b++) {

            int watter = ((a * A )+ (b * B)) * 100;
            if (watter < F && watter!=0) {

                water_paterrn.push_back(watter);
            }

        }

    }


/*
    for (const auto &p : water_paterrn) {

        cout << p << endl;
    }
*/

    std::vector<double> result;
    std::vector<pair<int, int>> finalresult;


    for (int i = 0; i < water_paterrn.size(); i++) {

        int enable_suger_max = (int) ((water_paterrn[i] / 100) * E);


        int allsuger = 0;
        int water_and_suger_mass = 0;//water_paterrn[i];
        double concentration = 0;
        //
        double max_concentration = 0;
        int max_allsuger = 0;
        int max_water_and_suger = 0;

        for (int iter_c = 0; iter_c <= enable_suger_max; iter_c++) {

            for (int iter_d = 0; iter_d <= enable_suger_max; iter_d++) {

                allsuger = (iter_c * C) + (iter_d * D);
                water_and_suger_mass = water_paterrn[i] + allsuger;

                if ((water_and_suger_mass <= F ) && ( enable_suger_max >= allsuger) && (water_and_suger_mass !=0)) {

                    double j=allsuger;
                    double k=water_and_suger_mass;
                    concentration = (100.0*j)/k;

                    if (concentration >= max_concentration) {
                        max_concentration = concentration;
                        max_allsuger = allsuger;
                        max_water_and_suger = water_and_suger_mass;
                    }

                }
            }

        }

        result.push_back(max_concentration);
        finalresult.emplace_back(max_water_and_suger, max_allsuger);
    }

    //
    std::vector<double >::iterator iter2 = std::max_element(result.begin(), result.end());
    size_t index2 = static_cast<size_t>(std::distance(result.begin(), iter2));


    w_suger_water = finalresult[index2].first;
    w_suger = finalresult[index2].second;


// 出力
    cout << w_suger_water << " " << w_suger << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long pown(long N, long P, long M){
    if(P==0) return 1;
    if(P%2==0){
        long t = pown(N, P/2, M);
        return t*t % M;
    }
    return N * pown(N, P-1, M);
}
int main () {
  string S;
  cin >> S;
  long ans = ((long)pown(3, S.size() - 1, 1000000007));
  long sub = 2;
  for(int i = 1; i < S.size(); i++){
    if(S.at(i) == '1') {
      ans +=  sub * ((long)pown(3, S.size() - i - 1, 1000000007)) % 1000000007;
      sub *= 2;
      sub %= 1000000007;
    }
  }
  cout << (ans + sub) %  1000000007 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int t[250],a[250],b[250],c[250];
int dp[250][250];
int d,n;
int main()
{
	cin >> d >> n;
	for(int i=1;i<=d;i++)cin >> t[i];
	for(int i=0;i<n;i++)cin >> a[i] >> b[i] >> c[i];
	for(int i=2;i<=d;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(t[i]<a[j]||t[i]>b[j])continue;
			for(int k=0;k<n;k++)
			{
				if(t[i-1]<a[k]||t[i-1]>b[k])continue;
				dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(c[j]-c[k]));
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,dp[d][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1364
#include<stdio.h>

int main(){
    int x,y;

    scanf("%d %d", &x, &y);

    while(x>0 && y>0){
        if(x>y){
            x=x%y;
        }else{
            y=y%x;
        }
    }

    if(x!=0){
        printf("%d\n", x);
    }else{
        printf("%d\n", y);
    }

    return 0;
}


Measured memory_bytes: 2104
N, A, B = map(int, input().split())
S = input()

mem = list(S)
now = 0
fore=1
for i in range(N):
    if(mem[i]=='a'):
        if(now<(A+B)):
            now+=1
            print('Yes')
        else:
            print('No')

    elif(mem[i]=='b'):
        if(now<(A+B)):
            if(fore<=B):
                fore+=1
                now+=1
                print('Yes')
            else:
                print('No')
        else:
            print('No')

    else:
        print('No')


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

int main (void)
{
    string n;
    cin >> n;

    for (int i = 0; i < 3; i++) {
        char x = n[i];
        if (x == '7') {
            cout << "Yes" << endl;
    return 0;
        }
    }
            cout << "No" << endl;
    
    return 0;

}

Measured memory_bytes: 3128
#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
  int a;
  int b;
  int c;
  int num;
  int count = 0;
  
  cin >> a >> b >> c >> num;
  
  for (int i = 0;i <= a;i++) {
    for (int ii = 0; ii <= b;ii++) {
      for (int iii = 0;iii <= c;iii++) {
        if (500 * i + 100 * ii + 50 * iii == num) {
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

    int i,j;
    int x[100+1] = {0};
    for( i = 1; i <= N; i++ ){
        scanf("%d", &x[i]);
    }

    int E;
    int ans;
    for( i = 1; i <= 100; i++ ){
        E = 0;
        for( j = 1; j <= N; j++ ){
            E += (x[j]-i)*(x[j]-i);
        }
        //printf("%d\n", E);
        if( i == 1 ){
            ans = E;
        }
        else{
            if( E < ans ) ans = E;
        }
    }


    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
while 1:
    N = int(input())
    if N == 0:
        break
    L = 5000
    MP = [[0]*L for i in range(5)]
    cs = [L]*5
    us = []
    U = [0]*L
    for i in range(N):
        d, p, q = map(int, input().split()); q -= 1
        if d == 1:
            y = L
            for j in range(p):
                y = min(y, cs[q+j])
            y -= 1
            for j in range(p):
                MP[q+j][y] = 1
                cs[q+j] = y

            if all(MP[j][y] for j in range(5)):
                us.append(y)
        else:
            y = cs[q] - p
            for j in range(p):
                MP[q][y+j] = 1
            cs[q] = y
            for j in range(p):
                if all(MP[k][y+j] for k in range(5)):
                    us.append(y+j)
        if us:
            y0 = us[-1]
            for y in us:
                U[y] = 1
            for j in range(5):
                cur = y0
                for k in range(y0, cs[j]-1, -1):
                    if U[k]:
                        continue
                    MP[j][cur] = MP[j][k]
                    cur -= 1
                for k in range(cur, cs[j]-1, -1):
                    MP[j][k] = 0
                while cur < L and MP[j][cur] == 0:
                    cur += 1
                cs[j] = cur
            for y in us:
                U[y] = 0
            us = []
    ans = 0
    for j in range(5):
        for k in range(cs[j], L):
            ans += MP[j][k]
    print(ans)


Measured memory_bytes: 6048
import java.awt.geom.*;
import java.io.*;
import java.util.*;


public class Main {
	//2327 start
	int [] map = {-1, 0,1,2,0,-1,2,0,1,2};
	int INF = 1 << 24;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			String s = sc.next();
			if(s.equals("#")) break;
			int len = s.length();
			int [][][][] dp = new int[len][2][3][3];
			int firststep = map[s.charAt(0) - '0'];
			for(int i = 0; i < len; i++){
				for(int j = 0; j < 2; j++){
					for(int k = 0; k < 3; k++){
						for(int l = 0; l < 3; l++){
							dp[i][j][k][l] = INF;
						}
					}
				}
			}
			dp[0][0][firststep][2] = 0;
			dp[0][1][0][firststep] = 0;
			
			for(int i = 0; i < len-1; i++){
				for(int j = 0; j < 2; j++){
					for(int left = 0; left < 3; left++){
						for(int right = 0; right < 3; right++){
							if(dp[i][j][left][right] == INF) continue;
							dp[i+1][j][left][right] = 
									Math.min(dp[i+1][j][left][right], dp[i][j][left][right] + 1);
							
							int lefts = left;
							int rights = right;
							if(j == 0){
								rights = map[s.charAt(i+1) - '0'];
							}
							else{
								lefts = map[s.charAt(i+1) - '0'];
							}
							if(rights < lefts) continue;
							dp[i+1][(j + 1) % 2][lefts][rights] = 
									Math.min(dp[i+1][(j+1) % 2][lefts][rights], dp[i][j][left][right]);
						}
					}
				}
			}
			
			int ans = INF;
			for(int i = 0; i < 2; i++){
				for(int j = 0; j < 3; j++){
					for(int k = 0; k < 3; k++){
						ans = Math.min(ans, dp[len-1][i][j][k]);
					}
				}
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 48000
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    std::deque<int> deq(100002,0);
    int count=0;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq[a]++;
        deq[a+1]++;
        if (a-1<0) {
            count++;
        } else {
            deq[a-1]++;
        }
    }
    int max=0;
    for (int j=0;j<deq.size();j++) {
        if (max<deq[j]) {
            max=deq[j];
        }
    }
    if (count>max) {
        cout<<count<<endl;
    } else {
        cout<<max<<endl;
    }
}


Measured memory_bytes: 640
#include<cstdio>
using namespace std;
typedef double db;
const int N=500500;
int i,j,k,n,l,r,L,v,t,V,ch;
int a[N];
db T,b[N];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) ch=getchar();
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
}
int main() {
	R(n);R(L);
	l=1;r=0;
	for (i=1;i<=n;i++) {
		R(t);R(v);
		while (V+v>L) {
			if (V-a[l]+v>=L) {
				V-=a[l];
				T-=b[l];
				l++;
			}
			else {
				int tv=V+v-L;
				db tt=b[l]/(1.0*a[l])*tv;
				a[l]-=tv;
				b[l]-=tt;
				V-=tv;
				T-=tt;
			}
		}
		V+=v;
		T+=1.0*t*v;
		r++;
		a[r]=v;
		b[r]=1.0*t*v;
		while (l<r && b[r]*a[r-1]<b[r-1]*a[r]) {
			a[r-1]+=a[r];
			b[r-1]+=b[r];
			r--;
		}
		printf("%.7lf\n",T/(1.0*V));
	}
}

Measured memory_bytes: 14848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int t, x;
  cin >> t >> x;

  printf("%.10f\n", (double)t/x);
  return 0;
}


Measured memory_bytes: 256