akhauriyash/Code-Regression huggingface dataset:
let cnt = ref 0

let print_array a =
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ()

let selection_sort a n =
  let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  let rec select j minj =
    if j >= n then minj
    else select (j + 1) (if a.(j) < a.(minj) then j else minj)
  in
  let rec doit i =
    if i < n then begin
      let minj = select i i in
      if minj <> i then (swap i minj; incr cnt);
      doit (i + 1)
    end
  in
  doit 0

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (Str.split (Str.regexp " ") (read_line ()))) in
  selection_sort a n;
  print_array a;
  Printf.printf "%d\n" !cnt

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

int main(){
  int a,b,c;
  cin >> a >> b;
  c = a*b;
  //cout << "c=" << c <<endl;
  if(c%2==0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
  return 0;
}


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

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

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[3], k;
	cin >> a[0] >> a[1] >> a[2];
	cin >> k;
	rep(i, k) {
		sort(a, a + 3);
		a[2] *= 2;
	}
	cout << a[0] + a[1] + a[2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define R(i,n) for(int i=0;i<n;i++)
int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[(i-n+o)&1][i],&t=p[B|1<<i][k];R(j,k+1)t=min(t,p[B][j]+d[i]);}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}

Measured memory_bytes: 52480
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$M) =  explode(" ",trim(fgets(STDIN)));
//$A = explode(" ",trim(fgets(STDIN)));

for($i=0;$i<$M;$i++) {
  list($a[$i],$b[$i]) =  explode(" ",trim(fgets(STDIN)));
  $c[$i] = explode(" ",trim(fgets(STDIN)));
}

$maxn = 1<<$N;
$dp = array_fill(1,$maxn,1001001001);
$dp[0]=0;
for($i=0;$i<$M;$i++) {
  $k=0;
  foreach($c[$i] as $v) {
    $k += 1<<((int)$v-1);
  }
  for($l=0;$l<$maxn;$l++) {
    $dp[$l|$k]=min((int)$dp[$l|$k],(int)$a[$i]+(int)$dp[$l]);
  }
}
if ($dp[$maxn-1]==1001001001) $dp[$maxn-1]=-1;
printf("%d\n",$dp[$maxn-1]);


Measured memory_bytes: 6648
#include <iostream>
#include <string>
#include <vector>
#define N 12
using namespace std;
int main() {
	string a, b;
	int min = 0,i;
	cin >> a >> b ;
	if (a.length() <= b.length()) {
		min = a.length();
	}
	else {
		min = b.length();
	}
	for (i = 0; i < min;i++) {
		cout << a[i];
		cout << b[i];
	}
	if (a.length() == b.length()) {
	}
	else if (a.length() < b.length()) {
		cout << b[i];
	}
	else {
		cout << a[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  ll a, b, c, x;
  cin>>a>>b>>c>>x;
  ll ans = a-b;
  if (x&1) ans = -ans;
  cout<<ans<<endl;
  return 0;
}






















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

using namespace std;

vector<int> v[500];

int n,m;
int p[500];

void solve(int num){
  for(int i = 0;i<v[num].size();i++){
    p[v[num][i]] = 1;
    // cout<<v[num][i]<<endl;
  }

}

int main(){

  while(cin>>n,cin>>m){
    if(n==0&&m==0)
      break;

    for(int i = 0;i<m;i++){
      int a,b;
      cin>>a>>b;
      a--;b--;
      v[a].push_back(b);
      v[b].push_back(a);
    }
    memset(p,0,sizeof(p));
    for(int i= 0;i<v[0].size();i++){
      solve(v[0][i]);
      p[v[0][i]] = 1;
    }
    int ans = 0;
    for(int i = 1;i<n;i++){
      // cout<<"i:"<<i<<"\t"<<p[i]<<endl;
      if(p[i] == 1)
	ans++;
    }
    cout<<ans<<endl;
    for(int i = 0;i<500;i++)
      v[i].clear();

  }
  

  return 0;
}

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define for(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)



int main(void) {
    long int N,W,ans;
    cin >> N >> W;    
if(W>=N){
  cout << "unsafe" << "\n"; 
}
else{
      cout << "safe" << "\n"; 
}
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;


int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    rep(i,1,s.size()-1){
        int v[2][26]={0};
        rep(j,0,i)v[0][s[j]-'a']++;
        rep(j,i,s.size())v[1][s[j]-'a']++;

        int aans=0;
        rep(j,0,26){
            aans+=(v[0][j]&&v[1][j]);
        }
        ans=max(aans,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def chess(h,w):
    o = ""
    for i in range(h):
        for j in range(w):
            if (i+j)%2: o+="."
            else: o+="#"
        o+="\n"
    print o
  
while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    chess(h,w)

Measured memory_bytes: 6376
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m, k;
    cin >> n >> m >> k;
    map<pair<int, int>, int> mp;
    for (int i = 0; i < k; ++ i) {
        int x, y;
        cin >> x >> y;
        for (int a = x - 2; a <= x; ++ a) {
            for (int b = y - 2; b <= y; ++ b) {
                if (a < 1 || a + 2 > n || b < 1 || b + 2 > m) continue;
                mp[{a, b}] ++;
            }
        }
    }
    vector<ll> a(10, 0);
    for (auto& x : mp) {
        a[x.second] ++;
    }
    a[0] = (n - 2) * (m - 2) - accumulate(a.begin(), a.end(), 0LL);
    for (auto& x : a) cout << x << "\n";
    
}

Measured memory_bytes: 56576
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  ll Q;
  cin >> Q;
  vector<char> foo, bar;
  bool direction = false;
  rep (i, Q) {
    ll T;
    cin >> T;
    if (T == 1) {
      direction = !direction;
      continue;
    }
    ll F;
    char C;
    cin >> F >> C;
    if (direction == false and F == 1) foo.push_back(C);
    if (direction == false and F == 2) bar.push_back(C);
    if (direction == true and F == 1) bar.push_back(C);
    if (direction == true and F == 2) foo.push_back(C);
  }

  if (direction == false) {
    for (auto it = foo.rbegin(); it != foo.rend(); it++) cout << *it;
    for (auto it = S.begin(); it != S.end(); it++) cout << *it;
    for (auto it = bar.begin(); it != bar.end(); it++) cout << *it;
    cout << endl;
  } else {
    for (auto it = bar.rbegin(); it != bar.rend(); it++) cout << *it;
    for (auto it = S.rbegin(); it != S.rend(); it++) cout << *it;
    for (auto it = foo.begin(); it != foo.end(); it++) cout << *it;
    cout << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;
const long long INF = 1LL<<60; // 仮想的な無限大の値
vector<bool> seen;

Graph G;

int main() {
    
    int a,b,c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    if(sum >= 22 ){
        cout << "bust";
    }else if(sum <= 21){
        cout << "win";
    }
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,sum=0,b;
    int a[110]={};
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>b;
    	a[b]=1;
    }
    for(int i=0;i<=100;i++)
    {
    	sum+=a[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

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

  int x = 1;
  for(int i = 1; i + 1 <= 999; i++){
    int left = i * (i + 1) / 2;
    int right = (i + 1) * (i + 2) / 2;
    if(abs(left - right) == abs(a - b) && left - a >= 0){
      x = left - a;
      break;
    }
  }

  cout << x << endl;

  return 0;
}


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

#define   ll    long long int

ll n, k;

int main( )
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
        cout << "bust\n";
    else
        cout << "win\n";
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	auto a = vector<int>(n);
	for(auto&& b : a) cin >> b;
	long long int l = -n, r = 1000000000 + n, ans = 200000000000000;
	while(1){
		long long int m = (l + r) / 2, t1, t2, t3;
		t1 = t2 = t3 = 0;
		for(auto i = 0; i < n; ++i){
			t1 += abs(a[i] - (m - 1 + i));
			t2 += abs(a[i] - (m + i));
			t3 += abs(a[i] - (m + 1 + i));
		}
		if(t1 == t2 || t2 == t3 || (t1 > t2 && t2 < t3)){
			ans = t2;
			break;
		}
		if(t1 < t2) r = m - 1;
		else l = m + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner scan = new Scanner(System.in);
        
        int x = scan.nextInt();
        
        int num = (x + 1000 - 1) / 1000;
        System.out.println(1000*num - x);
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define all(c) begin(c),end(c)
const ll INF = 1e18;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll>a(3 * N);
	priority_queue<ll, vector<ll>, greater<ll>>minq;
	priority_queue<ll>maxq;
	ll sum1 = 0, sum2 = 0;
	ll ans = -INF;

	rep(i, 3 * N) {
		cin >> a[i];
		if (i < N ) {
			minq.push(a[i]);
			sum1 += a[i];
		}
		if (i >= N * 2) {
			maxq.push(a[i]);
			sum2 += a[i];
		}
	}
	vector<ll>suma(N+1), sumb(N+1);
	suma[0] = sum1; sumb[0] = sum2;
	rep(i, N) {
		minq.push(a[N + i]);
		sum1 += a[N + i];
		sum1 -= minq.top();
		suma[i+1] = sum1;
		minq.pop();
	}
	rep(i, N) {
		maxq.push(a[2 * N - 1 - i]);
		sum2 += a[2 * N - 1 - i];
		sum2 -= maxq.top();
		sumb[i+1] = sum2;
		maxq.pop();
	}
	rep(i, N+1) {
		ans = max(ans, suma[i] - sumb[N - i]);
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
  int N, peo = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    for (int j = l; j <= r; j++) {
      peo++;
    }
  }
  cout << peo << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}

signed main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << (y1 - y2) + x2 << " ";
	cout << y2 + (x2 - x1) << " ";
	cout << x1 + (y1 - y2) << " ";
	cout << (x2 - x1) + y1 << endl;
	endre;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    bool ok;
    if(V<=W){
        ok = false;
    }else{
        ll D = abs(A-B);
        if(D<=(V-W)*T){
            ok = true;
        }else{
            ok = false;
        }
    }

    cout << (ok?"YES":"NO") << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
int MOD = 1000000007; 

int main(){
  int n; cin >>n;
  vector<ll>a(n),b(n),sum(n+1,0);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=n-1;i>=0;--i){
    sum[i]+=a[i]+sum[i+1];
    sum[i]%=MOD;
    //cout<<sum[i]<<endl;
  }
  ll kotae=0;
  for(int i=0;i<n-1;i++){
    kotae+=a[i]*sum[i+1];
    kotae%=MOD;
    //cout<<a[i]<<" "<<sum[i+1]<<endl;
  }
  cout<<kotae<<endl;
  return 0;
}



Measured memory_bytes: 8004
/*
g++ -std=c++11 -o2 -Wall ABC111A.cpp -o .\out\ABC111A.out
.\out\ABC111A.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  string ans = "";
  for (int i = 0; i < n; ++i) {
    if (s[i]=='1') ans += "9";
    else if (s[i]=='9') ans += "1";
    else ans += s[i];
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
from itertools import product

input = sys.stdin.readline

P = 10 ** 9 + 7


def is_ok(a, b, c, d):
    s = "".join((a, b, c, d))
    if ("AGC" in s) or ("ACG" in s) or ("GAC" in s):
        return False
    if (s[0] == "A" and s[2:4] == "GC") or (s[0:2] == "AG" and s[3] == "C"):
        return False
    return True


def main():
    N = int(input())

    dp = [defaultdict(int) for _ in range(N + 1)]
    dp[0][("T", "T", "T")] = 1

    for i in range(N):
        for a, b, c, d in product("ACGT", repeat=4):
            if is_ok(a, b, c, d):
                dp[i + 1][(b, c, d)] = (dp[i + 1][(b, c, d)] + dp[i][(a, b, c)]) % P

    ans = 0
    for v in dp[N].values():
        ans = (ans + v) % P
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
	int N,L;
	cin >> N >> L;
	int sum=(L-1)*N+(1+N)*N/2;

	if(L>0) sum-=L;
	else if(L+N-1<0) sum-=L+N-1;
	cout << sum << endl;
}

Measured memory_bytes: 256
loop do
    n = gets.to_i
    break if n == 0
    a = gets.split.map(&:to_i)
    table = (0..n-1).map { [0] * n }
    (1..n-1).each do |d|
        (0..n-1-d).each do |l|
            r = l + d
            if d == 1
                table[l][r] = ( (a[l] - a[r]).abs <= 1 ? 2 : 0 )
            else 
                table[l][r] = table[l+1][r-1] + 2 if (a[l] - a[r]).abs <= 1 && table[l+1][r-1] == r - l - 1
                (l..r-1).each do |i|
                    m = table[l][i] + table[i+1][r]
                    table[l][r] = m if m > table[l][r]
                end
            end
        end
    end
    p table[0][n-1]
end

Measured memory_bytes: 10180
x1,y1,x2,y2 = gets.split.map(&:to_i)

if x1 < x2
  if y1 < y2
    puts "#{x2-(y2-y1)} #{y2+(x2-x1)} #{x1-(y2-y1)} #{y1+(x2-x1)}"
  else
    puts "#{x2+(y1-y2)} #{y2+(x2-x1)} #{x1+(y1-y2)} #{y1+(x2-x1)}"
  end
else
  if y1 < y2
    puts "#{x2-(y2-y1)} #{y2-(x1-x2)} #{x1-(y2-y1)} #{y1-(x1-x2)}"
  else
    puts "#{x2+(y1-y2)} #{y2-(x1-x2)} #{x1+(y1-y2)} #{y1-(x1-x2)}"
  end
end
  

Measured memory_bytes: 1788
#include<stdio.h>

int main(){
  int n; scanf("%d",&n);
  int mae; scanf("%d",&mae);
  int s=mae;
  if(n==2) printf("%d\n",2*mae);
  else{
  for(int i=0; i<n-1; i++){
    int usi; scanf("%d",&usi);
    if( mae<usi) s+=mae;
    else s+=usi;
    mae=usi;
  }
  printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
using namespace std;
#define int long long
typedef pair<int, int> P;

signed main() {
	string s;
	cin >> s;
	
		int wa = s.size();
		int ans = 114514;
		for (int i = 0; i < s.size()-1; i++) {
			if (s[i] != s[i + 1])ans = min(ans, max(i+1, wa-i-1));
		}
		if (ans == 114514)cout << s.size() << endl;
		else cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	String a = sc.next();
      String b = sc.next();
      if(a.charAt(0)==b.charAt(2)&& a.charAt(1)==b.charAt(1)&&a.charAt(2)==b.charAt(0)){
     	System.out.println("YES");
      }else{
      System.out.println("NO");
      }
		
    }
}


Measured memory_bytes: 23252
#include <stdio.h>
#include <limits.h>

int
main(void)
{
    int i, n, tmp, max = INT_MIN, min = INT_MAX;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; ++i) {
        scanf("%d", &tmp);
        if(max < tmp - min) max = tmp - min;
        if(min > tmp) min = tmp;
    }
    
    printf("%d\n", max);
}




Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>v, sum, odd;
int n, q;
void init(){
	v.resize(n+1);
	sum.resize(n+1);
	odd.resize(n+1);
	sum[0]=0ll; odd[0]=0ll;
}
int main(){
	scanf("%d %d", &n, &q);
	init();
	for(int i=0; i<n; i++){
		scanf("%lld", &v[i]);
		sum[i+1]=sum[i]+v[i];
		odd[i+1]=odd[i]+(i%2==1? v[i]:0ll);
	}
	v[n]=1e9+1;
	for(int qq=0; qq<q; qq++){
		int x; scanf("%d", &x);
		int l=0, r=n, md;
		while(l+1<r){
			int md=(l+r)/2;
			if(n<=2*md || x-v[n-2*md-1]>v[n-md-1]-x)
				r=md;
			else l=md;
		}
		if(n<=2*l || x-v[n-2*l-1]>v[n-l-1]-x) r=0;
		else{
			r=1; l++;
		}
		ll ans=sum[n]-sum[n-l];
		if(n%2==1){
			ans+=sum[n-2*l+r]-odd[n-2*l+r];
		}else{
			ans+=odd[n-2*l+r];
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1e9+7 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

const int MAX = 2000000 ;

//宣言するときはstaticをつけて静的変数にするかグローバル変数として宣言
//initのときに関数の種類を決定する（0:sum,1:min,2:max,3:gcd）
class SGT{
public :
	int n = 1;
	ll d ;
	ll num[MAX] ;
	int fan ;

//	指定された関数を実行する
	ll f(ll a,ll b){
		if(fan==0) return a+b ;
		else if(fan==1) return min(a,b) ;
		else if(fan==2) return max(a,b) ;
		else if(fan==3) return gcd(a,b) ;
		else return d ;
	}

	void d_set(int b){
		fan = b ;
		if(fan==0) d = 0 ;
		else if(fan==1) d = INF ;
		else if(fan==2) d = -INF ;
		else if(fan==3) d = 0 ;
	}

//	初期化する、bは関数の種類を指定する
	void init(vector<ll> &a,int b){
		d_set(b) ;
		while(a.size()>n) n *= 2 ;
		for(int i=0;i<n;i++){
			if(i<a.size()) num[n-1+i] = a.at(i) ;
			else num[n-1+i] = d ;
		}
		for(int i=n-2;i>=0;i--){
			num[i] = f(num[i*2+1],num[i*2+2]) ;
		}
	}

	void init(ll a,ll sz,int b){
		d_set(b) ;
		while(sz>n) n *= 2 ;
		for(int i=0;i<n;i++){
			if(i<sz) num[n-1+i] = a ;
			else num[n-1+i] = d ;
		}
		for(int i=n-2;i>=0;i--){
			num[i] = f(num[i*2+1],num[i*2+2]) ;
		}
	}

//	内容次第でwhile内の計算式を書き換える→書き換えなくて良くなった
	void update(int i,ll a){
		i += n-1 ;
		num[i] = a ;
		while(i>0){
			i = (i-1)/2 ;
			num[i] = f(num[i*2+1],num[i*2+2]) ;
		}
	}

//	最初に呼び出すときは[a,b)だけで十分
	ll query(int a,int b,int l=0,int r=-1,int now=0){
		if(r==-1) r = n ;
		if(r<=a||b<=l) return d ;
		if(a<=l&&r<=b) return num[now] ;
		ll r1 = query(a,b,l,(l+r)/2,now*2+1) ;
		ll r2 = query(a,b,(l+r)/2,r,now*2+2) ;
		return f(r1,r2) ;
	}
};

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	ll ans = 0 ;
	static SGT sgt ;
	sgt.init(a,3) ;
	for(int i=0;i<n;i++){
		ans = max(ans,gcd(sgt.query(0,i),sgt.query(i+1,n))) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 6168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) a[i] = in.nextInt();
		int[] b = new int[n];
		for(int i=0;i<n;i++) b[i] = in.nextInt();
		int[] c = new int[n];
		for(int i=0;i<n-1;i++) c[i] = in.nextInt();
		int ans = b[a[0]-1];
		int pre = a[0];
		for(int i=1;i<n;i++) {
			ans += b[a[i]-1];
			if(pre+1==a[i]) ans += c[a[i]-2];
			pre = a[i];
		}
		System.out.print(ans);
		
		in.close();

	}

}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef vector<vector<int> > mat;
int h,w,n;
inline void mat_mul(mat &A, mat &B, int M=1000000009){
  mat ret(w,vector<int>(w));
  for(int i = 0; i < w; ++i){
    for(int j = 0; j < w; ++j){
      ret[i][j] = 0;
      for(int k = 0; k<w; ++k){
        ret[i][j] += (A[i][k]*B[k][j])%M;
        ret[i][j] %= M;
      }
    }
  }
  A=ret;
}
  
inline mat mat_pow(mat &A, int N, int M=1000000009){
  mat ret(A.size(),vector<int>(A.size(),0)), t = A;
  for(int i = 0; i < A.size(); ++i) ret[i][i] = 1;
  int k = 0;
  while(N>0){
    if(N&1){
      mat_mul(ret,t,M);
    }
    mat_mul(t,t,M);
    N>>=1;
  }
  return ret;
}
  
mat XXX;
  
void init(){
    mat res(w,vector<int>(w,0));
    for(int i=0;i<w;i++){
        for(int j=0;j<w;j++){
            if(i==j){
                if(i)res[i-1][j]=1;
                res[i][j]=1;
                if(i!=w-1)res[i+1][j]=1;
            }
        }
    }
    XXX=res;
}
  
  
inline mat make_mat(vector<int> &V){
    mat res=XXX;
    for(int i=0;i<V.size();i++){
        for(int j=0;j<w;j++){
            res[j][V[i]]=0;
        }
    }
    return res;
}
  
signed main(){
    init();
    int cnt=0;
    while(cin>>w>>h>>n,w){
        init();
        cout<<"Case "<<(++cnt)<<": ";
        vector<P>v;
        vector<int>v1;
        r(i,n){
            int x,y;
            cin>>x>>y;
            x--;y--;
            if(y==0)v1.push_back(x);
            else v.push_back(P(y,x));
        }
        v.push_back(P(1e18+1,0));
        int y=0;
        sort(v.begin(),v.end());
        mat A(w,vector<int>(w,0));
        A[0][0]=1;
        r(i,v1.size())A[v1[i]][v1[i]]=0;
        for(int i=0;i<v.size();i++){
            int s=v[i].first;
            int c=s-y;
            vector<int>vs,kara;
            vs.push_back(v[i].second);
            while(v[i].first==v[i+1].first){
                vs.push_back(v[i+1].second);
                i++;
            }
            mat B=make_mat(vs);
            mat C=make_mat(kara);
            if(s==1e18+1){
                c=(h-1)-y;
                if(c){
                    C=mat_pow(C,c);
                    mat_mul(A,C);
                }
                break;
            }
            if(c>1){
                C=mat_pow(C,c-1);
                mat_mul(A,C);
            }
            mat_mul(A,B);
            y=s;
        }
        int ans=0;
        r(i,w)ans=(ans+A[i][w-1])%1000000009;
        cout<<ans<<endl;
    }
}


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

int main(){
    int n;
    cin >> n;
    int x[20][20];
    int y[20][20];
    int a[20];
    bool all_not_told = true;
    for(int i = 1;i <= n; i++){
        cin >> a[i];
        if(a[i] > 0) all_not_told = false;
        for(int j = 1;j <= a[i]; j++){
            cin >> x[i][j] >> y[i][j];
        }
    }
    
    if(all_not_told){
        cout << n << endl;
        return 0;
    }

    if(n == 1){
        cout << 1 << endl;
    }

    int max_honest_count = 0;
    // {0, 1, ..., n-1} の部分集合の全探索
    for(int bit = 1; bit < (1<<n); ++bit){        
        bool ishonest[20];
        for(int i = 1;i <= n; i++){
            ishonest[i] = false;
        }

        int honest_count = 0;
        for(int i = 0;i < n; i++){
            if(bit & (1<<i)) { // i が bit に入るかどうか
                ishonest[i+1] = true;
                honest_count++;
            }
        }
        
        bool contradiction = false;
        for(int i = 1;i <= n; i++){
            if(!ishonest[i]) continue;
            for(int j = 1;j <= a[i]; j++){
                if(y[i][j] == 1){   //honest
                    if(!ishonest[x[i][j]]){
                        contradiction = true; 
                    }
                }else{  //not know whether honest or a lier
                    if(ishonest[x[i][j]]){
                        contradiction = true;
                    }
                }
            }
        }

        if(!contradiction) max_honest_count = max(honest_count, max_honest_count);
    }
    cout << max_honest_count << endl;
    return 0;
}

Measured memory_bytes: 3192
use proconio::input;

fn main() {
  input! {
    n: usize,
  }
  let mut patterns:Vec<Vec<usize>> = vec![vec![10;n];n];
  for i in 0..n {
    input! {
      p: usize,
    }
    
    for _ in 0..p {
      input! {
        a: usize,
        b: usize
      }
      patterns[i][a-1] = b;
    }
  }

  let max = 2usize.pow(n as u32);
  let mut result = 0;
  for i in 1..=max {
    let mut memo = vec![0;n];
    let mut count = 0;
    for index in 0..n {
      if i>>index & 1 == 1 {
        memo[index] = 1;
        count += 1;
      }
    }
    
    let mut success = true;
    for index in 0..n {
      if memo[index] != 1 {
        continue
      }

      for (i, v) in patterns[index].iter().enumerate() {
        if *v == 10 { continue }
        if memo[i] != *v {
          success = false;
          break;
        }
      }
      if !success {
        break
      }
    }

    if success {
      result = std::cmp::max(result, count);
    }
  }
  println!("{}", result);
}

Measured memory_bytes: 2168
from itertools import permutations

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

visit = list(map(int, input().split()))
g = [[float('inf')] * N for _ in range(N)]
for i in range(N):
    g[i][i] = 0

for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    g[a][b] = c
    g[b][a] = c


def dijkstra(start):
    c_l = [float('inf')] * N
    c_l[start] = 0
    visited = [False] * N
    while True:
        min_v = float('inf')
        next = -1
        visited[start] = True
        for i in range(N):
            if visited[i]:
                continue
            if g[start][i]:
                d = c_l[start] + g[start][i]
                if d < c_l[i]:
                    c_l[i] = d
                if min_v > c_l[i]:
                    min_v = c_l[i]
                    next = i
        start = next
        if next == -1:
            break
    return c_l


cost_list = []
for i in range(N):
    cost_list.append(dijkstra(i))

cost = float('inf')
for town in permutations(visit):
    c = 0
    for i in range(R - 1):
        c += cost_list[town[i] - 1][town[i + 1] - 1]
    cost = min(cost, c)
print(cost)


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n, vector<int>());
	vector<int> deg(n);
	vector<int> a(n + m - 1), b(n + m - 1);
	rep(i, n + m - 1) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[b[i]].push_back(a[i]);
		deg[a[i]]++;
	}
	queue<int> que;
	rep(i, n) if (deg[i] == 0) que.push(i);
	vector<int> order;
	while (!que.empty()) {
		int v = que.front(); que.pop();
		order.pb(v);
		for (int i : graph[v]) {
			deg[i]--;
			if (deg[i] == 0) que.push(i);
		}
	}
	reverse(all(order));
	vector<int> rorder(n);
	rep(i, n) rorder[order[i]] = i;
	vector<int> ans(n, -1);
	rep(i, n + m - 1) {
		chmax(ans[b[i]], rorder[a[i]]);
	}
	rep(i, n) {
		if (ans[i] == -1) cout << 0 << endl;
		else cout << order[ans[i]] + 1 << endl;
	}
}

Measured memory_bytes: 12020
from bisect import bisect
from sys import setrecursionlimit

setrecursionlimit(10000000)

N = int(input())
A = tuple(map(int,input().split()))
adj = [list() for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    adj[a].append(b)
    adj[b].append(a)


res = [None]*N
dp = [float('inf') for _ in range(N)]

def rec(v, ml):
    """
    dp[l]: min tail value of increasing subsequence of length l+1
    """
    a = A[v]
    i = bisect(dp, a-1)
    ml += int(ml == i)
    res[v] = ml

    orig = dp[i]
    dp[i] = a
    for u in adj[v]:
        if res[u] is None:
            rec(u, ml)
    dp[i] = orig

rec(0, 0)

print(*res, sep='\n')


Measured memory_bytes: 231224
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n,a,b,t;
  cin >> a >> b;
  if(b==100) n=a*1000+b;
  else if(b>=10) n=a*100+b;
  else n=a*10+b;
  t=(int)sqrt(n);
  if(t*t==n)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if ((i + 1) % 2 == 1 && a.at(i) % 2 == 1) count++;
  }
  cout << count << endl;
  return 0;
}

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        vector<vector<vector<_i64>>> room(4, vector<vector<_i64>>(3, vector<_i64>(10, 0)));
        _i64 n, b, f, r, v;  const string pause(20, '#'); cin >> n;
        _rep(i, n){ cin >> b >> f >> r >> v; room[b - 1][f - 1][r - 1] += v; }
        _rep(i, 4) {
            _rep(j, 3) { _rep(k, 10) { cout << " " << room[i][j][k]; } cout << endl; }
            if(i != 3) { cout << pause << endl; }
        }
    }
    return 0;
}


Measured memory_bytes: 3220
#include<cstdio>
#define mod 1000000007
#define maxn 405
int n,c,a[maxn],b[maxn],dp[maxn][maxn],pw[maxn][maxn];
int main()
{
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	for(int i=1;i<=400;i++)
	{
		pw[i][0]=1;
		for(int j=1;j<=400;j++) pw[i][j]=1ll*pw[i][j-1]*i%mod;
	}
	for(int i=1;i<=400;i++)
		for(int j=0;j<=400;j++)
			pw[i][j]=(pw[i][j]+pw[i-1][j])%mod;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			for(int k=0;k<=j;k++) 
				dp[i][j]=(dp[i][j]+1ll*dp[i-1][j-k]*(pw[b[i]][k]-pw[a[i]-1][k])%mod)%mod;
	printf("%d\n",(dp[n][c]+mod)%mod);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
int main()
{
	int a,n,d,l;
	int b;
	scanf("%d%d",&n,&d);
	l=d * 2+1;
	b=n/l;
	if(n%l==0)
	{
		printf("%d",b);
	}
	else{ printf("%d",b+1);
	}
	return 0;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int fac(int num) {
  if(num==1) return 1;
  else return num*fac(num-1);
}


map<ll,ll> idx;
vector<bool> prime(200,true);




ll rec(map<ll,ll>::iterator p, ll mul) {
  if(p == idx.end()) {
    if(mul == 1) return 1;
    else return 0;
  }
  ll res = 0;
  for(int i=0; i < p->second+1; i++) {
    if(mul % (i+1) != 0) continue;
    res += rec(++p,mul/(i+1));
    --p;
  }
  return res;
}



int main() {
  ll N;cin >> N;
  prime[0] = false;
  prime[1] = false;
  for(int i=2; i <= 100; i++) {
    if(prime[i]) {
      for(int j=i+i; j <= 100; j+=i) {
	prime[j] = false;
      }
    }
  }
  
  for(int i=2; i<=N; i++) {
    if(prime[i]) {
      int j=1;
      ll tmp = 0;
      while(N/pow(i,j)) {
	tmp += N/pow(i,j);
	j++;
      }
      idx[i] = tmp;
    }
  }

  

  // for(auto itr : idx) cout << itr.first << " : " << itr.second << endl;
  cout << rec(idx.begin(),75) << endl;
  
  return 0;
}


Measured memory_bytes: 512
using System;

namespace Project
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            char[] s = Console.ReadLine().ToCharArray();
            int k = int.Parse(Console.ReadLine());
            char r = s[k - 1];
            string res = "";
            foreach(char c in s)
            {
                if(c == r)
                {
                    res += c;
                }else
                {
                    res += "*";
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11092
def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    cnt = 0
    for r in range(N + 1):
        for g in range(N + 1 - (R * r)):
            if (N - (R * r) - (G * g)) % B == 0 and N - (R * r) - (G * g) >= 0:
                cnt += 1
 
    print(cnt)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 39280
# https://atcoder.jp/contests/arc068/tasks/arc068_b

from collections import Counter

n = int(input())
A = list(map(int, input().split()))

if len(set(A)) == n:
    print(n)
    exit()

cA = Counter(A)

if len(cA) % 2 == 0:
    print(len(cA) - 1)
else:
    print(len(cA))

Measured memory_bytes: 58796
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int count = 0;
        int max_count = 0;
        for (int i = 0; i < N; i++) {
            int d1 = scan.nextInt();
            int d2 = scan.nextInt();
            if (d1 == d2) {
                count += 1;
                max_count = Math.max(max_count, count);
            } else {
                count = 0;
            }
        }
        if (3 <= max_count) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 36028
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
	long long n, num, price, sale;

	while(cin>>n, n!=0){
		vector<long long> vec(4001, 0);
		vector<int> a;
		while(n--){
			cin>>num>>price>>sale;
			if(find(a.begin(), a.end(), num)==a.end())a.push_back(num);
			vec[num] += price*sale;
		}
		int count=0;
		for(int i=0; i<a.size(); i++){
			if(vec[a[i]] >= 1000000){
				cout<<a[i]<<"\n";
				count++;
			}
		}
		if(!count)cout<<"NA\n";
	}	
	return 0;
}

Measured memory_bytes: 1252
//25
#include<iostream>
#include<string>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    string ice[10];
    while(n--){
      int i;
      cin>>i;
      ice[i]+='*';
    }
    for(int i=0;i<10;i++){
      if(ice[i].empty()){
	cout<<'-'<<endl;
      }else{
	cout<<ice[i]<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
int find(vector<int>& grp, int x) {
    if (grp[x] == x)
        return grp[x];
    return grp[x] = find(grp, grp[x]);
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> arr(n, 0);
    for(int& val: arr) {
        cin >> val;
        val -= 1;
    }
    vector<int> grp(n, 0);
    for(int i = 0; i < n; i++) {
        grp[i] = i;
    }
    int x, y;
    for(int i = 0; i < m; i++) {
        cin >> x >> y;
        x--; y--;
        int r1 = find(grp, x);
        int r2 = find(grp, y);
        if (r1 != r2) {
            grp[r1] = grp[r2] = min(r1, r2);
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if (find(grp, arr[i]) == find(grp, i))
            ans += 1;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	double r,s,l,x;
	scanf("%lf",&r);
	
	x=3.141592653589;
	s=x*r*r;
	l=2*x*r;
	
	printf("%.5f %.5f\n",s,l);
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
using namespace std;

int n;
map<int,int> m;

void solve()
{
    cin>>n;
    for(int i=1;i<=500;i++)
    {
        for(int j=1;j<=500;j++)
        {
            for(int k=1;k<=500;k++)
            {
                int p=i*i+j*j+k*k+i*j+j*k+k*i;
                if(p<=1e4) m[p]++;
            }
        }
    }
    for(int i=1;i<=n;i++) cout<<m[i]<<endl;
}

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

Measured memory_bytes: 4008
N = int(input())
S = input()

nr = 0
ng = 0
nb = 0

for i in range(0, N):
    if S[i] == "R":
        nr += 1
    elif S[i] == "G":
        ng += 1
    else:
        nb += 1

count = 0

for i in range(0, N-2):
    for j in range(i+1, N-1):
        k = j + (j - i)
        if k < N and ord(S[i]) + ord(S[j]) + ord(S[k]) == ord("R") + ord("G") + ord("B"):
            count += 1

print(nr*ng*nb - count)

Measured memory_bytes: 72168
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

void canP(bool x){
    if(x){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
}
int main(){
    int n; cin >> n;
    int v[n],c[n];
    int ans = 0;
    rep(i,n){
        cin >> v[i];
    }

    rep(i,n){
        cin >> c[i];
    }

    rep(i,n){
        if (v[i] - c[i] >= 0) ans += v[i] - c[i];
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cctype>
#include<iomanip>
#include<iostream>
#include<map>
#include <queue>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define each(e, v) for (auto&& e : v)
#define clamp(v,lo,hi) min(max(v,lo),hi)
#define debug(i) cout<<"point :"<< i << endl;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define all(a) a.begin(),a.end()
typedef long long LL;
typedef vector<int> vint;
typedef vector<long> vl;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef map<string, int> mapstri;
typedef map<int, int> mapii;
typedef std::pair<int, int> pairii;

int main () {
    string s;
    cin >> s;
    if (s != "AAA" && s != "BBB") {
        out("Yes")
    } else {
        out("No")
    }
    return 0;
}

Measured memory_bytes: 256