akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<cmath>

constexpr int N = 13;
constexpr long MOD = 1000000007LL;
int main(void)
{
	std::string s;
	std::cin >> s;
	
	std::vector<std::vector<uint64_t>> dp(s.length() + 1, std::vector<uint64_t>(N));
	dp[0][0] = 1;

	int idx = 1;
	for (int i=0 ; i < s.length(); i++) {
		if (s[i] == '?') {
			for (int j=0; j < 10; j++) {
				for (int k=0; k < N; k++) {
					dp[idx][(k * 10 + j) % 13] += dp[idx - 1][k];
					dp[idx][(k * 10 + j) % 13] %= MOD;
				}
			}
		}
		else {
			for (int k=0; k < N; k++) {
				int val = static_cast<int>(s[i] - '0');

				dp[idx][(k * 10 + val) % 13] += dp[idx - 1][k];
				dp[idx][(k * 10 + val) % 13] %= MOD;
			}
		}

		idx++;
	}

	std::cout << dp[idx - 1][5] << std::endl;

	return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	vector<int> A(N),B(N),C(N-1);
	int i;
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	for (i=0;i<N;i++){
		cin>>B[i];
	}
	for (i=0;i<N-1;i++){
		cin>>C[i];
	}
	int ans=0;
	for (i=0;i<N;i++){
		ans+=B[A[i]-1];
		if (i>0){
			if (A[i]==A[i-1]+1){
				ans+=C[A[i-1]-1];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
#include<string.h>
char x[201][101],y[201][101];
int main(void)
{
	int i,l,n,m;
	char s[201];
	scanf("%s",s);
	m=0;
	n=0;
	l=strlen(s);
	n=strlen(s);
	while(1){	
		if(m==1 || n==1) break;
		if(n%2==0 && n!=l){
			for(i=0;i<n/2;i++){
				x[n][i]=s[i];
				y[n][i]=s[n/2+i];
			}
			if(strcmp(x[n],y[n])==0){
				printf("%d\n",n);
				m=1;
			}
		}
		n--;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int A;
  double sum_A = 0;
  for(int i=0; i<N; i++){
    cin >> A;
    sum_A += 1.0/A;
  }
  cout << 1.0/sum_A << endl;
  return 0;
}

Measured memory_bytes: 256
#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() {
  int n;
  ll x;
  cin >> n >> x;
  vector<ll> a(n + 10);
  rep(i, n) cin >> a[i];
  ll cnt = 0;
  for (int i = 0; i < n; i += 2) {
    if (a[i] > x) {
      cnt += a[i] - x;
      a[i] -= a[i] - x;
      // cout << a[i] << endl;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i + 1 > n) continue;
    if (a[i] + a[i + 1] > x) {
      cnt += a[i] + a[i + 1] - x;
      a[i + 1] = x - a[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
    long long K, A, B;
    cin >> K >> A >> B;
    long long ret = 1; // number of biscuit
 
    if (
        B-A > 2 // 錬金したほうが得
        || K < A - 1 + 2// 錬金できるか　A枚のビスケット, -1 最初の一枚, +2 錬金に必要な回数
    ) {
        // A になるまでたたく
        K -= (A - 1);
        ret = A;
        
        // 回数限度まで錬金する
        int num = K / 2; // 錬金回数  a b a
        K -= num * 2; // 錬金後の残回数
        ret += num * (B - A);
 
        // 最後の調整
        ret += K;
    } else { // たたいた方が得
        ret += K;
    }
 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3528
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[][] a=new int[s[1]][];
		int[] h=new int[s[0]+1];
		HashSet<int>[] hs=new HashSet<int>[s[0]+1];
		Dictionary<int,List<int>>[] hl=new Dictionary<int,List<int>>[s[0]+1];
		List<int[]>[] li=new List<int[]>[s[0]+1];
		for(int i=1;i<=s[0];i++){
			li[i]=new List<int[]>();
			hs[i]=new HashSet<int>();
			h[i]=int.MaxValue;
			hl[i]=new Dictionary<int,List<int>>();
		}
		h[1]=0;
		for(int i=0;i<s[1];i++){
			a[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			li[a[i][0]].Add(new int[]{a[i][1],a[i][2]});
			li[a[i][1]].Add(new int[]{a[i][0],a[i][2]});
			if(!hl[a[i][0]].ContainsKey(a[i][2])){hl[a[i][0]].Add(a[i][2],new List<int>());}
			if(!hl[a[i][1]].ContainsKey(a[i][2])){hl[a[i][1]].Add(a[i][2],new List<int>());}
			hl[a[i][0]][a[i][2]].Add(a[i][1]);
			hl[a[i][1]][a[i][2]].Add(a[i][0]);
		}
		for(int i=0;i<li[1].Count;i++){
			hpa(1,li[1][i][0],li[1][i][1]);
			h[li[1][i][0]]=1;
		}
		while(he.Count>0&&hs[s[0]].Count==0){
			if(h[he[0][1]]==he[0][0]){
				if(hs[he[0][1]].Count==0){
					hs[he[0][1]].Add(he[0][2]);
					for(int i=0;i<li[he[0][1]].Count;i++){
						int q=li[he[0][1]][i][1]==he[0][2]?he[0][0]:he[0][0]+1;
						if(h[li[he[0][1]][i][0]]>=q&&(!hs[li[he[0][1]][i][0]].Contains(li[he[0][1]][i][1]))){
							hpa(q,li[he[0][1]][i][0],li[he[0][1]][i][1]);
							h[li[he[0][1]][i][0]]=q;
						}
					}
				}
				else if(!hs[he[0][1]].Contains(he[0][2])){
					hs[he[0][1]].Add(he[0][2]);
					if(hl[he[0][1]][he[0][2]].Count>1){
						for(int i=0;i<hl[he[0][1]][he[0][2]].Count;i++){
							if(h[hl[he[0][1]][he[0][2]][i]]>=he[0][0]&&(!hs[hl[he[0][1]][he[0][2]][i]].Contains(he[0][2]))){
								hpa(he[0][0],hl[he[0][1]][he[0][2]][i],he[0][2]);
								h[hl[he[0][1]][he[0][2]][i]]=he[0][0];
							}
						}
					}
				}
			}
			hpr();
		}
		Console.WriteLine(h[s[0]]==int.MaxValue?-1:h[s[0]]);
	}
	static List<int[]> he=new List<int[]>();
	static void hpa(int a,int b,int c){
		he.Add(new int[]{a,b,c});
		int j=he.Count-1;
		while(he[j][0]<he[(j-1)/2][0]){//
			int v=he[j][0];he[j][0]=he[(j-1)/2][0];he[(j-1)/2][0]=v;
			v=he[j][1];he[j][1]=he[(j-1)/2][1];he[(j-1)/2][1]=v;
			v=he[j][2];he[j][2]=he[(j-1)/2][2];he[(j-1)/2][2]=v;
			j=(j-1)/2;
		}
	}
	static void hpr(){
		he[0]=he[he.Count-1];
		he.RemoveAt(he.Count-1);
		int j=0;
		while(true){
			if(j*2+2<he.Count){
				if(he[j*2+1][0]<he[j*2+2][0]){j=j*2+1;}//
				else{j=j*2+2;}
			}
			else if(j*2+1<he.Count){j=j*2+1;}
			else{break;}
			if(he[j][0]>=he[(j-1)/2][0]){break;}//
			int v=he[j][0];he[j][0]=he[(j-1)/2][0];he[(j-1)/2][0]=v;
			v=he[j][1];he[j][1]=he[(j-1)/2][1];he[(j-1)/2][1]=v;
			v=he[j][2];he[j][2]=he[(j-1)/2][2];he[(j-1)/2][2]=v;
		}
	}
}

Measured memory_bytes: 149340
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   int N;
   cin >> N;
   int A[N];
   for (int i = 0; i < N; i++)
   {
      cin >> A[i];
   }
   sort(A,A+N);
   reverse(A,A+N);
   long long ans = 0;
   int cur = 0;
   for(int i = 1; i<N;i++){
      ans += A[cur];
      if(i%2==1) cur++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 4372
import math
K=int(input())
def gcd(a,b,c):
    s=math.gcd(a,b)
    s=math.gcd(s,c)
    return s
t=0
for a in range(K):
    for b in range(K):
        s=math.gcd(a+1,b+1)
        for c in range(K):
            t+=math.gcd(c+1,s)
print(t)

Measured memory_bytes: 9188
#include<iostream>

using namespace std;

struct d{
  string s;
  int t;
};

int main(){
  int n;
  cin>>n;
  d r[n];
  for(int i=0;i<n;i++){
    cin>>r[i].s>>r[i].t;
  }
  string l;
  cin>>l;
  bool y=false;
  long long ans=0;
  for(int i=0;i<n;i++){
  	if(y){
      ans+=r[i].t;
    }
    if(r[i].s==l){
      y=true;
    }
  }
  cout<<ans;
  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 REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
	int r;
	cin >> r;
	
	cout << 3* r * r << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<int,pair<int,int> > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 100005
typedef long long int ll;
ll dp[100][N];
int main()
{
    int n,W,i,j;
    in2(n,W);
    vi w(n),v(n);
    rep(i,n)
        in2(w[i],v[i]);
    lp(j,w[0],W+1)
        dp[0][j]=v[0];
    lp(i,1,n)
    {
        rep(j,w[i])
            dp[i][j]=dp[i-1][j];
        lp(j,w[i],W+1)
            dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
    }
    outl(dp[n-1][W]);


}


Measured memory_bytes: 78336
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
long long Pow(long long base,long long x){
    const long long mod = (long long)MOD;
    if (x == 0) return 1;
    if (x%2 == 1) return base * Pow(base,x-1) % mod;
    long long y = Pow(base, x/2);
    return y * y % mod;
}

int main(){
    long long m,n; cin >> m >> n;
    cout << Pow(m,n) << endl;
}
  




Measured memory_bytes: 3112
#include <stdio.h>

int main(void){
  int i,n,m,count[1000001],res;
  char s[1000001];
  
  while(scanf("%d",&n),n){
    scanf("%d %s",&m,s);
    
    for(i=0;i<1000001;count[i]=0,i++);
    
    for(i=0,res=0;i<=m;i++)
      if(s[i]=='I' && s[i-1]=='O' && s[i-2]=='I')
        count[i]=count[i-2]+1;
    
    for(i=0,res=0;i<m;i++)if(count[i]>=n)res++;
    
    printf("%d\n",res);
  }
  return 0;
}

Measured memory_bytes: 0
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m

ok = [True]*n

for i in range(m):
    a[i], b[i] = map(int, input().split())

    if h[a[i]-1] <= h[b[i]-1]:
        ok[a[i]-1] = False
    if h[b[i]-1] <= h[a[i]-1]:
        ok[b[i]-1] = False

ans = 0
for i in range(n):
    if ok[i] == True:
        ans += 1

print(ans)


Measured memory_bytes: 21628
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, m;
bool broken[100005];
long dp[100005];
const long MOD = 1000000007;

int main(){
	scanf("%ld%ld", &n, &m);
	for(int i = 0; i < m; i++){
		long a;
		scanf("%ld", &a);
		broken[a] = true;
	}
	dp[0] = 1;
	for(int i = 1; i <= n; i++){
		if(!broken[i-1]){
			dp[i] += dp[i-1];
		}
		if(i >= 2 && !broken[i-2]){
			dp[i] += dp[i-2];
		}
		dp[i] %= MOD;
	}
	printf("%ld\n", dp[n]);
}


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

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(6 <= a && a <= 12){
        cout << b/2 << endl;
    }else if(a >= 13){
        cout << b << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#a,b,c = list(map(int,input().split()))

s = input().rstrip()
t = input().rstrip()

best = 99999999

for i in range(len(s) - len(t) + 1):
  tmp = 0
  for j in range(len(t)):
    if t[j] != s[j+i]:
      tmp += 1
  best = min(best,tmp)
  
print(best)

Measured memory_bytes: 67472
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	x := make([][][2]int, n)
	for i := 0; i < n; i++ {
		a := iScan()
		x[i] = make([][2]int, a)
		for j := 0; j < a; j++ {
			x[i][j] = [2]int{iScan() - 1, iScan()}
		}
	}
	ans := 0
	for i := 0; i < (1 << uint(n)); i++ {
		f := true
		for j := 0; j < n; j++ {
			if (i>>uint(j))&1 == 1 {
				for _, v := range x[j] {
					if (i>>uint(v[0]))&1 != v[1] {
						f = false
					}
				}
			}
		}
		if f {
			ans = larger(ans, bits.OnesCount(uint(i)))
		}
	}
	fmt.Println(ans)
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int int64_t
#define ll long long
#define abs(a) llabs(a)
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

signed main(){

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

    int n,a=10,b=5,cnt,ans=0;
    cin>>n;

    if(n%2!=0){
        cout<<0<<'\n';
    }else{
        while(a <= n){
            ans += (n/a);
            a *= b;
        }
        cout<<ans<<'\n';
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,n) for(int i=0;i<n;i++)
char ca;
const int MOD = 1000000007;
ll  c, d = 0, e,n, i, j, k, h, w,  o,a[100005],b[10000];
queue<ll> q;
string s;
pair<ll, ll> p[20][20];
vector<ll> v;
const int MAX = 2005;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		for (j = 1; j <= a[i]; j++) cin >> p[i][j].first >> p[i][j].second;
	}
	k = (1 <<n);
	rep(i, k) {
		o = 0;
		rep(j, n) {
			if (i & (1 << j)) {
				b[j + 1] = 1;
				o++;
			}
			else b[j + 1] = 0;
			//cout << b[j+1];
		}
		//cout << "\n";
		for (j = 1; j <= n; j++) {
			for (w = 1; w <= a[j]; w++) {		
				if (b[j]==1 && (p[j][w].second != b[p[j][w].first]))
					o = 0; 
				//cout << b[j] << " " << p[j][w].second << " " << b[p[j][w].first] << " " << o << "\n";
			}
		}
		d = max(d, o);
	}

	cout << d;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	int ans=0;
	cin>>s;
	for(int i=0;i<=3;i++)
	{
		t=s[i];
		if(t=="+")
			ans++;
		else if(t=="-")
			ans--;
		
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<thread>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

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

	map<string, int> mp;
	ll ans = 0;

	for (int i = 0; i < N; ++i)
	{
		string S;
		cin >> S;

		vector<char> lst;
		for (auto c : S) { lst.emplace_back(c); }
		sort(lst.begin(), lst.end());

		for (int i = 0; i < 10; ++i)
		{
			S[i] = lst[i];
		}

		ans += mp[S];
		mp[S]++;
	}

	cout << ans << endl;

	return 0;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


int dp[1001][20001];

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int h, n; cin >> h >> n;
  vi a(n), b(n);

  rep(i, n) cin >> a[i] >> b[i];
  rep(i, 1001) rep(j, 20001) dp[i][j] = inf;

  dp[0][0] = 0;
  rep(i, n) rep(j, 20001) {
    if (j - a[i] >= 0) {
      chmin(dp[i+1][j], dp[i][j - a[i]] + b[i]);
      chmin(dp[i][j], dp[i][j - a[i]] + b[i]);
    }
    chmin(dp[i+1][j], dp[i][j]);
  }

  int ans = inf;
  rep2(i, h, 20000) chmin(ans, dp[n][i]);

  cout << ans << endl;
}


Measured memory_bytes: 81760
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
HashMap<String,Integer> U=new HashMap<>();
String[] s=new String[n];
for(int i=0;i<n;i++){s[i]=sc.next();U.put(s[i],0);}
int m=Integer.parseInt(sc.next());
String[] t=new String[m];
for(int i=0;i<m;i++){t[i]=sc.next();U.put(t[i],0);}
for(int i=0;i<n;i++){
    int c=U.get(s[i]);
    c++;
    U.put(s[i],c);
}
for(int i=0;i<m;i++){
    int c=U.get(t[i]);
    c--;
    U.put(t[i],c);
}
int max=0;
for(String str:U.keySet()){
max=Math.max(max,U.get(str));
}
System.out.println(max);
}}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
static const int MAX_V = 100000;

//Graph Element
struct E {
	E(int t, int f) {
		to = t;
		from = f;
	}
	E(int t, int f, int c) {
		to = t;
		from = f;
		cost = c;
	}
	int to;
	int from;
	int cost;
	bool visited;
	bool use;
};
struct V {
	vector<E*> edge;
	bool visited;
};
V G[MAX_V];
/////////////////////////////////////////////

//dfs
int ans = 0;
int VS, ES;
void dfs(int n) {
	rep(i, 0, G[n].edge.size()) {
		if (G[n].edge[i]->use && !G[G[n].edge[i]->to].visited) {
			G[G[n].edge[i]->to].visited = true;
			dfs(G[n].edge[i]->to);
		}
	}
}

//
void bfs(int n) {
	int q[10000] = {};
	int s = 0, e = 0;
	q[e++] = n;
	int c = 0;

	while (s < e) {
		c = q[s++];
		G[c].visited = true;

		rep(i, 0, G[c].edge.size()) {
			if (G[c].edge[i]->use && !G[G[c].edge[i]->to].visited) {
				q[e++] = G[c].edge[i]->to;
			}
		}
	}

	//rep(i, 0, G[n].edge.size()) {
		//	if (G[n].edge[i]->use && !G[G[n].edge[i]->to].visited) {
		//		G[G[n].edge[i]->to].visited = true;
		//		dfs(G[n].edge[i]->to);
		//	}
		//}
}

int main() {
	cin >> VS >> ES;

	rep(i, 0, ES)
	{
		int s, t; cin >> s >> t;
		G[s].edge.push_back(new E(t, s));
		G[t].edge.push_back(new E(s, t));
	}

	///////////////////////////////////////////////////////////
	//DFS
	//Edge all false
	repe(i, 1, VS) rep(j, 0, G[i].edge.size()) {
		//Edge all visited false;
		repe(k, 1, VS) rep(l, 0, G[k].edge.size()) G[k].edge[l]->use = true;
		repe(k, 1, VS) G[k].visited = false;

		G[i].edge[j]->use = false;

		//DFS
		G[1].visited = true;
		//dfs(1);
		bfs(1);

		bool ok = true;
		repe(k, 1, VS)  ok &= G[k].visited;
		if (!ok)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>


int main(){


int H,W,i,j;
while(1){
scanf("%d %d",&H,&W);
if (H == 0 && W == 0)break;

for (i = 0;i < H;i++){
for (j = 0;j < W;j++){
if ((j + i) % 2 == 0){printf("#");}else{printf(".");}

}
printf("\n");

}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
import java.util.Scanner;



public class Main {
	final int N = 12;
	final int[][] ofs = {
			{1, 0}, {0,-1}, {-1, 0}, {0, 1}
	};
	void del(boolean[][] map, int y, int x){
		map[y][x] = false;
		for(int i=0; i<4; ++i){
			int nx = x + ofs[i][0];
			int ny = y + ofs[i][1];
			if(0<=ny && ny<N && 0<=nx && nx<N){
				if(map[ny][nx]){
					del(map, ny, nx);
				}
			}
		}
	}
	
	int solve(boolean map[][]){
		int c = 0;
		
		for(int y=0; y<N; ++y){
			for(int x=0; x<N; ++x){
				if(map[y][x]){
					c++;
					del(map, y, x);
				}
			}
		}
		
		return c;
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[][] str = new char[N][N];
			for(int i=0; i<N; ++i){
				str[i] = sc.nextLine().toCharArray();
			}
			
			boolean[][] map = new boolean[N][N];
			for(int y=0; y<N; ++y){
				for(int x=0; x<N; ++x){
					map[y][x] = str[y][x]=='1';
				}
			}
			
			System.out.println(solve(map));
			sc.nextLine();//から読み
		}
	}
	
	public static void main(String[] args) {
		new Main().io();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const int INF=1000000;
int main() {
	int dp[101][101]={};
	for(int i=0;i<101;++i){
		for(int j=0;j<101;++j){
			dp[i][j]=INF;
		}
	}
	int n,m,a[1001],b[1001],c[1001];
	cin>>n>>m;
	for(int i=0;i<m;++i){
		cin>>a[i]>>b[i]>>c[i];
		dp[a[i]][b[i]]=c[i];
		dp[b[i]][a[i]]=c[i];
	}
	bool flag=true;
	while(flag){
		flag=false;
		for(int i=1;i<n+1;++i){
			for(int j=1;j<n+1;++j){
				for(int k=1;k<n+1;++k){
					if(dp[i][j]>dp[i][k]+dp[k][j]){
						flag=true;
						dp[i][j]=dp[i][k]+dp[k][j];
					}

				}
			}
		}
	}
	int r=0;
	for(int i=0;i<m;++i){
		if(c[i]>dp[a[i]][b[i]])++r;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int min(int m, int x) {
   if (m > x) {
      m = x;
   }
   return m;
}

int main() {
   int i, j, r, n, c, k, l;
   int m[200][200];
   int x[200];

   scanf("%d", &n);

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

   for (k = 2; k <= n; k++) {
      for (i = 0; i <= n - k + 1; i++) {
         j = i + k - 1;
         m[i][j] = 10000000;
         for (l = i; l <= j - 1; l++) {
            m[i][j] = min(m[i][j], m[i][l] + m[l + 1][j] + x[i - 1] * x[l] * x[j]);
         }
      }
   }
   printf ("%d\n", m[1][n]);

   return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  bool t = 1;
  for(int i = 0;i<50000;i++){
    double p = i*1.08;
    int q = p;
    if(q == N){
      cout << i << endl;
      t = 0;
      break;
    }
  }
  if(t == 1){
    cout << ":(" << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<queue>
using namespace std;
int main()
{
  int n,m,i;
  long long t,res=0;
  priority_queue<long long> q;
  cin >> n >> m;
  for(i=0;i<n;i++){
    cin >> t;
    q.push(t);
  }
  for(i=0;i<m;i++){
    t=q.top(); q.pop();
    q.push(t/2);
  }
  for(i=0;i<n;i++){
    t=q.top(); q.pop();
    res+=t;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1400
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

int main() {
	int ans=0;

	int n,x,t;
	cin >> n >> x >> t;

	ans=n/x*t;
	if (n%x>0) ans+=t;



	cout << ans << endl;

}


Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(o) {cerr<<#o<<" "<<o<<endl;}
#define DUMPC(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

bool cmp(pii a, pii b) {
	return a.second == b.second ? a.first<b.first : a.second>b.second;
}

signed main() {
	int n; cin >> n;
	vector<pii> a(n);
	REP(i, n)cin >> a[i].first >> a[i].second;
	sort(ALL(a), cmp);
	cout << a[0].first << " " << a[0].second << endl;
	return 0;
}

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


using p=pair<int,int>;
using ll=long long;

int main(){

  int n;
  cin >> n;
  string str;

  int m;
  int e;

  priority_queue<p,vector<p>,less<p>> upque;//(m.e)
  priority_queue<p,vector<p>,less<p>> downque;//(m,e)

  for(int i=0;i<n;i++){
    cin >> str;
    e=0;
    m=0;
    for(int j=0;j<str.length();j++){
      if(str[j]=='('){
        e++;
      }else{
        e--;
        m=min(e,m);
      }
    }

    if(e>0){
      upque.push(make_pair(m,e));
    }else{
      downque.push(make_pair(m-e,-e));
    }
  }



  ll sum=0;
  bool flag = 1;
  p tmp;
  while(!upque.empty()){
    tmp = upque.top();
    upque.pop();

    if(sum+tmp.first<0){
      flag=0;
      break;
    }else{
      sum+=tmp.second;
    }
    
  }
  ll nsum=0;
  while(!downque.empty()){
    if(flag==0) break;

    tmp=downque.top();
    downque.pop();


    if(nsum+tmp.first<0){
      flag=0;
      break;
    }else{
      nsum+=tmp.second;
    }
  }

  if(flag==1 && sum-nsum==0) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 11324
#include <bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
#define M 1000000007
#define boost
#define push_back push
#define pop_back pop
#define fo(i,n)   for (size_t i = 0; i < n; i++)
#define fo1(i,n)   for (size_t i = 1; i <= n; i++)
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}
int price[100001];
int dp[100001];

int cost(int x){
    
    if(x==1)
    return dp[x]=0;

    if(x==2)
   return dp[x]= abs(price[2]-price[1]);

  else{ 
  if(dp[x]!=-1)
  return dp[x];

 else
return dp[x]= std ::min(cost(x-1)+ abs(price[x]-price[x-1]),cost(x-2)+abs(price[x]-price[x-2])) ;
  } 
   
}
//ll T;

int main()
{  
   /* ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
      for(read(T);T;--T)*/
   {
    memset(dp,-1,sizeof(dp));
    int n ; read(n);

    fo1(i,n)
    read(price[i]);

    cout<<cost(n);
   }

return 0;
}

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

using static Input;
class Program
{
    static int N;
    static int[] A;
    static void INPUT()
    {
        N = NextInt();
        A = LineInt();
    }
    static void OUTPUT()
    {
        var ans = Math.Pow(A.Sum(__ => Math.Pow(__, -1)), -1);
        Console.WriteLine(ans);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
        //A = new int[]{ 200 ,200 ,200 };
        A = new int[] { 1000 };
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll h,w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i,h) cin >> s[i];
  vector<vl> cost(h,vl(w,1e9));
  ll def = 0;
  REP(i,h) REP(j,w) if(s[i][j]=='.') def++;
  queue<pll> que;
  que.push(make_pair(0,0));
  cost[0][0] = 1;
  while(!que.empty()){
    pll now = que.front();
    que.pop();
    s[now.first][now.second] = '#';
    if(now.first>0 && s[now.first-1][now.second]=='.'){
      que.push(make_pair(now.first-1,now.second));
      s[now.first-1][now.second] = '#';
      cost[now.first-1][now.second] = cost[now.first][now.second]+1;
    }
    if(now.first<h-1 && s[now.first+1][now.second]=='.'){
      que.push(make_pair(now.first+1,now.second));
      s[now.first+1][now.second] = '#';
      cost[now.first+1][now.second] = cost[now.first][now.second]+1;
    }
    if(now.second>0 && s[now.first][now.second-1]=='.'){
      que.push(make_pair(now.first,now.second-1));
      s[now.first][now.second-1] = '#';
      cost[now.first][now.second-1] = cost[now.first][now.second]+1;
    }
    if(now.second<w-1 && s[now.first][now.second+1]=='.'){
      que.push(make_pair(now.first,now.second+1));
      s[now.first][now.second+1] = '#';
      cost[now.first][now.second+1] = cost[now.first][now.second]+1;
    }
  }
  if(cost[h-1][w-1]==1e9){
    cout << -1 << endl;
    return 0;
  }else{
    cout << def - cost[h-1][w-1] << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int n;
	cin >> n;
	if(n >= 400 && n < 600){
		cout << 8 << endl;
	}else if(n >= 600 && n < 800){
		cout << 7 << endl;
	}else if(n >= 800 && n < 1000){
		cout << 6 << endl;
	}else if(n >= 1000 && n < 1200){
		cout << 5 << endl;
	}else if(n >= 1200 && n < 1400){
		cout << 4 << endl;
	}else if(n >= 1400 && n < 1600){
		cout << 3 << endl;
	}else if(n >= 1600 && n < 1800){
		cout << 2 << endl;
	}else if(n >= 1800 && n < 2000){
		cout << 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;

using namespace std;

int main() 
{   
    ll n; cin >> n;
    ll ans = -1;

    lrep2(i, 1, 1e5) {
        if(i*i <= n) {
            ans = max(ans, i*i);
        }
    }
    cout << ans << endl;
    return 0;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
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)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// vector<vector<int>> data(i, vector<int>(j))
// vector<vector<vector<char>>> data(N, vector<vector<char>>(3, vector<char>(3)))


int main() {
  int n;
  cin >> n;
  ll before_number=2,current_number=1,tmp;
  switch (n) {
    case 0:
    cout << 2 << endl;
    return 0;
    case 1:
    cout << 1 << endl;
    return 0;
  }
  REP(i,1,n){
    tmp = current_number;
    current_number = current_number+before_number;
    before_number = tmp;
  }
  cout << current_number << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
 
    public static void main(String args[]){
    int w,n;
    int[][] Edge;
    int[] Ans;
    Scanner in = new Scanner(System.in);
    String[] s;
 
      
    w = in.nextInt();
    n = in.nextInt();
    Edge = new int[w+1][2];
    Ans = new int[w+1];
    for(int i=1;i<=w;i++)Ans[i] = i;
    for(int i=0;i<n;i++){
        s = in.next().split(",");
        Edge[i][0] = Integer.valueOf(s[0]).intValue();
        Edge[i][1] = Integer.valueOf(s[1]).intValue();
        int h = Ans[Edge[i][0]];
        Ans[Edge[i][0]] = Ans[Edge[i][1]];
        Ans[Edge[i][1]] = h;
    }
     
    for(int i=1;i<=w;i++)System.out.println(Ans[i]);
 
    }
 
 
 
}


Measured memory_bytes: 26212
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//templete
struct pos{
	ll x,y;
};
int main() {
	int N,M;
	cin>>N>>M;
	vint A,B;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	for(int j=0;j<M;j++){
		int b;
		cin>>b;
		B.pb(b);
	}
	sort(A.begin(),A.end(),greater<int>());
	sort(B.begin(),B.end(),greater<int>());
	if(A[0]!=N*M || B[0]!=N*M){
		cout<<0<<endl;
		return 0;
	}
	A.pb(-1);
	B.pb(-1);
	pos now{0,0};
	ll ans=1;
	//ここまでに入れられるマスの数
	ll emp=0;
	for(int i=N*M-1;i>=1;i--){
		//cout<<i<<" "<<emp<<" "<<ans<<endl;
		if(A[now.x+1]==i && B[now.y+1]==i){
			now=pos{now.x+1,now.y+1};
			emp+=now.x+now.y;
			continue;
		}
		if(A[now.x+1]==i){
			now=pos{now.x+1,now.y};
			emp+=now.y;
			ans=ans*(now.y+1)%MOD;
			continue;
		}
		if(B[now.y+1]==i){
			now=pos{now.x,now.y+1};
			emp+=now.x;
			ans=ans*(now.x+1)%MOD;
			continue;
		}
		ans=ans*emp%MOD;
		emp--;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

x = []

for line in sys.stdin.readlines():
    x.append(int(line.strip()))

length = int(x[0])

del x[0]

max = -(10 ** 9)
min =  x[0]

for i in range(1, length):
    sa = x[i] - min

    if sa > max:
        max = sa

    if x[i] < min:
        min = x[i]
   
print max

Measured memory_bytes: 23712
#include<iostream>
#include<set>
using namespace std;
int N,K,d,A;
set<int>S;
main()
{
  cin>>N>>K;
  for(;K--;)
  {
    cin>>d;
    for(;d--;)cin>>A,S.insert(A);
  }
  cout<<N-S.size()<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    rep(i, 9) cin >> s[i];
    cout << s[0] << s[4] << s[8] << endl;
    return 0;
}


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

typedef long long LL;

int n;
LL li[200005];

int main()
{
   scanf("%d",&n);
   LL tot=0LL; 
   for(int i=1;i<=n;i++)
   {
      scanf("%lld",&li[i]);
      li[i]-=(LL)i;
//      tot+=li[i];
   }
   sort(li+1,li+n+1);
   tot=li[n/2];
   LL ans = 0LL;
   for(int i = 1;i<=n;i++)
   {
      ans+=abs(li[i]-tot);
   }
   tot = li[(n/2)+1];
   LL ans2=0LL;
   for(int i=1;i<=n;i++)
   {
      ans2+=abs(li[i]-tot);
   }
   printf("%lld\n",min(ans,ans2));
 	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

void chmax(ll& a,ll b){if(a<b) a = b;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N);
    for(auto& x:A) cin >> x;
    ll inf = 1e18;
    vec<ll> dp(N+1,-inf);
    dp[0] = 1000;
    for(int i=0;i<N;i++){
        chmax(dp[i+1],dp[i]);
        for(int j=i+1;j<N;j++){
            ll n = dp[i]/A[i];
            chmax(dp[j+1],n*A[j]+dp[i]%A[i]);
        }
    }
    cout << *max_element(dp.begin(),dp.end()) << "\n";
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long x = sc.NextLong();
        long k = sc.NextLong();
        long d = sc.NextLong();

        long absX = Math.Abs(x);
        long count = absX / d;

        if (k <= count)
        {
            Console.WriteLine(absX - k * d);
            return;
        }

        x = absX - count * d;
        k = k - count;

        long answer = 0;
        if (k % 2 == 0)
        {
            answer = Math.Abs(x);
        }
        else
        {
            answer = Math.Abs(x - d);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27548
#include<cstdio>
long long a,b,k;
main(){
    scanf("%lld%lld%lld",&k,&a,&b);
    if(k<=a)return puts("1"),0;
    else if(a<=b)return puts("-1"),0;
    else printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
}

Measured memory_bytes: 128
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
 
let ans=readLine()!
let week=["SUN","MON","TUE","WED","THU","FRI","SAT"]
var num=0
for s in week{
  if(ans==s){print(7-num)}
  num+=1
}

Measured memory_bytes: 7868
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<usize> = s.trim().split(' ').map(|x| x.parse().unwrap()).collect();
    println!("{}", if v[0]+v[1] >= v[2] {"Yes"} else {"No"});
}



Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10000000)
import math
 
def main():
    a, b, x = map(int, input().split())
    k = x / (a ** 2)
    if 2 * k > b:
        tan = 2 * (k - b) / a
        print(abs(math.degrees(math.atan(tan))))
    else:
        tan = (b ** 2) / (2 * a * k)
        print(abs(math.degrees(math.atan(tan))))
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_B&lang=jp
//
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

#define NUM 100
#define BLACK 0
#define WHITE 1
#define INF 100000000
#define NIL -1

vector<pair<int,int>> A[NUM];
int V[NUM];
int color[NUM];

void init(){
    for(int i = 0; i < NUM; i++){
        V[i] = INF;
        color[i] = WHITE;
    }
}

int main(void){
    init();

    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int u, k;
        scanf("%d", &u);
        scanf("%d", &k);

        for(int j = 0; j < k; j++){
            int v, c;
            scanf("%d", &v);
            scanf("%d", &c);
            A[u].push_back(make_pair(v, c));
        }
    }

    int next_node = 0;
    V[0] = 0;
    while(1){
        color[next_node] = BLACK;
        for(int i = 0; i < A[next_node].size(); i++){
            int v = A[next_node][i].first;
            int c = A[next_node][i].second;
            V[v] = min(V[v], V[next_node] + c);
        }

        next_node = NIL;
        int min_dist = INF;
        for(int i = 0; i < n; i++){
            if(color[i] == BLACK){
                continue;
            }
            if(V[i] < min_dist){
                min_dist = V[i];
                next_node = i;
            }
        }

        if(next_node == NIL){
            break;
        }
    }
    for(int i = 0; i < n; i++){
        printf("%d %d\n", i, V[i]);
    }
}



Measured memory_bytes: 3268