akhauriyash/Code-Regression huggingface dataset:
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}

const ll MX=10000000;

ll cul(ll a,const vector<ll> &A){
    ll ret=0;
    ret+=a/A[1];
    a%=A[1];
    ret+=a/A[0];
    a%=A[0];
    ret+=a;
    return ret;
}



int main(){
    vector<ll> A(2);
    cin>>A;
    for(ll i=0;i<MX;i++){
        if(i<cul(A[0]*i,A)){cout<<A[0]*i<<endl; return 0;}
    }
    cout<<-1<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3104
n=int(input())
boo=[0 for i in range(10**5+1000)]
boo[100]=1
boo[101]=1
boo[102]=1
boo[103]=1
boo[104]=1
boo[105]=1
for i in range(100,n+1):
  if boo[i]==1:
    for j in range(6):
      boo[i+100+j]=1
if boo[n]:
  print(1)
else:
  print(0)


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

int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;

  if (op == "+")
    cout << A + B << endl;
  else
    cout << A - B << endl;
  return 0;
}

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

int x, y;

int main() {
  cin >> x >> y;
  int ans = 0;
  if(x <= 3) ans += 100000 * (3 - x + 1);
  if(y <= 3) ans += 100000 * (3 - y + 1);
  if(x == y && x == 1) ans += 400000;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    //first input is number of songs; use a for loop with the length
    int num = sc.nextInt();
    String[] songArray = new String[num];
    int[] songLength = new int[num];

    //sc.next(); and sc.nextInt();
    for(int i = 0; i < num; i++){
      songArray[i] = sc.next();
      songLength[i] = sc.nextInt();
    }
    //take in song name
    String endSong = sc.next();

    /*
    System.out.println(num);
    for( String each : songArray ){
      System.out.println(each);
    }
    for( int each : songLength ){
      System.out.println(each);
    }
    System.out.println(endSong);
    */

    boolean afterEndSong = false;
    int total = 0;
    for(int i = 0; i < num; i++){
      if( afterEndSong ){
        total += songLength[i];
      }
      if( songArray[i].equals(endSong) ){
        afterEndSong = true;
      }
    }

    System.out.println(total);

  }
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;


int32_t main(){
    boost;

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt" , "r" , stdin); 
    // freopen("output.txt" , "w", stdout);
    // #endif
    
    int n , d;
    cin >> n >> d;

    int x = 0;
    int ans = 0;
    while(x < n){
        x += 2*d;
        x++;
        ans++;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
/* Bismillahirrahmanirrahim
   Ps. SelfRemainder #1: Variabel gak otomatis nilainya 0
					 #2: Output harus sama persis formatnya sama di contoh
					 #3: Jangan lama2 mikirin 1 soal. Kalo dah gabisa, stop
					 #4: Kalau for bersarang, variabelnya jangan sama
*/
#include<bits/stdc++.h>

using namespace std;

int main(){
	int a, b, tes=0;
	cin >> a >> b;
	while(a>0){
		tes++; a-=b;
	}
	cout << tes << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,cnt=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(a!=i) cnt++;
	}
	if(cnt<=2) cout<<"YES";
	else cout<<"NO";
	return 0;
}

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

#define pb push_back
#define sz(x) (int) x.size()

using namespace std;
using ll = long long;

const int N = 2e5;
const int MOD = 1e9 + 7;

int dp[N][2];

vector<int> adj[N];

int add(int a, int b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
    return a;      
}

int mult(ll a, ll b) {
    return (a * b) % MOD;
}
                                                    
void dfs(int x = 0, int p = -1) {
    for (int to : adj[x])
        if (to != p) {
            dfs(to, x);
            dp[x][1] = mult(dp[to][0], dp[x][1]);
            dp[x][0] = mult(dp[x][0], add(dp[to][0], dp[to][1]));
        }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i < n; ++i) {
        int u, v; 
        cin >> u >> v;
        u--, v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for (int i = 0; i < N; ++i)
        dp[i][0] = dp[i][1] = 1;
    dfs();
    cout << add(dp[0][0], dp[0][1]);
    return 0;
}     

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

int main() {
    char a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    if (a == f && b == e && c == d) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<bool> sunuke(N, false);
  for(int i = 0; i < K; i++){
    int d;
    cin >> d;
    for(int i = 0; i < d; i++){
      int a;
      cin >> a;
      sunuke.at(a-1) = true;
    }
  }
  int result = 0;
  for(bool i : sunuke){
    if(!(i)){
      result ++;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 3632
n = int(input())
d = {}
for i in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1
largest = max(d.values())
common_values = []
for key in d.keys():
    if d[key] == largest:
        common_values.append(key)
common_values = sorted(common_values)
for val in common_values:
    print(val)

Measured memory_bytes: 35556
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;


const int M_N=200001;

struct UnionFind{
    int par[M_N];
    int rank[M_N];

    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;
        }
        else{
            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);
    }
};

struct edge { int from;int to;int cost;};

int main(){
    int n,m;
    while(cin >> n >> m){
        if(!n&&!m) break;
        UnionFind uf; 
        uf.init(n+1);
        vector<edge> v;
        for (int i = 0; i < m; i++) {
            int x,y,c;cin >> x >> y >> c;
            v.pb({x,y,c});
        }
        sort(ALL(v),[](const edge &right ,const edge &left){ return right.cost<left.cost;});
        int k=0;
        for (int i = 0; i < m; i++) {
            edge e=v[i];
            if(uf.same(e.from,e.to)) continue;
            uf.unite(e.from,e.to);
            k++;
            if(k==n/2){
                cout << e.cost << endl;
                break;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3332
from collections import  deque

H,W = map(int,input().split())

S = []

for i in range(H):

    s = list(input())
    S.append(s)

#print (S)

ans = 0

for a in range(H):
    for b in range(W):

        if S[a][b] == "#":
            continue
        
        q = deque([])
        q.append([a,b])
        d = [[float("inf")] * W for i in range(H)]
        d[a][b] = 0

        while len(q) > 0:

            now = q.popleft()
            x = now[0]
            y = now[1]

            if x > 0 and S[x-1][y] == ".":
                if d[x-1][y] > d[x][y] + 1:
                    d[x-1][y] = d[x][y] + 1
                    q.append([x-1,y])
            if x < H-1 and S[x+1][y] == ".":
                if d[x+1][y] > d[x][y] + 1:
                    d[x+1][y] = d[x][y] + 1
                    q.append([x+1,y])

            if y > 0 and S[x][y-1] == ".":
                if d[x][y-1] > d[x][y] + 1:
                    d[x][y-1] = d[x][y] + 1
                    q.append([x,y-1])

            if y < W-1 and S[x][y+1] == ".":
                if d[x][y+1] > d[x][y] + 1:
                    d[x][y+1] = d[x][y] + 1
                    q.append([x,y+1])

        
        for i in range(H):
            for j in range(W):
                if d[i][j] != float("inf"):
                    ans = max(ans,d[i][j])

        #print (d)

print (ans)

Measured memory_bytes: 3316
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);
	  //すぬけ君の人数
		int N=sc.nextInt();

		//お菓子の種類数
		int K=sc.nextInt();

		ArrayList<Integer>array=new ArrayList<>();

		//お菓子の種類分繰り返し
		for(int i=0;i<K;i++) {
			//そのお菓子を持っている人数
			int	d=sc.nextInt();

			//そのお菓子を持っている人の名前の入力繰り返し
			for(int j=0;j<d;j++) {
				int checkint=sc.nextInt();
				if(!array.contains(checkint)) {
					//そのお菓子をもっている人の名前を配列に格納
					array.add(checkint);
				}
			}


		}
		System.out.println(N-array.size());

	}
}


Measured memory_bytes: 46240
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (500*a + 100*b + 50*c) == X:
                ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << 2018;
    for (int i = 4 ; i < s.length() ; i++) cout << s[i];
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a,b,c = 0;
  scanf("%d %d", &a,&b);
  switch (a) {
    case 1:
      c+=300000;
      break;
    case 2:
      c+=200000;
      break;
    case 3:
      c+=100000;
  }
  switch (b) {
    case 1:
      c+=300000;
      break;
    case 2:
      c+=200000;
      break;
    case 3:
      c+=100000;
  }
  if (a==1&&b==1) {
    c+=400000;
  }
  printf("%d\n",c);
  return 0;
}


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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
const int MAXN = 2e5 + 10;
int a[MAXN], n;
int main(){
    n = read();
    for (int i = 1; i < n; i++){
        int x = read();
        a[x]++;
    }
    for (int i = 1; i <= n; i++){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int h1, h2, m1, m2, k;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << 60 * (h2 - h1) + (m2 - m1) - k << endl;

	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 110
#define MAXW 100001
#define rep(i,n) for (int i = 0; i < n; ++i)
const ll mod = 1e9+7;



ll n, W;
ll dp[MAXN][MAXW];
ll v[MAXN], w[MAXN];

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

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


    for(int i=0; i<W+1; ++i) {
        dp[0][i] = 0;
    }

    for(int i=0; i<n; ++i) {
        for(int k=0; k<=W; ++k) {
            if (k >= w[i]) {
                dp[i+1][k] = max(dp[i][k], dp[i][k-w[i]] + v[i]);
            } else {
                dp[i+1][k] = dp[i][k];
            }
        }
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 80128
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int dp[300][300];
string ans;

int getLCSlen(string a, string b){
    memset(dp, 0, sizeof(dp));
    int ret = 0;

    for(int j = 0; j < b.length(); j++) if(a[0] == b[j])    dp[0][j] = 1, ret = 1;
    for(int i = 0; i < a.length(); i++) if(a[i] == b[0])    dp[i][0] = 1, ret = 1;
    
    // add these if you want to get longest common subsequence
    for(int i = 1; i < a.length(); i++) dp[i][0] = max(dp[i][0], dp[i-1][0]);
    for(int j = 1; j < b.length(); j++) dp[0][j] = max(dp[0][j], dp[0][j-1]);

    for(int i = 1; i < a.length(); i++){
        for(int j = 1; j < b.length(); j++){
            if(a[i] == b[j]){
                dp[i][j] = dp[i-1][j-1]+1;
                ret = max(ret, dp[i][j]);
            }
            dp[i][j] = max(dp[i][j], max(dp[i-1][j], dp[i][j-1]));
            ret = max(ret, dp[i][j]);
        }
    }
    return ret;
}

void solve(string s){
    ans = "";
    for(int x = 1; x < s.length(); x++){
        int len = getLCSlen(s.substr(0,x), s.substr(x));
        if(len > ans.length()){
            string tmp = "";
            int i = x-1, j = s.length()-x-1;
            while(i >= 0 && j >= 0 && dp[i][j]>0){
                while(i > 0 && dp[i-1][j]==dp[i][j])    i--;
                while(j > 0 && dp[i][j-1]==dp[i][j])    j--;
                tmp += s[i];
                i--, j--;
            }
            ans = tmp;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

int main(){
    string s;
    while(cin >> s, s != "#END"){
        solve(s);
    }
    return 0;
}


Measured memory_bytes: 3380
#include<stdio.h>

int main( ) {
	int input_a;
	int input_b;

	while(1) {
		scanf("%d %d",& input_a ,& input_b);

		if( input_a == 0 && input_b == 0 ) {
			break;
		}

		if( input_a < input_b ) {
			printf("%d %d\n",input_a ,input_b);
		} else {
			printf("%d %d\n",input_b ,input_a);
		}
	}

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int start,end;
    bool flag = true;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == 'A' && flag){
           start = i;
           flag = false;
        }
        if(s.at(i) == 'Z' && !(flag)){
            end = i;
        }
    }
    cout << (end - start + 1) << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

inline double sq(double a){return a*a;}
inline double le(P a, P b){return sqrt(sq(a.F-b.F)+sq(a.S-b.S));}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(15);
    int n;
    cin>>n;
    vp p(n);
    cin>>p;
    double l=0;
    REP(i,n){
        REP(j,i+1,n){
            l+=le(p[i],p[j]);
        }
    }
    l*=n-1;
    l/=n*(n-1)/2;
    cout<<l<<endl;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))

s1 = 0
s2 = 0
ref = sum(w)

for i in range(n - 1):
    s1 = sum(w[0: i + 1])
    s2 = sum(w[i + 1: n])
    diff = abs(s1 - s2)
    if diff <=  ref:
        ref = diff

print(ref)

Measured memory_bytes: 3064
#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<P>>
#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(){
    ll n;cin>>n;
    vector<ll> a(n+2,0);
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }

    ll sum=0;
    rep(i,n+1){
        sum+=abs(a[i+1]-a[i]);
    }

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

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,C;
    cin >> N >> C;
    vector<vector<ll> > d(C, vector<ll>(C));
    rep(i,C){
        rep(j,C){
            cin >> d[i][j];
        }
    }
    vector<vector<ll> > color(N, vector<ll>(N));
    rep(i,N){
        rep(j,N){
            cin >> color[i][j];
            color[i][j]--;
        }
    }
    vector<ll> color_list1(C);
    vector<ll> color_list2(C);
    vector<ll> color_list3(C);
    rep(i,C){
        color_list1[i] = 0;
        color_list2[i] = 0;
        color_list3[i] = 0;
    }
    rep(i,N){
        rep(j,N){
            if ((i + j + 2) % 3 == 0) color_list1[color[i][j]]++;
            if ((i + j + 2) % 3 == 1) color_list2[color[i][j]]++;
            if ((i + j + 2) % 3 == 2) color_list3[color[i][j]]++;
        }
    }
    vector<ll> color1(C);
    vector<ll> color2(C);
    vector<ll> color3(C);
    
    rep(i,C){
        ll ans = 0;
        rep(j,C){
            ans += color_list1[j] * d[j][i];
        }
        color1[i] = ans;
    }
    rep(i,C){
        ll ans = 0;
        rep(j,C){
            ans += color_list2[j] * d[j][i];
        }
        color2[i] = ans;
    }
    rep(i,C){
        ll ans = 0;
        rep(j,C){
            ans += color_list3[j] * d[j][i];
        }
        color3[i] = ans;
    }
    ll ans = 10000000000;
    rep(i,C){
        rep(j,C){
            rep(k,C){
                if (i == j || j == k || k == i) continue;
                ans = min(ans, color1[i] + color2[j] + color3[k]);
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  int av=0;
  rep(i,n) {
    cin >> x[i];
    av+=x[i];
  }
  av/=n;
  int cand1=0, cand2=0;
  rep(i,n) {
    cand1+=(av-x[i])*(av-x[i]);
    cand2+=(av+1-x[i])*(av+1-x[i]);
  }
  cout << min(cand1,cand2) << endl;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc099/tasks/abc099_d
# さまざまな合わせ技
# ダイクストラ、全探索

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため



# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations

# from scipy.sparse.csgraph import dijkstra
# from scipy.sparse import csr_matrix, lil_matrix
# 0 まずはダイクストラでX→Yの最小コストを求めておく #えーーーーこれ想定されてないの？
# 1 座標ごとに3つのグループわけができる(n=1のときだけ場合分け
# 2 グループごとに色をカウント
# 3 各グループの色を仮定して全探索

N, C = read_ints()
D = read_matrix(C)
# D = csr_matrix(D)
# D = dijkstra(D)


# 1 座標のグループわけ
Cmap = read_matrix(N)

if N == 1:
    print(0)
    exit()

lsbymod = defaultdict(lambda: [])
for i in range(N):
    for j in range(N):
        lsbymod[(i + j + 2) % 3].append(Cmap[i][j] - 1)

# グループごとに色のカウント
for k, v in lsbymod.items():
    lsbymod[k] = Counter(v)

# 各グループの色を仮定して全探索


# print(D)
# print(lsbymod)


def ret_score(*arg):
    # 各仮定から違和感を計算
    ret = 0
    for i in range(3):
        for k, v in lsbymod[i].items():
            ret += v * D[k][arg[i]]
    return ret


ans = 2**63
for a, b, c in permutations(range(C), 3):
    # print(a, b, c, ret_score(a, b, c))
    ans = min(ans, ret_score(a, b, c))

print(ans)


Measured memory_bytes: 56156
// https://atcoder.jp/contests/abc159/tasks/abc159_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "unordered_map"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  VL cts(N + 1);

  for (auto a : as) ++cts[a];

  ll all_ct = 0;

  for (auto ct : cts) {
    all_ct += ct * (ct - 1) / 2;
  }

  for (auto a : as) {
    ll res = all_ct;
    ll ct = cts[a];
    res -= ct * (ct - 1) / 2;
    res += (ct - 1) * (ct - 2) / 2;
    cout << res << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 5760
import scala.io.Source.stdin

object Main {
  def main(args:Array[String]) =  {
    val (r,l) = stdin.getLines.foldLeft((0,0)){ (x,y) =>
      val z = y.split(",").map(_.toInt)
      if(z(0)==z(1)) (x._1,x._2+1)
      else if(z(0)*z(0)+z(1)*z(1)==z(2)*z(2)) (x._1+1,x._2)
      else x
    }
    println(r)
    println(l)
  }
}

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

using namespace std;

typedef long long Int;
const Int mod = 1000000007;
const Int INF = mod * mod;

int main() {
	Int n;
	cin >> n;
	vector<Int>W(n);
	for (Int i = 0; i < n; i++)cin >> W[i];
	Int res = INF;
	for (Int i = 1; i < n ; i++) {
		Int l = 0, r = 0;
		for (Int j = 0; j < i; j++)l += W[j];
		for (Int j = i; j < n; j++)r += W[j];
		res = min(res, abs(l - r));
	}
	cout << res << endl;
}

Measured memory_bytes: 256
while True:
  a, op, b = input().split()
  a, b = int(a), int(b)
  if op == '+':
    print(a + b)
    next
  elif op == '-':
    print(a - b)
    continue
  elif op == '*':
    print(a * b)
    continue
  elif op == '/':
    print(a // b)
    continue
  else:
    break


Measured memory_bytes: 5600
// finish date: 2018/04/21

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    string S, T;
    cin >> S >> T;
    vi ruisekiS(S.length(), 0);
    vi ruisekiT(T.length(), 0);
    rep(i, S.length()) {
        if (S[i] == 'A') ruisekiS[i]++;
        else ruisekiS[i] += 2;
        if (i != 0) {
            ruisekiS[i] += ruisekiS[i - 1];
        }
    }
    rep(i, T.length()) {
        if (T[i] == 'A') ruisekiT[i]++;
        else ruisekiT[i] += 2;
        if (i != 0) {
            ruisekiT[i] += ruisekiT[i - 1];
        }
    }
    int q;
    cin >> q;
    rep(i, q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        c--;
        d--;
        int valS = (a != 0) ? ruisekiS[b] - ruisekiS[a - 1] : ruisekiS[b];
        int valT = (c != 0) ? ruisekiT[d] - ruisekiT[c - 1] : ruisekiT[d];

        if ((valT - valS) % 3 == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#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
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;

int Getinput(){
    string s; cin >> s;
    if(s == "Vacant") return 0;
    else if(s == "Male") return 1;
    else if(s == "Female") return 2;
}
int main(){
    int N; cin >> N;

    cout << N - 1 << endl;
    if(Getinput() == 0){
        return 0;
    }
    cout << 0 << endl;
    int x = Getinput();
    if(x == 0){
        return 0;
    }

    int low = 0,high = N - 1;
    int stnd = x;

    while(high - low > 2){
        int mid = (high + low) / 2;
        if(mid % 2 == 1) mid--;

        cout << mid << endl;
        int y = Getinput();
        if(y == 0){
            return 0;
        }else if(stnd == y){
            low = mid;
        }else{
            high = mid;
        }
    }

    cout << low + 1 << endl;
    int z = Getinput();
    return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  double A, B; cin >> A >> B;
  double H,M; cin >> H >> M;
  double time = H*60+M;
  double ta = 360 * time / 720.0;
  double tb = 360 * M/60;
  double d = abs(ta-tb);
  if(d>180.0) d = 360-d;
  double the = 2*acos(-1)*d/360.0;
  //cout << time << " " << ta << " " << tb << " " << d << " " << the << endl;
  double ans = sqrt(A*A+B*B-2*A*B*cos(the));
  cout << fixed << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll n;
double dis[601],d[601];
vector<vector<ll> > v(601);
void dfs(ll now){
	double niko=double(v[now].size());
	double sum=0;
	if(v[now].size()==0){
		if(now==n-1){
			dis[now]=0.0;
		}else{
			dis[now]=1e14;
		}
		return;
	}
	for(auto& to:v[now]){
		if(dis[to]<-1.0)dfs(to);
		sum+=dis[to];
	}
	dis[now]=sum/niko+1.0;
	return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll m,a,b;
    cin>>n>>m;
    for(int i=1;i<n;i++){
    	dis[i]=-2.0;
    }
    for(int i=0;i<m;i++){
    	cin>>a>>b;
    	a--,b--;
    	v[a].pb(b);
    }
    dfs(0);
    double ans=dis[0];
    for(int i=0;i<n-1;i++){
    	if(v[i].size()==1)continue;
    	for(int j=i+1;j<n;j++){
    		d[j]=dis[j];
    	}
    	double sum=0,ma=0;
    	for(auto& to:v[i]){
    		sum+=d[to]+1.0;
    		ma=max(ma,d[to]+1.0);
    	}
    	d[i]=(sum-ma)/(v[i].size()-1);
    	for(int j=i-1;j>=0;j--){
    		d[j]=0;
    		for(auto& to:v[j]){
    			d[j]+=d[to]+1.0;
    		}
    		d[j]/=v[j].size();
    	}
    	ans=min(ans,d[0]);
    }
    doublecout(ans);
    return 0;
}


Measured memory_bytes: 2560
MOD = 10**9+7

n = int(input())
s1 = input()
s2 = input()
ans = 1

if s1[0] == s2[0]:
    i = 1
    pre_pat = 0
    ans = 3
else:
    i = 2
    pre_pat = 1
    ans = 6

t = [[2, 2], [1, 3]]
while True:
    if i >= n:
        break
    if s1[i] == s2[i]:
        pat = 0
        i += 1
    else:
        pat = 1
        i += 2
    ans *= t[pre_pat][pat]
    ans %= MOD
    # print(pre_pat, pat, ans, i)
    pre_pat = pat
print(ans)

Measured memory_bytes: 38424
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n;
char a[2000000], b[2000000];

int main()
{
	int i, j, k, l;
	cin>>n;
	scanf("%s%s", a, b);
	for(i=0;i<n;i++) if(a[i] != b[i]) break;
	if(i == n) return !printf("0\n");
	vector<pair<pii, char>> av, bv;
	vector<pii> g;
	int st=0;
	for(i=0;i<n;i++)
	{
		if(a[i] != a[i+1])
		{
			av.emplace_back(mp(st, i), a[i]);
			st=i+1;
		}
	}
	st=0;
	for(i=0;i<n;i++)
	{
		if(b[i] != b[i+1])
		{
			bv.emplace_back(mp(st, i), b[i]);
			st=i+1;
		}
	}
	int avi=av.size()-1;
	for(i=bv.size()-1;i>=0;i--)
	{
		int bad=0;
		while(1)
		{
			if(avi == -1)
			{
				bad=1;
				break;
			}
			if(av[avi].first.first > bv[i].first.first || av[avi].second != bv[i].second)
			{
				avi--;
				continue;
			}
			g.emplace_back(min(av[avi].first.second, bv[i].first.first), bv[i].first.second);
			break;
		}
		if(bad == 1) return !printf("-1\n");
	}
	int ma=0;
	sort(all(g));
	for(i=0;i<g.size();i++)
	{
		int low=i+1, high=g.size()-1, mid;
		while(low <= high)
		{
			mid=(low+high)/2;
			if(g[mid].first-(mid-1-i) <= g[i].second) low=mid+1;
			else high=mid-1;
		}
		ma=max(ma, low-i);
	}
	cout<<ma<<endl;
	return 0;
}
//*/

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9 + 7;
const double EPS = 1e-9;
const int n = 13;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int len = s.size();
    int dp[len + 1][n];
    rep (i, len + 1) {
      rep (j, n) dp[i][j] = 0;
    }

    dp[0][0] = 1;
    int mal = 1;
    for (int i = len - 1; i >= 0; --i) {
      int index = len - i;
      if (s[i] == '?') {
        rep (j, n) {
          rep (k, 10) {
            dp[index][(j + k * mal) % n] += dp[index - 1][j];
            dp[index][(j + k * mal) % n] %= Inf;
          }
        }
      } else {
        int num = s[i] - '0';
        rep (j, n) {
          dp[index][(j + num * mal) % n] += dp[index - 1][j];
          dp[index][(j + num * mal) % n] %= Inf;
        }
      }
      mal *= 10;
      mal %= n;
    }
    cout << dp[len][5] << endl;

    return 0;
}


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

static const int MAX_V = 200;
int V, E;
vector<int> G[MAX_V];
int match[MAX_V];
int used[MAX_V];

// u と v を結ぶ辺をグラフに追加する
void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

// 増加パスを DFS で探す
bool dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    int w = match[u];
    if (w < 0 || !used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

// 二部グラフの最大マッチングを求める
int biparticle_matching() {
  int res = 0;
  memset(match, -1, sizeof(match));
  for (int v = 0; v < V; v++) {
    if (match[v] < 0) {
      memset(used, 0, sizeof(used));
      if (dfs(v)) res++;
    }
  }
  return res;
}

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

  int N;
  cin >> N;
  V = 2 * N;

  int a[N], b[N], c[N], d[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> d[i];
  }

  // 隣接リストの作成
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (a[i] < c[j] && b[i] < d[j]) add_edge(i, j + N);
    }
  }
  int ans = biparticle_matching();
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
N = int(input())

A = list(map(int, input().split()))
#print (A)

def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    if x%y == 0:
        return y
    else:
        return gcd(y, x%y)

ans = A[0]
for i in range(N):
    ans = gcd(ans, A[i])

print (ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> x(N), y(N);
    vector<pair<long long, long long>> points(N);
    REP(i, N) {
        cin >> x[i] >> y[i];
        points[i] = make_pair(x[i], y[i]);
    }
    // N点のうちK個以上の点を含む
    //長方形の辺上の点は長方形の内部に含みます。
    //それらの長方形の中で、最小の面積となるような長方形の面積を求めてください。
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    long long ans =
        1LL * (x[N - 1] - x[0]) * (y[N - 1] - y[0]); // INFでもよいのでは
    for(int xi = 0; xi < N; xi++) {
        for(int xj = xi + 1; xj < N; xj++) {
            for(int yi = 0; yi < N; yi++) {
                for(int yj = yi + 1; yj < N; yj++) {
                    int num = 0;
                    long long leftx = x[xi];
                    long long rightx = x[xj];
                    long long uppery = y[yj];
                    long long downy = y[yi];
                    for(int i = 0; i < N; i++) {
                        pair<long long, long long> point = points[i];
                        if(leftx <= point.first and point.first <= rightx and
                           downy <= point.second and point.second <= uppery) {
                            num++;
                        }
                    }
                    if(num >= K) {
                        ans =
                            min(ans, 1LL * (rightx - leftx) * (uppery - downy));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string s;

  cin >> s;

  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3580
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  int N;

  cin >> N;

  if ((N==3) ||(N==5)||(N==7)) cout << "YES" << "\n";
  else cout << "NO" << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n, tmp, x[100], y[100];
    double p, q, r, s;
    s = 0;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> x[i];
    }
    for (int i=0; i<n; i++) {
        cin >> tmp;
        x[i] = x[i] - tmp;
    }
    for (int i=0; i<n; i++) {
        p += abs(x[i]);
        q += pow(abs(x[i]), 2);
        r += pow(abs(x[i]), 3);
        if (s < abs(x[i])) {
            s = abs(x[i]);
        }
    }
    cout << fixed << p << endl;
    cout << fixed << sqrt(q) << endl;
    cout << fixed << cbrt(r) << endl;
    cout << fixed << s << endl;
    
    
}


Measured memory_bytes: 3476
#include <iostream>
#include <cmath>

bool checkInputParameter(const int& val, bool isCircle) {
    if(isCircle) {
        if ((-100 <= val) && (val <= 100)) {
            return true;
        }
        return false;
    }
    
    if ((0 < val) && (val <= 100)) {
        return true;
    }
    return false;
}

int main(int argc, char* argv[])
{
    int W, H, x, y, r;
    
    std::cin >> W;
    std::cin >> H;
    std::cin >> x;
    std::cin >> y;
    std::cin >> r;
    
    if (!checkInputParameter(W, false)
     || !checkInputParameter(H, false)
     || !checkInputParameter(x, true)
     || !checkInputParameter(y, true)
     || !checkInputParameter(r, false))
        goto END;
    
    if (((x-r) >= 0)
     && ((x+r) <= W)
     && ((y-r) >= 0)
     && ((y+r) <= H)) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    
END:
    return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
        int data;
        struct node *next;
        struct node *prev;
        struct node *head;
        struct node *last;
}stack;
typedef struct {
        stack pair;
        stack area;
}areapair;
void Push_back(stack**, stack**, int);
int Pop_back(stack**, stack**);
main()
{
        int i, ch, count = 0, sum = 0;
        char str[20001];
        stack S1, *p;
        areapair S2;
        S1.head = S1.last = S2.pair.head = S2.pair.last
                = S2.area.head = S2.area.last = NULL;
        scanf("%s", str);
        for(i = 0; str[i]; i++){
                if(str[i] == '\\'){
                        Push_back(&(S1.head), &(S1.last), i);
                }else if(S1.head != NULL && str[i] == '/'){
                        int j = Pop_back(&(S1.head), &(S1.last));
                        int a = i - j;
                        sum += i - j;
                        count++;
                        while(S2.pair.head != NULL && S2.pair.last -> data > j){
                                a += S2.area.last -> data;
                                Pop_back(&(S2.pair.head), &(S2.pair.last));
                                Pop_back(&(S2.area.head), &(S2.area.last));
                                count--;
                        }
                        Push_back(&(S2.pair.head), &(S2.pair.last), j);
                        Push_back(&(S2.area.head), &(S2.area.last), a);
                }
        }
        printf("%d\n%d", sum, count);
        p = S2.area.head;
        while(p != NULL){
                printf(" %d", p -> data);
                p = p -> next;
        }
        putchar('\n');
}
void Push_back(stack **head, stack **last, int data)
{
        stack *p;
        if((p = (stack*)malloc(sizeof(stack))) == NULL){
                fprintf(stderr, "Memory cannot allocate\n");
                exit(0);
        }
        p -> data = data;
        p -> next = NULL;
        p -> prev = *last;
        if(*head == NULL){
                        *head = p;
        }else{
                        (*last) -> next = p;
        }
        *last = p;
}
int Pop_back(stack **head, stack **last)
{
        int pop_data;
        stack *p = *last;
        if(*head == NULL){
                return EOF;
        }
        pop_data = (*last) -> data;
        if((*last) -> prev == NULL){
                *head = NULL;
        }else{
                        (*last) -> prev -> next = NULL;
        }
                *last = (*last) -> prev;
        free(p);
        return pop_data;
}

Measured memory_bytes: 2788
n, m = (int(i) for i in input().split())
h = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for i in range(m)]
ma = []
for i in range(n):
    ma.append(0)
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    ma[a-1] = max(ma[a-1],h[b-1])
    ma[b-1] = max(ma[b-1],h[a-1])
ans = 0
for i in range(n):
    ans += (h[i]>ma[i])
print(ans)

Measured memory_bytes: 30340
//14
#include<iostream>
#include<algorithm>

using namespace std;

char g[1000][80];
int h;
int t,tr;
int b,l,r;

void ff(int y,int x){
  if(y==t){
    tr=max(tr,x);
  }else if(b<y){
    b=y;
    l=r=x;
  }else if(b==y){
    l=min(l,x);
    r=max(r,x);
  }
  g[y][x]=0;
  for(int i=-1;i<=1;i++){
    for(int j=-1;j<=1;j++){
      int nx=x+i;
      int ny=y+j;
      if(0<=ny&&ny<h&&0<=nx&&nx<80&&g[ny][nx]=='*'){
	ff(ny,nx);
      }
    }
  }
}
	
int main(){
  bool ns=false;
  while(cin>>h,h){
    cin.ignore();
    fill(g[0],g[h],0);
    for(int i=0;i<h;i++){
      cin.getline(g[i],80);
    }
    int cn[80000]={};
    for(int i=0;i<h;i++){
      for(int j=0;j<80;j++){
	if(g[i][j]=='*'){
	  t=i;
	  l=80;
	  b=r=tr=0;
	  ff(i,j);
	  cn[(tr-j+1+r-l+1)*(b-i+1)/2]++;
	}
      }
    }
    if(ns){
      cout<<"----------"<<endl;
    }
    ns=true;
    for(int i=0;i<80000;i++){
      if(cn[i]){
	cout<<i<<' '<<cn[i]<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1512