akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define forn(i, n) for(lli i=0; i<n; i++)
#define forn1(i, n) for(lli i=1; i<n; i++)
#define debug(x) cerr << "------" << x << endl;
#define All(x) x.begin(), x.end()
#define elif else if
#define lli long long int
#define _USE_MATH_DEFINES
#define _x first
#define _y second

#define _CRT_SECURE_NO_WARNINGS



//#include <bits/stdc++.h>

#include <stdlib.h>
#include <limits.h>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <cmath>
#include <numeric>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <list>
#include <sstream>

#include <random>
#include <typeinfo>

using namespace std;

//Constant vars

const lli MOD = 1000000007, LIM = 4294967295;

//Vars

lli n, m, a, b, c, d, q, k, tr, summ, ans, minx, maxx, li, lj, lk, ri, rj, rk, mid, l1, r1, mid1, res, mass1[10000][10000], mass2[100001], mass[100000], from[1000][1000];

string s, trs, str, ss;

//Structures

set<lli> g, bb, all;
set<vector<lli>> myset, myset1, childs[51][51][51];
vector<vector<lli>> myvec[51][51], toWrite, myvec2;
vector<pair<lli, lli>> mm, mm1;
vector<vector<lli>> mvv;
queue<lli> myq;
map<lli, lli> mymap, mymap1, mymap2;
map<lli, vector<lli>> mymapvec;
multiset<lli> mmset;
unordered_map<string, lli> smap;





int compare(const void * a, const void * b) {

	return -((*(lli*)a) - (*(lli*)b));

};

lli gcd(lli a, lli b) {

	while (b != 0) {

		lli t = b;
		b = a % b;
		a = t;

	}

	return a;

}

lli gcdex(lli a, lli b, lli & x, lli & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	lli x1, y1;
	lli d = gcdex(b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}

lli NOK(lli n1, lli n2) {

	return n1 * n2 / gcd(n1, n2);

}

lli bin_pow(lli base, lli p) {
	if (p == 1) {
		return base % MOD;
	}
	if (p == 0) {
		return 1;
	}

	if (p % 2 == 0) {
		lli t = bin_pow(base, p / 2) % MOD;
		return t * t % MOD;
	}
	else {
		return bin_pow(base, p - 1) * base % MOD;
	}
}

lli inverse_element(lli x) {
	return bin_pow(x, MOD - 2);
}


lli divide(lli a, lli b) {
	return a * inverse_element(b) % MOD;
}

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("testlist.txt", "w", stdout);

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

	cin >> n;
	cout << n / 3;

	return 0;
}
//

Measured memory_bytes: 6332
using System;
using System.Collections.Generic;
using System.Linq;
class c{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int N = int.Parse(str[0]);
    int M = int.Parse(str[1]);
    long K = long.Parse(str[2]);
    String[] s1 = Console.ReadLine().Split(' ');
    String[] s2 = Console.ReadLine().Split(' ');
    long[] A = new long[N+1];
    long[] B = new long[M+1];
    A[0] = B[0] = 0;
    for(long x=1; x<=N; x++){
      A[x] = A[x-1] + long.Parse(s1[x-1]);
    }
    for(long x=1; x<=M; x++){
      B[x] = B[x-1] + long.Parse(s2[x-1]);
    }
    //Console.WriteLine(string.Join(" ",A));
    //Console.WriteLine(string.Join(" ",B));
    int max = M;
    long ans=0;
    int i,j;
    for(i=0; i<=N; i++){
      if(A[i] > K){ break; }
      for(j=max; j>=0; j--){
        if((A[i] + B[j]) <= K){
          max = j;
          break;
        }
      }
      //Console.WriteLine("{0} {1}",ti,tj);
      ans = Math.Max(ans,i+j);
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 59692
#include <iostream>
#include <cstring>
using namespace std;
int main(void) {
  int n;
  while(cin >> n, n) {
    int x, y, m;
    bool flag[32][32];
    memset(flag, false, sizeof(flag));
    for(int i = 0;i < n; i++) {
      cin >> x >> y;
      flag[y][x] = true;
    }
    cin >> m;
    char d;
    int nx = 10, ny = 10, cnt = 0;
    for(int i = 0;i < m; i++) {
      cin >> d >> x;
      for(int j = 0;j < x; j++) {
        if(d == 'N') ny++;
        if(d == 'E') nx++;
        if(d == 'S') ny--;
        if(d == 'W') nx--;
        if(flag[ny][nx]) flag[ny][nx] = false, cnt++;
      }
    }
    cout << (cnt==n? "Yes" : "No") << endl;
  }
}


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

int main() {
  //Nを500で割ったあまり＝A
  int N,A;
  cin >> N >> A;
  
  if(A >= N%500){
    cout << "Yes" << endl;
  }
  
  if(A < N%500){
    cout << "No" << endl;
  }  
}


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


int main(){
  ll x;
  cin >> x;
  ll cnt = 0;
  ll num = 0;
  while(true){
    cnt++;
    num += cnt;
    if( num >= x ){
      cout << cnt << endl;
      return 0;
    }
    
  }
  return 0;
}

Measured memory_bytes: 256
import java.lang.Math;
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long blue = sc.nextLong();
        long red  = sc.nextLong();
        long l = n/(blue+red)*blue;
        long rem = n%(red+blue);
        l += Math.min(rem, blue);
        System.out.println(l);
    }
}

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

void fnInput(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

int fnRcsSch(int nPos, int nTrgSu, int nTrgKin, vector<int>& rvnNumMoney)
{
  vector<int> vnMoney{10000, 5000, 1000};

  if (nTrgKin < 0)  return -1;
  if (nPos == rvnNumMoney.size() - 1)
  {
    rvnNumMoney[nPos] = nTrgSu;
    if (nTrgKin - vnMoney[nPos] * nTrgSu == 0)
      return 1;
    else
      return 0;
  }

  for (int i = 0; i <= nTrgSu; i++)
  {
    rvnNumMoney[nPos] = i;
    int nRtn = fnRcsSch(nPos + 1, nTrgSu - i, nTrgKin - vnMoney[nPos] * i, rvnNumMoney);
    if      (nRtn == -1)  return 0;
    else if (nRtn)        return 1;
  }

  return 0;
}

int fnExhSch(int nTrgSu, int nTrgKin)
{
  vector<int> vnNumMoney(3);

  if (fnRcsSch(0, nTrgSu, nTrgKin, vnNumMoney))
    cout << vnNumMoney[0] << " " << vnNumMoney[1] << " " << vnNumMoney[2] << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;
  
  fnInput(nTrgSu, nTrgKin);
  fnExhSch(nTrgSu, nTrgKin);

  return 0;
}
 

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

#define TARGET "slv"

using namespace std; 

using ll = long long;

int main() {
#ifdef INSPIRATION
    freopen(TARGET".in", "r", stdin);
    freopen(TARGET".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);    
    string s;
    cin >> s;
    int n = (int) s.size();
    vector<int> cnt(26);
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ans += i-cnt[s[i]-'a'];
        cnt[s[i]-'a']++;
    }
    cout << ans;
    return false;       
} 

Measured memory_bytes: 720
N = int(input())
H = list(map(int,input().split()))
count =0
ans = 0
now = 0
for val in H:
    if now >= val:
        now = val
        count += 1
    else:
        ans = max(ans, count)
        now = val
        count = 0
ans = max(ans, count)

print(ans)
    
    
    


Measured memory_bytes: 14228
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)

	inputs := scanNums(N)
	ans := float64(inputs[0])

	for i := 1; i < N; i++ {
		// if inputs[i] > inputs[i-1] {
		// 	ans += inputs[i-1]
		// } else {
		// 	ans += inputs[i]
		// }
		// なんでfloat64だと不正解になるのか
		ans += math.Min(float64(inputs[i]), float64(inputs[i-1]))
	}

	fmt.Println(int(ans))
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
class UnionFind:
  def __init__(self, num):
    self.rank = [0]*num
    self.par = [i for i in range(num)]
    self.n = num
    self.size = [1]*num
  
  def find(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
    
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return 
    if self.rank[x] > self.rank[y]:
      self.par[y] = x
      self.size[x] += self.size[y]
      self.size[y] = 0
    else:
      self.par[x] = y
      self.size[y] += self.size[x]
      self.size[x] = 0
      if self.rank[x] == self.rank[y]:
        self.rank[y] += 1
    
  def same(self, x, y):
    return self.find(x) == self.find(y)
  
  def all_find(self):
    ls = []
    for i in range(len(self.par)):
      ls.append(self.find(i))
    return ls
    
n, q = map(int, input().split())

uf = UnionFind(n)

for _ in range(q):
  com, x, y = map(int, input().split())

  if com == 0:
    uf.union(x, y)
  else:
    print(int(uf.same(x,y)))


Measured memory_bytes: 6116
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        if ((i * 108) / 100 == n)
        {
            cout << i;
            return 0;
        }
    }
    cout << ":(";
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  str s;
  cin >> s;
  int n = s.length();
  ll ans = n;
  ll s_cnt = 0;
  REP(i,n){
    if(s[i]=='S'){
      s_cnt++;
    }else{
      if(s_cnt){
        ans -= 2;
        s_cnt--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;


int main() {
	int N; cin >> N;
	vector<long long> A(N), B(N,0);
	for (int i = 0; i < N; i++) cin >> A[i];
	int ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		int x = 0;
		for (int j = i+1;j<=N; j += i+1) x ^= B[j-1];
		B[i] += x^A[i]; ans += x^A[i];
	}
	cout << ans << endl;
	for (int i = 0; i < N; i++) {
		if (B[i] == 1)cout << i+1 << " ";
	}
}





Measured memory_bytes: 3968
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  string N;
  cin >> N;
  if (N[0] == N[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

 
int main()
{
    
    int n;
    scf(n);
    
    string s;
    cin>>s;
    
    ll r=0,g=0,b=0,ctr=0;
    
    rep(i,0,n)
    {
        if(s[i]=='R') r++;
        
        if(s[i]=='B') b++;
       
        if(s[i]=='G') g++;
    }
    
    ll res=r*g*b;


    rep(i,0,n)
    {
        rep(j,i,n)
        {
            char a=s[i];
            char b=s[j];

            if(a!=b)
            {
                if(j+j-i<n&&j+j-i>=0)
                {
                    char c=s[2*j-i];

                    if(a!=c&&b!=c)
                    ctr++;
                }

            }



        }



    }
    

    res-=(ctr);
    
    lprin(res);


}


Measured memory_bytes: 3752
#include<iostream>
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
const int N=1e5+5;
struct node{
    int u,v,w;
    bool operator<(const node&a)const{return w<a.w;}
}e[N*2];
int se[N];
int get(int x){
    while(x!=se[x])
        x=se[x]=se[se[x]];
    return x;
}
struct point{
    int w,id;
    bool operator<(const point&a)const{return w<a.w;}
}x[N],y[N];
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&x[i].w,&y[i].w);
        x[i].id=y[i].id=i;
        se[i]=i;
    }
    sort(x+1,x+n+1),sort(y+1,y+n+1);
    int ct=0;
    for(int i=1;i<n;i++) e[++ct]=(node){x[i].id,x[i+1].id,abs(x[i].w-x[i+1].w)};
    for(int i=1;i<n;i++) e[++ct]=(node){y[i].id,y[i+1].id,abs(y[i].w-y[i+1].w)};
    sort(e+1,e+ct+1);
    long long sum=0;
    int cnt=1;
    for(int i=1;i<=ct;i++){
        int fu=get(e[i].u),fv=get(e[i].v);
        if(fu==fv)continue;
        sum+=e[i].w;
        se[fu]=fv;
        if(++cnt==n) break;
    }
    cout<<sum;
}


Measured memory_bytes: 4480
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = 0
for i in range(n):
    if a[i] != i+1:
        cnt += 1
if cnt == 0 or cnt == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38764
N, M = map(int, input().split())
N, M = min(N,M), max(N,M)

ans = [[1], [2, 0], [3, 0, 9], [2, 0, 6, 4]]
if M <= 4:
  print(ans[M-1][N-1])
  exit()
if N == 1:
  print(M-2)
  exit()
if N == 2:
  print(0)
  exit()
if N == 3:
  print(N*M - 6)
  exit()

print(4 + (N-4 + M-4)*2 + (N-4)*(M-4))

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

int n;

int main(){
  cin>>n;
  int res=INF;
  rep(i,n+1){
    if(i%6!=0)continue;
    int ni=i,nj=n-i;
    int sum=0;
    ni/=6;
    while(ni>0){
      sum+=ni%6;
      ni/=6;
    }
    while(nj>0){
      sum+=nj%9;
      nj/=9;
    }
    minch(res,sum);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    if T[:-1] == S:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61724
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  for(int i=n-1; i>=0; i--){
    if(i != n-1) cout << " ";
    cout << v[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main (){
  int N,K;
  string S,A="A",B="B",C="C";
  cin>>N>>K;
  cin>>S;
  if(S.compare(K-1,1,A)==0){
    S.replace(K-1,1,"a");
    cout<<S<<endl;
  }
  else if(S.compare(K-1,1,B)==0){
    S.replace(K-1,1,"b");
    cout<<S<<endl;
  }
   else if(S.compare(K-1,1,C)==0){
    S.replace(K-1,1,"c");
    cout<<S<<endl;
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using gr = vector<vll>;
using wgr = vector<vpll>;

#define pb push_back
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
struct d_ {
    template<typename T> d_ & operator ,(const T & x) { cerr << ' ' <<  x; return *this;}
    template<typename T> d_ & operator ,(const vector<T> & x) { for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) begin(x),end(x)
#define IN(n) ll n;cin >> n;
#define x first
#define y second


int main(void) {
    ios_base::sync_with_stdio(false);
    ll t; cin >> t;
    while(t--) {
        ll n; cin >> n;
        vll a(n);
        F(n) cin >> a[i];
        string s; cin >> s; for(auto &c: s) c-='0';
        if(s[n-1]) {
            cout << 1 << endl;
            continue;
        }
        vll S;
        bool ret = 0;
        D(n-1) {
            ll cur = a[i];
            for(auto s: S) cur=min(cur,cur^s);
            if(!s[i]) {
                // add a_i to basis
                S.pb(cur);
            } else {
                if(cur) { //a_i not in S
                    ret = 1;
                }
            }
        }
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++)
    cin >> p[i] >> s[i];
  
  vector<bool> ac(n, false);
  int a = 0;
  vector<int> b(n, 0);
  for (int i = 0; i < m; i++) {
    if (ac[p[i] - 1])
      continue;
    if (s[i] == "AC") {
      ac[p[i] - 1] = true;
      a++;
    }
    if (s[i] == "WA") {
      b[p[i] - 1]++;
    }
  }
  int total;
  for (int i = 0; i < n; i++)
    total += ac[i] ? b[i] : 0;
  cout << a << " " << total << endl;
  return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
const int md=1000000007;
int n,x,y,z,sum;
long long t;
long long dp[45][1<<17];
long long sol(long long a,long long b)
{
	if(dp[a][b]!=-1)return dp[a][b];
	if((b>>(x+y+z-1))&1&&(b>>(y+z-1))&1&&(b>>(z-1))&1)return 0;
	if(a==n)return 1;
	long long ans=0;
	for(int i=1;i<=10;i++)ans=(ans+sol(a+1,((b<<i)|(1<<(i-1)))&t))%md;
	return dp[a][b]=ans;
}
int main()
{
	scanf("%d%d%d%d",&n,&x,&y,&z);
	sum=x+y+z;
	t=(1<<sum)-1;
	long long ans=1;
	for(int i=1;i<=n;i++)ans=ans*10%md;
	memset(dp,-1,sizeof(dp));
	ans-=sol(0,0);
	ans=(ans+md)%md;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 46336
import sys
lines = '' 
for line in sys.stdin.readlines():
    if not line:
        break
    else:
        lines += line.lower()

a = ord('a')
z = ord('z')
n = z - a + 1
lis1 = list(map(chr, (_ for _ in range(a, z+1))))
lis2 = [0]*n
d = dict(zip(lis1, lis2))
for c in lines:
        if c in lis1:
            d[c] += 1
for i in d:
    print('{} : {}'.format(i, d[i]))


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

int main(){
	int N, input;
	bool flag = true;
	cin >> N;
	rep(i, N){
		cin >> input;
		if(input % 2 == 0){
			if(input % 3 != 0 && input % 5 != 0)
				flag = false;
		}
	}
	if(flag == true) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int N;
  cin >> N;
  vector<int> A(N+1), B(N);
  REP(i, N+1){
    cin >> A[i];
  }
  REP(i, N){
    cin >> B[i];
  }
  ll ans = 0;
  REP(i, N){
    if(B[i] >= A[i]){
      ans += A[i];
      B[i] -= A[i];
      A[i] = 0;
    }
    else{
      ans += B[i];
      A[i] -= B[i];
      B[i]=0;
    }
    if(B[i] >= A[i+1]){
      ans += A[i+1];
      A[i+1] = 0;
    }
    else{
      ans += B[i];
      A[i+1] -= B[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m,x;cin>>n>>m>>x;
  VV<ll> v(n,V<ll>(m));
  V<ll> c(n);
  rep(i,0,n){
    cin>>c[i];
    rep(j,0,m)cin>>v[i][j];
  }

  ll ans=LINF;
  rep(i,0,1<<n){
    V<ll> und(m,0);
    ll res=0;
    rep(j,0,n){
      if((1<<j)& i){
        res+=c[j];
        rep(k,0,m){
          und[k]+=v[j][k];
        }
      }
    }

    bool flag=true;
    rep(j,0,m)if(x>und[j])flag=false;

    if(flag)chmin(ans,res);
  }
  if(ans<LINF)cout<<ans<<ENDL;
  else cout<<-1<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	for(int n,k;cin>>n>>k && n|k;){
		vector<vector<int> > ps(10);
		for(int i=0;i<n;i++){
			int p,g; cin>>p>>g;
			ps[g-1].push_back(p);
		}
		
		for(int i=0;i<10;i++)
			sort(ps[i].begin(),ps[i].end(),greater<int>());
		vector<vector<int> > ss=ps;
		for(int i=0;i<10;i++)
			for(int j=1;j<ss[i].size();j++)
				ss[i][j]+=ss[i][j-1]+2*j;
		
		vector<vector<int> > dp(2,vector<int>(n+1));
		for(int i=0;i<10;i++){
			dp[i+1&1]=dp[i&1];
			for(int j=0;j<ss[i].size();j++)
				for(int k=n;k>j;k--)
					dp[i+1&1][k]=max(dp[i+1&1][k],dp[i&1][k-(j+1)]+ss[i][j]);
		}
		cout<<dp[0][k]<<endl;
	}
	return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int N,c=1;
  cin>>N;
  for(int i=9;i>=1;i--)
  {
    if((N%i==0)&&((N/i)<10))
    {
      cout<<"Yes"<<endl;
      c=0;
      break;
    }
  }
  if(c)
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int x,t;
    cin>>x>>t;
    cout<<max(x-t,0)<<endl;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque

n, d, a = (int(v) for v in stdin.readline().split())
monsters = [(int(v) for v in line.split()) for line in stdin.readlines()]

monsters = [[x, (h // a + 1) if h % a > 0 else (h // a)] for x, h in monsters]
monsters = sorted(monsters)
bomb_size = 2 * d + 1
num_bombs = 0

current_bombs = 0
bomb_endpoints = deque()
bomb_endnumbers = deque()

for i in range(len(monsters)):
    while len(bomb_endpoints) > 0 and bomb_endpoints[0] <= monsters[i][0]:
        current_bombs -= bomb_endnumbers[0]
        bomb_endpoints.popleft()
        bomb_endnumbers.popleft()
    monsters[i][1] -= current_bombs
    if monsters[i][1] > 0:        
        bombs_now = monsters[i][1]
        monsters[i][1] = 0
        num_bombs += bombs_now
        current_bombs += bombs_now
        bomb_endpoints.append(monsters[i][0] + bomb_size)
        bomb_endnumbers.append(bombs_now)

print(num_bombs)


Measured memory_bytes: 169452
#include<stdio.h>

int main(void){
  int n,i;
  int p,d1,d2;
  int max_dist, max_id ;

  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    
    max_dist = 0;
    max_id = 0;
    
    for(i=0;i<n;i++){
      scanf("%d %d %d",&p,&d1,&d2);
      if(max_dist < d1+d2){
	max_dist = d1+d2;
	max_id = p;
      }
    }

    printf("%d %d\n",max_id,max_dist);
  }

  return 0;
}

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

int main() {
  int N, K, x, y, z;
  cin >> N >> K;
  z = 1;
  for (int i = 0; i < N; i++) {
    x = 2 * z;
    y = z + K;
      if (x < y){
        z = x;
      }
    else z = y;   
  }
  cout << z << endl;
}

Measured memory_bytes: 256
package main

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

type Node struct {
	id    int
	left  *Node
	right *Node
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	nodes, err := prepareNodes(n, sc)
	if err != nil {
		panic(err)
	}
	// fmt.Println(nodes)
	root := findRoot(nodes)
	// fmt.Println(root)
	fmt.Println("Preorder")
	fmt.Println(preorder(root))
	fmt.Println("Inorder")
	fmt.Println(inorder(root))
	fmt.Println("Postorder")
	fmt.Println(postorder(root))
}

func findRoot(nodes []Node) *Node {
	node := &nodes[0]
	findParent := false
	for {
		for i := 0; i < len(nodes); i++ {
			if nodes[i].left == node || nodes[i].right == node {
				node = &nodes[i]
				findParent = true
				break
			}
		}
		if !findParent {
			return node
		}
		findParent = false
	}
}

func preorder(top *Node) string {
	var x string
	x += " " + strconv.Itoa(top.id)
	if top.left != nil {
		x += preorder(top.left)
	}
	if top.right != nil {
		x += preorder(top.right)
	}
	return x
}

func inorder(top *Node) string {
	var x string
	if top.left != nil {
		x += inorder(top.left)
	}
	x += " " + strconv.Itoa(top.id)
	if top.right != nil {
		x += inorder(top.right)
	}
	return x
}

func postorder(top *Node) string {
	var x string
	if top.left != nil {
		x += postorder(top.left)
	}
	if top.right != nil {
		x += postorder(top.right)
	}
	x += " " + strconv.Itoa(top.id)
	return x
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func prepareNodes(n int, sc *bufio.Scanner) ([]Node, error) {
	rs := make([]Node, n)
	m := make(map[int][2]int) // id -> {left, right}
	for i, _ := range rs {
		id, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		left, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		right, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		rs[i].id = id
		m[id] = [2]int{left, right}
	}
	for parentId, childrenIds := range m {
		leftId, rightId := childrenIds[0], childrenIds[1]
		var parent *Node
		for i := 0; i < len(rs); i++ {
			if rs[i].id == parentId {
				parent = &rs[i]
				break
			}
		}
		if parent == nil {
			panic(fmt.Errorf("parent not found..."))
		}
		if leftId != -1 {
			for i := 0; i < len(rs); i++ {
				if rs[i].id == leftId {
					parent.left = &rs[i]
					break
				}
			}
		}
		if rightId != -1 {
			for i := 0; i < len(rs); i++ {
				if rs[i].id == rightId {
					parent.right = &rs[i]
					break
				}
			}
		}
	}
	return rs, nil
}



Measured memory_bytes: 1164
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 18;
int n , a[1 << N];

int main(){
  scanf("%d",&n);
  rep(i,0,1<<n) scanf("%d",a+i);
  per(i,0,n) {
    rep(j,0,1<<i) {
      int x=a[j<<1],y=a[j<<1|1];
      if(x>y) a[j]=x-y;
      else if(x==y) a[j]=x;
      else a[j]=y-x;
    }
  }
  printf("%d\n",a[0]);
  return 0;
}


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

int main(){
 bool cards[4][13]={false};

 int n;
 cin >> n;

 char suit;
 int rank;

 for( int h=0; h<n; h++ ){
  cin >> suit >> rank;
  if( suit == 'S' ){
   cards[0][rank-1] = true;
  }
  if( suit == 'H' ){
   cards[1][rank-1] = true;
  }
  if( suit == 'C' ){
   cards[2][rank-1] = true;
  }
  if( suit == 'D' ){
   cards[3][rank-1] = true;
  }
 }

 for( int i=0; i<4; i++ ){
  for( int j=0; j<13; j++ ){
   if( cards[i][j] == false ){
      if( i==0 ){
        cout << "S" << " " << j+1 << endl;
      }
      if( i==1 ){
        cout << "H" << " " << j+1 << endl;
      }
      if( i==2 ){
        cout << "C" << " " << j+1 << endl;
      }
      if( i==3 ){
        cout << "D" << " " << j+1 << endl;
      }
   }
  }
 }

 return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <list>
#include <vector>

using namespace std;

enum TYPE{
	ROOT,
	LEAF,
	NODE,
};
string TYPESTR[]={"root","leaf","internal node"};

class Node{
	
	int id;
	int depth;
	//TYPE node_type;
public:	
    Node(int id){this->id = id;}
	Node* parent;
	list<Node*> child_list;
	int getChildNum(){return child_list.size();}
	int getId(){return id;}
	int getDepth(){return depth;}
	TYPE getType();
	void setDepth(int depth);
};

void output(vector<Node*> t);

int main(){
	
	int n = 0;
	cin >> n ;
	vector<Node*> table;
	table.resize(n);
	//全テーブルをノードで埋める
	for(int i=0;i<n;i++){
		table[i]=new Node(i);
	}
	for(int i=0;i<n;i++){
		int id=0;
		cin >> id;
		int child_num=0;
		cin >> child_num;
		table[id]->child_list.resize(child_num);
		for(auto itr = table[id]->child_list.begin() ; itr != table[id]->child_list.end(); itr++){
			int child = 0;
			cin >> child;
			//ノードの子を教える
			*itr = table[child];
			//ノードの親を教える
			table[child]->parent = table[id];
		}
	}
	//rootを決める
	Node* root = table[0];
	while(root->parent){
		root = root->parent;
	}
	//root->parent = -1;
	root->setDepth(0);
	
	output(table);
	return 0;
}

void Node::setDepth(int depth){
	this->depth = depth;
	for(auto /*list<Node*>::iterator*/ itr = child_list.begin(); itr != child_list.end(); itr++){
		(*itr)->setDepth(depth+1);
	}
}
TYPE Node::getType(){
	if(!parent){
		return ROOT;
	}
	if(child_list.size()==0){
		return LEAF;
	}
	return NODE;
}

void output(vector<Node*> t){
	int size = t.size();
	for(int i=0;i<size; i++){
		cout << "node " << i << ": ";
		int parent = (t[i]->parent) ? (t[i]->parent->getId()) : -1;
		cout << "parent = " << parent <<", ";
		cout << "depth = " << t[i]->getDepth() << ", ";
		cout << TYPESTR[t[i]->getType()] << ", ";
		cout << "[";
		for(auto itr =t[i]->child_list.begin(); itr!= t[i]->child_list.end(); itr++){
			if(itr != t[i]->child_list.begin()){
				cout << ", ";
			}
			cout << (*itr)->getId() ;
		}
		cout << "]" << endl;
	}
}




Measured memory_bytes: 12312
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)

template<typename T>
vector<T> divisor_enumeration(T n){
    vector<T> ret;
    for(T i=1; i*i<=n; i++){
        if(n%i == 0){
            ret.push_back(i);
            if(i*i != n) ret.push_back(n/i);
        }
    }
    return ret;
}

int N;
int A[200000];

int cnt[1000001] ={};

signed main(){
    cin >> N;
    rep(i, N){
        cin >> A[i];
        cnt[A[i]]++;
    }

    int ans = 0;
    rep(i, N){
        auto tmp = divisor_enumeration(A[i]);
        cnt[A[i]]--;
        bool flg = true;
        rep(j, tmp.size()){
            flg &= (cnt[tmp[j]] == 0);
        }
        cnt[A[i]]++;
        if(flg) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  string S;
  int N;
  cin >> N >> S;
  for (auto& s : S) {
    s = (s + N);
    if ('Z' < s) s -= ('Z' + 1 - 'A');
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <stack>


using namespace std;
typedef long long LL;
const int MaxN = 1e6 + 5;
const int Mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double esp = 1e-6;

#define pi acos(-1.0)
double r;

int main(){
    cin >> r;
    double ans = 2 * pi * r;
    printf("%.8lf\n",ans);

    return 0;
}

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

int main() {
  int N, i, p, w, g, y;
  string Si;
  w = 0;
  p = 0;
  g = 0;
  y = 0;
 cin >> N;
  for(int i = 0; i < N; i++){
    cin >> Si;
     if(Si == "W" && w == 0){
        w += 1;
      }
     else if(Si == "P" && p == 0){
        p += 1;
      }
     else if(Si == "G" && g == 0){
        g += 1;
      }
     else if(Si == "Y" && y == 0){
        y += 1;
      }
  }
  if(w + p + g + y == 3){
  cout << "Three" << endl;
  }
  else if(w + p + g + y == 4){
    cout << "Four" << endl;
  }
}
  
  

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

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

using namespace std;

namespace Kyopro {

    using ll = long long;



    const ll MOD = 998244353LL;

    const int MAX = 210000;

    long long fac[MAX], finv[MAX], inv[MAX];

    // テーブルを作る前処理
    void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    // 二項係数計算
    long long COM(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    long long modpow(long long a, long long n, long long mod) {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    ll f(size_t m, size_t n) {
        ll ret = (m * modpow(m - 1, n - 1, MOD)) % MOD;
        return ret;
    }

    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    ll combinations2(size_t n, size_t k) {
        ll r = 1;
        for (ll d = 1; d <= k; ++d) {
            r *= n--;
            r = r % MOD;
            r = r * modinv(d, MOD);
            r = r % MOD;
        }
        if (r > MOD / 2) {
            r -= MOD;
        }
        return r;
    }
}

using namespace Kyopro;

const double PI = acos(-1);

map<ll, vector<ll>> g;
vector<ll> v;
queue<ll> q;

void solve() {
    size_t n, m;
    cin >> n >> m;
    v.resize(n);
    fill(v.begin(), v.end(), -1);
    v.at(0) = 0;
    REP(i, m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    q.push(0);
    while (!q.empty()) {
        ll c = q.front();
        q.pop();
        //cout << "now:" << c + 1 << endl;
        auto& r = g.at(c);
        for (auto d : r) {
            if (v.at(d) == -1) {
                //cout << "  add:" << d + 1 << endl;
                v.at(d) = c;
                q.push(d);
            }
        }

    }
    
    if (find(v.begin(), v.end(), -1) != v.end()) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
        for (size_t i = 1; i < n; ++i) {
            cout << v.at(i)+1 << endl;
        }
    }
}

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

    COMinit();

    solve();

    return 0;
}

Measured memory_bytes: 24348
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

static constexpr ll mod = 1000000007LL;

ll add(ll a, ll b){
    return (a + b) % mod;
}

ll sub(ll a, ll b){
    return (a + mod - b) % mod;
}

ll mul(ll a, ll b){
    return ((a % mod) * (b % mod)) % mod;
}

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

ll div(ll a, ll b){
    return mul(a, power(b, mod-2));
}

int main() {
    ll N, M;
    cin >> N >> M;

    if (N < M) swap(N, M);
    if (N - M > 1 ) cout << 0 << endl;
    else {
        ll n_factorial{1};
        for (auto &&i: irange(1LL, N+1)){
            n_factorial = mul(n_factorial, i);
        }
        ll m_factorial{1};
        for (auto &&i: irange(1LL, M+1)){
            m_factorial = mul(m_factorial, i);
        }
        ll ret{mul(n_factorial, m_factorial)};
        if (N==M) ret = mul(ret, 2LL);
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
  string a,b;
  cin>>a>>b;
  int check=0;
  for(int i=0;i<a.size();i++)check=check*10+(a.at(i)-'0');
  for(int i=0;i<b.size();i++)check=check*10+(b.at(i)-'0');
  int q=sqrt(check);
  if(check==q*q)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

typedef long long ll ; 
typedef unsigned long long ull ; 
typedef vector<int> vi ; 
typedef vector<vi> vii ;
typedef vector<ll> vl ;
typedef vector<vl> vll ;
typedef set<int> si ; 
typedef map<int,int> mii ; 
typedef map<ll,ll>  mll ; 
typedef map<string,int> msi ;
typedef set<ll> sl ; 
typedef set<char> sc ; 
typedef pair<int,int> pii ;


#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1 << 29 ; 
#define MOD (ll)(1e9+7)
#define eps 1e-6
#define pb push_back 
#define mp make_pair 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;
#define F first 
#define S second 

int main() 
{
	ios::sync_with_stdio(0) ;
	
	int n , k;
	cin >> n >> k ;
	int h[n];
	REP(i,n) cin >> h[i];
	
	int dp[n+5];
	REP(i,n+5) dp[i] = INT_MAX;
	dp[0] = 0;
	for(int i = 1; i <= min(n,k); ++i) {
		dp[i] = dp[0] + abs(h[i-1] - h[0]);
	}
	for(int i = k+1; i <= n; ++i) {
		int res = INT_MAX;
		for(int j = 1; j <= k; ++j) {
			res = min(res , dp[i-j] + abs(h[i-1] - h[i-j-1]));
		}
		dp[i] = res;
	}
	cout << dp[n] << endl;

	return 0 ; 
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

//ユークリッドの互除法
int gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

//3項以上の場合
ll gcd(vector<ll>a) {
  ll ans = a[0];
  for (int i=1; i<sz(a); i++) {
    ans = gcd(ans, a[i]);
  }
  return ans;
}

set<int> st;
int cnt = 0;

//素因数分解
vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    cnt = 0;
    if (n<=1) return res;
    if (n==2) {
        cnt++;
        st.insert(2);
        return res;
    }
    for (ll i=2; i*i<=n; i++) {
        if (n%i) continue;
        //割り切れるなら
        cnt++;
        st.insert(i);
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) {
        res.emplace_back(n, 1);
        st.insert(n);
        cnt++;
    }
    return res;
}

// map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

// //O(√n)
// //整列済み(mapはkeyで自動で整列される)
// void prime_factorize(ll n){
//     if(n<=1) return;
//     ll l=sqrt(n);
//     REP(i,2,l){
//         if(n%i==0){
//         prime_factorize(i);prime_factorize(ll(n/i));return;
//         }
//     }
//     //mapでは存在しないkeyの場合も自動で構築される
//     prime[n]++;return;
// }

 
int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll GCD = gcd(a);
    if (GCD != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    vector<pair<ll, int>> res;

    rep(i,n) {
        int S = sz(st);
        cnt = 0;
        res = factorize(a[i]);
        if (cnt > 0) {
            int T = sz(st);
            if (cnt != T-S) {
                cout << "setwise coprime" << endl;
                return 0;
            }
        }
    }
    cout << "pairwise coprime" << endl;

}


Measured memory_bytes: 18756
import java.util.*;

class Main
{
	public static void main(String args[]) {

		try {

			Scanner sc = new Scanner(System.in);

			int temp = Integer.parseInt(sc.next());

			int hou = temp/3600;
			int min = (temp/60) - (hou*60);
			int sec = temp - (hou*3600+min*60);

			System.out.println(hou +":"+ min +":"+ sec);
		}
		catch (Exception e) {
			System.out.println(e);
		}
	}
}

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


int main() {
	int H, W;
	cin >> H >> W;
	vector<string> grid(H);
	vector<int> row(0);
	vector<int> column(0);

	//入力情報の保存
	for (int i = 0; i < H; i++) {
			cin >> grid.at(i);
	}

	//#がある行および列は削除されないが、同時に処理するのはやや面倒
	//分けて考える

	//#が存在する行番号を配列rowに保存
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (grid.at(i).at(j) == '#') {
				row.push_back(i);
				break;
			}
		}
	}

	//#が存在する列番号を配列columnに保存
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			if (grid.at(j).at(i) == '#') {
				column.push_back(i);
				break;
			}
		}
	}

        //#が存在する行と列部分を出力
	for (int i : row) {
		for (int j : column) {
			cout << grid.at(i).at(j);
		}
		cout << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	int x, y; cin >> x >> y;
	if (x >= 0 == y >= 0) {
		if (x < y)cout << y - x << endl;
		else cout << x - y + 1 + (y != 0) << endl;
	}
	else {
		if (x < y) {
			if (abs(x) <= y)cout << y - abs(x) + 1 << endl;
			else cout << x * -1 - y + (y != 0) << endl;
		}
		else {
			cout << abs(abs(x) - abs(y)) + 1 << endl;
		}
	}
}

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

int main(){
  char s[2];
  cin >> s;
  int a=0;
  int i;
  for ( i=0; i<3; i++ )
  {
     if (s[i]=='1')
	{
          a++;
         }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 101;
int n,w;
ll weight[N],val[N];
ll dp[N][100001];
ll knapsack(ll w, int i){
    if(i<0)
        return 0;
    if(dp[i][w]!=-1)
        return dp[i][w];
    if(weight[i]>w){
        dp[i][w]=knapsack(w, i-1);
        return dp[i][w];
    }
    dp[i][w] = max(val[i]+knapsack(w-weight[i], i-1),knapsack(w, i-1));
    return dp[i][w];
}
int main(){
    cin>>n>>w;
    for(int i = 0; i < n; i++)
        scanf("%lld%lld",&weight[i],&val[i]);
    memset(dp, -1, sizeof(dp));
    printf("%lld",knapsack(w, n-1));
}


Measured memory_bytes: 82164
n=int(input())
s=[input() for _ in range(n)]
s.sort()
ans,be=[],""
cnt,maxcount=1,0

for i in range(n):
  if be==s[i]:
    cnt+=1
    
  else:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
      
      cnt=1
  be=s[i]
  if i==n-1:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
    
ans.sort()
for i in ans:
  if i!="":
    print(i)

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll temp=2*a[0];
    for(ll i=1;i<n-1;i++)
    {
        temp=(2*a[i])-temp;
    }
    ll x=temp+2*a[n-1];
    ll ans[n];
    memset(ans,0,sizeof(ans));
    ans[n-1]=x/2;
    for(ll i=0;i<n-1;i++)
    {
        if(i==0)
        {
            ans[i]=(2*a[n-1])-ans[n-1];
        }
        else
        {
            ans[i]=(2*a[i-1])-ans[i-1];
        }
    }
    for(ll i=0;i<n;i++)
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 2816