akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>

using namespace std;

long long mod = 1000000007;

long long pow(long long x, long long k)
{
    if (k == 0)
    {
        return 1LL;
    }
    long long temp = pow(x, k / 2);
    if (k % 2 == 1)
    {
        return (((temp * temp) % mod) * x) % mod;
    }
    else
    {
        return (temp * temp) % mod;
    }
}

long long modular_inverse(long long x)
{
    return pow(x, mod - 2);
}

long long binomial(long long n, long long k)
{
    long long rez = 1;
    for (int i = n - k + 1; i <= n; i++)
    {
        rez *= i;
        rez %= mod;
    }
    long long temp = 1;
    for (int i = 1; i <= k; i++)
    {
        temp *= i;
        temp %= mod;
    }
    rez *= modular_inverse(temp);
    rez %= mod;
    return rez;
}

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char> > c(h, vector<char>(w));
    vector<vector<int> > res(h, vector<int>(w));
    int firstRow = -1;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> c[i][j];
            if (c[i][j] == '#' && firstRow == -1)
            {
                firstRow = i;
            }
        }
    }
    int curr = 1;
    for (int i = firstRow; i < h; i++)
    {
        bool copyPrev = true;
        for (int j = 0; j < w; j++)
        {
            if (c[i][j] == '#')
            {
                copyPrev = false;
                break;
            }
        }
        if (copyPrev)
        {
            for (int j = 0; j < w; j++)
            {
                res[i][j] = res[i - 1][j];
            }
        }
        else
        {
            vector<int> ids;
            for (int j = 0; j < w; j++)
            {
                if (c[i][j] == '#')
                {
                    ids.push_back(j);
                }
            }
            queue<int> changePoints;
            for (int j = 1; j < ids.size(); j++)
            {
                changePoints.push(ids[j] - 1);
            }
            changePoints.push(w - 1);
            for (int j = 0; j < w; j++)
            {
                res[i][j] = curr;
                if (changePoints.front() == j)
                {
                    changePoints.pop();
                    curr++;
                }
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << res[max(i, firstRow)][j] << " ";
        }
        cout << '\n';
    }
    return 0;
}


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

namespace abc165_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = double.Parse(Console.ReadLine());
            double a = 100; //銀行預金100円
            int answer = 0; //何年後にX円を上回る

            while (a < X)
            {
                a = Math.Floor(a * 1.01);
                answer ++;
            }

            Console.WriteLine(answer);

            Console.Read();
        }
    }
}


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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

ll S1[1010101], S2[1010101];
ll n, ans;

int main()
{
	ll i, x;
	
	scanf("%lld", &n);
	
	ans = 1;
	
	for(i=0; i<n; i++){
		if(i >= 3) x = ((i - 2) * S1[i - 3] - S2[i - 3] + mod + 1) % mod;
		else x = 1;
		
		if(i < n) ans = (ans + x * (n - 1)) % mod;
		if(i < n - 1) ans = (ans + x * (n - 1) % mod * (n - 1)) % mod;
		
		S1[i] = (S1[i - 1] + x) % mod;
		S2[i] = (S2[i - 1] + x * i) % mod;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 16000
n = gets.to_i
s = n.times.map{gets.chomp}

alp = ("a".."z").step(1).to_a

min = Hash.new(50)
sc = n.times.map{Hash.new(0)}

n.times{|i| s[i].chars{|c|sc[i][c] += 1}}

sc.each{|t|
  alp.each{|c|
    min[c] = t[c] if min[c] > t[c]
  }
}

ans = []
min.each{|k,x| ans<<k*x}
puts ans.join


Measured memory_bytes: 3964
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
)
 
var sc = bufio.NewScanner(os.Stdin)

//fmt.Scan(&a)とかの方が楽ではある。
//1行に二つ以上の塊があるパターン
//for r = append(r, s[0])
//的な感じ
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
func abc053b(str string){
	ans := strings.LastIndex(str,"Z") - strings.Index(str,"A") + 1
	fmt.Println(ans)
}
 
func main(){
	str := ""
	fmt.Scan(&str)
	abc053b(str)
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    int n;
    cin>>n;
    int a[n+1];
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    }
    a[n] = 0;
    int stocks = 0, money = 1000;
    for (int i = 0; i < n; ++i)
    {
    	if(a[i+1] > a[i]) {
    		int temp = money / a[i];
    		stocks += temp;
    		money -= temp * a[i];
    	}
    	else if(a[i+1] < a[i]){
    		money += stocks * a[i];
    		stocks = 0;
    	}
    }
    show(money);
    return 0;
}

Measured memory_bytes: 3648
from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
    
n,p=map(int,input().split())
c = Counter(prime_factorize(p))
ans=1
for k,v in c.items():
    ans*=k**(v//n)
print(ans)

Measured memory_bytes: 9400
N = int(input())
C = input()

l_W = [0]*(N+1)
r_R = [0]*(N+1)

for i in range(N):
  l_W[i+1] = l_W[i] + (C[i]=='W')
  r_R[N-i-1] = r_R[N-i] + (C[N-i-1]=='R')
  
times = [max(l,r) for l,r in zip(l_W,r_R)]

print(min(times))

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

import javax.swing.text.StyledEditorKit.ForegroundAction;

public class Main {

    public Main() {
    }

    private static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().run();
    }

    int N;
    int M;
    boolean[] visited;
    List<List<Integer>> adjList = new ArrayList<List<Integer>>();

    private void run() {
        N = sc.nextInt();
        M = sc.nextInt();
        visited = new boolean[N];

        for (int i = 0; i < N; i++) {
            adjList.add(new ArrayList<Integer>());
        }

        for (int i = 0; i < M; i++) {
            int from = sc.nextInt() - 1;
            int to = sc.nextInt() - 1;
            adjList.get(from).add(to);
            adjList.get(to).add(from);
        }

        int ans = 0;
        ans = dfs(0, 0);

        System.out.println(ans);
    }

    private int dfs(int n, int idx) {
        if (n == N - 1) {
            return 1;
        }
        visited[idx] = true;

        int res = 0;
        for (int i = 0; i < adjList.get(idx).size(); i++) {
            if (visited[adjList.get(idx).get(i)]) {
                continue;
            }

            res += dfs(n + 1, adjList.get(idx).get(i));
        }
        visited[idx] = false;
        return res;
    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
  double  a,b,x;cin>>a>>b>>x;
     double y=0;
    double ans=0;
    if(x>(a*a*b)/2.0000000){
        y=(2.0000000/(a*a))*(a*a*b-x);
        ans=atan2((double)(y),( double)(a));
    }
    else{
        ans=atan2(( double)(a*b*b),( double)(2.0000000*x));
    }
    ans=ans*(360.0000000/(2.0000000*PI));
    (double)ans;
    printf("%.7lf",ans);
    return 0;
}

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

int main() {
  int a ;
  cin >> a  ;
  int answer =  0;
  if(a/10 >= 1){
    answer += 9;
    if (a/1000 >= 1){
      answer += 900;
        if (a/100000>= 1){answer += 90000;
                     }
        else if ( a/10000>=1){ answer += a- 9999;}}
    else if(a/100>=1){answer += a-99;}
    
              cout << answer << endl;    }
  else {
    cout << a <<endl;}
  
   }




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

using namespace std;

int main() {
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);

    int K;
    scanf("%d", &K);

    long D = max(A, max(B, C));
    long ans = A + B + C - D;
    D = D << K;
    ans += D;

    printf("%ld\n", ans);

    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;

int main()
{
	ll x, y;
	scanf("%lld%lld", &x, &y);
	ll res = 0;
	while(x <= y)
	{
		res++;
		x += x;
	}
	cout << res;
	return 0;            
}

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

int main(){
  bool g[1000][1000];
  int p[2][1000],i,j,h,w,n,t;
  while(scanf("%d%d%d",&h,&w,&n) && (h||w||n)){
    for(i=0;i<h;i++)
      for(j=0;j<w;j++){
	scanf("%d",&t);
	g[i][j]=t?1:0;
	p[i&1][j]=0;
      }

    p[0][0]=n-1;
    for(i=0;i<h;i++)
      for(j=0;j<w;j++){
	t=i&1;
	n=p[t][j];
	if(g[i][j]){
	  p[1-t][j]+=n/2;
	  p[t][j+1]+=n-n/2;
	}else{
	  p[1-t][j]+=n-n/2;
	  p[t][j+1]+=n/2;
	}
	if(n&1)g[i][j]=!g[i][j];
	p[t][j]=0;
      }

    i=j=0;
    while(i<h && j<w)g[i][j]?j++:i++;
    printf("%d %d\n",i+1,j+1);
  }
}

Measured memory_bytes: 1748
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
	long long a = rng();
    return a;
}
int n, v[500002], sxor[500002];
struct xorin
{
    int poz, val;
};
xorin v2[500002];
bool cmp(xorin a, xorin b)
{
    if(a.val == b.val)
        return a.poz < b.poz;
    return a.val < b.val;
}
int pr0[500002];
long long ans = 0;
vector<int>poz;
void solvedp()
{
    if(sxor[poz[0]] == 0)
    {
        long long a = 1;
        for(int i = 1; i < poz.size(); ++i)
            a = (a * 2) % mod;
        if(poz.back() == n || (sxor[poz.back()] ^ sxor[n]) == sxor[poz[0]])
            ans = (ans + a) % mod;
        return;
    }
    if(poz[0] == n || (sxor[poz[0]] ^ sxor[n]) == sxor[poz[0]])
        ans = (ans + 1) % mod;
    long long sumM = 1, sum0 = 0;
    for(int i = 1; i < poz.size(); ++i){
        int nr0 = pr0[poz[i]] - pr0[poz[i-1]];
        sum0 = (sum0 + 1LL * nr0 * sumM) % mod;
        if(poz.back() == n || (sxor[poz[i]] ^ sxor[n]) == sxor[poz[0]])
            ans = (ans + sum0 + 1) % mod;
        sumM = (sumM + sum0 + 1) % mod;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    for(int i = 1; i <= n; ++i){
        sxor[i] = sxor[i-1] ^ v[i];
        v2[i] = {i, sxor[i]};
    }
    if(sxor[n] != 0)
    {
        ans = 0;
        long long aa = 1, bb = 0;
        for(int i = 1; i <= n; ++i){
            long long x, y;
            x = aa, y = bb;
            if(sxor[i] == sxor[n])
                y += aa;
            if(sxor[i] == 0)
                x += bb;
            aa = x % mod, bb = y % mod;
        }
        cout << aa << '\n';
        return 0;
    }
    sort(v2 + 1, v2 + n + 1, cmp);
    for(int i = 1; i <= n; ++i)
        pr0[i] = pr0[i-1] + (sxor[i] == 0);
    for(int i = 1; i <= n; ++i){
        int j = i;
        poz.clear();
        while(j <= n && v2[i].val == v2[j].val)
            poz.push_back(v2[j].poz), ++j;
        if(sxor[n] == 0 || sxor[n] == v2[i].val)
            solvedp();
        i = j-1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 12276
# -*- coding: utf-8 -*-

from collections import namedtuple

Move = namedtuple('Move', ['fx', 'fy', 'tx', 'ty'])

def make_then_even(cells):
    moves = []
    for i, row in enumerate(cells):
        for j in range(len(row) - 1):
            if row[j] % 2:
                row[j] -= 1
                row[j+1] += 1
                moves.append(Move(i+1, j+1, i+1, j+2))

    w = len(cells[0])
    for i in range(len(cells) - 1):
        if cells[i][-1] % 2:
            cells[i][-1] -= 1
            cells[i+1][-1] += 1
            moves.append(Move(i+1, w, i+2, w))
    return moves

def main():
    h, w = [int(s) for s in input().split()]
    cells = []
    for _ in range(h):
        row = [int(s) for s in input().split()]
        cells.append(row)
    moves = make_then_even(cells)
    print(len(moves))
    for move in moves:
        print(move.fx, move.fy, move.tx, move.ty)

main()


Measured memory_bytes: 29332
#include <bits/stdc++.h>
#include <ext/numeric>
/**
       return NO_PAIN ? NO_GAIN : GAIN;
*/
using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define pow(n, m) power(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

vi dig;
int k;
string s;
ll dp[20002][100][2];
/*
dp[i][modOfDigits][f1];
index of digit, sum of digits mod k,
 state that we are smaller than b.
 */

ll solve(int i, int modDig, int smaller){
    if(i==sz(dig))  return !modDig;

    ll &ret = dp[i][modDig][smaller];
    if(~ret) return ret;

    ll cnt = 0, mxDig = 0;
    if(smaller) mxDig = 9;
    else mxDig = dig[i];

    for(int j = 0; j<=mxDig; j++){
        int sum = modDig + j;
        sum %= k;
        int sm = (j < mxDig || smaller);
        cnt += solve(i+1, sum, sm)%MOD;
        cnt %= MOD;
    }
    return ret = cnt%MOD;
}
ll pos(string s){
    dig.clear();
    for(int i = 0; i<sz(s); i++){
        dig.pb(s[i]-'0');
    }
    mem(dp, -1);

    return solve(0, 0, 0);
}
int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    //freopen("test cases\\out.txt", "w", stdout);
    cin>>s>>k;
    ll ans = pos(s) - 1;
    cout<<(ans>=0? ans: ans + MOD);//1000000006 1
	return 0;
}


Measured memory_bytes: 32764
#include <bits/stdc++.h>
        using namespace std;
        #define ll long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 1000000007
        #define inf 2e18

        int main() {
 
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
            
        ll h,n;
        cin>>n>>h;
        vector<ll> v(n);
        ll sum=0;
        for(ll i=0;i<n;i++){cin>>v[i]; sum+=v[i]; 
        }
        sort(v.begin(),v.end());
        sum=0;
        for(ll i=0; i< n-h; i++)
            sum+=v[i];
        cout<<sum;



        return 0;
        }

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}


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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,m,k;
    cin>>n>>m>>k;
    int a[n+1];
    int b[m+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=m;i++)
        cin>>b[i];
    int ans=0;
    int tot=0;
    int x=0,y=0;
    for(int i=1;i<=m;i++)
    {
        if(tot+b[i]<=k)
        {
            x++;
            tot+=b[i];        
        }
        else
            break;
    }
    int mx=0;
    mx=x;
    for(int i=1;i<=n;i++)
    {
        tot+=a[i];
        if(x>0)
        while (tot>k)
        {
            tot-=b[x--];
            if(x==0)
                break;
        }      
        if(tot<=k)
        {
            mx=max(mx,x+i);
        }  
    }
    cout<<mx;

} 
    


Measured memory_bytes: 6736
class unionFind:
    parent = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.weight = [0]*N

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            p = self.root(self.parent[x])
            self.weight[x] += self.weight[self.parent[x]]
            self.parent[x] = p
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y, w):
        w -= self.getWeight(x)
        w += self.getWeight(y)
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            self.weight[x] = self.weight[y]+w
            return

    def getWeight(self, x):
        x -= 1
        self.root(x)
        return(self.weight[x])


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    G = unionFind(N)
    for i in range(M):
        L, R, D = map(int, input().split())
        if G.same(L, R):
            x = G.getWeight(L)
            y = G.getWeight(R)
            if x == y + D:
                continue
            else:
                print("No")
                exit(0)
        else:
            G.unite(L, R, D)
    print("Yes")


main()


Measured memory_bytes: 9000
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 1000, OO = 1e18 + 100, M = 998244353, P = 6151, SQ = 120, lg = 22;
typedef pair <int, int> pii;
int cnt[100][100];

int32_t main() {
    use_fast;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
    	int a1 = i % 10;
    	int h = i;
    	while(h > 9)
    		h /= 10;
    	cnt[a1][h]++;
	}
	int ans = 0;
	for(int i = 1; i <= 10; i++) {
		for(int j = 1; j <= 10; j++) {
			if(!cnt[i][j] || !cnt[j][i])
				continue;
			if(i == j) {
				ans += (cnt[i][j] * (cnt[i][j] - 1)) + cnt[i][j];
				continue;
			}
			ans += (cnt[i][j] * cnt[j][i]);
		}
	}
	cout << ans << endl;
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

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

int main() {
  string s;
  cin >> s;
  int x = 0;
  for (char c : s) {
    x += (c - '0');
  }
  x %= 9;
  if (x == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <queue>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	
	priority_queue<int> p;
	int t;
	for (int i = 0; i < n; i++) {
		cin >> t;
		
		p.push(t);
	}

	for (int i = 0; i < m; i++) {
		t = p.top() / 2;
		p.pop();
		p.push(t);
	}

	long long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += p.top();
		p.pop();
	}
	cout << sum << endl;

	return 0;
}

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

long long dp[100009], n, a[100009], mod = 1000000007;
bool prime[1000009];

int main() {
	for (int i = 2; i <= 1000004; i++) prime[i] = true;
	for (int i = 2; i <= 1000; i++) {
		for (int j = i*i; j <= 1000000; j += i) prime[j] = false;
	}
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	if (prime[a[1]] == false) {
		cout << "0" << endl;
		return 0;
	}
	a[n + 1] = 1000003;
	dp[1] = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i + 1] > a[i] && prime[a[i + 1]] == true) dp[i + 1] += dp[i];
		if (a[i + 2] > a[i] && prime[a[i + 2]] == true) dp[i + 2] += dp[i];
		dp[i + 1] %= mod; dp[i + 2] %= mod;
	}
	cout << dp[n + 1] << endl;
	return 0;
}


Measured memory_bytes: 5608
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline int read() {
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}

inline void out(int x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
} 
char s[20];
double p=acos(-1);
int main(){
	double r;
	cin>>r;
	printf("%.2f\n",p*2*r);
	return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include<functional>
#include<map>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int max_v = 1003;
int main() {
	int a[3];
	while (cin >> a[0] >> a[1] >> a[2]) {
		sort(a, a + 3);
		cout << a[0] + a[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int m,d,mm,dd;
cin >> m >> d >> mm >> dd;
if(m+1==mm&&dd==1)cout<<1<<endl;
else cout<<0<<endl;
}





Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

#define MAX_V 11000

int V;
vector<int> G[MAX_V]; // グラフの隣接リスト表現
vector<int> rG[MAX_V];// 辺の向きを逆にしたグラフ
vector<int> vs;       // 帰りがけ順の並び
bool used[MAX_V];     // すでに調べたか
int cmp[MAX_V];       // 属する強連結成分のトポロジカル順序

// from から to への辺を張る関数
void add_edge(int from, int to){
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v){
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
	vs.push_back(v);
}

void rdfs(int v, int k){
	used[v] = true;
	cmp[v] = k;
	for(int i = 0; i < rG[v].size(); i++){
		if(!used[rG[v][i]]){
			rdfs(rG[v][i], k);
		}
	}
}

// 強連結成分分解を行う関数、返り値は強連結成分の個数
int scc(){
	memset(used, 0, sizeof(used));
	vs.clear();
	for(int v = 0; v < V; v++){
		if(!used[v]){
			dfs(v);
		}
	}
	memset(used, 0, sizeof(used));
	int k = 0;
	for(int i = vs.size() - 1; i >= 0; i--){
		if(!used[vs[i]]){
			rdfs(vs[i], k++);
		}
	}
	return k;
}

int main(){
	
	while(true){
		
		int n;
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		V = 26;
		for(int i = 0; i < MAX_V; i++){
			G[i].clear();
			rG[i].clear();
		}
		
		string str, str_pre;
		cin >> str_pre;
		
		bool flag = true;
		
		for(int i = 0; i < n - 1; i++){
			cin >> str;
			for(int j = 0; j <= min(str.size(), str_pre.size()); j++){
				if(j == min(str.size(), str_pre.size())){
					if(str.size() < str_pre.size()){
						flag = false;
					}
					break;
				}
				if(str[j] != str_pre[j]){
					add_edge(str_pre[j] - 'a', str[j] - 'a');
					break;
				}
			}
			str_pre = str;
		}
		
		flag &= (scc() == 26);
		
		if(flag){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}
	return 0;
}


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

vector<ll> v;
ll n;

bool check(ll x) {
    string s = to_string(x);
    bool three = false, five = false, seven = false;
    rep(i,s.size()) {
        if(s[i] == '3') {
            three = true;
        }
        if(s[i] == '5') {
            five = true;
        }
        if(s[i] == '7') {
            seven = true;
        }
    }
    if(three == 1 && five == 1 && seven == 1) {
        return true;
    } else {
        return false;
    }
}

void dfs(string s) {
    ll x = stoll(s);
    if(x > n) {
        return;
    } 
    v.push_back(x);
    dfs(s + "3");
    dfs(s + "5");
    dfs(s + "7");
}

int main() {
    scanf("%lld",&n);
    dfs("3");
    dfs("5");
    dfs("7");
    int ans = 0;
    rep(i,v.size()) {
        if(check(v[i])) {
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    cout << (N+M)*(N+M-1)/2 - N * M << endl;
    return 0;
}


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

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define MOD 1000000007

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

    int n;
    cin>>n;
    int a[n],b[n];
    for(int i = 0; i<n; i++){
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    int x,y;
    if(n%2 == 0){
        x = a[n/2-1] + a[n/2];
        y = b[n/2-1] + b[n/2];
    }else{
        x = a[n/2];
        y = b[n/2];
    }
    cout<<y-x+1;
}

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

#define getchar getchar_unlocked

#define INF 1000000000

inline int nextInt(void) {
	int ch;
	int minus, x;

	do {
		ch = getchar();
	} while (ch < '-');

	if (ch == '-') {
		minus = 1;
		ch = getchar();
	} else
		minus = 0;

	x = 0;
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + (ch & 15);
		ch = getchar();
	}

	return minus ? -x : x;
}

typedef struct Edge {
	int to;
	struct Edge *next;
} Edge;

Edge e[100000 * 2], *adj[100000];
int e_size;
int d[100000];
int cnt[100000];
int queue[100000];
int front, rear;

void add(int from, int to) {
	e[e_size] = (Edge){to, adj[from]};
	adj[from] = e + e_size++;
}

int main(void) {
	int n, m;

	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		const int a = nextInt() - 1, b = nextInt() - 1;
		add(a, b);
		add(b, a);
	}
	for (int i = 0; i < n; i++)
		d[i] = INF;

	d[0] = 0;
	queue[rear++] = 0;
	while (front != rear) {
		const int from = queue[front++];
		cnt[d[from]]++;
		for (Edge *p = adj[from]; p; p = p->next) {
			const int to = p->to;
			if (d[to] == INF) {
				d[to] = d[from] + 1;
				queue[rear++] = to;
			} else if (d[to] == d[from]) {
				printf("%lld\n", (long long)n * (n - 1) / 2 - m);
				return 0;
			}
		}
	}

	long long sum[2] = {0};
	for (int i = 0; i < 100000; i++)
		sum[i & 1] += cnt[i];

	printf("%lld\n", sum[0] * sum[1] - m);

	return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
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 Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	int i;
	V a(n);
	V b(n);
	V c(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	for (i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	int ans = 0;
	int zen = -2;
	for (i = 0; i < n; i++) {
		ans += b[a[i]];
		if (a[i] - zen == 1) ans += c[zen];
		zen = a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
/*ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}*/

int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}

 ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; 
   
    if (x == 0) return 0; 
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  
bool isPrime(int n) 
{
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
int main()
{
    fastio;
   
      ll n,c=0,i,mi=0;
      cin>>n;
      ll a[n];
      for(i=0;i<n;i++)
      cin>>a[i];
      
      mi=a[0];
      c=1;
      for(i=1;i<n;i++)
      {
        if(a[i]<mi)
        {
            c++;
            mi=a[i];
        }
      }
      cout<<c<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
};
int main(){
    int n,k,l;
    cin>>n>>k>>l;
    UnionFind uf1(n),uf2(n);
    int x,y;
    rep(i,k){
        scanf("%d%d",&x,&y);
        x--;y--;
        uf1.unite(x, y);
    }
    rep(i,l){
        scanf("%d%d",&x,&y);
        x--;y--;
        uf2.unite(x, y);
    }
    map<pint,int> mp;
    rep(i,n)mp[{uf1.find(i),uf2.find(i)}]++;
    rep(i,n)printf("%d ",mp[{uf1.find(i),uf2.find(i)}]);
    cout<<endl;
   return 0;
}

Measured memory_bytes: 13568
/* 
 Author:N_o_o_B 
 Created:November 23 2019 17:33:56
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    vl a(n);
    fori(i,n) cin >> a[i];
    vl pref = a,suff=a;
    rep(i,1,n-1) pref[i]+=pref[i-1];
    repd(i,n-2,0) suff[i]+=suff[i+1];
    ll ans = INF;
    rep(i,1,n-1) {
        ans = min(ans,abs(pref[i-1]-suff[i]));
    }
    cout << ans << endl;
    time_taken();
    return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    vi a(n);
    double sum = 0;
    rep(i,n) {
        cin >> a[i];
        sum += 1.0 / a[i];
    }
    cout << setprecision(16) << 1.0 / sum << endl;
}

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

int sweep(vector<string> mine,int i, int j,int h,int w) {
	int ans = 0;
	if (mine.at(i).at(j) == '#') return 9;
	//右
	if (j != w - 1) {
		if (mine.at(i).at(j + 1) == '#') ans++;
	}
	//左
	if (j != 0) {
		if (mine.at(i).at(j - 1) == '#') ans++;
	}
	//下
	if (i != h - 1) {
		if (mine.at(i + 1).at(j) == '#') ans++;
	}
	//上
	if (i != 0) {
		if (mine.at(i - 1).at(j) == '#') ans++;
	}
	//右上
	if (j != w - 1&& i != 0) {
		if (mine.at(i - 1).at(j + 1) == '#') ans++;
	}
	//左上
	if (j != 0&& i != 0) {
		if (mine.at(i - 1).at(j - 1) == '#') ans++;
	}
	//左下
	if (i != h - 1 && j != 0) {
		if (mine.at(i + 1).at(j - 1) == '#') ans++;
	}
	//右下
	if (i != h - 1 && j != w - 1) {
		if (mine.at(i + 1).at(j + 1) == '#') ans++;
	}

	return ans;
}
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> mine(h);
	for (int i = 0; i < h; i++) cin >> mine.at(i);
	vector<vector<int>> res(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			res.at(i).at(j) = sweep(mine,i, j,h,w);
		}
	}
	for (int i = 0; i < w; i++) {
		int ans = res.at(0).at(i);
		if (ans == 9) {
			cout << '#';
		}
		else {
			cout << ans;
		}
	}
	for (int i = 1; i < h; i++) {
		cout << endl;
		for (int j = 0; j < w; j++) {
			int ans = res.at(i).at(j);
			if (ans == 9) {
				cout << '#';
			}
			else {
				cout << ans;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fr(i,k,n) for(int i=k;i<n;i++)
#define read(x) cin>>x
#define ll long long int
#define mod 1000000007 
#define print(x) cout<<x<<endl
#define pb(x) push_back(x)
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
int main() { 
    fastIO;
     int t=1,n,k;
     //cin>>t;
     while(t--){
         cin>>n>>k;
       vector<vector<unsigned ll>>dp(n+1,vector<unsigned ll>(k+1,0));  
       int a[100000];
       a[0]=-1;
       vector<unsigned ll>fake(k+1,0);
       fr(i,1,n+1){ 
       cin>>a[i];}
       fr(i,0,a[1]+1){
       dp[1][i]=1;}
      fr(i,2,n+1)
      { vector<unsigned ll>fake(k+1,0);
     fr(j,0,k+1){
       if(j>=0)
        fake[j ]+=dp[i-1][j];
        
     int  r=min(k,a[i]+j);
       if(r<k)
         fake[r+1]-=  dp[i-1][j];
      }  
       unsigned ll prefix_sum=0;
       fr(j,0,k+1){
         prefix_sum+=fake[j];
         dp[i][j]+=prefix_sum;
         dp[i][j]=dp[i][j]% mod;
       } }
      cout<<dp[n][k] % mod<<endl;    
         }
	return 0;
}


Measured memory_bytes: 81908
#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; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    set<int> s;
    rep(i, n) {
        int d; cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
  int n,c=0;
  while(cin>>n,n){
    int a[4],min=1000000,sum=0,ans[4];
    for(int i=0;i<4;i++)cin>>a[i],sum+=a[i];
    for(int i=0;i<=a[0];i++)
      for(int j=0;j<=a[1];j++)
	for(int k=0;k<=a[2];k++)
	  for(int l=0;l<=a[3];l++){
	    int sum2=sum;
	    if(n<=10*i+50*j+100*k+500*l){
	      sum2-=(i+j+k+l);
	      int sa=(10*i+50*j+100*k+500*l)-n;
	      sum2+=sa/500,sa%=500;
	      sum2+=sa/100,sa%=100;
	      sum2+=sa/50,sa%=50;
	      sum2+=sa/10;
	      if(min>sum2){
		min=sum2;
		ans[0]=i,ans[1]=j,ans[2]=k,ans[3]=l;
	      }
	    }
	  }
    if(c!=0)cout<<endl;
    for(int i=0;i<4;i++){
      if(ans[i]!=0){
	if(i==0)cout<<"10"<<" ";
	if(i==1)cout<<"50"<<" ";
	if(i==2)cout<<"100"<<" ";
	if(i==3)cout<<"500"<<" ";
	cout<<ans[i]<<endl;
      }
    }
    c=1;
  }
  return 0;
}

Measured memory_bytes: 2984
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean a = false;
        boolean b = false;
        boolean c = false;
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == 'a') {
                a = true;
            } else if (s.charAt(i) == 'b') {
                b = true;
            } else if (s.charAt(i) == 'c') {
                c = true;
            }
        }
        if (a && b && c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define input_vector(v,n) for(long long i=0;i<n;i++){cin>>v[i];}
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
 ll n,k;
 cin>>n>>k;
 vector<ll> v(n);
 input_vector(v,n);
 vector<ll> dp(n);
 dp[0]=0;
 for(ll i=1;i<n;i++){
 	dp[i]=dp[i-1]+abs(v[i-1]-v[i]);
	for(int j=2;j<=k && i-j>=0;j++){
		dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
	}
}
 cout<<dp[n-1]<<endl;
 return 0;
}



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


using namespace std;
using ll = long long;
using ld = long double;


const ll mod = 998244353ll;

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

    int n; cin >> n;
    vector<int> b(n + 1);

    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }

    int last = 0;
    vector<int> ans;
    for (int j = 0; j < n; ++j) {
        int t = -1;
        for (int i = 1; i < b.size(); ++i) {
            if (b[i] == i) {
                t = i;
            }
        }
        if (t == -1) {
            cout << -1;
            return 0;
        }
        ans.emplace_back(t);
        b.erase(b.begin() + t);
    }

    if (b.size() == 1) {
        for (int i = n - 1; i >= 0; --i) {
            cout << ans[i] << "\n";
        }
    }
    else {
        cout << -1;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;

signed main(){
	int n, wt;
	cin>>n>>wt;
	
	int w[n], v[n];
	for(int i=1; i<=n; i++){
		cin>>w[i]>>v[i];
	}
	
	int dp[n+1][wt+1];
	
	for(int i=0; i<=n; i++){
		dp[i][0]=0;
	}
	
	for(int i=0; i<=wt; i++){
		dp[0][i]=0;
	}
	
	for(int i=1; i<=n; i++){
		for(int j=1; j<=wt; j++){
			if(w[i]>j) dp[i][j]=dp[i-1][j];
			else dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
		}
	}
	
	cout<<dp[n][wt];
	
    return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=2e5+5;
struct Edge{
	int to,ne;
}e[N<<1];
int h[N],cnt,son[N],siz[N],maxn[N],ans[N],d[N],n;
void add(int x,int y){
	e[++cnt]=(Edge){y,h[x]};
	h[x]=cnt;
}
void calc(int x,int fa,int val){
	son[x]=1;
	for(int i=h[x];i;i=e[i].ne){
		int y=e[i].to;
		if(y==fa||y>val)continue;
		calc(y,x,val);
		son[x]+=son[y];
	}
}
void dfs1(int x,int fa){
	maxn[x]=max(maxn[fa],x);siz[x]=1;
	for(int i=h[x];i;i=e[i].ne){
		int y=e[i].to;
		if(y==fa)continue;
		dfs1(y,x);siz[x]+=siz[y];d[x]+=d[y];
	}
	if(maxn[x]==x)calc(x,fa,maxn[fa]),d[x]=-siz[x];
	if(maxn[fa]==fa)d[x]+=siz[x];
}
void dfs2(int x,int fa){
	if(fa){
		if(maxn[x]==x)ans[x]+=son[x];
		else if(maxn[fa]==fa)ans[x]-=son[x],ans[x]+=d[x];
		ans[x]+=ans[fa];
	}
	for(int i=h[x];i;i=e[i].ne){
		int y=e[i].to;
		if(y!=fa)dfs2(y,x);
	}
}
signed main(){
	n=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		add(x,y),add(y,x);
	}dfs1(1,0);dfs2(1,0);
	for(int i=2;i<=n;i++)cout<<ans[i]<<' ';
	return signed();
}

Measured memory_bytes: 26088
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main(int argc, const char * argv[]) {
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    std::cout << std::fixed;
    double s = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    cout << setprecision(8) << s <<endl;
    return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;

  bool ok = false;
  string ans = S;

  reverse(ans.begin(), ans.end());
  reverse(T.begin(), T.end());

  rep(i, ans.size() - T.size() + 1) {
    bool flag = false;
    rep(j, T.size()) {
      if (ans[i + j] != T[j] && ans[i + j] != '?')
        break;
      if (j == T.size() - 1)
        flag = true;
    }
    if (flag) {
      rep(j, T.size()) {
        ans[i + j] = T[j];
      }
      rep(i, ans.size()) {
        if (ans[i] == '?')
          ans[i] = 'a';
      }
      ok = true;
      break;
    }
  }

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

  if (ok) {
    cout << ans << endl;
  } else
    puts("UNRESTORABLE");
}

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

#define ll long long
using namespace std;

int main()
{
	ll s, c;
	cin >> s >> c;
	
	ll ans = 0;
	ll t = c / 2;
	
	if (s > t) {
		cout << t;
		return 0;
	}
	else {
		ans += s;
		c -= (s * 2);
		ans += (c / 4);
	}
	
	
	cout << ans;
	return 0;
}


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

using namespace std;

int main() {
	string s; cin >> s;
	int pay = 700;

	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o') pay += 100;
	}

	cout << pay << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		sc.close();

		for (int i = 0; i < S.length(); i++) {
			String S1 = S.substring(0, S.length() - 1);
			String S2 = S.substring(S.length() - 1);
			S = S2 + S1;
			if (S.equals(T)) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21844