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

using namespace std;

#define INF 100010001000
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef pair<int, int> P;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) {   //素数判定
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

signed main() {
    int H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    int h = H / 2 + H % 2;
    int w = W / 2 + W % 2;
    if (W % 2 == 1)
        cout << H * (w - 1) + h << endl;
    else
        cout << H * w << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

int line[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin >> k;
cout << line[k-1] <<endl;
return 0;


}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p+q, q+r, r+p});   
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define d double
#define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;

const long long INF = ( 1LL << 59LL );
int n;
int cap;
ll weight[101];
ll value[101];
ll dp[101][100001];

ll solve( int idx, int c ){

    if( c == 0 ) return 0;
    if( c < 0 )  return -INF;
    if( idx < 0 ) return 0; 

    if( dp[idx][c] != -1 ) return dp[idx][c];

    return dp[idx][c] = max( solve( idx-1, c ) , solve( idx-1, c - weight[idx] ) + value[idx] );

}

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

    memset( dp, -1, sizeof dp );

    cin >> n >> cap;
    for(int i=0;i<n;i++) cin >> weight[i] >> value[i];

    cout << solve( n-1, cap ) << endl;

}

Measured memory_bytes: 79232
#include <bits/stdc++.h>  // ver2.2.8
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  if(n==1){cout<<0<<endl;return 0;}
  Vi a(n);
  Vin(a);
  
  Vi b(n);
  
  rep(i,0,n){
    b[a[i]-1] = i;
  }
  Verr(b);
  int ct=0,maxx=0;
  rep(i,0,n-1){
    if(b[i] < b[i+1]) ct++;
    else {
      maxx = max(ct,maxx);
      ct = 0;
    }
  }
  maxx = max(ct,maxx);
  maxx++;
  
  cout << n - maxx << endl;
  return 0;
}

Measured memory_bytes: 3456
#n=int(input())
n,x=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ml=[int(input()) for i in range(n)]
dif=x-sum(ml)
if dif==0:
    ans=n
else:
    ans=n+dif//min(ml)

print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <random>
#include <stack>
#include <ctime>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

long cnt(long k) {
    if (k % 100) return 0;
    return 1 + cnt(k / 100);
}

int main() {
    long d, n;
    cin >> d >> n;
    long c = 0;
    long i = 1;
    while (1) {
        if (cnt(i) == d) {
            c++;
            if (c == n) {
                cout << i << endl;
                return 0;
            }
        }
        i++;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
#define MOD 1000000007
typedef long long ll; 
inline ll quick_pow(ll a, int n)
{
	ll res = 1; 
	while (n)
	{
		if (n & 1)
			res = res * a % MOD; 
		a = a * a % MOD; 
		n >>= 1; 
	}
	return res; 
}
ll dp[25005][405], sum[25005][405]; 
int arr[25005]; 
bool vis[405]; 
int main()
{
	// freopen("ARC100-F.in", "r", stdin); 
	int n, k, m, lp = -1, rp = -1; 
	scanf("%d%d%d", &n, &k, &m); 
	for (int i = 0; i < m; i++)
		scanf("%d", arr + i); 
	bool flg = false; 
	for (int i = 0; i + k <= m; i++)
	{
		memset(vis, false, sizeof(vis)); 
		int cnt = 0; 
		for (int j = 0; j < k; j++)
		{
			cnt += !vis[arr[i + j]];
			vis[arr[i + j]] = true;
		}
		flg |= cnt == k; 
	}
	ll ans = quick_pow(k, n - m) * (n - m + 1) % MOD; 
	if (flg)
	{
		printf("%lld\n", ans);
		return 0; 
	}
	memset(vis, false, sizeof(vis)); 
	for (int i = 0; i < m && -1 == lp; i++)
	{
		if (!vis[arr[i]])
			vis[arr[i]] = true; 
		else
			lp = i; 
	}
	memset(vis, false, sizeof(vis)); 
	for (int i = m - 1; i >= 0 && -1 == rp; i--)
	{
		if (!vis[arr[i]])
			vis[arr[i]] = true; 
		else
			rp = i; 
	}
	for (int i = 1; i < k; i++)
	{
		dp[0][i] = 1; 
		sum[0][i] = i; 
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j < k; j++)
		{
			dp[i][j] = (dp[i - 1][j + 1] * (k - j) + sum[i - 1][j]) % MOD; 
			sum[i][j] = (sum[i][j - 1] + dp[i][j]) % MOD; 
		}
	}
	for (int i = 0; i + m <= n; i++)
	{
		if (~lp)
			(ans -= dp[i][lp] * dp[n - (i + m)][m - rp - 1]) %= MOD; 
		else
		{
			ll cur = 1;
			for (int j = i + m; j - i < k && j <= n; j++)
			{
				(ans -= dp[i][j - i] * (j == n ? 1 : sum[n - j - 1][j - i]) % MOD * cur) %= MOD; 
				cur = cur * (k - j + i) % MOD; 
			}
		}
	}
	printf("%lld\n", (ans + MOD) % MOD);
	return 0; 
}


Measured memory_bytes: 158464
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s1, s2, s3; cin >> s1 >> s2 >> s3;

	printf("%c", toupper(s1[0]));
	printf("%c", toupper(s2[0]));
	printf("%c\n", toupper(s3[0]));

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;

int main() {

	string s;
	cin >> s;

	if (s[0] != s[1] && s[2] != s[1] && s[2] != s[3])cout << "Good" << endl;
	else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# coding: utf-8
import random


class Dice() :

    mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),
            'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1),'CW':(0,2,4,1,3,5)}

    way = ("N","E","W","S","CW","Nop")

    def __init__(self, data):
        self.label = data

    def move(self, data):
        if data == "Nop":
            return
        self.label = [self.label[idx] for idx in self.mask[data]]

    def get_up(self):
        return self.label[0]

    def compare_6sq(self, dice2):
        check = True
        for i in range(6):
            if self.label[i] == dice2.label[i] :
                continue
            else:
                check = False
                break

        return check
    
    def compare_4rot(self, dice2):
        ok = False
        for i in range(4):
            self.move("CW")
            if self.compare_6sq(dice2) :
                ok =True
                break
        return ok
    
    def compare(self,dice2):
        ok = False
        orderway =("Nop","E","N","E","N","E")

        for s in orderway:
            self.move(s)
            if self.compare_4rot(dice2):
                ok = True
                break
        
        return ok
    
    def check_dicelist(self, dicelist):
        
        for tdice in dicelist:
            if self.compare(tdice):
                return True

        if len(dicelist) != 1 and dicelist[0].check_dicelist(dicelist[1:]) :
            return True

        return False
    




def check_alldice(dicelist):
    return dicelist[0].check_dicelist(dicelist[1:])

length = int(input())
dicelist1 = []
for _ in range(length):
    dicelist1.append(Dice(input().split()))

if not(check_alldice(dicelist1)) :
    print ("Yes")
else:
    print ("No")



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

#110_c

def main():
    S = input()
    T = input()

    start = [-1]*26
    goal  = [-1]*26

    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')

        if (start[a] != -1 or goal[b] != -1) and (start[a] != b or goal[b] != a):
            print("No")
            return
        else:
            start[a] = b
            goal[b]  = a
    print("Yes")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	cout<<a-b+1<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define norm(X) ((X) * (X))
using namespace std;
using llong = long long;

llong a, b, c;

int main() {
    cin >> a >> b >> c;

    if (a + b - c <= 0) {
        if (norm(a + b - c) > 4 * a * b) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main() {
  string str;
  cin >> str;
  int len = str.length();
  int win=0;
  for(int i=0;i<len;i++){
    if(str[i]=='o') win++;
  }
  win += 15-len;
  if(win>=8) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll  long long
#define M 1000000007
#define tc int t; cin>>t; while(t--)
#include <cstring>
#include <cmath>

int main(){
	int n;
	cin>>n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	for(int i = 0; i < n; i++){
		string s;
		cin>>s;
		if(s[0] == 'A'){
			ac++;
		}
		else if(s[0] == 'W'){
			wa++;
		}
		else if(s[0] == 'T'){
			tle++;
		}
		else{
			re++;
		}
	}
	cout << "AC" << " x " << ac << endl;
	cout << "WA" << " x " << wa << endl;
	cout << "TLE" << " x " << tle << endl;
	cout << "RE" << " x " << re << endl;
	return 0;
}

Measured memory_bytes: 3196
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::unordered_map<int64_t, size_t> A;

    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A[t]++;
    }

    size_t count = 0;
    size_t r = 0;
    for (auto&& a: A) {
        auto n = a.second;
        count ++;
        if (n != 1) {
            r += n - 1;
        }
    }
    if (r % 2 != 0) {
        count --;
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 4388
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int T = N*A;
    if (T<=B){
      System.out.println(T);
    } else {
      System.out.println(B);
    }      
  }
}

Measured memory_bytes: 23764
N,L = map(int,input().split())
apple = [L+i-1 for i in range(1,N+1,1)]
minapp = 10000
index = 0
for i in range(0,N,1):
    if minapp > abs(apple[i]):
        index = i
        minapp = abs(apple[i])
print(sum(apple)-apple[index])

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int mod(double n)
{
	if (n < 0){
		return (0);
	}
	if (n == 0){
		return (1);
	}
	return (mod(n - 0.0625));
}

int main(void)
{
	double n;
	double r;
	int out[12];
	int i;
	
	while (scanf("%lf", &n), n >= 0.0){
		memset(out, 0, sizeof(out));
		
		if (n >= pow(2.0, 8.0) || !mod(n) == 1){
			printf("NA\n");
		}
		else {
			r = pow(2, 7);
			
			for (i = 0; i < 12; i++){
				if (n >= r){
					out[i] = 1;
					n -= r;
				}
				
				r /= 2;
			}
			
			for (i = 0; i < 12; i++){
				printf("%d", out[i]);
				if (i == 7){
					printf(".");
				}
			}
			puts("");
		}
	}
	
	return (0);
}

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

using namespace std;

#define FOR(i,a,b)  for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n)    FOR(i,0,n)
#define ALL(a)      a.begin(),a.end()
#define vi          vector<int>
#define vvi         vector<vi>
#define P           pair<int,int>
#define vP          vector<P>
#define vvP         vector<vP>

int main(){
    string a;cin>>a;
    string b;cin>>b;
    if(a.length()>b.length()){
        cout<<"GREATER"<<endl;
    }else if(a.length()<b.length()){
        cout<<"LESS"<<endl;
    }else{
        bool done=false;
        REP(i,a.length()){
            if(a[i]>b[i]){
                cout<<"GREATER"<<endl;
                done=true;
                i=a.length();
            }else if(a[i]<b[i]){
                cout<<"LESS"<<endl;
                done=true;
                i=a.length();
            }
        }
        if(done==false){
            cout<<"EQUAL"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

n=ii()
a=ll()
a[0]-=1
for i in range(1,n):
    if(a[i]-1>=a[i-1]):
        a[i]-=1
f=0        
for i in range(1,n):
    if(a[i]<a[i-1]):
        f=1
        break
if f:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 87688
N, K = map(int, input().split())
d=list(map(int,(input().split())))
ans = 0
for i in range(N,100000):
    temp = str(i)
    n_len = len(temp)
    for j in range(n_len):
        if int(temp[j]) in d:
            break
        elif j == n_len-1:
            ans = 1
            break
    if ans == 1:
        print(temp)
        break



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	cin >> n;
	if(n <= 999){
		cout << "ABC";
		return 0;
	}
	cout << "ABD";
	return 0;
}

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

int cnt[5];

int main(){
	int a[3], b[3];
	for(int i=0; i<3; i++){
		cin >> a[i] >> b[i];
		cnt[a[i]]++;
		cnt[b[i]]++;
	}
	int d=0, e=0;
	for(int i=1; i<5; i++){
		if(cnt[i] == 1){
			d++;
		}
		if(cnt[i] == 2){
			e++;
		}
	}
	if(d == 2 && e == 2){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
// const int MOD = 1000000007;

template <typename T>
void __print__(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void __print__(std::ostream &os, const char *del, const char *tail, const Fst &fst,
               const Rst &... rst) {
    os << fst << del;
    __print__(os, del, tail, rst...);
}

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __print__(os, ", ", "\n", __VA_ARGS__);           \
        std::cerr << os.str();                            \
    } while (0)
#else
#define dump(...)
#endif

template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, " ", "\n", fst, rst...);
}

template <typename iter>
void println_(iter bgn, iter end) {
    while (bgn != end) println(*bgn++);
}

template <typename iter>
void print_(iter bgn, iter end) {
    while (bgn != end) {
        std::cout << *bgn++;
        std::cout << (bgn == end ? "\n" : " ");
    }
}

int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
         std::ios::sync_with_stdio(0), 0);

template <typename T>
std::vector<T> ndarray(int n, T v) {
    return std::vector<T>(n, v);
}
template <typename... Args>
auto ndarray(int n, Args... args) {
    auto val = ndarray(args...);
    return std::vector<decltype(val)>(n, move(val));
}

template <typename T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, true : false;
}

template <typename T>
bool umin(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

using namespace std;

int main() {
    int h, w;
    while (cin >> h >> w) {
        int n;
        cin >> n;
        vector<int> a;
        rep(i, n) {
            int x;
            cin >> x;
            rep(j, x) a.push_back(i);
        }
        auto ans = ndarray(h, w, 0);
        rep(i, h) rep(j, w) {
            ans[i][j] = a.back() + 1;
            a.pop_back();
        }
        rep(i, h) {
            if (i & 1) reverse(all(ans[i]));
            print_(all(ans[i]));
        }
    }
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    string W, T;
    cin >> W;
    transform(W.begin(), W.end(), W.begin(), ::toupper);
    int ans = 0;
    while(1){
        cin >> T;
        if(T=="END_OF_TEXT") break;
        if(T[T.length()-1]=='.') T.erase(T.end());
        if(T[0]=='"'){
            T.erase(T.begin());
            T.erase(T.end());
        }
        transform(T.begin(), T.end(), T.begin(), ::toupper);
        if(T==W) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3208
import itertools
import math

num = int(input())
town_list = [[int(item) for item in input().split()] for _ in range(num)]

root_list = list(itertools.permutations(list(range(num))))

length = 0

for root in root_list:
    for i in range(num-1):
        temp_path = root[i:i+2]
        first = temp_path[0]
        second = temp_path[1]

        x_length = town_list[first][0] - town_list[second][0]
        y_length = town_list[first][1] - town_list[second][1]


        length += math.sqrt(x_length**2 + y_length**2)
print(length / len(root_list))


Measured memory_bytes: 7972
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B)
for i in range(N-1):
    if A[i+1] - A[i] == 1:
        ans += C[A[i] - 1]

print(ans)


Measured memory_bytes: 3060
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
last_idx = len(a) - 1
idx = 0
for e in bc:
    b, c = e
    for i in range(b):
        if i + idx > last_idx:
            break
        if a[i + idx] < c:
            a[i + idx] = c
    idx += b

print(sum(a))


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

constexpr int MOD = 1e9 + 7;
using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};
using mint = ModInt<MOD>;

// dp[i][j][k] := i回操作，孤立点j個，左端連結サイズk
mint dp[310][310][310];
int main() {
	int n, m; cin >> n >> m;
	dp[0][n - 1][1] = 1;
	for(int i = 0; i < m; ++i) {
		for(int j = 0; j < n; ++j) {
			for(int k = 1; k <= n; ++k) {
				if(j - 1 >= 0) dp[i + 1][j - 1][k] += dp[i][j][k] * j;
				dp[i + 1][j][k] += dp[i][j][k] * max(0, n - j - k);
				if(n - j >= 0) dp[i + 1][j][n - j] += dp[i][j][k] * k;
			}
		}
	}
	cout << dp[m][0][n] << '\n';
	return 0;
}

Measured memory_bytes: 233088
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  ll d,t,s;
  cin>>d>>t>>s;
  if(t*s>=d){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

int main() {
	fastio();
	
	LL n, k;

	cin >> n >> k;

	vector<LL> a(n);

	for (auto &e : a) {
		cin >> e;
	}

	LL low = 1, high = 1e9, mid = low + (high-low)/2;

	LL ans = (*max_element(a.begin(), a.end()));
	while (low <= high) {
		LL cnt = 0;

		for (LL i = 0; i < n; ++i) {
			cnt += (a[i]+mid-1)/mid - 1;
		}

		if (cnt <= k) {
			ans = mid;
			high = mid-1;
		}
		else {
			low = mid+1;
		}

		mid = low + (high - low)/2;
	}

	cout << ans << "\n";


}

Measured memory_bytes: 4720
# coding: utf-8

class DroppingInk
  def solve
    @area = Array.new(10).map { Array.new(10, 0) }

    while line = gets do
      x, y, size = line.chomp.split(",").map {|s| s.to_i}

      #puts "#{x} #{y} #{size}"
      @area[y][x] += 1
      case size
      when 1 then
        # 小の滴
        drop_s(x, y)
      when 2 then
        # 中の滴
        drop_m(x, y)
      when 3 then
        # 大の滴
        drop_l(x, y)
      end
      #dump
    end
    zero = 0
    max = 0
    @area.each do |a|
      a.each do |b|
        if b == 0 then
          zero += 1
        end
        if max < b then
          max = b
        end
      end
    end

    puts zero
    puts max
  end

  def dump
    @area.each do |a|
      a.each do |b|
        print b, " "
      end
      print "\n"
    end
    print "\n"
  end

  def drop_l(x, y)
    drop_m(x, y)
    if x - 2 >= 0 then
      @area[y][x - 2] += 1
    end
    if x + 2 < 10 then
      @area[y][x + 2] += 1
    end
    if y - 2 >= 0 then
      @area[y - 2][x] += 1
    end
    if y + 2 < 10 then
      @area[y + 2][x] += 1
    end
  end

  def drop_m(x, y)
    drop_s(x, y)
    if (x - 1 >= 0) && (y - 1 >= 0) then
      @area[y - 1][x - 1] += 1
    end
    if (x + 1 < 10) && (y - 1 >= 0) then
      @area[y - 1][x + 1] += 1
    end
    if (x - 1 >= 0) && (y + 1 < 10) then
      @area[y + 1][x - 1] += 1
    end
    if (x + 1 < 10) && (y + 1 < 10) then
      @area[y + 1][x + 1] += 1
    end
  end

  def drop_s(x, y)
    if x - 1 >= 0 then
      @area[y][x - 1] += 1
    end
    if x + 1 < 10 then
      @area[y][x + 1] += 1
    end
    if y - 1 >= 0 then
      @area[y - 1][x] += 1
    end
    if y + 1 < 10 then
      @area[y + 1][x] += 1
    end
  end
end

DroppingInk.new.solve

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

int main(){
  string s;
  int cnt=0;
  cin>>s;
  for(int i=2; i<4; i++){
    if(s[i] == s[i-1] && s[i-2] == s[i]) cnt++;
  }

  cout<<( cnt > 0 ? "Yes" : "No")<<endl;

  return 0;
}


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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> A(N-1);
  for(int i=1; i<N; i++){
    for(int j=i+1; j<=N; j++) A.at(min(abs(j-i), abs(X-i)+1+abs(j-Y))-1)++;
  }
  rep(i, N-1) cout << A.at(i) << endl;
}

Measured memory_bytes: 256
S = str(input())
l = 0
r = 0
ans = 0
tmp = S[0]
if tmp == ">":
    r = 1
else:
    l = 1
for i in range(1,len(S)):
    if tmp == ">" and S[i] == "<":
        ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) * (min(l, r) - 1) / 2
        l = 1
        r = 0
        tmp = S[i]
    else:
        if S[i] == ">":
            r += 1
        else:
            l += 1
        tmp = S[i]
ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) * (min(l, r) - 1) / 2
print(int(ans))

Measured memory_bytes: 4116
// E - Divisible Substring
#include <bits/stdc++.h>
using namespace std;
#define c2d(c) ((c)-'0') // char to digit

int main(){
	int N,P; string S; cin>>N>>P>>S;
	long long total = 0;
	if(10%P == 0){ // P={2,5}
		for(int i=0; i<N; ++i) if(c2d(S[i]) % P == 0) total += i+1;
	}
	else{
		vector<int> cnt(P, 0);
		int r = 0, ten = 1;
		cnt[r]++; // for half-open section
		for(int i=N-1; i>=0; --i){
			// n=count(r), nC2 = {n-1}C2 + {n-1}
			// {n-1} = count(r): previous of count up
			// ∴ total = total + {count of previous of count up}
			r = (r + c2d(S[i])*ten) % P;
			total += cnt[r];
			cnt[r]++;
			ten = ten * 10 % P;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
//
int main(){
    int W,H,N;
    VP V;
    cin>>W>>H>>N;
    FOR(i,0,N){
        int X,Y;
        cin>>X>>Y;
        V.PB(MA(X,Y));
    }
    sort(V.begin(),V.end());
    if(N==1){
        cout<<min(V[0].FI,V[0].SE)<<endl;
        return 0;
    }
    VP mid;
    int now=0;
    while(now<N-1){
        while(now<N-1&&V[now].FI==V[now+1].FI){
            now++; 
        }
        mid.PB(V[now]);
        now++;
        if(now==N-1){
            mid.PB(V[now]);
        }
    }
    VP ans;
    ans.PB(mid.back());
    ROF(i,0,(int)mid.size()){
        if(mid[i].SE>ans.back().SE){
            ans.PB(mid[i]);
        }
    }
    reverse(ans.begin(),ans.end());
    int a=min(ans[0].SE,ans.back().FI);
    FOR(i,0,(int)ans.size()-1){
        a=min(a,ans[i].FI+ans[i+1].SE);
    }
    cout<<a<<endl;
	return 0;
}



Measured memory_bytes: 5104
import java.util.Scanner;

//Kyudo: A Japanese Art of Archery
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int s = 0;
			for(int i=0;i<n/4;i++)s+=sc.nextInt();
			System.out.println(s);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
use std::io;
use std::cmp;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let n = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let a = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let b = iter.next().unwrap().parse::<i32>().ok().unwrap();
	println!("{}", cmp::min(n*a, b));
}

Measured memory_bytes: 4352
def main():
    s = input()
    t = input()

    def rot(s, n):
        return s[n:] + s[:n]

    for i in range(0, len(s)):
        v = rot(s, i)
        if v == t:
            print('Yes')
            return

    print('No')
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
# coding: utf-8
h,w=map(int,input().split())
dic={}
for i in range(h):
    for c in input():
        if c in dic:
            dic[c]=(dic[c]+1)%4
        else:
            dic[c]=1
d=list(dic.values())
if h%2 and w%2:
    if d.count(1)+d.count(3)==1 and d.count(2)<=h//2+w//2:
        print('Yes')
    else:
        print('No')
elif (h%2 and not w%2) or (w%2 and not h%2):
    if not (d.count(1)+d.count(3)>0):
        if h%2:
            if d.count(2)<=w//2 :#and d.count(2)%2==(w//2)%2:
                print('Yes')
            else:
                print('No')
        elif w%2:
            if d.count(2)<=h//2 :#and d.count(2)%2==(h//2)%2:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
else:
    if sum(d)==0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
using namespace std;
signed main()
{
    fast;
    
    int n,i;
    string s,ans;
    cin>>n;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
    	int c = s[i] - 'A';
    	int rem = (c+n)%26;
    	ans.pb('A' + rem);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x[10]={0};
int y[10]={0};
int N;
double dist(int i, int j){
  double dx=x[i]-x[j];
  double dy=y[i]-y[j];
  return pow(dx*dx+dy*dy,0.5);}
 
int main () {
  double answer=0;
  int aaa=1;
  cin >> N ;
  int p[10]={0};
  for (int j = 1; j <= N; j++) {
    cin>>x[j]>>y[j];}
    for (int i = 0; i < N ; i++) {
    p[i]=i+1;}
   do{
     for (int j = 0; j < N-1; j++) {
     answer+=dist(p[j],p[j+1]);}
   }while (next_permutation(p,p+N));
     for (int j = 2; j <= N; j++) {
     aaa*=j;}
    cout << fixed << setprecision(10);
    cout << answer/aaa << endl;
}


Measured memory_bytes: 640
import numpy as np

N, A = map(int, input().split())
xs = np.array(list(map(int, input().split()))) - A

dp = np.zeros((50*50*2+1, N+1), dtype=np.int64)
dp[50*50,0] = 1

for i, x in enumerate(xs):
    dp[:,i+1] = dp[:,i]
    dp[max(0,x):min(len(dp),len(dp)+x),i+1] += dp[max(0,-x):min(len(dp),len(dp)-x),i]

print(dp[50*50,N]-1)

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

using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  int d;
  
  vector<bool> b(N,false);
  
  for(int j = 0; j < K; j++){
      cin >> d;
      vector<int> a(d);
  for(int i = 0; i < d; i++){
      cin >> a.at(i);
      b.at(a.at(i)-1) = true;
      
  }
}
int sum = 0;
for(int i = 0; i < N; i++){
    if(b.at(i) == false)
    sum++;
}
cout << sum << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#define inf 1000000000

using namespace std;

int N, M;
int G[105][105];
int dist[105][105];

int main(void)
{
	cin >> N >> M;
	int a, b, c;
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			G[i][j] = inf;
		}
	}
	for(int i = 0; i < M; i++){
		cin >> a >> b >> c;
		G[a][b] = G[b][a] = c;
	}
	
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			dist[i][j] = G[i][j];
		}
	}
	for(int k = 1; k <= N; k++){
		for(int i = 1; i <= N; i++){
			for(int j = 1; j <= N; j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			if(G[i][j] >= inf) continue;
			if(G[i][j] > dist[i][j]) ans++;
		}
	}
	
	cout << ans/2 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int M, D;
  cin >> M >> D;
  int ans = 0;
  for (int m = 1; m <= M; m++) {
	  for (int d = 1; d <= D; d++) {
		  int d1  = d % 10;
		  int d10 = d / 10;
		  if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) {
			  ans++;
			}
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int main(void)
{int N,A,M,B,j,x,i,k,l,m,flag;
	scanf("%d%d",&N,&M);
	int a[50];
	int b[50];
	int D[50]={0};
	for(i=0;i<=M-1;i++){
		scanf("%d%d",&a[i],&b[i]);}
	for(l=0;l<=N-1;l++){
		for(m=0;m<=M-1;m++){
	if(((l+1)==a[m])||((l+1)==b[m])){
	    D[l]+=1;}
		}}
for(k=0;k<=N-1;k++){
		printf("%d\n",D[k]);}



	return 0;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

vector<PII> G[maxn];

ll dep[maxn];

int size[maxn];

ll ans;

void dfs1(int u,int f){
	size[u]=1;
	for(auto v:G[u])if(v.fi!=f){
		dep[v.fi]=dep[u]+v.se;
		dfs1(v.fi,u);
		size[u]+=size[v.fi];
	}
}

int dfs2(int u,int f){
	for(auto v:G[u])if(v.fi!=f&&size[v.fi]>=(n+1)/2)return dfs2(v.fi,u);
	return u;
}

void Work(){
	dfs1(1,0);
	int x=dfs2(1,0);
	dep[x]=0;
	dfs1(x,0);
	REP(i,1,n)ans+=dep[i];
	ll mn=1e18;dep[x]=1e18;
	for(auto v:G[x]){
		mn=min(mn,(ll)v.se);
		if(size[v.fi]==(n+1)/2){
			mn=v.se;
			break;
		}
	}
	cout<<ans*2-mn<<endl;
}

void Init(){
	read(n);
	REP(i,2,n){
		int x,y,z;
		read(x,y,z);
		G[x].PB(MP(y,z));G[y].PB(MP(x,z));
	}
}

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


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)

inline bool solve(li n, li odd_cnt) {
	if (odd_cnt % 2 == 0) {
		return true;
	}
	return n == 1;
}


int main(void)
{
	li n;
	cin >> n;
	li odd_cnt = 0;
	rep(i, n) {
		li a;
		cin >> a;
		if (a % 2 > 0) {
			odd_cnt++;
		}
	}
	cout << (solve(n, odd_cnt) ? "YES" : "NO") << endl;


	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = input()
    q = I()
    K = LI()
    for k in K:
        d = 0
        m = 0
        dm = 0
        ans = 0
        for i in range(n):
            if i >= k:
                j = i-k
                if s[j] == "D":
                    d -= 1
                    dm -= m
                elif s[j] == "M":
                    m -= 1
            if s[i] == "D":
                d += 1
            elif s[i] == "M":
                m += 1
                dm += d
            elif s[i] == "C":
                ans += dm
        print(ans)
    return


#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 57728
#include <iostream>
#include <algorithm> 
#include <cmath>
//#include <bitset>
//#include <deque>
#include <iterator>
#include <map> 
//#include <queue>
//#include <stack>
#include <string>
#include <vector>
#include <array>
//#include <tuple>
#include <unordered_map>
//#include <unordered_set>

using namespace std;

typedef long long ll;
struct __{__(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}__; 


int C(int a, int b) {
	int ans = 1;
	for (int i = 1; i <= a; ++i) {
		ans *= i;
	}
	for (int i = 1; i <= a - b; ++i) {
		ans /= i;
	}
	for (int i = 1; i <= b; ++i) {
		ans /= i;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	string p = "MARCH";
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	vector<ll> v(5);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 5; ++j) {
			if (s[i][0] == p[j]) {
				v[j]++;
			}
		}
	}
	//for (int i = 0; i < 5; ++i) {
		//cout << v[i] << " ";
	//}
	ll ans = 0;
	for (int i = 0; i < pow(2,5); ++i) {
		int op = 0;
		ll val = 1;
		for (int j = 0; j < 5; ++j) {
			if ((i >> j) & 1) {
				val *=  v[j];
				op++; 
			}
		}
		if (op == 3) {
			ans += val;
		}
	}
	//for (int i = 0; i < 3; ++i) {
		//int ap = 1;
		//for (int j = i; j < 5; ++j) {
			//ap *= C(v[j],1);
		//}
		//ans += ap;
	//}
	cout << ans;
}









Measured memory_bytes: 6348
def main():
    n = int(input())
    a = list(map(int, input().split()))
    n_min, n_max = min(a), max(a)
    ans = []

    if n_min == n_max:
        return 0

    for y in range(n_min, n_max+1):
        cost = 0
        for x in a:
            cost += (x-y)**2
        ans.append(cost)

    return min(ans)


if __name__ == '__main__':
    ans = main()
    print(ans)


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

bool next_candidate(vector<int64_t>& v, int64_t max) {
    for (int64_t i = v.size() - 1; i >= 0; i--) {
        if (v[i] < max) {
            v[i]++;
            for (int64_t j = i + 1; j < v.size(); j++) {
                v[j] = v[i];
            }
            return true;
        }
    }
    return false;
}

int main() {
    int64_t N, M, Q;
    cin >> N >> M >> Q;
    vector<int64_t> a(Q), b(Q), c(Q), d(Q);
    for (int64_t i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    vector<int64_t> A(N, 1);
    int64_t ans = 0;
    do {
        int64_t curr_score = 0;
        for (int64_t i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                curr_score += d[i];
            }
        }
        ans = max(ans, curr_score);
    } while (next_candidate(A, M));

    cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  int satsu = N/1000 * 1000;
//  cout << satsu << endl;
  int koseni = N-satsu;
  if(koseni == 0){
    cout << 0 << endl;
  }else{
    int otsuri = 1000-koseni;
    cout << otsuri << endl;
  }
  return 0;

}


Measured memory_bytes: 3624
#include<iostream>

int main(void){
	int H, W;
	
	while(1){
		std::cin >> H >> W;
		
		if (H == 0 && W ==0) break;
		
		for (int i = 1; i <= H; i++) {
			if (i == 1 || i == H){
				for (int j = 1; j <= W;  j++) {
					std::cout << '#';
				}
				std::cout << std::endl;
			} else {
				for (int j = 1; j <= W;  j++) {
					if (j == 1 || j == W) {
						std::cout << '#';
					} else {
						std::cout << '.';
					}
				}
				std::cout << std::endl;
			}
		}
		std::cout << std::endl;
	}
	
	return 0;
}

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

int main(void){
  int a,b,c;
  int check = 0;
  cin >> a >> b >> c;
  
  if(a == 5 || a == 7)check += a;
  if(b == 5||b == 7)check += b;
  if(c == 5|| c == 7)check += c;
  //cout << check;
  if(check == 17){
    cout << "YES"; 
  }else{
	cout << "NO";
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
 int n;
 cin>>n;
 rep(i,9){
  if(n%(i+1)==0&&n/(i+1)<=9){
  cout<<"Yes"<<endl;
  return 0;
  }
 }
 cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
string s[12]={"Even","Odd"};
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	cout<<s[(a%2)*(b%2)];
	putchar(10);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int a,b;
    cin >>a>>b;
    if(a>b){
        for(int i=0;i<a;i++){
            cout << b <<flush;
        }
    }else if(b>=a){
        for(int i=0;i<b;i++){
            cout << a <<flush;
        }
    }
}

Measured memory_bytes: 256