akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    int cnt = 0;
    for (int i = 1; i <= N; i += 2) {
        cnt++;
    }
    if (cnt >= K) puts("YES");
    else puts("NO");
    return 0;
}


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

int main(void){
  int n;
  std::cin >> n;
  std::vector<int> h(n);

  int height_max = -1;
  int count = 0;
  for(int i=0; i<n; i++){
    std::cin >> h[i];
    if (h[i] >= height_max){
      count++;
      height_max = h[i];
    }
  }
  std::cout << count << std::endl;
  return 0;
  
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define d(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
    int R;
    cin>>R;
    if(R<1200){
        cout<<"ABC"<<endl;
    }
    else if(R<2800){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"AGC"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a

dist = [0] * (n + 1)
cur_dist = 0
cur_pos = 1
while True:
    next_pos = a[cur_pos] 
    cur_dist += 1
    if cur_dist == k:
        print(next_pos)
        exit()
    elif dist[next_pos] == 0:
        dist[next_pos] = cur_dist
        cur_pos = next_pos
    else:
        cycle = cur_dist - dist[next_pos]
        nokori = k - cur_dist
        nokori = nokori % cycle
        cur_pos = next_pos
        for i in range(nokori):
            next_pos = a[cur_pos]
            cur_pos = next_pos
            if i == nokori - 1:
                print(cur_pos)
                exit()




    





Measured memory_bytes: 32132
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
int a[200000];
int sum;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        sum ^= a[i];
    }
    for(int i = 0; i < N; i++) cout << (sum^a[i]) << ' ';
    cout << endl;
}

Measured memory_bytes: 4424
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll A, V, B, W, T; cin >> A >> V >> B >> W >> T;
	if (A < B) {
		A += T * V;
		B += T * W;
		if (A >= B)puts("YES");
		else puts("NO");
	}
	else {
		A -= T * V;
		B -= T * W;
		if (B >= A)puts("YES");
		else puts("NO");
	}

	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define MAX_N 6500000
#define rank Asdfiasofsad
using namespace std;

struct edge{
  int c,a,b;
  bool operator < (edge x)const{return c<x.c;}
};

int par[MAX_N];
int rank[MAX_N];
int n,m;
edge e[50000];
bool used[50000];
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
}

int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}

bool same(int x,int y){return find(x)==find(y);}

int cal(int x){
  int res=0,c=0;
  init(n);
  for(int i=0;i<m;i++){
    if(i==x||same(e[i].a,e[i].b))continue;
    if(x==-1)used[i]=1;
    unite(e[i].a,e[i].b);
    res+=e[i].c,c++;
  }
  return c==n-1?res:0;
}

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>e[i].a>>e[i].b>>e[i].c;
    e[i].a--,e[i].b--;
  }
  sort(e,e+m);
  int cnt=0,ans=0,mn=cal(-1);
  for(int i=0;i<m;i++)
    if(used[i]&&cal(i)!=mn)ans+=e[i].c,cnt++;
  cout<<cnt<<" "<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {
    public static void debug(String str){
        boolean debug = false;
        if(debug != true){
            return;
        }
        System.out.println(str);
    }
    public static void scanArray(Scanner sc ,int[] array, int num){
        for(int i =0;i<num;i++){
            array[i] = sc.nextInt();
        }
    }
    public static void main(String[] args) {

        String S;

        try (Scanner sc = new Scanner(System.in)) {
            S = sc.next();

        }
        if(S.charAt(0) == S.charAt(1) || S.charAt(1) == S.charAt(2) ||S.charAt(2) == S.charAt(3) ){
            System.out.println("Bad");
        }else{
            System.out.println("Good");
        }


    }


}


Measured memory_bytes: 21972
// #include <bits/stdc++.h>
// using namespace std;
// const int M=110;
// typedef long long ll;
// char s[M];


// dp0[i][j]=dp0[i-1][j]*s[i]+dp[i-1][j-1]+s[]
// int main(int argc, char const *argv[])
// {
// 	scanf("%s",s+1);
// 	int k;cin>>k;
// 	int len=strlen(s+1);
// 	ll ans=0;
// 	if(k==1){
// 		ans=(len-1)*9+s[1]-'0';
// 	}
// 	else if(k==2){
// 		for(int i=1;i<=len;i++){
// 			for(int j=i+1;j<=len;j++){
// 				int aa=s[i]-'0';
// 				int bb=s[j]-'0';
// 				if(i==1)
// 					ans+=(aa-1)*9+bb;
// 				else
// 					ans+=81;
// 			}
// 		}
// 	}
// 	else{
// 		for(int i=1;i<=len;i++){
// 			for(int j=i+1;j<=len;j++){
// 				for(int z=j+1;z<=len;z++){
// 					if(i==1){
// 						int aa=s[i]-'0';
// 						int bb=s[j]-'0';
// 						int cc=s[z]-'0';
// 						ans+=(aa-1)*81+bb*cc;
// 					}
// 					else
// 						ans+=9*9*9;
// 				}
// 			}
// 		}
// 	}
// 	cout<<ans<<endl;
// 	return 0;
// }

#include <bits/stdc++.h>
using namespace std;
const int M=110;
char s[M];
int dp[M][5][3];
int main(int argc, char const *argv[])
{
	scanf("%s",s+1);
	int k;cin>>k;
	int len=strlen(s+1);
	dp[1][0][0]=1;
	dp[0][0][0]=1;
	for(int i=1;i<=len;i++){
		for(int j=0;j<=3;j++){//j个非零数字
			for(int p=0;p<2;p++){//p=0表示一定小于
				int num=s[i]-'0';
				for(int d=0;d<=9;d++){
					int ni=i+1,nj=j,np=p;
					if(d!=0)nj++;
					if(nj>k)continue;
					if(np==0){
						if(d>num)continue;
						if(d<num)np=1;
					}
					dp[ni][nj][np]+=dp[i][j][p];
				}
			}
		}
	}
	cout<<dp[len+1][k][0]+dp[len+1][k][1]<<endl;
	return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N; cin >> N;
  vector<int> A(N); for(int i=0; i<N; i++){ cin >> A[i]; }
  map<int,int> mp; mp[0] = 3;
  ll ans = 1;
  for(int i=0; i<N; i++){
    if(mp[A[i]] == 3){
      mp[A[i]] --; mp[A[i]+1] ++;
      ans = (ans*3)%MOD;
    }else if(mp[A[i]] == 2){
      mp[A[i]] --; mp[A[i]+1] ++;
      ans = (ans*2)%MOD;
    }else if(mp[A[i]] == 1){
      mp[A[i]] --; mp[A[i]+1] ++;
      ans = (ans*1)%MOD;
    }else{
      mp[A[i]] --; mp[A[i]+1] ++;
      ans = (ans*0)%MOD;
    }
  }
  
  cout << ans << endl;

  return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  rep(i,0,n-2){
    if(s.substr(i,3)=="ABC")res++;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
import Data.List
main=do
 [n,m]<-map read.words<$>getLine
 x<-sort.map read.words<$>getLine
 print(g n (f m x))
  where g n l =sum (drop(n-1)(reverse(sort l)))
        f 1 _ =[]
        f m (a:b:x) =(b-a):(f(m-1)(b:x))

Measured memory_bytes: 32892
DBG = !true
n,m = gets.split.map{|z| z.to_i}
a = gets.split.map{|z| z.to_i}

a.reject!{|z| z==6} if a.include?(9)
a.reject!{|z| z==3} if a.include?(5)
a.reject!{|z| z==2} if a.include?(5)
a.reject!{|z| z==2} if a.include?(3)
a.sort!
$a = a
use = [ 0,2,5,5,4,5,6,3,7,6 ]
$use = use
$sortu = a.map{|z| use[z]}.sort
base = $sortu[0]
mass = (n-(base)*(a[-1]))/base
rest = n - mass*base
$ans = Array.new(a.size, 0)
$best = Array.new(a.size, 0)
$best[0] = -1

$a2ssuf = Array.new(10, -1)
for i in 0...a.size
  for j in 0...a.size
    $a2ssuf[a[i]] = j if $sortu[j] == use[a[i]]
  end
end

if DBG
  print a
  print $sortu
  print $a2ssuf
  puts "base #{base} mass #{mass} rest #{rest}"
end

def better(ans, best)
  return true if best[0] == -1
  asum = ans.inject(:+)
  bsum = best.inject(:+)
  return true if asum > bsum
  return false if bsum > asum
  ($a.size-1).downto(0) { |i|
    s = $a2ssuf[$a[i]]
    return true if ans[s] > best[s]
    return false if ans[s] < best[s]
  }
  return false # either ok
end

def srch(i,r)
  sz = $sortu.size
  puts "srch i #{i} r #{r} called sz #{sz}" if DBG
  if i == sz-1
    return if r % $sortu[-1] != 0
    $ans[sz-1] = r / $sortu[-1]
    if better($ans, $best)
      $best = $ans.map{|z|z}
      if DBG
        print $best
        puts "updated best"
      end
    end
  else
    for j in 0..(r/$sortu[i])
      $ans[i] = j
      srch(i+1, r - j*$sortu[i])
    end
  end
end

srch(0,rest)
print $best if DBG
(a.size-1).downto(0) { |i|
  rpt = $best[$a2ssuf[a[i]]] + (use[a[i]] == base ? mass : 0)
  puts "i #{i} ai #{a[i]} asuf #{$a2ssuf[a[i]]} " +
       "use #{use[a[i]]}" if DBG
  rpt.times { print a[i] }
}
puts ""


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
using namespace std;

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  if(op == '+') cout << a+b;
  else cout << a-b;
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {
	string s;
	cin >> s;
	if (s.size()>=4&&s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I')puts("Yes");
	else puts("No");
	ll
}

Measured memory_bytes: 256
main () {
    int a;
    scanf("%d", &a);
    switch(a % 10) {
      case 0:
      case 1:
      case 6:
      case 8:
        puts("pon");
        return 0;
      case 3:
        puts("bon");
        return 0;
      default:
        puts("hon");
    }
}


Measured memory_bytes: 1660
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var a = Array(n+1);
  var b = Array(n+1);
  var c = Array(n+1);
  a[1] = 0;
  b[1] = 1;
  c[1] = 1;
  while(b[1] < k){
    a[1]++;
    b[1] *= 2;
    c[1] /= 2;
  }
  for(var i = 2; i <= n; i++){
    c[i] = c[i-1];
    b[i] = b[i-1];
    a[i] = a[i-1];
    if(b[i] > 1 && b[i] * i / 2 >= k){
      c[i] *= 2;
      b[i] /= 2;
      a[i]--;
    }
  }
  var ans = 0;
  for(var i = 1; i <= n; i++){
    ans += c[i];
  }
  return ans / n;
}

Measured memory_bytes: 15436
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto n = readln.chomp.to!int;
  int odd;
  foreach (i; 1..n+1) {
    if (i% 2) {
      odd++;
    }
  }
  writefln("%.10f", odd / n.to!double);
}


Measured memory_bytes: 256
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>

using namespace std;

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


int main() {
    ll n, k;
    scanf("%lld %lld", &n, &k);
    vector<pll> a(n);
    ll f, s;
    for (int i = 0; i < n; i++) {
        scanf("%lld %lld", &f, &s);
        a[i].second = f; a[i].first = s;
    }
    // 美味しさ降順にソート
    sort(a.begin(), a.end(), greater<pll>());
    ll ans = 0;
    ll sum = 0; // 美味しさ sum
    ll kind = 0; // 何種類食べたか
    // 降順に並べるpriority queue
    priority_queue<ll, vector<ll>, greater<ll> > PQ;
    stack<ll> St;
    // 食べた種類を格納する
    set<ll> S;
    
    for (int i = 0; i < k; i++) {
        sum += a[i].first;
        if (S.count(a[i].second) == 0) {
            kind++;
            S.insert(a[i].second);
        }
        else {
            St.push(a[i].first);
        }
    }

    ans = sum + kind * kind;

    // 美味しさがk番目に大きいやつ以降を調べる
    for (ll i = k; i < n; i++) {
        if (St.empty()) break;
        // i 番目のやつがまだ食べてない種類なら
        if (S.count(a[i].second) == 0) {
            kind++;
            sum -= St.top(); St.pop();
            sum += a[i].first;
            S.insert(a[i].second);
            ans = max(ans, sum + kind * kind);
        }
    }

    printf("%lld\n", ans);
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
  int n;
  while(cin>>n,n){
    string s;cin>>s;
    vector<int> cnt(n);
    int tmp=0;
    for(int i=0;i<s.size();++i){
      if(s[i]=='M'){
        ++cnt[i%n];
      }else if(s[i]=='L'){
        cnt[i%n]+=tmp+1;
        tmp=0;
      }else if(s[i]=='S'){
        tmp+=cnt[i%n]+1;
        cnt[i%n]=0;
      }
    }
    sort(cnt.begin(), cnt.end());
    for(int i=0;i<n;++i) cout<<cnt[i]<<" ";
    cout<<tmp<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
// AtCoder Beginner Contest 088 - Problem A: Infinite Coins (https://abc088.contest.atcoder.jp/tasks/abc088_a?lang=en) 
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, A;
    cin >> N >> A;

    int r = N % 500;

    cout << (r <= A ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
// AtCoder Beginner Contest - Problem C: ID (https://beta.atcoder.jp/contests/abc113/tasks/abc113_c)
#include <bits/stdc++.h>

using namespace std;
using city = tuple<int, int, int>;

#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)

const int MAX { 2000010 };

city cities[MAX];
char ids[MAX][16];

void solve(int M)
{
    sort(cities, cities + M);

    int last = 0, pos = 0;

    REPN(i, M)
    {
        int p, y, n;
        tie(p, y, n) = cities[i];

        p == last ? pos++ : pos = 1;

        sprintf(ids[n], "%06d%06d", p, pos);
        last = p;
    }

    REPN(i, M)
        cout << ids[i] << '\n';
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    REPN(i, M)
    {
        int P, Y;
        cin >> P >> Y;

        cities[i] = city(P, Y, i);        
    }

    solve(M);

    return 0;
}


Measured memory_bytes: 5120
/****************************************************************************
 \file      ITP1_1_C.c
 \author    SENOO, Ken
 \copyright CC0
 \date      created date: 2016-03-05T16:07+09:00
 \date      updated date: 2016-03-05T16:08+09:00
 ****************************************************************************/

#include <stdio.h>

int main(){
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d %d\n", a*b, 2*(a+b));
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 55
using namespace std;
int n,d,x[N][N];
int pf(int y){
	return y*y;
}
bool ispf(int y){
	int sq=sqrt(y);
	return sq*sq==y;
}
bool pd(int i,int j){
	int res=0;
	for(int k=1;k<=d;k++)
		res+=pf(x[i][k]-x[j][k]);
	return ispf(res);
}
int main(){
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			scanf("%d",&x[i][j]);
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(pd(i,j)) ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
/**
 *       Author:  kulubat
 *       Written on Thursday, 16 April 2020.
 **/

#include <bits/stdc++.h>


using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    
    int n;

    cin >> n;


    cout << n*(n+1)/2 << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N; cin >> N;
	int F[101][11],P[101][11];
	long long ans = -1e11;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++)cin >> F[i][j];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++)cin >> P[i][j];
	}
	for (int i = 1; i < (1<<10); i++) {
		int x[101] = { 0 };
		long long z = 0;
		for (int j = 0; j < 10; j++) {
			if ((i >> j) & 1) {
				for (int k = 0; k < N; k++)x[k] += F[k][j];
			}
		}
		for (int k = 0; k < N; k++)z += P[k][x[k]];
		ans = max(ans, z);
	}
	cout << ans << endl;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr int INF=125252;
ll num[125252];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, q;
  ll a[125252], b, c;
  cin>>n;
  ll ans=0;
  REP(i, n){
    cin>>a[i];
    ans+=a[i];
    ++num[a[i]];
  }
  cin>>q;
  while(q--){
    cin>>b>>c;
    ll tmp=num[b];
    num[b]=0;
    ans-=b*tmp;
    num[c]+=tmp;
    ans+=c*tmp;
    cout<<ans<<'\n';
  }
  return 0;
}


Measured memory_bytes: 5224
# https://atcoder.jp/contests/abc065/tasks/abc065_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    X, A, B = map(int, input().split())
    if B <= A:
        print('delicious')
        exit()
    if B <= A + X:
        print('safe')
        exit()
    print('dangerous')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

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

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
inline T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
inline T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}


/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s;
	scans(s);
	s += (s.back() == 's' ? "es" : "s");
	prints(s);

	Please AC;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * 10 2 5 8 3 1
 * 10 12 17 25 28 29
 * 28 - 25 >= k*1 -> 28 >= 25 + k*1
 * 28 - 17 >= k*2 -> 28 >= 17 + k*2
 * 28 - 12 >= k*3
 * 28 - 10 >= k*4
 * 10, 12 - k, 17 - 2*k, 25 - 3*k
 */
const int N = 200 * 1000 + 5;
vector <int> tree(N);
void update(int id, int val) {
	while(id < N) {
		tree[id] += val;
		id += (id & -id);
	}
}
int getsum(int id) {
	int res = 0;
	while(id > 0) {
		res += tree[id];
		id -= (id & -id);
	}
	return res;
}
int main() {
	int n, k;
	cin >> n >> k;
	vector <ll> pre(n + 1);
	map <ll, int> mp;
	mp[0];
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		pre[i] = pre[i - 1] + x;
	}
	for (int i = 1; i <= n; i++) {
		pre[i] = pre[i] - 1LL*i*k;
		mp[pre[i]];
	}
	int x = 0;
	for (auto g : mp) {
		mp[g.ff] = ++x;
	}
	update(mp[0], 1);
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		pre[i] = mp[pre[i]];
		ans += getsum((int)pre[i]);
		update((int)pre[i], 1);
	}
	cout << ans;
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
#define int long long

signed main() {
    int c[3][3];
    rep(i,3)rep(j,3) cin >> c[i][j];
    
    bool ans = true;
    
    int prev = -1;
    rep(i,3){
        int sum = 0;
        rep(j,3) sum += c[i][j];
        if(prev == -1) prev = sum % 3;
        if(prev != sum % 3) ans = false;
    }
    
    prev = -1;
    rep(i,3){
        int sum = 0;
        rep(j,3) sum += c[j][i];
        if(prev == -1) prev = sum % 3;
        if(prev != sum % 3) ans = false;
    }
    
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 10005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll N,X,D;
vi xs, diff;
int dmax = 0, dmin = INF; 

int GCM(int a, int b){
    if(b==0) return a;

    return GCM(b, a % b);
}

void solve(){
    sort(xs.begin(),xs.end());

    rep(i,N){
        diff[i] = xs[i+1] - xs[i];
    }

    if(N == 1)
        D = diff[0];
    else{
        D = GCM(diff[0], diff[1]);
        rep(i,N-2)
            D = GCM(D, diff[i+2]);
    }

    cout << D << endl;
}

int main(){
    cin >> N >> X;
    xs.resize(N+1);
    diff.resize(N);

    rep(i,N){
        cin >> xs[i];
    }
    xs[N] = X;

    solve();
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,x,y;
int a,b,c,d,i,j,k;
cin>>s;
x+=s[0];x+=s[1];
 y+=s[2];y+=s[3];
stringstream ab(x);
  ab>>a;
 stringstream aa(y);
  aa>>b;
  if(a<=12&&a>0&&b<=12&&b>0)
  cout<<"AMBIGUOUS\n";
  else if(a<=12&&a>0)
  {
  cout<<"MMYY\n";
  }
    else if(b<=12&&b>0)
  cout<<"YYMM\n";
else cout<<"NA\n";

}

Measured memory_bytes: 256
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

// Author:: Subash Singha Roy
// Institution:: Jalpaiguri Government Engineering College

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) int t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf 999999999999999999
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}


int main(){
    fio;
    ll n,k;
    cin>>n>>k;
    ll dp[k+5]={0};
    dp[0]=0;
    ll a[n+5];
    fr(i,0,n){
        cin>>a[i];
    }
    fr(i,1,k+1){
        fr(j,0,n){
            if(i>=a[j] &&  dp[i-a[j]]==0){
                dp[i]=1;
            }
        }
        // cout<<dp[i]<<" ";
    }
    if(dp[k]){
        // cout<<dp[k]<<" ";
        cout<<"First\n";
    }
    else{
        cout<<"Second\n";
    }
    rr;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<ll>> a(n, vector<ll>(n));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    vector<ll> dp((1 << n), -LLINF);
    dp[0] = 0;
    for(int S = 0; S < (1 << n); S++) {
        ll tmp = 0;
        for(int i = 0; i < n; i++) {
            if(S & (1 << i)) {
                for(int j = i + 1; j < n; j++) {
                    if(S & (1 << j)) {
                        tmp += a[i][j];
                    }
                }
            }
        }
        dp[S] = tmp;
        for(int T = (S - 1) & S; T > 0; T = (T - 1) & S) {
            chmax(dp[S], dp[T] + dp[S ^ T]);
        }
    }
    print(dp[(1 << n) - 1]);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

template <class T>
class bsegment_tree {
   public:
    ll size;
    vector<T> data;
    T default_value;

    bsegment_tree(ll n, T default_value_) {
        default_value = default_value_;

        ll siz = 1;
        while (siz < n) {
            siz = siz * 2;
        }
        data.resize(siz * 2, default_value);
        size = siz;
    }

    ~bsegment_tree() {}

    T compare(T& a, T& b) {
        //  ここをカスタム ex) min
        //return min(a, b);
        //return min(a, b);
        return max(a, b);
    }

    void update(ll k, T value) {
        // 葉の節点
        k += size - 1;
        data[k] = value;

        while (k > 0) {
            // 順に親に向かっていく
            k = (k - 1) / 2;
            data[k] = compare(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }

    // [a, b) で compare 最強のもの
    T query_open(ll a, ll b, ll k, ll l, ll r) {
        if (r <= a || b <= l) {  // 共通要素がない
            return default_value;
        }
        if (a <= l && r <= b) {  // 完全に含んでいる
            return data[k];
        }

        // 2つの子の compare で勝つほう
        T vl = query_open(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query_open(a, b, k * 2 + 2, (l + r) / 2, r);
        return compare(vl, vr);
    }

    // [a, b] で compare 最強のもの
    T query(ll a, ll b) {
        return query_open(a, b + 1, 0, 0, size);
    }
};
using segment_tree = bsegment_tree<ll>;
using pll = pair<ll, ll>;
int main() {
    ll N, K;
    cin >> N >> K;
    vector<pll> va(N);
    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        ll v;
        cin >> v;
        va[i] = {v, i};
        a[i] = v;
    }

    sort(va.begin(), va.end());

    auto st = segment_tree(N, 0);
    vector<ll> stindex(N, 0);
    for (ll i = 0; i < N; i++) {
        stindex[va[i].second] = i;
    }

    vector<ll> dp(N, 0);
    ll maxlen = 0;
    for (ll i = N - 1; i >= 0; i--) {
        ll v = a[i];
        ll left = lower_bound(va.begin(), va.end(), (pll){v - K, -1}) - va.begin();
        ll right = lower_bound(va.begin(), va.end(), (pll){v + K, 300002}) - va.begin() - 1;
        dp[i] = 1 + st.query(left, right);
        maxlen = max(dp[i], maxlen);
        st.update(stindex[i], dp[i]);
    }
    print(maxlen);
}


Measured memory_bytes: 23312
#include <iostream>

 

using namespace std;

 

int main()
{
   int a, b, ans1, ans2;
   cin >> a >> b;
   ans1=a*b;
   ans2=2*a+2*b;
   cout << ans1 << " " << ans2 << endl; 
   
   return 0;
}


Measured memory_bytes: 3068
object Main extends App {
  import scala.io.StdIn._


  val edges = Array.tabulate(3){_ ⇒
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt)
    (a, b)
  }
  val count = (1 to 4).map(i ⇒ edges.count(it ⇒ it._1 == i || it._2 == i))
  println(
    if (count.count(_ == 2) == 2 && count.count(_ == 1) == 2) "YES"
    else "NO"
  )
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}

Measured memory_bytes: 25412
// V solo
#include <bits/stdc++.h>

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)2e5 + 7;
const long long INF = 1e18;

typedef long long ll;
typedef long double ld;

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

int n, a[N];
set < int > s;

ll ok (int x){
  ll sum = 0;
  forn (i, 1, n){
    sum += ((a[i] - x) * (a[i] - x));
  }
  return sum;
}

int main (){
  scanf ("%d", &n);
  forn (i, 1, n) scanf ("%d", a + i), s.insert(a[i]);
  if (s.size() == 1) return printf ("0\n"), 0;
  int l = -10000, r = 10000;
  while (r - l > 1){
    int mid = l + r >> 1;
    if (ok(mid) > ok(mid + 1)){
      l = mid;
    } else {
      r = mid;
    }
  }
  printf ("%lld\n", min(ok(l), ok(r)));
  return 0;
}


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

#define INF 1E18



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

    int m = max({a,b,c});
    if(m%2 == (a+b+c)%2) cout << (3*m -(a+b+c))/2 <<endl;
    else cout << (3*(m+1) -(a+b+c))/2 <<endl;

    return 0;
}


Measured memory_bytes: 3636
// Grouping 2

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n;

int main() {
    cin >> n;
    cout << n / 3 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	m := f(n)
	for i := 1; i <= n; i++ {
		fmt.Println(m[i])
	}
}

func f(n int) map[int]int {
	m := map[int]int{}
	for x := 1; x*x <= n; x++ {
		for y := 1; y*y <= n; y++ {
			for z := 1; z*z <= n; z++ {
				a := (x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x)
				if a%2 == 0 {
					m[a/2]++
				}
			}
		}
	}
	return m
}


Measured memory_bytes: 4680
#include<stdio.h>
int y[2][2];
int f(int t){
  int i,max=0,min=1,r;
  for(i=0;i<4;i++){
    if(y[t][i/2]>4||y[1-t][i%2]>4)continue;
    y[1-t][i%2]+=y[t][i/2];
    if(y[1-t][0]>4&&y[1-t][1]>4){
      y[1-t][i%2]-=y[t][i/2];
      return t;
    }
    else {
      r=f(1-t);
      if(t){
	if(r)max=r;
      }
      else{
	if(r==0)min=r;
      }
      y[1-t][i%2]-=y[t][i/2];
    }
  }
  if(t)return max;
  else return min;
}
int main(){
  int i;
  for(i=0;i<4;i++)scanf("%d",&y[i/2][i%2]);
  if(f(0))printf("NAKAJIMA\n");
  else printf("ISONO\n");
  return 0;
}

Measured memory_bytes: 580
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
dic = collections.defaultdict(int)
for i in range(1, n + 1):
    s = str(i)
    a = s[0]
    b = s[-1]
    if b != '0':
        dic[(a, b)] += 1
res = 0
for i in range(1, 10):
    for j in range(1, 10):
        i = str(i)
        j = str(j)
        res += dic[(i, j)] * dic[(j, i)]
print(res)

Measured memory_bytes: 3316
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int A, B;
  char op;
  cin >> A >> op >> B;
  cout << (op == '+' ? A + B : A - B) << endl;
  return 0;
}

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


using namespace std;
 
int main(){
  
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  

  for(int i = 0; i < N; i++){
      if(a[i] % 2 == 0){
          if(a[i] % 5 != 0 && a[i] % 3 != 0){
              cout << "DENIED";
              return 0;
          }
      }
  }

  cout << "APPROVED";




    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<numeric>
#include<math.h>


int main() {
	int n,s;
	cin >> n;
	vector<int>x(n);
	rep(i, n) {
		cin >> x[i];
	}
	double m;
	s = accumulate(x.begin(), x.end(), 0);
	m = double(s) / double(n);
	double amari;
	amari = fmod(m, 1);
	int mm;
	mm = s / n;
	if (amari >= 0.5) {
		mm += 1;
	}
	int sum(0);
	//cout << amari<<m<<mm << endl;
	rep(i, n) {
		int t;
		t = (x[i] - mm) * (x[i] - mm);
		sum += t;
	}
	cout << sum;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int m,int n){
  while(m != n){
    if (m > n)
      m = m - n;
    else
      n = n - m;
  }
  return m;
}

int lcm(int m,int n){
  return m/gcd(m,n)*n;
}

int main(){
  int a,b;
  while(cin>>a>>b){
    cout << gcd(a,b) <<" "<<lcm(a,b)<<endl;
  }
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = sum(A)

for i in range(N):
    n = min(A[i], B[i])
    A[i] -= n
    B[i] -= n
    
    if B[i] > 0: A[i+1] = max(0, A[i+1]-B[i])

print(ans - sum(A))

Measured memory_bytes: 18476
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String[][] s = new String[100][100];
		for(int i = 0; i < 100; i++) {
			for(int j = 0; j < 100; j++) {
				if(i < 50) {
					s[i][j] = ".";
				} else {
					s[i][j] = "#";
				}
			}
		}
		a--;
		b--;
		int i = 0;
		int j = 0;
		while(b > 0) {
			s[i][j] = "#";
			b--;
			j += 2;
			if(j >= 100) {
				j = 0;
				i += 2;
			}
		}
		i = 99;
		j = 0;
		while(a > 0) {
			s[i][j] = ".";
			a--;
			j += 2;
			if(j >= 100) {
				j = 0;
				i -= 2;
			}
		}
		System.out.println(100 + " " + 100);
		for(int k = 0; k < 100; k++) {
			for(int l = 0; l < 100; l++) {
				System.out.print(s[k][l]);
			}
			System.out.println();
		}

	}

}


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

template <typename T>
void print(const T &v);

int main()
{
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3596