akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	vector<int> v(26, 0);
	for( char c : s ){
		++v[c-'a'];
	}
	for( int i = 0; i < (n-1); ++i ){
		vector<int> w(26, 0);
		string t; cin >> t;
		for( char c : t ){
			++w[c-'a'];
		}
		for( int j = 0; j < 26; ++j ){
			if( v[j] > w[j] ) v[j] = w[j];
		}
	}
	string ans = "";
	for( int i = 0; i < 26; ++i ){
		for( int j = 0; j < v[i]; ++j ){
			ans += char('a'+i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func calc(a, b int) int {
	result := a + b
	return result
}

func main() {
	var N, A, B int
	fmt.Scan(&N)
	if N == 1 {
		fmt.Println("Hello World")
	} else {
		fmt.Scan(&A, &B)
		fmt.Println(calc(A, B))
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){

  string s;
  cin >> s;
  int ans = 700;
  for(int i = 0; i < 3; ++i){
    if(s[i] == 'o') ans+=100;
  }

  cout << ans << endl;
}


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

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  std::string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    std::cin >> com;
    if (com == "insert") {
      scanf("%d", &x);
      insert(x);
    } else if (com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



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

using namespace std;

int main() {
	int n;
	cin >> n;
	int tmp = n;
	int sum = 0;
	while (n>0) {
		sum += n % 10;
		n /= 10;
	}
	
	if (tmp%sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/local/bin/ruby
n=gets.to_i
rec=Array.new
ans=Array.new
n.times{
   rec=gets.split(" ").map(&:to_i)
   rec.sort!{|a,b| a <=> b}
   x,y,z=rec[0],rec[1],rec[2]
   a=x*x+y*y
   b=z*z
   if a==b
   puts"YES"
   else
      puts"NO"
   end
}

Measured memory_bytes: 6112
#include<iostream>
#include<string>

using namespace std;


int main() {
	int N;
	char S[110];
	cin >> N >> S;

	int count = 0;
	int x = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'I')
			count++;
		else
			count--;
		if (count > x)
			x = count;
		}

	cout << x << endl;
}

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


int main(){
  int n,x; cin>>n>>x;
  vector<int> d(n+1);
  int ans=0;
 
 
  for(int i=0;i<n+1;i++){
     int l;
    cin>>l;
    d[i+1]=d[i]+l;

    if(d[i]<=x)ans++;
  }
   cout<<ans<<endl;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int n;
	int ts = 0, hs = 0;
	char t[110], h[110];
	cin >> n;
	rep(i,n) {
		cin >> t >> h;
		if(strcmp(t, h) > 0) ts += 3;
		else if(strcmp(t, h) < 0) hs += 3;
		else ts += 1, hs += 1;
	}
	cout << ts << " " << hs << endl;
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<unsigned long long int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    unsigned long long int hoge=0;
    for(int geho=0;geho<n-k;geho++){
        hoge+=h[geho];
    }
    cout<<hoge<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int a=0,b=0,c;
  scanf("%d",&c);if(c==5)a++;if(c==7)b++;
  scanf("%d",&c);if(c==5)a++;if(c==7)b++;
  scanf("%d",&c);if(c==5)a++;if(c==7)b++;
  if(a==2&&b==1){printf("YES");return 0;}
  printf("NO");
return 0;
  
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	string p;
	cin >> p;
	bool f = 0;
	int t = 0;
	string x="AKIHABARA";
	for (int i = 0; i < p.size(); i++) {
		if (x[t] != p[i]) {
			if (x[t] == 'A') {
				t++; i--; continue;
			}
			else {
				cout << "NO" << endl;
				return 0;
			}
		}
		t++;
	}
//	if (x != "KIHBR")f = 1;
	
	

	if(t>=8)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;


}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


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

    for(int i = 1; i <= n; i++){
        int ans = 0;
        for(int j = 1; j * j <= i; j++){
            for(int k = 1; k * k <= i; k++){
                for(int l = 1; l * l <= i; l++){
                    int sum = j * j + k * k + l * l + j * k + k * l + l * j;
                    if(sum > i) break;
                    if(sum == i) ans++;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int x, y;
  cin >> x >> y;

  if (y%2 != 0 || y < x * 2 || y > x * 4) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 3632
#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.at(i);
sort(a.begin(),a.end());
int ans =1;
int che =a.at(0);
for(int i=1;i<n;i++){
    if(che!=a.at(i)){
        che=a.at(i);
        ans++;
    }
}
cout << ans << endl;
 }



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

int main()
{
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  if(N%2 != 0){
    cout << "No" << endl;
    return 0;
  }
  
  int N2 = N/2;
  for(int i=0; i<N2; i++){
    if(S[i] != S[i+N2]){
      cout << "No" << endl;
    	return 0;
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

char C[200001];

signed main()
{
    int N;
    cin >> N;
    cin >> C;

    int len = strlen(C);
    int r_cnt = 0;

    REP(i, len)
    {
        if (C[i] == 'R')
        {
            r_cnt++;
        }
    }

    int ans = 0;
    for (int i = 0; i < r_cnt; i++)
    {
        if (C[i] == 'W')
        {
            ans++;
        }
    }
    cout << ans << endl;
}

 

Measured memory_bytes: 3380
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))

x = 0
y = 0
z = 0
for i in range(n):
    if (p[i]<=a):
        x += 1
    elif (a+1 <= p[i]<= b):
        y += 1
    else:
        z += 1

print(min(x,y,z))


Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <functional>
using namespace std;
int arr[110];
bool f(int a, int b){
return a>b ;}
int main(){
    int a,b=0,i;
    scanf("%d",&a);
    for(i=1;i<=a;i++){
        scanf("%d",&arr[i]);
    }
    sort(arr+1,arr+1+a,f);
    for(i=1;i<=a;i++) b += (i%2==0 ? -1 * arr[i] :arr[i]);
    printf("%d",b);

}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    void Calc()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        if (a < b && b < c)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    static void Main()
    {
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

Measured memory_bytes: 5304
#include <stdio.h>
int main(void)
{
	int a,b,c,d,x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	printf("%d\n",(a+b+c+d)/60);
	printf("%d\n",(a+b+c+d)%60);
	return 0;
}

Measured memory_bytes: 1744
w = []
c = int(raw_input())
for i in xrange(c):
    hatugen = raw_input()
    w.append(hatugen)
last = ''
first = ''
ruled = True
if len(set(w)) != len(w):
    ruled = False
for i in w:
    if i == w[0]:
        last = i[-1]
    else:
        first = i[0]
        if first == last:
            pass
        else:
            ruled = False
        last = i[-1]
print('Yes' if ruled else 'No')

Measured memory_bytes: 2820
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int x, y;
    
    while (cin>>x>>y, x||y){
        if (x < y){
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=20;
i64 d,e[maxn],ans;
inline i64 solve(int l,int r,i64 d){
	if(l>=r&&d)return 0;
	if(l==r)return 10-(l==0);
	if(l==r+1)return 1;
	int t=(10-d%10)%10;
	return (10-(l==0)-t)*solve(l+1,r-1,abs(d-t*(e[r-l]-1))/10);
}
int main(){
	e[0]=1;
	rep(i,1,17)e[i]=10ll*e[i-1];
	cin>>d;
	rep(i,0,17)ans+=solve(0,i,d);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a > b && b != 1)
    {
        cout << "Alice";
    }
    else if(a > b && b == 1)
    {
        cout << "Bob";
    }
    else if(a < b && a != 1)
    {
        cout << "Bob";
    }
    else if(a < b && a == 1)
    {
        cout << "Alice";
    }
    else
    {
        cout << "Draw";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    string s;
    cin >> s;
    vector<bool> check(26, false);
    rep(i, s.size()) {
        if (check[(ll)(s[i] - 'a')] == true) {
            cout << "no\n";
            return 0;
        } else {
            check[(ll)(s[i] - 'a')] = true;
        }
    }

    cout << "yes\n";
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
using ll = int;

int main(){
  ll n,m,q;
  cin >> n >> m >> q;
  ll a[100],b[100],c[100],d[100];
  for(ll i=0;i<q;i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  ll x[11];  
  ll ans = 0;
  for(x[10]=1;x[10]<=m;x[10]++){
    for(x[9]=1;x[9]<=x[10];x[9]++)
      for(x[8]=1;x[8]<=x[9];x[8]++)
        for(x[7]=1;x[7]<=x[8];x[7]++)
        for(x[6]=1;x[6]<=x[7];x[6]++)
        for(x[5]=1;x[5]<=x[6];x[5]++)
        for(x[4]=1;x[4]<=x[5];x[4]++)
        for(x[3]=1;x[3]<=x[4];x[3]++)
        for(x[2]=1;x[2]<=x[3];x[2]++)
        for(x[1]=1;x[1]<=x[2];x[1]++){
          ll temp = 0;
          for(ll i=0;i<q;i++){
            if(x[b[i]]==(c[i]+x[a[i]])) temp+=d[i];
          }
          ans = max(temp,ans);
        }
  }
  cout << ans;
}

Measured memory_bytes: 3644
function main(input){
  const temp=input.split('\n');
  const arr=temp[0].split(" ");
  const N=arr[0];
  const K=arr[1];
  var S=temp[1];
  if(K>1){
    console.log(S.slice(0,K-1)+S.substr(K-1,1).toLowerCase()+S.slice(K,N));
  }else{
    console.log(S.substr(K-1,1).toLowerCase()+S.slice(K,N));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
function Main(input) {
	var n = parseInt(input, 10);
	var results = [];
	for (var i = 1; i <= n; i++) {
		if (i % 2 != 0) {
			results.push(i);
		}
	}
	console.log(results.length / n);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int N=2999;
int n;
double a[N+1];
double dp[N+1][N+1];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	dp[0][0]=1.;
	for(int i=1;i<=n;i++)for(int j=0;j<=n;j++){
		dp[i][j]=(1.-a[i])*dp[i-1][j];
		if(j)dp[i][j]+=a[i]*dp[i-1][j-1];
	}
	double ans=.0;
	for(int i=n/2+1;i<=n;i++)ans+=dp[n][i];
	printf("%.100lf",ans);
	return 0;
}
/*1
3
0.30 0.60 0.80
*/
/*2
1
0.50
*/
/*3
5
0.42 0.01 0.42 0.99 0.42
*/

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1e5+5;
int32_t main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<"No\n";
    }else if(n&1){
        cout<<"Yes\n";
        for(int i=2;i<=n;i+=2)cout<<"1 "<<i<<'\n';
        for(int i=2;i<=n;i+=2)cout<<i<<' '<<i+n+1<<'\n';
        for(int i=3;i<=n;i+=2)cout<<"1 "<<i<<'\n';
        for(int i=3;i<=n;i+=2)cout<<i<<' '<<i+n-1<<'\n';
        cout<<3+n<<' '<<1+n<<'\n';
    }else{
        int ok=0;
        for(int x=1;!ok&&x<n;++x){
            int y=(n+1)^x;
            if(y>=1&&y<n){
                ok=1;
                cout<<"Yes\n";
                cout<<x<<' '<<n<<'\n';
                cout<<y<<' '<<n+n<<'\n';
            }
        }
        if(!ok)cout<<"No\n";
        else{
            for(int i=2;i<=n-1;i+=2)cout<<"1 "<<i<<'\n';
            for(int i=2;i<=n-1;i+=2)cout<<i<<' '<<i+n+1<<'\n';
            for(int i=3;i<=n-1;i+=2)cout<<"1 "<<i<<'\n';
            for(int i=3;i<=n-1;i+=2)cout<<i<<' '<<i+n-1<<'\n';
            cout<<3+n<<' '<<1+n<<'\n';
        }
    }

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  
  return 0;
    

}


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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

void dfs(string s, char mx, ll N)
{
    if (s.length() == N)
    {
        cout << s.c_str() << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
        }
    }
}

int bfs(int a, int b, int h, int w, char tmp[][101])
{
    int ans[101][101] = {0};
    char c[101][101] = {0};
    queue<pair<int, int>> s;

    for (int i = 0; i <= h; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            c[i][j] = tmp[i][j];
        }
    }

    s.push(make_pair(a, b));

    while (s.size() > 0)
    {

        pair<int, int> tmp = s.front();
        s.pop();
        c[tmp.first][tmp.second] = '#';
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (tmp.first + i < 1 || tmp.first + i > h)
                {
                    continue;
                }
                if (tmp.second + j < 1 || tmp.second + j > w)
                {
                    continue;
                }
                if (i != 0 && j != 0)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    continue;
                }
                if (c[tmp.first + i][tmp.second + j] == '#')
                {
                    continue;
                }
                c[tmp.first + i][tmp.second + j] = '#';
                if (ans[tmp.first + i][tmp.second + j] == 0)
                {
                    ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
                }
                else
                {
                    ans[tmp.first + i][tmp.second + j] = min(ans[tmp.first + i][tmp.second + j], ans[tmp.first][tmp.second] + 1);
                }
                s.push(make_pair(tmp.first + i, tmp.second + j));
            }
        }
    }

    int asd = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            asd = max(a, ans[i][j]);
        }
    }

    return asd;
}

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int main()
{
    ll x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish = [a, b, c, d, e]
dishp = list(itertools.permutations(dish, 5))
t = []
x = 0
for i in range(0,120):
    x = 0
    for j in range(0,4):
        if dishp[i][j] %10 == 0:
            x += dishp[i][j]
        else:
            x += (dishp[i][j] // 10 +1) * 10
    x += dishp[i][4]
    t.append(x)
print(min(t))


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  string t = "CODEFESTIVAL2016";
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
/*
Codeforces Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

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

    int a, b;
    cin >> a >> b;

    if(a * b % 2 == 0){
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
<?php

$ans = "A";

while($item = fgets(STDIN)){
    $item = trim($item);
    $array = split(",",$item);
    if ($array[0]==$ans) {
        $ans = $array[1];
    } else if ($array[1]==$ans) {
        $ans = $array[0];
    }
}

echo $ans ."\n";

Measured memory_bytes: 15400
import java.util.Scanner;
 
class Main {
	public static void main(String[] args) {
 
	    Scanner sc = new Scanner(System.in);
	    
	    double A = sc.nextDouble(); // 辺
	    double B = sc.nextDouble(); // 辺
	    double H = sc.nextDouble(); // 時
	    double M = sc.nextDouble(); // 分
	    
	    // 角度
	    double cosC = 0;
	    double h = (H * 30) + (M * 0.5);
	    double s = M * 6;
	    if (h > s) { cosC = h - s; } else if (h < s) { cosC = s - h; }
	    
	    // 残りの辺の長さ C2 = A2 + B2 - 2ABcosC
	    double C = Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(cosC)));

	    System.out.println(C);
	    
	  }
}

Measured memory_bytes: 28880
function main(arg) {
	arg = arg.trim().split('\n');
  	var data = arg.shift().split(' ').map(str => parseInt(str, 10)),
        //参加者、ポイント、回答数
      	n = data[0], k = data[1], q = data[2],
        //正解者、pt数
        arg = arg.map(str => parseInt(str, 10)), pt = new Array(n).fill(0);
    //加点処理
  	for (var i = 0; i < q; i++) {
      pt[arg[i]-1] +=1
    }
  	//減点処理
  	for (var i = 0; i < n; i++) {
    	 pt[i] = pt[i]-(q-k);
    }
  	//1pt以上を判定
  	for (var i = 0; i < n; i++) {
    	pt[i] = (pt[i] > 0) ? 'Yes' : 'No';
    }
  	var out = pt.join('\n');
  console.log(out);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 27584
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] button = new int[n];
        for (int i = 0; i < n; i++) {
            button[i] = sc.nextInt();
        }

        int next = 1;
        boolean can = false;
        Set<Integer> pushed = new HashSet<>();
        while (true) {
            next = button[next - 1];
            if (pushed.contains(next)) {
                break;
            }

            if (next == 2) {
                can = true;
                break;
            }

            pushed.add(next);
        }

        if (can) {
            System.out.println(pushed.size() + 1);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 52540
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        b: chars,
    );
    println!("{}", match b[0] {
        'A' => {'T'},
        'C' => {'G'},
        'G' => {'C'},
        'T' => {'A'},
        _ => {'A'},
    });
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		System.out.println(n % k == 0 ? 0 : 1);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 35808
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

ll cum[N], ans;

ll add(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (a + b) % mod;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    for(ll i = 1; i < N; i++){
        cum[i] = cum[i - 1] + i;
    }

    for(int i = k - 1; i <= n; i++){
        ll mn = cum[i], mx = cum[n] - cum[n - i - 1];
        ans = add(ans, mx - mn + 1);
        // cout << mx << ' ' << mn  << '\n';
    }
    cout << ans;
    return 0;

}




Measured memory_bytes: 5208
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


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

  int num = pow(2, M);

  if (M == 1){
    if (K == 0){
      cout << "0 0 1 1" << endl;
    }else{
      cout << -1 << endl;
    }
  }else{
    if (K < num){
      if (K == 0){
        for (int i = 0; i < 2 * num; i++){
          cout << i / 2;
          if (i != 2 * num - 1) cout << " ";
        }
        cout << endl;
      }else{
        cout << "0 " << K << " 0 ";
        for (int i = 1; i < num; i++){
          if (i != K){
            cout << i << " ";
          }
        }
        cout << K;
        for (int i = num - 1; i >= 1; i--){
          if (i != K){
            cout << " " << i;
          }
        }
        cout << endl;
        
      }
    }else{
      cout << -1 << endl;
    }
  }
    
  
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
const double pi = 3.14159265359;
int main(void)
{
	double r;
	scanf("%lf", &r);
	printf("%.6lf %.6lf\n", pi * r * r, 2 * pi * r);
	return 0;
	
	
	
	
	
} 


Measured memory_bytes: 2692
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
 
int main(){
    int A;
    int count_1 = 0;
    int count_2 = 0;
    int B;
    cin >> A;
    for(int i = 1; i <= A; i++){ 
        count_1 = 9;
        B = i;
        while(true){
            if(B/10 > 0){
                B = B/10;
                count_1++;
            }
            else {
                B = B/10;
                break;
            }
        }
        if((count_1 % 2) == 1){
            count_2++;
        }
    }
    cout << count_2 << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
#define BUF_SIZE 1024
#define ARRAY_SIZE 100
 
int main(){
 
    char buf[BUF_SIZE];
    int n = atoi(fgets(buf,BUF_SIZE,stdin));
    int array[ARRAY_SIZE];
    int change_count = 0;
 
    for(int i = 0; i < n; i++){
        cin >> array[i];
    }
 
    int tmp = 0;
    for(int i = n-1;i > 0;i--){
        for(int j = 0; j < i;j++){
            if(array[j] > array[j+1]){
                tmp = array[j+1];
                array[j+1] = array[j];
                array[j] = tmp;
                change_count++;
            }
        }
    }
 
    for(int i = 0; i < n; i++){
        if(i != n-1){
            printf("%d ",array[i]);
        }else{
            printf("%d\n",array[i]);
        }
    }
    printf("%d\n",change_count);
}


Measured memory_bytes: 3148
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;


int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  s[200][200];
	string str;
	//cout << fixed << setprecision(10);
	long long int n, m, k, p, q, r, a[200005], sum[200005] = {}, dpz[200005] = {}, dpo[200005] = {}, res = 999999999;
	cin >>str;
	n = str.length();
	dpz[0] = 1;
	dpo[0] = 2;
	for (int i = 1; i < n; i++) {
		
		if (str[i] == '1') {
			dpz[i] = 3 * dpz[i-1]+dpo[i-1];
			dpo[i] = 2 * dpo[i - 1];
		}
		else {
			dpo[i] = dpo[i - 1];
			dpz[i] = 3 * dpz[i - 1] ;
		}
		dpz[i] %= mod;
		dpo[i] %= mod;
	}
	cout << (dpz[n - 1] + dpo[n - 1]) % mod;
}


Measured memory_bytes: 3584
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        double cur_p = 1.0 / (n * 1.0);
        int st = i;
        int cnt = 0;
        while(st < k){
            st += st;
            cnt++;
        }
        double d = powl(0.5, cnt);
        cur_p *= d;
        ans += cur_p;
    }
    cout << fixed << setprecision(20) << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;//<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



int main() {
	int n;
	cin >> n;
	vl a(n), b(n);
	ll sum = 0;
	ll mi = INF;
	rep(i, n) {
		cin >> a[i] >> b[i];
		sum += a[i];
		if (a[i] > b[i]) {
			mi = min(mi, b[i]);
		}
	}
	if (a == b) {
		cout << 0 << endl;
	}
	else {
		cout << sum - mi << endl;
	}
}

Measured memory_bytes: 512
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
long long n,m,a,b,i,j,d[110][101010];
int main(){
  scanf("%lld %lld",&n,&m);
  for(i=0;i<110;i++){
    for(j=0;j<100010;j++)d[i][j]=1e18;
  }
  for(i=d[0][0]=0;i<n;i++){
    scanf("%lld %lld",&a,&b);
    for(j=0;j<100000;j++){
      d[i+1][j  ]=MIN(d[i+1][j  ],d[i][j]);
      d[i+1][j+b]=MIN(d[i+1][j+b],d[i][j]+a);
    }
  }
  for(i=j=0;i<100001;i++){
    if(d[n][i]<=m)j=i;
  }
  printf("%lld\n",j);
}


Measured memory_bytes: 86912
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli h,w,m;cin>>h>>w>>m;
    vlli counth(h+1,0);
    vlli countw(w+1,0);
    set<plli> pts;
    flli(i,0,m-1)
    {
    	lli t1,t2;cin>>t1>>t2;
    	counth[t1]++;
    	countw[t2]++;
    	pts.insert(mp(t1,t2));
    }
    lli maxi=0;
    lli ans=0;
    flli(i,1,h)
    {
    	maxi=max(maxi,counth[i]);
    }
    ans+=maxi;
    set<lli> hmax;
    flli(i,1,h){
    	if(counth[i]==maxi)hmax.insert(i);
    }
    maxi=0;
    flli(i,1,w)
    {
    	maxi=max(maxi,countw[i]);
    }
    set<lli> wmax;
    flli(i,1,w){
    	if(countw[i]==maxi)wmax.insert(i);
    }
    ans+=maxi;
    lli temp=0;
    tr(pts,it)
    {
    	if(present(hmax,it->first) && present(wmax,it->second))temp++;
    }
    lli szh=sz(hmax),szw=sz(wmax);
    if(temp==szh*szw)ans--;
    cout<<ans;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1000100;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int N;
int arr[MAXN];
 
struct Dinic {
    struct Edge {
        int to, rev;
        ll c, f;
    };
    vi lvl, ptr, q;
    vector<vector<Edge>> adj;
    Dinic(int n) : lvl(n), ptr(n), q(n), adj(n) {}
    void addEdge(int a, int b, ll c, int rcap = 0) {
        adj[a].push_back({b, sz(adj[b]), c, 0});
        adj[b].push_back({a, sz(adj[a]) - 1, rcap, 0});
    }
    ll dfs(int v, int t, ll f) {
        if (v == t || !f) return f;
        for (int& i = ptr[v]; i < sz(adj[v]); i++) {
            Edge& e = adj[v][i];
            if (lvl[e.to] == lvl[v] + 1)
                if (ll p = dfs(e.to, t, min(f, e.c - e.f))) {
                    e.f += p, adj[e.to][e.rev].f -= p;
                    return p;
                }
        }
        return 0;
    }
    ll calc(int s, int t) {
        ll flow = 0; q[0] = s;
        rep(L,0,31) do { // 'int L=30' maybe faster for random data
            lvl = ptr = vi(sz(q));
            int qi = 0, qe = lvl[s] = 1;
            while (qi < qe && !lvl[t]) {
                int v = q[qi++];
                trav(e, adj[v])
                    if (!lvl[e.to] && (e.c - e.f) >> (30 - L))
                        q[qe++] = e.to, lvl[e.to] = lvl[v] + 1;
            }
            while (ll p = dfs(s, t, LLONG_MAX)) flow += p;
        } while (lvl[t]);
        return flow;
    }
};

bool pr (int x)
{
    if (x == 1) return false;
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0) return false;
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> arr[i];
    vector <int> v;
    for (int i = 0; i < N; i++)
    {
        if (i == 0 || arr[i-1] + 1 < arr[i])
            v.push_back(arr[i]);
        if (i == N - 1 || arr[i+1] - 1 > arr[i])
            v.push_back(arr[i]+1);
    }

    int m = v.size();
    Dinic d (m + 2);
    int ne = 0, no = 0;
    for (int i = 0; i < m; i++)
    {
        if (v[i] % 2 == 0)
        {
            d.addEdge (m, i, 1);
            ne++;
        }
        else
        {
            d.addEdge (i, m + 1, 1);
            no++;
        }
    }
    for (int i = 0; i < m; i++)
        for (int j = 0; j < m; j++)
        {
            if (v[i] % 2 == 0 && v[j] % 2 == 1)
            {
                if (pr (abs (v[i] - v[j])))
                {
                    //cout << i << " " << j << "\n";
                    d.addEdge (i, j, 1);
                }
            }
        }

    int r = d.calc (m, m + 1);

    //cout << r << " " << ne << " " << no << "\n";
    int res = r;
    ne -= r;
    no -= r;
    res += 2 * (ne / 2 + no / 2);
    res += 3 * (ne % 2);
    cout << res << "\n";
}

Measured memory_bytes: 640
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
    a[i].reverse()

ans = n
used = set()
for i in range(m):
    count = [0]*(m+1)
    for j in range(n):
        count[a[j][-1]] += 1

    ans = min(max(count), ans)
    num = count.index(max(count))
    used.add(num)
    for j in range(n):
        while len(a[j]) > 0:
            if a[j][-1] in used:
                a[j].pop()
            else:
                break

print(ans)


Measured memory_bytes: 10172
#include <stdio.h>
struct Edge{int to,next;}e[200003];int head[200003],len,h[200003],n,m,s;void add(int &u,int &v){e[++len]=(Edge){v,head[u]},head[u]=len;}
main(){
    scanf("%d%d",&n,&m);for(int i=1;i<=n;i++) scanf("%d",&h[i]),h[i+n]=h[i];while(m--){int a,b;scanf("%d%d",&a,&b),add(a,b),add(b,a);}
    for(int i=1;i<=n;i++){bool ok=1;for(int j=head[i];j;j=e[j].next) if(h[i]<=h[e[j].to])ok=0;if(ok) ++s;}printf("%d\n",s);return 0;
}

Measured memory_bytes: 4468
N = int(input())
S = [input() for i in range(N)]
count_dict = {}
for s in S:
  if not s in count_dict.keys():
    count_dict[s] = 1
  else:
    count_dict[s] += 1
maxnum = max(count_dict.values())
count_dict = dict(filter(lambda x: x[1] == maxnum, count_dict.items()))
ans = list(count_dict.keys())
ans.sort()
for s in ans:
  print(s)

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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e17;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int n, x = -1, p;
   cin >> n;
   for (int i = 0; i < n; i++) {
        cin >> p;
        if (x == -1) x = p;
        else x^= p;
   }
   if (x == 0) cout << "Yes";
   else cout << "No";

}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"unicode/utf8"
)


func main() {
	var s string
  	fmt.Scanf("%s", &s)
	sum := 0
	for i := 0; i < utf8.RuneCountInString(s); i++ {
		if s[i:i+1] == "1" { sum++ }
	}
	fmt.Printf("%d\n", sum)
}

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 != 0) {
            int div = 0;
            for (int j = 1; j<= i; j++) {
                if (i % j == 0) {
                    div++;
                }
            }
            if (div == 8) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  vector<char> ans(2*n);
  rep(i,n) {
    ans[i*2] = s[i];
    ans[i*2+1] = t[i];
  }
  rep(i,2*n) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  cin>>s;
  int n = s.length();
   string t = s;
  reverse(s.begin(),s.end());
  if(t==s){
  	string k =s.substr(0,(n-1)/2);
      string q = k;
    reverse(k.begin(),k.end());
    if(k==q){
    	string m = s.substr((n+3)/2 - 1);
      string o = m;
          reverse(m.begin(),m.end());
      if(m==o){
      	cout <<"Yes\n";
      }else 
      cout << "No\n";
    }
    else 
      cout << "No\n";
  }
  else 
      cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc174/tasks/abc174_f
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

// BIT(Binary-Indexed-Tree) 別名：Fenwick Tree
template <typename T> struct BIT {
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    // 要素iにxを加算
    void add(int i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }
    // 区間[0, i]の合計を求める（閉区間）
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
    // 区間[l, r]の合計を求める（閉区間）
    T sum(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

signed main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    vector<int> c(N, -1);
    // (s, t)
    vector<pair<int, int>> A;
    REP(i, N) {
        int a;
        cin >> a;
        if (c[a] != -1) {
            A.emplace_back(c[a], i + 1);
        }
        c[a] = i + 1;
    }
    sort(ALLR(A));

    vector<pair<int, int>> B(Q);
    REP(i, Q) { cin >> B[i].first >> B[i].second; }
    vector<int> ord(Q);
    iota(ALL(ord), 0);
    sort(ALL(ord), [&](int x, int y) {
        if (B[x].first == B[y].first)
            return B[x].second > B[y].second;
        return B[x].first > B[y].first;
    });

    BIT<int> bit(N + 1);
    vector<int> ans(Q);

    int j = 0;
    REP(k, Q) {
        int i = ord[k];
        while (j < (int)A.size() && B[i].first <= A[j].first) {
            bit.add(A[j].second, 1);
            j++;
        }
        int l = B[i].first;
        int r = B[i].second;
        ans[i] = r - l + 1 - bit.sum(r);
    }

    REP(i, Q) { cout << ans[i] << "\n"; }

    return 0;
}


Measured memory_bytes: 34296
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    d = collections.defaultdict(int)
    d[-1] = 3
    mt = 1
    for v in a:
        mt *= d[v-1]
        mt %= mod
        d[v-1] -= 1
        d[v] += 1
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 55524
from collections import defaultdict
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    add = []
    counter = defaultdict(int)
    
    for i in range(N):
        add.append(i+1 + A[i])
        key = i+1 - A[i]
        #key = abs(i+1 - A[i])
        counter[key] += 1
    
    ans = 0
    for add_value in add:
        ans += counter[add_value]
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 133576