akhauriyash/Code-Regression huggingface dataset:
from collections import deque


def bfs(start):
    q = deque([[start]])
    visited = set()
    while q:
        path = q.popleft()
        i, j = path[-1]
        if (i, j) == (H - 1, W - 1):
            return path
        for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            ni, nj = i + di, j + dj
            if (
                0 <= ni < H
                and 0 <= nj < W
                and field[ni][nj] != "#"
                and (ni, nj) not in visited
            ):
                q.append(path + [(ni, nj)])
                visited.add((ni, nj))


H, W = map(int, input().split())
field = [input() for _ in range(H)]
shortest_path = bfs((0, 0))
if shortest_path is None:
    print(-1)
    exit()
ans = 0
for i in range(H):
    for j in range(W):
        if field[i][j] == "." and (i, j) not in shortest_path:
            ans += 1
print(ans)


Measured memory_bytes: 9636
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>

using namespace std;
typedef long long ll;

ll solve(ll X)
{
	ll n = X / 11;
	ll m = X % 11;
	ll ans = n * 2;
	if (m > 0)
		ans += (m / 7) + 1;
	return ans;
}
int main()
{
	ll X;
	cin >> X;
	cout << solve(X) << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main {
     
     
     
    public static void main(String args[]){
        try(Scanner sc=new Scanner(System.in)){
            int n=sc.nextInt();
            int x=n;
            int count=n;
            for(int i=2; i*i<=x; i++) {
                if(n%i==0) {
                    count-=count/i;
                    while(n%i==0) {
                        n/=i;
                    }
                }
            }
            if(n>1) {
                count-=count/n;
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 26232
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(void){
  int n, k;
  bool app = true;
  
  cin >> n;
  
  for(int i=0; i<n; i++){
    cin >> k;
    if(k%2==0){
      if(k%3==0 || k%5==0){
        app = true;
      }
      else{
        app = false;
        break;
      }
    } 
  }
  
  if(app) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  
  return 0;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  
  map<int,int> maps;
  for(int i=0;i<n;i++)
    maps[i+1]=0;
  
  for(int i=0;i<k;i++)
  {
    int d;
    cin>>d;
    vector<int> a(d);
    for(int j=0;j<d;j++)
    {
      cin>>a[j];
      maps[a[j]]=1;
    }
  }
  
  int result=0;
  for(int i=0;i<n;i++)
  {
    if(maps[i+1]==0)
      result++;
  }
  cout<<result;
}
      

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;

vector<string> a;

int main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   string s;
   int K;

   cin >>s >> K;

   for (int i=0; i < s.length(); ++i) {
      string tmp = string("") + (s[i]);
      a.push_back(tmp);
      for (int j=1; j<=5 && j+i < s.length(); ++j) {
         tmp += s[i+j];
         a.push_back(tmp);
      }
   }

   sort(a.begin(), a.end());
   a.erase(unique(a.begin(), a.end()), a.end());


   outl(a[K-1]);

}



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int x = A + B + C;
  int y = max(A, max(B, C));

  if (x % 2 == 3 * y % 2) {
    cout << (3 * y - x) / 2 << endl;
  } else {
    cout << (3 * (y + 1) - x) / 2 << endl;
  }
}


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

int main() {
int N;
  int A[3][3];
  int B[3][3];
  int result = 0;
  for(int a = 0;a < 3;a++){
    for(int b = 0;b < 3;b++){
      cin >> A[a][b];
      B[a][b] = 0;
    }
  }
  cin >> N;
  int C[N];
  for(int a = 0;a < N;a++){
   cin >> C[a];
    for(int b = 0;b < 3;b++){
    for(int c = 0;c < 3;c++){
      if(A[b][c] == C[a]){
      B[b][c] = 1;
      }
    }
  }
  }
  
  if(B[0][0]==1&&B[0][1]==1&&B[0][2]==1){
    result = 1;
  }
  if(B[1][0]==1&&B[1][1]==1&&B[1][2]==1){
    result = 1;
  }
  if(B[2][0]==1&&B[2][1]==1&&B[2][2]==1){
    result = 1;
  }
  if(B[0][0]==1&&B[1][0]==1&&B[2][0]==1){
    result = 1;
  }
  if(B[0][1]==1&&B[1][1]==1&&B[2][1]==1){
    result = 1;
  }
  if(B[0][2]==1&&B[1][2]==1&&B[2][2]==1){
    result = 1;
  }
  if(B[0][0]==1&&B[1][1]==1&&B[2][2]==1){
    result = 1;
  }
  if(B[2][0]==1&&B[1][1]==1&&B[0][2]==1){
    result = 1;
  }
 if(result==1)cout<<"Yes"<<endl;
  if(result==0)cout<<"No"<<endl;
}

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

int main()
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  tx -= sx;
  ty -= sy;
  string res = "";
  rep(i, ty) res.push_back('U');
  rep(i, tx) res.push_back('R');
  rep(i, ty) res.push_back('D');
  rep(i, tx) res.push_back('L');
  res.push_back('L');
  rep(i, ty + 1) res.push_back('U');
  rep(i, tx + 1) res.push_back('R');
  res.push_back('D');
  res.push_back('R');
  rep(i, ty + 1) res.push_back('D');
  rep(i, tx + 1) res.push_back('L');
  res.push_back('U');
  
  cout << res << endl;
  
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll a;
	double b;
	cin >> a >> b;
	
	ll b100 = (ll)(b * 100 + 0.001);
	cout << a * b100 / 100 << endl;

	return 0;
}

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

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

int main(){
    int x, y;
    cin >> x >> y;
    cout << (x+1)+(y+1)-gcd(x, y)-1 << endl;
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<string>

using namespace std;

int N;
vector<vector<int>> to(100000),co(100000);
vector<int> ans(100000,-1);
vector<bool> on(100000,false);
int dfs(int a);
void solve();
int main(){
    cin >> N;
    for(int i=0;i<N-1;i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        to[u].push_back(v);co[u].push_back(w);
        to[v].push_back(u);co[v].push_back(w);
    }
    solve();
}

int dfs(int a){//bugged
    if(a>N) return -1;
    if(a==0) return 0;
    if(ans[a]!=-1 && ans[a]!=-2) return ans[a];
    on[a]=true;
    int ret;
    for(int i=0;i<to[a].size();i++){
        int b = to[a][i];
        int w = co[a][i];
        if(!on[b]) ret = dfs(b);
        if(ret==-1) continue;
        ans[a] = (ret+w)%2;
        break;
    }
    on[a]=false;
    return ans[a];
}

void solve(){
    ans[0]=0;
    for(int i=0;i<N;i++) cout << dfs(i) << endl;
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll a;
    ll sum=0;
    cin>>a;
    ll aa[a], bb[a], cc[a];
    for (int i=0; i<a; i++) cin>>aa[i];
    for (int i=0; i<a; i++) cin>>bb[i];
    for (int i=0; i<a-1; i++) cin>>cc[i];
    sum=bb[aa[0]-1];
    for (int i=1; i<a; i++){
        sum+=bb[aa[i]-1];
        if (aa[i]-aa[i-1]==1) sum+=cc[aa[i]-2];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long mod = 1000000007;
        long[] dp = new long[n + 1];
        dp[0] = 1;
        for (int i = 3; i <= n; i++) {
            for (int j = 3; j <= i; j++) {
                dp[i] = (dp[i] + dp[i - j]) % mod;
            }
        }
        System.out.println(dp[n]);
    }
}


Measured memory_bytes: 35820
n = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7
ans = 0

for k in range(60):
    x, y = 0, 0
    for a in A:
        x += 1 & a >> k
    tmp = x * (n - x) % mod
    tmp *= 2**k%mod
    ans += tmp
    ans %= mod
print(ans)


Measured memory_bytes: 124484
#include <stdio.h>

#define NUM 10000

int main()
{
	int a[NUM], b[NUM], ans[NUM], i = 0;
	char op[NUM];
	
	while(1) {
		scanf("%d %c %d", &a[i], &op[i], &b[i]);
		if (op[i] == '?') {
			break;
		}
		i++;
	}
	
	i = 0;
	
	while(1) {
		if (op[i] == '+') {
			ans[i] = a[i]+b[i];
		}
		if (op[i] == '-') {
			ans[i] = a[i]-b[i];
		}
		if (op[i] == '*') {
			ans[i] = a[i]*b[i];
		}
		if (op[i] == '/') {
			ans[i] = a[i]/b[i];
		}
		if (op[i] == '?') {
			break;
		}
		
		printf("%d\n", ans[i]);
		i++;
	}
	
	return 0;
}

Measured memory_bytes: 616
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
fact = math.factorial
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
num1 = 1000
num2 = 0
F = 0
s = [1000]
for i in range(N-1):
    if A[i] > A[i+1] and F == 1:
        num1 += num2*A[i]
        s.append(num1)
        num2 = 0
        F = 0
    if A[i] < A[i+1] and F == 0:
        num2 = num1 // A[i]
        num1 -= A[i]*(num1//A[i])
        s.append(num1)
        F = 1

    if i+1 == N-1:
        s.append(num1+num2*A[i+1])
print(max(s[-1],s[-2]))

Measured memory_bytes: 9988
#include <iostream>
#include <string.h>
#include <stdlib.h>

using namespace std;

int n, r, p, c;
int cards[50];
int temp[50];

int main()
{
	while( 1 )
	{
		cin >> n >> r;
		if(n==0 && r==0) break;
		
		for(int i=0; i<n; i++) cards[i] = n-i-1;
		for(int i=0; i<r; i++)
		{
			cin >> p >> c;
			memcpy(&temp[0], &cards[p-1], sizeof(int) * c);
			memcpy(&temp[c], &cards[0], sizeof(int) * (p-1));
			for(int j=0; j<p+c-1; j++) cards[j] = temp[j];
		}
		printf("%d\n", cards[0]+1);
   	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
int  main()
{
	ll n;;
	scanf("%lld",&n);
	printf("%lld\n",n*(n-1)/2);
}

Measured memory_bytes: 256
#121-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,m=IL()
c=[IL() for i in range(n)]
c.sort()
cnt=0
ans=0
for i in range(n):
    if cnt+c[i][1]>=m:
        ans+=(m-cnt)*c[i][0]
        break
    else:
        cnt+=c[i][1]
        ans+=c[i][0]*c[i][1]
print(ans)

Measured memory_bytes: 27872
package main

import (
	."fmt"
	."os"
)

func main() {
	var a,b int
	Scan(&a,&b)
	for i := 1; i<=3; i++{
		if (a*b*i)%2 == 1{
			Println("Yes")
			Exit(0)
		}
	}
	Println("No")
}


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

int solver(vector<int>& dp, int N){
  if(dp[N] == -1){
    dp[N] = solver(dp, N-1) + solver(dp, N-2);
  }
  dp[N] %= 1000000007;
  return dp[N];
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> dp(N+1, -1);
  for(int ii=0; ii<M; ii++){
    int a;
    cin >> a;
    dp[a] = 0;
  }
  dp[0] = (dp[0]==0) ? 0 : 1;
  dp[1] = (dp[1]==0) ? 0 : 1;
  cout << solver(dp, N) << endl;
  return 0;
}


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

int main () {
	int N, A, B;
	scanf ("%d%d%d", &N, &A, &B);
	while (true) {
		if (A == 1 && B == 2) {
			puts ("Borys");
			return 0;
		}
		if (A + 1 == B) --A;
		else ++A;
		if (A == N - 1 && B == N) {
			puts ("Alice");
			return 0;
		}
		if (A + 1 == B) ++B;
		else --B;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	if (n % 2 == 0)cout << n << endl;
	else cout << n * 2 << endl;
	return 0;
}

Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    std::vector<ll> v(n);
    ll sum=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>v[i];
        sum+=v[i];
    }
    ll ans=0;
    for (int i = 0; i < n-1; ++i)
    {
        sum=sum-v[i];
        ans=(ans+(v[i]*(sum%M))%M)%M;
    }
    cout<<ans<<'\n';
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

int factorize(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}

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


    int last_1 = -1;
    char first_1_igai = 0;
    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        if (c != '1') {
            first_1_igai = c;
            break;
        } else {
            last_1 = i;
        }
    }

    if (k- 1 <= last_1) {
        cout << '1' << endl;
    } else {
        cout << first_1_igai << endl;
    }

}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
S = 0
for j in range(N+1):
    S+=abs(A[j]-A[j+1])
for i in range(N):
    ans = S-abs(A[i]-A[i+1])-abs(A[i+1]-A[i+2])+abs(A[i]-A[i+2])
    print(ans)

Measured memory_bytes: 14048
package main

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

func main() {
	var a int
	var b string
	fmt.Scan(&a)
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	b = stdin.Text()
	c := strings.Split(b, " ")
	var d = []int{}
	for _, j := range c {
		temp, _ := strconv.Atoi(j)
		d = append(d, temp)
	}
	var result = 0
	for i, j := range d {
		e := d[0 : i+1]
		sort.Ints(e)
		if j >= e[len(e)-1] {
			result++
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
/*{{{*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define mset(x,c) memset(x, c, sizeof(x))
#define mem0(x) mset(x,0)
#define mem1(x) mset(x,-1)
#define memc(x,y) memcpy(x, y, sizeof(x));
#define P(a,n) FOR(_,0,n) _W(a),printf("%c", " \n"[_==n-1])
#define print(a,n) cout << #a << " = ";FOR(_,0,n) _W(a),printf("%c", " \n"[_==n-1])
using namespace std;

template<class T> void _R(T &x) { cin >> x; }
void _R(signed &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const signed &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.fi); putchar(' '); _W(x.se);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef LOCAL
 #define debug(...) {printf(" [" #__VA_ARGS__ "]: ");W(__VA_ARGS__);}
#else
 #define debug(...)
#endif

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
/*}}}*/
//#define int long long

signed main() {
#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	int cur = 1, h, w;
	R(h, w);
	set<pair<int,int> > s;
	multiset<int> t;
	FOR(i,1,w+1) s.insert(mp(i,i)), t.insert(0);
	FOR(i,0,h) {
		int l, r;
		R(l, r);
		int tmp = 0;
//		puts("!");
		for (auto it = s.lower_bound(mp(l,0)); it != s.end() && it->fi <= r; s.erase(it++)) {
//			W(it->fi, it->se);
			t.erase(t.find(it->fi - it->se));
//			puts("!");
			tmp = max(tmp, it->se);
		}
		if (tmp && r != w) {
			t.insert(r+1-tmp);
			s.insert(mp(r+1, tmp));
		}
		if (!t.empty()) W(i+1 + *t.begin());
		else W(-1);
	}
}


Measured memory_bytes: 22476
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	int h;
	int w;
	int d;
	int[] x;
	int[] y;
	void run() {

		h = sc.nextInt();
		w = sc.nextInt();
		d = sc.nextInt();

		x = new int[h * w + 1];
		y = new int[h * w + 1];

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int k = sc.nextInt();
				x[k] = i;
				y[k] = j;
			}
		}

		m = new int[h * w + 1];
		int q = sc.nextInt();

		for(int i = 0 ; i< q; i++)
		{
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(query(l,r));
		}
	}

	int[] m;

	int query(int l,int r) {
		return search(r)- search(l) ;
	}
	
	int search(int target ){
		if(target - d<= 0 ){
			return 0;
		}
		if(m[target] != 0 ){
			return m[target];
		}
		
		int res;
		res = search(target - d);
		res += Math.abs(x[target] - x[target-d]);
		res += Math.abs(y[target] - y[target-d]);
		
		m[target] = res;
		return res;
	}
	
}

Measured memory_bytes: 101732
X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse = True)[: X]
q = sorted(list(map(int, input().split())), reverse = True)[: Y]
r = list(map(int, input().split()))

all_apple = sorted(p + q + r, reverse = True)
print(sum(all_apple[: X + Y]))

Measured memory_bytes: 22488
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
    int n,a[200000],b[200000];
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    long long z=0,A=0,B=0;
    for(int i=0;i<n;i++) A+=a[i],B+=b[i];
    if(A<B) cout<<-1;
    else{
        long long E[200000],x=A-B,ans=0;
        for(int i=0;i<n;i++) E[i]=a[i]-b[i];
        sort(E,E+n);
        for(int i=0;i<n;i++){
            if(E[i]>=0&&x>=0)  x-=E[i],ans++;
        }
        if(x<0) cout<<n-ans+1;
        else cout<<n-ans;
    }
}

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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  void solve(std::istream& in, std::ostream& out)
  {
    int n;
    in >> n;
    vector<int> a(n);
    for(auto&& i : a) {
      in >> i;
    }
    int cnt = 0;
    long long b[2];
    sort(a.rbegin(), a.rend());
    for(int i = 0; i < n; i++) {
      int k = upper_bound(a.rbegin(), a.rend(), a[i]) - lower_bound(a.rbegin(), a.rend(), a[i]);
      if(!cnt && k >= 4) {
        b[0] = a[i];
        b[1] = a[i];
        cnt += 2;
        break;
      }
      if(k >= 2) {
        b[cnt] = a[i];
        cnt++;
        if (cnt >= 2) break;
      }
      i += k - 1;
    }
    if (cnt < 2) {
      out << 0 << "\n";
    }
    else {
      out << b[0] * b[1] << "\n";
    }
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    string s;
    cin>>s;
    int sum=700;
    REP(i,3)if(s[i]=='o')sum+=100;
    cout<<sum<<endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int  k,n; cin >> k >> n;
    vi a(n); rep(i,n) cin >> a[i];
    sort(all(a));

    int ans = inf;
    for(int i = 0; i < n; ++i) {
        int dist1, dist2;
        if(i==n-1) {
            dist1 = min(a[0]+k-a[n-1], a[n-1]-a[0]);
             dist2 = min(a[n-1]-a[n-2], a[n-2]+k-a[n-1]);
        }
        else {
             dist1 = min(a[i+1]-a[i], a[i]+k-a[i+1]);
             dist2 = min(a[i]-a[i-1], a[i-1]+k-a[i]);
        }

        chmin(ans, min(k-dist1, k-dist2));
    }
    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 1024
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro nlet (name args &body body)
  (labels ((ensure-list (x) (if (listp x) x (list x))))
    (let ((args (mapcar #'ensure-list args)))
      `(labels ((,name ,(mapcar #'car args) ,@body))
         (,name ,@(mapcar #'cadr args))))))

(declaim (inline split-ints-into-vector))
(defun split-ints-into-vector (string dest-vector &key (offset 0) (key #'identity))
  (declare (string string)
           (function key)
           ((array * (*)) dest-vector)
           ((integer 0 #.most-positive-fixnum) offset))
  (loop with position = 0
        for idx from offset below (length dest-vector)
        do (setf (values (aref dest-vector idx) position)
                 (parse-integer string :start position :junk-allowed t))
           (setf (aref dest-vector idx) (funcall key (aref dest-vector idx)))
        finally (return dest-vector)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

;; Let the sequence (Ai) be 0-based.
;; 1. A(0)+...+A(r0-1)+A(r0) where r0 is the first index that causes overflow.
;; 2. A(1)+...+A(r1-1)+A(r1) where r1 ...

;; result = r0 + (r1-1) + (r2-2) + ... + rn-1
(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (as (make-array n :element-type 'uint32)))
    (split-ints-into-vector (read-line) as)
    (nlet recurse ((l 0) (r 0) (psum (aref as 0)) (pxor (aref as 0)) (count 0))
      (declare (uint32 l r psum pxor)
               (fixnum count))
      (if (= l n)
          (println count)
          (loop for i from r below n
                for csum of-type uint32 = psum then (+ csum (aref as i))
                for cxor of-type uint32 = pxor then (logxor cxor (aref as i))
                while (= csum cxor)
                finally
                   (return (recurse (1+ l)
                                    i
                                    (- (or csum psum) (aref as l))
                                    (logxor (or cxor pxor) (aref as l))
                                    (+ count (- i l)))))))))

#-swank(main)


Measured memory_bytes: 31200
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, K;
    cin >> N >> K;
    vector<long> p(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    ll total = 0;
    for(size_t i=0;i<K; i++)
    {
        total += p[i];
    }
    cout << total << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3624
use std::io;
use std::str::FromStr;

fn main() {
    let mut vec: Vec<usize> = Vec::new();

    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (n, k) = (it.next().unwrap(), it.next().unwrap());

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    
    for _ in 0..n {
        let n: usize = it.next().unwrap();
        vec.push(n);
    }

    let mut sum: usize = 0;

    for _ in 0..k {
        let mut m = 0;
        for i in 0..n {
            m = if vec[m] < vec[i] { 
                i
            } else {
                m
            }
        }
        sum = sum + vec[m];
        vec[m] = 0
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
int main(){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    int K;
    scanf("%d",&K);
    int ans=0;
    while(A>=B){
        B *= 2;
        ans++;
    }
    while(B>=C){
        C *= 2;
        ans++;
    }
    if(ans<=K)
        printf("Yes");
    else
        printf("No");
}


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

ll solve() {
    int N, d;
    cin >> N;
    vector<int> nd(13);
    nd[0]++;
    for ( int i = 0; i < N; i++ ) {
        cin >> d;
        nd[d]++;
    }
    for ( int i = 1; i < 12; i++ ) {
        if ( nd[i] > 2 ) return 0;
    }
    if ( nd[0] > 1 ) return 0;
    if ( nd[12] > 1 ) return 0;
    vector<int> d1, d2, d0;
    if ( nd[12] > 0 ) d0.push_back(12);
    for ( int i = 1; i < 12; i++ ) {
        if ( nd[i] == 1 ) d1.push_back(i);
        else if ( nd[i] == 2 ) d2.push_back(i);
    }

    ll ans = 0;
    for ( int k = 0; k < (1<<d1.size()) ; k++ ) {
        vector<int> d;
        d.push_back(0);
        d.push_back(24);
        for ( int j = 0; j < d0.size(); j++ ) {
            d.push_back(d0[j]);
        }
        for ( int j = 0; j < d2.size(); j++ ) {
            d.push_back(d2[j]);
            d.push_back(24-d2[j]);
        }
        for ( int i = 0; i < d1.size(); i++ ) {
            if ( (k>>i) & 1 ) d.push_back(d1[i]);
            else d.push_back(24-d1[i]);
        }
        sort(d.begin(), d.end());
        int mn = 24;
        for ( int i = 1; i < d.size(); i++ ) {
            int diff = d[i] - d[i-1];
            if ( mn > diff ) mn = diff;
        }
        if ( ans < mn ) ans = mn;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter



def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

def main():
    N = int(input())
    c = Counter()

    for i in range(1, N + 1):
        for j in prime_factors(i):
            c[j] += 1

    ans = 1
    for k in c.keys():
        ans *= (c[k] + 1)

    print(ans % (10 ** 9 + 7))

    

if __name__ == '__main__':
    main()




Measured memory_bytes: 3316
N = int(input())
S = list(input())

reS = S[::-1]

wSum = [0 for i in range(N)]
eSum = [0 for i in range(N)]

for i in range(N):
    if i == 0:
        if S[i] == 'W':
            wSum[i] = 1
        if reS[i] == 'E':
            eSum[i] = 1
    else:
        if S[i] == 'W':
            wSum[i] = wSum[i-1] + 1
        else:
            wSum[i] = wSum[i-1]
        if reS[i] == 'E':
            eSum[i] = eSum[i-1] + 1
        else:
            eSum[i] = eSum[i-1]

eSum = eSum[::-1]

cost = eSum[1]

for i in range(1,N):
    if i == N - 1:
        if cost > wSum[N-2]:
            cost = wSum[N-2]
    else:
        if cost > wSum[i-1] + eSum[i+1]:
            cost = wSum[i-1] + eSum[i+1]
print(cost)


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


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

Measured memory_bytes: 256
import java.util.*;

public class Main {

  static int N;

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    N = sc.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    int[] C = new int[N];

    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    
    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }
    
    for (int i = 0; i < N; i++) {
      C[i] = sc.nextInt();
    }

    sc.close();

    Arrays.sort(A);
    Arrays.sort(C);

    long count = 0;

    for (int i = 0; i < N; i++) {
      count += binary_search(A, B[i]) * (N - binary_search(C, B[i] + 1));
    }

    System.out.println(count);

  }

  public static long binary_search(int[] a, int x) {

	int l = -1;
	int r = N;
    
    while(r - l > 1) {

	  int i = (l + r) / 2;
      
      if(x <= a[i]) {
        r = i;
      } else {
        l = i;
      }

	}
	return r;
  }

}

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

long long abs(long  a){return (a >= 0) ? a : -a; }
long long min(long a, long b){return ( a > b) ? b : a;}
int main(){
    int n; cin >> n;
    int a[n+1];
    long long sum[n+1] = {}, sum2[n];
    for(int i = 1; i <= n; i++) cin >> a[i];
    sum[1] = a[1];
    for(int i = 2; i <= n; i++){
        sum[i] += sum[i-1] + a[i];
    }
    long long mini = sum[n];
    for(int i = 1; i < n; i++){
        sum2[i] = sum[n] - sum[i];
    }
    for(int i = 1; i < n; i++){
        mini = min(mini, abs(sum2[i]-sum[i]));
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 4096
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using Um = unordered_map<char,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

vector<long long> divisor(long long n) {
vector<long long> ret;
for (long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) ret.push_back(n / i);
}
}
sort(ret.begin(), ret.end()); // 昇順に並べる
return ret;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    Um um;
    for(ll i=0;i<H;++i)
        for(ll j=0;j<W;++j){
            char c;cin>>c;um[c]++;
        }
    if(H%2==0&&W%2==0){
        bool ok=1;
        for(auto p: um){
            if(p.second%4!=0){
                ok=0;break;
            }
        }
        if(ok){
            prt("Yes");
        }
        else prt("No");
    }
    else if(H%2==1&&W%2==0){
        vector<ll> vec(4,0);
        for(auto p: um){
            vec[p.second%4]++;
        }
        if(vec[1]==0&&vec[3]==0&&vec[2]<=W/2){
            prt("Yes");
        }
        else prt("No");
    }
    else if(H%2==0&&W%2==1){
        vector<ll> vec(4,0);
        for(auto p: um){
            vec[p.second%4]++;
        }
        if(vec[1]==0&&vec[3]==0&&vec[2]<=H/2){
            prt("Yes");
        }
        else prt("No");
    }
    else {
        vector<ll> vec(4,0);
        for(auto p: um){
            vec[p.second%4]++;
        }
        if(vec[1]+vec[3]==1&&vec[2]+vec[3]<=(H+W-2)/2){
            prt("Yes");
        }
        else prt("No");
    }
    

    return 0;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;
  for (int i=0; i<S.size(); i++) {
    if (S[i]!=S[K-1]) S[i] = '*';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
vector<i64> A;

int main(){
  cin >> N;
  A.resize(N);
  i64 XOR = 0;
  set<i64> st;
  rep(i,0,N - 1){
    cin >> A[i];
    XOR ^= A[i];
    st.insert(A[i] ^ (A[i] - 1));
  }
  int ans = 0;
  for(int i = 30;i >= 0;i--){
    if(XOR & (1LL << i)){
      if(st.count((1LL << (i + 1)) - 1)){
        XOR ^= (1LL << (i + 1)) - 1;
        ans++;
      }
      else{
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int n,d,x;cin>>n>>d>>x;
    ll sum =x;
    rep(i,n){
        int tmp;cin>>tmp;
        sum+=((d-1)/tmp+1);
    }
    co(sum);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <utility>
#include <queue>
#include <tuple>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;
constexpr ll INF = 1000000007;

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0) cout << n / 2 << "\n";
    else cout << n / 2 + 1 << endl;
    
    return 0;
}

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

int main(void){
    int N,Y;
    int c1,c2,c3;
    c1 = -1;
    c2 = -1;
    c3 = -1;
    cin >> N >> Y;

    for(int a = 0;a <= N;a++){
        for(int b = 0;b <= N-a;b++){
            int c = N-a-b;
            int total = 10000*a+5000*b+1000*c;

            if(total == Y){
                c1 = a;
                c2 = b;
                c3 = c;
            }
            
        }
    }

    cout << c1 << " " << c2 << " " << c3 <<endl;


    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X;
  cin  >> N;
  X=(N/100000000) + (N%100000000)/10000000 + (N%10000000)/1000000 + (N%1000000)/100000 + (N%100000)/10000 + (N%10000)/1000 + (N%1000)/100 + (N%100)/10 + (N%100)%10;
  
  if (N%X == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int mv[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

int main(){
    int H,W,answer=0;
    cin >> H >> W;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }

    for(int sy=0;sy<H;sy++){
        for(int sx=0;sx<W;sx++){
            if(S[sy][sx]=='#'){
                continue;
            }

            int ans[H][W] = {0};

            memset(ans,-1,sizeof(ans));

            ans[sy][sx] = 0;

            queue<pair<int,int>> Q;
            pair<int,int> P;
            P.first = sy;
            P.second = sx;
            Q.push(P);

            while(!Q.empty()){
                P = Q.front();
                Q.pop();
                //cout << P.first << P.second << endl;
                for(int i=0;i<4;i++){
                    if(ans[P.first+mv[i][0]][P.second+mv[i][1]]==-1 && S[P.first+mv[i][0]][P.second+mv[i][1]]!='#' && P.first+mv[i][0]<H && 0<=P.first+mv[i][0] && P.second+mv[i][1]<W && 0<=P.second+mv[i][1]){
                        ans[P.first+mv[i][0]][P.second+mv[i][1]] = ans[P.first][P.second]+1;
                        Q.push(make_pair(P.first+mv[i][0],P.second+mv[i][1]));
                    }
                }
            }

            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    answer = max(answer,ans[i][j]);
                }
            }
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
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() {
    ll n,m;
    std::cin >> n>>m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;b--;
        
        uf.merge(a,b);
    }
    vector<bool> used(n,false);
    vector<ll> ans;
    for (int i = 0; i < n; i++) {
        if(!used[uf.root(i)]){
            ans.push_back(uf.size(i));
            used[uf.root(i)] = true;
        }
    }
    sort(ans.begin(),ans.end());
    
    ll res = n;
    
    for (int i = 1; i <= n; i++) {
        auto index = lower_bound(ans.begin(),ans.end(),i)-ans.begin();
        auto cnt = ans.size()-index;
        if(cnt>=2){
            res -= cnt-1;
        }
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 6120
#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline

using namespace std;

int main() {

	int S;
	cin >> S;

	int h = S / 3600;
	int m = (S % 3600) / 60;
	int s = (S % 3600) % 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;

}


Measured memory_bytes: 3080
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    x_list1 = []

    for i in range(N):
        x = int(input_raw[i])
        x_list1.append(x)


    min_dist = sys.maxint
    for i in range(N - K + 1):
        L = i;
        R = i + K - 1
        if x_list1[L] >= 0 and x_list1[R] >= 0:
            dist = x_list1[R]
        elif x_list1[L] <= 0 and x_list1[R] <= 0:
            dist = abs(x_list1[L])
        else:
            dist = min(2*x_list1[R] - x_list1[L], x_list1[R] - 2 * x_list1[L])
        if min_dist > dist:
            min_dist = dist
    print min_dist

if __name__ == '__main__':
    main()


Measured memory_bytes: 15036
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

constexpr ll MOD = 1e9 + 7;

ll MODpow(ll n, ll m) {
    ll result = 1;
    while (m) {
        if (m % 2 == 1) {
            result *= n;
            result %= MOD;
        }

        m /= 2;
        n *= n;
        n %= MOD;
    }

    return result;
}

class Combination {
public:
    Combination(ll max_num, ll mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (ll i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    ll operator()(ll n, ll m) const {
        if (m < 0 || m > n) return 0;
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }
private:


    vector<ll> fact_, inv_fact_;
    ll mod_;
};

int main() {
    ll N, M, K;
    cin >> N >> M >> K;

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll tmp = 0;
        ll x = 0;
        (x += i * (i + 1) / 2 % MOD) %= MOD;
        (x += (N - i - 1) * (N - i) / 2 % MOD) % MOD;
        ll sum = M * (M - 1) / 2 % MOD;
        ll sum_u = ((sum + M - 1) + (sum + i * (M - 1))) * i / 2 % MOD;
        ll sum_d = (sum + (sum + (N - i - 1) * (M - 1))) * (N - i) / 2 % MOD;
        (x += sum_u) %= MOD;
        (x += sum_d) %= MOD;

        (tmp += M * x % MOD) %= MOD;

        ll pow2 = (M - 1) * M * (2 * M - 1) / 6 % MOD;
        (tmp += N * pow2 % MOD) %= MOD;

        ll sub = (M - 1) * (M - 1) * M / 2 % MOD * N % MOD;
        tmp = (tmp + MOD - sub) % MOD;

        (ans += tmp) %= MOD;
    }
    (ans *= MODpow(2, MOD - 2)) %= MOD;

    for (ll i = 0; i < K - 2; i++) {
        (ans *= N * M - 2 - i) %= MOD;
    }
    for (ll i = 1; i <= K - 2; i++) {
        (ans *= MODpow(i, MOD - 2)) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int C = 100;
  int F = 0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i) == 'C'){
      C = i;
      break;
    }
  }
  for(int j=S.size()-1; j>=0; j--){
    if(S.at(j) == 'F'){
      F = j;
      break;
    }
  }
  
  if(C<F){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main()
{
  char s[3];
  char judge;
  int count=0;
  for(int i=0;i<3;i++)
  {
    cin>>s[i];
    judge=s[0];
    if(judge==s[i])
    {
      count++;
    }
  }
  if(count==3)
  {
    cout<<"No";
  }
  else
  {
    cout<<"Yes";
  }
}


Measured memory_bytes: 256