akhauriyash/Code-Regression huggingface dataset:
w, h, n = gets.chomp.split(' ')
w = w.to_i; h = h.to_i; n = n.to_i;

rect = Array.new(w, Array.new(h, 0))

n.times do
  point = gets.chomp.split(' ').map { |i| i.to_i }
  case point[2]
  when 1
    point[0].times do |i|
      rect[i] = Array.new(h, 1)
    end
  when 2
    (w - point[0]).times do |i|
      rect[w - i - 1] = Array.new(h, 1)
    end
  when 3
    point[1].times do |i|
      w.times do |j|
        rect[j][i] = 1
      end
    end
  when 4
    (h - point[1]).times do |i|
      w.times do |j|
        rect[j][h - i - 1] = 1
      end
    end
  end
end

puts rect.flatten!.count(0)

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

using namespace std;

int count(int len,string w, char t){
	int re = 0;
	for(int i = 0; i < len; i++){
		if(t == w[i]) re++;
	}
	return re;
}

int main(void)
{
	string w; cin>>w;
	int len = w.size();
	for(int i = 0; i < len;i++){
		if(count(len,w,w[i])%2 != 0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		String c=sc.next();
		System.out.println("A"+b.charAt(0)+"C");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 23892
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

struct E {
    int v, m;
    E() {}
    E(int v, int m) : v(v), m(m) {}
    bool operator < (const E& o) const {
        return v == o.v ? m < o.m : v < o.v;
    }
};

const int INF = 10000000;
const E INF_E = E(INF, -1);

/* range minimum query with segment tree (verified in AOJ/DSL_2_A) */
template<typename T, int B> // 1 << B >= max length
struct segment_tree_min {
    int N; T arr[2 << B];
    segment_tree_min() {}
    void init(int n) {
        N = 1;
        while (N < n) N *= 2;
        for (int i = 0; i < 2*N-1; ++i) arr[i] = INF_E;
    }
    void update(int i, T v) {
        int j = i + N-1; arr[j] = v;
        while (j > 0) {
            j = (j-1) / 2;
            arr[j] = min(arr[2*j+1], arr[2*j+2]);
    }   }
    T query(int a, int b) { return query(a, b, 0, 0, N); }
    T query(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) return INF_E;
        if (a <= l && r <= b) return arr[k];
        const int m = (l+r)/2;
        return min(query(a, b, 2*k+1, l, m), query(a, b, 2*k+2, m, r));
}   };

int N, M;
string S;

segment_tree_min<E, 17> st;
int dp[101010], nxt[101010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> S;
    fill(dp, dp+N+1, INF);
    st.init(N+1);
    dp[N] = 0;
    st.update(N, E(0, N));
    for (int i = N-1; i >= 0; --i) {
        if (S[i] == '1') continue;
        E e = st.query(i+1, min(i+1+M, N+2));
        dp[i] = 1 + e.v;
        nxt[i] = e.m;
        st.update(i, E(dp[i], i));
    }

    if (dp[0] >= INF) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 0; i < N; i = nxt[i]) {
        cout << (nxt[i] - i) << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3536
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut arr = vec![vec![0usize; 3]; 3];
    for i in 0..3 {
        for j in 0..3 {
            arr[i][j] = read();
        }
    }
    let x: usize = read();
    for _ in 0..x {
        let i: usize = read();
        for j in 0..3 {
            for k in 0..3 {
                if arr[j][k] == i {
                    arr[j][k] = 0;
                }
            }
        }
    }
    let mut ans = "No";
    for i in 0..3 {
        let mut a = 0;
        let mut b = 0;
        for j in 0..3 {
            a += arr[i][j];
            b += arr[j][i];
        }
        if a == 0 || b == 0 {
            ans = "Yes"
        }
    }
    if arr[0][0] + arr[1][1] + arr[2][2] == 0 || arr[2][0] + arr[1][1] + arr[0][2] == 0 {
        ans = "Yes"
    }
    println!("{}", ans);
}


Measured memory_bytes: 2136
s=input()
n=len(s)
dp=[[0]*13 for _ in range(n)]
if s[-1]=='?':
  for i in range(10):
    dp[n-1][i]=1
else:
  dp[n-1][int(s[-1])]=1
keta=1
mod=10**9+7
for i in range(n-2,-1,-1):
  keta*=10
  keta%=13
  for j in range(13):
    if s[i]!='?':
      dp[i][(int(s[i])*keta+j)%13]+=dp[i+1][j]
      dp[i][(int(s[i])*keta+j)%13]%=mod
      continue
    for k in range(10):
      dp[i][(k*keta+j)%13]+=dp[i+1][j]
      dp[i][(k*keta+j)%13]%=mod
print(dp[0][5])

Measured memory_bytes: 95908
// by Balloons
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

const int maxn=2e5+5;
char s[maxn];
int n,m;
vector<int>g[maxn]; 
int vis[maxn];
int cnt[maxn][3];

void dfs(int x){
	vis[x]=1;
	for(int i=0;i<g[x].size();i++){
		int u=g[x][i];
		if(vis[u])continue;
//		printf("%d %d %d\n",u,s[x]-'A',cnt[u][s[x]-'A']);
		--cnt[u][s[x]-'A'];
		if(cnt[u][0]==0||cnt[u][1]==0)dfs(u);
	}
}

int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		g[x].push_back(y);g[y].push_back(x);
		cnt[x][s[y]-'A']++;cnt[y][s[x]-'A']++;
	}
	for(int i=1;i<=n;i++){
//		printf("i=%d,cnt[][]=%d %d\n",i,cnt[i][0],cnt[i][1]);
		if(!vis[i]&&(cnt[i][0]==0||cnt[i][1]==0))dfs(i);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
//			printf("i=%d\n",i);
			return puts("Yes"),0;
		}
	}
	puts("No");

	return 0;
}


Measured memory_bytes: 16896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    double l = sc.nextDouble();
    double edge = l / 3.0;
    System.out.println(edge * edge * edge);
  }
}

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

#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define int long long

const int N = 1e5 + 5;
int k;
int ans = 1;
vector<int> v[N];
const int mod = 1e9 + 7;
void dfs(int s , int p = -1){

	int x = k-1 - (p!=-1);
	for(int it : v[s]){

		if(it==p)
			continue;

		ans*=x;
		ans%=mod;

		x--;

		dfs(it,s);
		
	}
}

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

	for(int i = 1 ; i < n ; ++i){

		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	ans = k;
	dfs(1);
	cout<<ans<<endl;
}


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

int main() {
	string S;
	cin >> S;
	int ss = S.size();
	int cnt = 0;
	for (int i = 0;i < 15;i++) {
		if (i < ss) {
			if (S[i] == 'o')cnt++;
			continue;
		}
		cnt++;
	}
	if (cnt >= 8)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


Measured memory_bytes: 256
//Harjot Singh Student NIT JALANDHAR	

#include<bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long int ll;

int longestpath(int s,vector<int> *adj,int *dp)
{
    if(dp[s]!=-1) return dp[s];
    bool child=false;
    int len=0;
    for(auto it: adj[s])
    {
    	child=true;
       len =max(len,longestpath(it,adj,dp));
    }

    return dp[s]=child?1+len:0;

}
int main()
{

   int n,m;
   cin>>n>>m;
   vector<int> adj[n+1];
   for(int i=0;i<m;i++)
   {
   	int a,b;
   	cin>>a>>b;
   	adj[a].push_back(b);
   }
   int dp[n+1];
   memset(dp,-1,sizeof(dp));
   int res=0;
   for(int i=1;i<=n;i++)
   {
   	res=max(res,longestpath(i,adj,dp));
   }
   cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  string s;
  int w;
  cin >> s >> w;
  string ans = "";
  for(int i = 0; ; ++i) {
    if(i * w >= s.length()) break;
    ans += s.substr(i * w, 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int a, b, c;
        double s, l, h;

        a = scanner.nextInt();
        b = scanner.nextInt();
        c = scanner.nextInt();

        h = b*Math.sin(Math.toRadians(c));
        s = a*h/2;
        l = a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c)));
        System.out.println(s);
        System.out.println(l);
        System.out.println(h);
    }
}



Measured memory_bytes: 26212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		
		int res = 0;
		
		for(int i = 0; i < n; i++) {
			res+=Math.abs(sc.nextInt()-sc.nextInt())+1;
		}
		
		out.println(res);
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21844
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

int main() {
	ll K, N; cin >> K >> N;
	vector<ll> a(N); rep(i, N)cin >> a[i];

	vector<ll> d(N);
	rep(i, N) {
		if (i == 0)d[i] = K - a[N - 1] + a[0];
		else d[i] = a[i] - a[i - 1];
	}
	
	sort(ALL(d));

	cout << K - d[N - 1] << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int x, n;
    cin >> x >> n;
    vector<bool> v(101, false);
    rep(i, n){
        int num;
        cin >> num;
        v[num] = true;
    }

    rep(i, 100) {
        if (x-i <= 0) {
            cout << 0 << endl;
            return 0;
        }
        if (v[x-i] == false) {
            cout << x-i << endl;
            return 0;
        }
        if (x+i >= 101) {
            cout << 101 << endl;
            return 0;
        }
        if (v[x+i] == false) {
            cout << x+i << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3596
#include<iostream>

#include<bits/stdc++.h>

#include<cstring>

#include<algorithm>
using namespace std;
int main()
{
	priority_queue<int>q;
	int n,pp,t;
	cin>>n>>pp;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		q.push(t);
	}
	long long sum=0;
	while(pp)
	{
		t=q.top()/2;
		q.pop();
		q.push(t);
		pp--; 
	}
	while(!q.empty())
	{
		sum+=q.top();
		q.pop();
	}
	cout<<sum;
	return 0;
}/*代码来自网络*/ 

Measured memory_bytes: 892
import java.io.*;
import java.util.*;

class Main {

	static final int M = 1000000007;

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		long[][] dp = new long[n][n];
		Arrays.fill(dp[0], 1);
		for (int i = 1; i < n; i++) {
			if (s[i - 1] == '>') {
				long p = dp[i - 1][n - i];
				for (int j = n - i - 1; j >= 0; j--) {
					dp[i][j] = (dp[i][j] + p) % M;
					p = (p + dp[i - 1][j]) % M;
				}
			} else {
				long p = dp[i - 1][0];
				for (int j = 0; j < n - i; j++) {
					dp[i][j] = (dp[i][j] + p) % M;
					p = (p + dp[i - 1][j + 1]) % M;
				}
			}
		}

		long a = 0;
		for (int i = 0; i < n; i++) a = (a + dp[n - 1][i]) % M;
		System.out.println(a);
	}
}


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

void print_vec(vector<ll> vec) {
    cout << "{";
    for(auto x: vec) cout << x <<  " ";
    cout << "}" << endl;
}

int main() {
    ll N,K,Q;
    cin >> N >> K >> Q;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) {
        A.at(i) = K;
    }
    rep(i,N) {
        A.at(i) -= Q;
    }
    rep(i,Q) {
        ll a;
        cin >> a;
        A.at(a-1)++;
    }
    rep(i,N) {
        if(A.at(i) <= 0)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<cmath>
#include<queue>
#include<algorithm>

using namespace std;
using ll=long long;
using db=double;

typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<bool> vbl;

int inf=(1LL<<31)-1;
int MOD=1000000007;

#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define f_i(a,b) for(int i=a;i<=b;i++)
#define f_j(a,b) for(int j=a;j<=b;j++)
#define vvii(c,a,b) vector<vector<ii>> c(a,vector<ii>(b,0))
#define vvll(c,a,b) vector<vector<ll>> c(a,vector<ll>(b,0))
#define vvstr(c,a,b) vector<vector<string> c(a,vector<string>(b,0))
#define vvbol(c,a,b) vector<vector<bool>> c(a,vector<bool>(b,true))

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n+n*n*n+n*n << endl;
    return(0);
}

Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean[] spade = new boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false};
        boolean[] heart = new boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false};
        boolean[] club = new boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false};
        boolean[] diamond = new boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false};
        for (int i = 0; i < n; i++) {
            String symbol = sc.next();
            int num = sc.nextInt();
            switch (symbol) {
                case "S":
                    spade[num - 1] = true;
                    break;
                case "H":
                    heart[num - 1] = true;
                    break;
                case "C":
                    club[num - 1] = true;
                    break;
                case "D":
                    diamond[num - 1] = true;
                    break;
            }
        }
        print(spade, "S");
        print(heart, "H");
        print(club, "C");
        print(diamond, "D");
    }

    public static void print(boolean[] mark, String symbol) {
        for (int i = 0; i < 13; i++) {
            if (!mark[i]) System.out.println(String.format("%s %d", symbol, i + 1));
        }
    }
}



Measured memory_bytes: 26408
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  double fa=a,fb=b;
  //cout << (a/b) <<" "<<(a%b)<<" "<<(fa/fb)<<endl;
  printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
  return 0;
}

Measured memory_bytes: 1192
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

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

        
         public static long gcd(long x, long y)
        {
            if (x < y) gcd(y, x);
            while (y != 0)
            {
                var z = x;
                x = y;
                y = z % y;
            }
            return x;
        }

        public static long C(long n, long k)
        {
            long x = 1;
            for (long i = 1; i <= k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var q = Reads();
            var w = q[0];
            var h = q[1];
            var n = q[2];
            long left = 0;
            long right = w;
            long up = h;
            long down = 0;
            for (int i = 0; i < n; i++)
            {
                q = Reads();
                if (q[2] == 1) left = Math.Max(left,q[0]);
                if (q[2] == 2) right = Math.Min(right,q[0]);
                if (q[2] == 3) down = Math.Max(down,q[1]);
                if (q[2] == 4) up = Math.Min(up,q[1]);
            }

            if (left < right && down < up)
                WriteLine((right - left) * (up - down));
            else
                WriteLine(0);
            


            Console.Out.Flush();
        }
    }
}


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

c = 0
if a[0] > x:
     c += a[0]-x
     a[0] = x
for i in range(n-1):
    cnt = a[i] + a[i+1]
    if cnt > x:
        c += cnt-x
        a[i+1] -= cnt-x
print(c)

Measured memory_bytes: 14132
#include<stdio.h>

int main()
{
	int a, b, c;
	int max, min, total = 0;
	scanf("%d %d %d", &a, &b, &c);
	total = a + b + c;
	if(a > b && a > c)
	{
		max = a;
	}
	else if(b > a && b > c)
	{
		max = b;
	}
	else
	{
		max = c;
	}
	
	if(a < b && a < c)
	{
		min = a;
	}
	else if(b < a && b < c)
	{
		min = b;
	}
	else
	{
		min = c;
	}
	printf("%d %d %d\n", min, total-max-min, max);
	
	return 0; 
}


Measured memory_bytes: 2756
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt(); //横=x
	    int m = kbd.nextInt(); //縦=y
	    if(n!=0 && m!=0){
		solve(n, m);
	    }
	}
    }

    static void solve(int n, int m){
	int[][] field = new int[n][m];  //マップ(横*縦)
	Stack[] s = new Stack[2];  //行ける場所確保
	s[0] = new Stack(n*m);     // x座標
	s[1] = new Stack(n*m);     // y座標

	int i, j;
	int x=0, y=0, cnt=0; // 現在座標と踏んだタイルの数 
	for(i=0; i<m; i++){
	    String ss = kbd.next();
	    for(j=0; j<ss.length(); j++){
		String f = ss.substring(j, j+1);
		if(f.equals(".")){
		    field[j][i] = 1; // 1 = まだ踏んでいない
		}
		else if(f.equals("#")){
		    field[j][i] = -1;  // -1 = 進めない
		}
		else if(f.equals("@")){
		    field[j][i] = 0;  // 0 = スタートor 通過済み
		    x = j;
		    y = i;
		    cnt = 1;
		}
	    }
	}
	//フィールドセットここまで

	search(s, field, x, y, n, m);
	while(!(s[0].isEmpty() && s[1].isEmpty())){
	    x = (Integer)s[0].pop();
	    y = (Integer)s[1].pop();
	    if(field[x][y]==1){
		field[x][y] = 0;
		cnt++;
	    }
	    search(s, field, x, y, n, m);
	    //System.out.println(x+" "+y);
	}
	System.out.println(cnt);
    }

    static void search(Stack[] s, int[][] field, int x, int y, int n, int m){
	int a=x+1, b=x-1, c=y+1, d=y-1;
	if(a<n && field[a][y]==1){
	    s[0].push(a);
	    s[1].push(y);
	    //System.out.println((x+1)+" "+y);
	}
	if(b>=0 && field[b][y]==1){
	    s[0].push(b);
	    s[1].push(y);
	    //System.out.println((x-1)+" "+y);
	}
	if(c<m && field[x][c]==1){
	    s[0].push(x);
	    s[1].push(c);
	    //System.out.println(x+" "+(y+1));
	}
	if(d>=0 && field[x][d]==1){
	    s[0].push(x);
	    s[1].push(d);
	    //System.out.println(x+" "+(y-1));
	}
    }
}

class Stack{
    Object[] stack;
    int sp;
    public Stack(int n){
	stack = new Object[n];
	sp = 0;
    }
    public void push(Object x){
	stack[sp++] = x;
    }
    public Object pop(){
	return stack[--sp];
    }
    public boolean isEmpty(){
	return sp == 0;
    }
}

Measured memory_bytes: 31392
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define fi first
#define se second
#define pii pair<int,int>
#define inf LLONG_MAX
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int MAX=(int)2e5 + 1;

signed main() {
    int num;
    cin>>num;

    if(num%2!=0){
        cout<<0;
    }
    else{
        int div=10, cnt=0;
        while(div<=num){
            cnt+=num/div;
            div*=5;
        }
        cout<<cnt;
    }


}

Measured memory_bytes: 256
import Foundation

func readInt() -> [Int]{
    return readLine()!.split(separator:" ").map{Int($0)!}
}
let n = Int(readLine()!)!
var c = 0
var max = 0
for i in 1...n{
  let m = readInt()
  if(m[0] == m[1]){
    c += 1
    if(max < c){
      max = c
    }
  }else{
    c = 0
  }
}
if(max >= 3){
  print("Yes")
}else{
  print("No")
}




Measured memory_bytes: 13592
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    const int num3=2200;      // (10^10)^(1/3) 以下の数について
    vector<ll> a2(num3+1);    // 2乗した数を列挙  a2[i]=i^2
    vector<ll> a3(num3+1);    // 3乗した数を列挙  a3[i]=i^3

    int i,j;
    for(i=1; i<=num3; i++) {
        a2[i]=(ll)i*i;
        a3[i]=a2[i]*i;
    }

    int n;
    scanf("%d", &n);

    map<ll,int> cnt;
    for(i=0; i<n; i++) {
        ll s;
        scanf("%lld", &s);
        for(j=2; j<=num3; j++) {      // 立方数で割っておく
            if(s<a3[j]) break;
            while(s%a3[j]==0) {
                s/=a3[j];
            }
        }
        cnt[s]++;
    }

    int ans=0;
    if(cnt.find(1)!=cnt.end()) {    // 1（つまり元々立方数だったもの）を答えに反映させて、mapから削除
        ans++;
        cnt.erase(1);
    }

    queue<ll> que;
    {
        auto it=cnt.begin();
        for(; it!=cnt.end(); ++it) {
            que.push(it->first);
        }
    }

    while(!que.empty()) {
        ll tt=que.front();
        que.pop();

        auto it=cnt.find(tt);
        if(it==cnt.end()) continue;

        ll curr=it->first;
        ll sub=1;
        for(j=2; j<=num3; j++) {        // currを平方数と無平方数の積にする。ただし平方数はa2に列挙したもののみ考えればよい
            if(curr<a2[j]) break;
            while(curr%a2[j]==0) {
                curr/=a2[j];
                sub*=j;
            }
            if(sub>num3 || curr<sub) break;
        }
        if(sub>num3 || curr<sub) continue;
        double chk=(double)curr*curr*sub;
        if(chk>1e12) continue;
        ll tmp=curr*curr*sub;         // currとペアになる数（積が立方数になるもの）を見つける
        auto it2=cnt.find(tmp);
        if(it2!=cnt.end()) {          // ペアが見つかったら答に追加して、currおよびペアをmapから削除
            ans += MAX(it->second, it2->second);
            ll tmp0=it->first;
            ll tmp1=it2->first;
            cnt.erase(tmp0);
            cnt.erase(tmp1);
        }
    }

    auto it=cnt.begin();
    for(; it!=cnt.end(); ++it) {    // ペアにならなかった分を答に反映
        ans+=it->second;
    }
    printf("%d\n", ans);
  
    return 0;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1)
using namespace std;


int main ()
{
__

double a,ans=0.0;
int n;

cin >> n;

for(int i=0;i<n;i++){
cin >> a;

ans+=(1.0 / a);

}

ans = 1.0/ans;

printf("%.9f\n",ans);

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
int c[4][4];
bool F(int i,int j)
{
    int x=c[i][1]+c[i][2]+c[i][3]-c[j][1]-c[j][2]-c[j][3];
    if((c[i][1]-c[j][1])*3==x)return true;
    return false;
}
bool G(int i,int j)
{
    int x=c[1][i]+c[2][i]+c[3][i]-c[1][j]-c[2][j]-c[3][j];
    if((c[1][i]-c[1][j])*3==x)return true;
    return false;
}
int main()
{
    ios_base::sync_with_stdio(0);
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
            cin>>c[j][i];
        }
    }
    if(G(1,3)==true && G(1,2)==true && G(2,3)==true
    &&F(1,3)==true && F(1,2)==true && F(2,3)==true){cout<<"Yes";return 0;}
    cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF 2000
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

#define MAX_V 200
int d[MAX_V][MAX_V];
int V;

void warshall_floyd()
{
  int i,j,k;
  rep(k,V)rep(i,V)rep(j,V)
    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}

struct Edge
{
  int s;
  int t;
  int c;
};

Edge e[MAX_V*MAX_V]={};

signed main(void)
{
  int i,j,k;
  rep(i,MAX_V)rep(j,MAX_V)
    d[i][j]=i==j?0:INF;

  cin>>V;
  in(int,M);
  rep(i,M)
    {
      in(int,a,b,c);
      if(a>b)swap(a,b);
      e[i]=(Edge){a-1,b-1,c};
      d[a-1][b-1]=c;
      d[b-1][a-1]=c;
    }

  warshall_floyd();

  drep(i,V)
    {
      drep(j,V)
	dprintf("%4d,",d[i][j]);
      puts("");
    }

  int count=M;
  rep(k,M)
    {
      bool flg=false;
      for(i=0;i<V;i++)
	{
	  for(j=0;j<V;j++)
	    {
	      if(d[i][e[k].s]+e[k].c+d[e[k].t][j]==d[i][j])
		flg=true;
	    }
	}
      count-=flg;
    }
  putv(count);
  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, K;
    cin >> N >> K;

    ll ans = 0;
    FOR(i, K + 1, N + 1) {
        ans += (N / i) * (i - K);

        int tmp = N - N / i * i;
        if (tmp >= K) ans += tmp - K + 1;
        if (K == 0) ans--;
    }

    print(ans);
    
}


Measured memory_bytes: 3632
import numpy as np

N = int(input())
W = input().split()

for i in range(N):
    W[i] = int(W[i])
min_w= 1000000
for i in range(N-1):
    w1 = W[:i+1]
    w2 = W[i+1:]
    w1 = np.array(w1)
    w2 = np.array(w2)
    min_w = min(min_w, abs(np.sum(w2)-np.sum(w1)))

print(min_w)

Measured memory_bytes: 27336
#include <bits/stdc++.h>
using namespace std;
const int N = 310;
long long d[N][N], t[N][N], f[N], b[N], pw[N], base = 233, mod=998244353ll;;
int n, ans, a[N][N], now[N];
long long AP_hash(char *s) {
	long long ans=0;
	int len=strlen(s+1);
	for(int i=1;i<=len;i++)
	if(i&1)
	ans=~(ans<<7)^s[i]^(ans>>3);
	else ans=(ans<<11)^s[i]^(ans>>5);
	return ans; 
}
char s[N], ch[N][N];
main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%s", ch[i] + 1);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) {
			memset(s, 0, sizeof(s));
			for(int k = j; k <= j + n - 1; k++)
				s[k - j + 1] = ch[i][(k - 1) % n + 1];
			t[i][j] = AP_hash(s);
			memset(s, 0, sizeof(s));
			for(int k = i; k <= i + n - 1; k++)
				s[k - i + 1] = ch[(k - 1) % n + 1][j];
			d[i][j] = AP_hash(s);
		}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) {
			int nowi = n - i, nowj = n - j, p = 1;
			for(int k = 1; k <= n; k++)
				if (d[nowi + 1][(nowj + k - 1) % n + 1] != t[(nowi + k - 1) % n + 1][nowj + 1]) {
					p = 0; break;
				}
			ans += p;
		}
	printf("%d\n", ans);
	
} 

/*
4
ydsa
dwxz
sxcq
azqf

4
aaaa
baab
baab
aaaa
*/

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

#define MAX_N 100
#define MAX_M 100

int N, M;
std::string s, t;
std::map<std::string, int> mp;

int main() {
    std::cin >> N;
    for (int i=0; i<N; i++) {
        std::cin >> s;
        if (mp.find(s) != mp.end()) {
            ++mp[s];
        } else {
            mp[s] = 1;
        }
    }
    std::cin >> M;
    for (int j=0; j<M; j++) {
        std::cin >> t;
        if (mp.find(t) != mp.end()) --mp[t];
    }

    int res = 0;
    std::map<std::string, int>::iterator itr=mp.begin();
    while (itr != mp.end()) {
        res = std::max(res, itr->second);
        ++itr;
    }
    std::cout << res << std::endl;
    return 0;
}


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

int main() {
    char a;
    cin >> a;
    if (a >= 65 && a <= 90)
        cout << 'A' << endl;
    else
        cout << 'a' << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll i,j,x,v;
	cin >> x;
	for(i=-3000;i<=3000;++i)
	{
		for(j=-3000;j<=3000;++j)
		{
			v = i*i*i*i*i-j*j*j*j*j;
			if(v == x)
			{
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}

	

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
const int MAX_N = 1e5;
list<pair<int, LL>> G[MAX_N + 1];
VEC<bool> used;
VEC<bool> black;
void dfs(int node, LL dist) {
  if (used[node]) return;
  // DUMP(node, dist);
  used[node] = 1;

  if (dist % 2 == 0) black[node] = 1;
  for (auto v : G[node]) {
    dfs(v.first, dist + v.second);
  }
}

int main() {
  int N;
  cin >> N;
  REP(i, 0, N-1) {
    int a, b;
    LL c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }
  used = VEC<bool>(N, 0);
  black = VEC<bool>(N, 0);
  dfs(0, 0);
  REP(i, 0, N) { cout << black[i] << endl; }

  return 0;
}


Measured memory_bytes: 12288
#include "bits/stdc++.h"

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool ok = true;
  REP(i, s.size()) {
    if (i & 1) {
      if (s[i] == 'R')
        ok = false;
    } else {
      if (s[i] == 'L')
        ok = false;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}


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


#define rep(i,n) for (int i=0; i<(n); i++)
//const int INF =1001001001;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

int main(){
    int x;
    rep(i,5){
        cin >> x;
        if(x==0) cout << i+1 << endl;
    }
    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
const int INF = 1001001001;
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

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

vector<int> adj[N];

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    for(int i=0;i<m;i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    queue<int> q;
    q.push(1);
    vector<int> res(n+1, -1);
    while(!q.empty()) {
        int cur = q.front();
        q.pop();
        for(auto next : adj[cur]) {
            if(next > 1 && res[next] < 0) {
                q.push(next);
                res[next] = cur;
            }
        }
    }
    cout << "Yes" << endl;
    for(int i=2;i<=n;i++) {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 12620
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 1000000;
ll mod = INF;

ll l,r;

int main(){
    cin >> l>>r;
    if(l>0&&r-l+1>=2019){
        cout << 0<<endl;
    }else if(l==0&&r>=2019){
        cout << 0<<endl;
    }else{
        ll ans=INF;
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){
                ll t1=i%2019;
                ll t2=j%2019;
                ans=min(ans,t1*t2%2019);
            }
        }
        cout << ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

class Edge
{
	public:
	int cost;
	int next;

	Edge(int n,int c)
	{
		next=n;
		cost=c;
	}
};

vector<Edge> g[100000];
ll x[100000];
bool used[100000];

int saiki(int s)
{
	int b;
	for(int u=0;u<g[s].size();u++)
	{
		Edge t=g[s][u];
		if(used[t.next]==false)
		{
			x[t.next] = x[s]+t.cost;
			used[t.next]=true;
			b = saiki(t.next);
			if(b==-1)
			{
				return -1;
			}
		}else if(x[t.next]!=x[s]+t.cost){
			return -1;
		}
	}
	return 0;
}

int main()
{
	int n,m;
	int l,r,d;
	cin>>n>>m;
	fill(used,used+100000,false);
	for(int i=0;i<m;i++)
	{
		cin>>l>>r>>d;
		l--;
		r--;
		g[l].push_back(Edge(r,d));
		g[r].push_back(Edge(l,-1*d));
	}
	for(int i=0;i<n;i++)
	{
		int b=0;
		if(used[i]==false)
		{
			x[i]=0;
			b = saiki(i);
		}
		if(b==-1)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

namespace ConsoleApp1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var result = Console.ReadLine()
                .Split(' ')
                .Select(x => int.Parse(x))
                .Aggregate((mults, value) => mults * value);

            if (result % 2 == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = (1<<12) + 5;
const int M = 1005;
ll dp[M][N];
int n,m;
vector<ll> price;
vector<ll> ormask;

int main(){

	cin>>n>>m;
	for(int i=0; i<m; ++i){
		ll a,b;
		cin>>a>>b;
		price.push_back(a);
		int mask = 0;
		for(int j=0; j<b; ++j){
			ll x; cin>>x; x--;
			mask |= (1<<x);
		}
		ormask.push_back(mask);
	}

	const ll inf = 1e18;
	for(int i=0; i<M; ++i){
		for(int j=0; j<N; ++j){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for(int offer=1; offer<=m; ++offer){
		for(int j=0; j<(1<<n); ++j){
			dp[offer][j] = dp[offer-1][j];
		}
		for(int j=0; j<(1<<n); ++j){
			dp[offer][(j|ormask[offer-1])] = min( dp[offer][(j|ormask[offer-1])], dp[offer-1][j] + price[offer-1]);
		}
	}
	ll ans = dp[m][(1<<n) - 1];
	if( ans == inf ){ cout<<-1<<endl; }
	else{ cout<<ans<<endl; }


	return 0;
}


Measured memory_bytes: 32512
from sys import stdin


def main() -> None:
    a = next_int()
    b = next_int()

    ab = int(str(a) + str(b))
    sqrt = int(ab ** 0.5)

    print(["No", "Yes"][int(sqrt ** 2 == ab)])


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

namespace abc098_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int ret = 0;
            for (int i = 1; i < n; i++)
            {
                string s1 = s.Substring(0, i);
                string s2 = s.Substring(i, n - i);
                int count = 0;
                for (char j = 'a'; j <= 'z'; j++)
                {
                    if (s1.Contains(j) && s2.Contains(j)) count++;
                }
                ret = Math.Max(ret, count);
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int N,M;
    cin>>N>>M;
    vi a(N),b(N),x(M),y(M);
    REP(i,N) {
        cin>>a[i]>>b[i];
    }
    REP(i,M) {
        cin>>x[i]>>y[i];
    }
    REP(i,N) {
        int min=INF;
        int ans=0;
        REP(j,M) {
            if(chmin(min,abs(x[j]-a[i])+abs(y[j]-b[i]))) ans=j+1;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

#define int long long int
int const M = 1e9 + 7, N = 2e5 + 1;

int a[N];

signed main() {
    int n, k, ans = 0;
    map<int, vector<int>> mp;
    cin >> n >> k;
    int sum = 0;
    mp[0ll].push_back(0ll);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
        // k = 8
        // i = 11, mp[val] => { 1, 2, 6, 8, 9 }
        int val = (sum - (i + 1)) % k;
        int pos = lower_bound(mp[val].begin(), mp[val].end(), max(i - k + 2, 0ll)) - mp[val].begin();
        int cnt = (mp[val].size() - pos);
        ans += cnt;
        mp[val].push_back(i + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 23680