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

using namespace std;

int main(int argc, char *argv[]) {
	int N = 0;  // マスの数
	int M = 0;  // 料金所の数
	int X = 0;  // 現在いるマス
	cin >> N >> M >> X;

	int current_M;
	std::vector<int> line(N + 1, 0);
	for (int i = 0; i < M; i++) {
		cin >> current_M;
		line[current_M] = 1;
	}

	int back_cost = 0;
	for (int j = X; j >= 0; j--) {
		back_cost += line[j];
	}
	int forward_cost = 0;
	for (int k = X; k <= N; k++) {
		forward_cost += line[k];
	}
	
	int min_cost = (back_cost <= forward_cost) ? back_cost : forward_cost;
	cout << min_cost << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    char S[4];
    scanf("%s", S);
    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R') printf("3\n");
    else if(S[1] == 'R' && (S[0] == 'R' || S[2] == 'R')) printf("2\n");
    else if(S[0] == 'R' || S[1] == 'R' || S[2] == 'R') printf("1\n");
    else printf("0\n");
    return 0;
}

Measured memory_bytes: 1636
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int64_t a[n];
    int i,zero=0;
    for (i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0) zero++;
    }
    if(zero>0){
        cout << 0 << endl;
        return 0;
    }
    int64_t mul=1;
    for(i=0;i<n;i++){
        if(a[i]<= (1000000000000000000/mul)){
            mul *= a[i];
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << mul << endl;
}

Measured memory_bytes: 4372
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-15;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
struct Point{double x,y;};
double dis(Point a,Point b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
Point tri(Point a, Point b, Point c){
  double a1,a2,b1,b2,c1,c2;
  a1=2*(b.x-a.x);
  b1=2*(b.y-a.y);
  c1=a.x*a.x-b.x*b.x+a.y*a.y-b.y*b.y;
  a2=2*(c.x-a.x);
  b2=2*(c.y-a.y);
  c2=a.x*a.x-c.x*c.x+a.y*a.y-c.y*c.y;
  Point p;
  p.x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
  p.y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
  return p;
}
int main(){
  startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,k,l,N;
  cin>>N;
  double ans=inf,res;
  vector<Point> v(N);
  Point x;
  rep(i,N)cin>>v[i].x>>v[i].y;
  rep(i,N)For(j,i+1,N){
    res=dis(v[i],v[j])*0.5;
    x.x=(v[i].x+v[j].x)/2;
    x.y=(v[i].y+v[j].y)/2;
    rep(k,N){
      if(i==k||j==k)continue;
      if(dis(x,v[k])>res+eps){
        res=inf;
        break;
      }
    }
    chmin(ans,res);
  }
  rep(i,N)For(j,i+1,N)For(k,j+1,N){
    if((v[i].x-v[k].x)*(v[j].y-v[k].y)!=(v[i].y-v[k].y)*(v[j].x-v[k].x)){
      x=tri(v[i],v[j],v[k]);
      res=dis(x,v[i]);
      rep(l,N){
        if(dis(x,v[l])>res+eps){
          res=inf;
          break;
        }
      }
      chmin(ans,res);
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	string s;cin>>s;
	ll sum=0;
	int n = s.length();
	for(int i=0;i<n;i++){
		sum += int(s[i])-'0';
	}
	if(sum%9==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3708
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

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

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	X, Y, Z, K := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(X)
	B := sc.nextIntSlice(Y)
	C := sc.nextIntSlice(Z)
	AB := make([]int, X*Y)
	cnt := 0
	for i := 0; i < X; i++ {
		for j := 0; j < Y; j++ {
			AB[cnt] = A[i] + B[j]
			cnt++
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(AB)))
	sort.Sort(sort.Reverse(sort.IntSlice(C)))
	D := make([]int, min(K, X*Y)*min(K, Z))
	cnt = 0
	for i := 0; i < min(K, X*Y); i++ {
		for j := 0; j < min(K, Z); j++ {
			D[cnt] = AB[i] + C[j]
			cnt++
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(D)))
	for i := 0; i < K; i++ {
		fmt.Fprintln(wtr, D[i])
	}
}


Measured memory_bytes: 33024
//
//  abc114_c.cpp
//
//
//  Created by Yoshida Satoshi on 2018/12/02.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    int n;
    cin>>n;
    
    int ans=0;
    for(int i=0;i<(1<<18);i++)
    {
        int k=i;
        int p=0;
        int num[4]={};
        int keta=100;
        bool flag=true;
        for(int j=0;j<9;j++)
        {
            p*=10;
            if(k%4!=0&&keta==100) keta=j;
            if(k%4==1) p+=3;
            if(k%4==2) p+=5;
            if(k%4==3) p+=7;
            if(j>keta&&k%4==0) flag=false;
            num[k%4]++;
            k=k/4;
        }
        if(flag&&num[1]>0&&num[2]>0&&num[3]>0&&p<=n)
        {
            ans++;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
const int maxn = 1e5+10;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
int d[4][2]={1,0,0,1,-1,0,0,-1};
int n;
ll a,b,c;
string s[maxn];
int main() {
    ios::sync_with_stdio(0);
    #ifdef Uncle_drew
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #else
    #endif
    string ans;
    cin>>n>>a>>b>>c;
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<n;i++){
//    	if (a==1&&b==1){
//			if (s[i+1]=="BC"){
//    			a--,b++,ans+="B\n";
//			}
//			else{
//    			b--,a++,ans+="A\n";
//			}
//			continue;
//		}
//		if (a==1&&c==1){
//			if (s[i+1]=="BC"){
//    			a--,c++,ans+="C\n";
//			}
//			else{
//    			c--,a++,ans+="A\n";
//			}
//			continue;
//		}
//		if (b==1&&c==1){
//			if (s[i+1]=="AC"){
//    			b--,c++,ans+="C\n";
//			}
//			else{
//    			c--,b++,ans+="B\n";
//			}
//			continue;
//		}
        if(s[i]=="AB"){
	        if (a==1&&b==1){
				if (s[i+1]=="BC"){
	    			a--,b++,ans+="B\n";
				}
				else{
	    			b--,a++,ans+="A\n";
				}
				continue;
			}
            if(a>b) a--,b++,ans+="B\n";
            else b--,a++,ans+="A\n";
        }
        if(s[i]=="AC"){
        	if (a==1&&c==1){
				if (s[i+1]=="BC"){
	    			a--,c++,ans+="C\n";
				}
				else{
	    			c--,a++,ans+="A\n";
				}
				continue;
			}
            if(a>c) a--,c++,ans+="C\n";
            else c--,a++,ans+="A\n";
        }
        if(s[i]=="BC"){
	        if (b==1&&c==1){
				if (s[i+1]=="AC"){
	    			b--,c++,ans+="C\n";
				}
				else{
	    			c--,b++,ans+="B\n";
				}
				continue;
			}
            if(c>b) c--,b++,ans+="B\n";
            else b--,c++,ans+="C\n";
        }
        if(a<0||b<0||c<0){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes\n"<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6824
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <iostream>
using namespace std;

#define x first
#define y second
typedef pair<int,int> pii;

#define INF 1e9

int main() {
	int W, H;
	const int symbol[] = {'S', '1', '2', '3', '4', '5', 'G'};
	while(cin >> W >> H, W || H) {
		vector<string> in;
		for(int i = 0; i < H; i++) {
			string s;
			cin >> s;
			in.push_back(s);
		}
		vector<vector<pii> > vertex(7);
		for(int i = 0; i < in.size(); i++) {
			for(int j = 0; j < in[i].size(); j++) {
				for(int k = 0; k < 7; k++) {
					if(in[i][j] == symbol[k])
						vertex[k].push_back(pii(j,i));
				}
			}
		}

		pii ans(INF, 0);
		for(int i = 0; i < 5; i++) {
			vector<vector<int> > cost;
			for(int j = 0; j < 5; j++) {
				cost.push_back(vector<int>(vertex[j+1].size(), INF));
			}

			for(int j = 0; j < cost[(i+1)%5].size(); j++) {
				cost[(i+1)%5][j] = abs(vertex[(i+1)%5+1][j].x - vertex[0][0].x) + abs(vertex[(i+1)%5+1][j].y - vertex[0][0].y);
			}

			for(int j = 1; j < 4; j++) {
				for(int k = 0; k < cost[(i+j)%5].size(); k++) {
					for(int l = 0; l < cost[(i+j+1)%5].size(); l++) {
						cost[(i+j+1)%5][l] =
							min(cost[(i+j+1)%5][l], cost[(i+j)%5][k] + abs(vertex[(i+j)%5+1][k].x - vertex[(i+j+1)%5+1][l].x) + abs(vertex[(i+j)%5+1][k].y - vertex[(i+j+1)%5+1][l].y));
					}
				}
			}

			pii tmp(INF, 0);
			for(int j = 0; j < cost[(i+4)%5].size(); j++) {
				if(tmp.first > cost[(i+4)%5][j] + abs(vertex[(i+4)%5+1][j].x - vertex[6][0].x) + abs(vertex[(i+4)%5+1][j].y - vertex[6][0].y)) {
					tmp.first = cost[(i+4)%5][j] + abs(vertex[(i+4)%5+1][j].x - vertex[6][0].x) + abs(vertex[(i+4)%5+1][j].y - vertex[6][0].y);
					tmp.second = i;
				}
			}

			if(ans > tmp)
				ans = tmp;
		}
		if(ans.first == INF)
			cout << "NA" << endl;
		else
			cout << ans.second + 1 << " " << ans.first << endl;;
	}
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#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;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll fac(ll n){
    if (n > 0) {
        return  n * fac(n - 1);
    }else{
        return 1;
    }
}

ll n,ans = 0;

void count753(ll x,bool a,bool b,bool c){
    if (n < x)return;
    if (a && b && c)++ans;
    count753(x * 10 + 3, true, b, c);
    count753(x * 10 + 5, a, true, c);
    count753(x * 10 + 7, a, b, true);
}

int main()
{
    cin >> n;
    count753(0,0,0,0);
    cout << ans << endl;
    return 0;
}


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

int main() {
	string s;
	cin>>s;
	int C=0;
	int F=0;
	int e=s.size();
	for(int i=0;i<e;i++) {
		if(s[i]=='C') {
			C=i;
			break;
		}
	}
	for(int i=C;i<e;i++) {
		if(s[i]=='F') {
			F=i;
			break;
		}
	}
	if(C<F) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i, n) {
    cin>>a[i];
  }
  dump(a);

  vi b(n);

  rep(i, 1, n){
    b[i] = 2*a[i-1] - b[i-1];
  }
  dump(b);

  int s = accumulate(all(a), 0LL);
  int t = accumulate(all(b), 0LL);
  dump(s,t);

  int x = s - t;
  rep(i, n){
    if (i%2==0) {
      b[i] += x;
    }
    else{
      b[i] -= x;
    }
  }
  rep(i, sz(b)) cout << b[i] << (i!=sz(b)-1 ? " " : "\n");

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 2944
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int> > graph(n);
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<int> dist(n, -1);
    vector<int> ans(n, 0);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while(!que.empty())
    {
        int v = que.front(); que.pop();
        for(int nv : graph[v])
        {
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v]+1;
            ans[nv] = v+1;
            que.push(nv);
        }
    }
    cout << "Yes" << endl;
    for(int v=1; v<n; v++) cout << ans[v] << endl;
    return 0;
}


Measured memory_bytes: 10656
import sys

x = int(next(sys.stdin).strip())
n = x // (6 + 5)
r = x % (6 + 5)

if r == 0:
    print(n * 2)
elif r <= 6:
    print(n * 2 + 1)
else:
    print(n * 2 + 2)


Measured memory_bytes: 3064
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = nextInt();

        int Answer = 0;

        if (n % 2 == 0) {
        	Answer = (n / 2) - 1;
        } else {
        	Answer = (n - 1) / 2;
        }

        println(Answer);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#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 VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int H,W,N;
vector <int > a;





int main()
{

	cin >> H >> W >> N;

	a.resize(N);
	REP(i,N){
		cin >> a[i];
	}
	int aa = 0;
	int b = 1;
	int count = 0;

	REP(i,H){
		vector <int> s;
		REP(j,W){
			if(aa%2 == 0)
				s.push_back(b);
			else
				s.insert(s.begin(),b);
			count++;
			if(count >= a[b-1]){
				b++;
				count=0;
			}
		}
		REP(j,W){
			cout << s[j] << " ";
		}
		cout << endl;
		aa++;
	}

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
//#define DEBUG
//#define RANDOM
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, x, m;
    // rekurencia sa zacykli po max m krokoch
    cin >> n >> x >> m;
    vector<ll> when(m, -1); // kedy naposledy sme navstivili toto policko
    vector<ll> sum(m, -1); // a aky bol vtedy sucet
    ll ans = 0;
    ll a_now = x;
    ll cycle_len = 0, cycle_sum = 0, pre_len = 0, pre_sum = x;
    // potrebujeme vediet:
    // dlzku cyklu, sucet cyklu, dlzku predperiody a sucet predperiody,
    sum[x] = x;
    when[x] = 0;
    a_now = (a_now * a_now) % m;
    for (int i = 1;; i++)
    {
        if (i >= n)
        {
            cout << pre_sum << "\n";
            return 0;
        }
        if (when[a_now] > -1)
        {
            cycle_len = i - when[a_now];
            cycle_sum = pre_sum - sum[a_now] + a_now;
            pre_len = i;
            break;
        }
        sum[a_now] = pre_sum + a_now;
        pre_sum += a_now;
        when[a_now] = i;
        ll nw = (a_now * a_now) % m;
        a_now = nw;
    }
    ans = pre_sum;
    n -= pre_len;
    ans += cycle_sum * (n / cycle_len);
    n %= cycle_len;
    for (int i = 0; i < n; i++)
    {
        ans += a_now;
        a_now = (a_now * a_now) % m;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4776
def func(r, V, edge):
    c = [float("inf")] * V
    update = True
    loop = 0
    c[r] = 0
    while update:
        update = False
        for s in range(V):
            for t, d in edge[s]:
                temp = c[s] + d
                if temp < c[t]:
                    c[t] = temp
                    update = True

        loop += 1
        if loop == V:
            break
        
    if loop == V and update:
        c[r] = float("inf")

    return c
            

V, E, r = map(int, input().split())
edge = [[] for _ in range(V)]
for _ in range(E):
    s, t, d = map(int, input().split())
    edge[s].append([t, d])

c = func(r, V, edge)

if c[r] == float("inf"):
    print("NEGATIVE CYCLE")
else:
    for temp in c:
        if temp == float("inf"):
            print("INF")
        else:
            print(temp)
            



Measured memory_bytes: 6064
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long int ;
 
 
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
 
    ll a,b,m;
    ll ans = 200001;
 
    cin >> a >> b >> m;

    vector<ll> ac(a), bc(b);

    ll tmp = 100001;
    for(int i=0; i<a; i++){
        cin >> ac[i];
        tmp = min(tmp, ac[i]);
    }

    for(int i=0; i<b; i++){
        cin >> bc[i];
        ans = min(ans, bc[i]+tmp);
    }

    for(int i=0; i<m; i++){
        ll x,y,c;
        cin >> x >> y >> c;
        ans = min(ans, ac[x-1] + bc[y-1] - c);
    }

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

Measured memory_bytes: 1792
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if int(l[i])==int(l[j]) or int(l[i])==int(l[k]) or int(l[k])==int(l[j]):
                ans += 0
            elif int(l[i])+int(l[j])>int(l[k]) and int(l[i])+int(l[k])>int(l[j]) and int(l[k])+int(l[j])>int(l[i]):
                ans += 1
            else:
                ans += 0
                
if n <= 2:
    print(0)
else:
    print(ans)

Measured memory_bytes: 9228
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, m) = readLongList()
    val aList = readLongList()

    val divCount = countDiv(aList.first(), 2)
    for (a in aList.drop(1)) {
        val count = countDiv(a, 2)
        if (divCount != count) {
            println(0)
            return
        }
    }

    var t = aList.first() / 2
    for (a in aList) {
        t = lcm(t, a / 2)
    }

    println((m / t + 1) / 2)
}


/** O(log(n)) */
tailrec fun countDiv(n: Long, divisor: Long, count: Long = 0L): Long =
    if (n % divisor == 0L) countDiv(n / divisor, divisor, count + 1) else count

/** O(log(n)): n = min(a, b) */
tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

/** O(log(n)): n = min(a, b) */
fun lcm(a: Long, b: Long) = a / gcd(a, b) * b

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


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

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        int N = cin.Int();
        int[] A = cin.ArrayInt(N);

        int odd = 0, num = 0; //odd:奇数の個数,num:4の倍数の個数
        foreach(var x in A)
        {
            if (x % 2 != 0) odd++;
            else if (x % 4 == 0) num++;
        }

        if (num + odd == A.Length) Console.WriteLine(num>= odd - 1 ? "Yes" : "No");
        else Console.WriteLine(num >= odd ? "Yes" : "No");
        Console.ReadLine();
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 18400
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    Map Ma;
    for(ll i=0;i<N;++i)cin>>A[i];
    for(ll i=0;i<N;++i)Ma[A[i]]++;
    for(ll i=N-1;i>=0;i-=2){
        if(i!=0)
        if(Ma[i]!=2){prt(0)return 0;}
        if(i==0)
        if(Ma[i]!=1){prt(0)return 0;}
    }
    ll ans=1;
    for(auto p: Ma){ans*=p.second;ans%=MOD;}
    prt(ans)


    return 0;
}


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

using namespace std;

const int MAX_N = 1e5 + 5;

vector<int> adj [MAX_N];
int dp [MAX_N];

void dfs (int u) {
  vector<int> dps;
  for (int nxt : adj[u]) {
    dfs(nxt);
    dps.push_back(dp[nxt]);
  }

  sort(dps.begin(), dps.end(), greater<int>());
  for (int i = 0; i < (int) dps.size(); i++) {
    dp[u] = max(dp[u], dps[i] + i);
  }
  dp[u]++;
}

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int p;
    cin >> p;

    adj[p].push_back(i);
  }

  dfs(1);

  cout << dp[1] - 1 << endl;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/


int main(){
    int x,y,z,k; cin >> x >> y >> z >> k;

    vector<ll> a(x), b(y), c(z);
    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];

    vector<ll> ab;
    for(int i=0; i<x; i++){
        for(int j=0; j<y; j++){
            ab.push_back(a[i]+b[j]);
        }
    }

    sort(ab.begin(), ab.end(), greater<ll>());
    vector<ll> sub;
    for(int i=0; i<min(x*y, k); i++){
        sub.push_back(ab[i]);
    }

    vector<ll> ans;
    for(int i=0; i<sub.size(); i++){
        for(int j=0; j<z; j++){
            ans.push_back(sub[i]+c[j]);
        }
    }

    sort(ans.begin(), ans.end(), greater<ll>());
    for(int i=0; i<k; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 43400
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];

	vector<VI> dp(N + 1, VI(3, 0));

	eFOR(i, 1, N) {

		if (i % 2) {
			if (i != 1)dp[i][2] = max(dp[i - 1][1], dp[i - 2][2]) + A[i - 1];
			else dp[i][2] = max(dp[i - 1][1], 0LL) + A[i - 1];

			if (i != 1)dp[i][1] = max(dp[i - 1][0] + A[i - 1], dp[i - 2][0] + A[i - 1]);
			else dp[i][1] = 0;

			dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]);
		}
		else {
			if (i != 1)dp[i][2] = max(dp[i - 1][0], dp[i - 2][1]) + A[i - 1];
			else dp[i][2] = max(dp[i - 1][0], A[i - 1]);

			dp[i][1] = dp[i - 1][2];
			dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
		}

	}




	if (N % 2)cout << max(dp[N][0], dp[N][1]) << endl;
	else cout << max(dp[N][2], dp[N][1]) << endl;



	return 0;
}



Measured memory_bytes: 15592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N; cin >> N;
    LL ans = (N / 11) * 2;
    if(N % 11 >= 7) ans += 2;
    else if(N % 11 == 0) ;
    else ans += 1;

    cout << ans << endl;

}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

struct bank
{
	int id,r,type;
	double ret;

	bool operator<(const bank &b) const
	{
		return ret < b.ret;
	}
};

int main()
{
	int n;
	while(cin >> n && n)
	{
		int y;
		cin >> y;

		vector<bank> v;
		v.resize(n);
		
		rep(i,n)
		{
			cin >> v[i].id >> v[i].r >> v[i].type;

			if(v[i].type == 1)
			{
				v[i].ret = 10000.0 * (1.0 + double(y) * (v[i].r / 100.0));
			}
			else
			{
				v[i].ret = 10000.0 * pow(1.0 + (v[i].r/100.0),y);
			}
		}

		sort(v.begin(),v.end());

		cout << v[v.size()-1].id << endl;
	}
}

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

using namespace std;

int main(void){
  int g;
  
  cin>>g;
  
  if(g<1200)
    cout<<"ABC"<<endl;
  else if(g<2800)
    cout<<"ARC"<<endl;
  else
    cout<<"AGC"<<endl;
  
  return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long n = sc.nextLong();
        int to = (int) Math.round(Math.sqrt(n));
        int ans = Integer.MAX_VALUE;
        for(long a = 1L; a<=to; a++) {
            if(n%a==0){
                long b = n/a;
//                System.out.println(a+" "+b);
                if(ans > String.valueOf(Math.max(a, b)).length()){
                    ans = String.valueOf(Math.max(a, b)).length();
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35648
#include<iostream>
#include<stdio.h>
 using namespace std;
int main()
{
    int h, w;
    int i, j;
    cin >> h;
    cin >> w;
    while (h != 0 || w != 0){
        for (i = 0; i < h; i++){
            for (j = 0; j < w; j++){
                cout << "#";
            }
            std::cout << "\n";
        }
        cout << "\n";
        cin >> h;
        cin >> w;
    }
    return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N , L;
  cin>>N>>L;
  vector<string> vec(N);
  for(int i = 0 ; i<N;i++){
    cin>>vec.at(i) ;
  }
  sort (vec.begin(),vec.end()) ;
  for(int i = 0 ; i < N ; i++ ){
    cout<<vec.at(i) ;
  }
  cout<<endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll> x(n),y(n);
    rep(i,n)cin>>x[i]>>y[i];

    vector<ll> a(n),b(n);

    ll a_max=-1e11,b_max=-1e11,a_min=1e11,b_min=1e11;

    rep(i,n){
        a[i]=x[i]+y[i];
        b[i]=x[i]-y[i];
        a_max=max(a_max,a[i]);
        b_max=max(b_max,b[i]);
        a_min=min(a_min,a[i]);
        b_min=min(b_min,b[i]);
    }
    ll ans=max(a_max-a_min,b_max-b_min);
    cout<<ans<<endl;
}

Measured memory_bytes: 9576
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll a[100002] = {};
ll b[100001] = {};
int main() {
	ll n; cin >> n;
	repe(i, 1, n + 1) cin >> a[i];
	repe(i,1,n)cin >> b[i];


	ll ans = 0;
	repe(i, 1, n) {
		if (a[i] >= b[i]) {
			ans += b[i];
		}
		else {
			ans += a[i];
			ll r = b[i] - a[i];
			if (a[i + 1] >= r) {
				ans += r;
				a[i + 1] -= r;
			}
			else {
				ans += a[i + 1];
				a[i + 1] = 0;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sumA = 0
sumB = 0
for i in range(N):
    sumA += A[i]
    sumB += B[i]
ruisekiA = [sumA]
ruisekiB = [sumB]
for i in range(1, N):
    ruisekiA.append(ruisekiA[i-1] - A[i-1])
    ruisekiB.append(ruisekiB[i-1] - B[i-1])

kouho = []
for i in range(N):
    kouho.append(sumA-ruisekiA[i]+A[i]+ruisekiB[i])
print(str(max(kouho)))

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

int main()
{
	int n,m;
	cin>>n;
	cin>>m;
	int ax[n+1];
	int ay[m+1];
  	cin>>ax[0];
  	cin>>ay[0];
	for(int i=1;i<=n;i++)
	{
		cin>>ax[i];
	}
	for(int i=1;i<m+1;i++)
	{
		cin>>ay[i];
	}
	sort(ax,ax+n+1);
	sort(ay,ay+m+1);
	if(ax[n]>=ay[0])
		cout<<"War";
	else
		cout<<"No War";
	return 0;
}


Measured memory_bytes: 256
public class Main {

	/**
	 * ?????????????????????
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
	}

}

Measured memory_bytes: 16848
#include<stdio.h>

int main()

{
	int a,b,s=0;
	scanf("%d%d",&a,&b);
	s=b-a;
	if(b>0){
		printf("%d",b+s);
	}
	else{
		printf("%d",s);
	}
	
	



	return 0;
}

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

def printStrAsList(strAsList):
  result = ''
  for chrItem in strAsList:
    result += chr(97 + chrItem)
  print(result)

def printList(strAsList):
  loopTimes = max(strAsList) + 1
  isLastChr = len(strAsList) == n-1
  for i in range(loopTimes + 1):
    if isLastChr:
      printStrAsList(strAsList + [i])
    else:
      printList(strAsList + [i])

if n == 1:
  print('a')
else:
  printList([0])

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<N-2;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C'){
        ans++;
      }
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
 
namespace Sample
{
  class Program
  {
    static void Main()
    {
        
      string dummy = Console.ReadLine();
      string val = Console.ReadLine();
      string cost = Console.ReadLine();
      
      char[] separator1 = new char[] {' '};
      string[] splitted1 = val.Split(separator1);
      int[] val1 = new int[20];
      for(int i=0; i<splitted1.Length; ++i)
      {
          val1[i] = int.Parse(splitted1[i]);
      }
      
      char[] separator2 = new char[] {' '};
      string[] splitted2 = cost.Split(separator2);
      int[] cost1 = new int[20];
      for(int i=0; i<splitted2.Length; ++i)
      {
          cost1[i] = int.Parse(splitted2[i]);
      }
      
      int res = 0;
      for(int i=0; i<val1.Length; i++)
      {
          if(val1[i] > cost1[i])
          {
              res += (val1[i] - cost1[i]);
          }
      }
      
      Console.WriteLine(res);
      
    }
  }
}

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

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

  vector<int> v(3);
  for(int i = 0; i < 3; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  cout << v[0] + v[1] + v[2]*10 << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans1=max(a)
m=10**9+1
temp=ans1/2
i=0
for index,val in enumerate(a):
    if val==ans1: continue
    if abs(val-temp)<m:
        m=abs(val-temp)
        i=index
ans2=a[i]
print(ans1,ans2)

Measured memory_bytes: 20116
n = int(input())
s = input()
#長さnの文字列s
def gene_hash(i,j): #特定範囲のハッシュを返す s[i:j]
    return (hash1[j]-hash1[i]*power1[j-i]%mod1)%mod1

base1 = 1007
mod1 = 10**9+7

hash1 = [0]*(n+1)
power1 = [1]*(n+1)

for i,e in enumerate(s):
    hash1[i+1] = (hash1[i]*base1 + ord(e))%mod1
    power1[i+1] = (power1[i]*base1)%mod1
    
lef = 0
rig = n//2 + 1

while rig - lef > 1:
    mid = (rig+lef)//2
    Flag = False
    for i in range(n-2*mid+1):
        if Flag:
            break
        now = gene_hash(i,i+mid)
        for j in range(i+mid,n-mid+1):
            if now == gene_hash(j,j+mid):
                Flag = True
                break
    if Flag:
        lef = mid
    else:
        rig = mid
print(lef)

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

int main() {
    string S;
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    bool yes = true;
    if (a > 8 || b > 8) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
#define USINT_MAX 4294967295

int main() {
	char s[100];
	int a = 0, b = 0,temp=0,temp2=0;
	cin >> s;
	for (int i = 0; i < 100; i++) {
		if (s[i] == 'C') { a = 1; temp = i; }
		if (s[i] == 'F') { b = 1; temp2 = i; }
	}
	if (temp > temp2)a = 0;
	if (a == 1 && b == 1)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

e_count = 0
for s in S:
  if s == 'E':
    e_count += 1

min_inv = float('infinity')
    
for s in S:
  if s == 'E':
    e_count -= 1
  
  min_inv = min(e_count, min_inv)
  
  if s == 'W':
    e_count += 1

print(min_inv)


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

const int MAXN = 1e6 + 5;

int n, a[MAXN], cnt[MAXN], gcdd;
vector<int> v[MAXN];

template <class T>
void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

bool isprime(int x) {
    for (int i = 2; i <= sqrt(x); i++)
        if (x % i == 0) return false;
    return true;
}

void init() {
    for (int i = 2; i <= MAXN - 5; i++)
        for (int k = 1; isprime(i) && k * i <= MAXN - 5; k++)
            v[k * i].push_back(i);
}

int main() {
    init();
    read(n);
    for (int i = 1; i <= n; i++) read(a[i]);
    bool tag = 1;
    for (int i = n; i >= 1; i--) {
        for (int j = 0; j < v[a[i]].size(); j++)
            if (cnt[v[a[i]][j]]) {
                tag = 0;
                break;
            }
        for (int j = 0; j < v[a[i]].size(); j++) cnt[v[a[i]][j]]++;
    }
    gcdd = a[1];
    for (int i = 2; i <= n; i++) gcdd = __gcd(a[i], gcdd);
    if (tag)
        cout << "pairwise coprime";
    else if (gcdd == 1)
        cout << "setwise coprime";
    else
        cout << "not coprime";
    return 0;
}


Measured memory_bytes: 66732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

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

    bool flag = true;

    if(S[0] != 'A') {
        flag = false;
    }

    bool has_C = false;
    ll ci;
    for(ll i = 2; i < S.length() - 1; ++i) {
        if(!has_C) {
            if(S[i] == 'C') {
                has_C = true;
                ci = i;
            }
        } else {
            if(S[i] == 'C') {
                has_C = false;
                break;
            }
        }
    }
    if(!has_C) {
        flag = false;
    }

    if(flag) {
        REP(i, S.length()) {
            if(i != 0 && i != ci && !(S[i] >= 'a' && S[i] <= 'z')) {
                flag = false;
                break;
            }
        }
    }

    if(flag) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll H, W, D;
ll A[400][400];
ll Q;
ll L[101010];
ll R[101010];

using Pii = pair<int, int>;
map<int, Pii> mp;

ll sum[201010];

int main() {
  cin >> H >> W >> D;
  repe(i, 1, H) {
    repe(j, 1, W) {
      cin >> A[i][j];
      mp[A[i][j]] = make_pair(i, j);
    }
  }
  cin >> Q;
  rep(i, 0, Q) { cin >> L[i] >> R[i]; }

  for (int i = 1; i <= D; ++i) {
    ll cur_num = i;
    while (cur_num <= H * W) {
      auto cur = mp[cur_num];
      cur_num += D;
      auto next = mp[cur_num];
      sum[cur_num] = sum[cur_num - D] + abs(cur.first - next.first) +
                     abs(cur.second - next.second);
    }
  }

  rep(i, 0, Q) {
    ll l = L[i];
    ll r = R[i];

    ll cur_num = l;
    ll ans = sum[r] - sum[l];

    cout << ans << "\n";
  }
}


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

using namespace std;

int main() {
	int caso;
	int lado_1, lado_2, lado_3;
	
	vector<int> triangle;
	
	cin >> caso;
	
	for(int index = 0; index < caso; ++index) {
		
		triangle.clear();
		
		cin >> lado_1 >> lado_2 >> lado_3;
		triangle.push_back(lado_1);
		triangle.push_back(lado_2);
		triangle.push_back(lado_3);
	
		sort(triangle.begin(), triangle.end());
		
		if( pow(triangle[0], 2) + pow(triangle[1], 2) == pow(triangle[2], 2) )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3072
S_ = input()
T = input()
a = S_
b = T
def fit(pat, word):
    return all([pi==wi for pi, wi in zip(pat, word) if pi != '?'])

ret = False
for i in reversed(range(len(a)-len(b)+1)):
    if fit(a[i:i+len(b)], b):
        ret = a[:i]+b+a[i+len(b):]
        break    
    
if not ret:
    print('UNRESTORABLE')
elif not '?' in a:
    print(a)
else:
    print(ret.replace('?', 'a'))



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

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	
	X = X - A;
	int numB = X/B;
	X = X - (B*numB);
	
	cout << X;
	
	cout << endl;
	
	return 0;
}

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

using namespace std;

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

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

    int m;
    cin >> m;

    for (int i = 0; i < m; i++) {
        int p, x;
        cin >> p >> x;

        int res = 0;
        for (int j = 0; j < n; j++) {
            res += (j == p - 1 ? x : t[j]);
        }

        cout << res << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

#define UB 2000

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n == 0) break;
		int D[10][10];
		for (int i=0; i<10; i++) {
			for (int j=0; j<10; j++) D[i][j] = (i==j) ? 0 : UB;
		}
		int towns = 0;
		for (int i=0; i<n; i++) {
			int s, t, cost;
			std::cin >> s >> t >> cost;
			towns = std::max(towns, std::max(s, t));
			D[s][t] = D[t][s] = cost;
		}
		for (int k=0; k<=towns; k++) {
			for (int i=0; i<=towns; i++) {
				for (int j=0; j<=towns; j++) {
					D[i][j] = std::min(D[i][j], D[i][k] + D[k][j]);
				}
			}
		}
		int res = UB;
		int argres;
		for (int i=0; i<=towns; i++) {
			int sum = 0;
			for (int j=0; j<=towns; j++) sum += D[i][j];
			if (sum < res) { res = sum; argres = i; }
		}
		std::cout << argres << " " << res << std::endl;
	}
	return 0;
}



Measured memory_bytes: 2996
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll c;
	cin >> n >> c;
	vector<ll> x(n), v(n);
	rep(i,n) cin >> x[i] >> v[i];
	vector<ll> sum1(n+1, 0), sum2(n+1, 0);
	rep(i,n){
		sum1[i+1] = sum1[i] + v[i];
		sum2[i+1] = sum2[i] + v[n-1-i];
	}
	vector<ll> opt1(n+1, 0), opt2(n+1, 0);
	rep(i,n){
		opt1[i+1] = max(opt1[i], sum1[i+1] - x[i]);
		opt2[i+1] = max(opt2[i], sum2[i+1] - (c - x[n-1-i]));
	}
	ll ans = 0;
	for(int i = 1; i <= n; ++i){
		chmax(ans, opt1[i]);
		chmax(ans, opt1[i] + opt2[n-i] - x[i-1]);
		chmax(ans, opt2[i]);
		chmax(ans, opt2[i] + opt1[n-i] - (c - x[n-i]));
		//cout << i << " " << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7944