akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int col[maxn],md[maxn],V[maxn],d[maxn],c[maxn],n,m;
vector <int> mp[maxn];

inline void wk(int u,int x,int C)
{
	if(x<=md[u]) return;
	md[u]=x; if(!col[u]) col[u]=C;
	for(int i=0;i<mp[u].size();i++)
	{
		int v=mp[u][i];
		wk(v,x-1,C);
	}
}

int main()
{
	n=read(); m=read();
	rep(i,1,m)
	{
		int u=read(),v=read();
		mp[u].pb(v); mp[v].pb(u);
	}
	int q=read();
	rep(i,1,n) md[i]=-1;
	rep(i,1,q) V[i]=read(),d[i]=read(),c[i]=read();
	per(i,q,1) wk(V[i],d[i],c[i]);
	rep(i,1,n) printf("%d\n",col[i]);
	return 0;
}

Measured memory_bytes: 32124
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<string> s(n);
    vector<ll> a;
    for(ll i=0;i<n;++i){
        cin>>s[i];
    }
    sort(s.begin(), s.end());
    ll ans = 1;
    for(ll i=1;i<n;++i){
        if(s[i-1] != s[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9596
import java.util.*;

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

        String N = sc.next();

        if(N.charAt(0)==N.charAt(2)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

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

		while (true) {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		}
		scan.close();
		System.exit(0);
	}

}

Measured memory_bytes: 26360
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    vector<int> a;
    int x, y, z;
    cin >> x >> y >> z;

    a.push_back(x);
    a.push_back(y);
    a.push_back(z);
    sort(a.begin(), a.end());

    if(a[0] == 5 & a[1] == 5 & a[2] == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n1,n2;
    cin>>n1>>n2;
    char arr[n1];
    char arr2[n2];
    int c=0;
    int b=0;
    int b2=0;
    char h;
    for(int i=0;i<n1;i++)
    {
        cin>>arr[i];
    }
    cin>>h;
    for(int i2=0;i2<n2;i2++)
    {
        cin>>arr2[i2];
    }
    for(int t=0;t<n1;t++)
    {
        if(arr[t]=='0'||arr[t]=='1'||arr[t]=='2'||arr[t]=='3'||arr[t]=='4'||arr[t]=='5'||arr[t]=='6'||arr[t]=='7'||arr[t]=='8'||arr[t]=='9')
        {
            b++;
        }
        if(b==n1)
        {
          c++;
        }
    }
    if(h=='-')
    {
        c++;
    }
    for(int t2=0;t2<n2;t2++)
    {
        if(arr2[t2]=='0'||arr2[t2]=='1'||arr2[t2]=='2'||arr2[t2]=='3'||arr2[t2]=='4'||arr2[t2]=='5'||arr2[t2]=='6'||arr2[t2]=='7'||arr2[t2]=='8'||arr2[t2]=='9')
        {
            b2++;
        }
        if(b2==n2)
        {
            c++;
        }
    }
    if(c==3)
    {
       cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
def root(x):
    path_to_root = []
    while x != P[x]:
        path_to_root.append(x)
        x = P[x]
    for node in path_to_root:
        P[node]=x
    return x

def unite(x,y):
    P[root(x)] = root(y)

def is_same_set(x,y):
    return root(x) == root(y)

n,q = map(int,input().split())
P = [i for i in range(n)]
for _ in range(q):
    com,x,y=map(int,input().split())
    if com == 0:
        unite(x,y)
    else:
        if is_same_set(x,y):
            print(1)
        else:
            print(0)


Measured memory_bytes: 5984
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int>A(N);
    cin >> A;

    int ans = 0;
    REP(i, N) {
        int cnt = 0;
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            cnt++;
        }
        ans += cnt;
    }

    cout << ans << endl;

    return 0;

}

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

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    // cout << l << r << d << endl;
    for(int i = l; i <=r; i++){
        // cout << l << d << endl;
        if(i % d == 0){
            // cout << l << d << endl;
            ans++;
            // cout << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

typedef struct _kiroku{
	int t,n,m,s;
} kiroku;

kiroku kiro[1024];

int main(){
	int n,m,r,q,ts,te,mm;
	while(scanf("%d%d",&n,&m),n|m){
		scanf("%d",&r);
		rep(i,r)scanf("%d%d%d%d",&kiro[i].t, &kiro[i].n, &kiro[i].m, &kiro[i].s);
		
		scanf("%d",&q);
		rep(i,q){
			scanf("%d%d%d",&ts,&te,&mm);
			int sum = 0;
			int start = 0;
			int cnt = 0;
			for(int i=0; i<r; i++)if( kiro[i].m==mm ){
				if( cnt==0 ){	 //init
					start = kiro[i].t;
					cnt++;
				}else{
					if( kiro[i].s==1 )cnt++;
					else              cnt--;
					if( cnt==0 ){
						//printf("%d - %d = %d\n",kiro[i].t,max(ts,start),kiro[i].t-start);
						if( kiro[i].t<ts )continue;
						if( min(te,kiro[i].t)<max(ts,start) )break;
						sum += (min(te,kiro[i].t)-max(ts,start));
					}
				}
			}
			printf("%d\n",sum);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    string s;
    cin >> s;

    vector<int> a(4, 0);
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            if (s[i] == s[j])
            {
                a[i]++;
            }
        }
    }

    for (int i = 0; i < 4; i++)
    {
        if (a[i] != 2)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
stack<bool> stk;
vector<int> v1, v2;
#define pb push_back
int main(){
	ll n; cin >> n;
	n = n + 1;
	ll tmp = n;
	for(;tmp; tmp >>= 1) stk.push(tmp & 1);
	stk.pop();
	for(int x = 1; !stk.empty(); stk.pop()){
		v1.pb(x), ++x;
		if(stk.top()) v2.pb(x), ++x;
	}
	int m = v1.size() + v2.size();
	cout << m * 2 << endl;
	for(int i = 1; i <= m; ++i)
		cout << i << " ";
	for(int i = v2.size() - 1; ~i; --i)
		cout << v2[i] << " ";
	for(auto x: v1)
		cout << x << " ";
	puts("");
	return 0;
}

Measured memory_bytes: 256
use std::cmp::*;

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut dp = vec![1 << 21; n + 1];
    dp[0] = 0;
    for i in 0..n + 1 {
        let mut j = 1;
        while i + j < n + 1 {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
            j *= 6;
        }
        j = 1;
        while i + j < n + 1 {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
            j *= 9;
        }
    }
    //eprintln!("{:?}", dp);
    println!("{}", dp[n]);
}


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

using namespace std;

typedef long long int ll;

const ll MAXN = 55556;

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

  ll n;
  cin >> n;
  vector < ll > lp(MAXN, 0), primes;
  for(int i = 2; i < MAXN; i++){
    if(lp[i] == 0){
      lp[i] = i;
      primes.push_back(i);
    }
    for(int j = 0; j < primes.size() && primes[j] <= i && i * primes[j] < MAXN; j++){
      lp[i * primes[j]] = primes[j];
    }
  }

  ll cnt = 0;
  for(int i = 0; i < primes.size(); i++){
    if(primes[i] % 5 == 1){
      cnt++;
      cout << primes[i] << " ";
    }
    if(cnt == n){
      cout << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
typedef pair<int, int> P;

vector<P> prime_factorize(lint N){
	vector<P> ans;
	for(lint a = 2; a*a <= N; a++){
		if(N%a == 0){
			lint ex = 0;
			while(N%a == 0){
				ex++;
				N /= a;
			}
			ans.push_back(P(a, ex));
		}
	}
	if(N != 1) ans.push_back(P(N, 1));
	return ans;
}


signed main(){
  lint A, B; cin >> A >> B;
  lint x = __gcd(A, B);
  vector<P> vec = prime_factorize(x);
  cout << vec.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	lli N, K; cin >> N >> K;
	lli a = N % K;
	if (a <= abs(a - K))cout << a << endl;
	else cout << abs(a - K) << endl;

	return 0;
}


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


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

ans = 1
if n == 2:
    print(max(a))
else:
    l = [0] * (n + 1)
    r = [0] * (n + 1)
    for i in range(1, n):
        l[i] = gcd(l[i - 1], a[i - 1])
        r[n - i] = gcd(r[n - i + 1], a[-i])
    for i in range(n):
        m = gcd(l[i], r[i + 1])
        ans = max(ans, m)
    print(ans)

Measured memory_bytes: 14488
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    int n;
    cin>>n;
    int f=0;
    int t,x,y;
    cin>>t>>x>>y;
    int temp;
    temp=t;
    int tot=x+y;
    if(temp<tot)f=1;
    else{
        temp=temp-tot;
        if(temp%2==0){
            //cout<<"enter1"<<endl;
            n=n-1;
            while(n--){
                int tm,a,b,tv;
                cin>>tm>>a>>b;
                tv=tm;
                int dis=abs(x-a)+abs(y-b);
                tv=tv-t;
                if(dis>tv){
                    f=1;
                    break;
                }else{
                    //cout<<"enter2"<<endl;
                    tv=tv-dis;
                    //cout<<tv<<endl;
                    if(tv%2!=0){
                        f=1;
                        break;
                    }
                }
                x=a;y=b;t=tm;
            }
        }else f=1;
    }
    if(f==1)cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << "\n";
    return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>

int main(void){

int i,n;

int number;

long long int sum=0;

int min=0;

int max=0;

scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%d",&number);

if(i==0){

min=number;

max=number;

}

if(number<min){

min=number;

}

if(number>max){

max=number;

}

sum+=number;

}

printf("%d %d %lld\n",min,max,sum);

return 0 ; 

}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

const int MAX_H = 8;
const int MAX_W = 8;
const int dx[2] = { 1, 0 }, dy[2] = { 0, 1 };

int main () {
  int H, W;
  int a[MAX_H][MAX_W];
  cin >> H >> W;
  for (int i=0;i<H;i++) {
    char tmp[MAX_W];
    cin >> tmp;
    for (int j=0;j<W;j++) {
      if (tmp[j] == '#') {
        a[i][j] = 1;
      } else {
        a[i][j] = 0;
      }
    }
  }

  int y, x, ny, nx;
  bool flag;
  y = x = 0;
  a[y][x] = 0;
  while (!flag) {
    flag = true;
    for (int i=0;i<2;i++) {
      ny = y+dy[i]; nx = x+dx[i];
      if (H <= ny || W <= nx) continue;
      if (a[ny][nx] == 1) {
        a[ny][nx] = 0;
        y = ny; x = nx;
        flag = false;
        break;
      }
    }
  }
  int sum = 0;
  for (int i=0;i<H;i++) {
    for (int j=0;j<W;j++) {
      sum += a[i][j];
    }
  }

  cout << (0<sum?"Impossible":"Possible") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int D;
  cin>>D;
  vector<int> c(26);
  vector<vector<int>> s(D,vector<int>(26,0));
  vector<int> t(D);
  rep(i,26)
    cin>>c.at(i);
  rep(i,D){
    rep(j,26)
      cin>>s.at(i).at(j);
  }
  rep(i,D){
    cin>>t.at(i);
    t.at(i)--;
  }
  
  vector<in> v(D,0);
  vector<int> last(26,0);
  
  in sum=0;
  for(int i=0;i<D;i++){
    last.at(t.at(i))=i+1;
    sum+=s.at(i).at(t.at(i));
    rep(j,26)
      sum-=c.at(j)*(i+1-last.at(j));
    
    v.at(i)=sum;
  }
  rep(i,D)
    cout<<v.at(i)<<endl;
  
  /*vector<in> v_ans(D);
  rep(i,D){
    cin>>v_ans.at(i);
    cout<<v_ans.at(i)-v.at(i)<<endl;
  }*/
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[][] wav = new int[n][2];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 2; j++){
                wav[i][j] = scanner.nextInt();
            }
        }
        System.out.println(new Main().f(wav, n, w));
    }

    public long f(int[][] wav, int n, int w) {
        long[][] dp = new long[n][w+1];
        long ans = 0;
        for(int i = 0; i <= w; i++){
            if(i >= wav[0][0])
                dp[0][i] = wav[0][1];
            ans = Math.max(dp[0][i], ans);
        }
        for(int i = 1; i < n; i++){
            for(int j = 0; j <= w; j++){
                if(j >= wav[i][0]){
                    dp[i][j] = Math.max(wav[i][1] + dp[i-1][j-wav[i][0]], dp[i-1][j]);
                }else{
                    dp[i][j] = dp[i-1][j];
                }
                ans = Math.max(dp[i][j], ans);
            }
        }
        return ans;
    }
}


Measured memory_bytes: 125268
#include <stdio.h>
//#include <stdlib.h>
#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  char s[101], t[201];
  scanf("%s %s", s, t);
  strcat(t, s);
  int n = strlen(t);
  for (int i=0; i<n; i++) printf("%c", t[i]);
  printf("\n");
  return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int c[n];
	for (auto &i : c) i = ri();
	int a[n][26];
	for (auto &i : a) for (auto &j : i) j = ri();
	
	for (int i = 0; i < n; i++) {
		printf("%d\n", i % 26 + 1);
	}
	
	return 0;
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>>a(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a.at(i).at(j);
			a.at(i).at(j) %= 2;
		}
	}
	vector<vector<int>>yxyx(0, vector<int>(4));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w - 1; j++) {
			if (a.at(i).at(j) == 1) {
				yxyx.push_back({ i,j,i,j + 1 });
				a.at(i).at(j)--;
				a.at(i).at(j + 1)++;
			}
			else a.at(i).at(j) %= 2;
		}
	}
	for (int i = 0; i < h-1; i++) {
		a.at(i).at(w - 1) %= 2;
		if (a.at(i).at(w - 1) == 1) {
			yxyx.push_back({ i,w - 1,i + 1,w - 1 });
			a.at(i).at(w - 1)--;
			a.at(i + 1).at(w - 1)++;
		}
	}
	a.at(h - 1).at(w - 1) %= 2;
	cout << yxyx.size() << endl;
	for (int i = 0; i < yxyx.size(); i++)cout << yxyx.at(i).at(0)+1 << " " << yxyx.at(i).at(1) + 1 << " " << yxyx.at(i).at(2) + 1 << " " << yxyx.at(i).at(3) + 1 << endl;

}

Measured memory_bytes: 9904
N = int(input())
def idx(s):
    return ord(s)-97

class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

d = {}
for i in range(26):
    d[i] = BIT(N)

S = input()
for i in range(N):
    d[idx(S[i])].add(i,1)
S = list(S)
Q = int(input())
for _ in range(Q):
    q = input().split()
    if q[0]=='1':
        i = int(q[1])-1
        s = S[i]
        d[idx(s)].add(i,-1)
        S[i] = q[2]
        d[idx(q[2])].add(i,1)
    else:
        l,r = int(q[1])-1,int(q[2])-1
        res = 0
        for i in range(26):
            c = d[i].sum(r)
            if l!=0:
                c -= d[i].sum(l-1)
            c = min(1,c)
            res += c
        print(res)

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

typedef long long ll;

const int maxn = 105, maxw = 1e9 + 5, maxv = 1e3 + 5;

int main(int argc, const char * argv[])
{
    ll n, W, w[maxn], v[maxn], dp[maxv*maxn], ans = 0;
    //memset(dp, maxw, sizeof dp);
    for (int i = 0; i < maxv * maxn; i++)
        dp[i] = maxw;
    cin >> n >> W;
    for (int i = 0; i < n; i++)
        scanf("%lld %lld", &w[i], &v[i]);

    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = maxv * maxn - 1; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
            if (dp[j] <= W)
                ans = max(ans, (ll)j);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    ll N,M;
    cin >> N >> M;
    if(N==1 && M==1) cout << "1" << endl;
    else if(N==1 || M==1) cout << max(N,M)-2;
    else cout << (N-2)*(M-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, T, Q;
    cin >> N >> T >> Q;
    vector<ll> A(N), D(N);
    vector<ll> B(N);
    vector<ll> X(Q);
    rep(i, N) cin >> A[i] >> D[i];
    rep(i, Q) {
        cin >> X[i];
        X[i]--;
    }
    ll now = -LINF;
    ll st = 0;
    rep(i, N) {
        if(D[i] == 1) {
            now = A[i];
            st = -LINF;
        } else {
            if(now == -LINF) {
                B[i] = -LINF;
            } else if(st == -LINF) {
                st = (now + A[i]) / 2;
                B[i] = st;
            } else {
                B[i] = st;
            }
        }
    }
    now = LINF;
    st = LINF;
    for(int i = N - 1; i >= 0; i--) {
        if(D[i] == 2) {
            now = A[i];
            st = LINF;
        } else {
            if(now == -LINF) {
                B[i] = LINF;
            } else if(st == LINF) {
                st = (now + A[i]) / 2;
                B[i] = st;
            } else {
                B[i] = st;
            }
        }
    }

    rep(i, Q) {
        if(D[X[i]] == 1) {
            cout << min(A[X[i]] + T, B[X[i]]) << endl;
        } else {
            cout << max(A[X[i]] - T, B[X[i]]) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5200
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;

vvi a;

int Rec(int x){
	int res=0,S=a[x].size();
	if(!S) return res;
	vi tmp(S);
	for(int i=0;i<S;i++) tmp.push_back(Rec(a[x][i]));
	sort(tmp.begin(),tmp.end(),[](int p,int q){return p>q;});
	for(int i=0;i<S;i++) res=max(res,tmp[i]+i+1);
	return res;
}

int main(){
	cin>>n;
	a=vvi(n);
	for(int i=1;i<n;i++){
		int A;
		cin>>A;
		a[A-1].push_back(i);
	}
	cout<<Rec(0)<<endl;
}

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

int A[105];
bool dp[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 1; i <= K; i++)
    {
        for (int j = 0; j < N; j++) if (A[j] <= i && !dp[i - A[j]])
        {
            dp[i] = true;
            break;
        }
    }
    if (dp[K]) cout << "First\n";
    else cout << "Second\n";
    return(0);
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

double ans;

void dfs(double d,double x,int n){
	if(n == 0)return;
	double next_d = ((n + 2) * d + 5 * x) / n;
	double next_x = ((n + 4) * x) / n;
	ans += (2 * d + (n - 1) * x) / 2;
	dfs(next_d,next_x,n-2);
}

int main(){
	int n;
	double d,x;
	cin >> n >> d >> x;
	dfs(d,x,n*2);
	cout << Decimal << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
 
  int n1 = n / 1000;
  int n2 = (n % 1000) / 100;
  int n3 = (n % 100) / 10;
  int n4 = (n % 10);
  
  if ( (n1 == n2 && n1 == n3) ||
       (n2 == n3 && n2 == n4)
     )
  {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define RREP(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define ALL(vector) vector.begin(), vector.end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin>>X;
    ll ans=-1;
    REP(i, 180){
        if(i==0) continue;
        if((i*360) % X == 0){
            ans = (i*360) / X;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
import math

prime = [1 for i in range(999999)]
prime[0] = 0
for i in range(2,999999/2):
    prime[2*i-1] = 0
for i in range(3,int(math.sqrt(999999)),2):
    mx = 2*i
    while mx <= 999999:
        prime[mx-1] = 0
        mx += i

while True:
    try:
        n = int(raw_input())
        print sum(prime[:n])
    except:
        break

Measured memory_bytes: 43948
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n-1);
    rep(i,n)
    {
        cin>>a[i];
    }
    rep(i,n)cin>>b[i];
    rep(i,n-1)cin>>c[i];

    int ans=0;
    rep(i,n)
    {
        ans+=b[a[i]-1];
        if(i>0)
        {
            if(a[i]==a[i-1]+1)
            {
                ans+=c[a[i-1]-1];
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	map<string, ll> mp;
	for( int i = 0; i < n; ++i ){
		string s = "";
		char c; 
		vector<char> vc;
		for( int j = 0; j < 10; ++j ){
			cin >> c;
			vc.push_back(c);
		}
		sort( vc.begin(), vc.end() );
		for( int j = 0; j < 10; ++j ){
			s += vc[j];
		}
		++mp[s];
	}
	ll ans = 0;
	for( auto a : mp ){
		ll k = a.second;
		ans += k*(k-1)/2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
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();
		int c = sc.nextInt();

		if (a == b && b == c) {
			System.out.println(1);
		} else if (a == b || b == c || c == a) {
			System.out.println(2);
		} else {
			System.out.println(3);
		}

		sc.close();
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

int main() {
	string S;
	cin >> S;
	if (S.length() < 26) {
		bool isUsed[26];
		for (int i = 0; i < 26; i++) isUsed[i] = false;
		for (int i = 0; i < S.length(); i++) isUsed[S[i] - 'a'] = true;
		cout << S;
		for (int i = 0; i < 26; i++) if (!isUsed[i]) {
			cout << (char)('a' + i) << endl;
			break;
		}
	}
	else {
		if (S == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
		}
		else {
			string T(S);
			next_permutation(S.begin(), S.end());
			for (int i = 0; i < S.length(); i++) {
				cout << S[i];
				if (S[i] != T[i]) break;
			}
			cout << endl;
		}

	}
	system("pause");
	return 0;
}


Measured memory_bytes: 504
// abc162_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((ll)1e15)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    // dp[i][j] i個見て、(i+1)/2-j選んでいる状態
    // 残りのn-i個で最高でも (n-i+1)/2個しか選べない。計算すると、たかだかj=2まで
    vector<vector<ll>> dp(N+1, vector<ll>(3, -INF));
    dp[0][0] = 0;
    dp[1][0] = A[0];
    dp[1][1] = 0;
    REPN(i, 2, N+1){
        ll a = A[i-1];
        if (i % 2 == 1){
            if (i >= 2) dp[i][0] = max(dp[i][0], dp[i-2][0] + a);

            if (i >= 1) dp[i][1] = max(dp[i][1], dp[i-1][0]);
            if (i >= 2) dp[i][1] = max(dp[i][1], dp[i-2][0]);
            if (i >= 2) dp[i][1] = max(dp[i][1], dp[i-2][1] + a);

            if (i >= 1) dp[i][2] = max(dp[i][2], dp[i-1][1]);
            if (i >= 2) dp[i][2] = max(dp[i][2], dp[i-2][1]);
            if (i >= 2) dp[i][2] = max(dp[i][2], dp[i-2][2] + a);

            if (i >= 3) dp[i][2] = max(dp[i][2], dp[i-3][0]);
            if (i >= 4) dp[i][2] = max(dp[i][2], dp[i-4][0]);
            if (i >= 4) dp[i][2] = max(dp[i][2], dp[i-4][1] + a);

        } else {

            if (i >= 1) dp[i][0] = max(dp[i][0], dp[i-1][0]);
            if (i >= 2) dp[i][0] = max(dp[i][0], dp[i-2][0] + a);

            if (i >= 1) dp[i][1] = max(dp[i][1], dp[i-1][1]);
            if (i >= 2) dp[i][1] = max(dp[i][1], dp[i-2][0]);
            if (i >= 3) dp[i][1] = max(dp[i][1], dp[i-3][0]);
            if (i >= 2) dp[i][1] = max(dp[i][1], dp[i-2][1] + a);

            if (i >= 1) dp[i][2] = max(dp[i][2], dp[i-1][2]);

            if (i >= 2) dp[i][2] = max(dp[i][2], dp[i-2][1]);
            if (i >= 3) dp[i][2] = max(dp[i][2], dp[i-3][1]);
            if (i >= 2) dp[i][2] = max(dp[i][2], dp[i-2][2] + a);

            if (i >= 4) dp[i][2] = max(dp[i][2], dp[i-4][0]);
            if (i >= 5) dp[i][2] = max(dp[i][2], dp[i-5][0]);
            if (i >= 4) dp[i][2] = max(dp[i][2], dp[i-4][1] + a);
        }
    }
//    print(dp);
    ll ans = N % 2 == 0 ? dp[N][0] : dp[N][1];
    print(ans);

    return 0;
}


Measured memory_bytes: 15868
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int res = (n + (x-1)) / x;
    res *= t;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3616
N=list(input())
ans=0
for i in range(len(N)):
    if i==len(N)-1:
        if len(N)%2==1:
            s=""
            for num in N:
                s=s+num
            s=int(s)-10**i
            s+=1
            ans+=s
    else:
        if i%2==0:
            ans+=10**(i+1)-10**i
print(ans)

Measured memory_bytes: 3060
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
 */
import java.applet.Applet;
import java.util.*;
import java.awt.*;
import java.awt.Graphics.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int inf=Integer.MAX_VALUE;
        Point[] red=new Point[n];
        for (int i=0;i<n;i++)red[i]=new Point(sc.nextInt(),sc.nextInt());
        Point[] blue=new Point[n];
        for (int i=0;i<n;i++)blue[i]=new Point(sc.nextInt(),sc.nextInt());
        Arrays.sort(blue,(p1,p2)->p1.x-p2.x);
        int ans=0;
        for (int i = 0; i < n; i++) {
            Point b=blue[i];
            int red_y=-1;
            int red_index=-1;
            for (int j = 0; j < n; j++) {
                Point r=red[j];
                if(d(b,r)){
                    if(red_y<r.y){
                        red_y=r.y;
                        red_index=j;
                    }
                }
            }
            if(red_index>-1){
                ans++;
                red[red_index]=new Point(inf,inf);
            }
        }
        out.println(ans);
    }
    static boolean d(Point blue,Point red){
        return red.x<blue.x&&red.y<blue.y;
    }
}

Measured memory_bytes: 26964
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll n;cin >> n;
  vector<ll> p(n);
  rep(i,n) cin >> p[i];
  vector<pair<ll,ll>> pv(n);
  rep(i,n) pv[i] = { - p[i] , i };
  sort(pv.begin(), pv.end());
  multiset<ll> st;
  st.insert((ll)-1);
  st.insert((ll)-1);
  st.insert(n);
  st.insert(n);  

  ll res = 0;
  rep(i,n){
    ll x = pv[i].second;
    ll y = - pv[i].first;
    st.insert(x);
    auto it1 = st.find(x);
    auto it2 = st.find(x);
    ll c = *it1; it1++;
    ll d = *it1; it1++;
    ll e = *it1; it2--;
    ll b = *it2; it2--;
    ll a = *it2;
    res += y * ( ( c - b ) * ( e - d ) + ( d - c ) * ( b - a ) );
  }
  cout << res << "\n";
  
  return 0;
}


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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }


// ***************************************

int main(void) {

	int N;
	cin >> N;

	vector<ll> dp(N, 1e10);
	vector<ll> H(N);
	for (auto& h : H) {
		cin >> h;
	}

	dp[0] = 0;

	REP(i, N-1) {
		dp[i + 1] = min(dp[i+1], dp[i] + abs(H[i + 1] - H[i]));
		if (i < N - 2) {
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]));
		}
	}

	cout << dp.back() << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
int n;
int main() {
	int i, j, k;
	scanf("%d", &n);
	int ans = 0;
	for(i = 1; i <= n; i++){
		int x, y, ret = 0;
		scanf("%d%d", &x, &y);
		if(y == 1){ ans ^= x; continue; }
		while(x >= y){
			if(x%y == 0){ ret = x/y; break; }
			int d = x/y+1;
			int p = x/y*y;
			if(x-d <= p) x -= d;
			else x -= (x-p)/d*d;
		}
		ans ^= ret;
	}
	if(ans == 0) printf("Aoki\n");
	else printf("Takahashi\n");
	return 0;
}

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

int main(){
  int N;
  string S;
  ll answer = 0;
  ll R_count = 0;
  ll G_count = 0;
  ll B_count = 0;
  ll violation = 0;
  cin >> N >> S;
  rep(i, N){
    if (S.at(i) == 'R') R_count++;
    if (S.at(i) == 'G') G_count++;
    if (S.at(i) == 'B') B_count++;
  }
  for (int i = 1; i <= N/2; i++){
    rep (j, N-2*i){
      if ((S.at(j) != S.at(j+i)) && (S.at(j+i) != S.at(j+i+i)) && (S.at(j+i+i) != S.at(j))) violation++;
    }
  }
  answer = R_count * G_count * B_count - violation;
  cout << answer << endl;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    map<string,ll> m;
    set<string> v;
    ll n;
    cin >> n;
    ll sum = 0;
    for(ll i = 0; i <n; i++)
    {

        string ss;
        cin >> ss;
        sort(ss.begin(), ss.end());
        m[ss]++;
        v.insert(ss);
    }
    set<string> :: iterator it;
    for(it = v.begin(); it != v.end(); it++)
    {

        ll x = m[*it];
        x--;
        sum+=((x*(x+1))/2);
    }
    cout << sum;
}


Measured memory_bytes: 20608
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int x = 0;
            int y = 0;
            int cnt = 0;
            boolean end = false;
            
            while(!end){
            	String temp = br.readLine();
            	String[] numbers = temp.split(" ");
            	x = Integer.parseInt(numbers[0]);
            	y = Integer.parseInt(numbers[1]);
            	
            	if((x < 0 && y > 10000) || (x == 0 && y == 0) || cnt > 3000){
            		end = true;
            	}else if(x > y || x == y){
            		System.out.println(y + " " + x);
            	}else if(x < y){
            		System.out.println(x + " " + y);
            	}
            	cnt++;
            }
            

        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 26784
N, M = map(int, input().split())

mod_num = 10 ** 9 + 7
a = [0] * M

for i in range(M):
    a[i] = int(input())
a = set(a)

val = [0,1]
j = 0
for i in range(1, N + 1):
    ans = (val[0] + val[1]) % mod_num
    val[0] = val[1]
    val[1] = ans
    if i in a:
        val[1] = 0

 
print(ans)

Measured memory_bytes: 13164
#include "bits/stdc++.h"
using namespace std;


int main() {
 //vector <char>P(3);
 //vector <char>R(3);
	int A,B;
	int sum=0;
 int count=0;
 int i=0;
 cin>>A>>B;
if(A>B){
   if(B==1){
    cout<<count<<endl;
    return 0;
  }
  count++;
   cout<<count<<endl;
  return 0;
}
 while(sum<B){
	sum=i*(A-1)+A;
	 i++;
	 count++;
 }
 cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
          　var nn = cin.ReadInt;
			var qq = cin.ReadInt;
			var S = cin.ReadLine;

			var sum = new int[nn + 1];
			for(int i = 1; i < nn; i++)
			{
				sum[i + 1] = sum[i];
				if(S[i] == 'C' && S[i - 1] == 'A')
				{
					sum[i + 1]++;
				}
			}

			var sb = new StringBuilder();
			for(int i = 0; i < qq; i++)
			{
				var l = cin.ReadInt - 1;
				if (l > 0 && S[l] == 'C' && S[l - 1] == 'A') l++;
				int r = cin.ReadInt;
				sb.AppendLine((sum[r] - sum[l]).ToString());
			}
			WriteLine(sb.ToString());
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 20040
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,m,a[1010],t[1010];

int main(){
	while(cin>>n>>m&&n){
		rep(i,n)cin>>a[i];
		int M=INF,D=INF;
		rep(i,n){
			int x=(M+a[i]-(D<a[i]))/a[i]*a[i];
			if(x<=m)t[i]=x;
			else t[i]=m/a[i]*a[i];
			if(t[i]<M)M=t[i],D=a[i];
			else if(t[i]==M)D=min(D,a[i]);
		}
		int r,m=INF,d;
		rep(i,n){
			if(t[i]<m||t[i]==m&&a[i]<d)r=i+1,m=t[i],d=a[i];
			else if(t[i]==m&&a[i]==d)r=n;
		}
		cout<<r<<endl;
	}
}

Measured memory_bytes: 0
a,b,c = input()
d,e,f = input()
if a == d:
  x = int( 1 )
else:
  x = int( 0 )

if b == e:
  y = int( 1 )
else:
  y = int( 0 )
  
if c == f:
  z = int( 1 )
else:
  z = int( 0 )
  
print( x+y+z )

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)x=-x,putchar('-');
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
const int maxn=100005;
typedef long long ll;
int n,a[maxn];
ll l[maxn],r[maxn];
int main(){
	n=read();
	REP(i,1,n)a[i]=read();
	if(a[n]!=2)return puts("-1"),0;
	l[n]=2,r[n]=3;
	DREP(i,n-1,1){
		l[i]=((l[i+1]-1)/a[i]+1)*a[i],r[i]=(r[i+1]/a[i]+1)*a[i]-1;
		if(l[i]>r[i])return puts("-1"),0;
	}
	cout<<l[1]<<' '<<r[1]<<endl;
	return 0;
}

Measured memory_bytes: 2176