akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
using ll = long long;
using P = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;

const int mod = 1000000007;
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint f(int n){ 
  if(n == 0)return 1;
  mint x = f(n / 2); 
  x *= x; 
  if(n % 2 == 1)x *= 2;
  return x;
}

mint choose(int n, int a){
  mint x = 1, y = 1;
  for(int i = 0; i < a; ++i){
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

mint fact[200200];
mint inv_fact[200200];
void init(){
	fact[0] = 1;
	for(int i = 1; i < 200200; ++i){
		fact[i] = fact[i - 1] * i;
	}

	inv_fact[200200 - 1] = fact[200200 - 1].inv();
	for(int i = 200200 - 1; i >= 1; --i){
		inv_fact[i - 1] = inv_fact[i] * i;
	}
}

mint comb(ll n, ll k){
	if(n < k)return 0;
	else return fact[n] * inv_fact[n - k] * inv_fact[k];
}

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

int main(){
  init();
  int n;
  cin >> n;
  map<pll, P> mp;
  mint zero_cnt = 0;
  for(int i = 0; i < n; ++i){
    ll a, b;
  	cin >> a >> b;
    if(a == 0 && b == 0){
      zero_cnt += 1;
      continue;
    }
    ll g = gcd(a, b);
    a /= g;
    b /= g;
    if((b < 0) || (b == 0 && a < 0)){
      a = -a;
      b = -b;
    }
    if(a <= 0){
      swap(a, b);
      b = -b;
      ++mp[{a, b}].first;
    }
    else ++mp[{a, b}].second;
  }

  mint ans = 1;
  for(auto m : mp){
    int s = m.second.first;
    int t = m.second.second;
    mint cur = 1;
    cur += f(s) - 1;
    cur += f(t) - 1;
    ans *= cur;
  }

  ans += zero_cnt;
  ans -= 1;
  cout << ans.x << endl;
  return 0;
}


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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a[N];
map<pair<int,int>,int>mp;
ll ans[N];
vector<vector<ll>>adj;
int n,q;
ll dp[N];
ll pos[N],val[N];
void dfs(ll parent,ll cur){
    if(parent!=-1)
        ans[cur]=ans[parent]+dp[cur];
    for(int i=0;i<adj[cur].size();i++){
        ll child = adj[cur][i];
            if(child!=parent)
            dfs(cur,child);
    }
}
int main() {
    scanf("%d%d",&n,&q);
    adj= vector<vector<ll>>(n);
    ll from,to;
    for(int i=0;i<n-1;i++){
        scanf("%lld%lld",&from,&to);
        from--;
        to--;
        adj[from].push_back(to);
        adj[to].push_back(from);
    }
    for(int i=0;i<q;i++){
        scanf("%lld%lld",&pos[i],&val[i]);
        pos[i]--;
    }
    for(int i=0;i<q;i++){
        dp[pos[i]]+=val[i];
    }
    ans[0]=dp[0];
    dfs(-1,0);
    for(int i=0;i<n;i++){
        printf("%lld ",ans[i]);
    }
//	#   ifdef LOCAL_PROJECT
//        freopen("in.txt", "r", stdin);
//    #   endif
//    int n;
//    scanf("%d",&n);
//    int start=0,end=1;
//    int ans=0;
//    int cnt =0,pre,cur;
//    scanf("%d",&pre);
//    for(int i=1;i<n;i++){
//        scanf("%d",&cur);
//        if(pre>=cur){cnt++;ans = max(ans,cnt);}
//        else cnt=0;
//        pre= cur;
//    }
//    printf("%d",ans);

//    int n,k,q;
//    int ans ;
//    scanf("%d%d%d",&n,&k,&q);
//    for(int i=1;i<=n;i++){
//        mp[{i,k}]=k;
//    }
//    for(int i=1;i<=q;i++){
//        scanf("%d",&ans);
//        mp[{ans,k}]++;
//    }
//    for(int i=1;i<=n;i++){
//        if(mp[{i,k}]-q>0)puts("Yes");
//        else puts("No");
//    }
    return 0;
}


Measured memory_bytes: 36352
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	int N;
	cin >> N;
	int a[N+10],go=0,color[8]={0,0,0,0,0,0,0,0},sum=0;
	for(int i=0; i<N; i++){
		cin >> a[i];
		if(a[i]/400 < 8){
			color[a[i]/400]+=1;
		}else{
			go+=1;
		}
	}for(int i=0; i<8; i++){
		if(color[i] != 0){
			sum+=1;
		}
	}
	if(sum!=0){
		cout << sum << ' ' << sum+go << endl;
	}else{
		cout << '1' << ' ' << sum+go << endl;
	}
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;
use std::cmp;


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

    let x = a + b;
    let mut ans = String::from("IMPOSSIBLE");
    if x % 2 == 0 {
        ans = (x / 2).to_string();
    }
   
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

int main(void){
  char N[51];
  int i;

  scanf("%s" ,N);

    if( N[0] ==  N[strlen(N)-1] ){
      printf("%c\n",N[0]);
    } else{
      printf("o\n");
  }
    return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='A')
        a++;
        else
        b++;
    }
    if((a==3)||(b==3))
    cout<<"No";
    else
    cout<<"Yes";
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

def SCC(E):
    n = len(E)
    rev = [[] for _ in range(n)]
    for v in range(n):
        for nv in E[v]:
            rev[nv].append(v)

    used = [0] * n
    order = []
    for v in range(n):
        if used[v]:
            continue
        stack = [~v, v]
        while stack:
            v = stack.pop()
            if v >= 0:
                if used[v]:
                    continue
                used[v] = 1
                for nv in E[v]:
                    if not used[nv]:
                        stack.append(~nv)
                        stack.append(nv)
            else:
                if used[~v] == 2:
                    continue
                used[~v] = 2
                order.append(~v)

    cnt = 0
    color = [-1] * n
    for v in order[::-1]:
        if color[v] != -1:
            continue
        color[v] = cnt
        queue = [v]
        for v in queue:
            for nv in rev[v]:
                if color[nv] == -1:
                    color[nv] = cnt
                    queue.append(nv)
        cnt += 1
    return color

from bisect import bisect_left, bisect_right
def resolve():
    n = int(input())
    ZI = []
    for i in range(n):
        x, y = map(int, input().split())
        ZI.append((x, i)), ZI.append((y, i))
    ZI.sort()

    pair = [[] for _ in range(n)]
    for i, p in enumerate(ZI):
        pair[p[1]].append(i)
    Z = [p[0] for p in ZI]
    n *= 2
    n2 = n * 2

    def check(d):
        N = 1 << (n2 - 1).bit_length()
        E = [[] for _ in range(N * 2)]
        for i in range(N - 1, 0, -1):
            E[i].append(i << 1)
            E[i].append(i << 1 | 1)

        for u, v in pair:
            E[u + N].append(v + n + N)
            E[u + n + N].append(v + N)
            E[v + N].append(u + n + N)
            E[v + n + N].append(u + N)

        for i, z in enumerate(Z):
            L = bisect_right(Z, z - d)
            R = bisect_left(Z, z + d)
            for l, r in [(L + n, i + n), (i + 1 + n, R + n)]:
                l += N
                r += N
                while l < r:
                    if l & 1:
                        E[i + N].append(l)
                        l += 1
                    if r & 1:
                        r -= 1
                        E[i + N].append(r)

                    l >>= 1
                    r >>= 1

        res = SCC(E)
        return all(res[i + N] != res[i + n + N] for i in range(n))

    l = 0
    r = max(Z)
    while r - l > 1:
        m = (l + r) // 2
        if check(m):
            l = m
        else:
            r = m
    print(l)
resolve()

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

int main() {
    ll A, B, C, K, ans = 0;
    cin >> A >> B >> C >> K;
    ans += min(K, A);
    K -= A;
    if (K > 0) {
        K -= B;
    }
    if (K > 0) {
        ans -= min(C, K);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
A,B,K = map(int, input().split())

giveA = int(A/2)
giveB = int(B/2)
for i in range(K):
    if i%2 == 0:
        giveA = int(A/2)
        A = giveA
        B += giveA
    else:
        giveB = int(B/2)
        B = giveB
        A += giveB

print(A,B)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    ll A;
    double B;
    cin >> A >> B;

    ll res = B * 100+0.0001;

    cout << A * res / 100 << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

class IcedTea{
public:
  long long getMinCost(int q, int h, int s, int d, int n){
    long long retC = 0LL;
    retC = get2C(q,h,s,d,n);
    n%=2;
    retC += get1C(q,h,s,d,n);
    return retC;
  }

  long long get2C(int q, int h, int s, int d, int n){
    long long n2Bot = n/2;
    long long cost2 = d*n2Bot;
    long long cost1 = 2LL*s*n2Bot;
    long long costPt5 = 4LL*h*n2Bot;
    long long costPt25 = 8LL*q*n2Bot;
    long long retC = cost2;
    retC = min(retC,cost1);
    retC = min(retC,costPt5);
    retC = min(retC,costPt25);    
    return retC;
  }

  long long get1C(int q, int h, int s, int d, int n){
    long long nBot = n;
    //n should be 1
    //    long long cost2 = d*n;
    long long cost1 = s*n;
    long long costPt5 = 2LL*h*n;
    long long costPt25 = 4LL*q*n;
    long long retC = cost1;
    //    retC = min(retC,cost1);
    retC = min(retC,costPt5);
    retC = min(retC,costPt25);        
    return retC;
  }
};

vector<string>split(string s, char delim){
  int len = s.length();
  string currStr = "";
  vector<string>retVec;
  for(int i = 0;i<len;i++){
    char ch = s[i];
    if(ch==delim){
      retVec.push_back(currStr);
      currStr = "";
    }else{
      currStr += ch;
    }
  }
  retVec.push_back(currStr);
  return retVec;
}


vector<string>strToStrVec(string s){
  int len = s.length();
  s = s.substr(1,len-2);
  vector<string>strVec = split(s,',');
  return strVec;
}

vector<int>strToIntVec(string s){
  int len = s.length();
  //  s = s.substr(1,len-2);
  vector<string>strVec = split(s,' ');
  vector<int>retVec;
  for(int i=0;i<strVec.size();i++){
    int el = atoi(strVec[i].c_str());
    retVec.push_back(el);
  }
  return retVec;
}

int main(int argc, const char*argv[]){
  string qhsdLn, nLn;
  getline(cin,qhsdLn);
  getline(cin,nLn);
  vector<int>qhsdVec = strToIntVec(qhsdLn);
  int q = qhsdVec[0];
  int h = qhsdVec[1];
  int s = qhsdVec[2];
  int d = qhsdVec[3];  
  int n = atoi(nLn.c_str());
  IcedTea it;
  long long minCost = it.getMinCost(q,h,s,d,n);
  cout<<minCost<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX = 1e5;

struct UnionFind {
    vector<ll> par,rank,cnt; // par[i]:iの親の番号,rank[r]:rを根とする木の高さ,cnt[r]:rを根とする木の要素数

    UnionFind(ll N){ //全て根として初期化
        for(ll i = 0; i < N; i++) par.push_back(i);
        rank.assign(N,0);
        cnt.assign(N,1);
    }

    ll root(ll x){ // xの根を返す
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x,ll y){ // xの木とyの木を併合
        ll rx = root(x); 
        ll ry = root(y);
        if (rx == ry) return;

        if(rank[rx] < rank[ry]){
            par[rx] = ry;
            cnt[ry] += cnt[rx]; 
        }else{
            par[ry] = rx;
            cnt[rx] += cnt[ry];
            if(rank[x] == rank[y]) rank[rx] ++;
        }
    }

    ll tsize(ll x){ //　xの木の要素数を返す
        ll rx = root(x);
        return cnt[rx];
    }

    bool same(ll x,ll y){ // xとyが同一の木に存在するかを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> x(n),y(n);
    UnionFind tree(2*MAX+1);

    for(int i = 0;i < n;i ++){
        cin >> x[i] >> y[i];
        tree.unite(x[i],y[i]+MAX);
    }
    map<int,ll> mpx,mpy;

    for(int i = 1;i <= MAX;i ++){
        mpx[tree.root(i)] ++;
    }
    for(int i = MAX+1;i <= 2*MAX;i ++){
        mpy[tree.root(i)] ++;
    }

    for(int i = 1;i <= 2*MAX;i ++){
        ans += mpx[i]*mpy[i];
    }

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

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

int main(){
    int N;
    cin >> N;
    int p[N];

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

    int count=0;

    for(int i=1;i<N-1;i++){
        if(((p[i]>p[i-1]) && (p[i]<p[i+1])) || ((p[i] < p[i-1]) && (p[i]>p[i+1]))){
            count++;
        }  
    }
    cout << count << endl;
    return 0;
}

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

//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

int main() {

    long N, K;
    cin >> N >> K;

    cout << min(N%K, K-N%K) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define lli long long int
int a,b,c;
inline lli mn(lli x,lli y){return x<y?x:y;}
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(a&b&c&1)return printf("%lld",mn(mn(1ll*a*b,1ll*a*c),1ll*b*c)),0;
	return printf("0"),0;
}

Measured memory_bytes: 1708
"use strict"

const Main =(input)=>{
const Array=input.split(" ")
const A=parseInt(Array[0],10)
const B=parseInt(Array[1],10)
const C=parseInt(Array[2],10)
const Answer= (A+B)>=C ?"Yes":"No"
console.log(Answer)
}




Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] ND = Array.ConvertAll(Console.ReadLine().Split(),double.Parse);
            int count = 0;
            for(int i = 0;i<ND[0];i++){
                double[] xy = Array.ConvertAll(Console.ReadLine().Split(),double.Parse);
                double res = Math.Sqrt(xy[0]*xy[0]+xy[1]*xy[1]);
                if(res<=ND[1]){
                    count++;
                }
            }
            Console.WriteLine(count);

        }
            
        
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 40592
//
// Created by Tetsuya Shiota on 2019-03-03.
//

#include<iostream>
#include<algorithm>
#include <vector>
#include <set>
#include<string>

using namespace std;

// 逆からやったほうが良さそう
// Union Findで管理できそう
// 答えは、連結成分で分解して、それぞれの大きさを適当に掛け算して和を取るとよさそう

typedef long long ll;

class DisJointSet{
public:
    vector<int> v;//親の添字を入れる
    vector<int> cnt;
    DisJointSet(int n){//初期化
        v = vector<int>(n);
        cnt = vector<int>(n);
        for(int i = 0; i<n; i++)v[i] = i;
        for(int i = 0; i<n; i++)cnt[i]=1;
    }
    int find(int x){//親を返す
        if(v[x] == x)return x;
        else return v[x] = find(v[x]);
    }
    int count(int x){
        return cnt[find(x)];
    }
    void unite(int x, int y){//xとyをくっつける
        x = find(x);
        y = find(y);
        if(x == y)return;
        v[x] = y;
        cnt[y] += cnt[x];
        cnt[x] = cnt[y];
    }
    bool same(int x, int y){//xとyが同じ集合かどうか
        return find(x) == find(y);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector< vector<int> > edge(N);
    vector<pair<int, int> > order(M);
    for(int i = 0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
        order[i].first = a;
        order[i].second = b;
    }

    ll score = ll(N) * ll(N-1) /2;
    DisJointSet djs(N);

    vector<ll> ans;
    for(auto it = order.rbegin(); it != order.rend(); ++it){
        ans.push_back(score);
        if(!djs.same(it->first, it->second)) {
            score -= ll(djs.count(it->first)) * ll(djs.count(it->second));
            djs.unite(it->first, it->second);
        }
    }
    for(auto it = ans.rbegin(); it !=ans.rend(); ++it){
        cout << *it <<endl;
    }




    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int count = 0;
    for(int i=1;S[i]!='\0';i++){
        if(S[i-1] != S[i])
            count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
  int m,n,a,flg,mem[1001],cnt,flg2,i,m1,j,flg3;
  char s[10];
  while(1){
    scanf("%d %d",&m,&n);
    for(i=0;i<=m;i++) mem[i]=1;
    cnt=0,m1=m;
    if(m==0&&n==0) break;
    for(i=1;i<=n;i++){
      flg2=0,flg=0,flg3=0;
      cnt++;
      if(cnt==m+1)cnt=1;
      scanf("%s",s);
      if(m1!=1){
	if(mem[cnt]==0){
	  for(cnt++;cnt<=m;cnt++){
	    if(mem[cnt]==1){
	      flg3=1;
	      break;
	    }
	  }
	  if(flg3==0){
	    for(cnt=1;;cnt++){
	      if(mem[cnt]==1){
		break;
	      }
	    }
	  }
	}
	if(strcmp(s,"Fizz")==0)flg=1;
	else if(strcmp(s,"Buzz")==0)flg=2;
	else if(strcmp(s,"FizzBuzz")==0)flg=3;
	switch(flg){
	case 0:
	  a=atoi(s);
	  if(!(i%3!=0&&i%5!=0&&a==i))flg2=1;
	  break;
	case 1:
	  if(!(i%3==0&&i%5!=0))flg2=1;
	  break;
	case 2:
	  if(!(i%5==0&&i%3!=0))flg2=1;
	  break;
	case 3:
	  if(!(i%5==0&&i%3==0))flg2=1;
	  break;
	}
      
	if(flg2==1){
	  mem[cnt]=0;
	  m1--;
	}
      }
    }
    for(i=1,cnt=0;i<=m;i++){
      if(mem[i]==1)cnt++;
    }
    for(i=1;i<=m;i++){
      if(mem[i]==1){
	printf("%d",i);
	if(cnt!=1)printf(" ");
	cnt--;
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int n;cin>>n;
	cout<<n/3<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

int main() {
    int n; cin >> n;
    vi a; a.resize(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    int m = a.back();

    int _min = INT_MAX;
    int idx = -1;
    for (int i = 0; i < n - 1; ++i) {
        if (_min >= abs(m / 2 - a[i])) {
            if (idx >= 0 && a[idx] > a[i]) {
                continue;

            } else {
                _min = abs(m / 2 - a[i]);
                idx = i;
            }
        }
    }
    cout << m << " " << a[idx] << endl;


    return 0;
}


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

int main(){
    int n,x,pay;
    cin >> n;
    int ans = 0;
    for(x = 0;x<=n;x++){
        pay = x + (x*8)/100;
        if(pay==n){
            cout << x << endl;
            return 0;
        }

        
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3628
use std::io;


fn main() {
    let (H, W) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let (h, w) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    println!("{}", (H - h) * (W - w));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

int main() {
	int sum;
	while(cin >> sum, sum) {
		int cnt = 0;
		for(int n=2; n<=sum; n++) {
			int a = (sum*2/n - n + 1) / 2;
			if(a<=0) break;
			if( (2*a+n-1)*n/2 == sum ) {
				cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import std.stdio, std.string, std.array, std.conv, std.math, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    double[] x = readln.chomp.split.to!(double[]);
    double[] y = readln.chomp.split.to!(double[]);
    double[] diff = new double[n];
    foreach (i; 0 .. n) diff[i] = abs(x[i] - y[i]);
    double d1 = diff.sum;
    double d2 = sqrt(diff.map!(a => a ^^ 2).sum);
    double d3 = cbrt(diff.map!(a => a ^^ 3).sum);
    double dinf = diff.sort.array[n-1];
    writefln("%0.6f", d1);
    writefln("%0.6f", d2);
    writefln("%0.6f", d3);
    writefln("%0.6f", dinf);
}


Measured memory_bytes: 2776
//include
//--------------------------------------------------
#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<cstring>
#include<ctime>

using namespace std;

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

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

//typedef
//--------------------------------------------------
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;

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

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

//constant
//--------------------------------------------------
const int INF=1e9+7;
const int dx[]={0,-1,0,1};
const int dy[]={-1,0,1,0};

//clear memory
#define CLR(a) memset((a),0,sizeof(a))

//debug
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<"(L"<<__LINE__<<")"<<endl

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





int n,c;
int a[30],b[30];
int dp[2][1<<16];
int solve(){
    fill_n(*dp,2*(1<<16),-1);
    dp[0][0]=0;
    REP(i,n){
        REP(j,(1<<16)){
            if(dp[i&1][j]==-1)continue;
            REP(k,c){
                int state=j|a[i];
                int cnt=0;
                REP(l,16){
                    if(((b[k]>>l)&1)==0)continue;
                    if(((state>>l)&1)==0)continue;
                    cnt++;
                    state^=(1<<l);
                }
                dp[(i+1)&1][state]=max(dp[i&1][j]+cnt,dp[(i+1)&1][state]);
            }
            dp[i&1][j]=-1;
        }
    }

    int ma=0;
    REP(i,1<<16)ma=max(ma,dp[n&1][i]);

    return ma;
}























int main(){
    while(cin>>n>>c,n||c){
        REP(i,n){
            a[i]=0;
            REP(j,16){
                int v;cin>>v;
                a[i]=a[i]*2+v;
            }
        }
        REP(i,c){
            b[i]=0;
            REP(j,16){
                int v;cin>>v;
                b[i]=b[i]*2+v;
            }
        }
        cout<<solve()<<endl;
    }
    return 0;
}

Measured memory_bytes: 1676
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main()
    {
     
        int k;
        scanf("%d", &k);
     
        int cnt = 0;
     
        for(int i = 1; i <= k; i++)
        {
            if(i % 2 == 0)
            {
                for(int j = 1 ; j <= k; j++)
                {
                    if(j % 2 == 1)
                        cnt++;
     
                }
            }
        }
        cout << cnt << endl;
        return 0;
    }

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

typedef pair<ll, ll> pll;

const int MAX_PRIME = 2000000;
vector<int> primes;
vector<bool> is_prime;
// 小さい素数(MAX_PRIMEまで)は先に用意しとく
void init_primes() {
  is_prime = vector<bool>(MAX_PRIME + 1, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= MAX_PRIME; i++) {
    if (is_prime[i]) {
      primes.push_back(i);
      for (int j = i*2; j <= MAX_PRIME; j+=i) {
        is_prime[j] = false;
      }
    }
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  init_primes();

  ll a,b;cin>>a>>b;
  set<ll> st;

  for(auto v : primes) {
    if(a==1)break;
    while(a && a%v==0){
      st.insert(v);
      a/=v;
    }
  }
  if(a!=1)st.insert(a);
  int res=1;
  for(auto v : primes) {
    if(b==1)break;
    bool used=false;
    while(b && b%v==0){
      used=true;
      b/=v;
    }
    if(st.count(v) && used)res++;
  }
  if(b!=1 && st.count(b))res++;

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
   string x;
    while(cin>>x){
        /*int a = 0,b = 0,c = 0;
        for(int i = 0;i < 3;i++){
            if(x[i] == 'a') a++;
            if(x[i] == 'b') b++;
            if(x[i] == 'c') c++;
        }
        if(a == 1,b == 1,c == 1)
            cout<<"Yes"<<endl;

        else cout<<"No"<<endl;*/
        if(x == "abc" || x == "acb" || x == "bac" || x == "bca" || x == "cab" || x == "cba"){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll dp[1001][1001] = {};
string g[1001];

int main()
{
	int i,j,h,w;
	cin>>h>>w;
	for(i=0; i<h; i++) cin>>g[i];

	for(i=h-1; i>=0; i--)
		for(j=w-1; j>=0; j--){
			if(i == h-1 and j == w-1) dp[i][j] = 1;
			else if(g[i][j] == '#') dp[i][j] = 0;
			else dp[i][j] = (dp[i+1][j] + dp[i][j+1])%mod;
		}

	cout<<dp[0][0];
}

Measured memory_bytes: 9088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"

	"github.com/emirpasic/gods/trees/binaryheap"
	"github.com/emirpasic/gods/trees/redblacktree"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)

	rbt := redblacktree.NewWithIntComparator()
	bh := binaryheap.NewWithIntComparator()
	right := make([]int, w)
	cnt := map[int]int{}
	for i := 0; i < w; i++ {
		rbt.Put(i, 1)
		bh.Push(0)
		right[i] = i
	}
	cnt[0] = w

	for i := 0; i < h; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner)
		x := -1
		for node, ok := rbt.Ceiling(a); ok && node.Key.(int) <= b; node, ok = rbt.Ceiling(a) {
			k := node.Key.(int)
			rbt.Remove(k)
			if x < right[k] {
				x = right[k]
			}
			cnt[k-right[k]]--
			right[k] = -1
		}
		if b < w && x != -1 {
			if right[b] < x {
				right[b] = x
			}
			rbt.Put(b, 1)
			if cnt[b-right[b]] == 0 {
				bh.Push(b - right[b])
			}
			cnt[b-right[b]]++
		}
		for p, ok := bh.Peek(); ok && cnt[p.(int)] == 0; p, ok = bh.Peek() {
			bh.Pop()
		}
		if p, ok := bh.Peek(); ok {
			fmt.Fprintln(writer, p.(int)+i+1)
			continue
		}
		fmt.Fprintln(writer, -1)
	}
}


Measured memory_bytes: 38528
#include <cstdio>
using namespace std;

int main()
{
	char ch;
	bool c=false;
	while((ch=getchar())!='\n')
		if(ch=='C')
			c=true;
		else if(ch=='F' && c)
			return printf("Yes")&0;
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#define MOD 1000000007
using namespace std;

int a[262145] = {};
int f(int l, int r, int kl, int kr)
{

	if (kl>=r || kr<=l){
		return 0;
	}else if (kl <= l&&kr >= r){
			return a[(131072 + l) / (r - l)];
	}
	else{
		return f(l, (l + r) / 2, kl, kr) + f((l + r) / 2, r, kl, kr);
	}
}
int main()
{
	int n, q,d;
	cin >> n>> q;
	int com[100005], x[100005], y[100005];
	int i,j;
	for (i = 0; i < q; i++){
		cin >> com[i] >> x[i] >> y[i];
	}
	for (i = 0; i < q; i++){
		if (com[i] == 0){
			d = x[i] + 131071;
			for (j = 0; j < 18;j++){
				a[d] += y[i];
				d = d / 2;
			}
		}
		else{
			cout << f(0, 131072, x[i]-1, y[i]) << endl;
		}
	}

	return 0;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef unordered_map<lli,unordered_map<lli,vll>> edge;

lli n,m;
edge g;
edge e;
priority_queue<vll,vector<vll>,greater<vll>> q;
set<vll> used;

int main(){
  cin >> n >> m;
  for(lli i = 0;i < m;i++){
    lli p,q,c;
    cin >> p >> q >> c;
    g[c][p].push_back(q);
    g[c][q].push_back(p);
    e[p][q].push_back(c);
    e[q][p].push_back(c);
  }
  q.push(vll({0,1,0}));//cost,station,company;
  while(!q.empty()){
    lli cost = q.top()[0];
    lli station = q.top()[1];
    lli company = q.top()[2];
    q.pop();
    if(station == n){
      cout << cost << endl;
      return 0;
    }
    if(used.count(vll({station,company})) != 0) continue;
    used.insert(vll({station,company}));
    if(company == 0){
      for(auto& itr : e[station]){
        for(lli& jtr : itr.second){
          q.push(vll({cost+1,itr.first,jtr}));
        }
      }
    }else{
      if(used.count(vll({station,0})) == 0) q.push(vll({cost,station,0}));
      for(lli& itr : g[company][station]){
        if(used.count(vll({itr,company})) == 0) q.push(vll({cost,itr,company}));
      }
    }
  }
  cout << -1 << endl;
  return 0;

}


Measured memory_bytes: 148836
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

long long com(long long n,long long k){
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	int data=0;
	for(int i=0;i<s.length();i++){
		if(data==0 && s[i]=='C')data++;
		if(data==1 && s[i]=='F')data++;
	}
	if(data==2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

	


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nab = ReadInts();
            if (nab[0] * nab[1] > nab[2])
            {
                WriteLine(nab[2]);
            }
            else
            {
                WriteLine(nab[0] * nab[1]);

            }
        }
        

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    int N;
    string S;
    cin >> N >> S;
    rep(i,S.size()){
        S[i]=((S[i]-'A')+N)%26+'A';
    }
    cout << S << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final long MOD =  1000000007L;
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		char[][] a = new char[n][];
		for (i = 0; i < n; i++) {
			a[i] = sc.next().toCharArray();
		}
		char[][] b = new char[m][];
		for (i = 0; i < m; i++) {
			b[i] = sc.next().toCharArray();
		}
		sc.close();
		boolean f=true;
LABEL1:	for (i = 0; i <= n-m; i++) {
		for (j = 0; j <= n-m; j++) {
				f=true;
LABEL2:			for (k = 0; k < m; k++) {
					for (l = 0; l < m; l++) {
						if(b[k][l]!=a[k+i][l+j]) {
							f=false;
							break LABEL2;
						}
					}
				}
				if(f)break LABEL1;
			}
		}
		out.println(f?"Yes":"No");
	}
}


Measured memory_bytes: 21204
N, K = map(int, input().split())
inList = list(map(int, input().split()))

lastSum = sum(inList[0: K])
maxNum = lastSum

for indx in range(1, N - (K - 1)):
  maxNum = max(lastSum - inList[indx-1] + inList[indx+K-1], maxNum)
  lastSum = lastSum - inList[indx-1] + inList[indx+K-1]

print((maxNum + K) / 2)

Measured memory_bytes: 25060
# 嘘解法を書いてしまったので、再提出。

# 最後に選ぶ料理は、食べる料理の中で時間が最もかかるものを食べるとして良い。
# 先に a で昇順ソートしておき、最後に選ぶ料理を i とした時に、
# それよりも時間のかからない料理だけを使って、t-1までに食べ切れるものの中で最も高い満足度を得るという方針。
# 前計算はナップサックDPで。

n, t = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()

a = []
b = []
for ai, bi in ab:
    a.append(ai)
    b.append(bi)

dp = [[0 for j in range(t+1)] for i in range(n+1)]

for i in range(n):
    for j in range(t):
        if j + a[i] <= t-1:
            if dp[i+1][j + a[i]] < dp[i][j] + b[i]:
                dp[i+1][j + a[i]] = dp[i][j] + b[i]
        if dp[i+1][j] < dp[i][j]:
            dp[i+1][j] = dp[i][j]

ans = 0

for i in range(n):
    ans = max(ans, dp[i][t-1] + b[i])

print(ans)






Measured memory_bytes: 124504
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <climits>

using namespace std;

typedef long long ll;

int main(){
  string str; cin >> str;
  pair<int, int> ans=make_pair(-1, -1);
  int i=0;
  while(1){
    if(i >= str.size()-1) break;
    if(str[i] == str[i+1]){
      ans = make_pair(i+1, i+2);
      break;
    }else if(str[i] == str[i+2]){
      ans = make_pair(i+1, i+3);
      break;
    }else{
      i = i+1;
    }
  }
  cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int rc=0;
	rep(i,n){
		if(s[i]=='R')rc++;
	}
	int ans=rc;
	rep(i,rc){
		if(s[i]=='R')ans--;
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin >> s;
    int w;
    cin >> w;
    string ans = "";
    REP(i, SZ(s)) {
        ans += s[i];
        i += w - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i,n) for (int i = 0; i < (n); ++i)

const string YES = "Yes";
const string NO = "No";

void solve(long long X){
    string ans = "";
    if(X >= 30) ans = YES;
    else ans = NO;

    cout << ans << endl;

}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  int a_min = a * 25 / 2, b_min = b * 10;
  int a_max = (a + 1) * 25 / 2, b_max = (b + 1) * 10;
  if (a_min * 8 / 100 != a) ++a_min;
  if (a_max * 8 / 100 != a + 1) ++a_max;
  if (a_min >= b_max || b_min >= a_max) {
    printf("-1\n");
  } else {
    if (a_min >= b_min)
      printf("%d\n", a_min);
    else
      printf("%d\n", b_min);
  }
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = x;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        ans += (d + a - 1) / a;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256