akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

#define forit(v) for(auto it = v.begin(); it != v.end(); ++it)

using namespace std;

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  flag = true;

  int n; cin >> n;
  string s; cin >> s;
  int x = 0;
  forit(s) {
    if (*it == 'I') ++x;
    else --x;
    num = max(x, num);
  }
  
  cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

//累乗 べき乗
long power(long a, long b){
	if(b == 0){
		return 1;
	}else if(b % 2 == 1){
		return a * power(a, b-1);
	}else{
		long r = power(a, b/2);
		return r*r;
	}
}
long power(long a, long b, long MOD){
	if(b == 0){
		return 1l;
	}else if(b % 2 == 1){
		return a * power(a, b-1, MOD) % MOD;
	}else{
		long r = power(a, b/2, MOD);
		return r * r % MOD;
	}
}

long m, n;
const long MOD = 1000000007;

int main(){
    scanf("%ld%ld", &m, &n);
    printf("%ld\n", power(m, n, MOD));
}



Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		if (S.equals("AAA") || S.equals("BBB")) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		sc.close();
	}
}

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

int main() {
    string S;
    
    cin >> S;
    if (S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'R') {
        cout << "3" << endl;
    }
    else if ((S.at(0) == 'R' && S.at(1) == 'R') || (S.at(1) == 'R' && S.at(2) == 'R')) {
        cout << "2" << endl;
    }
    else if (S.at(0) == 'S' && S.at(1) == 'S' && S.at(2) == 'S') {
        cout << "0" << endl;
    }
    else {
        cout << "1" << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,k;
  cin>>n>>k;
  int cur;
  double base=(double)1/n;
  double prob=0.5;
  double temp=0.0;
  double ans=0.0;
  REPP(i,n){
    cur = i;
    temp = base;
    if(i<=k-1){
      while(cur<k){
        cur *= 2;
        temp *= prob;
      }
    }
    ans += temp;
    temp = 0.0;
  }
  printf("%.10f",ans);
  return 0;
}

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

using namespace std;

int main() {
	int n;
	while ( cin >> n, n ) {
		double v[1000];
		for (int i = 0; i < n; ++i) cin >> v[i];

		double m = 0;
		for (int i = 0; i < n; ++i) m += v[i];
		m /= n;

		double s = 0;
		for (int i = 0; i < n; ++i) s += (v[i] - m) * (v[i] - m);
		s = sqrt(s / n);

		printf("%.10f\n", s);
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    REP(i, n) cin >> L[i];
    sort(L.begin(), L.end(), greater<int>());
    int sum = 0;
    for(int i = 1; i < n; i++) {
        sum += L[i];
    }
    cout << (sum > L[0] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    string s;
    cin >> s;
    if(s.size() == 6 && s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
V = Array.new(N + 1, 0)
M.times do
  a,b = gets.split.map(&:to_i)
  V[a] += 1
  V[b] += 1
end
puts V.all?(&:even?) ? 'YES' : 'NO'

Measured memory_bytes: 2556
import numpy

N = int(input())

S = [[x for x in input()] for _ in range(N)] 

S_mat = numpy.mat(S)

ret = 0
for A in range(N):
    A_change_list = list(range(A, N))
    A_change_list.extend(list(range(A)))
    moved = S_mat[A_change_list, :]
    if numpy.all(moved == moved.T):
        ret +=1
print(N*ret)



Measured memory_bytes: 14336
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	int a, b, c, k;
	
	cin >> a >> b >> c >> k;
	
	if (a < b){
		if (b < c) REP(i,k) c *= 2;
		else REP(i,k) b *= 2;
	}
	else {
		if (a > c) REP(i,k) a *= 2;
		else REP(i,k) c *= 2;
	}
	
	int sum = a + b + c;
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void)
{
	int A, B, C;
	cin >> A >> B >> C;
 
	int cnt = 0;
	while (true) {
if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			cout << cnt << endl;
			break;
		}
		if (A == B && B == C) {
			cout << "-1" << endl;
			break;
		}
		
		int tmp1 = A;
		int tmp2 = B;
		A = tmp2 / 2 + C / 2;
		B = tmp1 / 2 + C / 2;
		C = tmp1 / 2 + tmp2 / 2;
		++cnt;
	}
 
	return 0;
}

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

const int inf = 100000;

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n + 1][10 * n + 1][10 * n + 1];
    for (int i = 0; i <= n; i++) for (int j = 0; j <= 10 * n; j++) for (int k = 0; k <= 10 * n; k++) dp[i][j][k] = inf;
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j <= 10 * n; j++) for (int k = 0; k <= 10 * n; k++) {
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
        if (j + a[i] <= 10 * n && k + b[i] <= 10 * n) {
            dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
        }
    }
    int ans = inf;
    for (int j = 1; j <= 10 * n; j++) for (int k = 1; k <= 10 * n; k++) {
        if (dp[n][j][k] < ans && ma * k == mb * j) ans = dp[n][j][k];
    }
    if (ans == inf) ans = -1;
    cout << ans << endl;;
    return 0;
}

Measured memory_bytes: 25984
#include <iostream>
#include <string>
#include <vector>
#define m 1000000007;

using namespace std;

int main()
{
	int h, w;
	string s;
	cin >> h >> w;

	vector<string> V;
	for (int i = 0; i < h; i++) {
		cin >> s;
		V.push_back(s);
	}
	
	vector<vector<int>> dp(h, vector<int>(w, 0));
	dp[0][0] = 1;
	for (int i = 0; i < w; i++) {
		for (int k = 0; k < h; k++) {
			if (V[k][i] == '.') {
				if (k != 0) {
					if (V[k-1][i] == '.') {
						dp[k][i] += dp[k-1][i];
						dp[k][i] %= m;
					}
				}
				if (i != 0) {
					if (V[k][i-1] == '.') {
						dp[k][i] += dp[k][i-1];
						dp[k][i] %= m;
					}
				}
			}
		}
	}
	cout << dp[h - 1][w - 1];
}


Measured memory_bytes: 5248
<?php
list($n,$m,$q)=explode(" ",trim(fgets(STDIN)));
$i=0;
while($i<$q){
  list($a[],$b[],$c[],$d[])=explode(" ",trim(fgets(STDIN)));
  ++$i;
}
$ans=0;
$arr[]=1;
dfs($arr);
echo $ans;

function dfs($arr){
  global $n,$m,$q,$ans,$a,$b,$c,$d;
  if(count($arr)==$n){
    $now=0;
    $i=0;
    while($i<$q){
      if($arr[$b[$i]-1]-$arr[$a[$i]-1]==$c[$i]){
        $now+=$d[$i];
      }
      ++$i;
    }
    $ans=max($ans,$now);
    return;
  }
  //よくわからん
  $arr[]=$arr[count($arr)-1];
  while($arr[count($arr)-1]<=$m){
   dfs($arr);
    ++$arr[count($arr)-1];
  }
}

Measured memory_bytes: 16172
#include <stdio.h>
#define NIL -1
int F[44];
int fib(int n)
{
  if(n==0||n==1)
    {
      return F[n] = 1;
    }
  if(F[n]!=-1)return F[n];
  return F[n]=fib(n-2)+fib(n-1);
}

int main()
{
  int n,i;
  scanf("%d",&n);
  for(i=0;i<=n;i++)
    {
      F[i]=NIL;
    }
  printf("%d\n",fib(n));

  return 0;
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define MODNUM 1000000007
#define lp(i,a,b) for(ll i=a; i<b; i++)
#define all(v) v.begin(), v.end()

using namespace std;
 
ll mex(ll a, ll b, ll m) {
	if(b==0) return 1;
	if(b%2) return a*mex((a*a)%m,(b-1)/2,m)%m;
	else return mex((a*a)%m,b/2,m);
}
 
int x,y;
void exteu(ll a, ll m) {
	if(m==0) { x=1;y=0; }
	else {
		exteu(m,a%m);
		ll temp = x;
		x=y;
		y=temp-(a/m)*y;
	}
}
 
ll fact(ll n) 
{	ll prod=1;
	for(ll i=2; i<=n; i++) {
		prod*=i;
	}
	return prod;
}
 
ll gcd(ll a, ll b) {
	if(b==0) return a;
	return gcd(b, a%b);
}
 
// bool isprime[100001];
// void makesieve() {
// 	memset(isprime, true, sizeof(isprime));
// 	for (int i = 2; i <= sqrt(200000); ++i)
// 	{
// 		if(isprime[i]) {
// 			for (int j = i*i; j <= 200000; j+=i)
// 			{
// 				isprime[j]=false;
// 			}
// 		}
// 	}
// }
// 
// 1 2 4 5 8
vvll D = {{-1,-1}, {1,1}, {1,-1}, {-1,1}};
void solve() {
	ll n; cin>>n;
	vll a(n); lp(i,0,n) cin>>a[i];
	sort(all(a), greater<int>());
	// vll c(n,-1);
	vll dp;
	ll s = a[0];
	dp.pb(a[0]); dp.pb(a[1]); dp.pb(a[0]);
	for (int i = 2; i < n;)
	{
		vll dp2; dp2.pb(a[0]);
		for (int j = 1; j < dp.size() && i<n; ++j)
		{
			s += min(dp[j], dp[j-1]);
			dp2.pb(a[i++]);
			dp2.pb(dp[j]);
		}
		dp = dp2;
	}
	cout<<s;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1;
	// cin >> TESTS;
	// makesieve();
	while(TESTS--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 10120
#include<iostream>
#include<vector>
#define NIL -1
using namespace std;

int fib(vector<int>& F, int n){
    if (F[n] != NIL) return F[n];
    return F[n] = fib(F, n - 1) + fib(F, n - 2);
}

int main(){
    int n;
    cin >> n;
    vector<int> F(n + 1, NIL);
    F[0] = F[1] = 1;
    cout << fib(F, n) << endl;
    return 0;
}

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

int main(){

    int N, result=0;
    string str;
    cin >> N >> str;

    for(int i=1; i<N;i++){
        
        int count = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            bool xflag=false, yflag=false;

            for (int j=0; j<i; j++){
                if (str[j] == c)
                    xflag=true;
            }

            for (int j=i; j<N; j++){
                if (str[j] == c)
                    yflag=true;
            }

            if (xflag && yflag)
                count++;

        }
        if (result < count)
            result = count;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
INF = 10**18
dp = [INF] * (N+1)
dp[0] = 0

for i in range(1, N+1):
    dp[i] = min(dp[i], dp[i-1]+1)
    p = 6
    while p <= i:
        dp[i] = min(dp[i], dp[i-p]+1)
        p *= 6
    p = 9
    while p <= i:
        dp[i] = min(dp[i], dp[i-p]+1)
        p *= 9
print(dp[N])

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

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int A,B;

void solve(){
    if(A > B) cout << "Alice" << endl;
    else if(A < B) cout << "Bob" << endl;
    else cout << "Draw" << endl;
}

int main(){
    cin >> A >> B;
    if(A == 1) A += 13;
    if(B == 1) B += 13;    
    solve();
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	string S;
	int N, K;
	cin >> N >> K >> S;
	S[K - 1] = tolower(S[K - 1]);
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100500;
const int ALEF = 26;

int cnt[ALEF];
int n, m;

bool check() 
{

	if (n % 2 == 0 && m % 2 == 0) {
		bool ok = true;
		for (int i = 0; i < ALEF; i++) {
			ok &= cnt[i] % 4 == 0;
		}
		return ok;
	}

	if (n % 2 == 1 && m % 2 == 1) {
		vector <int> odd;
		for (int i = 0; i < ALEF; i++) {
			if (cnt[i] % 2 == 1)
				odd.push_back(i);
		}
	
		if (odd.size() != 1)
			return false;
		cnt[odd[0]]--;
		int sum = 0;
		for (int i = 0; i < ALEF; i++) {
			sum += cnt[i] % 4;
		}

		return sum <= n - 1 + m - 1;
	}

	if (m % 2 == 0)
		swap(n, m);

	vector <int> odd;
	for (int i = 0; i < ALEF; i++) {
		if (cnt[i] % 2 == 1)
			odd.push_back(i);
	}

	if (odd.size() != 0)
		return false;

	int sum = 0;
	for (int i = 0; i < ALEF; i++) {
		sum += cnt[i] % 4;
	}

	return sum <= n;
}

int main()
{                                                     
	// ios_base::sync_with_stdio(0);
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		// cout << s << '\n';
		for (int j = 0; j < m; j++) {
			cnt[s[j] - 'a']++;
		}
	}	

	cout << (check() ? "Yes\n" : "No\n");
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main(){
	char s[60];
	int ma,n,W,dp1[310],dp2[310],dp3[310],w[310],v[310],d[310],l[310];
	while(cin>>n>>W){
		ma=0;
		for(int i=0;i<n;i++){
			fgets(s,60,stdin);fgets(s,60,stdin);
			cin>>w[i]>>v[i]>>d[i]>>l[i];
			if(ma<w[i])
				ma=w[i];
		}
		for(int i=0;i<=W;i++){
			dp1[i]=0;
			dp2[i]=0;
			dp3[i]=0;
		}
		for(int i=0;i<n;i++)
		for(int j=w[i];j<=W;j++){
				dp1[j]=max(dp1[j],dp1[j-w[i]]+v[i]);
				dp2[j]=max(dp2[j],dp2[j-w[i]]+d[i]);
				dp3[j]=max(dp3[j],dp3[j-w[i]]+l[i]);
		}
		
		cout<<max(max(dp1[W],dp2[W]),dp3[W])<<endl;
	}
	return 0;
}

Measured memory_bytes: 876
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String Q[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
      int P = Arrays.asList(Q).indexOf(S); //Arrays.aslist → 配列をリスト化
      System.out.println(7-P);
    }
}      

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

using namespace std;

int main(void) {
  int sx, sy, tx, ty;

  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

  for(int i = 0; i < ty - sy; i++) {
    printf("U");
  }
  for(int i = 0; i < tx - sx; i++) {
    printf("R");
  }

  for(int i = 0; i < ty - sy; i++) {
    printf("D");
  }
  for(int i = 0; i < tx - sx; i++) {
    printf("L");
  }

  printf("L");
  for(int i = 0; i < ty - sy + 1; i++) {
    printf("U");
  }
  for(int i = 0; i < tx - sx + 1; i++) {
    printf("R");
  }
  printf("D");

  printf("R");
  for(int i = 0; i < ty - sy + 1; i++) {
    printf("D");
  }
  for(int i = 0; i < tx - sx + 1; i++) {
    printf("L");
  }
  printf("U");

  printf("\n");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	if(a<b){
	System.out.println("a < b");
	}else if(a>b){
	System.out.println("a > b");
	}else{
	System.out.println("a == b");
	}
	}
}

Measured memory_bytes: 26052
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int a, b;

int main() { 

  cin >> a >> b;

  for (int i = 1; i <= 10000; i++) {
    int f = i * 8 / 100, s = i * 10 / 100;
    if (f == a && s == b) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll a[n];rep(i,0,n)cin>>a[i];
    ll now=0;
    rep(i,0,n){
        if(a[i]==now+1){
            now++;
        }
    }
    if(now==0)cout<<-1<<endl;
    else cout<<n-now<<endl;
}


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

using namespace std;

int main(){
	int n, k;
	vector<int> a;
	vector<bool> dp;
	cin>>n>>k;
	a.assign(n+1, 0);
	dp.assign(k+1, false);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i-a[j] >= 0)
				dp[i] = dp[i]|(!dp[i-a[j]]);
		}
	}
	(dp[k] == 1)?cout<<"First\n":cout<<"Second\n";
	return 0;
}

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

#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 repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int n,q;
vector<vector<int>> tree(200000, vector<int>());

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

    string ans;
    int judge = b-a;

    if(judge <= 0){
        ans = "delicious";
    }
    else if(judge <= x){
        ans = "safe";
    }
    else{
        ans = "dangerous";
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut a = vec![0; n];
    let mut c = vec![0; n];
    for i in 0..n {
        a[i] = read::<i64>();
        c[i] += a[i] - (i+1) as i64;
    }
    c.sort();

    println!("{}", c.iter().map(|&s| (s - c[n/2]).abs()).sum::<i64>());
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

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

Measured memory_bytes: 256
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val x = readLong()
    var tmp = x / 500
    val ans = tmp * 1000 + (x - tmp * 500) / 5 * 5
    println(ans)
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 33548
#include <bits/stdc++.h>
#define MAX (ll)(2e5 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () { 
	IO;
	char c;
	cin >> c;
	cout << char (c + 1) << "\n";
}


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

int main(){
	
	int N,M,p;
	int target[110];
	int pnt[110]={};
	
	cin >> N >> M ;
	for( int i=0 ; i<M ; i++ ){
		cin >> target[i] ;
	}
	for( int i=0 ; i<M ; i++ ){
		for( int j=0 ; j<N ; j++ ){
			cin >> p ;
			if( p == target[i] ) pnt[j]++;
			else pnt[target[i]-1]++;
		}
	}
	
	for( int i=0 ; i<N ; i++ ){
		cout << pnt[i] << endl ;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s, ans = "AC";
    cin >> s;
    int cnt = 0;

    if (s[0] != 'A') ans = "WA";
    for (int i = 1; i < s.size(); i++) {
        if (isupper(s[i])) {
            if (i == 1 || i == s.size() - 1 || s[i] != 'C') ans = "WA";
            cnt++;
        }
    }
    if (cnt != 1) ans = "WA";
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    pti = 0
    pxi = 0
    pyi = 0
    for ti, xi, yi in zip(t, x, y):
        dt = ti - pti
        dx = xi - pxi
        dy = yi - pyi
        if abs(dx) + abs(dy) > dt or (dx + dy + dt) % 2 != 0:
            print(NO)
            return
        pti = ti
        pxi = xi
        pyi = yi
    print(YES)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [int()] * (N)  # type: "List[int]"
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        t[i] = int(next(tokens))
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, t, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11636
from itertools import accumulate
from collections import Counter

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

acc =  accumulate(a)
counter = Counter(acc)
def cal():
    yield counter[0]
    for v in counter.values():
        if v > 1:
            yield v*(v-1)//2

print(sum(cal()))

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

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int a = 0;
  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; i * r + j * g <= n; j++) {
      int k = n - (i * r + j * g);
      if (0 <= k && k % b == 0) a++;
    }
  }
  cout << a << endl;
}


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

int main(){
	int n,k;cin>>n>>k;
	vector<int> h(n);
	for(int i = 0; i < n; i++)
		cin>>h[i];
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++){
		for(int j = 1; j <= k; j++){
			if(j <= i){
				dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
			}
		}

	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
// Bismillahir Rahmanir Rahim. Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 3e5+5;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int A,B;
    cin >> A >> B;
    cout << max(0ll,A-2*B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int A,B,C;
	cin >> A >> B >> C;
	cout << min(B / A,C) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

using Graph = vector<vector<int>>;
int main(){
  int N, M; cin >> N >> M;
  Graph G(N);
  rep(i, M){
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i, N){
    cout << G[i].size() << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/agc009_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  vector<ll> a(N, 0);
  vector<ll> b(N, 0);
  rep(i, N) {
    cin >> a[i] >> b[i];
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());

  ll ans = 0;
  rep(i, N) {
    if ((a[i] + ans) % b[i] != 0) {
      ans += b[i] - ((a[i] + ans) % b[i]);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  int count=0;
  for (int i=0;i<N-2;i++){
    for (int j=i;j<N-1;j++){
      for (int k=j;k<N;k++){
        if (L.at(i)!=L.at(j) && L.at(j)!=L.at(k) && L.at(k)!=L.at(i)){
         if (L.at(i) + L.at(j) > L.at(k) && L.at(j) + L.at(k) > L.at(i) && L.at(k) + L.at(i) > L.at(j)){
           count++;
         }
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll MOD = 998244353;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A);
	int min_a = 1 << 30;
	for (int i = 0; i < A; i++) {
		cin >> a[i];
		min_a = min(min_a, a[i]);
	}
	vector<int> b(B);
	int min_b = 1 << 30;
	for (int i = 0; i < B; i++) {
		cin >> b[i];
		min_b = min(min_b, b[i]);
	}
	int ans = min_a + min_b;
	for (int i = 0; i < M; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		x--; y--;
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
  int n, m; cin >> n >> m;
  vector<long long> step(n + 1, 0);
  for(int i = 0; i < m; i++){
    int a;
    cin >> a;
    step[a] = -1;
  }
  step[n] = 1;
  int right = n + 1;
  for(int i = n - 1; i >= 0; i--){
    if(step[i] == -1){
      if(i == right - 1){
        break;
      }else{
        right = i;
        continue;
      }
    }else if(i == right - 1){
      step[i] = step[right + 1];
    }else if(i == right - 2){
      step[i] = step[i + 1];
    }else{
      step[i] = (step[i + 1] + step[i + 2]) % 1000000007;
    }
  }
  
  cout << step[0] << endl;
  
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll max_value(ll start, vl cost, vl gain) {
	vl dp(start+1);
	FOR(i,0,start+1) {
		dp[i] = i;
		FOR(j,0,sz(cost)) if (i >= cost[j]) {
			dp[i] = max(dp[i], dp[i-cost[j]] + gain[j]);
		}
	}
	return dp[start];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, p[2][3];
	cin >> n;
	FOR(i,0,2) FOR(j,0,3) cin >> p[i][j];
	
	FOR(dir,0,2) {
		vl cost, gain;
		FOR(j,0,3) {
			if (p[dir][j] < p[1-dir][j]) {
				cost.pb(p[dir][j]);
				gain.pb(p[1-dir][j]);
			}

		}
		n = max_value(n,cost,gain);
	}
	cout << n << endl;
}



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

int getSign(int i){
    int res=(i==0)?0:((i>0)?1:-1);
        return res;
    }
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0;i<N;i++){
  	cin >> A[i];
  }
  int pre=A[0];
  int sign0=0;
  int sign1;
  int cnt=1;
  for (int i=1;i<N;i++){
  sign1=getSign(A[i]-pre);
    if(sign0*sign1<0){
    cnt++;
  sign0=0;
  }else{
  if(sign0==0 and sign1 !=0)sign0=sign1;  
    }
  pre=A[i];  
  }
 cout <<cnt <<endl;
  return 0;
  
}


Measured memory_bytes: 640
N = 1000000007

def fac(n,r,N):
    ans=1
    for i in range(r):
        ans=ans*(n-i)%N
    return ans

def combi(n,r,N):
    if n<r or n<0 or r<0:
        ans = 0
        return ans
    r= min(r, n-r)
    ans = fac(n,r,N)*pow(fac(r,r,N),N-2,N)%N
    return ans


n , k = map(int, input().split())

for i in range(1,k+1):
    print(combi(k-1,i-1,N)*combi(n-k+1,i,N)%N)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll L;
ll X[303030];
ll T[303030];
int P[303030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>L;
	X[N+1]=L;
	for(i=1;i<=N;i++) cin>>X[i];
	
	ll num=0;
	
	deque<int> C[3];
	int lastadd=-1,lastpair=-1,last3=-1;;
	for(i=1;i<=N;i++) {
		cin>>T[i];
		num += T[i]/(2*L);
		T[i]%=2*L;
		
		P[i]|=2*((T[i]==0)||(T[i]>2*(L-X[i])));
		P[i]|=(T[i]==0)||(T[i]>2*X[i]);
		if(P[i]==3) {
			num+=T[i]!=0;
			last3=max(last3,i);
		}
		else if(P[i]==1) {
			if(C[0].size()) {
				num++;
				lastadd=max(lastadd,C[0].front());
				lastpair=max(lastpair,i);
				C[0].pop_front();
			}
			else {
				C[1].push_back(i);
			}
		}
		else if(P[i]==0) {
			if(C[2].size()) {
				num++;
				lastadd=max(lastadd,C[2].front());
				lastpair=max(lastpair,i);
				C[2].pop_front();
			}
			else {
				C[0].push_back(i);
			}
		}
		else {
			C[2].push_back(i);
		}
	}
	
	
	while(C[0].size()>=2) {
		num++;
		lastadd=max(lastadd,C[0].front());
		lastpair=max(lastpair,C[0].back());
		C[0].pop_front();
		C[0].pop_back();
	}
	num+=C[0].size()+C[1].size()+C[2].size();
	if(C[2].size()) {
		num++;
	}
	else {
		x=-1;
		if(C[0].size()) x=max(x,C[0].back());
		if(C[1].size()) x=max(x,C[1].back());
		if(x<lastadd || (last3>lastadd&&last3>lastpair)) num++;
	}
	
	cout<<num*2*L<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 7424
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif


// r, g, b
ll dp[3][4001];
ll sum[3];

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  ll N; cin >> N;
  string str; cin >> str;
  if(N < 3){
    cout << 0 << endl;
    return 0;
  }
  map<char, ll> mp;
  mp['R'] = 0;
  mp['G'] = 1;
  mp['B'] = 2;
  ll ans = 0;
  rep2(i, 1, N-1){
    memset(dp, 0, sizeof(dp));
    memset(sum, 0, sizeof(sum));
    rep(j, N){
      if(j == i) continue;
      ll sa = abs(j - i);
      ll num = mp[str[j]];
      if(j < i){
        // left
        if(mp[str[i]] != num){
          // if(i==2) DEBUG(sa);
          sum[num]++;
          dp[num][sa]++;
        }
      }
      else{
        // right
        if(mp[str[i]] != num){
          ll tmp = 0;
          ll katahou = 0;
          rep(k, 3){
            if(mp[str[i]] != k && mp[str[j]] != k){
              tmp += sum[k];
              katahou = k;
            }
          }
          // DEBUG(tmp);
          tmp -= dp[katahou][sa];
          ans+= tmp;
        }
      }
    }
  }

  cout << ans << endl;

}  


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

int main()
{
    int a,b,c,x,l=0;
    int i, j, k;
    cin >> a >> b >> c >> x;
    for(i=0;i<=a;i++){
        if(x < 500*i)break;
        for(j=0;j<=b;j++){
            if(x < 500*i+100*j)break;
            for(k=0;k<=c;k++){
                if(x==500*i+100*j+50*k){
                   l++;
                   //cout << i << j << k << x << endl;
                   break;
                }
                else if(x < 500*i+100*j+50*k)break;
             }
        }
    }
    cout << l;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
int N,T;
  cin>>N>>T;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i)>>B.at(i);
  }
   int Min=1001;
   for(int i=0;i<N;i++){
     if(B.at(i)<=T){
       Min=min(Min,A.at(i));
     }
   }
  if(Min==1001){
    cout << "TLE" << endl;
  }else
  cout<<Min;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_SEP_VAL		400										// 分岐値
#define D_RANK_MAX		8										// 最大ランク

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 人数取得
	int liHCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liHCnt);

	// ランク別人数取得
	int li1Rank[D_RANK_MAX + 5];
	memset(li1Rank, 0, sizeof(li1Rank));
	for (i = 0; i < liHCnt; i++) {
		int liVal;
#ifdef D_TEST
		fscanf(szpFpT, "%d", &liVal);
#else
		fscanf(stdin, "%d", &liVal);
#endif
		if (liVal < 1) {
			continue;
		}

		int liRNo = liVal / D_SEP_VAL;
		if (liRNo > D_RANK_MAX) {
			liRNo = D_RANK_MAX;
		}
		li1Rank[liRNo]++;
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// 最小値
	int liMin = 0;
	for (i = 0; i < D_RANK_MAX; i++) {
		if (li1Rank[i] > 0) {
			liMin++;
		}
	}

	// 最大値
	int liMax = liMin + li1Rank[D_RANK_MAX];

	// 最大ランクのみ
	if (liMin == 0) {
		if (li1Rank[D_RANK_MAX] > 0) {
			liMin = 1;
			liMax = li1Rank[D_RANK_MAX];
		}
	}

	// 結果セット
	sprintf(lc1Out, "%d %d\n", liMin, liMax);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

using namespace std;

using ll = long long;
#define rep(i,n) for(int i = 0; i < n ;++i)
#define all(v) v.begin(),v.end()

string s[100];
int w,h;
int dx[2]={0,1};
int dy[2]={1,0};
bool used[100][100];
string ans[100][100];

bool check(string s,string t){
  if(s.size()!=t.size())return s.size()>t.size();
  return s>t;
}

int main(){
    while(cin>>w>>h&&w+h){
      //vs.clear();
      rep(i,100)rep(j,100)ans[i][j].clear();
        rep(i,h)cin>>s[i];
        rep(i,h)rep(j,w){
          string t="";
          t+=s[i][j];
          //if(i==0&&j==0){
            if(s[i][j]>='1'&&s[i][j]<='9')ans[i][j]=t;
          //}
        }
        // rep(i,h){
        //   rep(j,w){
        //     cout<<ans[i][j]<<" ";
        //   }
        //   cout<<endl;
        // }
        //rep(i,h)rep(j,w)used[i][j]=0;
        string ret="";
        rep(i,h){
          rep(j,w){
            if(ans[i][j].empty())continue;
            if(i+1<h&&s[i+1][j]>='0'&&s[i+1][j]<='9'){
              ans[i+1][j]=ans[i][j]+s[i+1][j];
            }
            if(j+1<w&&s[i][j+1]>='0'&&s[i][j+1]<='9'){
              if(check(ans[i][j]+s[i][j+1],ans[i][j+1])){
                ans[i][j+1]=ans[i][j]+s[i][j+1];
              }
            }
          }
        }
        rep(i,h){
          rep(j,w){
          if(ans[i][j].size()>ret.size()){
              ret=ans[i][j];
          }
          else if(ans[i][j].size()==ret.size()){
            if(ret<ans[i][j])ret=ans[i][j];
          }
          // cout<<ans[i][j]<<" ";
          }
          // cout<<endl;
        }
        // sort(all(vs),F);
        // reverse(all(vs));
        // cout<<vs[0]<<endl;
        cout<<ret<<endl;
    }
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    if(a == b && b == c){
        cout << -1 << endl;
        return 0;
    }
    ll k = 1;
    while(k++){
        ll A = b/2 + c/2;
        ll B = a/2 + c/2;
        ll C = a/2 + b/2;
        a = A,b = B,c = C;
        if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0){
            cout << k-1 << endl;
            return 0;
       }
    }
}

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

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

int movX[8] = {-1, 0, 1,-1, 1,-1, 0, 1};
int movY[8] = {-1,-1,-1, 0, 0, 1, 1, 1};
typedef pair<int, int> pii;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	int h=read<int>(),w=read<int>();
	int mp[h][w];
	rep(i,h) rep(j,w){
		char c=read<char>();
		if(c=='.'){
			mp[i][j]=0;
		}else{
			mp[i][j]=c-'0';
		}
	}
	int around[h][w];
	Rep(i, 1, h-1){
		Rep(j, 1, w-1){
			int a = 0;
			rep(k,8) {
				int x = i+movX[k];
				int y = j+movY[k];
				if(!mp[x][y]){
					a++;
				}
			}
			around[i][j]=a;
		}
	}
	
	
	vector<pii> list;
	Rep(i, 1, h-1){
		Rep(j, 1, w-1){
			if(mp[i][j]>0 && around[i][j]>=mp[i][j]){
				list.push_back(pii(i,j)); 
			}
		}
	}
	if(list.size()==0){
		cout << 0 << endl;
		return 0;
	}
	for(vector<pii>::iterator it=list.begin();it!=list.end();it++){
		int i = it->first, j = it->second;
		mp[i][j] = 0;
		rep(k,8) {
			int x = i+movX[k];
			int y = j+movY[k];
			around[x][y]++;
		}
		// printf("(%d, %d)\n",i,j);
	}
	// printf("=============\n");
	
	int count = 1;
	while(true){
		vector<pii> list2;
		for(vector<pii>::iterator it=list.begin();it!=list.end();it++){
			int i = it->first, j = it->second;
			// cout << i << " " << j << endl;
			rep(k,8) {
				int x = i+movX[k];
				int y = j+movY[k];
				if(mp[x][y]>0 && around[x][y]>=mp[x][y]){
					list2.push_back(pii(x,y));
					// cout << "    " <<  i << " " << j << endl;
				}
			}
		}
		if(list2.size()==0){
			cout << count << endl;
			return 0;
		}
//		cout << list2.size() << endl;
		count++;
		vector<pii> list3;
		for(vector<pii>::iterator it=list2.begin();it!=list2.end();it++){
			int i = it->first, j = it->second;
			if(mp[i][j]){
				list3.push_back(*it);
				mp[i][j] = 0;
				rep(k,8) {
					int x = i+movX[k];
					int y = j+movY[k];
					around[x][y]++;
				}
				// printf("(%d, %d)\n",i,j);
			}
		}
		// printf("=============\n");
//		std::vector<pii>().swap(list);
//		std::vector<pii>().swap(list2);
		list = list3;
	}
}

Measured memory_bytes: 9012