akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(x...)
#endif
#define endl "\n"
#define int long long int
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define loop(i,c) for(auto i=(c).begin();i!=(c).end();i++)
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7;

void solving() {
	int X, Y;
	cin >> X >> Y;
	if (Y % 2 == 1) {
		cout << "No" << endl;
		return;
	}
	else {
		if (Y >= (2 * X) and Y <= (4 * X)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// int t{}; cin >> t; while (t--)
	solving();
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll lim=1e9;
int main()
{
	ll S;
	scanf("%lld",&S);
	ll p=sqrt(S);
	if(p*p==S)
	{
		printf("0 0 %lld 0 0 %lld\n",p,p);
		return 0;
	}
	p++;
	ll ax=p,by=p,bx,ay;
    ll Z=p*p-S;
    if(Z<=lim)
	{
		bx=Z;
		ay=1;
		printf("0 0 %lld %lld %lld %lld",ax,ay,bx,by);
		return 0;
	}
	for(ll i=2;i*i<=Z;i++) if(Z%i==0)
	{
		if(i<=lim && Z/i<=lim)
		{
			bx=i;
			ay=Z/i;
			printf("0 0 %lld %lld %lld %lld\n",ax,ay,bx,by);
			return 0;
		}
	}
	assert(0);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>

using namespace std;
typedef pair<int, int> Pi;
typedef pair<int, Pi> Ti;

int c, n, m, s, d;
vector<vector<Pi>> edge;

int djk(int s, int g) {
	int d[100 + 16][11];
	for (int i = 0; i < n; i++)for (int j = 0; j <= c; j++)d[i][j] = 1000000000;
	d[s][c] = 0;
	priority_queue<Ti, vector<Ti>, greater<Ti>> pq;
	pq.push(make_pair(0, make_pair(s, c)));
	while (pq.size()) {
		Ti tmp = pq.top(); pq.pop();
		int N = tmp.second.first, ticket = tmp.second.second;
		if (d[N][ticket] < tmp.first)continue;
		for (int i = 0; i < edge[N].size(); i++) {
			int to = edge[N][i].first, cost = edge[N][i].second;
			if (ticket > 0) {
				if (d[to][ticket - 1] > d[N][ticket] + cost / 2) {
					d[to][ticket - 1] = d[N][ticket] + cost / 2;
					pq.push(make_pair(d[to][ticket - 1], make_pair(to, ticket - 1)));
				}
			}
			if (d[to][ticket] > d[N][ticket] + cost) {
				d[to][ticket] = d[N][ticket] + cost;
				pq.push(make_pair(d[to][ticket], make_pair(to, ticket)));
			}
		}
	}
	int ans = 1000000000;
	for (int i = 0; i <= c; i++)ans = min(ans, d[g][i]);
	return ans;
}

int main() {
	while (cin >> c >> n >> m >> s >> d, c + n + m + s + d) {
		s--, d--;
		edge.resize(n);

		for (int i = 0; i < m; i++) {
			int a, b, f;
			cin >> a >> b >> f, a--, b--;
			edge[a].push_back(make_pair(b, f));
			edge[b].push_back(make_pair(a, f));
		}
		cout << djk(s, d) << endl;
		edge.clear();
	}
	return 0;
}

Measured memory_bytes: 3132
import java.util.Scanner;

class Main {

	/*
	 * 着席位置：中央前から３列目
	 * 問題：https://onlinejudge.u-aizu.ac.jp/problems/DSL_1_A
	 */

	private static int n[];

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		n = new int[Integer.parseInt(scanner.next())];
		for(int i=0; i<n.length; i++) {
			n[i] = i;//最初は全てroot
		}
		int q = Integer.parseInt(scanner.next());

		for(int i=0; i<q; i++) {
			String order = scanner.next();
			if(order.equals("0")) {
				unite(Integer.parseInt(scanner.next()), Integer.parseInt(scanner.next()));
			}else if(order.equals("1")){
				same(Integer.parseInt(scanner.next()), Integer.parseInt(scanner.next()));
			}
		}

		scanner.close();
	}

	//木を合体させる
	private static void unite(int x, int y) {
		int X = root(x), Y = root(y);
		n[Y] = X;
	}

	//同じ木か調べる
	private static void same(int x, int y) {
		if (root(x)==root(y)) {
			System.out.println("1");
		}else {
			System.out.println("0");
		}
	}

	//rootを返す
	private static int root(int i) {
		if(n[i]==i) return i;
		else {
			return root(n[i]);
		}
	}

}



Measured memory_bytes: 72104
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

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

		public FastScanner(InputStream source) {
			in = source;
		}

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

	public static void main(String[] args){

		solve_abc166_a();
	}
  
  	public static void solve_abc166_a(){

		FastScanner sc = new FastScanner(System.in);

		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		boolean ans = false;
		
		for(int i=a;i<=b;i++){
			if(i % k == 0){
				ans = true;
				break;
			}
		}
		
		if(ans) System.out.println("OK");
		else System.out.println("NG");
		
	}
}

Measured memory_bytes: 26944
<?php

fscanf(STDIN, "%d %d %d", $a, $b, $k);
$result_a = $a - $k;
$result_b = $b;
if ($result_a <= 0) {
  $result_b = $b + $result_a;
  $result_a = 0;
}
if ($result_b <= 0) {
  $result_b = 0;
}
echo $result_a." ".$result_b;

Measured memory_bytes: 4604
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	int gcnt = 0, pcnt = 0;
	for (int i = 0; i < (int)s.size(); i++) {
		bool f = (pcnt + 1 <= gcnt) ? true : false;
		if (s[i] == 'g') {
			if (f) {
				pcnt++;
				ans++;
			}
			else {
				gcnt++;
			}
		}
		if (s[i] == 'p') {
			if (f) {
				pcnt++;
			}
			else {
				gcnt++;
				ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b;
  cin >> a >> b;
  if(a % 3 == 0 || b%3 == 0 || (a+b)%3 == 0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 256
n=int(input())
dp=[0 for i in range(n+1)]
dp[0]=1
x=(n-1)**2
dp[1]=n
pref=dp[1]
mod=10**9+7
x%=mod
for i in range(2,n+1):
    dp[i]+=x+pref-dp[i-2]+(n-i+2)
    pref+=dp[i]
    pref%=mod
    dp[i]%=mod
        
print(dp[-1])
    
    
    


Measured memory_bytes: 114288
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
s = input()
t = input()

def gcd(a, b):
    while a and b:
        if a < b:
            b %= a
        else:
            a %= b
    return max(a, b)

_gcd = gcd(n, m)
if s[::n // _gcd] == t[::m // _gcd]:
    print(n * m // _gcd)
else:
    print(-1)

Measured memory_bytes: 3316
s = str(input())
a = int(s[0]) * 10 + int(s[1])
b = int(s[2]) * 10 + int(s[3])
if 1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1 <= a <= 12:
    print('MMYY')
elif 1 <= b <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 9176
#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 REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++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 ? "" : " "); 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;
//------------------------------------------------------------------------------

int K,R,L;
double P,E,T;
double rec(double wishl,double wishr,double watchl,double watchr,double p,int d) {
    if(wishr<=watchl || watchr<=wishl) return 0.0;
    if(wishl<=watchl && watchr<=wishr) return p;
    double m=(watchl+watchr)/2.0;
    if(d==K) {
        if(wishl<=m && m<=wishr) return p;
        if(m<=wishl || wishr<=m) return 0;
    }
    double pl=rec(wishl,wishr,watchl,m,p*(m<T?P:1-P),d+1);
    double pr=rec(wishl,wishr,m,watchr,p*(m<T?1-P:P),d+1);
    return pl+pr;
}
signed main() {
    cin>>K>>L>>R;
    cin>>P>>E>>T;
    cout<<rec(T-E,T+E,L,R,1.0,0)<<endl;
    return 0;
}

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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  ll l,r;
  cin >> l >> r;
  ll cnt = 0;
  for (ll i = l; i <= r && cnt <= 2019; i++, cnt++) {
    if (i % 2019 == 0) {
      cout << 0 << endl;
      return;
    }
  }
  ll ans = INF;
  for (ll i = l; i <= r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ans = min(ans, i * j % 2019);
    }
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]){

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

Measured memory_bytes: 256
import bisect

N, M = map(int, input().split())

cards = list(map(int, input().split()))
cards.sort()
ops = []
for i in range(M):
    B, C = map(int, input().split())
    ops.append({"B": B, "C": C})
ops.sort(key=lambda o: o["C"], reverse=True)
#print(cards)
#print(ops)

left = 0
for op in ops:
    length = bisect.bisect_left(cards, op["C"], lo=left) - left
    #print(length)
    # fill left..idx
    for i in range(min(length, op["B"])):
        cards[left + i] = op["C"]
    left += min(length, op["B"])
#print(cards)
ans = 0
for val in cards:
    ans += val
print(ans)


Measured memory_bytes: 45508
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

bool adj[100][100];
int n;
int memo[100][100][500];
int solve(int a, int b, int t) {
  int f = t%2;
  if (memo[a][b][t] >= 0) return memo[a][b][t];
  if (a == b) return 0;
  if (t > 500) return INF;
  //cout << a << " "  << b << " " << t << endl;
  int res;
  if (f) {                      // aaron
    res = 0;
    REP(i,n) {
      if (adj[a][i]) {
        res = max(res,solve(i,b,t+1)+1);
      }
    }
  } else {
    res = INF;
    REP(i,n) {
      if (adj[b][i]) {
        res = min(res, solve(a,i,t+1));
      }
    }
  }
  return memo[a][b][t] = res;
}


int main() {
  int T;
  cin >> T;
  while(T--) {
    cin >> n;
    REP(i,n) REP(j,n)
      cin >> adj[i][j];
    REP(i,n) adj[i][i] = 1;
    // REP(i,n) {
    //   REP(j,n)cout<<dis[i][j]<< " "; cout << endl;
    // }
    int A, B; cin >> A >> B;
    memset(memo,-1,sizeof(memo));
    int ret = solve(A,B,1);
    if (ret > 2000) cout << "infinity" << endl;
    else cout << ret << endl;
    
  }
}

Measured memory_bytes: 0
package main

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

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	var s string
	if scanner.Scan() {
		s = scanner.Text()
	}
	slice := strings.Split(s, " ")
	a, _ := strconv.Atoi(slice[0])
	b, _ := strconv.Atoi(slice[1])

	if a > b {
		fmt.Println("safe")
	} else {
		fmt.Println("unsafe")
	}

}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "B"
ll f[101];
int n;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    f[0]=2;
    f[1]=1;
    read(n);
    FOR(i, 2, n) f[i]=f[i-1]+f[i-2];
    writeln(f[n]);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1) (__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1) (__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
using namespace std;


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

  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<vector<pair<int, int>>> adj(n);
  rep(i, m) {
    int l, r, d;
    cin >> l;
    cin >> r;
    cin >> d;
    l--;
    r--;
    adj[l].push_back(mp(r, d));
    adj[r].push_back(mp(l, -d));
  }
  bool ans = true;
  vector<int> dist(n);
  vector<bool> seen(n);
  function<void(int)> dfs = [&](int i) {
    each(e, adj[i]) {
      int next = e.first;
      int value = dist[i] + e.second;
      if (seen[next]) {
        if (dist[next] != value) ans = false;
      } else {
        dist[next] = value;
        seen[next] = true;
        dfs(next);
      }
    }
  };
  rep(i, n) if(!seen[i]) {
    seen[i] = true;
    dfs(i);
  }
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 12928
#include <cstdio>
#define N 111111
#define swap(a, b) { int t = a; a = b; b = t; }
int a[N];
int main(void)
{
	int n;
	scanf("%d", &n);
	int i, ans = 0;
	for (i = 1; i <= n; ++i) scanf("%d", a + i);
	for (i = 1; i <= n; ++i) {
		if (a[i] == i) {
			swap(a[i], a[i + 1]);
			++ans;
		}
	}
	printf("%d", ans);
}


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

int gcd(int p, int q){
    if (p % q == 0){
        return (q);
    }else{
        return (gcd(q, p % q));
    }
}



int main()
{
    ll n, sum = 0;
    cin >> n;

    for (ll i = 1; i <= n; i++){
        for(ll j = 1; j <= n; j++) {
            for(ll k = 1; k <= n; k++) {
                sum += gcd(gcd(i, j), k);
            }
        }
    }

    cout << sum << endl;    
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
ll a[1005];
ll b[1005];
P pos[1000005];
int cnt[1000005];

int main(void){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n*m;i++){
        pos[i]=P(-1,-1);
    }
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        pos[a[i]].first=i;
        cnt[a[i]]+=1;
    }
    for(int i=0;i<m;i++){
        scanf("%lld",&b[i]);
        pos[b[i]].first=i;
        cnt[b[i]]+=2;
    }
    ll ans=1;
    bool flag=false;
    ll cnta=0,cntb=0,used=0;
    for(int i=n*m;i>=1;i--){
        if(cnt[i]==3){
            cnta++;
            cntb++;
            used++;
        }else if(cnt[i]==1){
            ans=ans*cntb%MOD;
            cnta++;
            used++;
        }else if(cnt[i]==2){
            ans=ans*cnta%MOD;
            cntb++;
            used++;
        }else{
            ans=ans*((cnta*cntb-used)%MOD)%MOD;
            used++;
        }
        //printf("%d %lld\n",i,ans);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using Graph = vector<vector<LL>>;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
long long chmax(long long a,long long b){
  a = max(a,b);
}
long long chmin(long long a, long long b){
  a = min(a,b);
}
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}



int main() {
  LL n,k=-1,sum=0,a=0,b=0,c=0,d=0,ans=0;
  LL MOD = 1000000007;
  LL INF = 1LL << 60;
  LL h[100001],L[100001],R[100001];
  string S="",T="",U="";
  cin >> S >> T;
  if(S==T.substr(0,S.size())) cout << "Yes" << endl;
  else cout << "No" << endl;
  //cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include "math.h"
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= b) {
    std::cout << a;
  } else {
    std::cout << a - 1;
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
kjn=0
mi2=0
mi=0
for i in range(0,n):
    if a[i]==kjn:
        mi2=1-mi2
    else:
        kjn=a[i]
        mi+=1
print(mi-mi2)

Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
ll N;

int a[200010];
int b[200010];
int c[200010];
ll sum[200010];
signed main(void) {
    cin >> N;
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];
    REP(i, N) cin >> c[i];
    sort(a, a+N);
    sort(c, c+N);
    
    ll cnt=0;
    for(int i=0; i<N; ++i){
        ll lb = lower_bound(a, a+N, b[i]) - a;
        ll ub = N - (upper_bound(c, c+N, b[i]) - c);
        cnt += lb*ub;
    }
    cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 7680
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();
      Map<Integer, List<Integer>> map = new HashMap<>();
      for(int i = 0; i < m; i++) {
        int k = sc.nextInt();
        List<Integer> sList = new ArrayList<>();
        for(int j = 0; j < k; j++) {
          sList.add(sc.nextInt() - 1);
        }
        map.put(i, sList);
      }
      int[] p = new int[m];
      for(int i = 0; i < m; i++)
        p[i] = sc.nextInt();

      int cnt = 0;
      for(int i = 0; i < (1<<n); i++) {
        int num = i;
        if(check(map, p, num))
          cnt++;
      }
      System.out.println(cnt);
  }

  private static boolean check(Map<Integer, List<Integer>> map, int[] pArr, int n) {
    for(Map.Entry<Integer, List<Integer>> entry : map.entrySet()) {
        int p = pArr[entry.getKey()];
        List<Integer> lights = entry.getValue();
        int cnt = 0;
        for(int lightIdx : lights) {
          if(((n >> lightIdx) & 1) == 1)
            cnt++;
        }
        if(cnt % 2 != p)
          return false;
    }
    return true;
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,j,n) for(int i=j;i<n;i++)
const int INF = 1000000009;

int main(){
    int N,W;
    cin >> N >> W;
    int w[N+1],v[N+1];
    REP2(i,1,N+1){
        cin >> w[i]>>v[i];
    }
    long long dp[N+1][W+1]={};
    REP2(i,1,N+1){
        REP(j,W+1){
            //i番目の品物を入れた場合(dp[i-1][j-w[i]]+v[i])と入れない(dp[i-1][j])
            if(w[i] <= j){
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
            
        }
    }
    ll ans = 0;
    REP(j,W+1){
        ans = (ans > dp[N][j])? ans:dp[N][j];
    }
    cout << ans<<endl;
}

Measured memory_bytes: 79104
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
//        int d = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int x0 = 0;
        int y0 = 0;
        for(int i=0;i<c;i++){
            string[] temp = ReadLine().Split(' ');
            int n = int.Parse(temp[0]);
            int m = int.Parse(temp[1]);
            int k = int.Parse(temp[2]);
            if(k==1){    x0 = Max(x0,n);    }
            if(k==2){    a = Min(a,n);    }
            if(k==3){    y0 = Max(y0,m);    }
            if(k==4){    b = Min(b,m);    }
        }
        if(a-x0 >= 0 && b-y0 >= 0){
            WriteLine((a-x0)*(b-y0));
        }else{
            WriteLine("0");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
 
int main(){
    char src[17];
    char ans[17] = "CODEFESTIVAL2016";
    int result = 0;
    
    scanf("%s", src);
    for(int i = 0; i < 17; i++){
        if(src[i] != ans[i])
            result++;
    }
    printf("%d\n", result);
 
    return 0;
}

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

int main(){
    long long N,M,X;
    cin >> N >> M >> X;
    vector<vector<int>> A(N,vector<int>(M));
    vector<int> C(N);
    int min = 1<<30;
    for(int i =0; i < N; i++){
        cin >> C[i];
        for(int j =0; j < M; j++){
            cin >> A[i][j];
        }
    }
    for(int i =0; i < 1<<N; i++){
        int sum = 0;
        vector<int> rikaido(N);
        for(int j =0; j < N; j++){
            if((1<<j)&i){
                sum += C[j];
                for(int k =0; k < M; k++){
                    rikaido[k] += A[j][k];
                } 
            }
        }
        bool beyond = true;
        for(int i =0; i < M; i++){
            if(rikaido[i] < X){
                beyond = false;
                break;
            }
        }
        if(beyond){
            if(sum < min) min = sum;
        }
    }
    if(min == (1<<30)) cout << -1 << endl;
    else cout << min << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
ll n, res;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 1; i <= n; i++){
        ll ans = 0;
        for (ll j = 1; j <= sqrt(i); j++){
            if (i % j == 0){
                if (i == j * j) ans += 1;
                else ans += 2;
            }
        }
        if (ans == 8 && i % 2 == 1) res++;
    }
    cout << res << endl;
}


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

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

int main() {
    ll N,M;cin >> N >> M;
    ll A[N] = {};
    for (int i = 0;i < N;i++){
        ll a;cin >> a;
        A[i] = a / 2;
    }
    ll LCM = lcm(A[0],A[1]);
    for (int i = 2;i < N;i++){
        LCM = lcm(LCM,A[i]);
    }
    if (N == 1) LCM = A[0];
    for (int i = 0;i < N;i++){
        if ((LCM / A[i]) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll res;
    res = M / LCM;
    if (res % 2 == 0) res /= 2;
    else res = res/2 + 1;
    cout << res << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
  
int main(void)
{
   int a, b, c, key;
   scanf("%d %d %d", &a, &b, &c);
   if(a > b){
        key = a;
        a = b;
        b = key;
   }
   if(b > c){
        key = b;
        b = c;
        c = key;
        if(a > b){
            key = a;
            a = b;
            b = key;
        }
   }
   printf("%d %d %d\n", a, b, c);
   return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,i,j,k,x,maxi= INT_MIN ,mini=INT_MAX;
    cin>>n;
    for(i = 0 ;i<n ;i++)
    {
        cin>>x;
        maxi = max(maxi,x);
        mini= min(mini,x);
    }
    cout<<maxi-mini<<endl;
    return 0;
}


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

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

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int n = 0;n<N;++n) {
		cin >> A[n];
	}
	vector<int>L(N);	
	L[0] = 0; 
	for (int n = 1; n < N; ++n) {
		L[n] = gcd(A[n-1],L[n - 1]);
	}
	vector<int>R(N);
	R[N - 1] = 0;
	for (int n = 1; n < N; ++n) {
		R[N-1-n] = gcd(A[N - n],R[N-n]);
	}
	int ans = 0;
	for (int n = 0; n < N; ++n) {
		ans = max(ans,gcd(R[n],L[n]));
	}
	cout << ans <<endl;
}


Measured memory_bytes: 4532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << x << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    sc(n);
    int a[n];
    GET(a);
    ll p[n];
    map<ll,int> m;
    p[0] = a[0];
    ++m[0];
    ll ans = m[p[0]]++;
    for(int i = 1; i < n; ++i){
        ans += m[p[i] = p[i-1]+a[i]]++;
    }
    cout << ans << '\n';
}



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

int main() {
  int N, K, d, a;
  cin >> N >> K;
  vector<int> V(N,1);
  for (int i=0; i<N; i++) {
    cin >> d;
    for (int j=0; j<d; j++) {
      cin >> a;
      V.at(a-1) = 0;
    }
  }
  
  int C=0;
  for (int i=0; i<N; i++) {
    if (V.at(i)) {
      C++;
    }
  }
  cout << C << endl;
}

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

#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

const int oo = 1e9;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n,m; cin>>n>>m;
	int a[n][m];
	f(i,0,n) f(j,0,m) cin>>a[i][j];
	f(i,0,n) f(j,0,m) a[i][j]--;
	bool take[m];	
	f(i,0,m) take[i] = 1;
	int ans = oo;
	f(_,0,m) {
		int freq[m];
		fill(freq,freq+m,0);
		f(i,0,n) {
			int k = 0;	
			fr(j,0,m) if (take[a[i][j]]) k = a[i][j];
			freq[k]++;
		}
		int k = 0;
		f(i,1,m) if (freq[k]<freq[i])
			k=i;
		ans = min(ans,freq[k]);
		take[k] = 0;
	}	
	cout << ans << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 640
using System;

namespace SoundHound2018B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int w = int.Parse(Console.ReadLine());

            int count = s.Length / w + (s.Length % w == 0 ? 0 : 1);
            for (int i = 0; i < count; i++)
            {
                Console.Write(s[i * w]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main()
{
    int days[13][32];
    int i,j,day=0,month,date;
    for(i=1;i<=12;i++){
        for(j=1;j<=31;j++) {
            if(i==2&&j>29) break;
            if(i==4||i==6||i==9||i==11){
                if(j>30) break;
            }
            days[i][j] = day;
            day++;
            if(day>6){
                day=0;
            }
        }
    }
    
    while(1){
        scanf("%d %d", &month ,&date);
        if(month==0&&date==0) break;
        switch(days[month][date]){
            case 0:puts("Thursday");
                break;
            case 1:puts("Friday");
                break;
            case 2:puts("Saturday");
                break;
            case 3:puts("Sunday");
                break;
            case 4:puts("Monday");
                break;
            case 5:puts("Tuesday");
                break;
            case 6:puts("Wednesday");
        }
    }
    return 0;
}

Measured memory_bytes: 584
import sys
uppers = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
lowers = 'abcdefghijklmnopqrstuvwxyz'
s = []
for line in sys.stdin:
    s += line
for i in range(26):
    print(lowers[i] + ' : ' + str(s.count(uppers[i]) + s.count(lowers[i])))

Measured memory_bytes: 7420
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll a;
    ll state;
    ll r_left,r_right;//Rの左右端
    ll l_left,l_right;//Lの左右端
    //ll ari;//R..RLのLの位置
    string s;
    cin >> s;
    vll kodomo(s.length());

    state=0;
    FOR(i,0,s.length()-1){
        if(state==0){ //(L)R
            //はじめ/Lの連続がとぎれたときはR
            state=1;
            r_left=i;
        }else if(state==1){ //R....RL
            if(s[i]=='R'){
                //state=1; //continue loop
            }else if(s[i]=='L'){
                //アリ地獄
                r_right=i-1;
                l_left=i;
                while(s[i]=='L' && i<=s.length()-1){
                    i++;
                }
                l_right=i-1;

                i=l_left;
                if((r_right-r_left+1)%2==1){
                    kodomo[i-1]+=(r_right-r_left+2)/2;
                    kodomo[i]+=(r_right-r_left)/2;
                }else{
                    kodomo[i-1]+=(r_right-r_left+1)/2;
                    kodomo[i]+=(r_right-r_left+1)/2;
                }
                if((l_right-l_left+1)%2==1){
                    kodomo[i-1]+=(l_right-l_left)/2;
                    kodomo[i]+=(l_right-l_left+2)/2;
                }else{
                    kodomo[i-1]+=(l_right-l_left+1)/2;
                    kodomo[i]+=(l_right-l_left+1)/2;
                }

                i=l_right;
                state=0;
            }else{
                cerr << "???" << endl;
                return 1;
            }
        }
    }
    REP(i,s.length()){
        cout << kodomo[i] << endl;
    }
}

Measured memory_bytes: 1408
s=input()
#print(s[1]+s[2:2+s[2:-1].index("C")]+s[s[2:-1].index("C")+1:])
if s[0]=="A" and s[2:-1].count("C")==1:
    if (s[1]+s[2:2+s[2:-1].index("C")]+s[s[2:-1].index("C")+3:]).islower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 38256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    s = input()

    a = 0

    p1 = p2 = p3 = ''
    for c in s:
        p1 = p2
        p2 = p3
        p3 = c

        if p1 == 'A' and p2 == 'B' and p3 == 'C':
            a += 1

    print(a)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>

int main (){
	int n, d;

	std::cin >> n >> d;

	std::vector<std::vector<long long> > v(n, std::vector<long long>(d, 0));

	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = 0; j < d; j++)
		{
			std::cin >> v[i][j];
		}
	}

	int count = 0;
	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = i + 1; j < n; j++)
		{
			long long ans = 0;
			for (size_t k = 0; k < d; k++)
			{
				ans += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
			}
			for (long long j = 0; j * j <= ans; j++)
			{
				if (j * j == ans) {
					count++;
				}
			}
		}
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	n := oneInt()
	a := scanNums(n)

	a = append(a, 0)
	a = sortDesc(a)

	ans := 0
	for i := 0; i < n; i += 2 {
		ans += a[i] - a[i+1]
	}

	fmt.Println(ans)
}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func oneStr() string {
	sc.Scan()
	return sc.Text()
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums []int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums []int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

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

func sum(nums []int) int {
	sum := 0
	for i := 0; i < len(nums); i++ {
		sum += nums[i]
	}
	return sum
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}

func sumOfEachDigit(num int) int {
	sum := 0
	for num > 0 {
		sum += num % 10
		num /= 10
	}
	return sum
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  char x, y;
  cin >> x >> y;
  cout << (x < y ? '<' : x == y ? '=' : '>') << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N,M;
  scanf("%d%d",&N,&M);
  int a[N];
  int sum=0;
  int cnt=0;
  for(int i=0;i<N;i++)
  {
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  for(int i=0;i<N;i++)
  {
    if(a[i]*4*M>=sum)
      cnt++;
  }
  if(cnt>=M)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int dp[100010],n,a[100010];
int solve(int i)
{
  if(i==0)
    return 0;
  if(dp[i]!=-1)
    return dp[i];
  int m=0;
   if(i>=2)
  m=min(abs(a[i]-a[i-1])+solve(i-1),abs(a[i]-a[i-2])+solve(i-2));
  else if(i==1)
    m=abs(a[i]-a[i-1]);
  return dp[i]=m;
}
int main()
{
  memset(dp,-1,sizeof(dp));
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  cout<<solve(n-1)<<"\n";
   //cout<<dp[n-1]<<"\n";
  return 0;
}

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


int main() {
  int r;
  cin >> r;
  string ans = "AGC";
  if(r < 1200) ans = "ABC";
  else if(r < 2800) ans = "ARC";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int n,m;
char w[108][108];
bool h[108],l[108];

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int k=1;k<=m;k++)
		{
			cin>>w[i][k];
			if(w[i][k]=='#')
			{
				h[i]=true;
				l[k]=true;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int k=1;k<=m;k++)
		{
			if(h[i]==true && l[k]==true)
			{
				cout<<w[i][k];
			}
		}
		if(h[i]==true)
		{
			cout<<endl;
		}
	}

	return 0;
}

/**
 *      ┌─┐       ┌─┐
 *   ┌──┘ ┴───────┘ ┴──┐
 *   │                 │
 *   │       ───       │
 *   │  ─┬┘       └┬─  │
 *   │                 │
 *   │       ─┴─       │
 *   │                 │
 *   └───┐         ┌───┘
 *       │         │
 *       │         │
 *       │         │
 *       │         └──────────────┐
 *       │                        │
 *       │                        ├─┐
 *       │                        ┌─┘
 *       │                        │
 *       └─┐  ┐  ┌───────┬──┐  ┌──┘
 *         │ ─┤ ─┤       │ ─┤ ─┤
 *         └──┴──┘       └──┴──┘
 */

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

int main() {
	int N,A,B;
	cin>>N>>A>>B;
	int ansmax,ansmin;
	ansmax=min(A,B);
	ansmin=max(0,A+B-N);
	cout<<ansmax<<' '<<ansmin<<endl;
}

Measured memory_bytes: 256