akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define Graph vector<vector<int>>

int binary_search_under(vector<int> A, int key){//めぐる式（要復習)//ngとokは下側を残したいか上側を残したいかで調整すること(okは残したい側からスタート)
  int ng = (int)A.size(); //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = -1; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (A[mid]<=key) ok = mid;//ここの分岐を変えるだけで求める境界をkeyより大きい最小か、keyより小さい最大かなど多彩に変化させられる(今回はkeyより小さいから<=key)
        else ng = mid;
    }
    return ok;
}//今回はkey以下になる最大のindexを返す

int binary_search_over(vector<int> A, int key){//めぐる式（要復習)//ngとokは下側を残したいか上側を残したいかで調整すること(okは残したい側からスタート)
  int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)A.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (A[mid]>=key) ok = mid;//ここの分岐を変えるだけで求める境界をkeyより大きい最小か、keyより小さい最大かなど多彩に変化させられる(今回はkeyより大きいから>=key)
        else ng = mid;
    }
    return ok;
}//今回はkey以上になる最大のindexを返す

 
int main() {

  int N;

  cin >> N ;

  vector<int> A(N),B(N),C(N);

  rep(i,N) cin >>A[i];
  rep(i,N) cin >>B[i];
  rep(i,N) cin >>C[i];//入力終了

  sort(all(A)); sort(all(C));//昇順

  ll ans=0;  

  rep(i,N){
    auto a=lower_bound(all(A),B[i]),b=upper_bound(all(C),B[i]);
    ans+=(a-A.begin())*(C.end()-b);
  }

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

Measured memory_bytes: 1408
a,b = map(int,input().split())
li = list(map(int,input().split()))
countUp = a
countDown = a
ans = 0
while True:
  if countDown not in li:
    ans = countDown
    break 
  countDown = countDown - 1
  if countUp not in li:
    ans = countUp
    break
  countUp = countUp + 1 

print(ans)


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

int main() 
{
	ll n,s=0;
	cin>>n;
	ll a[n+1];
	for(int i=1;i<=n;i++)
	{
	    if(i%15!=0&&i%5!=0&&i%3!=0)
	    s+=i;
	}
	cout<<s<<"\n";
	return 0;
}

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

public class Main {
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();

    int N = fs.nextInt(), K = fs.nextInt(), ans = 0;
    for (int i = 0; i < N; i++) {
      int h = fs.nextInt();
      if (h >= K) ans++;
    }
    System.out.println(ans);
  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte())
    return buffer[ptr++];
    else
    return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr]))
    ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext())
    throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext())
    throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
      throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
    throw new NumberFormatException();
    return (int) nl;
  }

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

Measured memory_bytes: 23240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int sum=0,i,max=0,min=1000,ave;
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			for(i=0;i<n;i++){
				int point=sc.nextInt();
				if(point<min){
					min=point;
				}
				if(point>max){
					max=point;
				}
				sum=sum+point;
			}
			ave=(sum-max-min)/(n-2);
			System.out.println(ave);
		}
	}
}

Measured memory_bytes: 28912
n = int(input())
s = []
while(n>0):
    s.append(int(input()))
    
    n -= 1

import math
num = 0
for i in range(len(s)):
    isPrime = True
    if(s[i] == 2 or s[i] == 3):
        num += 1
    
    half = s[i]//2 + 1
    
    rm = int(math.sqrt(s[i]))
    
    for j in range(2,rm+1):
        if(s[i] % j == 0):
            isPrime == False
            break
    
        if(j == rm and isPrime == True):
            num += 1
print(num)


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

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

	if (n % (d * 2 + 1) == 0) {
		cout << n / (d * 2 + 1) << endl;
	}
	else {
		cout << (n / (d * 2 + 1))+1 << endl;
	}

	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) { cout << "Case #" << i << ": "; solve(); ln; }
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e5, MOD = 998244353, SIZE = 2e7, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, a[4];
string s;

//<<-----Implement Functions Here---->>//
void solve()
{
	cin >> n;
	FOR(i, 0, n)
		cin >> s, s == "AC" ? ++a[0] : s == "WA" ? ++a[1] : s == "TLE" ? ++a[2] : ++a[3];
	out("AC x " << a[0])
	out("WA x " << a[1])
	out("TLE x " << a[2])
	out("RE x " << a[3])
}

//<<----------Start of Main---------->>//
int main()
{
	fastio
	//ts
	solve();
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		int[] in = new int[n];
		int[] arr = new int[n + 1];
		for (int i = 0; i < n; i++) {
			int a = scan.nextInt();
			in[i] = a;
			arr[a]++;
		}
		long[] res = new long[n + 1];
		long sum = 0;
		for (int i = 0; i <= n; i++) {
			res[i] = 0;
			for (int k = 1; k <= arr[i] - 1; k++) {
				res[i] += k;
			}
			sum += res[i];
		}
		for (int i = 0; i < n; i++) {
			long tmp = sum - res[in[i]];
			tmp += (res[in[i]] - 1) <= 0 ? 0 : (res[in[i]] - (arr[in[i]] - 1));
			System.out.println(tmp);
		}
	}

}


Measured memory_bytes: 93288
while True:
    n, r = map(int, input().split());
    if n == 0 and r == 0:
        break

    deck = [n - i for i in range(n)]
    for i in range(r):
        p, c = map(int, input().split())
        deck = deck[p - 1 : p + c - 1] + deck[:p - 1] + deck[p + c - 1:]
    print(deck[0])



Measured memory_bytes: 5620
n = int(input())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
result = 0
for a, b in zip(A[::-1], B[::-1]):
    piyo = (a+result) % b
    if piyo == 0:
        continue
    result += b - piyo
print(result)

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

using namespace std;

int main(void) {
  int n, m;
  while (cin >> n >> m, n) {
    int cnt[11] = {};
    int d, p;
    for (int i = 0; i < n; i++) {
      cin >> d >> p;
      cnt[p] += d;
    }

    for (int i = 10; i >= 0; i--) {
      if (m < cnt[i]) {
        cnt[i] -= m;
        m = 0;
      } else {
        m -= cnt[i];
        cnt[i] = 0;
      }
    }

    int ans = 0;
    for (int i = 0; i <= 10; i++) {
      ans += cnt[i] * i;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2968
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N; string s;
    cin >> N >> s;
    for(int i=0;i<s.size();i++){
        s[i] = 'A' + (s[i]-'A'+N)%26;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const long long INF = 1LL << 60;
//const int INF = 1e9+5;

//dpテーブル
int dp[3100][3100];

int main(){
  string s,t;cin >> s >> t;

  for(int i=0;i<s.size();i++){
    for(int j=0;j<t.size();j++){
      if(s[i] == t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
      chmax(dp[i+1][j+1],dp[i+1][j]);
      chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout << res << endl;
}

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

int main(void) {
    int check=0;
    string s;
    cin >> s;
    for(int i=0; i<4; i++) {
        for(int j=i+1; j<4; j++) {
            if(s[i]==s[j])
                check++;
        }
    }
    if(check==2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

using namespace std;

int main() {
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<Int> A(X), B(Y), C(Z);
	for (int i = 0; i < X; ++i) { cin >> A[i]; }
	for (int i = 0; i < Y; ++i) { cin >> B[i]; }
	for (int i = 0; i < Z; ++i) { cin >> C[i]; }

	vector<Int> AB;
	for (auto a : A) {
		for (auto b : B) { AB.emplace_back(a + b); }
	}

	sort(AB.rbegin(), AB.rend());
	vector<Int> ans;
	for (int i = 0; i < min((int)AB.size(), K); ++i) {
		for (auto c : C) { ans.emplace_back(AB[i] + c); }
	}

	sort(ans.rbegin(), ans.rend());
	for (int i = 0; i < K; ++i) { cout << ans[i] << endl; }

	return 0;
}


Measured memory_bytes: 44128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=100000000000000LL;
const int MAX=100001;
const double EPS=1e-10;
int main() {
    ll n;
    cin>>n;
    ll a[51];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    while(1){
        ll sum=0;
        bool f=true;
        for(int i=0;i<n;i++){
            sum+=a[i]/n;
            if(a[i]>=n){
                f=false;
            }
        }
        if(f){
            break;
        }
        for(int i=0;i<n;i++){
            ll m=a[i]/n;
            a[i]-=m*n;
            a[i]+=sum-m;
            ans+=m;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    string s,t;
    cin>>s>>t;
    int ls=sz(s),lt=sz(t);
    vector<vector<int>> dp(ls+1,vector<int>(lt+1));
    for(int i=0;i<ls;i++){
        for(int j=0;j<lt;j++){
            chmax(dp[i+1][j+1],max(dp[i][j+1],dp[i+1][j]));
            if(s.at(i)==t.at(j)){
                chmax(dp[i+1][j+1],dp[i][j]+1);
            }
        }
    }

    string ans;
    int ps=ls,pt=lt;
    while(ps && pt){
        if(s.at(ps-1)==t.at(pt-1)){
            ps--;pt--;
            ans.pb(s.at(ps));
        }
        else if(dp[ps][pt]==dp[ps-1][pt]){
            ps--;
        }
        else{pt--;}
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

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


int main(){
    int h,w;
    while(cin >> h >> w and h>0 and w>0){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if((i+j)%2==0){
                    cout << '#';
                }
                else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

//5,13をスペース
int main(){
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i==5 || i==13){
      s[i]=' ';
    }
    cout<<s[i];
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector> 
using namespace std;
int main(void){
	string input;
	cin>>input;
	char first = (input[0]-'0');
	int count =0;
  	int sum =0;
	for(int i=1;i<input.length();i++){
		if(first==0){
			first=1;
		}else{
			first =0;
		}
		sum += (input[i]==('0'+first))?0:1;
	}
  cout<<sum;
	return 0;
}

Measured memory_bytes: 512
//https://vjudge.net/contest/316821#problem/A  hdu4609
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const double PI = acos(-1.0);
struct Complex {
	double x, y;
	Complex(double _x = 0.0, double _y = 0.0) {
		x = _x;
		y = _y;
	}
	Complex operator-(const Complex &b) const {
		return Complex(x - b.x, y - b.y);
	}
	Complex operator+(const Complex &b) const {
		return Complex(x + b.x, y + b.y);
	}
	Complex operator*(const Complex &b) const {
		return Complex(x * b.x - y * b.y, x * b.y + y * b.x);
	}
};
/*
* 进行 FFT 和 IFFT 前的反置变换
* 位置 i 和 i 的二进制反转后的位置互换
*len 必须为 2 的幂
*/
void change(Complex y[], int len) {
	for (int i = 1, j = len / 2; i < len - 1; i++) {
		if (i < j) swap(y[i], y[j]);
		// 交换互为小标反转的元素，i<j 保证交换一次
		// i 做正常的 + 1，j 做反转类型的 + 1，始终保持 i 和 j 是反转的
		int k = len / 2;
		while (j >= k) {
			j = j - k;
			k = k / 2;
		}
		if (j < k) j += k;
	}
}
/*
* 做 FFT
*len 必须是 2^k 形式
*on == 1 时是 DFT，on == -1 时是 IDFT
*/
void fft(Complex y[], int len, int on) {
	change(y, len);
	for (int h = 2; h <= len; h <<= 1) {
		Complex wn(cos(2 * PI / h), sin(on * 2 * PI / h));
		for (int j = 0; j < len; j += h) {
			Complex w(1, 0);
			for (int k = j; k < j + h / 2; k++) {
				Complex u = y[k];
				Complex t = w * y[k + h / 2];
				y[k] = u + t;
				y[k + h / 2] = u - t;
				w = w * wn;
			}
		}
	}
	if (on == -1) {
		for (int i = 0; i < len; i++) {
			y[i].x /= len;
		}
	}
}

const int MAXN = 400020;//四倍
Complex x1[MAXN];
int a[MAXN];
ll sum[MAXN], num[MAXN];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]), num[a[i]]++;
	sort(a, a + n);
	int len1 = a[n - 1] + 1;//最高次方数
	int len = 1;
	while (len < len1 * 2) len <<= 1;
	for (int i = 0; i < len1; i++)
		x1[i] = Complex(num[i], 0);
	for (int i = len1; i < len; i++)
		x1[i] = Complex(0, 0);
	fft(x1, len, 1);//转化为点值表示法
	for (int i = 0; i < len; i++) x1[i] = x1[i] * x1[i];
	fft(x1, len, -1);//转化为系数表示法
	for (int i = 0; i < len; i++) num[i] = ll(x1[i].x + 0.5);
	len = a[n - 1] * 2;
	for (int i = 0; i < n; i++) num[a[i] + a[i]]--;//两个相同
	for (int i = 1; i <= len; i++)//无序
		num[i] /= 2;
	sum[0] = 0;
	for (int i = 1; i <= len; i++)//前缀和
		sum[i] = sum[i - 1] + num[i];

	ll ans = 0;
	for (int i = 0; i < n; i++){
		ans += sum[len] - sum[a[i]];
		ans -= (ll)(n - i - 1)*i;//一个比自己大 一个比自己小
		ans -= (ll)(n - 1 - i)*(n - i - 2) / 2;//两个大于自己
		ans -= n - 1;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int maxn = 2e5 + 5;
int n;
int a[maxn];

long long F(int m) {
	long long res = 0;
	for (int i = 1; i <= n; ++i)
		res += abs(a[i] - m - i);
	return res;
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	int l = -1e9, r = 1e9;
	while (r - l >= 3) {
		int m1 = l + (r-l)/3;
		int m2 = r - (r-l)/3;
		if (F(m1) < F(m2)) r = m2;
		else l = m1;
	}
	cout << min(F(l), min(F(l+1), F(l+2))) << endl;
	return 0;
}

Measured memory_bytes: 1024
n,a=map(int,raw_input().split())
x=map(int,raw_input().split())
x.sort()
dp=[[[0]*(n+1) for i in xrange(n*a+1)] for j in xrange(n+1)]
for i in xrange(n+1):
    dp[i][0][0]=1
ans=0
for i in xrange(n):
    for j in xrange(1,n*a+1):
        for k in xrange(1,n+1):
            if i+1<k:break
            if j<x[i]:
                dp[i+1][j][k]=dp[i][j][k]
                continue
            dp[i+1][j][k]=dp[i][j][k]+dp[i][j-x[i]][k-1]
for j in xrange(1,n*a+1):
    for k in xrange(1,n+1):
        if j==a*k:
            ans+=dp[n][j][k]
print(ans)

Measured memory_bytes: 81820
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=10000;
int f[N],n;
void init(int n){for(int i=0;i<n;i++) f[i]=i;}
int find(int x){ if (f[x]!=x) return f[x]=find(f[x]);else return x;}
void join(int x,int y){
	int xx=find(x),yy=find(y);
	if (xx!=yy) f[xx]=yy;
}
int main(){
	int q,ins,x,y;
	scanf("%d%d",&n,&q); 
	init(n);
	for(int i=0;i<q;i++){
		scanf("%d%d%d",&ins,&x,&y);
		if(ins==0) join(x,y);
		else if (ins==1){
			if (find(x)==find(y)) printf("1\n");
			else printf("0\n");
		}
	}
	return 0;
}



Measured memory_bytes: 3292
import java.util.*;

public class Main {

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

    for (int i = 0; i < n; i++) {
      x[i] = sc.nextInt();
    }

    for (int i = 0; i < m; i++) {
      y[i] = sc.nextInt();
    }

    for (int z = X+1; z <= Y; z++) {
      int countx = 0;
      int county = 0;
      for (int j = 0; j < n; j++) {
        if (x[j] < z) {
          countx++;
        }
      }

      for (int j = 0; j < m; j++) {
        if (y[j] >= z) {
          county++;
        }
      }

      if (countx == n && county == m) {
        System.out.println("No War");
        return;
      }
    }

    System.out.println("War");

  }

}


Measured memory_bytes: 23636
#include<iostream>
#include<queue>
using namespace std;
int mz[30][30];
int mr[30][30];
int md[30][30];
int w,h;
void bfs(int,int);
int main(){
  while(1){
    //syoki
    for(int i=0;i<30;i++){
      for(int j=0;j<30;j++){
	mz[i][j]=100000;
      }
    }
    //in
    cin >> w >> h;
    if(w==0&&h==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w-1;j++){
	cin >> mr[i][j];
      }
      if(i!=h-1){
	for(int j=0;j<w;j++){
	  cin >> md[i][j];
	}
      }
    }
    //syori
    mz[0][0]=1;
    bfs(0,0);
   /*debug
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(mz[i][j]==100000)cout<<"n ";
	else cout<<mz[i][j]<<" ";
      }
      cout<< endl;
    }
*/
    //out
    if(mz[h-1][w-1]==100000)cout << "0" << endl;
    else cout << mz[h-1][w-1] << endl;
  }
  return 0;
}


////////////////////////
void bfs(int x,int y){
  int xl,yl;
  queue<int>qx;
  queue<int>qy;
  qx.push(x);
  qy.push(y);
  while(!qx.empty()&&!qy.empty()){
    xl=qx.front();qx.pop();
    yl=qy.front();qy.pop();
    //right
    if(xl!=w-1){
      if(mr[yl][xl]==0&&mz[yl][xl+1]==100000){
	mz[yl][xl+1]=mz[yl][xl]+1;
	qx.push(xl+1);
	qy.push(yl);
      }
    }
    //left
    if(xl!=0){
      if(mr[yl][xl-1]==0&&mz[yl][xl-1]==100000){
	mz[yl][xl-1]=mz[yl][xl]+1;
	qx.push(xl-1);
	qy.push(yl);
      }
    }
    //up
    if(yl!=0){
      if(md[yl-1][xl]==0&&mz[yl-1][xl]==100000){
	mz[yl-1][xl]=mz[yl][xl]+1;
	qx.push(xl);
	qy.push(yl-1);
      }
    }
    //down
    if(yl!=h-1){
      if(md[yl][xl]==0&&mz[yl+1][xl]==100000){
	mz[yl+1][xl]=mz[yl][xl]+1;
	qx.push(xl);
	qy.push(yl+1);
      }
    }
  }
}

Measured memory_bytes: 1228
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n, k;
int a[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    /*int ix;
    for(int i=0;i<n;i++){
        if(a[i]==1)ix=i;
    }*/
    int ans=ceil(double(n-1)/(k-1));
    cout << ans << "\n";
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b > c*d){
    cout << a*b <<endl;
  }else if(a*b < c*d){
    cout << c*d <<endl;
  }else if (a*b == c*d){
    cout << a*b <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> a(3);    
    rep(i, 0, 3) cin >> a[i];
    if(a[0] == a[1] && a[1] == a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
// #include <algorithm>
// #include <set>
// #include <cmath>
// #include <map>
// #include <iomanip>

#define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}


int main(int argc, char const *argv[]) {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H+2, vector<char>(W+2));
    for (int i = 0; i < H; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < W; ++j) {
            a[i+1][j+1] = s[j];
        }
    }
    for (int i = 0; i < H+2; ++i) {
        a[i][0] = '#';
        a[i][W+1] = '#';
    }
    for (int j = 0; j < W+2; ++j) {
        a[0][j] = '#';
        a[H+1][j] = '#';
    }

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

    return 0;
}


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

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int k;
    cin >> k;
    while(k--) {
        if(a[2] <= a[1]) a[2] *= 2;
        else if(a[1] <= a[0]) a[1] *= 2;
    } 
    if(a[1] > a[0] && a[2] > a[1]) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
           vin a(n);
           rep(i,0,n){
             cin>>a[i];
             a[i]%=2;
           }
           bool ans=false;
           rep(i,0,n){
            if(a[i])ans=true; 
           }
           if(ans)cout<<"first"<<endl;
           else cout<<"second"<<endl;
}

Measured memory_bytes: 3780
//ios::sync_with_stdio(false);
#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z) for(int x=y;x<=z;++x)
#define D(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int N=110;
const LL Inf=10000000000000000ll;
LL Min(LL x,LL y){return x<y?x:y;}
LL Max(LL x,LL y){return x>y?x:y;}
LL R(){
    LL ans=0,f=1;char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if (c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) ans=ans*10+c-'0';
    return ans*f;
}
char s[N];
int n;
LL dp[N][26],g[40][26][26],f[26],f2[26];
LL ans,K;
void ckmin(LL &x,LL y){x=min(x,y);}
int main(){
	cin>>(s+1)>>K;
	n=strlen(s+1);
	F(i,1,n)s[i]-='a';
	ans=10000000000000000ll;
	F(i,0,31)F(j,0,25)F(k,0,25)g[i][j][k]=Inf;
	F(st,0,25){
		memset(dp,0x3f,sizeof(dp));
		dp[1][st]=st!=s[1];
		F(i,1,n-1)
			F(j,0,25)
				F(k,0,25)
					if(j!=k)
					ckmin(dp[i+1][k],dp[i][j]+(k!=s[i+1]));
		F(k,0,25){
			LL u=dp[n][k];
			g[0][st][k]=u;
		}
	}
	F(rd,1,30)
		F(l1,0,25)F(r1,0,25)F(l2,0,25)F(r2,0,25)
			if(r1!=l2)
			ckmin(g[rd][l1][r2],g[rd-1][l1][r1]+g[rd-1][l2][r2]);
	F(i,0,30)
		if((K>>i)&1){
			F(k,0,25)f2[k]=Inf;
			F(j,0,25)F(l2,0,25)F(r2,0,25)
				if(j!=l2)ckmin(f2[r2],f[j]+g[i][l2][r2]);
			F(k,0,25)f[k]=f2[k];
		}
	F(i,0,25)ckmin(ans,f[i]);
	cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 384
/*************************************
＜最初に考えたこと＞
AiとBiの差が0になると終了だから、
先手は差をなるべく差が大きくなるように、後手は差が小さくなるようにするのが最善かな？
そうすると先手は、Ai<BiというAiから1を引いていくのがよいけど、
それで0になったらそれ以上は引けないので、それ以降は差が小さくなる手を打つしかない。
一方でBは差が小さくなる手を打ち続ける。
⇒
まとめると、Ai-Biの絶対値の和をSとするとき、
先手が Ai<BiというAiから1を引いていく間は1ターンしてもSが変化しない。
そのあとは1ターンごとに先手と後手あわせてSを2減らしていき、0になったら終了。
ということで解けました。
⇒ 間違いです（考察ミス）

＜間違いの内容＞
先手の手番のとき、
Ai>Bi の場合は、Aiを1減らすと差が1減ってしまうのだけど、
Ai=Bi の場合は、Aiを1減らせば差が1増えるんですね。
だから先手はそう簡単には負けない。
3 2
2 2
0 1
みたいな状況のときは、3を減らしたら終わってしまうけど、2を減らせばまだ勝負を続けられる。

＜解答＞
逆に、どういう場合に終わってしまうかというと、終了直前の先手番の盤面は
0 0
6 5
0 1
0 0
みたいに、0でないAiが1個だけ残るような場合だけとわかる。そのあとの最終形は
0 0
5 5
0 0
0 0
というもの。
先手としては、この最後に残る数(上の例では5)を最小化したい。
→
先手としては、最初に Ai>Bi であるもののうち Bi が最小のものを残す
（それ以外のAiから引いていく）という戦略が最善で、実際にそれでうまくいくことがわかる。
************************************/

#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[])
{
    int n;
    scanf("%d", &n);
    ll sum=0;
    int val=INF;
    int i;
    for(i=0; i<n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        if(a>b) val=MIN(val,b);
        sum += a;
    }
    if(val==INF) {
        printf("0\n");
    }
    else {
        printf("%lld\n", sum-val);
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    int Sum=0;
    List<String> listA = new ArrayList<String>();
    for (int i=0;i<N ;i++ ) {
      listA.add(sc.next());

    }
    List<String> listB = listA.stream().distinct().collect(Collectors.toList());


    System.out.println(listB.size());




  }
}


Measured memory_bytes: 76848
/*-----------Author: Araz Jabrayilov---------*/
/*------------@araz17----(~~)#5371-----------*/

#include <bits/stdc++.h>

#define ll long long
#define endl '\n'

using namespace std;

ll a[200005];
ll cnt[200005];

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    ll n = 0;
    ll sum = 0;

    cin >> n ;

    for(int i = 0; i < n; i++){
      cin >> a[i];
      cnt[a[i]]++;
    }

    for(int i = 1; i < 200000; i++){
      sum += (cnt[i] * (cnt[i] - 1)) / 2;
    }

    for(int i = 0; i < n; i++){
      cout << sum - (cnt[a[i]] - 1) << endl;
    }


    return 0;
}


Measured memory_bytes: 4736
S=str(input())
disp=''
for i in range(len(S)):
    if S[i]=='0': disp+='0'
    elif S[i]=='1': disp+='1'
    elif S[i]=='B' and disp=='': continue
    elif S[i]=='B' and disp!='': disp=disp[:-1]
print(disp)

Measured memory_bytes: 3060
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

S =sys.stdin.buffer.readline().decode().rstrip()
c = S[-1]
if c in '24579':
    print('hon')
elif c == '3':
    print('bon')
else:
    print('pon')


Measured memory_bytes: 27252
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
	char c = getchar(); int w = 1; int x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
	x *= w;
	return x;
}
inline ll readll() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
	x *= w;
	return x;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
struct node{int x,y;};
int h,w,k,xx1,yy1,x2,y2;
bool ok(int x,int y){
	if(x<=h&&x>=1&&y<=w&&y>=1)return true;
	else return false;
}
queue<node>Q;
int main(){
	cin>>h>>w>>k;
	char g[h+1][w+1];
	int vis[h+1][w+1],step[h+1][w+1];
	memset(vis,0,sizeof(vis));
	memset(step,0,sizeof(step));
	cin>>xx1>>yy1>>x2>>y2;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>g[i][j];
		}
	}
	node a,b;
	a.x=xx1,a.y=yy1;
	step[xx1][yy1]=0;
	vis[xx1][yy1]=1;
	Q.push(a);
	int ans=bql;
	while(!Q.empty()){
		a=Q.front();
		Q.pop();
		if(a.x==x2&&a.y==y2){
			ans=min(ans,step[x2][y2]);
		}
		for(int i=0;i<4;i++){
			for(int j=1;j<=k;j++){
				b.x=dx[i]*j+a.x;
				b.y=dy[i]*j+a.y;
				if(ok(b.x,b.y)==0||(step[b.x][b.y]<=step[a.x][a.y]&&step[b.x][b.y]))break;
				else{
					if(g[b.x][b.y]=='@')break;
					if(g[b.x][b.y]=='.'&&!vis[b.x][b.y]){
						vis[b.x][b.y]=1;
						step[b.x][b.y]=step[a.x][a.y]+1;
						Q.push(b);
					}
				}
			}
		}
	}
	if(ans==bql)cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}
/* stuff to remember
	* int overflow, array bounds
	* special cases (n=1? n=0?)
	* do something instead of nothing and stay organized
	* USE STATIC ARRAYS
	* DEFINING ARRAYS BEFORE main()
	* DO NOT DEFINE ARRAYS IN main()
	* USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 20208
#include <bits/stdc++.h>
#define MAX 10000007
#define PI acos(-1)
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cout<<x<<endl;
#define endl "\n"
#define MEM(a,x) memset(a,x,sizeof(a))

using namespace std;
typedef long long ll ;
const int INF= 1e9+7;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<long long,null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
*/
/*
bool sortbysec(const pair<int,int>&a, const pair<int,int>&b)
{
    return (a.second<b.second);
}
*/
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.tie(NULL);
    int n;
    cin>>n;

    if(n==7 || n== 5 || n==3)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<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)++)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define esort(s) sort((s).begin(),(s).end()) 
#define INF 999999999

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


    if ( s == "SUN")
        cout << 7 << endl;
    else if ( s == "MON")
        cout << 6 << endl;
    else if ( s == "TUE")
        cout << 5 << endl;
    else if ( s == "WED")
        cout << 4 << endl;
    else if ( s == "THU")
        cout << 3 << endl;
    else if ( s == "FRI")
        cout << 2 << endl;
    else if ( s == "SAT")
        cout << 1 << endl;
    
    return 0;
}

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

int main(){
int i,j,N,Y,k;
k=0;
cin >> N >> Y;
for(i=0;i<=N;i++){
	for(j=0;j<=N-i;j++){
		if(10000*i+5000*j+1000*(N-i-j)==Y){
			cout << i << " " << j << " " << N-i-j <<endl;
			k = 1;
			break;
		}
	}
	if(k==1){
		break;
	}
}
	
if(k==0){
	cout << -1 << " " << -1 << " " << -1 <<endl;
}
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K;
    cin >> N >> K;
    ll t = N % K;
    cout << min(t, abs(K - t)) << '\n';

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		for(int h=0;h<3;h++){
			for(int w=0;w<3;w++){
				map[h][w] = sc.nextInt();
			}
		}

		int dw1 = map[0][1]-map[0][0];
		if(dw1 != map[1][1]-map[1][0] || dw1 != map[2][1]-map[2][0]){ answer(false); return;}

		int dw2 = map[0][2]-map[0][1];
		if(dw2 != map[1][2]-map[1][1] || dw2 != map[2][2]-map[2][1]) { answer(false); return;}

		int dh1 = map[1][0]-map[0][0];
		if(dh1 != map[1][1]-map[0][1] || dh1 != map[1][2]-map[0][2]){ answer(false); return;}

		int dh2 = map[2][0]-map[1][0];
		if(dh2 != map[2][1]-map[1][1] || dh2 != map[2][2]-map[1][2]){ answer(false); return;}

		answer(true);
	}

	private static void answer(boolean ans){
		if(ans) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    map<char, ll> cnt;
    for(ll i='a'; i<='z'; i++) cnt[i] = 0;
    rep(i, s.size()) cnt[s[i]]++;

    for(auto p: cnt){
        if(p.second == 0){
            cout << p.first << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"["; 
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    
    int t=1;
    // cin>>t;
    while(t--)
    {
         string s;cin>>s;int ans=0;int c=0;
         f(i,0,3) 
         {
           if(s[i]=='R')
           c++;
           else
           {
             c=0;
           }
           ans=max(ans,c);
           
         }
         cout<<ans;
    }    
} 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
 
 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll A,C;
  long double B;
  cin >> A >> B;
  C = A*B;
    cout << C << endl;
}

Measured memory_bytes: 3748
import math
n,d = map(int, input().split())
point = [list(map(int, input().split())) for i in range(n)]
count = 0
for i in range(len(point)):
  if math.sqrt((point[i][0])**2+(point[i][1])**2) <= d:
    count = count+1
print(count)
  


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

int main(){
  int n;
  cin >> n;
  int k=0;
  int s=100000;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    k+=x;
    if(x%10!=0) s=min(s,x);
  }
  if(k%10!=0) cout << k << endl;
  else if(s!=100000) cout << k-s << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
N,M  = map(int, input().split())
A = {}
mod = 10**9+7
for i in range(M):
    a = int(input())
    A[a] = 1
    if a-1 in A:
        print(0)
        exit()

stairs = [0 for _ in range(N+2)]
stairs[0] = 1

for i in range(N):
    if i+1 not in A:
        stairs[i+1] = (stairs[i] + stairs[i+1]) % mod
    if i+2 not in A:
        stairs[i+2] = (stairs[i] + stairs[i+2]) % mod
        
print(stairs[N])


Measured memory_bytes: 10024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    int a = 0, b = 0, c = 0;
    rep(i, s.size()){
        a += (s[i] == 'a');
        b += (s[i] == 'b');
        c += (s[i] == 'c');
    }

    int diff = max({a, b, c}) - min({a, b, c});
    if(diff > 1) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 512
C=0
while True:
    try:
        a=input()
        b=len(a)//2
        c=0
        i=0
        while i<b:
            if a[i]==a[len(a)-1-i]:
                i+=1
                c+=1
            else:
                break
        if c==b:
            C+=1
    except:
        print(C)
        break


Measured memory_bytes: 5560
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(sys.stdin.readline() for _ in range(n)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# INF = float("inf")
# sys.setrecursionlimit(10000)
import sys,collections
sys.setrecursionlimit(100000)
n = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
if 0 in a:
    print(0)
    exit()
ret = 1
i = 0
lim = 10**18
while i < len(a):
    ret *= a[i]
    if lim < ret:
        print(-1)
        exit()
    i += 1
print(ret)


Measured memory_bytes: 22480
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ns = readln.split;
    foreach (a; ns) {
        foreach (b; ns) {
            foreach (c; ns) {
                foreach (d; ns) {
                    if (a~b~c~d == "1974") {
                        writeln("YES");
                        return;
                    }
                }
            }
        }
    }
    writeln("NO");
    return;
}

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

int main() {
    string s;
    cin >> s;
   
   if(s[2]==s[3]&&s[4]==s[5]){
       cout << "Yes\n";
   }
   else
       cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
	char s[100];
	char p[100];
	int i, j;
	int count=0;
	int a=0;

	scanf("%s", s);
	scanf("%s", p);

	for (i=0;i<=strlen(s);i++)
	{
		count=0;

		if (p[0] == s[i])
		{
			for (j=0;j<=strlen(p)-1;j++)
			{
				if (strlen(s) > i+j)
				{
					//printf("%c %c\n", s[i+j], p[j]);
					if (s[i+j] != p[j])
					{
						count++;
					}
				}
				else if (strlen(s) <= i+j)
				{
					//printf("%c %c\n", s[i+j-strlen(s)], p[j]);
					if (s[i+j-strlen(s)] != p[j])
					{	
						count++;
					}
				}

				else if (count != 0)
				{
					break;
				}
			}

			if (count == 0)
			{
				a=1;
			}
		}
	}
	if (a==1)
	{
		printf("Yes\n");
	}
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	cout<<n*n;
	return 0;
}

Measured memory_bytes: 256