akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
    int N,A;
    scanf("%d %d",&N,&A);
    if(N>A){
        if(N%500<=A){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    else{
        printf("Yes\n");
    }
	return 0;		
}

Measured memory_bytes: 128
import Data.List
import Data.Maybe
import qualified Data.IntSet as S

type Index = Int
type Memo = S.IntSet

-- data Props = Props { total :: Int, memo :: Memo } deriving Show

step :: (Int, Memo) -> (Int, Index) -> (Int, Memo)
step (total, memo) (x, i) = -- traceShow (props, x, i)
  (total', memo')
  where
    h = fromJust (S.lookupGT i memo) - i
    w = i - fromJust (S.lookupLT i memo)
    total' = total + x * h * w
    memo' = S.insert i memo

solve :: [Int] -> Int
solve l = total
  where
    n = length l
    l' = sort $ zip l [1..]
    init = (0, (S.fromList [0, n + 1]))
    (total, memo) = foldl' step init l'

main = getContents >>= print . solve . map read . words . last . lines


Measured memory_bytes: 84348
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		int ans = 0;

		for(;sc.hasNext();){

			String buffer = sc.next();

//			if(buffer.equals("ateer")) break;

			String rM = "";

			for(char c:buffer.toCharArray()){

				if(!Character.isDigit(c)){

					c=' ';

				}

				rM += c;

			}

			Scanner in = new Scanner(rM);

			for(;in.hasNextInt();){

				ans += in.nextInt();

			}

		}

		System.out.println(ans);

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int d = b / a;
    cout << (d < c ? d : c) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
signed main() {
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u)cout << a - 1 << " " << b << endl;
	else cout << a << " " << b - 1 << endl;
	ggr
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    string S;
    cin>>S;
    ll ans=0;
    for(int i=0; i<(1<<S.size()-1); i++){
        int insert_cnt=0;
        string T=S;
        for(int j=S.size()-2; j>=0; j--){
            if(i&(1<<j)){
                T.insert(T.size()-j-1,"+");
            }
        }
        ll num=0;
        rep(j,T.size()){
            if(T.at(j)=='+'){
                ans+=num;
                num=0;
                continue;
            }
            num*=10;
            num+=T.at(j)-'0';
        }
        ans+=num;
    }
    cout<<ans<<endl;
}


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

int main(void)
{
  int N;
  long int a = 0;
  long int nums[200000] = {0};
  unsigned long long int m,sum = 0;
  int i,j;

  scanf("%d",&N);
  for(i = 0;i < N;i++)scanf("%ld",&nums[i]);

  for(i = 1;i < N;i++)
  {
    a %= 1000000007;
    a += nums[i-1];
    m = nums[i] * a;
    m %= 1000000007;
    sum += m;
    sum %= 1000000007;
  }

  sum %= 1000000007;

  printf("%lld",sum);
  
  return 0;
}


Measured memory_bytes: 3264
import java.util.*;

public class Main {

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

    for (int i = 0; i < 101; i++) {
      for (int j = 0; j < 101; j++) {
        if (4*i + 7*j == n) {
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}


Measured memory_bytes: 22608
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long

using namespace std;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
string s;

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

  int ans = 0;
  char curr = ' ';

  Rep(i, N) {
    if (curr != s[i]) {
      ++ans;
      curr = s[i];
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 512
#include <bits//stdc++.h>
using namespace std;
struct Point{
    vector<pair<int,int>> next;
    int distance=0;
    int check=1;
};
int main(void){
    int a,b,i,j;
    cin>>a;
    Point points[a];
    for(i=0;i<a;i++){
        int p,dist,d,e;
        cin>>d>>e;
        for(j=0;j<e;j++){
            cin>>p>>dist;
            pair<int,int> t;
            t=make_pair(dist,p);
            points[d].next.push_back(t);
        }
    }
    
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
    q.push(make_pair(0,0));
    while(q.empty()==false){
        int v=q.top().second;
        int dist=q.top().first;
        q.pop();
        if(points[v].check){
            points[v].distance=dist;
            points[v].check=0;
            for(i=0;i<points[v].next.size();i++){
                int d1=points[v].next[i].first;
                int v1=points[v].next[i].second;
                if(points[v1].check)
                    q.push(make_pair(d1+dist,v1));
            }
        }
    }
    for(i=0;i<a;i++)
        cout<<i<<" "<<points[i].distance<<endl;
}



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

using namespace std;


int main() {
   
      string s;
       cin>>s;
  
      int i,cnt=0;
       
      for(i=0;i<s.length();++i)
      {
          if(s[i]=='o')
              cnt++;
      }
  
      if(cnt+(15-s.length())>=8)
          printf("YES");
  
      else
         printf("NO");
      
    	return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <stdlib.h>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll ans;

string next(string s){
  ll smallestNotSeven = s.length()-1;
  while(smallestNotSeven > -1){
    if(s[smallestNotSeven] != '7')
      break;
    smallestNotSeven--;
  }
  if(smallestNotSeven == -1) {
    string ne="";
    F0R(i,s.length()+1) ne +="3";
    return ne;
  }
  s[smallestNotSeven] +=2;
  FOR(i,smallestNotSeven+1,s.length()) s[i] = '3';
  return s;
}

bool isGod(string s){
  bool hSev = false;
  bool hFiv = false;
  bool hThre = false;
  F0R(i,s.length()) {
    if(s[i] == '3') hThre = true;
    if(s[i] == '5') hFiv = true;
    if(s[i] == '7') hSev = true;
  }
  if(hSev && hFiv && hThre) return true;
  return false;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    string x = "3";
    ll s =3;
    while(s <= n){
      if(isGod(to_string(s))) ans++;
      x = next(x);
      s = stoll(x);
    }
    cout << ans << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [a,b,x] <- map read . words <$> getLine :: IO [Integer]                                                                  
  let f = a `div` x                                                                                                        
      c = a - f * x                                                                                                        
      d = b - f * x                                                                                                        
      e = if c == 0 then d `div` x + 1 else d `div` x                                                                      
  print e

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && a==c){
		cout<<"No";
	}
	else if(a==b || b==c || a==c){
		cout<<"Yes";
	}
	else if(a!=b || b!=c){
		cout<<"No";
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main(){

	
	int idx,cor;
	map<int,int> info;
	set<int,greater<int> > rank;
	while(~scanf("%d,%d",&idx,&cor)){
		if(idx == cor && idx == 0) break;
		rank.insert(cor);
		info[idx] = cor;
	}

	while(~scanf("%d",&idx)){
		int i=1;
		for(set<int,greater<int> >::iterator it = rank.begin(); it != rank.end(); it++,i++){
			if(*it == info[idx]){
				cout << i << endl;
			}
		}
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        int ans = 0;

        for (int i = 1; i <= n; i += 2) {
            int cnt = 0;
            for (int j = 1; j <= i; j++) {
                if (i % j == 0) {
                    cnt++;
                }
            }
            if (cnt == 8) {
                ans++;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    const int mod=1000000007;
    int n,m;
    cin>>n>>m;
    int a[m];
    for(int i=0;i<m;i++)cin>>a[i];
    long long dp[n+1]={};
    dp[0]=1;
    for(int i=0;i<n;i++){
        if(binary_search(a,a+m,i+1) && binary_search(a,a+m,i+2)){
            cout<<"0"<<endl;
            return 0;
        }
        if(!binary_search(a,a+m,i+1))dp[i+1]+=dp[i]%mod;
        if(!binary_search(a,a+m,i+2) && i<n-1)dp[i+2]+=dp[i]%mod;
    }
    cout<<dp[n]%mod<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

double p[3000];
double dp[3000][3000];

int main() {
  int n;
  cin >> n;
  for(int i = 1; i<=n; i++) cin >> p[i];
  dp[0][0] = 1.0000000000;
  for(int i = 1; i<=n; i++) {
    for(int j = 0; j<=n; j++) {
      if(j==0) dp[i][j] = dp[i-1][j]*(1-p[i]);
      else dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
    }
  }
  double ans = 0;
  for(int i = (n+1)/2; i<=n; i++) {
    ans += dp[n][i];
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
 
int main() {
  ll a;
  ci(a);
  string c="No";
  ll b=0;
  for(i,0,a/4+1){
    for(j,0,a/7+1)
      if(4*i+7*j==a){
        c="Yes";
        b=1;
        break;
      }
    if(b==1)
      break;
  }
  co(c);
}

Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;

fn run(args: &Vec<String>) -> bool {
    let mut s: Vec<u32> = args[0].split(' ').map(|s| s.parse().unwrap()).collect();
    s.sort();
    s[0] == 5 && s[1] == 5 && s[2] == 7
}

fn main() {
    let stdin = io::stdin();
    let args = stdin.lock().lines().map(|l| l.unwrap()).collect();
    let r = run(&args);
    println!("{}", if r { "YES" } else { "NO" });
}


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

// positive only
int get_int() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return -1;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
int get_str(char *str) {
    int c = getchar_unlocked();
    if(c == -1) return -1;
    while(c > 32) {
        *str++ = (char)c;
        c = getchar_unlocked();
    }
    *str = 0;
    return 0;
}

#define M 49762109
char dic[M][13];

int str_key(char *str){
    int key = 0;
    for(int i = 1; *str; i*=3) {
        key += *str++ * i;
    }
    return key;
}
#define hash_key(k) ((k) % M)
#define hash_alt(k) (1 + ((k) % (M - 1)))
#define hash(k, i) ((hash_key(k) + (i) * hash_alt(k)) % M)
int dic_find(char *str){
    int key = str_key(str);
    size_t len = strlen(str);
    int hash;
    for(int i = 0;; ++i) {
        hash = hash(key, i);
        if(strlen(dic[hash]) == len && strncmp(dic[hash], str, len) == 0) return 1;
        if(strlen(dic[hash]) == 0) return 0;
    }
}
void dic_insert(char *str){
    int key = str_key(str);
    size_t len = strlen(str);
    int hash;
    for(int i = 0;; ++i) {
        hash = hash(key, i);
        if(strlen(dic[hash]) == len && strncmp(dic[hash], str, len) == 0) return;
        if(strlen(dic[hash]) == 0){
            strcpy(dic[hash], str);
            return;
        }
    }
}

int main(int argc, char **argv) {
    int n = get_int();
    char c[13];
    for(int i = 0; i < n; ++i) {
        get_str(c);
        if(*c == 'i') {
            get_str(c);
            dic_insert(c);
        } else {
            get_str(c);
            if(dic_find(c)) puts("yes");
            else puts("no");
        }
    }
    return 0;
}




Measured memory_bytes: 44588
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

int a,b,c,d,ans;
bool gett[105];

int main(){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for (int i=a;i<b;++i)gett[i]=1;
	for (int i=c;i<d;++i)ans+=gett[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
def solve(string):
    n, *b = map(int, string.split())
    b.append(b[-1])
    return str(b[0] + sum([min(b0, b1) for b0, b1 in zip(b, b[1:])]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ostream>
using namespace std;
template <typename T> void printRange(T &x) { for (auto y : x) cout << y << ' '; cout << endl; }
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define getNum(i) scanf("%d", &(i))
#define MODULO 321555123
#define INF 10000000007ll
#define FOR(i,j,k) for(int (i)=(j);(i)<=(k);(i)++)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define getNum(i) scanf("%d", &(i))
#define mp make_pair
#define reset(a) memset((a), 0, sizeof((a)))
 
const int maxn = 2e5 + 10;
 
int main() {
    IOS
    int m, n, k;
    cin >> n >> m >> k;
    FOR(r,0,n) {
        FOR(c,0,m) {
            if (r*m + c*(n-r) - r*c == k && (n>=r)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
 
    return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b;cin>>a>>b;
  cout<<(a<=8 && b<=8 ?"Yay!":":(")<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
 int main(){
     double x1,x2,y1,y2,k,x,y,z;
     scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
     x=x2-x1;
     y=y2-y1;
     z=x*x+y*y;
     z=sqrt(z);
     printf("%f\n",z);
     }



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

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            var Q = long.Parse(Console.ReadLine());
            var Bs = new long[Q + 1];
            var Cs = new long[Q + 1];

            for (int i = 1; i < Q + 1; i++)
            {
                var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                Bs[i] = read[0];
                Cs[i] = read[1];
            }

            var Ss = new long[Q + 1];
            Ss[0] = As.Sum();
            var numDict = new Dictionary<long, int>();
            for (int i = 0; i < N; i++)
            {
                if (numDict.ContainsKey(As[i]))
                    numDict[As[i]]++;
                else
                    numDict.Add(As[i], 1);
            }
            for (int i = 1; i < Q + 1; i++)
            {
                if (numDict.ContainsKey(Bs[i]))
                {
                    Ss[i] = Ss[i - 1] + numDict[Bs[i]] * (Cs[i] - Bs[i]);
                    if (numDict.ContainsKey(Cs[i]))
                        numDict[Cs[i]] += numDict[Bs[i]];
                    else
                        numDict.Add(Cs[i], numDict[Bs[i]]);
                    numDict.Remove(Bs[i]);
                }
                else
                    Ss[i] = Ss[i - 1];
            }
            for (int i = 1; i < Q + 1; i++)
            {
                Console.WriteLine(Ss[i]);
            }
        }
    }
}


Measured memory_bytes: 49328
n,m = map(int,input().split())
AC = [0] * n
WA = [0] * n
penalty = 0

for i in range(m):
    p,s = input().split()
    p = int(p) - 1
    
    if s == "WA":
        WA[p] += 1
    else:
        if AC[p] == 0:
            AC[p] = 1
            penalty += WA[p]
            
print(sum(AC),penalty)

Measured memory_bytes: 4596
s = int(input())

x1, x2, x3 = 0, 10 ** 9, 1
a = -(-s // (10 ** 9))
b = a * (10 ** 9) - s

y1, y2, y3 = 0, b, a

print(x1, y1, x2, y2, x3, y3)


#print(abs((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  char A, B;
  cin >> A >> B;
  if(A == 'D'){
    if(B == 'H') B = 'D';
    else B = 'H';
  }
  cout << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 2e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 1e9+7;

int n,m;
ll a[maxN];
pii b[maxN];
unordered_map<ll,ll> mp;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=m;i++)
	{	
		ll x,y;
		scanf("%lld%lld",&x,&y);
		b[i].first = y;
		b[i].second = x;
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+m);
	reverse(b+1,b+1+m);
	int st = 1;
	for(int i=1;i<=m;i++)
	{
		ll num = b[i].second;
		ll tmp = b[i].first;
		int j = st+num-1;
		if(j>n)
			j = n;
		int k;
		for(k = st;k<=j&&a[k]<tmp;k++)
		{
			a[k] = tmp;
		}
		if(k <= j)
			break;
		else
		{
			st = j+1;
			if(st>n)
				break;
		}
	}
	ll ans = 0;
	for(int i=1;i<=n;i++)
		ans += a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, j, k) for (int (i) = (j); (i) < (k); ++(i))
#define repr(i, j, k) for (int (i) = (j); (i) <= (k); ++(i))

using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;

void solve() {
	Int n;
	cin >> n;
	
	vector<Int> vi(n), ans(n);
	rep(i, 0, n) {
		cin >> vi[i];
	}
	
	Int sum = 0;
	rep(i, 0, n) {
		sum += ((i&1) ? -1 : 1) * vi[i];
	}
	ans[0] = sum/2;
	
	rep(i, 1, n) {
		ans[i] = vi[i-1] - ans[i-1];
	}
	
	rep(i, 0, n) {
		cout << 2*ans[i] << ' ';
	}
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 2944
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N, K; cin >> N >> K;
  vector<int> p(N); cin >> p;
  sort(p.begin(), p.end());
  int sum = 0;
  for (int i = 0; i < K; ++i) {
    sum += p[i];
  }
  cout << sum << endl;
}



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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   int N;
   cin>>N;
   vector<int>a(N);
   for(int i=0;i<N;i++)cin>>a[i];
   set<int>s;
   int tensai=0;
   for(int i=0;i<N;i++){
      if(a[i]<400)s.insert(0);
      else if(a[i]<800)s.insert(1);
      else if(a[i]<1200)s.insert(2);
      else if(a[i]<1600)s.insert(3);
      else if(a[i]<2000)s.insert(4);
      else if(a[i]<2400)s.insert(5);
      else if(a[i]<2800)s.insert(6);
      else if(a[i]<3200)s.insert(7);
      else tensai++;
   }

   ll ans_min = s.size();
   if(s.size()==0&&tensai>0)ans_min=1;
   ll ans_max=s.size()+tensai;
   cout << ans_min<<" "<<ans_max<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
const ll mod=1e9+7;
ll dp[65][2][2][2];
main()
{
    ll l,r;
    scanf("%lld%lld",&l,&r);
    int n=64;
    vector<ll> bl(n),br(n);
    for(int i=0;i<n;i++)
    {
        bl[i]=l%2;
        br[i]=r%2;
        l/=2;
        r/=2;
    }
    reverse(begin(bl),end(bl));
    reverse(begin(br),end(br));
    dp[0][0][0][0]=1;
    rep(i,n)rep(fl,2)rep(fr,2)rep(g,2)
    {
        if(dp[i][fl][fr][g]==0)continue;
        rep(bx,2)rep(by,2)
        {
            if(bx==1&&by==0)continue;
            if(!g&&bx+by==1)continue;
            if(!fl&&bl[i]&&!bx)continue;
            if(!fr&&!br[i]&&by)continue;
            dp[i+1][fl | (bx > bl[i])][fr | (by < br[i])][g | bx | by] += dp[i][fl][fr][g]%=mod;
        }
    }
    ll ans=0;
    rep(fl,2)rep(fr,2)rep(g,2)ans=(ans+dp[n][fl][fr][g])%mod;
    printf("%lld\n",ans);
    return 0;
}

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

int main() {
    vector<pair<int, int>> food(5);
    for (int i = 0; i < 5; i++) {
        int x, r; cin >> x;
        r = x % 10;
        if (r != 0) r = 10 - r;
        food.at(i) = make_pair(r, x);
    }
    sort(food.begin(), food.end());
    int time = 0;
    for (int i = 0; i < 4; i++) {
        time += food.at(i).first + food.at(i).second;
    }
    time += food.at(4).second;
    cout << time << endl;
}

Measured memory_bytes: 3600
#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<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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() {
    string s;
    int N;
    cin >> N >> s;
    int R = 0;
    int B = 0;

    REP(i,N){
        if (s[i] == 'R') R++;
        else B++;
    }

    if (R>B) puts("Yes");
    else puts("No");

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N, M, K, x, ql, qr, p[109], g[19][109], v[65555][109], dist[65555], que[6555555];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N >> M >> K;
	fill(p, p + N, -1);
	for (int i = 0; i < M; i++) {
		cin >> x;
		p[--x] = i;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) {
			cin >> x;
			if (p[i] != -1) g[p[i]][j] = --x;
		}
	}
	for (int i = 1; i < 1 << M; i++) {
		for (int j = 0; j < M; j++) {
			if (!((i >> j) & 1)) continue;
			for (int k = 0; k < K; k++) {
				if (p[g[j][k]] != -1) v[i][k] |= 1 << p[g[j][k]];
			}
		}
	}
	fill(dist, dist + (1 << M), -1);
	que[qr++] = (1 << M) - 1;
	dist[(1 << M) - 1] = 0;
	while (ql != qr) {
		int u = que[ql]; ql++;
		for (int i = 0; i < K; i++) {
			if (dist[v[u][i]] == -1) {
				dist[v[u][i]] = dist[u] + 1;
				que[qr++] = v[u][i];
			}
		}
	}
	cout << dist[0] << "\n";
	return 0;
}


Measured memory_bytes: 31616
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N;
    cin >> N;
    vector<int> h(N);
    rep(i, N) cin >> h[i];
    vector<int> f(N);

    ll ans = 0;
    bool flag = true;
    while(flag){
        int left = 0;
        rep(j, N){
            if(h[j] != 0){
                left = j;
                break;
            }
            if(j == N-1) flag = false;
        }
        bool check = false;
        for(int j = left; j < N; j++){
            if(h[j] != 0){
                h[j]--;
                ans++;
                if(check == false) check = true;
                else ans--;
            }else{
                check = false;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import Data.List

ans' [y1,m1,d1] [y2,m2,d2] =
  if [m1,d1] <= [m2,d2]
  then y1 - y2
  else y1 - y2 + 1

ans x =
  let [d1,d2] = reverse $ sort x -- d1 > d2
  in
    ans' d1 d2

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  print o



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

int main() {
    int N, M;
    cin >> N >> M;
    int ans = 0;
    vector<ll> H(N);
    vector<ll> ma(N, 0);
    rep(i, N) {
        cin >> H[i];
    }
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        ma[A-1] = max(ma[A-1], H[B-1]);
        ma[B-1] = max(ma[B-1], H[A-1]);
    }
    rep(i, N) {
        if (H[i] > ma[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include <iostream>
#include <cmath>
#include <vector>

int frac(int n)
{
    int v = 1;

    while(n > 1) {
        v *= n;
        n--;
    }

    return v;
}

int rate(const int n, const std::vector<int> p)
{
    std::vector<bool> f(n, 0);

    int v = 1;

    for (int i = 0; i < n; i++) {
        int num = p[i];
        int count = 0;
        for (int j = 0; j < num; j++) {
            if (f[j] == false) {
                count++;
            }
        }
        f[num] = true;
        v += count * frac(n - i - 1);
    }

    return v;
}

int main(int argc, char *argv[])
{
    int n;
    std::vector<int> p;
    std::vector<int> q;

    std::cin >> n;

    p.resize(n);
    q.resize(n);

    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < n; i++) {
        std::cin >> q[i];
        q[i]--;
    }

    const int rate_p = rate(n, p);
    const int rate_q = rate(n, q);

#ifdef _DEBUG
    std::cout << rate_p << std::endl;
    std::cout << rate_q << std::endl;
#endif

    std::cout << std::abs(rate_p - rate_q) << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.io.*;
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner();
        try (final FastWriter writer = new FastWriter()) {
            String N = scanner.next();
            int[] n = new int[N.length()];
            for (int i = N.length() - 1; i >= 0; i--) {
                n[i] = N.charAt(i) - '0';
            }
            int[] dp1 = new int[n.length], dp2 = new int[n.length];
            dp1[n.length - 1] = n[n.length - 1];
            dp2[n.length - 1] = 10 - n[n.length - 1];
            for (int i = n.length - 2; i >= 0; i--) {
                dp1[i] = Math.min(dp1[i + 1] + n[i], dp2[i + 1] + n[i] + 1);
                if (n[i] + 1 <= 10)
                    dp2[i] = Math.min(dp1[i + 1] + 10 - n[i], dp2[i + 1] + 10 - n[i] - 1);
                else dp2[i] = dp1[i + 1] + 10 - n[i];
            }
            writer.println(Math.min(dp1[0], dp2[0] + 1));
        }
    }
}

class FastScanner {
    private final BufferedReader br;
    private StringTokenizer st;

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (final IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

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

    public String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (final IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}

class FastWriter extends PrintWriter {
    public FastWriter() {
        super(new BufferedOutputStream(System.out));
    }

    public static void main(final String[] args) {
        try (final FastWriter w = new FastWriter()) {
            w.println(32);
        }
    }
}



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

int main() {
  string s, t; cin >> s >> t;
  bool flag = false;

  for(int i = 0; i < s.size(); i++) {
    char c = s[s.size()-1];
    for(int j = s.size()-1; j > 0 ; j--) {
      s[j] = s[j-1];
    }
    s[0] = c;
    if(s == t) {
      flag = true;
      break;
    }
  }

  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
var
	n,k,ans:int64;
	b:Longint;
begin
	read(n,k);
	for b:=k+1 to n do begin
		inc(ans,n div b*(b-k));
		if n mod b>=k then inc(ans,n mod b-k+1);
	end;
	if k=0 then dec(ans,n);
	writeln(ans);
end.

Measured memory_bytes: 128
import java.util.*;

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

	  while(true){
	     int H = sc.nextInt();
	     int W = sc.nextInt();
	     
		 if ( H == 0 && W == 0) break;
	     
		 for ( int i = 0; i < H; i++ ){
			    for ( int j = 0; j < W; j++ ){
			        if(i >= 1 && i < H-1 && j >= 1 && j < W-1){
			            System.out.print(".");
			        } else {
			            System.out.print("#");
			        }
			    }
			    System.out.println("");
		 }
	     System.out.println();	
	  }
   }
}



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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  string s; cin >> s;
  ll len = s.length();
  ll l = 0, r = len-1;
  ll result = 0;
  while (l<r) {
    if (s[l]==s[r]) { l++; r--; }
    else if (s[l]=='x') { l++; result++; }
    else if (s[r]=='x') { r--; result++; }
    else { cout << -1 << endl; return 0; }
  }
  cout << result << endl;
  return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
  public:
  vector<int> Parent; 
  
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    
    if(size(A) < size(B)) swap(A, B);
    
    Parent[A] += Parent[B];
    Parent[B] = A;
    
    return true;
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,k; cin>>n>>k;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  ll sum=0;
  rep(i,n)sum+=a[i];
  set<ll> candidates;
  for(int i=1; i*i<=sum; i++){
    if(sum%i==0){
      candidates.insert(i);
      candidates.insert(sum/i);
    }
  }
  ll ans=1;
  for(ll x: candidates){
    ll need;
    vector<ll> r(n);
    rep(i,n)r[i]=a[i]%x;
    sort(r.begin(), r.end());
    ll B=0;
    rep(i,n)B+=x-r[i];
    ll A=0;
    need=1e18;
    rep(i,n){
      A+=r[i];
      B-=x-r[i];
      chmin(need,max(A,B));
    }
    if(need<=k) chmax(ans,x);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#define ll long long

ll maximumProfit(ll *arr, int n) {
    int i;
    ll min = 1000000001;
    ll maxp = -1000000001;

    for (i = 1; i < n; i++) {
        if (arr[i-1] < min) min = arr[i-1];
        if (arr[i] - min > maxp) maxp = arr[i] - min;
    }

    return maxp;
}

int main(void) {
    int n, idx;
    scanf("%d", &n);
    ll arr[n];

    for (idx = 0; idx < n; idx++) scanf("%lld", &arr[idx]);

    printf("%lld\n", maximumProfit(&arr, n));

    return 0;
}


Measured memory_bytes: 3412
#include <iostream>

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  while (H != 0 && W != 0) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i % 2 == 0) {
          if (j % 2 == 0) {
            cout << "#";
          } else {
            cout << ".";
          }
        } else {
          if (j % 2 == 0) {
            cout << ".";
          } else {
            cout << "#";
          }
        }
      }
      cout << endl;
    }
    cin >> H >> W;
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<string, int> SI;

int main()
{
	int n, q; cin >> n >> q;
	queue<SI> que;

	rep (i, n ){
		string proc = "";
		int time = 0;
		cin >> proc >> time; 
		que.push (SI (proc, time ) );
	} // end rep
	vector<SI> res; res.clear();

	int ti = 0;
	while (!que.empty() ){
		SI curr = que.front(); que.pop();
		string name = curr.first;
		int time = curr.second;
		if (time <= q ){
			ti += time;
			res.push_back (SI (name, ti ) );
		}else{
			ti += q;
			time -= q;
			que.push (SI (name, time ) );
		} // end if
	} // end while
	rep (i, n ){
		cout << res[i].first << ' ' << res[i].second << endl;
	} // end rep
		
	return 0;
}

Measured memory_bytes: 5280
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
	string s;
	cin>>s;
	int pos=0,n=s.size(),i,j,b=0,r=0;
	while(pos<n){
		i=j=0;
		while(s[pos+i]=='>')++i;
		while(s[pos+i+j]=='<')++j;
		if(b<=i)r-=b;
		else r-=i;
		r+=i*(i+1)/2+j*(j+1)/2;
		b=j;
		pos+=i+j;
	}
	cout<<r<<"\n";
	return 0;
}

Measured memory_bytes: 900
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

TMPMAX = -float('inf')
for j in range(2):

    types = []
    last = [-1] * 26
    S = 0
    for d in range(D):
        # search type
        M = -float('inf')
        for tt in range(26):
            _last = last[:]
            tmp = s[d][tt]

            _last[tt] = d
            for i in range(26):
                tmp -= c[i] * (d - _last[i])

            if tmp > M:
                M = tmp
                M_tt = tt

        S += s[d][M_tt]

        last[M_tt] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        types.append(M_tt)


    last = [-1] * 26
    S = 0

    if j == 0:
        r = list(range(D))
    else:
        r = list(reversed(range(D)))
    for d in r:
        seq = []
        for tt in range(26):
            _last = last[:]
            tmp = s[d][tt]

            _last[tt] = d
            for i in range(26):
                tmp -= c[i] * (d - _last[i])

            seq.append([tmp, tt])

        seq.sort(reverse=True)

        tmpmax = -float('inf')
        for i in range(15):
            tt = seq[i][1]
            _last = last[:]
            _types = types[:]
            _types[d] = tt
            _S = S

            for dd in range(d, D):
                _S += s[dd][_types[dd]]
                _last[_types[dd]] = dd
                for i in range(26):
                    _S -= c[i] * (dd - _last[i])

            if _S > tmpmax:
                cand = tt
                tmpmax  = _S

        S += s[d][cand]
        last[cand] = d
        for i in range(26):
            S -= c[i] * (d - last[i])

    if S > TMPMAX:
        ans = types
        TMPMAX = S

for _ans in ans:
    print(_ans + 1)


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

int main() {
#ifdef _test
    freopen( "in.txt", "r", stdin);
#endif

    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for ( int i = 0; i<k; ++i) {
        int x;
        cin >> x;
        for (int i = 0; i<x; i++) {
            int m;
            cin >> m;
            v[m-1]++;
        }
    }
    int x = 0;
    for(auto it: v) {
        if ( it == 0) x++;
    }
    cout << x << '\n';
    return 0;
}


Measured memory_bytes: 3640
import collections

N = int(input())
H = list(map(int, input().split()))

d = collections.defaultdict(int)
count = 0
updated = True

while updated:
  updated = False

  for n in range(N):
    if H[n] > d[n]:
      d[n] += 1
      updated = True

      if n == N-1:
        count += 1
      elif H[n+1] <= d[n+1]:
        count += 1


print(count)

Measured memory_bytes: 3444
N, M = map(int, input().split())

B = [[1, 0] for i in range(N)]

B[0][1] = 1

for i in range(M):
    x, y = map(int, input().split())
    if B[x - 1][1] == 1:
        B[y - 1][1] = 1
    B[x - 1][0] -= 1
    B[y - 1][0] += 1
    if B[x - 1][0] == 0:
        B[x - 1][1] = 0

cnt = 0
for i in range(N):
    if B[i][1] == 1:
        cnt += 1

print(cnt)


Measured memory_bytes: 13172
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int a, b;
	cin >> a >> b;
	if(a>=13) cout << b << endl;
	else if(a>=6) cout << b/2 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;


void solve(){
	int n;
	cin>>n;
	int a[n];
	int x[n][15],y[n][15];
	rep(i,n){
		cin>>a[i];
		rep(j,a[i]){
			cin>>x[i][j]>>y[i][j];
			--x[i][j];
		}	
	}
	int ans=0;
	for(int mask=0;mask<(1<<n);++mask){
		int c[n];
		int res=0;
		rep(i,n){
			if(mask&(1<<i))c[i]=1,res++;
			else c[i]=0;
		}
		//cerr<<"res is"<<res<<'\n';
		bool ok=1;
		rep(i,n){
			if(c[i]){
				rep(j,a[i]){
					if(c[x[i][j]]!=y[i][j])ok=0;
				}
			}
		}
		if(ok)umax(ans,res);
	}
	cout<<ans;
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3644