akhauriyash/Code-Regression huggingface dataset:
def popcnt(n):
    return bin(n).count("1")

n = int(input())
grid = []

for i in range(n):
    p = int(input())
    for j in range(p):
        array = [i] +list(map(int, input().strip().split(' ')))
        array[1] = array[1] - 1
        grid.append(array)


truth = 0
count = 0

for i in range(2**n):
    k = (bin(i)[2:]).zfill(n)
    count = 0
    for j in range(len(grid)):
        if int(k[grid[j][0]]) == 1:
            if (int(k[grid[j][1]]) == 1 and grid[j][2] == 0) or (int(k[grid[j][1]]) == 0 and grid[j][2] == 1):
                count = 1
                break
    if count == 0:
        if truth < popcnt(i):
            truth = popcnt(i)

print(truth)


Measured memory_bytes: 3188
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int x=0;x<k;x++){
    bool ale = true;
    vector<ll> imo(n+1,0);
    for(int i=0;i<n;i++){
      ll pre = i-a[i],nex=i+a[i]+1;
      pre = max(0ll,pre);
      nex = min(nex,n);
      imo[pre] ++;
      imo[nex] --;
    }
    for(int i=1;i<n;i++){
      imo[i] += imo[i-1];
    }
    for(int i=0;i<n;i++){
      if(imo[i]!=n){
        ale= false;
      }
      a[i] = imo[i];
    }
    if(ale) break;
  }
  for(int i=0;i<n;i++){
    cout << a[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 6368
#include <vector>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <limits>

int includes(const std::vector<intmax_t> &x,
             const std::vector<intmax_t> &y, int xi, int xj, int yi, int yj) {

  intmax_t XL=x[xi], XR=x[xj];
  intmax_t YL=y[yi], YR=y[yj];
  if (XL > XR) std::swap(XL, XR);
  if (YL > YR) std::swap(YL, YR);

  int res=0;
  for (size_t i=0; i<x.size(); ++i)
    if (XL <= x[i] && x[i] <= XR && YL <= y[i] && y[i] <= YR) {
      //fprintf(stderr, "%jd, %jd\n", x[i], y[i]);
      ++res;
    }

  ///fprintf(stderr, "%d\n", res);
  return res;
}

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

  std::vector<intmax_t> x(N), y(N);
  for (int i=0; i<N; ++i) {
    scanf("%jd %jd", &x[i], &y[i]);
  }

  intmax_t res=std::numeric_limits<intmax_t>::max();
  for (int xi=0; xi<N; ++xi)
    for (int xj=xi; xj<N; ++xj)
      for (int yi=0; yi<N; ++yi)
        for (int yj=yi; yj<N; ++yj) {
          int cur=includes(x, y, xi, xj, yi, yj);
          if (cur < K) continue;

          res = std::min(res, std::abs(x[xi]-x[xj])*std::abs(y[yi]-y[yj]));
        }

  printf("%jd\n", res);
  return 0;
}


Measured memory_bytes: 256
n=int(input())
d=dict()
for i in range(1,n+1):
  for j in range(1,i+1):
    if j==1:
      continue
    while i%j==0:
      if j not in d:
        d[j]=1
      else:
        d[j]+=1
      i//=j
ans=1
for i in d.values():
  ans*=i+1
print(ans%1000000007)


Measured memory_bytes: 3060
/////////////////////////////////
//                             //
//           /(.^.)\           //
//                             //
/////////////////////////////////

#include <stdio.h>

#define LL long long
#define SD(x) scanf("%d", &(x))

//modは素数
const int mod = 1000000007;
const int N   = 100001;

//n!
int fact[N], invfact[N];

//a+b
inline int add(int a, int b)
{
    a += b;
    if(a >= mod) a -= mod;
    return a;
}

//a-b
inline int sub(int a, int b)
{
    a -= b;
    if(a < 0) a += mod;
    return a;
}

//a*b
inline int mul(int a, int b)
{
    return (((LL) a) * b) % mod;
}

//a^bのかっこいいやつ
inline int pwr(int a, LL b)
{
	int x = 1;
	while(b)
    {
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}

//なんか(m-2)乗したら逆数になるやつ
inline int inv(int a)
{
    return pwr(a, mod - 2);
}

//nCk求めるやつ改
inline int cmbxy(int x, int y)
{
	return mul(fact[x+y], mul(invfact[x], invfact[y]));
}

//n!求めるやつ
void calc_fact()
{
	fact[0] = invfact[0] = 1;
	for(int i = 1;i < N; i++) fact[i] = mul(i, fact[i - 1]);
	invfact[N - 1] = inv(fact[N - 1]);
	for(int i = N - 2; i >= 1; i--) invfact[i] = mul(invfact[i + 1], i + 1);
	
    return;
}



int main()
{
    int n,m;
    int a, aa;
    int retn = 1;

    int x,y;
    int tmp;

    calc_fact();

    SD(n);
    SD(m);

    aa = -1;
    for (int i = 0; i <= m; ++i)
    {
        if (i == m)
        {
            a = n + 1;
        }
        else
        {
            SD(a);
        }

        if (aa == n-1)
        {
            break;
        }

        if (a - aa == 0)
        {
            continue;
        }
        else if ((a - aa == 1))
        {
            retn = 0;
            break;
        }
        else if (a - aa == 2)
        {

        }
        else
        {
            tmp = 0;
            for (x = a - aa - 2, y = 0; x >= 0; x -= 2, ++y)
            {
                tmp += cmbxy(x,y);
                if(tmp >= mod) tmp -= mod;

                /////////////////////
                //printf("%d %d %d\n" ,x,y,tmp);
            }
            retn = (((LL) retn) * tmp) % mod;
        }

        aa = a;
    }
   

    printf("%d" ,retn);

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

template<typename T>
using vec2 = vector<vector<T>>;
template<typename T>
using vec3 = vec2<vector<T>>;
template<typename T>
using vec4 = vec3<vector<T>>;
template<typename T>
using vec5 = vec4<vector<T>>;
template<typename T>
using vec6 = vec5<vector<T>>;

ll extGCD(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    ll g = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return g;
}
ll MOD = 1000000007;

vector<ll> mfact(1,1);

ll minv(ll a){
    ll x;ll y;
    extGCD(a, MOD, x, y);
    if(x<0){
        x+= ((-x)/MOD+1)*MOD;
        x %= MOD;
    }
    return x;
}

ll mpow(ll a,ll b){
    ll res = 1;
    while(b > 0){
        if(b%2==1)res=(res*a)%MOD;
        b/=2;
        a = (a*a)%MOD;
    }
    return res;
}

ll mfactorial(ll a){
    if(mfact.size()-1 >= a)return mfact[a];
    for(ll i = mfact.size();i<=a;i++){
        mfact.push_back((i * mfact[i-1])%MOD);
    }
    return mfact[a];
}

ll mcomb(ll n, ll r){
    return (((mfactorial(n) * minv(mfactorial(r)))%MOD) * minv(mfactorial(n-r)))%MOD;
}
ll ipow(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b % 2 == 1)res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

void factorize(map<ll,ll>& fac, vector<ll>& sieved, ll a){
    while(a != 1){
        if(fac.find(sieved[a]) == fac.end())fac[sieved[a]] = 0;
        fac[sieved[a]]++;
        a/=sieved[a];

    }
}
void primesieve(vector<ll>& res,ll n){
    res = vector<ll>(n+1, -1);
    for(int i = 2;i <= n;i++){
        if(res[i] != -1)continue;
        res[i] = i;
        for(int j = 2;j*i <= n;j++){
            res[j*i] = i;
        }
    }
}
vector<ll> primesuntil(ll n){
    vector<ll> res;
    vector<ll> sieved;
    primesieve(sieved, n);
    for(int i = 2;i <= n;i++){
        if(sieved[i] == i)res.push_back(i);
    }
    return res;
}
int gcd(int a, int b){
    if(b == 0)return a;
    return gcd(b, a%b);
}

int main(){
    ll N;cin>>N;
    ll a = (mpow(10,N) - mpow(8,N)+MOD)%MOD;
    ll b = (mpow(10,N) - mpow(9,N)+MOD)%MOD;
    cout<<(2 * b - a+MOD)%MOD<<endl;
}

Measured memory_bytes: 3628
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
if K == 1:
  print(0)
else:
  print(N-K)

Measured memory_bytes: 21452
// Kevin Mathew T
// Birla Institute of Technology, Mesra
// LinkedIn - https://www.linkedin.com/in/KevinMathewT/
// GitHub - https://github.com/KevinMathewT
// CodeForces - https://codeforces.com/profile/KevinMathew
// CodeChef - https://www.codechef.com/users/KevinMathew
// HackerRank - https://www.hackerrank.com/KevinMathew

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define F first
#define S second
#define fi(a, b) for(ll i=(a);i<=b;i++)
#define fj(a, b) for(ll j=(a);j<=b;j++)
#define fid(a, b) for(ll i=(a);i>=b;i--)
#define fjd(a, b) for(ll j=(a);j>=b;j--)

// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// #include <iostream> 
// using namespace __gnu_pbds; 
// using namespace std; 
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) : Value at kth index in sorted array. 
// order_of_key(k) : Index of the value k.

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    os << "]";
	return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class T> ostream& operator<<(ostream &os, multiset<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, unordered_map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}


const ll N = 1000010, M = 1e9 + 7;
ll n, m, a[N];

void solve(){
	cin >> n >> m;
	swap(n, m);
	fi(0, n - 1) cin >> a[i];
	ll tot = accumulate(a, a + n, 0LL);
	if(tot > m) cout << -1 << '\n';
	else cout << (m - tot) << "\n";
}

int main(){
	//freopen("input.txt", "r", stdin);		//Comment
	//freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	// ll T;
	// cin >> T;
	// while(T--)
		solve();

	return 0;
}

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

int main()
{
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int v = 0;
	for (int i = 0; i < N; ++i) {
		v += i < K ? X : Y;
	}
	cout << v << endl;
	return 0;
}

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


int main()
{

    int a;
    int b;
    int c;

    cin >>a>>b>>c;

    if(c<a||c>b)
    {
        cout<< "No"<<endl;
    }

    else{
        cout<< "Yes"<<endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std ;
int q , len , pos;
long long n;
char op[10] ;
int main() {
    scanf("%d",&q) ;
    while(q--) {
        scanf("%d%s%d",&pos,op,&len) ;
        if(op[0] == '(') n+=len ;
        else n-=len ;
        if(!n) printf("Yes\n") ;
        else printf("No\n") ;
    }
    return 0 ;
}

Measured memory_bytes: 1016
import java.util.*;
import java.math.*;
public class Main {
	static int x;
	static int ans;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k = Integer.parseInt(in.next());
		String s = in.next();
		if(s.length() <= k) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0, k) + "...");
		}
	}
}

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

using ll=int64_t;

int main() {
  int N; cin >>N;
  int hairetsu=1e5+2;
  vector<int> check(hairetsu);
  rep(i,0,N) {
    int a; cin >>a;
    check[a  ]++;
    check[a+1]++;
    check[a+2]++;
  }
  int ans=0;
  rep(i,0,hairetsu) ans=max(ans,check[i]);
  cout <<ans <<endl;
  return 0;
}


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

class ListElement{
public:
  int value;
  int prev;
  int next;

  ListElement(int p1,int p2,int p3):value(p1),prev(p2),next(p3){}
};

class DoublyLinkedList{
public:
  int first;
  int last;
  vector<ListElement> Lists;

  DoublyLinkedList(){
    first = -1;
    last = -1;
  }
  void insert(int x){
    ListElement p(x,-1,first);
    Lists.push_back(p);
    if(first!=-1) Lists[first].prev=Lists.size()-1;
    first = Lists.size()-1;
    if (last == -1) last =Lists.size()-1;
    //   cout <<"insert: "<< &Lists.back()<<endl;
  }
  bool deleteP(int x){
    int tmp=first;
    while(Lists[tmp].value != x && tmp!=last){
      tmp=Lists[tmp].next;
    }
    if (Lists[tmp].value == x){
      if (tmp==first && tmp == last){
	first=-1;
	last=-1;
	return true;
      } else if (tmp==last){
	Lists[Lists[tmp].prev].next=-1;
	last=Lists[tmp].prev;
	return true;
      }else if (tmp==first){
	Lists[Lists[tmp].next].prev=-1;
	first=Lists[tmp].next;
	return true;
      }else {
	Lists[Lists[tmp].prev].next=Lists[tmp].next;
	Lists[Lists[tmp].next].prev=Lists[tmp].prev;
	return true;
      }
    }
    return false;
  }
  void deleteFirst(){
    first=Lists[first].next;
    if (first!=-1)    Lists[first].prev=-1;
  }
  void deleteLast(){
    last=Lists[last].prev;
    if (last!=-1)    Lists[last].next=-1;
  }
  void output(){
    int tmp=first;
    //cout<<"s: "<<Lists.size()<<endl;
    while(tmp!=last){
      //      cout<<"ad: " << tmp << " / value: "<<tmp->value<<endl;
      cout<<Lists[tmp].value<<" ";
      tmp=Lists[tmp].next;
    }
    //    cout<<"ad: "<<tmp<<" / value: "<<tmp->value<<endl;
    if (tmp!=-1)
        cout<<Lists[tmp].value<<endl;
    /*    for(auto b : Lists){
      cout<<b.value<<endl;
    }
    cout<<"first: "<<first<<endl;
    cout<<"vec last "<<&Lists.back()<<endl;
    cout<<"last: "<<last<<endl;
    cout<<"vec first "<<&Lists.front()<<endl;*/
  }
};

int main(void){
  int n;
  cin>>n;
  string s;
  int val;
  DoublyLinkedList LL;
  for(int i=0;i<n;i++){
    cin>>s;
    if (!s.compare("insert")){
      cin>>val;
      LL.insert(val);
    }else if (!s.compare("delete")){
      cin>>val;
      LL.deleteP(val);
    }else if (!s.compare("deleteFirst")){
      LL.deleteFirst();
    }else if (!s.compare("deleteLast")){
      LL.deleteLast();
    }else{
      cout << "Invalid Operation: "<<s<<endl;
    }
  }
  LL.output();
  return 0;
}



Measured memory_bytes: 27480
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    repk(i, 1, n + 1) {
        if (int(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    ABs = [list(map(int, input().split())) for _ in range(n)]
    CDs = [list(map(int, input().split())) for _ in range(m)]

    for AB in ABs:
        thresh = float('inf')
        for i, CD in enumerate(CDs, start=1):
            thresh_temp = abs(AB[0]-CD[0])+abs(AB[1]-CD[1])
            if thresh == thresh_temp:
                continue
            if thresh_temp < thresh:
                ans = i
                thresh = thresh_temp
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int x;
    cin >> x;

    int qtd = 0;

    int maior = 0;
    while (x--) {
        int y;
        cin >> y;
        if (y >= maior) {
            qtd++;
            maior = y;
        }
    }

    cout << qtd << endl;
    
    return 0;
}

Measured memory_bytes: 256
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

const int MAX = 1000001;

struct q {
	int l, r, idx;
};

bool cmp(q x, q y) {
	return x.r < y.r;
}

void update(int idx, int val, int bit[], int n) {
	for (; idx <= n; idx += idx&-idx)
		bit[idx] += val;
}

int query(int idx, int bit[], int n) {
	int sum = 0;
	for (; idx>0; idx-=idx&-idx)
		sum += bit[idx];
	return sum;
}

void answeringQueries(int arr[], int n, q queries[], int q) {
	int bit[n+1];
	memset(bit, 0, sizeof(bit));
	int last_visit[MAX];
	memset(last_visit, -1, sizeof(last_visit));
	int ans[q];
	int query_counter = 0;
	for (int i=0; i<n; i++) {
		if (last_visit[arr[i]] !=-1)
			update (last_visit[arr[i]] + 1, -1, bit, n);
		last_visit[arr[i]] = i;
		update(i + 1, 1, bit, n);
		while (query_counter < q && queries[query_counter].r == i) {
			ans[queries[query_counter].idx] =
				query(queries[query_counter].r + 1, bit, n)-
				query(queries[query_counter].l, bit, n);
			query_counter++;
		}
	}
	for (int i=0; i<q; i++)
		cout << ans[i] << endl;
}
int main() {
	int n, m; cin >> n >> m;
	int a[n];
	for ( int k = 0; k < n; k++ ) cin >> a[k];
	q qs[m];
	for ( int k = 0; k < m; k++ ){
		cin >> qs[k].l >> qs[k].r; qs[k].idx = k;
		qs[k].r--; qs[k].l--;
	}
	sort(qs, qs + m, cmp);
	answeringQueries(a, n, qs, m);
	return 0;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    vector<vector<int> > c(3,vector<int>(3));
    REP(i,3) REP(j,3) cin>>c[i][j];

    bool f=0;
    // REP2(a1,-1000,1000){
        int a1=0;
        int a2,a3,b1,b2,b3;
        b1=c[0][0]-a1;b2=c[0][1]-a1;b3=c[0][2]-a1;
        a2=c[1][0]-b1;
        if(a2!=c[1][1]-b2 || a2!=c[1][2]-b3) f=0;
        else{
            a3=c[2][0]-b1;
            if(a3!=c[2][1]-b2 || a3!=c[2][2]-b3) f=0;
            else f=1;
        }
        // break;
    // }
    cout<<(f? "Yes":"No")<<endl;

	return 0; 
}

Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

dicD = {}
dicT = {}

for d in D:
    if d not in dicD:
        dicD[d] = 0
    dicD[d] += 1

for t in T:
    if t not in dicT:
        dicT[t] = 0
    dicT[t] += 1

for t in dicT:
    if (t not in dicD) or (dicT[t] > dicD[t]):
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 56672
#include <stdio.h>

int main(void)
{
	int b1, b2, b3;
	
	scanf("%d %d %d", &b1, &b2, &b3);
	
	if (b1 == 1 && b2 == 1 || b3 == 1){
		printf("Open\n");
	}
	else {
		printf("Close\n");
	}
	return (0);
}

Measured memory_bytes: 584
#include <stdio.h>

int main(){
  int i,n;
  long m=100000;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    m*=1.05;
    m=((m/1000)+(m%1000!=0))*1000;
  }
  printf("%ld\n",m);
  return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){


  int n,m,in,out,ans;
  
  cin >> n >> m;
    ans=m;
    for(int i=0;i<n;i++){
      cin >> in >> out;
      m=m+in-out;
      if(m<0){
	cout << 0 << endl;
	return 0;
      }
      ans=max(ans,m);
    }
    cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

namespace problem {
    array<array<int, 30>, 30> g, visited;
    int w, h;
    int gx, gy;
    array<int, 4> di{1, -1, 0, 0}, dj{0, 0, -1, 1};
    void dfs(int y, int x, int depth){
        if(depth > 10) return;
        for (int k = 0; k < 4; ++k) {
            int yy = y, xx = x;
            if(g[yy+di[k]][xx+dj[k]]) continue;
            while(!g[yy][xx]){
                visited[yy][xx] = min(visited[yy][xx], depth+1);
                yy += di[k]; xx += dj[k];
            }
            if(g[yy][xx] == 1){
                g[yy][xx] = 0;
                dfs(yy-di[k], xx-dj[k], depth+1);
                g[yy][xx] = 1;
            }
        }
    }
    void solve(int W, int H){
        w = W; h = H;
        for (int i = 0; i <= h+1; ++i) {
            for (int j = 0; j <= w+1; ++j) {
                g[i][j] = -1;
                visited[i][j] = INF<int>;
            }
        }
        int sx, sy;
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                cin >> g[i][j];
                if(g[i][j] == 2) {
                    sy = i, sx = j;
                    g[i][j] = 0;
                }else if(g[i][j] == 3){
                    gy = i, gx = j;
                    g[i][j] = 0;
                }
            }
        }
        dfs(sy, sx, 0);
        cout << (visited[gy][gx] <= 10 ? visited[gy][gx] : -1) << "\n";
    }


}

int main() {
    int w, h;
    while(cin >> w >> h, w){
        problem::solve(w, h);
    }
    return 0;
}


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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int D, T, S;
	cin >> D >> T >> S;
	if (D <= T * S)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3648
# C - Go Home
# 問題URL:http://abc056.contest.atcoder.jp/tasks/arc070_a

import math

X = int(input())
n = int((-1 + math.sqrt(1+8*X)) / 2)
sigma = 0.5 * n*(n+1)

if X != sigma:
    print(n+1)
else:
    print(n)

Measured memory_bytes: 2940
import bisect

N = int(input())
S = input()

C = {0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[]}
for i in range(N):
  C[int(S[i])].append(i)

ans = 0
for i in range(1000):
  a = i//100
  if len(C[a]) == 0:
    continue
  amin = C[a][0]
  b = (i//10)%10
  if len(C[b]) == 0:
    continue
  bi = bisect.bisect_right(C[b], amin)
  if bi == len(C[b]):
    continue
  bmin = C[b][bi]
  c = i%10
  if len(C[c]) == 0:
    continue
  ci = bisect.bisect_right(C[c], bmin)
  if ci < len(C[c]):
    #print(a,b,c)
    ans += 1
print(ans)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> N>>S;

    string S_tmp = S;
    sort(S.begin(), S.end());

    ll E_count, W_count;
    if(S.at(0)=='W'){
        E_count = 0;
        W_count = N;
    }
    else if(S.at(N-1)=='E'){
        E_count = N;
        W_count = 0;
    }
    else{
        REP(i,N-1){
            if(!(S.at(i)==S.at(i+1))){
                E_count = i + 1;
                W_count = N - (i + 1);
                break;
            }
        }
    }
    //cout << E_count << " " << W_count << endl;
    ll count = E_count;
    S = S_tmp;
    if (S.at(0) == 'E')
    {
        count--;
    }
    //cout << count << endl;
    ll ans = MOD;
    REP(i, N-1)
    {
        ans = min(ans, count);
        if(S.at(i)=='W'){
            if (S.at(i+1) == 'W'){
                count++;
            }
        }
        else{
            if(S.at(i+1)=='W'){
            }
            else{
                count--;
            }
        }
        //cout << count << endl;
        ans = min(ans, count);
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    string S;
    cin>>S;
    if(S=="SAT")
    {
        cout<<"1";
    }
    if(S=="MON")
    {
        cout<<"6";
    }
    if(S=="TUE")
    {
        cout<<"5";
    }
    if(S=="WED")
    {
        cout<<"4";
    }
    if(S=="THU")
    {
        cout<<"3";
    }
    if(S=="FRI")
    {
        cout<<"2";
    }
    if(S=="SUN")
    {
        cout<<"7";
    }

    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc116/tasks/abc116_c
N = int(input())
H = list(map(int, input().split()))


def ret_n_miz(ls: list):
    ret = 0  # 水やり回数
    pre = 0  # 水やりが必要なければ0
    for l in ls:
        if pre == 0 and l > 0:
            ret += 1
        pre = l
    return ret


ans = 0
while sum(H) > 0:
    ans += ret_n_miz(H)
    for i in range(N):
        H[i] = max(0, H[i] - 1)

print(ans)


Measured memory_bytes: 67556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ll n, k;
  cin >> n >> k;
  vector<ll> p;
  REP(i,n){
      ll pi;
      cin >> pi;
      p.PB(pi);
  }
  sort(ALL(p));
  cout << accumulate(p.begin(), p.begin() + k, 0LL) << endl;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}
 
LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}

int main(){
  int a,b,h;
  cin >> a >> b >> h;
  
  cout << (a+b)*h/2 << endl;
  
  return 0;
}
  


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
bool chk(int x,int y){
	int z = x^y;
	if((z&(z-1))==0) return 1;
	return 0;
}
void swap(int& x,int i,int j){
	int xx = (1<<i) , yy = (1<<j);
	bool fg1 = ((x&xx)==0);
	bool fg2 = ((x&yy)==0);
	if(fg1!=fg2) x = x^xx^yy;
}
int vis[(1<<17)];
vi solve(int n,int c){
	if(c==1){
		vi v;
		v.pb(0);
		v.pb(1);
		repA(i,1,n-1){
			int s = sz(v);
			repD(j,s-1,0){
				v.pb(v[j]|(1<<(i)));
			}
		}
		trav(i,v) swap(i,0,n-1);
		return v;
	}
	int xx = (c-1)/2;
	if(xx%2==0) xx++;
	vi x = solve(n-1,xx);
	vi y = solve(n-1,c-1-xx);
	trav(i,y) rep(j,c-1-xx) swap(i,j,xx+j);
	int xl  =x.back();
	trav(i,y) {
		i^=xl;
		i|=(1<<(n-1));
		x.pb(i);
	}
	trav(i,x){
		swap(i,n-1,c-1);
	}
	return x;
}
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n,a,b;cin>>n>>a>>b;
	int x = a^b,cnt=0;
	rep(i,n) if((x&(1<<i))) cnt++;
	if(cnt%2==0){
		cout<<"NO";
		exit(0);
	}
	vi v = solve(n,cnt);
	repD(i,n-1,0) if(x&(1<<i)){
		cnt--;
		trav(j,v) swap(j,i,cnt);
	}
	cout<<"YES"<<endl;
	rep(i,(1<<n)){
		cout<<(v[i]^a)<<' ';	
	}
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 1716
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bool dp[88][88][25652];
int a[88][88];

int main(void){
	int h,w,i,j,k,b,ans=INF;
	cin >> h >> w;
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			cin >> a[i][j];
		}
	}
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			cin >> b;
			a[i][j] -= b;
		}
	}
	dp[0][0][12826+a[0][0]] = true;
	dp[0][0][12826-a[0][0]] = true;
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			for(k=0; k<25652; ++k){
				if(!dp[i][j][k]){
					continue;
				}
				if(0<=k+a[i+1][j] && k+a[i+1][j]<25652){
					dp[i+1][j][k+a[i+1][j]] = true;
				}
				if(0<=k-a[i+1][j] && k-a[i+1][j]<25652){
					dp[i+1][j][k-a[i+1][j]] = true;
				}
				if(0<=k+a[i][j+1] && k+a[i][j+1]<25652){
					dp[i][j+1][k+a[i][j+1]] = true;
				}
				if(0<=k-a[i][j+1] && k-a[i][j+1]<25652){
					dp[i][j+1][k-a[i][j+1]] = true;
				}
			}
		}
	}
	for(k=0; k<25652; ++k){
		if(dp[h-1][w-1][k]){
			ans = min(ans,(int)abs(k-12826));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 179328
/*
   Creator - Glitched
   Yeet!!
*/

#include "bits/stdc++.h"

using namespace std;
#define testcases ll t;cin>>t;while(t--)
#define queries ll q;cin>>q;while(q--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);

int main()
{
    long long n,x;
    cin>>n>>x;

    if(n%x == 0){
        cout<<n/x;
    }
    else{
        cout<<n/x +1;

    }
    flush;

    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  vi a(1001,0);
  a.at(1) = 1;
  for(int i = 2;i<sqrt(1001);i++){
    int j = i*i;
    while(j<1001){
    a.at(j) = 1;
    j *= i;
    }
  }
  int b;
  cin >> b;
  for(int i = b;i>0;i--){
    if(a.at(i)==1){
      cout << i;
      break;
    }
  }
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
using namespace std;
long long a[100000],b,n,m,d;
long long dist(long long p1,long long p2){
	return min((p2-p1+d)%d,(p1-p2+d)%d);
}
int main(){
	while(true){
		cin>>d;if(d==0)break;
		cin>>n>>m;
		for(int i=1;i<n;i++)cin>>a[i];
		sort(a,a+n);long long sum=0;
		for(int i=0;i<m;i++){
			cin>>b;
			long long pos1=lower_bound(a,a+n,b)-a;pos1%=n;
			sum+=min(dist(a[pos1],b),dist(a[(pos1+n-1)%n],b));
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

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

signed main(){
  int H, W;
  cin >> H >> W;
  int SH, SW, GH, GW;
  cin >> SH >> SW >> GH >> GW;
  SH--; SW--; GH--; GW--;

  vector<string> S(H);
  for( int i = 0; i < H; i++ ) cin >> S[i];

  vector<vector<int>> dist(H, vector<int>(W, INF));
  dist[SH][SW] = 0;
  deque<pair<int, pair<int, int>>> queA;
  deque<pair<int, pair<int, int>>> queB;
  queA.push_front(make_pair(0, make_pair(SH, SW)));

  while(!queA.empty() || !queB.empty())
  {
  while( !queA.empty() ){
    int cost = queA.front().first;
    int x = queA.front().second.first;
    int y = queA.front().second.second;
    queB.push_back(queA.front());
    queA.pop_front();

    //移動Aで行けるところ
    for (int direction = 0; direction < 4; ++direction) {
      int next_x = x + dx[direction];
      int next_y = y + dy[direction];
      if (next_x < 0 || next_x >= H || next_y < 0 || next_y >= W) continue;
      if (S[next_x][next_y] == '#') continue;
      if( dist[next_x][next_y] < dist[x][y] ) continue;
      if( dist[next_x][next_y] != INF ) continue;
      dist[next_x][next_y] = dist[x][y];
      queA.push_front(make_pair(0, make_pair(next_x, next_y)));
    }
  }
  while( !queB.empty() ){
    int cost = queB.front().first;
    int x = queB.front().second.first;
    int y = queB.front().second.second;
    queB.pop_front();
    
    //移動Bで行けるところ
    for( int i = -2; i <= 2; i++ ){
      for( int j = -2; j <= 2; j++ ){
        int next_x = x + i;
        int next_y = y + j;
        if (next_x < 0 || next_x >= H || next_y < 0 || next_y >= W) continue;
        if (S[next_x][next_y] == '#') continue;
        if( dist[next_x][next_y] < dist[x][y]+1 ) continue;
        dist[next_x][next_y] = dist[x][y]+1;
        queA.push_back(make_pair(1, make_pair(next_x, next_y)));
      }
    }
  }
  }

  if( dist[GH][GW] == INF ) cout << -1 << endl;
  else cout << dist[GH][GW] << endl;

}


Measured memory_bytes: 14512
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [10000000000]*(N+100)
dp[0] = 0
for i in range(N):
    for j in range(1, K+1):
        if i + j <= N-1:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp[N-1])


Measured memory_bytes: 52448
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########
class Edge:
    def __init__(self, from_edge, to_edge, cost):
        self.from_edge = from_edge
        self.to_edge = to_edge
        self.cost = cost

def bellman_ford(start, edges, node_num):
    dist = [INF] * node_num
    dist[start] = 0
    flag = False
    for i in range(node_num):
        for edge in edges:
            if edge.from_edge != INF and dist[edge.to_edge] > dist[edge.from_edge] + edge.cost:
                dist[edge.to_edge] = dist[edge.from_edge] + edge.cost
                if i == N-1 and edge.to_edge == (node_num - 1):
                    flag = True
    return dist, flag


N, M = l_inpl()
edges = []

for _ in range(M):
    ai, bi, ci = l_inpl()
    edges.append(Edge(ai-1, bi-1, -ci))

dist, flag = bellman_ford(0, edges, N)
# print(dist)
if flag:
    print("inf")
else:
    print(-dist[N-1])


Measured memory_bytes: 47336
n,k= list(map(int,input().split()))
count_0 = 0
count_half = 0
for i in range(1,n+1):
    if i %k == k/2:
        count_half += 1
    elif i%k == 0:
        count_0 += 1
        
print(count_half**3 + count_0**3)

Measured memory_bytes: 9160
#include <stdio.h>

int a,b,r,c;


int main( ){


  while(1){

        if(scanf("%d %d", &a, &b) != 2)
             break;
        if(a < b){
       c = a;
       a = b;
       b = c;
        }

        if(b < 1)
          continue;

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

    printf("%d\n", b);

  }

return 0;

}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h),ans(h);
  rep(i,h){
    cin >> s.at(i);
    ans.at(i) = s.at(i);
  }

  vector<int> dx = {0,1,1,1,0,-1,-1,-1};
  vector<int> dy = {1,1,0,-1,-1,-1,0,1};


  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int cnt=0;
      for(int k=0;k<8;k++){
        if( s.at(i).at(j) == '#' ) continue;
          
        if( i+dy.at(k) >= 0 && i+dy.at(k) < h &&
            j+dx.at(k) >= 0 && j+dx.at(k) < w      ){

          if( s.at(i+dy.at(k)).at(j+dx.at(k)) == '#' ){
            cnt++;
          }

        }
        if( k == 7 ) ans.at(i).at(j) = cnt+'0';
      }
    }
  }
  
  for(int i=0;i<h;i++){
    cout << ans.at(i) << endl;;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue> 
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int c=1,ans=0;
    for(int i=0;i<n;i++){
        if(a[i]==a[i+1])c++;
        if(a[i]!=a[i+1]){
            if(c-a[i]<0)ans+=c;
            else ans+=c-a[i];
            c=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	int m, f, r, point;
	scanf("%d %d %d", &m, &f, &r);
	while (m != -1 || f != -1 || r != -1)
	{
		if (m != -1 && f != -1)
		{
			point = m + f;
			if (point >= 80)
				printf("A\n");
			else if (point >= 65)
				printf("B\n");
			else if (point >= 50 || r >= 50)
				printf("C\n");
			else if (point >= 30)
				printf("D\n");
			else
				printf("F\n");
		}
		else
			printf("F\n");
		scanf("%d %d %d", &m, &f, &r);
	}

	return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;
public class Main{
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
        for(int cnt=0;cnt<4;cnt++){
            int t=sc.nextInt();
            int n=sc.nextInt();
            switch(t){
                case 1:
                 System.out.println(n*6000);
                 break;
                case 2:
                 System.out.println(n*4000);
                 break;
                case 3:
                 System.out.println(n*3000);
                 break;
                case 4:
                 System.out.println(n*2000);
                 break;
            }
        }
    }
    
    public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17184
#include <stdio.h>

int main(void){
        int i, j;
        int h, w;

        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( i==0 || i==h-1 || j==0 || j==w-1 )
                                        putchar('#');
                                else
                                        putchar('.');
                        }
                        putchar('\n');
                }
                        putchar('\n');
        }

        return 0;
}


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

int main(){
	int m,f,r;
	while(1){
		cin >> m >> f >> r;
		if(m == -1 and f == -1 and r == -1){
			break;
		}
		if(m == -1 or f == -1) cout << "F";
		else if( m+f >= 80 ) cout << "A";
		else if( m+f >= 65 ) cout << "B";
		else if( m+f >= 50 || r >= 50 ) cout << "C";
		else if( m+f >=30 ) cout << "D";
		else cout << "F";
		cout << endl;
	}
	return 0;
}					

Measured memory_bytes: 3092
N, M = map(int, input().split())

class City():
    def __init__(self, idx, prefecture, year):
        self.idx = idx
        self.prefecture = prefecture
        self.year = year

    def set_rank(self, rank):
        self.rank = rank

    @property
    def id(self):
        return "{0:0>6}{1:0>6}".format(self.prefecture, self.rank)

city_list = []
for i in range(M):
    p, y = map(int, input().split())
    city_list.append(City(i, p, y))

rank_list = [1 for _ in range(N+1)]
for city in sorted(city_list, key=lambda city: city.year):
    prefecture = city.prefecture
    city.set_rank(rank_list[prefecture])
    rank_list[prefecture] += 1

for city in city_list:
    print(city.id)


Measured memory_bytes: 73736
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())

using namespace std;

int main() {

	int i, j, k;
	int n;
	cin >> n;
	int ans=1;
	rep(i, 0, 10) {
		if (1 << i <= n) {
			ans = 1 << i;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

vector<int> counting_sort(const vector<int> &as) {
    const int len = as.size();
    const int nax = *max_element(all(as));
    vector<int> cnt(nax + 1, 0);
    rep(i, 0, len) {
        cnt[as[i]]++;
    }
    rep(i, 0, nax) {
        cnt[i + 1] += cnt[i];
    }
    vector<int> bs(len, 0);
    rrep(j, len - 1, 0) {
        bs[cnt[as[j]] - 1] = as[j];
        cnt[as[j]]--;
    }

    return bs;
}

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    dump_vec(counting_sort(A));
}



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

public class P
{
    public int t { get; set; }
    public int m { get; set; }
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var ps = new P[n];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var t = int.Parse(line[0]);
                var m = int.Parse(line[1]);
                ps[i] = new P { t = t, m = m };
            }
            var tsum = 0;
            foreach (var x in ps.OrderBy(y => y.m))
                if (tsum + x.t <= x.m) tsum += x.t;
                else { Console.WriteLine("No"); goto end; }
            Console.WriteLine("Yes");
            end:;
        }
    }
}


Measured memory_bytes: 14096