akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int main()
{
	int n,temp,t,x,y;
	cin>>n;
	long long sum=0;
	for (int i=0;i<n;i++)
	{
		cin>>temp;
		sum+=temp;
		m[temp]++;
	}
	cin>>t;
	for (int i=0;i<t;i++)
	{
		cin>>x>>y;
		if (m[x]==0)   cout<<sum<<endl;
		else
		{
			if (y>x)
			{
				sum+=(y-x)*m[x];
				m[y]=m[y]+m[x];
				m[x]=0;
			}
			else if (x>y)
			{
				sum-=(x-y)*m[x];
				m[y]=m[y]+m[x];
				m[x]=0;
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7720
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;



typedef struct {
	char name[10];
	int time;
} P;

void enq(P);
P deq(void);

P q[100005];
int head=0;
int tail=0;

int main(){
	P w;
	int n,qt,g=0;
	int t=0;
	cin >> n >> qt;
	for(int i=0;i<n;i++){
		cin >> q[i].name >> q[i].time;
		tail++;
	}
	while(g!=n){
		w = deq();
		if(w.time-qt>0){ // ???????????????
			w.time-=qt;
			t+=qt;
			enq(w);
		}else{ //?????????
			t+=w.time;
			w.time=0;
			cout << w.name << " "<< t << endl;
			g++;
		}
	}



	return 0;
}

void enq(P a){
	tail%=100005;
	q[tail]=a;
	tail++;
}

P deq(void){
	head%=100005;
	head++;
	return q[head-1];
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	string a,b,c;
	char x;
	cin>>a>>b>>c;
	x='a';
	while(1){
		if(x=='a'){
			if(a.size()==0){
				puts("A");
				return 0;
			}
			
			x=a[0];
			a=a.substr(1);
		}
		if(x=='b'){
			if(b.size()==0){
				puts("B");
				return 0;
			}
			
			x=b[0];
			b=b.substr(1);
		}
		if(x=='c'){
			if(c.size()==0){
				puts("C");
				return 0;
			}
			x=c[0];
			c=c.substr(1);
		}
	}
	return 0;
}


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

int w1, w2, h1, h2, sum;
int hash_a[800][800][13], hash_b[800][13];
int cumo_a[800][800][13], cumo_b[800][13];
char s[800][800],t[800][700];

void make_table(){
  rep(i,h1) rep(j,w1-w2+1) {
    rep(k,w2){
      rep(l,8) hash_a[i][j][(k*8)/64] = hash_a[i][j][(k*8)/64]*2 + ( ((s[i][j+k]>>l)&1)?1:0);
      rep(l,8) cumo_a[i][j][(k*8)/64] = cumo_a[i][j][(k*8)/64]*2 + (s[i][j+k]=='?'?1:0);
    }
  }
  rep(i,h2) {
    rep(j,w2){
      rep(k,8) hash_b[i][(j*8)/64] = hash_b[i][(j*8)/64]*2 + (((t[i][j]>>k)&1)?1:0);
      rep(k,8) cumo_b[i][(j*8)/64] = cumo_b[i][(j*8)/64]*2 + (t[i][j]=='?'?1:0);
    }
  }
}

void count_s(){
  rep(i,h1-h2+1) {
    rep(j,w1-w2+1) {
      rep(k,h2) {
        int p1[13]={} ,p2[13]={} ,flag = 0;
        rep(l,13){
          p1[l] = hash_a[i+k][j][l] ^ hash_b[k][l];
          p2[l] = cumo_a[i+k][j][l] | cumo_b[k][l];
          if( (p1[l] | p2[l]) != p2[l] ) { flag ++; break; }
        }
        if( flag ) break ;
        if( k == h2-1 ) sum++;
      }
    }
  }
}

signed main(){
  cin >> w1 >> h1 >> w2 >> h2;
  rep(i,h1) scanf("%s", s[i]);
  rep(i,h2) scanf("%s", t[i]);
  make_table();
  count_s();
  cout << sum << endl;
}

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

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
using P = pair<ll, ll>;

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x)
    {
        return -par[root(x)];
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<P> a(n), b(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    for (ll i = 0; i < n; i++)
    {
        cin >> b[i].first;
        b[i].second = i;
    }
    sort(ALL(a));
    sort(ALL(b));
    UnionFind uf(n);
    bool flg = false;
    for (ll i = 0; i < n; i++)
    {
        if (a[i].first > b[i].first)
        {
            cout << "No" << endl;
            return 0;
        }
        uf.merge(a[i].second, b[i].second);
        if (i > 0 && a[i].first <= b[i - 1].first)
        {
            flg = true;
        }
    }
    if (uf.size(0) != n || flg)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef  long long ll;
int const N = 200020;

int main() {
	
	int a , b , c, x , y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 0;
	while(x > 0 && y > 0){
		ans += min(2*c,a+b);
		x--;
		y--;
	}
	while(x > 0){
		ans += min(a , 2*c) ;
		x--;
	}
	while(y > 0){
		ans += min(b , 2*c);
		y--;
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
ret :: Int -> Int -> Bool
ret a b =
    if (a `mod` 2 == 1 && b `mod` 2 == 1) then
        True
    else
        False


main = do
    hoge <- getLine
    let [a, b] = map read $ words hoge
    if (ret a b) then
        putStrLn "Yes"
    else
        putStrLn "No"

Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a;
    cin >> a;
    if(a < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
    return 0;
}

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

int main (){
    int N,A;
    cin >> N;
    cin >> A;
    int oturi ;
    oturi = N % 500;
    if(oturi <= A)
        {
            cout << "Yes" << endl; 
        }
    else
        {
            cout << "No" << endl;
        }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e2;
int n, x[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) cin >> x[i];
  int ans = IINF;
  FOR(i, 1, 101){
    int s = 0;
    FOR(j, 0, n) s += (x[j]-i)*(x[j]-i);
    mins(ans, s);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2020/04/10
 *      Author: SkAaO
 */

#include <iostream>
#include <math.h>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int count = 1;
	int f_b = b;
	while(1){
		if(b / 10 != 0){
			b /= 10;
			count++;
		}else{
			break;
		}
	}

	int num = a * pow(10, count) + f_b;
	if(num == pow((int)sqrt(num), 2)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, D[1010][1010], dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
queue <pair<int,int> > q;
char p[1010][1010];
int ans = -1;
void Put(int x, int y, int d) {
	if (x<1 || x>n || y<1 || y>m)return;
	if (D[x][y] <= d)return;
	D[x][y] = d;
	ans = max(ans,D[x][y]);
	q.push({x,y});
}
int main() {
	int i, j;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) {
		scanf("%s", p[i] + 1);
		for (j = 1; j <= m; j++) {
			D[i][j] = 1e9;
			if(p[i][j]=='#') Put(i, j, 0);
		}
	}
	while (!q.empty()) {
            pair<int,int>  t= q.front();    q.pop();
		for (i = 0; i < 4; i++) Put(t.first + dx[i], t.second + dy[i], D[t.first][t.second] + 1);
	}
	printf("%d\n", ans);
}


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

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

  vector<vector<int>> A(n);
  for (int i = 0; i < q; ++i) {
    int q, t;
    cin >> q >> t;

    if (q == 0) { // pushBack
      int x;
      cin >> x;
      A[t].push_back(x);
    }
    if (q == 1) { // dump
      for (int i = 0; i < A[t].size(); ++i) {
        if (i != 0)
          cout << " ";
        cout << A[t][i];
      }
      cout << endl;
    }
    if (q == 2) { // clear
      A[t].clear();
    }
  }
}


Measured memory_bytes: 5832
#include <stdio.h>

int F(long long a, long long b)
{
    int ret = 0;
    while (a > 0 || b > 0)
    {
        a /= 10;
        b /= 10;
        ret ++;
    }
    return ret;
}

int main()
{
    long long n;
    scanf("%lld", &n);

    long long i,j,ans = 100,buf;

    for (i = 1; i * i <= n; i++)
    {
        if(n % i == 0){
            buf = F(i, n / i);
            if(buf < ans)ans = buf;
        }
    }
    
    printf("%lld",ans);
}

Measured memory_bytes: 128
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

long long func(long long a){
	if(a<0)return -a;
	return a;
}

int main(){
	int n;
	long long sum=0,alt;
	cin>>n;
	long long a[n];
	rep(i,n){
		cin>>a[i];
		sum+=(i==0)?func(a[i]):func(a[i]-a[i-1]);
	}
	sum+=func(a[n-1]);
	rep(i,n){
		alt=sum;
		if(i==0){
			alt-=(func(a[0])+func(a[0]-a[1]));
			alt+=func(a[1]);
		}else if(i==n-1){
			alt-=(func(a[n-2]-a[n-1])+func(a[n-1]));
			alt+=func(a[n-2]);
		}else{
			alt-=(func(a[i+1]-a[i])+func(a[i]-a[i-1]));
			alt+=func(a[i+1]-a[i-1]);
		}
		cout<<alt<<endl;
	}
	return 0;
}

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

int main() {
	int64_t N;
	cin >> N;

	int64_t a = 1;
	int64_t b = 3;
	int64_t c;

	if (N != 1 && N != 2) {
		for (int i = 2; i < N; i++) {
			c = a + b;
			a = b;
			b = c;
		}

		cout << c << endl;
	}
	else {
		if (N == 1) {
			cout << "1" << endl;
		}
		else {
			cout << "3" << endl;
		}
	}
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sc = new Scanner();
            int n = sc.NextInt();
            int m = sc.NextInt();
            int[] x = new int[m];
            for (int i = 0; i < m; i++) x[i] = sc.NextInt();
            
            if (n >= m)
            {
                Console.WriteLine(0);
                return;
            }

            Array.Sort(x);
            var list = new List<int>(m - 1);
            for (int i = 1; i < m; i++) list.Add(x[i] - x[i - 1]);
            int open = 0;
            list.Sort(); list.Reverse();
            for (int i = 0; i < n - 1; i++) open += list[i];
            Console.WriteLine(x[m - 1] - x[0] - open);
        }
    }

    class Scanner
    {
        int index = -1;
        string[] buf;

        public Scanner()
        {
        }

        public int NextInt()
        {
            CheckNext();
            return int.Parse(buf[index++]);
        }

        public long NextLong()
        {
            CheckNext();
            return long.Parse(buf[index++]);
        }

        public string NextString()
        {
            CheckNext();
            return buf[index++];
        }

        private void CheckNext()
        {
            if (index >= 0 && index < buf.Length) return;

            buf = Console.ReadLine().Split(' ');
            index = 0;
        }
    }
}



Measured memory_bytes: 18784
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7


N = int(input())
a = [int(i) for i in input().split()]


counts = [0 for i in range(8)]
any = 0
for i in range(N):
    if a[i] >= 3200:
        any += 1
    else:
        ind = a[i] // 400
        counts[ind] += 1

# print(counts)

ans_min = max(1,len(counts)-counts.count(0))
if counts.count(0) != 8:
    ans_max = ans_min+any
else:
    ans_max = any
print(ans_min,ans_max)


Measured memory_bytes: 5460
k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  state = 7
  state %= k
  cnt = 1
  while True:
    if state == 0:
      print(cnt)
      break
    state = state * 10 + 7
    state %= k
    cnt += 1


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int hai=0, cha=0, midori=0, mizu=0, ao=0, ki=0, orange=0, aka=0, ran=0;
    for(int i=0; i<N; i++){
        if(a[i]<400){hai=1;}
        else if(a[i]<800){cha=1;}
        else if(a[i]<1200){midori=1;}
        else if(a[i]<1600){mizu=1;}
        else if(a[i]<2000){ao=1;}
        else if(a[i]<2400){ki=1;}
        else if(a[i]<2800){orange=1;}
        else if(a[i]<3200){aka=1;}
        else {ran++;}
    }

    int min, max;
    max = hai+cha+midori+mizu+ao+ki+orange+aka+ran;
    if(hai+cha+midori+mizu+ao+ki+orange+aka==0){
        min=1;
    }else{
        min = hai+cha+midori+mizu+ao+ki+orange+aka;
    }
    cout << min << ' ' << max;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn calc_score(c: &Vec<i64>, t: &Vec<usize>, s: &Vec<Vec<i64>>) -> i64 {
    let d = s.len();
    let mut score = 0;
    let mut last = vec![0; 26];
    for i in 0..d {
        score += s[i][t[i]];
        last[t[i]] = i + 1;
        for qi in 0..26 {
            score -= c[qi] * (i as i64 + 1 - last[qi] as i64);
        }
    }
    score
}

fn main() {
    let d = read::<usize>();
    let c = read_vec::<i64>();
    let mut s = vec![vec![]; d];
    for i in 0..d {
        s[i] = read_vec::<i64>();
    }

    let mut answers = vec![];

    for i in 0..d {
        let mut max_idx = 0;
        for j in 0..26 {
            if s[i][j] > s[i][max_idx] {
                max_idx = j;
            }
        }
        answers.push(max_idx);
    }
    let mut cur_score = calc_score(&c, &answers, &s);

    let mut xor = Xorshift::new();
    for _ in 0..50000 {
        let rd = xor.next() as usize % d;
        let rq = xor.next() as usize % 26;

        let prev = answers[rd];
        answers[rd] = rq;
        let score = calc_score(&c, &answers, &s);
        if score > cur_score {
            cur_score = score;
        } else {
            answers[rd] = prev;
        }
    }

    for ans in answers {
        println!("{}", ans + 1);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[derive(Debug)]
pub struct Xorshift {
    seed: u64,
}
impl Xorshift {
    pub fn new() -> Xorshift {
        Xorshift {
            seed: 0xf0fb588ca2196dac,
        }
    }
    pub fn with_seed(seed: u64) -> Xorshift {
        Xorshift { seed: seed }
    }
    #[inline]
    pub fn next(&mut self) -> u64 {
        self.seed = self.seed ^ (self.seed << 13);
        self.seed = self.seed ^ (self.seed >> 7);
        self.seed = self.seed ^ (self.seed << 17);
        self.seed
    }
    #[inline]
    pub fn rand(&mut self, m: u64) -> u64 {
        self.next() % m
    }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int i=0;
  bool flag = true;
  if(b == 1){
    cout << "0" << endl;
    return 0;
  }
  while(flag == true){
    i += 1;
    if((a-1)*i+1 >= b){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		string s[n];
		r(i,n)cin>>s[i];
		for(int i=n-1;i>0;i--)
			r(j,s[i].size()-1)
				if(s[i][j]=='.'&&s[i][j+1]<='z'&&s[i][j+1]>='a'){

					s[i][j]='+';

					int k=i;

					while(s[k-1][j]=='.')
						if(s[k--][j]!='+')s[k+1][j]='|';

					s[k][j]='+';
				}
		for(int i=n-1;i>0;i--)
			r(j,s[i].size()-1)
				if(s[i][j]=='|'&&s[i][j+1]<='z'&&s[i][j+1]>='a')
					s[i][j]='+';
			for(int i=n-1;i>0;i--)
			r(j,s[i].size()-1)
				if(s[i][j]=='.')
					s[i][j]=' ';	
		r(i,n)cout<<s[i]<<endl;
	}
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define int long long
using namespace std;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
	}
signed main()
{
	int a,b;
	while(cin>>a>>b){
	 cout<<gcd(a,b)<<" "<<a*b/gcd(a,b)<<endl;
		}
	}

Measured memory_bytes: 3040
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int N=5e5+5;
const int maxn=5e5;
const int mod=1e9+7;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
int fac[N],inv[N],n,m,ans;
int A(int n,int m){return n<m?0:1ll*fac[n]*inv[n-m]%mod;}
int C(int n,int m){return n<m?0:1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read(),m=read();
	fac[0]=1;for(int i=1;i<=maxn;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[1]=1;for(int i=2;i<=maxn;i++)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	inv[0]=1;for(int i=1;i<=maxn;i++)inv[i]=1ll*inv[i]*inv[i-1]%mod;
	for(int i=0;i<=n;i++)ans=(ans+1ll*(i&1?mod-1:1)*A(m,i)%mod*C(n,i)%mod*A(m-i,n-i)%mod*A(m-i,n-i)%mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6992
import sys
def input():
    return sys.stdin.readline()[:-1]


def test():
    x, y = map(int, input().split())
    # x = input().split()
    a = y / 2 - x
    b = x - a
    if a >= 0 and b >= 0 and a.is_integer():
        print("Yes")
    else:
        print("No")

test()

Measured memory_bytes: 9172
#include <stdio.h>

int main(void)
{
	int a, b, c, ans = 0;

	scanf("%d %d %d", &a, &b, &c);

	for (a; a <= b; a++) {
		if (c%a == 0) {
			ans++;
		}
	}

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

	return 0;
}

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

namespace atcoderA
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = Console.ReadLine();
            var array = new string[] { "a", "e", "i", "o", "u" };
            Console.WriteLine(array.Contains(c) ? "vowel" : "consonant");
        }
    }
}

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

int main(){
	int N;
	int mx=0;
	int ans = 0;
	cin >> N;
	rep(i,N){int t; cin >> t; ans+=t; mx = max(mx,t);}
	ans = ans - mx/2;
	cout << ans << endl;

	return 0;
}

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

int main(){
  int H,W;
  char a[100][100];
  int count;
  cin >> H >> W;
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      cin >> a[i][j];
    }
  }

  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      count = 0;
      if(a[i][j] == '.'){
        if(a[i-1][j-1] == '#') count++;
        if(a[i-1][j] == '#') count++;
        if(a[i-1][j+1] == '#') count++;
        if(a[i][j-1] == '#') count++;
        if(a[i][j+1] == '#') count++;
        if(a[i+1][j-1] == '#') count++;
        if(a[i+1][j] == '#') count++;
        if(a[i+1][j+1] == '#') count++;
        a[i][j] = '0' + count;
      }
    }
  }

  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      cout << a[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
# include <iostream>
# include <math.h>

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int h1 = a,h2 = c,n=0;
    while(h2>0){
        n += 1;
        h2 -= b;
    }
    if ((h1-n*d)>0){
        cout << "Yes\n";
    }
    else if ((h1 - (n-1)*d)>0){
        cout << "Yes\n";
    }
    else {cout << "No\n";}

    return 0;

}

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

int main(){
  int N;
  int cnt = 0;
  cin >> N;

  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i*j == N){
        cnt++;
      }
    }
  }

  if(cnt > 0){
      cout << "Yes" << endl;
    }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

    LL A,B; cin >> A >> B;
    LL K; cin >> K;
    int turn = 0;
    REP(i,K){
        if(turn == 0){
            if(A % 2 == 1) A--;

            B += A/2;
            A /= 2;
            turn = 1;
        }
        else{
            if(B%2 == 1) B--;

            A += B/2;
            B /= 2;
            turn = 0;
        }
    }
    cout << A << " " << B << endl;

}

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())
k = M / 60
if H == 0:
    H = 12
if M == 0:
    M = 60

H_d = ((H/12 * 60 + k*5)/60)*2*math.pi
M_d = (M/60)*2*math.pi
r = abs(H_d-M_d)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(r)))

Measured memory_bytes: 9508
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
using namespace std;

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

const long long INF = 1LL << 60;
int main()
{
	long long N;cin >> N;
	int res = 0;
	vector<long long> a(100000);
	for (long long i = 0;i < N;i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.begin()+N);
	for (int i = 0;i < N;) {
		int cc = a[i];int f = 0;
		for (;i < N&&a[i] == cc;) {
			f++;i++;
		}
		if (f % 2 == 1) {
			res++;
		}
	}
	
	cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include "atcoder/math.hpp"
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
	int t;
	cin >> t;
	rep(i, t) {
		ll n, m, a, b;
		cin >> n >> m >> a >> b;
		cout << floor_sum(n,m,a,b) << endl;
	}
	return 0;
}


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

namespace ABC139B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = CIN.IntArray();
            int A = AB[0];
            int B = AB[1];

            if (B == 1)
            {
                Console.WriteLine(0);
                return;
            }

            if (B <= A)
            {
                Console.WriteLine(1);
                return;
            }

            int cnt = 0;
            while (true)
            {
                if (1 + (A - 1) * cnt >= B)
                {
                    Console.WriteLine(cnt);
                    return;
                }

                cnt++;
            }
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,v,d,a[10002],n,c,tmp;

  while(scanf("%d%d",&v,&d) != EOF){
    c = 1;
    a[0] = 1;
    a[1] = 2;
    
    for(i=2;i<=v;i++) a[i] = (a[i-1] + a[i-2]) % 1001;
    
    for(i=v;i>1;i--){
      for(j=1;j<i;j++){
	if(a[j+1] < a[j]){
	  tmp = a[j];
	  a[j] = a[j+1];
	  a[j+1] = tmp;
	}
      }
    }
    
    for(i=2;i<=v;i++){
      if(a[i] - a[i-1] >= d) c++;
    }
    
    cout << c << endl;
    
  }
  return 0;
}

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

int main(){
	int n,a[200],ans=0;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	bool flag = true;
	
	while(flag){
		for(int i = 0;i < n; i++){
			if(a[i] % 2 == 0) a[i] /= 2;
			else flag = false;
		}
		if(flag) ans++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
let () =
  let nlst = [0;1;2;3;4;5;6;7;8;9] in
  let rec charlist_of_string str n i =
    if i = n then [] else str.[i] :: charlist_of_string str n (i+1) in
  let rec search lst n i = match lst with
    | [] -> raise Not_found
    | h :: t -> if h = (int_of_char n)-48 then i else search t n (i+1) in
  let rec solve lst ans = match lst with
    | [] -> ans
    | h :: t -> solve t ((search nlst h 0) + ans) in
  Scanf.scanf "%s\n" @@ fun n ->
  let lst = charlist_of_string n (String.length n) 0 in
  Printf.printf "%s\n" (if (solve lst 0) mod 9 = 0 then "Yes" else "No") 

Measured memory_bytes: 16852
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
 
int main()
{
    int n;cin >> n ;

    vector<long long int> v(100002);
    for(int i=0;i<n;i++){
        long long int tmp;cin >> tmp;
        tmp++;v[tmp-1]++;v[tmp]++;v[tmp+1]++;
    }
    sort(v.begin(),v.end(),greater<>());
    p(v[0])
}

Measured memory_bytes: 1152
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <string>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define REP(i, x, y) for(int i = (int)x; i <= (int)y; i ++)
#define FOR(i, x, y) for(int i = (int)x; i <  (int)y; i ++)
#define PER(i, x, y) for(int i = (int)x; i >= (int)y; i --)
#define trace(x) cerr << #x << " " << x << endl;
#define dprintf(...) fprintf(stderr, __VA__ARGS__)
#define dln()        fprintf(stderr, "\n")
using namespace std;
typedef long long LL;
typedef long double db;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
const	int N = 100005;
const	int P = 1e9 + 7;
const	int inf = 1e9;
const	LL Inf = 1e15;

inline int IN(){
	char ch = getchar(); int x = 0, f = 0;
	while(ch < '0' || ch > '9') ch = getchar(), f = (ch == '-');
	while(ch >= '0' && ch <= '9'){
		x = (x << 1) + (x << 3) + ch - 48;
		ch = getchar();
	}
	return f ? (-x) : x;
}

inline int Pow(int x, int y, int p){
	int an = 1;
	for(; y; y >>= 1, x = (LL)x * x % p) if(y & 1) an = (LL)an * x % p;
	return an;
}

void renew(int &x, int y){
	x += y;
	if(x < 0) x += P;
	else if(x >= P) x -= P;
}

template<typename T> inline void chkmin(T &a, const T &b) {if(a > b) a = b;}
template<typename T> inline void chkmax(T &a, const T &b) {if(a < b) a = b;}

bitset<305> now, bas[305];
int p2[305], dp[305][305], vis[305], n;

int main(){
	scanf("%d", &n);
	int rk = 0;
	REP(i, 1, n){
		now.reset();
		REP(j, 1, n){
			int x;
			scanf("%d", &x);
			now[j] = x;
		}
		PER(j, n, 1) if(now[j]){
			if(!vis[j]){
				vis[j] = 1;
				bas[j] = now;
				++rk;
				break;
			}else now ^= bas[j];
		}
	}
	//printf("%d\n", rk);
	dp[0][0] = 1;
	p2[0] = 1;
	REP(i, 1, n) p2[i] = (p2[i - 1] + p2[i - 1]) % P;
	REP(i, 0, n)
	REP(j, 0, i){
		int val = dp[i][j];
		dp[i + 1][j] = (dp[i + 1][j] + (LL)val * p2[j]) % P;
		dp[i + 1][j + 1] = (dp[i + 1][j + 1] + (LL)val * (p2[n] + P - p2[j])) % P;
	}
	int ans = 0;
	REP(i, rk, n)
		ans = (ans + (LL)dp[n][i] * Pow(2, n * (n - i), P) % P * dp[i][rk]) % P;
	ans = (LL)ans * Pow(dp[n][rk], P - 2, P) % P;
	printf("%d\n", ans);
	return 0;
}





















Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;
#define MOD 1000000007
int cnt[100010]={};

ll mypow(ll a,ll b){
	if(b==0)return 1;
	if(b%2==0){
		ll d=mypow(a,b/2)%MOD;
		return (d*d)%MOD;
	}
	return a*mypow(a,b-1)%MOD;
}


int main(){
	int n;
	cin>>n;
	vi a;
	int fr,bk;
	rep(i,n+1){
		int t;scanf("%d",&t);
		a.push_back(t);
		cnt[t]++;
		if(cnt[t]==2){
			bk=n-i;
			fr=find(a.begin(),a.end(),t)-a.begin();
		}
	}
	printf("%d\n",n);
	fr+=bk;
	ll coma=n+1,comb=1;
	nrep(i,2,n+2){
		coma=(coma*(n+2-i)%MOD)*mypow(i,MOD-2)%MOD;
		ll ret=coma;
		if(fr>=i-1){
			comb=(comb*(fr+2-i)%MOD)*mypow(i-1,MOD-2)%MOD;
			ret=(MOD+ret-comb)%MOD;
		}
		cout<<ret<<endl;
	}
	return 0;
}



Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<chrono>
#include<random>
#include<cstdio>
#include<set>
#include<map>
#define MAX_N 10
#define MAX_M 100
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;



int main(){
    long long H,W;
    cin>>H>>W;
    if(H==1 || W==1){
        cout<<1;
    }else{
        if(H%2==0){
            H=H/2;
            cout<<H*W;
        }else{
            long long H1,H2;
            H1=H/2;
            H2=H1+1;
            if(W%2==0){
                W=W/2;
                cout<<W*(H1+H2);
            }else{
                long long W1,W2;
                W1=W/2;
                W2=W1+1;
                long long ans=(H2*W2)+(H1*W1);
                cout<<ans;
            }
        }
    }
}

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

using namespace std;
string dirs = "LRUD";
int pre[2][4][200005];
int di[] = {0, 0, -1, 1};
int dj[] = {-1, 1, 0, 0};
int n, m, l;

bool valid(int i, int j) {
    return i > 0 && j > 0 && i <= n && j <= m;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.in", "r", stdin);
#endif

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

    cin >> n >> m >> l;
    int x, y;
    cin >> x >> y;
    string s[2];
    cin >> s[0] >> s[1];

    bool found = false;
    for (int d = 0; d < 4; d++) {
        int nx = x, ny = y;
        for (int i = 0; i < l; i++) {
            if (dirs.find(s[0][i]) == d) {
                nx += di[d], ny += dj[d];
            }
            if (!valid(nx, ny)) {
                found = true;
                break;
            }
            if (dirs.find(s[1][i]) == (d ^ 1)) {
                if(valid(nx + di[d^1], ny + dj[d^1])){
                    nx += di[d^1], ny += dj[d^1];
                }
            }
        }
    }
    cout << (found ? "NO\n" : "YES\n");
    return 0;
}


Measured memory_bytes: 920
n, m = map(int, input().split())
sc_list = [list(input().split()) for _ in range(m)]
ans = -1
for i in range(10**n):
    if len(str(i)) != n:
        continue
    else:
        count = 0
        s = str(i)
        for sc in sc_list:
            if s[int(sc[0])-1] == sc[1]: 
                count += 1
        if count == m:
            ans = i
            break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
struct UnionFind{
	int par[51];
	void init(int N){rep(i,N) par[i]=i;}
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){return find(x)==find(y);}
	void unite(int x,int y){
		x=find(x),y=find(y);
		par[x]=y;
	}
}UF;
typedef long long ll;
ll N,M,A,n[2249],mod=1e9+7;
ll dp[200][200];
void add(ll &x,ll y){
	x+=y;
	x%=mod;
}
inline ll B(int x){return 1LL<<x;}
bool B(ll x,int i){return (x>>i)&1;}
bool is_pset(ll b){
	UF.init(M);
	rep(i,M) if((b>>i)&1){
		rep(j,M-i) UF.unite(j,j+i);
	}
	ll x=0;
	rep1(i,M-1){
		bool ok=1;
		rep(j,M-i) if(!UF.same(j,j+i)) ok=0;
		if(ok) x|=B(i);
	}
	return b==x;
}
int dim(ll b){
	UF.init(M);
	rep(i,M) if((b>>i)&1){
		rep(j,M-i) UF.unite(j,j+i);
	}
	int d=0;
	rep(i,M) if(i==UF.find(i)) d++;
	return d;
}
vector<ll> vc;
void enum_pset(int L,ll b){
	if(L==0){
		if(is_pset(b)) vc.pb(b);
		return;
	}
	rep1(p,L){
		if(p<=L/2){
			ll nb=b;
			for(int k=p;k<L;k+=p) nb|=B(k+M-L);
			enum_pset(L%p+p,nb);
		}else{
			ll nb=b;
			for(int k=p;k<L;k+=p) nb|=B(k+M-L);
			enum_pset(L-p,nb);
		}
	}
}
ll calc(ll x){
	rep(i,N) rep(j,N) dp[i][j]=0;
	dp[0][0]=1;
	rep(i,N-M) dp[i+1][i+1]=dp[i][i]*A%mod;

	rep(i,N-1) rep(j,N) if(dp[i][j]!=0){
		if(i+1+M<=N && (i+1>=j+M || B(x,i+1-j)) ){
			add(dp[i+1][i+1],-dp[i][j]);
		}
		if(i+1>=j+M) add(dp[i+1][j],dp[i][j]*A);
		else add(dp[i+1][j],dp[i][j]);
	}
	ll ret=0;
	rep(j,N) add(ret,dp[N-1][j]);
	return ret;
}

int main(){
	cin>>N>>M>>A;
	enum_pset(M,0);
	sort(all(vc));
	vc.erase(unique(vc.begin(),vc.end()),vc.end());
	int K=vc.size();
	reverse(all(vc));
	rep(i,K){
		int d=dim(vc[i]);
		n[i]=1;
		rep(j,d) n[i]=n[i]*A%mod;
	}
	ll ans=0;
	rep(i,K){
		ll tmp=calc(vc[i]);
		rep(j,i) if((vc[i]&vc[j])==vc[i]) add(n[i],-n[j]);
		add(ans,n[i]*tmp);
	}
	cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 3528
n = int(input())
a = list(map(int,input().split()))

def gcd(a, b):
    while b!=0:
        a,b=b,a%b
    return a

l = [0] * (n + 1)
r = [0] * (n + 1)
for i in range(n):
    l[i + 1] = gcd(l[i], a[i])

for i in reversed(range(n)):
    r[i] = gcd(r[i + 1], a[i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(l[i], r[i + 1]))

print(ans)

Measured memory_bytes: 14076
import java.util.*

fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    val map = HashMap<Char, ArrayList<Long>>()
    s.forEachIndexed { index, c ->
        val i = index.toLong()
        if (map[c] == null) {
            map[c] = arrayListOf(i, i + s.length)
        } else {
            with(map[c]!!) {
                add(i)
                add(i + s.length)
            }
        }
    }
    map.values.forEach { it.sort() }

    var ans = 0L
    t.forEach { c ->
        if (map[c] == null) {
            println("-1")
            return
        }
        val list = map[c]!!
        var b = list
                .binarySearch(ans % s.length)
                .let { if (it < 0) it.inv() else it }
        val p = list[b]
        ans += (p - ans % s.length + 1)
    }
    println(ans)
}

Measured memory_bytes: 50664
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int H,W,D;
    cin >> H >> W >> D;
    vector<pair<int,int> > num(H*W);
    vector<ll> accum(H*W);
    for(int i = 0;i < H;i++)for(int j = 0;j < W;j++){
        int a;
        cin >> a;
        num[a-1] = make_pair(i,j);
    }
    for(int i = 0;i < D;i++){
        pair<int,int> now = num[i];
        for(int j = i+D;j < H*W;j += D){
            accum[j] = accum[j-D] + abs(now.first - num[j].first) + abs(now.second - num[j].second);
            now = num[j];
        }
    }
    
    int Q;
    cin >> Q;
    for(int i = 0;i < Q;i++){
        int s,g;
        cin >> s >> g;
        s--,g--;
        cout << accum[g] - accum[s] << endl;
    }
    
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int h,n,sum=0;
	cin>>h>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) sum=sum+a[i];
	if(sum>=h) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int n;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int a=0;4*a<=n;a++) {
        int dif=n-4*a;
        if(dif%7) {
            continue;
        }
        int b=dif/7;
        cout<<"Yes\n";
        return 0;
    }
    cout<<"No\n";
    return 0;
}
/**

**/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

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

    map<string,int> count;
    rep(i,n){
        string s; cin >> s;
        count[s]++;
    }
    if(count.size() == 3)print("Three");
    else print("Four");
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])

Measured memory_bytes: 3064
#include <stdio.h>
#define m 1000000007
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    unsigned long long b[200003]={},i,j,s=0;
    for(i=1;i<=n+1;i++) {
        b[i]=1+i*(n+1-i);
        b[i]=b[i]%m;
    }
    for(j=k;j<=n+1;j++) {
        s+=b[j];
    }
    printf("%llu\n",s%m);
    

    return 0;
}

Measured memory_bytes: 3296
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>v(N + 2);
	for (int i = 1; i <= N; i++)cin >> v[i];
	int con = 0;
	int ans = 0;
	for (int i = 1; i <= N + 1; i++) {
		if (v[i] != v[i - 1]) {
			ans += con / 2;
			con = 1;
		}
		else con++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  int out = 0;
  double S;
  S = ((double)(W) * H) / 2;
  if((W % 2) == 0){
    if((H % 2) == 0){
      if((W / 2) == x){
        if((H / 2) == y){
          out = 1;
        }
      }
    }
  }
  cout << std::setprecision(10) << S << " " << out;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n, l;
  cin >> n >> l;

  vector<string> s(n);
  REP(i, n)
    cin >> s[i];

  sort(s.begin(), s.end());
  REP(i, n)
    cout << s[i];
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string l="qazwsxedcrfvtgb";
  string r="yhnujmikolp";
  while(1){
    string s;
    cin >> s;
    if(s[0]=='#') break;
    int str = 0;
    for(int i=0; i<(int)l.size(); i++){
      if(s[0]==l[i]) str=1;
    }
    int ans = 0;
    for(int i=0; i<(int)s.size(); i++){
      if(str==0){
        for(int j=0; j<(int)l.size(); j++){
          if(s[i]==l[j]){
            str=1;
            ans++;
          }
        }
      }
      else{
        for(int j=0; j<(int)r.size(); j++){
          if(s[i]==r[j]){
            str=0;
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}




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

using namespace std;

int main()
{
	int n, m, min;
	char c;
	scanf("%d", &n);
	
	vector<pair<char, int> > v;
	vector<pair<char, int> > b;
	vector<pair<char, int> > s;
	
	for(int i = 0; i < n; i++)
	{
		cin >> c >> m;
		v.push_back(make_pair(c, m));
		b.push_back(make_pair(c, m));
		s.push_back(make_pair(c, m));
	}
	
	for(int i = 0; i < b.size()-1; i++)
		for(int j = b.size()-1; j > i; j--)
			if(b[j].second < b[j-1].second)
				swap(b[j], b[j-1]);
			
	for(int i = 0; i < s.size()-1; i++)
	{
		min = i;
		
		for(int j = i; j <= s.size()-1; j++)
			if(s[j].second < s[min].second)
				min = j;
		if(s[min].second < s[i].second)
			swap(s[i], s[min]);
	}
	
	int i;
	
	for(i = 0; i < b.size()-1; i++)
		cout << b[i].first << b[i].second << " ";
	cout << b[i].first << b[i].second << "\nStable\n";
	
	bool cond = true;
	
	for(i = 0; i < b.size(); i++)
		if(!(b[i].first == s[i].first && b[i].second == s[i].second))
			cond = false;
	
	for(i = 0; i < s.size()-1; i++)
		cout << s[i].first << s[i].second << " ";
	cout << s[i].first << s[i].second << "\n";
	
	if(cond)
		printf("Stable\n");
	else
		printf("Not stable\n");
	
	return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a,b,k;
int main(){

cin>>a>>b>>k;
  if(a<=k)  
     if(a+b>=k){b=b+a-k,a=0;
	 }
     else  {a=0,b=0;}
   else {a=a-k,b=b;} 
     cout<<a<<" "<<b;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
 
int main() {
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <map>
#include <cstdlib>
#define INF (1000000007)
#define rep(i,N) for(ll i=0;i<N;i++)
#define rep2(i,j,k) for(ll i=j; i<k;i++)
typedef long long int ll;
using namespace std;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using vs=vector<string>;
using vvs=vector<vector<string>>;

template <typename T>
void print(T v){
    for(size_t i=0;i<v.size();i++){
        cout<<i<<": "<<v[i]<<endl;}
}

template <typename T>
void print2(T v){
    for(size_t i=0;i<v.size();i++){
        cout<<i<<": ";
        for(size_t j=0;j<v[0].size();j++){
            cout<<v[i][j]<<" ";
        }
        cout<<endl;
    }
}

template <typename T>
T slice(T v,ll left,ll right){
    T ret(0);
    copy(v.begin()+left,v.begin()+right,back_inserter(ret));
    return ret;
}

int main(){
    ll N;
    ll m=0;
    ll ans=0;
    cin>>N;
    vl h(N);
    rep(i,N){
        cin>>h[i];
    }
    
    rep(i,N){
        m=max(m,h[i]);
        if(m<=h[i]){
            ans++;
        }
    }
    
    cout<<ans<<endl;
            

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
long long int gcd(long long a,long long b)
{
	if(b==0)
	return a;
	else
	return gcd(b,a%b);
}
int main()
{
	int n,i;
	long long a[1000],com;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	if(n==1)
	printf("%lld",a[1]);
	else if(n==2)
	printf("%lld",a[1]/gcd(a[1],a[2])*a[2]);
	else
	{
		com=a[1]/gcd(a[1],a[2])*a[2];
		for(i=3;i<=n;i++)
		{
			com=com/gcd(com,a[i])*a[i];
		}
		printf("%lld\n",com);
	}
	return 0;
}

Measured memory_bytes: 128