akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int sum = 0;
    if (a > b) {
      System.out.println(a + Math.max(a - 1, b));
    } else {
      System.out.println(b + Math.max(a, b - 1));
    }
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s,t;
    cin>>s>>t;
    int count = 0;
    priority_queue<int,vector<int>,greater<int>> pq;
    for(int i=0;i<s.size();i++){
          if(s.size() - i >= t.size()){
            count = 0;
            for(int k=i,j=0;j<t.size();k++,j++){
            if(s[k] != t[j]){
                count++;
            }
          }
          pq.push(count);
        }
        else{
            break;
        }
    }
    cout<<pq.top();
}



Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	int n,a,b;
	ll ans=0;
	cin>>n>>a>>b;
	cout<<min(a*n,b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double ans=0;
  for(int i=0;i<n;i++){
    double x;
    string u;
    cin>>x>>u;
    if(u=="JPY")ans+=x;
    else ans+=x*380000.0;
  }
  cout<<ans<<endl;
}

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

int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	double s = w * h / 2;
	printf("%.10f ", s);
	if (x * 2 == w && y * 2 == h)
	{
		cout << 1;
		return 0;
	}
	cout << 0;
	return 0;
}

Measured memory_bytes: 384
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
d = LIST()
m = INT()
t = LIST()
d.sort()
t.sort()
j = 0
for i in range(n):
    if(d[i]==t[j]):
        j += 1
    if(j == m):
        break
if(j == m):
    print("YES")
else:
    print("NO")

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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    map<string, int> mp = {
        {"AC", 0},
        {"WA", 0},
        {"TLE", 0},
        {"RE", 0}
    };
    
    for (int i = 0; i < N; i++) {
        string key;
        cin >> key;
        mp[key]++;
    }
    
    std::cout << "AC x " << mp["AC"] << endl;
    std::cout << "WA x " << mp["WA"] << endl;
    std::cout << "TLE x " << mp["TLE"] << endl;
    std::cout << "RE x " << mp["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3236
#include <iostream>

using namespace std;

int main()
{
  int x, y;
  cin >> x >> y;
  int g1[] = {1, 3, 5, 7, 8, 10, 12};
  int g2[] = {4, 6, 9, 11};
  int g3[] = {2};

  bool fx, fy;
  fx = false, fy = false;
  for (int i = 0; i < 7; i++) {
    if (g1[i] == x) fx = true;
    if (g1[i] == y) fy = true;
  }
  if (fx && fy) {
    cout << "Yes" << endl;
    return 0;
  }


  fx = false, fy = false;
  for (int i = 0; i < 4; i++) {
    if (g2[i] == x) fx = true;
    if (g2[i] == y) fy = true;
  }
  if (fx && fy) {
    cout << "Yes" << endl;
    return 0;
  }

  fx = false, fy = false;
  for (int i = 0; i < 1; i++) {
    if (g3[i] == x) fx = true;
    if (g3[i] == y) fy = true;
  }
  if (fx && fy) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))

#実家DPと気合い遷移式

def main():
    N = I()
    a = LI()
    t = [0, 0, 0]
    for ai in a:
        t[ai-1] += 1
    A, B, C = t
    E = B+C

    dp = [[0 if (not i|j) else N/(i+j) for j in range(E+1)] for i in range(N+1)]

    for k in range(C+1):
        for i in range(N+1):
            dp[i][E] = 0 if (not i|E|k) else N/(i+E+k)
        for j in range(E+1-k):
            for i in range(N+1-k-j):
                z = i+j+k
                if (not z):
                    continue
                d = dp[i][j]
                if (i<N):
                    dp[i+1][j] += (i+1)*d/(z+1)
                if (i>0)&(j<E):
                    dp[i-1][j+1] += (j+1)*d/z
                if (j>0)&(k<C):
                    dp[i][j-1] = (k+1)*d/z + N/z

    print(dp[A][B])

if __name__ == "__main__":
    main()


Measured memory_bytes: 42096
// atcoder/abc149/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli a, b, k;
  while (cin >> a >> b >> k) {
    lli mn = min(a, k);
    a -= mn;
    k -= mn;
    if (k) {
      b -= min(b, k);
    }
    cout << a << ' ' << b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    int X, ans = 1;
    cin >> X;

    for (int i=2; i<=X; ++i) {
        for (int j=2; ; ++j) {
            int p = (int)pow(i, j);
            if (p <= X) ans = max(ans, p);
            else break;
        }
    }

    cout << ans << endl;
}




Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,M,X,Y = inpl()
X = max(max(inpl()),X)
Y = min(min(inpl()),Y)
if X < Y:
    print("No War")
else:
    print("War")


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

int main(){
    int N;
    bool ans = true;
    cin >> N;
    vector<int>vec(N);
    for(int i=0;i<N;i++){
        cin >>vec[i];
    }
    for(int i=0;i<N-1;i++){
        if(vec[N-i-2]-vec[N-i-1] >=2){
            ans = false;
            break;
        }
        if(vec[N-i-2]-vec[N-i-1] ==1){
            vec[N-i-2]--;
        }
    }
    if(ans == true){
        cout << "Yes"<< endl;
    }
    if(ans == false){
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
import math
import sys
import os

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
MOD = 10 ** 9 + 7

N = I()
ans = 10**N%MOD-2*9**N%MOD+8**N%MOD


print(ans%MOD)

Measured memory_bytes: 10828
#include <iostream>
#define mod 1000000007
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	if(n-m >= 2 || m-n >= 2){
		cout << 0 << endl;
		return 0;
	}

	long long a, b;
	a = 1, b=1;
	for(int i=1; i<=n; i++){
		a *= i;
		a %= mod;
	}
	for(int i=1; i<=m; i++){
		b*= i;
		b %= mod;
	}
	a *= b;
	a %= mod;
	if(n==m){
		a *= 2;
		a %= mod;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val inf = 1e9.toLong() * 1e9.toLong()
    val (n, k) = readLine()!!.split(' ').let { it[0].toInt() to it[1].toLong() }
    val a = readLine()!!.split(' ').map { it.toLong() }.sorted().toLongArray()

    fun f(x: Long): Long {
        var cnt = 0L

        for (i in 0 until n) {
            var c = 0
            var l = i + 1
            var r = n - 1

            while (l <= r) {
                val m = (l + r) / 2

                if (a[i] < 0) {
                    if (a[i] * a[m] < x) {
                        r = m - 1
                        c = n - m
                    } else {
                        l = m + 1
                    }
                } else {
                    if (a[i] * a[m] < x) {
                        l = m + 1
                        c = m - i
                    } else {
                        r = m - 1
                    }
                }
            }

            cnt += c
        }

        return cnt
    }

    var ans = -inf
    var l = -inf
    var r = inf
    while (l <= r) {
        val m = (l + r) / 2
        if (f(m) < k) {
            ans = m
            l = m + 1
        } else {
            r = m - 1
        }
    }

    println(ans)
}


Measured memory_bytes: 85580
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll a[51] = {0};
ll p[51] = {0};

ll solve(ll N, ll X){
    if (X == 1) return N==0?1:0;

    if(1 < X and X <= (1 + a[N-1])) return solve(N-1, X-1);
    if(X == (2 + a[N-1])) return p[N-1] + 1;
    if(X > (2 + a[N-1]) and X <= (2 + 2 * a[N-1]))
        return p[N-1] + 1 + solve(N-1, X-2-a[N-1]);
    else
        return 2 * p[N-1] + 1;
}

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


    ll N, X;
    cin >> N >> X;

    a[0] = 1;
    p[0] = 1;
    FOR(i,1,51){
        a[i] = 2 * a[i-1] + 3;
        p[i] = 2 * p[i-1] + 1;
    }

    cout << solve(N,X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int64_t>A(N),B(N);;
  for(int i=0;i<N;i++){
    cin>>A[i];
    B[i]=A[i]-(i+1);
  }
  sort(B.begin(),B.end());
  int64_t b=B[N/2];
  int64_t sum=0;
  for(int i=0;i<N;i++){
    sum+=abs(A[i]-(i+1)-b);
  }
  cout<<sum<<endl;
  return 0;  
}

Measured memory_bytes: 6412
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll d[110][100010];
int n,m;
ll w[100010],v[100010];
ll res=0;
int main()
{
	cin >>n>>m;
	for (int i=1;i<=n;i++) cin >>w[i]>>v[i];
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=m;j++)
		{
			d[i][j]=d[i-1][j];
			if (w[i]<=j) d[i][j]=max(d[i][j],d[i-1][j-w[i]]+v[i]);
		}
	} 
	for (int i=0;i<=m;i++) res=max(res,d[n][i]);
	cout <<res;
	return 0;
}

Measured memory_bytes: 80128
mod = 1000000007

def sum_(a, b):
    return int((a+b)*(b-a+1)/2)

def main():
    args = input().rstrip().split(' ')
    N, K = int(args[0]), int(args[1])
    
    Ans = 0
    for i in range(K, N+2):
        sum_b = sum_(0, i-1)
        sum_u = sum_(N-i+1, N)
        Ans += (sum_u-sum_b)+1
        Ans = Ans % mod
    print(Ans)
    
if __name__ == "__main__":
    main()

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

struct RSQ_RUQ{
 UL N;
 struct Node{ LL x; LL s; bool z; };
 vector<Node> V;

 void init(UL n){
  N=1; while(N<n) N<<=1;
  V.assign(N*2,Node{0,0,true});
 }

 void upd(UL l,UL r,LL x,UL a=0,UL b=0,UL i=~0u){
  if(i==~0u){ a=0; i=1; b=N; }
  if(r<=a || b<=l) return;
  if(l<=a && b<=r){ V[i]={x,x*(b-a),true}; return; }
  if(V[i].z){
   V[i<<1] = V[(i<<1)+1] = {V[i].x,V[i].s/2,true};
  }
  upd(l,r,x,a,(b+a)>>1,i<<1);
  upd(l,r,x,(b+a)>>1,b,(i<<1)+1);
  V[i]={0,V[i<<1].s+V[(i<<1)+1].s,false};
 }

 LL sum(UL l,UL r,UL a=0,UL b=0,UL i=~0u){
  if(i==~0u){ a=0; i=1; b=N; }
  if(r<=a || b<=l) return 0;
  if(l<=a && b<=r) return V[i].s;
  if(V[i].z) return V[i].x*(min(r,b)-max(l,a));
  LL q1=sum(l,r,a,(b+a)>>1,i<<1);
  LL q2=sum(l,r,(b+a)>>1,b,(i<<1)+1);
  return q1+q2;
 }

} G;

int main(){
 UL N,Q; scanf("%u%u",&N,&Q);
 G.init(N);
 rep(q,Q){
  UL c; scanf("%u",&c);
  if(c==0){
   UL l,r; LL x; scanf("%u%u%lld",&l,&r,&x);
   G.upd(l,r+1,x);
  }
  if(c==1){
   UL l,r; scanf("%u%u",&l,&r);
   printf("%lld\n",G.sum(l,r+1));
  }
 }
 return 0;
}



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


int main() {
	int n; long long T, sum = 0;
	cin>>n>>T;
	vector<long long> t(n);
	for(int i = 0; i < n; i++) cin>>t[i];
	for(int i = 1; i < n; i++) {
		sum += min(T, t[i] - t[i-1]);
	}
	sum += T;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
import sys
n = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

array = factorization(n)
if array[0][0] == 1:
    print(0)
    sys.exit()
e_point = 1
count = 0
for i in range(len(array)):
    e = array[i][1]

    while e > 0:
        count += 1
        e -= e_point
        if e < 0:
            count -= 1
            break
        e_point += 1
    e_point = 1
print(count)

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

int main() {
    int K, S;
    cin >> K >> S;

    int counter = 0;
    for (int X = 0; X <= K; ++X) {
        for (int Y = 0; Y <= K; ++Y) {
            int Z = S - X - Y;
            if (Z >= 0 && Z <= K) ++counter;
        }
    }

    cout << counter << endl;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Dividing Chocolate
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 10;
const int MAX_W = 1000;
const int INF = 1 << 30;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

char ss[MAX_H][MAX_W + 4];
int css[MAX_H + 1][MAX_W + 1];
int ys[MAX_H + 1];

/* subroutines */

bool check(int yn, int x0, int x1, int k) {
  for (int i = 0; i < yn; i++) {
    int y0 = ys[i], y1 = ys[i + 1];
    if (css[y1][x1] - css[y1][x0] - css[y0][x1] + css[y0][x0] > k)
      return false;
  }
  return true;
}

/* main */

int main() {
  int h, w, k;
  scanf("%d%d%d", &h, &w, &k);

  for (int y = 0; y < h; y++) scanf("%s", ss[y]);

  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++)
      css[y + 1][x + 1] =
	(ss[y][x] - '0') + css[y + 1][x] + css[y][x + 1] - css[y][x];

  int minv = INF;
  int hbits = 1 << (h - 1);
  for (int bits = 0; bits < hbits; bits++) {
    int yn = 0;
    ys[yn++] = 0;
    for (int y = 1, bi = 1; y < h; y++, bi <<= 1)
      if (bits & bi) ys[yn++] = y;
    ys[yn] = h;
    //printf("bits=%d:", bits);
    //for (int i = 0; i <= yn; i++) printf(" %d", ys[i]); putchar('\n');

    int v = yn - 1;
    for (int x0 = 0; x0 < w;) {
      int x1 = x0;
      while (x1 < w && check(yn, x0, x1 + 1, k)) x1++;
      if (x0 == x1) {
	v = INF;
	break;
      }
      if (x1 < w) v++; //, printf("  x1=%d\n", x1);
      x0 = x1;
    }

    //printf("  v=%d\n", v);
    if (minv > v) minv = v;
  }

  printf("%d\n", minv);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int a[n+1]={};
    for(int i=0;i<m;i++)
    {
        int tmp;
        cin>>tmp;
        a[tmp]=1;
    }
    int ans1=0,ans2=0;
    for(int i=0;i<x;i++)
    {
        ans1+=a[i];
    }
    for(int i=x;i<=n;i++)
    {
        ans2+=a[i];
    }
    cout<<min(ans1,ans2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
static const long double pi = 3.141592653589793;

const int m = 10e6;
using namespace std;
ll ar[8005];
bool mark[8005];


int main() {
    Fast;

    int n,m,tst;
    string s;
    cin>>n>>m;
    cout<<n*m<<endl;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int par[100010];
int Rank[100010];

void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        Rank[i] = 1;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else{
        return par[x] = find(par[x]);
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

void unite(int x, int y){
    int rx = find(x), ry = find(y);
    if(rx != ry){
        if(Rank[rx] >= Rank[ry]){
            par[ry] = rx;
            if(Rank[rx] == Rank[ry]) Rank[rx]++;
        }else{
            par[rx] = ry;
        }
    }
}



int main(void){
    int N,M;
    cin >> N >> M;
    init(N);
    
    for(int i = 0; i < M; i++){
        int x,y,z;
        cin >> x >> y >> z;
        x--, y--;
        unite(x, y);
    }
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(i == par[i]) ans++;
    }
    cout << ans << endl;
    
    
    
    
}


Measured memory_bytes: 1024
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

signed main() {
	int n; cin >> n;
	vector<int> a(n);
	vector<int> b(n - 1);
	for (int i = 0; i < n - 1; ++i)
		cin >> b[i];

	a[0] = (int)1e9;
	for (int i = 0; i < n - 1; ++i) {
		a[i] = min(b[i], a[i]);
		a[i + 1] = b[i];
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i)
		ans += a[i];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define titititing break;
#define zty return
using namespace std;
bitset<4000000> dp;
int n,sum,x;
int main(){
	scanf("%d",&n);
	dp[0]=1;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		dp=dp|(dp << x);
		sum=sum+x;
	}
	for (int i=(sum+1)/2;i<=sum;i++){
		if (dp[i])
		{
			printf("%d\n",i);
			titititing;
		}
	}
	zty 0;
}

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

int main(){
  ll x;
  cin >> x;
  ll i=0;
  ll ans=100;
  while(x>ans){
    ans=ans*1.01;
    i++;
    // cout << ans << endl;
  }
  cout << i << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  string s;
  cin >> s;
  int ans = 0;
  int pnum = 0, gnum = 0;
  for(int i = 0; i < int(s.size()); i++){
    if(pnum == gnum){
      if(s[i] == 'p'){
        ans--;
        gnum++;
      }else{
        gnum++;
      }
    }
    else{
      if(s[i] == 'g'){
        ans++;
        pnum++;
      }else{
        pnum++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//
		int[][][] intRoom = new int[4][3][10];
		//n??¶????????±?????????
		int n = sc.nextInt();

		//2????????\????????????
		for(int i = 0; i < n; i++){
			//??´ b
			int intBuilding = sc.nextInt();
			//??? f
			int intFloor = sc.nextInt();
			//??¨?±? r
			int intRoomFirst = sc.nextInt();
			//?????° v
			int intPeople = sc.nextInt();
			//??\??????????????????????´?
			intRoom[intBuilding - 1][intFloor -1][intRoomFirst -1] += intPeople;
		}
		//??????
		for(int i = 0; i< 4; i++){
			for(int j = 0; j<3; j++){
				for(int k = 0; k< 10; k++){
					System.out.print(" " + intRoom[i][j][k]);
				}
				System.out.println(""); //??????
			}
			if(i != 3){
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 29048
import java.util.Scanner;

public class Main {

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

		int n=sc.nextInt();
		int t=sc.nextInt();
		int c[]=new int [n];
		int tl[]=new int [n];

		for(int i=0;i<n;i++){
			c[i]=sc.nextInt();
			tl[i]=sc.nextInt();
		}

		int min=10000;

		for(int i=0;i<n;i++){
			if(t>=tl[i]){
				if(min>c[i]){
					min=c[i];
				}
			}
		}

		if(min==10000){
			System.out.println("TLE");
		}else{
			System.out.println(min);

		}


	}

}


Measured memory_bytes: 21972
#include <iostream>
using namespace std;
 
int main() {
while(1){
	int n,m;
	cin >> n >> m;
	if(n == 0 & m == 0){break;}
	int *b = new int [n];
	for(int i = 0;i<n;i++){
		cin >> b[i];
	}
	int *c = new int [m];
	for(int i = 0;i < m;i++){
		cin>>c[i];
	}
	int a = 1;int count = 0;
	while(a<n){
		a = a+c[count];
		a = a+b[a-1];
		count++;
	}
	cout << count <<endl;
	delete[] b;
	delete[] c;
}
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

template <typename T>
T ceil(T a, T b){ return (a+b-1)/b; }


template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
class Solution {
    int  M = 3e9 + 7;
public:    
    Solution() {
        
    }
    void solve() {
        int n; cin>>n;
        int mx1 = -M, mn1 = M, mx2 = -M, mn2 = M;
        FOR(i, 0, n) {
            int x, y; cin>>x>>y;
            mx1 = max(mx1, x+y);
            mn1 = min(mn1, x+y);
            mx2 = max(mx2, x-y);
            mn2 = min(mn2, x-y);
        }
        cout<<max(abs(mx1-mn1), abs(mx2-mn2));
    }
};
// abs(x1 - x2) + abs(y1 - y2)   
// (x1 - x2) + (y1-y2)       -- both +ve
// (x1 + y1) - ( x2 + y2)    -- (1) 
// OR 
// -(x1 - x2) - (y1 - y2)    -- both -ve
// -x1 + x2 - y1 + y2        -- Same as (1) (?)
// OR
// x1 - x2 - y1 + y2         -- second -ve
// (x1 - y1) - (x2 - y2)     -- (2) 
// OR
// -x1 + x2 + y1 - y2
// -(x1 - y1) + (x2 - y2)    -- Same as (2) ()

void solve(){
    Solution sol;
    sol.solve();
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}

Measured memory_bytes: 3636
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
b=[x for x in a if "#" in x]  #1つでも#があれば、bにいれる　つまり全部...ならば除外される
c=zip(*[y for y in zip(*b) if "#" in y]) #zip(*)で転置行列になる！！！
for d in c:print("".join(d))

Measured memory_bytes: 3188
n=int(input())
arr=list(map(int,input().split()))
from collections import Counter
even=Counter(arr[::2])
even[0]=0
odd=Counter(arr[1::2])
odd[0]=0
even1,even2=even.most_common(2)
odd1,odd2=odd.most_common(2)
if even1[0]!=odd1[0]:
  print(n-(even1[1]+odd1[1]))
else:
  print(n-max(even1[1]+odd2[1],even2[1]+odd1[1]))


Measured memory_bytes: 18528
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	l := scanInts(n)
	sort.Ints(l)
	a := 0
	for i := 0; i < n; i++ {
		a += l[i]
	}
	for i := 0; i < n; i++ {
		if a <= l[i]*2 {
			fmt.Fprintln(wr, "No")
			return
		}
	}
	fmt.Fprintln(wr, "Yes")
}


Measured memory_bytes: 1784
import java.util.Scanner;

public class Main {
    public static boolean debug = true;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] input = new int[n-1];

        int sum = 0;

        for(int i=0; i<n-1;i++){
            input[i] = sc.nextInt();
        }

        if(n==2){
            System.out.println(input[0]*2);
            return;
        }


        int before = 0;
        for(int i=n-2; i>=0;i--){
            //d("input[" + i + "]=" + input[i]);
            if(i == n-2){
                sum += input[i];
                before = input[i];
            }else if(i !=0){
                sum += Math.min(input[i],before);
                before = input[i];
            }else{
                sum += Math.min(input[i],before);
                sum += input[i];
            }

        }

        System.out.println(sum);
        /*
        0 153 10 10 23
        0 0   10 10 10 23

        2 5
        2 2 5

        3
        3  3
         */


    }

    public static void d(String message){
        if(debug){
            System.out.println(message);
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;

#define MOD 998244353
ll modpow(ll e, ll x){
    if(0==e) return 0;
    ll r=1;
    rep(_, x){
        r *= e;
        r %= MOD;
    }
    return r;
}

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

    // solution comes here
    //各Diの値が何回出てきたか、が重要。つまりmapだ！！

    ll N, D;
    cin >> N >> D;

    if(D){
        cout << 0 << nl;
        return 0;
    }

    vl cntmap(N);//0で初期化されてるらしい
    ll M=0;
    cntmap[0]++;
    rep(_, N-1) {
        cin >> D;
        cntmap[D]++;
        M = max(M, D);
    }

    if(cntmap[0]>1){
        cout << 0 << nl;
        return 0;
    }

    ll ans=1;
    for(ll i=1; i<=M; i++) {
        ans *= modpow(cntmap[i-1], cntmap[i]);
        ans %= MOD;
    }

    cout << ans << nl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
namespace fuck
{
	typedef long long ll;
	const int N=100100,M=N*2;
	int begin[N],next[M],to[M];
	ll w[M],dis[N];
	int n,m,e,root;
	void add(int x,int y,ll z,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		w[e]=z;
		if(k)add(y,x,z,0);
	}
	void dfs(int p,int h=0)
	{
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
				dis[q]=dis[p]+w[i],dfs(q,p);
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,u,v,h;i<n;i++)
			scanf("%d%d%d",&u,&v,&h),add(u,v,h);
		scanf("%d%d",&m,&root);
		dfs(root);
	}
	void solve()
	{
		initialize();
		for(int u,v;m--;)
		{
			scanf("%d%d",&u,&v);
			printf("%lld\n",dis[u]+dis[v]);
		}
	}
}
int main()
{
	fuck::solve();
	return 0;
}


Measured memory_bytes: 10752
S = input()
T = input()
ans = float('inf')
for i2 in range(len(S)):
    if i2 + len(T) > len(S):
        break
    ans = min(ans, sum(S[i1] != T[i1 - i2] for i1 in range(i2, i2 + len(T))))
print(ans)


Measured memory_bytes: 9060
# Code for C - Guess The Number
# Use input() to fetch data from STDIN
import sys
[n, m] = [int(x) for x in input().split()]
s = []
c = []

for i in range(m):
    [x, y] = [int(x) for x in input().split()]
    s.append(x)
    c.append(y)

for x in range(1000):
    a = str(x)
    if len(a) != n:
        continue

    test = all([a[i - 1] == str(j) for i, j in zip(s, c)])
    if test:
        print(x)
        sys.exit()

print("-1")


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
   int H[10000],W[10000],i,j,x,y;
   for(i=0;i<10000;i++)
   {
       scanf("%d %d",&H[i],&W[i]);
       if(H[i]==0&&W[i]==0)
        break;
   }
   for(i=0;i<10000;i++)
   {
       if(H[i]==0&&W[i]==0)
       {
           break;
       }

       for(x=0;x<W[i];x++)
       {
       printf("#");
   }
   printf("\n");
   for(y=0;y<H[i]-2;y++)
   {
       printf("#");
       for(j=0;j<W[i]-2;j++)
       {
           printf(".");
        }
        printf("#");
        printf("\n");
    }
    for(x=0;x<W[i];x++)
    {
        printf("#");
    }
    printf("\n\n");
   }
   return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define maxn 10006
using namespace std;

typedef pair<int, int> P;

int n;

int main()
{
	cin >> n;
	int a = 0;
	int b = 0;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		if (x > a)
		{
			a = x;
			b = y;
		}
	}
	printf("%d", a + b);

	return 0;
}


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

int main() {
  string S;
  cin >> S;
  if(S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if(S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else if(S == "Rainy") {
    cout << "Sunny" << endl;
  }
  
}


Measured memory_bytes: 256
<?php
/*
    Problem URL : http://arc071.contest.atcoder.jp/tasks/arc071_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

$ans = "";

fscanf(STDIN, "%d", $n);

for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s", $S[$i]);
    for ($j = 0; $j < strlen($S[$i]); $j++) {
        $s = substr($S[$i], $j, 1);
        $sum[$i][$s]++;
    }
}
// var_dump($sum);
// exit;

$ch = ord('a');
for ($i = 0; $i < 26; $i++) {
    // echo "===" . chr($ch + $i) . PHP_EOL;
    for ($j = 0; $j < $n; $j++) {
        // echo "* {$j} " . chr($ch + $i) . PHP_EOL;
        if ($j == 0) {
            $mmin = $sum[$j][chr($ch + $i)];
            // echo $mmin . PHP_EOL;
        } else {
            $mmin = min($mmin, $sum[$j][chr($ch + $i)]);
        }
        // echo "mmin = " . $mmin . PHP_EOL;
    }
    $ans .= str_repeat(chr($ch + $i), $mmin);
}

echo $ans . PHP_EOL;


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++) cin >> L.at(i);

	int c = 0;

	for (int i = 0; i < N-2; i++) {
		for (int j = i + 1; j < N-1; j++) {
			if (L.at(i) != L.at(j)) {				
				for (int k = j + 1; k < N; k++) {
					if (L.at(i) != L.at(k)) {
						if (L.at(j) != L.at(k)) {
							int _max = max(L.at(i), L.at(j));
							_max = max(_max, L.at(k));
							int sum = L.at(i) + L.at(j) + L.at(k);
							if ( sum - _max > _max) {
								c++;
							}
						}
					}
				}
			}
		}
	}

	cout << c << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

struct edge { int to, cost; };

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

ll f[200010];
ll pm[200010];
ll pmf[200010];

void fuct(){
	f[0] = 1;
	for(int i = 1; i < 200010; i++){
		f[i] = f[i-1] * i % MOD;
	}
}

ll powz(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

void pow_mod(){
	for(int i = 0; i < 200010; i++){
		pm[i] = powz(i,MOD-2);
	}
	pmf[0] = 1;
	for(int i = 1; i < 200010; i++){
		pmf[i] = pmf[i-1] * pm[i] % MOD;
	}
}

int main()
{
	fuct();
	pow_mod();

	int h,w,a,b;
	cin >> h >> w >> a >> b;
	ll ans = 0;
	for(int i = 0; i < h-a; i++){
		ll x = f[i+b-1]*pmf[i]%MOD*pmf[b-1]%MOD;
		ll y = f[h-i+w-b-2]*pmf[h-i-1]%MOD*pmf[w-b-1]%MOD;
		ans += x * y % MOD;
		ans %= MOD;
	}

	cout << ans << endl;
	return 0;	
}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  int num;
  num = 100*r + 10*g + b;
  
  if (num % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    if(s[5]!='0')cout<<"TBD"<<endl;
    else{
        if(s[6]>'4')cout<<"TBD"<<endl;
        else {
            cout<<"Heisei"<<endl;
        }
    }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long
#define PI 3.14159265
int mod = 1000000009;
#define fi(i,start,end) for(int i=0; i<n; i++)
#define pb(x) push_back(x)
#define int long long
#define PI 3.14159265
#define all(v) v.begin(), v.end()
#define endl cout<<"\n" 
#define ll long long
#define dbg(x) cout<<#x<<" "<<x;endl;
#define bye endl;return
using namespace std;
template<typename T>



void debug(vector<T> x){
    for(auto e:x){
        cout<<e<<" ";
    }
    cout<<"\n";
}
/*
1
8 6
1 2 4 1 2 4 1 2

*/

void solve(){
    string s;
    cin>>s;
    int sum = 0;
    for(int i=0; i < (int)s.size(); i++){
        sum += (s[i] - '0');
    }
    if(sum%9==0){
        cout<<"Yes";bye;
    }else{
        cout<<"No";bye;
    }
    

}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1;;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3728
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var x = long.Parse(Console.ReadLine());
        long ans;
        long y = x / 11 * 2;
        long f = x % 11;
        if (f == 0) ans = y;
        else if (f > 6) ans = y + 2;
        else ans = y + 1;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
import sys
input = sys.stdin.readline
H, W, K = map(int, input().split())
mat = [[0]*W for i in range(H)]

for i in range(K):
    r, c, v = map(int, input().split())
    r, c = r-1, c-1
    mat[r][c] = v

dp0 = [[-1 for i in range(W)] for i in range(H)]
dp1 = [[-1 for i in range(W)] for i in range(H)]
dp2 = [[-1 for i in range(W)] for i in range(H)]
dp3 = [[-1 for i in range(W)] for i in range(H)]

dp0[0][0] = 0
if mat[0][0] != 0:
    dp1[0][0] = mat[0][0]

for i in range(H):
    for j in range(W):
        m = max(dp0[i][j], dp1[i][j], dp2[i][j], dp3[i][j])
        if i+1 < H:
            dp1[i+1][j] = max(dp1[i+1][j], m+mat[i+1][j])
            dp0[i+1][j] = max(dp0[i+1][j], m)
        if j+1 < W:
            dp0[i][j+1] = 0
            dp1[i][j+1] = max(dp1[i][j+1], dp1[i][j], dp0[i][j]+mat[i][j+1])
            dp2[i][j+1] = max(dp2[i][j+1], dp2[i][j], dp1[i][j]+mat[i][j+1])
            dp3[i][j+1] = max(dp3[i][j+1], dp3[i][j], dp2[i][j]+mat[i][j+1])

print(max(dp0[H-1][W-1], dp1[H-1][W-1], dp2[H-1][W-1], dp3[H-1][W-1]))


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

int n,d[200005];
map<int,int> m;

int main(){

  cin>>n;

  for(int i=0;i<n;i++){
    cin>>d[i];
    m[d[i]]++;
  }

  int M, T;

  bool ans=true;
  
  cin>>M;
  for(int i=0;i<M;i++){
    cin>>T;
    m[T]--;
    if(m[T]<0) ans=false;
  }

  if(ans)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 10368
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, p;

  cin >> n >> p;

  cout << n - p + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int N;
    cin >> N;
    vector<i64> cnt(N+1, 0), A(N);
    rep(i, N){
        cin >> A[i];
        cnt[A[i]]++;
    }

    i64 ans = 0;
    rep(i, N+1) ans += cnt[i]*(cnt[i] - 1) / 2;

    rep(i, N){
        cout << ans - cnt[A[i]]*(cnt[A[i]] - 1) / 2 + (cnt[A[i]] - 1) * (cnt[A[i]] - 2) / 2 << endl;
    }
}


Measured memory_bytes: 5760
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;

    if(a*b>c)cout<<c<<endl;
    else cout<<a*b<<endl;
    return 0;
}


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

using namespace std;

int main() {
    int x;
    cin >> x;
    for (int i = 1; i <= 360; i++) {
        if (x * i % 360 == 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


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

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;
	if(a + b < c)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
"""配列の再利用,numpyの利用の練習"""

from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))
import numpy as np

N,W= inpl()
WV = []
for _ in range(N):
    w_v = inpl()
    WV.append(w_v)

dp = np.full(W+1,0,dtype=np.int64)
for i in range(N):
    w = WV[i][0]
    v = WV[i][1]
    np.maximum(dp[w:],dp[:W+1-w]+v,out=dp[w:])

print(np.max(dp))


Measured memory_bytes: 14520
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
typedef vector<vector<int> > Matrix; //隣接行列
 
const int INF = 1000000000;
 
Matrix dist;
 
//trueなら負の閉路を検出
bool warshall_floyd(int n) { //nは頂点数
    for (int k = 0; k < n; k++) { //経由点
        for (int i = 0; i < n; i++) { //始点
            for (int j = 0; j < n; j++) { //終点
                if (dist[i][k] != INF && dist[k][j] != INF) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
    }
 
    //負の閉路を検出
    for (int i = 0; i < n; i++) {
        if (dist[i][i] < 0) return true;
    }
    return false;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    dist.resize(10, vector<int>(10, INF));
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> dist[i][j];
        }
    }
    warshall_floyd(10);
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int a;
            cin >> a;
            if (a == -1) continue;
            ans += dist[a][1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int MAXN = 1e5 + 7;
const long long INF = 1e18;

long long height = 0;
long long dp[MAXN];
long long h[MAXN];
int n, k;

long long rec(int idx)
{
    if (dp[idx] != -1)
        return dp[idx];
    if (idx == n - 1)
    {
        dp[idx] = 0;
        return dp[idx];
    }
    dp[idx] = INF;
    for (int i = 1; i <= k; i++)
    {
        if (idx + i <= (n - 1))
        {
            dp[idx] = min(dp[idx], rec(idx + i) + abs(h[idx + i] - h[idx]));
        }
    }
    return dp[idx];
}

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    for (int i = 0; i < n; i++)
        dp[i] = -1;
    cout << rec(0) << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#define LL long long
int main(){
	LL a,b,n,r;
	scanf("%lld%lld%lld",&a,&b,&n);
	if(n<b)r=n;
	else r=b-1;
	printf("%lld\n",r*a/b);
	return 0;
}

Measured memory_bytes: 1708
#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
typedef struct{
  int no,ptpt;
}P;
using namespace std;
int main(){
  string str;
  int n,cnt,score[21],s;

  while(1){
    cin >> n;
    if(n==0)break;
    P p[n];
    for(int l=0;l<n;l++){
      memset(score,0,sizeof(score));
      cin >> p[l].no;
      for(int i=0;i<18;i+=2){
	cin >> s;
	score[i] = s;
	if(s != 10){
	  cin >> s;
	  score[i+1]=s;
	}
      }
      cin >> score[18] >> score[19];
      if(score[18]+score[19]==10 || score[18]==10 || score[19]==10){
	cin >> s;
	score[20] = s;
      }
      int sum=0;
      for(int i=0;i<18;i+=2){
	if(score[i]==10){ //ストライク
	  sum += ((score[i+2]!=10||i==16) ? 10+score[i+2]+score[i+3] :
		  20+score[i+4]);
	} else if(score[i]+score[i+1]==10){ //スペア
	  sum += 10+score[i+2];
	}else 
	sum += score[i]+score[i+1];
      }
      p[l].ptpt = sum + score[18]+score[19]+score[20];
    }

    for(int i=0;i<n-1;i++){
      for(int j=n-1;j>i;j--){
	if(p[j].ptpt>p[j-1].ptpt){
	  swap(p[j],p[j-1]);
	}
      }
    }
    for(int i=0;i<n-1;i++){
      for(int j=n-1;j>i;j--){
	if(p[j].ptpt==p[j-1].ptpt&&p[j].no<p[j-1].no){
	  swap(p[j],p[j-1]);
	}
      }
    }
    for(int i=0;i<n;i++){
      cout << p[i].no << " " << p[i].ptpt << endl;
    }
  }   
}

Measured memory_bytes: 1160