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

long long nCr(int n, int r){
  if(r == 0) return 1;
  return nCr(n,r-1) * (n-(r-1)) / r;
}

int main(){

  int n,a,b;
  cin >> n >> a >> b;
  long long v[100];

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


  sort(v,v+n,greater<long long>());

  long long tmp = 0;
  for(int i = 0;i < a;i++){
    tmp += v[i];
  }

  printf("%.8lf\n",(double)tmp/(double)a);

  int cnt = 0;
  long long ans = 0;

  for(int i = 0;i < n;i++){
    if(v[0] == v[i]){
      cnt++;
    }
  }

  if(v[a] == v[0]){
    for(int i = a;i <= min(cnt,b);i++){
      ans += nCr(cnt,i);
    }
  }else{
    int cnt2 = 0;
    int tmp2 = 0;
    for(int i = 0;i < n;i++){
      if(v[a-1] == v[i]){
        cnt2++;
      }else if(v[a-1] < v[i]){
        tmp2++;
      }
    }
    ans = nCr(cnt2,a-tmp2);
  }

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



Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int main(int, char *[])
{
    int N;
    cin >> N;
    int prev_val = 0;
    int num_div = 0;
    enum e_st{ST_BEGIN, ST_UNKNOWN, ST_INC, ST_DEC} st = ST_BEGIN;
    for(int i = 0; i < N; ++i)
    {
        int v;
        cin >> v;
        switch(st)
        {
            case ST_BEGIN:
                ++num_div;
                st = ST_UNKNOWN;
                break;
            case ST_UNKNOWN:
                if(v > prev_val)
                    st = ST_INC;
                else if(v < prev_val)
                    st = ST_DEC;
                break;
            case ST_INC:
                if(v < prev_val)
                {
                    ++num_div;
                    st = ST_UNKNOWN;
                }
                break;
            case ST_DEC:
                if(v > prev_val)
                {
                    ++num_div;
                    st = ST_UNKNOWN;
                }
                break;
        }
        prev_val =v;
    }
    cout << num_div << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();

	string ans = "～";
	for (int i = 0; i <= n - m; i++) {
		bool x = true;
		string s1 = s;
		for (int j = 0; j < m; j++) {
			if (s[i + j] != '?' && s[i + j] != t[j])
				x = false;
			s1[i + j] = t[j];
		}
		if (x) {
			//ok1
			replace(s1.begin(),s1.end(), '?', 'a');
			ans = min(ans, s1);
		}
	}
	if (ans == "～")
		puts("UNRESTORABLE");
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

int main() {
    string s; cin >> s;

    ll sum = 0;
    bool f = true;
    for(int i = s.size() - 1; i >= 0; i--) {
        sum += s[i] -'0';

    }

    if (sum % 9)
    {
        f = false;
    }

    if(f) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3752
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int N;
vector<P> V[110000];
int color[110000];

void dfs(int x){
  for(int i=0;i<(int)V[x].size();i++){
    if(color[V[x][i].first]==-1){
      if(V[x][i].second==0){
        color[V[x][i].first]=color[x];
        dfs(V[x][i].first);
      }else{
        color[V[x][i].first]=color[x]^1;
        dfs(V[x][i].first);
      }
    } 
  }
}

int main(){
  for(int i=0;i<110000;i++) color[i]=-1;
  cin>>N;
  int u,v;
  ll w;
  for(int i=1;i<N;i++){
    cin>>u>>v>>w;
    V[u].push_back(P(v,w%2));
    V[v].push_back(P(u,w%2));
  }
  color[1]=0;
  dfs(1);
  for(int i=1;i<=N;i++) cout<<color[i]<<endl;
}


Measured memory_bytes: 8704
import itertools


def main():
    N = int(input())
    # testimony[i][y]: person list which i-th person says that is y (1: honest, 0: non-honest)
    testimony = [[[] for _ in range(2)] for _ in range(N)]
    for i in range(N):
        A = int(input())
        for _ in range(A):
            x, y = list(map(int, input().split(' ')))
            x -= 1
            testimony[i][y].append(x)
    # Check each honesty pattern
    max_honest = 0
    for pattern in itertools.product([0, 1], repeat=N):
        num_honest = sum(pattern)
        if max_honest > num_honest:
            continue
        is_valid = True
        for i, y in enumerate(pattern):
            # i-th person is y
            if y == 0:
                # skip testimony of non-honest person
                continue
            for yy in [0, 1]:
                ith_testimony = testimony[i][yy]
                for j in ith_testimony:
                    if pattern[j] != yy:
                        is_valid = False
                        break
                if not is_valid:
                    break
            if not is_valid:
                break
        if is_valid:
            max_honest = sum(pattern)
    print(max_honest)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
long long n, a[100005], ans = 1, m = 1e18;
int main()
{
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		if(a[i] == 0)
		{
			printf("0\n"); return 0;
		}
	}
	for(int i = 1; i <= n; i++)
	{
		ans *= a[i];
		m /= a[i];
		if(m <= 0) 
		{
			printf("-1\n");
			return 0;
		} 
	}
	
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 4544
package main
  
import (
    "fmt"
    "sort"
)

func main() {
    var n int
    fmt.Scan(&n)
    ds := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&ds[i])
    }
    sort.Sort(sort.IntSlice(ds))
    min, max := ds[n/2-1], ds[n/2]
    fmt.Println(max - min)
}


Measured memory_bytes: 5504
import java.util.Scanner

object Main {

  def main(args: Array[String]) {
    val sc = new Scanner(System.in)

    val a = sc.nextInt
    val b = sc.nextInt
    val c = sc.nextInt

    if (Set(a, b, c).toList.length == 2) println("Yes") else println("No")
  }
}

Measured memory_bytes: 25532
#include<iostream>
#include <stdio.h>
using namespace std;

int main()
{
  int h;
  int w;
  while(1){
    cin>>h>>w;
    if(h==0 && w==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(i==0 || j==0 || i==h-1 || j==w-1)
	  cout<<"#";
	else
	  cout<<".";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;  
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

namespace Math {
// Generic modular integer.
    template<int MOD, typename IntType = int>
    struct GModint {
        IntType val;

        GModint() : val(0) {}

        GModint(int v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        GModint(ll v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        explicit operator bool() const { return val != 0; }

        const bool operator==(const GModint &g) const { return val == g.val; }

        const bool operator!=(const GModint &g) const { return val != g.val; }

        const GModint operator+=(const GModint &g) { return *this = *this + g; }

        const GModint operator-=(const GModint &g) { return *this = *this - g; }

        const GModint operator*=(const GModint &g) { return *this = *this * g; }

        const GModint operator/=(const GModint &g) { return *this = *this / g; }

        const GModint operator^=(const GModint &g) { return *this = *this ^ g; }

        const GModint operator-() const { return GModint(val == 0 ? 0 : MOD - val, true); }

        const GModint operator+(const GModint &g) const {
            ll newval = val + g.val;
            if (newval >= MOD)
                newval -= MOD;
            return GModint(newval, true);
        }

        const GModint operator-(const GModint &g) const { return *this + (-g); }

        const GModint operator*(const GModint &g) const { return GModint(1ll * val * g.val); }

        const GModint operator/(const GModint &g) const { return *this * g.inv(); }

        template<class T>
        const GModint operator^(const T t) const { return GModint(modpow(val, t, MOD)); }

        const GModint inv() const { return GModint(modinv(val, MOD)); }
    };

    using Modint = GModint<1000000007>;
}

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

    int a, b, c; cin >> a >> b >> c;
    if ((a == b || b == c || a == c) && !(a == b && b == c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
using System;

namespace reidai01
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, r;

            string[] word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            r = c - (a - b);
            if (r < 0) r = 0;

            Console.WriteLine(r);

        }
    }
}


Measured memory_bytes: 27512
use std::collections::HashMap;
use std::io;

fn main() {
	let mut flag = true;
	
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let n: i32 = match iter.next().unwrap().parse(){
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let m: i32 = match iter.next().unwrap().parse(){
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	
	let mut map: HashMap<i32, i32> = HashMap::new();
	for num in 0..m {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let mut iter = buf.split_whitespace();
		let s = match iter.next().unwrap().parse(){
			Ok(n) => n,
			Err(_) => panic!(""),
		};
		let c = match iter.next().unwrap().parse(){
			Ok(n) => n,
			Err(_) => panic!(""),
		};
			
		match map.insert(s, c) {
			Some(n) => if n != c{
				flag = false;
			},
			None => (),
		}
			
	}
		
	if flag {
		let mut v: Vec<i32> = Vec::new();
		if n == 1 {
			match map.get(&1) {
				Some(n) => println!("{}", n ),
				None => println!("0"),
			}
		}else if n != 1 {
			match map.get(&1) {
				Some(&0) => {
					println!("-1");
				},
					
				Some(_) => {
					for number in 0..n {
						match map.get(&(number+1)){
							Some(n) => v.push(*n),
							None => v.push(0),
						}
					}
			
					for n in v {
						print!("{}", n);
					}
					print!("\n");
				},
									
				None => {
					v.push(1);
					for number in 1..n {
						match map.get(&(number+1)){
							Some(n) => v.push(*n),
							None => v.push(0),
						}
					}				
					for n in v {
						print!("{}", n);
					}
					print!("\n");
				}
			}
		}else{
			println!("-1");
		}
		
	}else{
		println!("-1");
	} 
	
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;
const double PI = 3.14159265359;

int main()
{
    string S, T; cin >> S >> T;
    int ans = 0;
    for (int i = 0, n = S.length(); i < n; ++i)
    {
        if (S[i] != T[i]) ++ans;
    }
    cout << ans << endl;
}


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

const int INFTY = (1 << 30);

int partition(pair<char, int> A[], int left, int right) {
  auto x = A[right];
  int i = left - 1;
  for (int j = left; j < right; j++) {
    if (A[j].second <= x.second) {
      i++;
      auto tmp = A[j];
      A[j] = A[i];
      A[i] = tmp;
    }
  }
  A[right] = A[i+1];
  A[i+1] = x;

  return i + 1;
}

void quickSort(pair<char, int> A[], int left, int right) {
  if (left < right) {
    int q = partition(A, left, right);
    quickSort(A, left, q-1);
    quickSort(A, q+1, right);
  }
}

void merge(pair<char, int> A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  pair<char, int> L[n1+1], R[n2+1];
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];

  L[n1] = make_pair('Z', INFTY);
  R[n2] = make_pair('Z', INFTY);
  int l_i {0}, r_i {0};

  for (int i = left; i < right; i++) {
    if (L[l_i].second <= R[r_i].second) {
      A[i] = L[l_i];
      l_i++;
    } else {
      A[i] = R[r_i];
      r_i++;
    }
  }
}

void mergeSort(pair<char, int> A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n;
  cin >> n;
  pair<char, int> A[n], B[n];
  int tmp_i;
  char tmp_c;
  for (int i = 0; i < n; i++) {
    cin >> tmp_c >> tmp_i;
    A[i] = make_pair(tmp_c, tmp_i);
    B[i] = A[i];
  }

  quickSort(A, 0, n-1);
  mergeSort(B, 0, n);

  bool is_stable = true;
  for (int i = 0; i < n; i++) {
    if (A[i].first != B[i].first) {
      is_stable = false;
      break;
    }
  }

  if (is_stable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  for (int i = 0; i < n; i++) {
    cout << A[i].first << " " << A[i].second << endl;
  }
  return 0;
}



Measured memory_bytes: 5400
/*https://atcoder.jp/contests/abc044/tasks/abc044_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	string w;
	cin >> w;
	for (int i = 0; i < w.size(); i++)
	{
		int count = 0;
		for (int j = 0; j <w.size(); j++)
		{
			if (w[i] == w[j])
				count++;
		}
		if (count % 2 != 0)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=2e5+10;

ll n,d;
pair<ll,ll> p[maxn];

int main(){
	cin>>n>>d;
	for(int i=0;i<n;i++) cin>>p[i].fst>>p[i].snd;
	int ans=0;
	for(int i=0;i<n;i++){
		ll now=p[i].fst*p[i].fst+p[i].snd*p[i].snd;
		ll dis=d*d;
		if(now<=dis) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if ((a*100+b*10+c)%4) NO;
  else YES;
  return 0;
}


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

using namespace std;

int main(){
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long> A(X), B(Y), C(Z);
    for (int i=0; i<X; i++){
        cin >> A.at(i);
    }
    for(int i=0; i<Y; i++){
        cin >> B.at(i);
    }
    for(int i=0; i<Z; i++){
        cin >> C.at(i);
    }

    
    vector<long> AplusB(X*Y);
    for(int i=0; i<X; i++){
        for(int j=0; j<Y; j++){
            AplusB.at(i*Y+j) = A.at(i)+B.at(j);
        }
    }

    sort(AplusB.begin(), AplusB.end(), greater<long>() );

    int T = min(K, X*Y);

    vector<long> AB(T);
    for(int i=0; i< T; i++){
        AB.at(i) = AplusB.at(i); 
    }

    vector<long> sum(T*Z);

    for(int i=0; i< T; i++){
        for(int j=0; j<Z; j++){
            sum.at(i*Z+j) =AB.at(i) + C.at(j);
        }
    }

    sort(sum.begin(), sum.end(), greater<long>() );

    for(int i=0; i<K; i++){
        cout << sum.at(i) << endl;
    }
}

Measured memory_bytes: 31616
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    
    rep(j, N) cin >> A.at(j);
    rep(j, N) cin >> B.at(j);
    rep(j, N) cin >> C.at(j);
    
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    rep(j, N) {
        ll i = lower_bound(A.begin(), A.end(), B.at(j)) - A.begin();
        ll k = C.end() - upper_bound(C.begin(), C.end(), B.at(j));
        ans += i * k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
// ABC 057 B - Checkpoints 
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;

struct coordinate{
public:
  int x;
  int y;
  int number;
};

void getMostNearDist(coordinate st, vector<coordinate> vc){
  int destCheckPoint;
  int min;

  for(int i=0 ; i<vc.size() ; i++){
    int tmpMin = abs(vc[i].x - st.x) + abs(vc[i].y - st.y);
    
    if(0 == i){
      min = tmpMin;
      destCheckPoint = vc[i].number;
    }
    else{
      if( tmpMin < min){
        min = tmpMin;
        destCheckPoint = vc[i].number;
      }
    }
  }
  cout << destCheckPoint << endl; 
}

int main(void){
  //input
  int n,m;
  cin >> n >> m;
 
  //initiallize students
  vector<coordinate> vs;
  for(int i=0; i<n ;i++){
    int x,y;
    cin >> x >> y;
    coordinate st;
    st.x = x; st.y = y;
    vs.push_back(st);
  }
  
  //initialize checkpoints
  vector<coordinate> vc;
  for(int i=0; i<m ;i++){
    int x,y;
    cin >> x >> y;
    coordinate cp;
    cp.x = x; cp.y = y;
    cp.number = i+1;
    vc.push_back(cp);
  }

  for(int i=0 ; i<vs.size() ; i++){
    getMostNearDist(vs[i],vc);
  }

  return 0;
}



Measured memory_bytes: 256
a = []
for i in range(5):
    a.append(int(input()))

ri = 0
r = 0
for i in range(5):
    if not a[i]%10==0:
        if r < 10 - a[i]%10:
            ri = i
            r = 10 - a[i]%10
res = 0
for i in range(5):
    if not i == ri:
        if a[i]%10==0:
            res += a[i]
        else:
            res += a[i] + 10 - a[i]%10

res += a[ri]
print(res)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
vector<int> lang[100010];

vector<int> g[200010];

bool used[200010];

void dfs(int v) {
    used[v] = true;
    int l = g[v].size();
    for (int i = 0; i < l; i++) {
        int j = g[v][i];
        if (!used[j]) {
            dfs(j);
        }
    }
}

bool solve() {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < lang[i].size(); j++) {
            g[i].push_back(n+lang[i][j]);
            g[n+lang[i][j]].push_back(i);
        }
    }
    memset(used, false, sizeof(used));
    dfs(0);
    for (int i = 0; i < n; i++) {
        if (!used[i])
            return false;
    }
    return true;
}

void input() {
    cin >> n >> m;
    int k, l;
    for (int i = 0; i < n; i++) {
        cin >> k;
        for (int j = 0; j < k; j++) {
            cin >> l;
            lang[i].push_back(l-1);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"YES":"NO") << endl;
}


Measured memory_bytes: 14208
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;


long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

int main(){
	int i, N;
	std::cin >> N;
	long long A, B, C, D, G, T;
	for (i = 0; i < N; i++) {
		std::cin >> A >> B >> C >> D;
		if (A < B || D < B) {
			std::cout << "No\n";
		}

		else if (C > B - 2) {
			std::cout << "Yes\n";
		}
		else if (D == B) {
			if (A%B < C) {
				std::cout << "Yes\n";
			}
			else {
				std::cout << "No\n";
			}
		}
		else {
			G = gcd(D, B);
			T = A % G;

			if (C < B-G + T) {
				std::cout << "No\n";
			}
			else {
				std::cout << "Yes\n";
			}
		}
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int B = N % 1000 / 100;
  int C = N % 100 / 10;
  if ((N / 1000 == B && B == C)||(B == C && C == N % 10))cout << "Yes" << endl;
  else 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;

int main() {
  int N; cin>>N;
  if(N == 1) cout << "Hello World" << endl;
  else{
    int a,b;cin>>a>>b;
    cout << a+b << endl;
  }
}

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

int main () {
    
    int n, k; cin >> n >> k;

    if(n % k > 0) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    } 
    
    return 0;
}

Measured memory_bytes: 256
# ABC 57, mB - checkpoints

def dist(x, y):
    return(abs(x[0]-y[0]) + abs(x[1]-y[1]))

n, m = [int(el) for el in input().split(' ')]
S = []
for i in range(n):
    a, b = input().split(' ')
    S.append((int(a), int(b)))

T = []
for i in range(m):
    c, d = input().split(' ')
    T.append((int(c), int(d)))


for i in range(n):
    D = []
    for j in range(m):
        D.append(dist(S[i], T[j]))
    print(D.index(min(D))+1)


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

void solve(){
	// code starts from here
	ll A,B,K;
	cin >> K >> A >> B;
	ll t = A/K + !(A%K == 0);
	if(t*K > B) cout << "NG" << endl;
	else cout << "OK" << endl;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


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

// UnionFind
struct UnionFind {
    vector<int> d;
    UnionFind(int n) : d(n, -1) {} // each node has "minus-size"
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (-d[x] < -d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
    int component() {
        set<int> S;
        rep(x,d.size()) S.insert(find(x));
        return S.size();
    }
};

int main() 
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> V;

    auto f = [&](int x) {
        UnionFind un(n);
        rep(i,m) {
            if (i == x) continue;
            un.unite(V[i].first, V[i].second);
        }
        return un.size(0) != n;
    };

    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        V.emplace_back(a,b);
    }

    int ans = 0;
    rep(i,m) {
        if(f(i)) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	int** left = new int*[N+2];
	int** right = new int*[N+2];

	for(int i = 0; i <= N+1; i++){
		left[i] = new int[N+2];
		right[i] = new int[N+2];
		for(int k = 0; k <= N+1; k++){
			left[i][k] = 0;
			right[i][k] = 0;
		}
	}

	int row,col,length;

	for(int loop = 0; loop < M; loop++){
		scanf("%d %d %d",&row,&col,&length);
		left[row][col]++;
		left[row+length+1][col]--;

		right[row][col+1]--;
		right[row+length+1][col+1+length+1]++;
	}

	int tmp_row,tmp_col;

	for(int row = 1; row <= N; row++){
		tmp_row = row;
		tmp_col = 1;

		while(tmp_row <= N && tmp_col <= N){
			tmp_row++;
			tmp_col++;

			right[tmp_row][tmp_col] += right[tmp_row-1][tmp_col-1];
		}
	}

	for(int col = 1; col <= N; col++){
		for(int row = col+1; row <= N; row++){
			left[row][col] += left[row-1][col];
		}
	}

	for(int row = 1; row <= N; row++){
		for(int col = 1; col <= row; col++){
			left[row][col] += right[row][col];
		}
	}

	for(int row = 1; row <= N; row++){
		for(int col = 1; col <= row; col++){
			left[row][col] += left[row][col-1];
		}
	}

	int ans = 0;

	for(int row = 1; row <= N; row++){
		for(int col = 1; col <= row; col++){
			if(left[row][col] > 0){
				ans++;
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 198852
#include <stdio.h>

int main(int argc, const char * argv[])
{

    int input;
    int cnt = 0;
    int i, j;
    
    while (scanf("%d", &input) != EOF) {
        for (i = input - 1; 1 < input; i--) {
            for (j = 2; j <= i; j++) {
                if (i == j) {
                    cnt++;
                    break;
                }
                else if (i % j == 0) {
                    break;
                }
            }
            if (cnt == 1) {
                printf("%d ", i);
                break;
            }
        }
        cnt = 0;
        for (i = input + 1; i <= 100000; i++) {
            for (j = 2; j <= i; j++) {
                if (i == j) {
                    cnt++;
                    break;
                }
                else if (i % j == 0) {
                    break;
                }
            }
            if (cnt == 1) {
                printf("%d\n", i);
                break;
            }
        }
        cnt = 0;
    }
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n, m;
  cin >> n >> m;

  vector<int> cnt(100);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    ++cnt[a];
    ++cnt[b];
  }

  reps(i, 1, n) {
    cout << cnt[i] << "\n";
  }

  return 0;
}

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

using namespace std;
int aa[4]={300000,200000,100000,0};

int main() {
  int a,b;
  cin>>a>>b;if(a>=4){a=4;}if(b>=4){b=4;}
  a--;b--;
  int ans=0;
  ans+=aa[a];
  ans+=aa[b];
 if(a==b&&a==0){
     ans+= 
400000;}
cout<<ans;
}

Measured memory_bytes: 3600
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve_(uvs: Vec<(i64, i64)>, ds: Vec<i64>) -> Vec<String> {
    let mut ans = Vec::new();

    let dir = [['R', 'U'], ['D', 'L']];

    for (u,v) in uvs {
        let mut cu = 0;
        let mut cv = 0;

        let mut s = String::new();
        for &d in ds.iter() {
            let ud = if cu < u { cu += d; 0} else { cu -= d; 1};
            let vd = if cv < v { cv += d; 0} else { cv -= d; 1};
            s.push(dir[ud][vd]);
        }
        ans.push(s);
    }

    ans
}

fn solve(xys: Vec<(i64, i64)>) -> Option<(Vec<i64>, Vec<String>)> {
    let parity = (xys[0].0 + xys[0].1).abs() % 2;
    let mut uvs = Vec::new();
    for &(x, y) in xys.iter() {
        if (x+y).abs() % 2 != parity {
            return None
        }
        uvs.push((x+y, x-y));
    }

    let mut ds = Vec::new();

    for i in (0..31).rev() {
        ds.push(2i64.pow(i));
    }

    if parity == 0 {
        ds.push(1);
    }

    Some((ds.clone(), solve_(uvs, ds)))
}

fn main() {
    let n = parse_line!(usize);
    let xys = (0..n).map(|_| parse_line!(i64, i64)).collect::<Vec<_>>();

    match solve(xys) {
        Some((ds, ws)) => {
            println!("{}", ds.len());
            println!("{}", ds.iter().map(|d| format!("{}", d)).collect::<Vec<_>>().join(" "));
            for w in ws { println!("{}", w); }
        },
        _ => {
            println!("-1");
        }
    }
}

#[test]
fn solve_test() {
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  int count = a-1;
  if(b>=a)
  {
    cout << a << endl;
  }
  else
  {
    cout << a-1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>

using namespace std;

struct Node{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
	
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while(x != NIL){
		y = x;
		if(z->key < x->key){
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	
	if(y == NIL){
		root = z;
	} else {
		if(z->key < y->key){
			y->left = z;
		} else {
			y->right = z;
		}
	}

}

void inorder(Node *u){

	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);

}

void preorder(Node *u){

	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);

}

int main(){

	int n, i, x;
	string com;
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++){
		cin >> com;
		if(com == "insert"){
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	
	return 0;

}



Measured memory_bytes: 26636
using System;
//using System.Collections;
//using System.Collections.Generic;
using System.Linq;

namespace problem
{
    class Test
    {
        static void Main()
        {
            string[] x = Console.ReadLine().Split(' ');
            int[] a = x.Select(c => int.Parse(c)).ToArray();
            Console.WriteLine(a[0] * a[1] + " " + (a[0] + a[1]) * 2);
        }
    }
}


Measured memory_bytes: 9632
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, d, N = map(int, read().split())

b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)

q, r = divmod(N, 2)
x = q * d + r * c
print(x)

Measured memory_bytes: 9108
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef vector < long long > vll;
typedef pair <long long, long long> pll;
typedef pair <int, int> pii;
typedef vector < int > vii;
typedef complex < double > Point;

#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mp make_pair
#define fst first
#define snd second

ll t, n, m, u, v, q, r, ql, qr, k, l, s, w, z, x, y, d, p, c, L, b;
const int N = 1e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 52LL;
string str;
int a[N];
int main() {
    csl;
    cin >> str >> k;
    for (int i = 0; i < str.size(); ++i) {
        if (str[i] == 'a') continue;
        if ('z' - str[i] + 1 <= k) {
            k -= ('z' - str[i] + 1);
            str[i] = 'a';
        }
    }
    k %= 26;
    str[str.size() - 1] += k;
    if (str[str.size() - 1] > 'z') str[str.size() - 1] -= 'z';
    cout << str << '\n';
    return 0;
}










Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;

void zz(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

int32_t main(){
zz();
int n;cin>>n;
while(n){
  int x=n%10;
  n/=10;
  if(x==7){cout<<"Yes"<<endl;return 0;}
}
cout<<"No"<<endl;

}

Measured memory_bytes: 3648
#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;
using P = pair<ull, int>;

int main() {
    int N, M;
    cin >> N >> M;
    vector<ull> A(N);
    vector<P> V(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> V[i].second >> V[i].first;
    sort(A.begin(), A.end());
    sort(V.begin(), V.end());
    int now = M - 1;          //現在位置
    int time = V[now].second; //使用回数

    for(int i = 0; i < N; i++) {
        // cout << A[i] << " ";
        if(V[now].first > A[i]) {
            A[i] = V[now].first;
            time--;
        }
        if(time == 0) {
            now--; //現在位置更新
            if(now < 0) {
                break;
            }
            time = V[now].second;
        }
    }
    ull sum = 0;
    rep(i, N) {
        // cout << A[i] << " " << endl;
        sum += A[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 5640
#include <iostream>
#include <cstring>
using namespace std;
const int N=2e5+10;
char str[N];

int main()
{
    cin>>str;
    int n=strlen(str);
    int ans=0;
    for(int i=0;i<n;i++){
        if(str[i]=='?')str[i]='D';
    }
    cout<<str<<endl;
}

Measured memory_bytes: 3864
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC 9(12).
       01  a2 PIC 9(12).
       01  a3 PIC 9(12).
       01  r pic 9(12).
       01  g pic 9(12).
       01 disp pic Z(10)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1 a2 a3.
        compute r = a1 * a2


         IF r > a3 THEN
          MOVE FUNCTION TRIM(a3) to disp
          DISPLAY disp
         ELSE
          MOVE FUNCTION TRIM(r) to disp
          DISPLAY disp
         END-IF


       STOP RUN.


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

int main() {
	int a,b,c,d,e;
  	string s;
    cin>>a>>s;
  b = s.size();
  for(int i=0;i<b;i++){
int x=s.at(i)-'A';
 x=(x+a)%26;
 putchar('A'+x);
  }
  cout<<endl;
 
 
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
 
int main(){
         ios::sync_with_stdio(false);    
        cin.tie(0);
        int n, m;
        
        cin>>n>>m;
        cout<<n*(n-1)/2+m*(m-1)/2;
       
        return 0;
 
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := r()

	ans := 1
	ah := r()
	xh := 0
	var ai, xi int
	for i := 1; i < n; i++ {
		ai = r()
		switch {
		case ah < ai:
			xi = 1
		case ah > ai:
			xi = -1
		default:
			xi = 0
		}
		if (xh == 1 && xi == -1) || (xh == -1 && xi == 1) {
			ans++
			xh = 0
		} else if xi != 0 {
			xh = xi
		}
		ah = ai
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
from sys import stdin
import math
# 1行だけ読むやつ

N = int(stdin.readline().rstrip().split()[0])
Sum = 0

for i in range(1, N+1):
    for j in range(i, N+1):
        for k in range(j, N+1):
            if i == j and j == k:
                Sum += i
            elif i == j or j == k or k == i:
                temp_gcd = math.gcd(i, j)
                Sum += (math.gcd(temp_gcd, k) * 3)
            else:
                Sum += (math.gcd(temp_gcd, k) * 6) 

print(Sum)

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

using ll=long long;



void solve(){
    string s;
    cin>>s;
    for(int i=0; i<3; i++){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return;
        }
    }
    cout<<"Good"<<endl;
}

signed main(){
    //while(1)
    solve();
}

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

int main(){
  int x;
  cin >> x;
  int p[int(2e5+1)]={};
  for(int i=2;i<=2e5;i++){
    int k=1;
    while(i*k<=2e5){
      p[i*k]++;
      k++;
    }
  }
  for(int i=2;i<=2e5;i++){
    if(p[i]==1&&x<=i){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
typedef long long ll;

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int sum = 1;
    for(int i = 0; i < n; i++)
    {
        int ok = sum*2;
        if(sum*2-sum < k)sum = sum*2;
        else sum = sum+k;
    }
    cout << sum << endl;
    return 0;
}


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


void solve(long long H, long long W, long long h, long long w){
	printf("%d\n", (H-h)*(W-w));
}

// 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)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long h;
    scanf("%lld",&h);
    long long w;
    scanf("%lld",&w);
    solve(H, W, h, w);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define TABLESIZE 3 //おまけでテーブルの可変化を実装
#define INPUTSIZE 3
#define BUFFSIZE INPUTSIZE*(INPUTSIZE+1)+1

int main() {
	//変数宣言。tblでマップフィールドを表現
	int i, j;
	int tbl[TABLESIZE][TABLESIZE];
	char buff[BUFFSIZE];

	//データ入力受付
	for (i = 0; i < TABLESIZE; i++) {
		fgets(buff, BUFFSIZE, stdin);
		sscanf(buff, "%d %d %d", &tbl[i][0], &tbl[i][1], &tbl[i][2]);
	}

	//一致の条件は(a(i)+b(j))-(a(i+1)+b(j))と
	//(a(i)+b(j+1))-(a(i+1)+b(j+1))を比較すれば求められるから以下の通りになる
	for (i = 0; i < TABLESIZE - 1; i++) {
		for (j = 0; j < TABLESIZE - 1; j++) {
			//条件を満たせなければ失敗とみなして終了する
			if (tbl[i][j] - tbl[i + 1][j] != tbl[i][j + 1] - tbl[i + 1][j + 1]) {
				printf("No\n");
				goto EndFanction;
			}
		}
	}
	printf("Yes\n");

EndFanction:
	return 0;
}

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

using namespace std;

int main() {

	int N,M,aux;
	scanf("%d %d", &N, &M);
	multiset < int> vet;

	for (int i = 0;i < N;i++){
		scanf("%d", &aux);
		vet.insert(aux);
	}

	for (int i = 0;i < M;i++) {
		int a = *vet.rbegin();
		vet.erase(vet.find(a));
		a = a/2;
		vet.insert(a);

	}
	long long res=0;
	for (auto i = vet.begin();i != vet.end();i++)
		res +=  *i;
	printf("%lld\n", res);
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int D;
	while (cin >> D) {
		int ans = 0;
		int now = 0;
		while (1) {
			now += D;
			if (now == 600) {
				cout << ans << endl;
				break;
			}
			else {
				ans += D * now * now;
			}
		}
	}
}


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

int main() {
  char N[1];
  scanf("%s" ,&N) ;

  if ( N[0] == N[1] && N[1] == N[2]|| N[1] == N[2] && N[2] == N[3] ) {
    puts("Yes" );
  }
  
  else puts("No") ;
}


Measured memory_bytes: 256
n = int(input())
lst = [int(i) for i in input().split()]

lst[0] -=1
for i in range(1,len(lst)):
    if (lst[i-1] != lst[i]) or (lst[i-1] > lst[i]):
        lst[i] -= 1

flag = 0
for i in range(len(lst)-1):
    if (lst[i] <= lst[i + 1]) & (flag==0):
        flag = 0
    else:
        flag = 1

if len(lst) == 1:
    flag = 1


if flag == 0:
    print('Yes')
else:
    if len(lst) == 1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14396
// input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>()
           };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        _c: i64,
        k: i64,
    }

    if a >= k {
        println!("{}", k);
    } else if (a + b) >= k {
        println!("{}", a);
    } else {
        println!("{}", a - (k - a - b));
    }
}


Measured memory_bytes: 2108
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    a = [I() for i in range(n)]
    b = [1] + [0]*(n-1)
    cnt = 0
    j = 0
    for i in range(n):
        b[j] = 0
        b[a[j]-1] = 1
        j = a[j]-1
        cnt += 1
        #print(j,a[j]-1,b)
        if b[1] == 1:
            print(cnt)
            exit()
    print(-1)

Measured memory_bytes: 14596