akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;

int main() {
  string s,t;
  cin>>s;
  cin>>t;
  int n=s.length();
  int trans[26];
  set<int> used;
  for (int i=0; i<26; i++) trans[i] = -1;
  for (int i=0; i<n; i++) {
    int si = s[i] - 'a';
    int ti = t[i] - 'a';
    if (trans[si] == -1) {
      if (used.find(ti) == used.end()) {
        trans[si] = ti;
        used.insert(ti);
      } else {
        cout<<"No"<<endl;
        return 0;
      }
    } else if (trans[si] != ti) {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define fix cout<<fixed<<setprecision(20);
const int maxn=(int)2e6+5;
vector<int> E[maxn];
int vis[maxn],ind[maxn],dis[maxn];
int reach[maxn];//longest can reach
inline int id(int x,int y){
    if(x>y)swap(x,y);
    //x--,y--;
    return x+1000*y;
}
int ans=-1;

int dfs(int x){
    //debug(x);
    if(vis[x]==2)return dis[x];
    vis[x]=1;
    for(auto v:E[x]){
        if(vis[v]==1)return -1;
        
        //dis[v]=dis[x]+1;ans=max(ans,dis[v]);
        int ret=dfs(v);
        if(ret==-1)return -1;
        dis[x]=max(dis[x],ret+1);//每个节点存最大值。
        
        
    }
    
    //debug(dis[x]);debug(x);
    
    vis[x]=2;
    return dis[x];
}
int main(){
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    rep(i,1,n){
        int last=0;
        rep(j,1,n)if(i!=j){
            int x;scanf("%d",&x);
            if(last==0){last=id(i,x);continue;}
            E[last].push_back(id(i,x));ind[id(i,x)]++;
            last=id(i,x);
        }
    }
    
    rep(i,1,n)rep(j,1,i-1)if(ind[id(i,j)]==0){
       // memset(vis,0,sizeof(vis));
        E[0].push_back(id(i,j));
        /* dis[id(i,j)]=1;
        if(dfs(id(i,j))==0){cout<<-1<<endl;return 0;};
        //debug("--"); */
    }
    dis[0]=-1;
    int ans=dfs(0);
    
    cout<<ans<<endl;
    

}
/* 
建DAG，判环
topo 可判环（无法进入队列的点），但无法找最长路径
两种环
一种是链环，用
一种是纯环，
3
2 3
1 3
1 2

12-13
12-23
13-23

4
2 3 4
1 3 4
4 1 2
3 1 2

12-13
13-14
12-23
23-24
34-13
13-23
34-14
14-24

 queue<int> Q;
    rep(i,1,n)rep(j,1,i-1)if(ind[id(i,j)]==0)Q.push(id(i,j)),vis[id(i,j)]=1;
    while(!Q.empty()){
        
        int cur=Q.front();Q.pop();
        debug(cur);debug(vis[cur]);
        for(auto v:E[cur]){
            if(vis[v]){continue;}
            //if(vis[v]==1){cout<<-1<<endl;return 0;}
            ind[v]--;
            if(ind[v]==0)Q.push(v),vis[v]=vis[cur]+1,ans=max(ans,vis[v]);
        }
    }
   // rep(i,1,n)rep(j,1,n)if(i!=j)debug(vis[id(i,j)]),debug(i),debug(j);
 */

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


bool solve(int* Ai, vector<int> B, int C) {
    int sum = 0;
    for (int i = 0; i < B.size(); i++) sum += Ai[i] * B[i];
    if (sum + C > 0) {
        return true;
    } else {
        return false;
    }
}


int main() {
    int N, M, C; cin >> N >> M >> C;
    vector<int> B(M); for (int i = 0; i < M; i++) cin >> B[i];
    int A[N][M];
    for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) {cin >> A[i][j];}

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (solve(A[i], B, C)) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n;i++){ cin >> a[i]; a[i]*=-1;}
    
    vector<ll> dp(n, LINF);
    for (int i = 0; i < n;i++) {
        *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    res = lower_bound(dp.begin(), dp.end(), LINF) - dp.begin();
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int dataNum = 0;
		while (true) {
			String input = br.readLine();
			if (input == null || "".equals(input)) break;

			int a = Integer.parseInt(input.split(" ")[0]);
			int b = Integer.parseInt(input.split(" ")[1]);

			if (dataNum > 200) break;
			if ((a == 0) && (b == 0)) break;
			if (!((a >= 0 && a <= 1000000) && (b >= 0 && b <= 1000000))) break;

			System.out.println(String.valueOf(a + b).length());
			dataNum++;
		}
	}
}

Measured memory_bytes: 23980
#include<stdio.h>
int main(){
	int i,j,hit,blow;
	int a,b,d;
	int aa[4],bb[4];

	while(1){
		d=1000;
		hit=0;
		blow=0;
		scanf("%d %d",&a,&b);
		if(a==0 && b==0) break;
		for(i=0;i<4;i++){
			aa[i]=a/d;
			a=a%d;
			bb[i]=b/d;
			b=b%d;
			d=d/10;
		}
		for(i=0;i<4;i++){
			if(aa[i]==bb[i]) hit++;
			for(j=0;j<4;j++){
				if(aa[i]==bb[j]) blow++;
			}
		}
		printf("%d %d\n",hit,blow-hit);
	}
	return 0;
}

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

int main(){
   int N;
   string S;
   cin >> N >> S;

   for (int i=0; i<S.size(); i++)
      if (S.at(i)+N > 'Z')
         S.at(i) = S.at(i) + N -26;
      else
         S.at(i) = S.at(i) + N;

   cout << S << endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int r = scan.nextInt();
        System.out.println(3 * r * r);
    }
}


Measured memory_bytes: 21204
n, m = list(map(int, input().split()))
par = list(range(n+1))
dis = [0] * (n+1)

def root(x):
  if x == par[x]:
    return x
  r = root(par[x])
  dis[x] += dis[par[x]]
  par[x] = r
  return r

def cost(x):
  # xからxの根までのコスト
  if x == par[x]:
    return 0
  return dis[x] + cost(par[x])

for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が違ってればマージ
  # 同じなら入力されたdistanceがこれまでの入力データからなる
  # 現在の木の構造から計算した数値とあっているか判断
  rootl, rootr = root(l), root(r)
  if rootl != rootr:
    if r != rootr:
      # 直接yにつなげる
      dis[rootl] = d - cost(l)
    else:
      # 根につなげる
      dis[rootl] = d - (cost(l) - cost(r))  # d - (dis[l] - dis[r])
    # ここで親を更新
    par[rootl] = r
  else:
    if d != cost(l) - cost(r):
      print("No")
      exit()

print("Yes")

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

int main(){
    int n;
    cin >> n;
    int total=0;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        total+=a[i];
    }
    int j=total/n;
    int k=j+1;
    int countk=0,countj=0;
    for(int i=0;i<n;i++){
        countj+=(j-a[i])*(j-a[i]);
        countk+=(k-a[i])*(k-a[i]);
    }
    cout << min(countj,countk) << endl;
}


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

#define FAST ios_base:: sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ff first
#define ss second
#define mp make_pair
#define FOR(i,a,b) for(ll i=a; i<b ; i++)

typedef long long ll;

int main(){
	FAST;
	int n,m,c;	cin >> n >> m >> c ;
	int b[m];
	int ans = 0;
	int temp = 0;
	int q;
	for(auto &X :b)	cin >> X;
	for(int i=0; i<n; i++){
		temp = c;
		for(int j=0; j<m ; j++)
			cin >> q , temp+= q*b[j];
		if(temp>0)	ans++;
	}

	cout << ans;
	
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int N,M,X,Y; cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  rep(i,N) cin >> x[i];
  rep(i,M) cin >> y[i];
  int xmax = X;
  int ymin = Y;
  rep(i,N) xmax = max(xmax, x[i]);
  rep(i,M) ymin = min(ymin, y[i]);
  if(xmax < ymin) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long calc(long h, long w) {
    if (h == 1 || w == 1) return 1;
    return (h * w + 1) / 2;
}

void main() {
    long h, w; scan(h, w);
    writeln(calc(h, w));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

using namespace std;

int main(){
    string S;
    int ans;
    cin >> S;
    if(S=="RRR")ans=3;
    else if(S=="RRS" || S=="SRR")ans =2;
    else if(S=="SSS")ans=0;
    else ans=1;
    cout << ans << endl;
}

Measured memory_bytes: 3624
import std.stdio, std.string, std.conv, std.algorithm, std.array;

void main()
{
  while( true ) {
	string[] token = split( strip( readln ) );
	int n = to!int( token[ 0 ] );
	int s = to!int( token[ 1 ] );
	if ( n == 0 && s == 0 ) break;

	int[] r = new int[]( n );
	foreach ( i; 0 .. n ) {
	  r[ i ] = to!int( strip( readln ) );
	}
	sort( r );
	int k = 0;
	int l = n - 1;
	int ans = 0;
	while ( k < l ) {
	  while ( k < l && r[ k ] + r[ l ] > s ) {
		l--;
	  }
	  ans += n - 1 - l;
	  k++;
	}
	foreach ( i; k .. n ) {
	  ans += n - 1 - i;
	}
	writeln( ans );
  }
}

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

#define ll long long
#define pb push_back

vector<ll> pang[100];
ll n;
ll ans;

ll div(ll a){
	if(a==1) return 0;
	ll res = 1;
	for(ll i=2; i*i<=a; i++){
		if(a%i==0){
			res++;
			if(i*i!=a) res++;
		}
	}
	return res;
}

void factorize(ll a){
	ll cur = a;
	for(ll i=2; i*i<=a; i++){
		if(cur%i == 0){
			// ll temp = 1;
			ll po = 0;
			while(cur%i == 0){
				po++;
				cur /= i;
			}
			pang[po].pb(i);
		}
	}
	if(cur > 1){
		pang[1].pb(cur);
	}
}

ll binpow(ll a, ll b){
	ll res = 1;
	while(b){
		if(a&1) res = res * a;
		a = a * a;
		b /= 2;
	}
	return res;
}

int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0), cout.tie(0);
 cin >> n;
 // if(n == 2) {cout << 1 << "\n";}
 ans = 1ll * div(n-1);
 factorize(n);

 ll beda = 0;
 for(int i=0; i<100; i++){
 	if(pang[i].empty()) continue;
 	beda++;
 	ll sz = (int) pang[i].size();
 	ll mask = (1ll<<(sz));
 	for(ll j=1; j<mask; j++){
 		for(ll t=1; t<=i; t++){
 			ll temp = 1;
 			for(ll k=0; k<sz; k++){
 				if((j>>k)&1) temp *= pow(pang[i][k],t);
 			}
 			ll cur = n;
 			while(cur%temp==0) cur/=temp;
 			if(cur%temp == 1) ans++;
 		}
 	}
 }

 if(beda > 1) ans++;

 cout << ans << "\n";

}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n;
int a[1000005];
bool val[1000005];
bool check(int lim){
	int ans=-1;
	for(int i=1;i<=n;i++){
		if(a[i]>lim)val[i]=1;
		else val[i]=0;
	}
	for(int i=n/2+2,j=n/2;i<=n;j--,i++)
	{
		if(val[i]==val[i-1]){
			ans=val[i];
			break;
		}
		if(val[j]==val[j+1]){
			ans=val[j];
			break;
		}
	}
	if(ans==-1) return val[1];
	else return ans;
}
signed main(){
	scanf("%lld",&n);
	n=2*n-1;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	int l=1,r=n,mid;
	while(l<r){
		mid=(l+r)>>1;
		if(check(mid))l=mid+1;
		else r=mid;
	}
	printf("%lld",l);
}

Measured memory_bytes: 3712
#include<stdio.h>
int main(void){
  int N;
  int i;
  int cnt = 1;
  int max = 0;
  
  scanf("%d", &N);
  
  int H[N];
  
  	for(i =0; i < N; i++){
		scanf("%d", &H[i]);
    }
  	max = H[0];
	for(i = 1; i < N; i++){
  		if(H[i - 1] <= H[i] && max <= H[i]){
			cnt++;
          	max = H[i];
		}
    }
  
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>

int main() {
  //入力
  int a,b,c;
  std::scanf("%d%d%d",&a,&b,&c);
  
  if(a < b && b < c) {
    std::printf("Yes");
  }
  else {
    std::printf("No");
  }
  std::printf("\n");
  
  return 0;
}



Measured memory_bytes: 2748
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    long long X;
    cin >> X;

    long long n = 100;
    for (int i = 1; true; i++) {
        n += (n / 100);
        if (n >= X) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3132
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    ans = 0
    for n in range(1,N+1):
        ans += (N//n)*(2*n+(N//n-1)*n)//2
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC113A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            Console.WriteLine(a + b / 2);
            Console.ReadKey();
         }
    }
}


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

int main(){
int n;
cin >> n;
vector <int> a(n);
for (int i = 0; i< n; i++){
cin >> a[i];
}
vector <int> s(n);
s[1] = abs(a[1] - a[0]);
for (int j = 2; j<n;j++){
s[j] = min(s[j-1]+abs(a[j]-a[j-1]),s[j-2]+abs(a[j] - a[j-2]));
}
cout << s[n-1] << "\n";
  return 0;
}


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

int main(){
    i64 ans{};
    string s,t;
    cin>>s>>t;
    for(i64 i=0;i<s.size();i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

//参考URL https://gist.github.com/rigibun/7905920

int main() {
  vector<int> vc;
  int n;
  cin >> n;
  while(n--){
    int x;
    cin >> x;
    vc.push_back(x);
  }

  sort(vc.begin(), vc.end());
  reverse(vc.begin(), vc.end());

  int alice = 0, bob = 0;

  for(int i=0; i<vc.size(); i++){
    if(i % 2 == 0){
      alice += vc[i];
    }
    else{
      bob += vc[i];
    }
  }

  cout << alice - bob << endl;

  return 0;
}

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

a = ""

if n == 0:
    print(0)
else:
    while n != 0:
        if n % (-2) == 0:
            a += "0"
            n = n // -2
        else:
            a += "1"
            n = n // -2 + 1
    b = a[::-1]
    print(b)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();

        var k = 0;
        for (int i = 0; i < s.Length; ++i)
        {
            if (s[i] == t[i])
            {
                continue;
            }

            ++k;
        }

        Console.WriteLine(k);
    }
}


Measured memory_bytes: 27444
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll dp[22][22];
int main()
{
	ll n;
	cin >> n;
	for(int i = 0; i <= 9; i ++)
		dp[i][1] = 1;
	for(int j = 2; j <= 15; j ++)
	{
		for(int i = 0; i <= 9; i ++)
		{
			if(i == 0)
				dp[i][j] = dp[0][j - 1] + dp[1][j - 1];
			else
			if(i == 9)
				dp[i][j] = dp[9][j - 1] + dp[8][j - 1];
			else
				dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1];
		}
	}
	ll ans = 0, flag = 0, l = 1, r = 9;
	for(int j = 1; j <= 15; j ++)
	{
		for(int i = l; i <= r; i ++)
		{
			if(n > dp[i][j])
			{
				n -= dp[i][j];
			}
			else
			{
				ans *= 10;
				ans += i;
				l = max(0, i - 1);
				r = min(9, i + 1);
				if(j == 1 && n == 1)
					flag = 1;
				j -= 2;
				break;
			}
		}
		if(flag)
		break;
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int main(){
	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	ll A[X], B[Y], C[Z];
	vector<ll> ans;
	for(int i=0; i<X; i++) cin >> A[i];
	for(int i=0; i<Y; i++) cin >> B[i];
	for(int i=0; i<Z; i++) cin >> C[i];
	sort(A, A+X);
	sort(B, B+Y);
	sort(C, C+Z);
	for(int i=X-1; i>=0; i--){
		for(int j=Y-1; j>=0; j--){
			for(int k=Z-1; k>=0 && (X-i)*(Y-j)*(Z-k) <= K; k--){
				ans.push_back(A[i]+B[j]+C[k]);
			}
		}
	}
	sort(ans.begin(), ans.end());
	for(int i=0; i<K; i++){
		cout << ans[ans.size()-1-i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  long long max = 0;
  long long ans = 0;
  for (int i = 0; i < n; ++i)
  {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    if (max < a)
    {
      max = a;
      ans = a + b;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
bool check(string s){
    int n = s.length();
    int sum = 0;
    for (int i=0; i<n; i++)
        sum += (s[i]-'0');
    return (sum % 9 == 0);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(check(s))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

#define int long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"

int32_t main()
{
	IOS;
	string a, b, c;
	cin >> a >> b >> c;
	//int p = a.size(), q = b.size(), r = c.size();
	//p++, q++, r++;
	char x = a[0];
	//p--;
	a.erase(a.begin());
	while (1)
	{
		if (x == 'a')
		{
			x = a[0];
			//p--;
			if (a.size())
				a.erase(a.begin());
			else
			{
				cout << "A" << endl;
				return 0;
			}
		}
		else if (x == 'b')
		{
			x = b[0];
			//q--;
			if (b.size())
				b.erase(b.begin());
			else
			{
				cout << "B" << endl;
				return 0;
			}
		}
		else
		{
			x = c[0];
			//r--;
			if (c.size())
				c.erase(c.begin());
			else
			{
				cout << "C" << endl;
				return 0;
			}
		}
	}
	// if (p == 0)
	// 	cout << "A" << endl;
	// else if (q == 0)
	// 	cout << "B" << endl;
	// else
	// 	cout << "C" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 long long int N;
  cin>>N;
  vector<long long int>A(N);
  vector<long long int>ans(N);
  
  for(long long int i=0;i<N;i++){
    cin>>A[i];
    ans[i]=A[i];
  }
  
  sort(ans.begin(),ans.end());
  
  for(long long int i=0;i<N;i++){
    if(A[i]==ans[N-1]){
      cout<<ans[N-2]<<endl;
    }

    else{
      cout<<ans[N-1]<<endl;
    }
  }
  
}


  

Measured memory_bytes: 4736
Imports System.Console
Module Module1
    Dim ans As Integer
    Dim n, k As Integer
    Sub Main()
        n = ReadLine()
        Dim s() As String = ReadLine().Split
        Dim l(n) As Integer
        For i = 1 To n
            l(i) = s(i - 1)
        Next
        Dim ii, iii As Integer
        For i = 1 To n
            For ii = i To n
                For iii = ii To n
                    If l(i) <> l(ii) And l(i) <> l(iii) And l(ii) <> l(iii) Then
                        Dim a As Integer = l(i)
                        Dim b As Integer = l(ii)
                        Dim c As Integer = l(iii)
                        If a + b > c Then
                            If b + c > a Then
                                If c + a > b Then
                                    ans += 1
                                End If
                            End If
                        End If
                    End If
                Next
            Next
        Next
        WriteLine(ans)
    End Sub
End Module


Measured memory_bytes: 28436
#include <iostream>

using namespace std;

int main() {
	int A, B, X;

	cin >> A >> B >> X;

	if (X < A) {
		cout << "NO" << endl;
		return 0;
	}

	if (B >= (X - A)) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long long a,b,x=1000;
	int i;
	scanf("%lld",&a);
	for(i=0;i<20;i++){
		b=a%1000;
		if(753-b<0){
			b=b-753;
		}else{
			b=753-b;
		}
		if(x>b){
			x=b;
		}
		a=a/10;
//		printf("%d\n",b);
		if(a/100==0){
			break;
		}
	}
	printf("%lld",x);
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    string S;
    cin >> S;
    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b)	for(i=a;i<b;i++)
#define mem(a,b) memset(a , b , sizeof a ) ;
#define M 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w;
    cin>>n>>w;
    ll a[n+1][2];
    mem(a,0);
    for(ll i=1;i<n+1;i++)
     for(ll j=0;j<2;j++)
      cin>>a[i][j];
    ll dp[n+1][w+1];
    mem(dp,0);
    for(ll i=1;i<n+1;i++)
    {
        for(ll j=1;j<w+1;j++)
        {
            if(i-1>=0 && j-a[i][0]>=0)
            {
                dp[i][j]=max(dp[i-1][j-a[i][0]]+a[i][1],dp[i-1][j]);
            }
            else if(i-1>=0) dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<vector<ll>> a(n + 1, vector<ll>(3)), dp(n + 1, vector<ll>(3));
	for(int i = 1; i <= n; ++ i)
		for(int j = 0; j <= 2; ++ j) cin >> a[i][j];
	for(int i = 1; i <= n; ++ i) {
		for(int j = 0; j <= 2; ++ j) {
			for(int k = 0; k <= 2; ++ k) {
				if(j == k) continue;
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
			}
		}
	}
	cout << *max_element(all(dp[n])) << '\n';
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define MOD 1000000007
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long  ll;

ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}


int main()
{
    run;
    double d;
    cin>>d;
    //cout<<d;
    double p=d/(3.0);

    double ans=p*p*p;
    std::cout<<std::setprecision(12)<<ans;

}


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

int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a.at(i);
    int answer = 0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            answer = max(answer, abs(a.at(i)-a.at(j)));
        }
    }
    cout<<answer;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n, m;

    cin>>n>>m;
    unordered_map<int, int> a;
    for (int i=0;i<n;i++)
    {
        int k, x;
        cin>>k;
        for (int j=0;j<k;j++)
        {
            cin>>x;
            a[x]++;
        }
    }
    int c=0;
    for (auto x:a)
    {
        if (x.second%n==0)
        {
            c++;
        }
    }
    cout<<c;
    
    return 0;
}

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

using namespace std;
using ll = long long;
int N;
vector<ll> L;
int main(){
    string s;
    cin >> N;
    cin.ignore();

    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        L.push_back(tmp);
    }
    cin.ignore();
    sort(L.begin(), L.end());
    
    ll ans = 0;
    for(int i = 0; i < N; i++){
        for (int j = i + 1; j < N; j++){
            for(int k = j + 1; k < N; k++){
                if(L[i] == L[j] || L[j] == L[k]) continue;
                if(L[i] + L[j] <= L[k]) continue;
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100
w = set()
for i in range(f):
    _w = i * a
    if f < _w: break
    for j in range(f):
        __w = _w + j * b
        if f < __w: break
        w.add(__w)
w.remove(0)
s = set()
for i in range(f):
    _s = i * c
    if f < _s: break
    for j in range(f):
        __s = _s + j * d
        if f < __s: break
        s.add(__s)
m = -1
ans = (0, 0)
for _w in w:
    for _s in s:
        if 100 * _s <= e * _w and _w + _s <= f:
            t = 100 * _s / (_s+_w)
            if m < t:
                ans = (_w+_s, _s)
                m = t
print(*ans)


Measured memory_bytes: 3188
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define LL long long
using namespace std;
LL n,a,b,c,d;
int main()
{
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	n--;
	if(a>b) swap(a,b);
	LL t=b-a;
	for(int i=0;i<=n;i++)
	{
		LL l=-(n-i)*(d-c)+(i-(n-i))*c,r=(d-c)*i+(i-(n-i))*c;
		if(l<=t && r>=t) {printf("YES\n");return 0;}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a,b,c,k;
  int i=0;
  scanf("%d%d%d",&a,&b,&c);
  scanf("%d",&k);
  while(a>=b){
    b*=2;
    i++;
  }
  while(b>=c){
    c*=2;
    i++;
  }
  if(i<=k) printf("Yes");
  else if(i>k) printf("No");
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int ans = 0;

    for (int i = 1; i < N + 1; i++)
    {
        if (to_string(i).length() % 2 != 0)
        {
            ans++;
        }
    }

    cout << ans;
}

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

using namespace std;

int main()
{
    int a,b,i,ci=0,h=0;
    cin>>a>>b;
    string s;
    cin>>s;
    for(i=0; i<s.size(); i++)
    {
        if(int(s[i])>=48 && int(s[i])<=58)
        ci++;
        if(s[i]=='-')
        h++;
    }
    
    if(s[a]=='-'&& h==1 && ci==(a+b))
    cout<<"Yes";
    else
    cout<<"No";

    return 0;
}


Measured memory_bytes: 3604
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            //満点解法2
            (long N, long A) = Slice<long, long>();
            var Xi = Sarray().Select(x => x - A).ToArray();
            var dp = new long[50 + 1, 2500 * 2 + 100];
            var GETA = 2500;
            dp[0, GETA] = 1;
            for (var j = 0; j < N; ++j)
            {
                for (var t = 50; t < 5050; ++t)
                {
                    dp[j + 1, t] += dp[j, t];
                    dp[j + 1, t + Xi[j]] += dp[j, t];
                }
            }
            var ans = dp[N, GETA] - 1;
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 30252
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    cin >> N;
    bool reverseFlag = false;
    deque<int> dq;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    rep(i, N){
        if(reverseFlag == false){
            dq.push_back(a[i]);
            reverseFlag = true;
        }else{
            dq.push_front(a[i]);
            reverseFlag = false;
        }
        // cout << reverseFlag << endl;
    }
    if(reverseFlag == false){
        rep(i, N){
        cout << dq.front() << " ";
        dq.pop_front();
        }
    }else{
        rep(i, N){
        cout << dq.back() << " ";
        dq.pop_back();
    }
    }
    
}

Measured memory_bytes: 4696
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n; cin >> n;
	int a[n];
	forn(i,0,n) cin >> a[i];
	
	int overall_xor = 0;
	forn(i,0,n){
		overall_xor ^= a[i];
	}
	
	forn(i,0,n){
		cout << (overall_xor ^ a[i]) << " ";
	}
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 
 



Measured memory_bytes: 4288
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
	stringstream ss;
	ss << f;
	ss >> t;
}


#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAH/3
#define INF INT_MAH/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(H) cout<<#H<<": "<<H<<endl
#define DEBUG(H) cout<<#H<<": "<<H<<endl
#define MIN(a,b) (a>b?b:a)
#define MAH(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.tHt","r",stdin)
#define OUTFILE()freopen("out0.tHt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

#define MOD 1000000009LL
#define EPS 1e-8


int a[7]={1,3,5,7,8,10,12},b[4]={4,6,9,11},c[1]={2};
int H,W;
char board[101][101];

int main(){
    cin>>H>>W;
    REP(i,H){
        REP(j,W){
            cin>>board[i][j];
        }
    }
    // REP(i,H){
    //     REP(j,W){
    //         cout<<board[i][j];
    //     }
    //     cout<<endl;
    // }
    for(int h=-1;h<H+1;h++){

        for(int w=-1;w<W+1;w++){
            if((h==-1||h==H)||(w==-1||w==W)){
                cout<<'#';
            }
            else{
                cout<<board[h][w];
            }
        }
        cout<<endl;
    }

}


Measured memory_bytes: 256
n, ma, mb = map(int, input().split())
med = [tuple(map(int, input().split())) for _ in range(n)]

INF = 10**8
MAX_M = 400
dp = [[[INF] * (MAX_M + 1) for _ in range(MAX_M + 1)] for _ in range(2)]
dp[0][0][0] = 0
for i, (a, b, c) in enumerate(med):
    i0 = (i + 0) % 2
    i1 = (i + 1) % 2
    for x in range(MAX_M + 1):
        for y in range(MAX_M + 1):
            if x - a >= 0 and y - b >= 0:
                dp[i1][x][y] = min(dp[i0][x][y], dp[i0][x - a][y - b] + c)
            else:
                dp[i1][x][y] = dp[i0][x][y]

ans = INF
for i in range(1, MAX_M + 1):
    if ma * i > MAX_M or mb * i > MAX_M:
        break
    ans = min(ans, dp[n % 2][ma * i][mb * i])
if ans == INF:
    ans = -1

print(ans)


Measured memory_bytes: 47980
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
char s[101010];
int sum[101010],ne[101010][3];
int dp[101010];
int main()
{
	bool jud=true;
	int n,ans=0;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=2;i<=n;i++)
		if(s[i]==s[i-1])
			jud=false;
	if(jud)
	{
		printf("1");
		return 0;
	}
	sum[0]=0;
	for(int i=1;i<=n;i++)
		sum[i]=(sum[i-1]+s[i]-'a'+1)%3;
	ne[n+1][0]=ne[n+1][1]=ne[n+1][2]=n+1;
	for(int i=n;i>=0;i--)
	{
		for(int j=0;j<3;j++)
			ne[i][j]=ne[i+1][j];
		ne[i][sum[i]]=i;
	}
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	for(int i=0;i<n;i++)
	{
		(dp[ne[i][(sum[i]+1)%3]]+=dp[i])%=mod;
		(dp[ne[i][(sum[i]+2)%3]]+=dp[i])%=mod;
	}
	for(int i=1;i<=n;i++)
		if(sum[i]==sum[n])
			(ans+=dp[i])%=mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int a[26] = {};
  string s;
  
  cin >> s;
  
  REP(i,s.size()){
    a[s[i]-'a']++;
  }
  
  REP(i,26) 
    if(a[i] == 0){
      cout << (char)(i + 'a') << endl;
      return 0;
    }

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


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    int count[m],ans=0;
    for (int i=0; i<m; i++){
        count[i]=0;
    }
    for (int i=0; i<n; i++){
        int k;
        scanf("%d",&k);
        for (int j=0; j<k; j++){
            int a;
            scanf("%d",&a);
            count[a-1]++;
        }
    }
    for (int i=0; i<m; i++){
        if (count[i]==n){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0 ;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m, k;
string s;

int main() {
    cin >> n >> k;
    Vi v(n);
    REP(i, n) cin >> v[i];

    V<double> ex(1001);
    REP2(i, 1, 1001) {
        double sum = i * (i + 1) / 2;
        ex[i] = sum / i;
    }

    double maxi = 0;
    double tmp = 0;
    REP(i, k) {
        tmp += ex[v[i]];
    }
    maxi = tmp;
    REP2(i, 1, n-k+1) {
        tmp -= ex[v[i-1]];
        tmp += ex[v[i+k-1]];
        maxi = max(maxi, tmp);
    }

    printf("%.7f\n", maxi);

    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,x[50],y[50],ans=INF;
map<pair<int,int>,bool> m;

signed main() {
    cin >> n;
    if (n==1) {
        cout << 1 << endl;
        return 0;
    }
    rep(i,n) cin >> x[i] >> y[i],m[mp(x[i],y[i])] = true;
    rep(i,n) {
        rep(j,n) {
            auto tmp = m;
            int p,q,cnt=n;
            p = x[i]-x[j];
            q = y[i]-y[j];
            if (!p && !q) continue;
            rep(k,n) {
                if (tmp[mp(x[k]-p, y[k]-q)]) {
                    cnt--;
                }
            }
            ans = min(ans,cnt);
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


set<int> cols;
int cnt[100005];


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

    int n;
    cin>>n;
    for(int i=0;i<n;i++){
    	int a;
    	cin>>a;
    	cnt[a]++;
    	cols.insert(a);
    }

    if((int)cols.size() > 2){
    	cout<<"No";
    	return 0;
    }

    if((int)cols.size() == 1){

    	int c = (*cols.begin());
    	if(c == n-1 || c <= (n/2)){
    		cout<<"Yes";
    		return 0;
    	}
    	cout<<"No";
    	return 0;
    }

    int c2 = (*cols.begin()), c1 = (*cols.rbegin());
    if(c2 == c1-1 && c1-cnt[c2] >= 1 && c1-cnt[c2] <= cnt[c1]/2)	cout<<"Yes";
    else	cout<<"No";
    return 0;
}












Measured memory_bytes: 5376
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string s; int a; cin>>a>>s;
    cout << ((a<3200) ? "red":s) << endl; return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(xy[0] + xy[1] / 2);
    }
}


Measured memory_bytes: 28116
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	dx = []int{1, 0, -1, 0}
	dy = []int{0, 1, 0, -1}
)

func solve() {
	h, w := getInt(), getInt()
	s := make([][]rune, h)
	for i := range s {
		s[i] = getRunes()
	}

	qx := make([]int, 0)
	qy := make([]int, 0)
	pop := func() (int, int) {
		x, y := qx[0], qy[0]
		qx = qx[1:]
		qy = qy[1:]
		return x, y
	}
	push := func(x, y int) {
		qx = append(qx, x)
		qy = append(qy, y)
	}

	ans := -1
	for y := range s {
		for x, masu := range s[y] {
			if masu == '#' {
				continue
			}

			dist := make([][]int, h)
			for i := range dist {
				dist[i] = make([]int, w)
				for j := range dist[i] {
					dist[i][j] = -1
				}
			}

			push(x, y)
			dist[y][x] = 0
			for len(qx) > 0 {
				curx, cury := pop()
				for i := 0; i < 4; i++ {
					nx, ny := curx+dx[i], cury+dy[i]
					if nx < 0 || ny < 0 || nx >= w || ny >= h {
						continue
					}
					if s[ny][nx] == '#' {
						continue
					}
					if dist[ny][nx] != -1 {
						continue
					}

					dist[ny][nx] = dist[cury][curx] + 1
					push(nx, ny)
				}
			}
			for i := range dist {
				for _, d := range dist[i] {
					ans = max(ans, d)
				}
			}
		}
	}

	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 5376
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
    char a[16], b[16], c[16];
    scanf("%s %s %s", a, b, c);

    if (a[strlen(a)-1] == b[0]
        && b[strlen(b)-1] == c[0]
    ) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 128