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

int max(std::vector<int> &v){
    int maxVal = INT_MIN;
    for(int i=0; i<(int)v.size(); ++i){
        if(v[i] > maxVal)
            maxVal=v[i];
    }
    return maxVal;
}

int main(){
    int n, ans, x;
    string s;
    ans=0;
    x=0;
    cin >> n;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='I'){
            x=x+1;
            ans=max(ans,x);
        }else{
            x=x-1;
            ans=max(ans,x); 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char ch=' ';
int ans=0;

int main()
{
	int n;
	char c;
	cin>>n;
	getchar();
	for(int i=1;i<=n;i++)
	{
		c=getchar();
		if(c!=ch) ans++,ch=c;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def main()->None:
    W, H, N = map(int, input().split())
    range_N = range(N)
    xl, xr, yd, yu = 0, W, 0, H
    for i in range_N:
        x, y, a = map(int, input().split())
        if a == 1:
            xl = max(x, xl)
        elif a == 2:
            xr = min(x, xr)
        elif a == 3:
            yd = max(y, yd)
        else:
            yu = min(y, yu)
    if xl >= xr or yd >= yu:
        print(0)
    else:
        print((xr - xl) * (yu - yd))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

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

int main() {
	int x, y;
	cin >> x >> y;
	bool one = false;
	bool two = false;
	for (int i = 0; i < 10; i++) {
		if (x == a[i])one = true;
		if (y == a[i])two = true;
	}
	if (one&&two) {
		cout << "Yes" << endl;
		return 0;
	}
	one = false;
	two = false;
	for (int i = 0; i < 10; i++) {
		if (x == b[i])one = true;
		if (y == b[i])two = true;
	}
	if (one&&two) {
		cout << "Yes" << endl;
		return 0;
	}
	one = false;
	two = false;
	for (int i = 0; i < 10; i++) {
		if (x == c[i])one = true;
		if (y == c[i])two = true;
	}
	if (one&&two) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
  string l, w;
  getline(cin, l);

  stringstream ss{l};

  vector<string> v;

  while (getline(ss, w, ' ')) {
    v.push_back(w);
  }

  if (v.at(1) == "+") {
    cout << stoi(v.at(0)) + stoi(v.at(2)) << endl;
  } else {
    cout << stoi(v.at(0)) - stoi(v.at(2)) << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdint>

int main() {
  int Q, H, S, D, N;
  scanf("%d %d %d %d %d", &Q, &H, &S, &D, &N);

  intmax_t one=std::min({4*Q, 2*H, S});
  intmax_t two=std::min<intmax_t>(2*one, D);

  printf("%jd\n", N/2*two+N%2*one);
  return 0;
}


Measured memory_bytes: 128
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
	#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	#endif

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a,p;
	cin >> a >> p;
	cout << (3*a + p)/2;
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<(n);i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    ll n, m;
    cin>>n>>m;
    vector<pair<ll, ll> > v(n);

    rep(i, n){
        ll a, b;
        cin>>a>>b;
        b*=-1;
        v[i].first=a;
        v[i].second=b;

    }

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

    

    ll ans=0;
    ll now=0;
    rep(i, n){
        ans+=v[i].first*min(v[i].second*(-1), m-now);
        now+=(v[i].second*(-1));
        if(now>=m) break;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1920
w,h,n=[int(i) for i in input().split()]
a1=[0]
a2=[w]
a3=[0]
a4=[h]
for i in range(n):
    x,y,a=[int(j) for j in input().split()]
    if a==1:
        a1.append(x)
    elif a==2:
        a2.append(x)
    elif a==3:
        a3.append(y)
    else:
        a4.append(y)

a1a2=sorted(a2)[0]-sorted(a1)[-1]
a3a4=sorted(a4)[0]-sorted(a3)[-1]
if a1a2>0 and a3a4>0:
    ans=a1a2*a3a4
else:
    ans=0
print(ans)

Measured memory_bytes: 3064
//Author:  Pranta
//Date:    2020-Aug-15
//Problem: B_Making_Triangle
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    int n,cnt=0;
    cin>>n;
    vector<ll>v(n);
    for(int i=0;i<n;++i){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            for(int k=j+1;k<n;++k){
                if(v[i]+v[j]>v[k]&& v[i]!=v[j] && v[j]!=v[k])
                cnt++;
            }
        }
    }
    cout<<cnt<<"\n";
}
int main()
{
    fast;
    int t;
    solve();
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>


int main(){
	int n, ret;
	if((ret = scanf("%d", &n))== EOF){return EXIT_FAILURE;}
	assert(3 <= n && n <= 50);
	char *s;
	s = (char*)malloc(sizeof(char)*(n+1));
	if((ret = scanf("%50s", s))== EOF){return EXIT_FAILURE;}
	int c;
	int flag = 0;
	int count = 0;
	int i = 0;
	while(s[i] != '\0'){
		c = s[i];
		i++;
		if (c == 'A'){flag =1; continue;}
		if (flag == 1 && c == 'B'){flag =2; continue;}
		if (flag == 2 && c == 'C'){flag = 0; count++; continue;}
		flag = 0;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
import bisect

s=input()
t=input()
n=len(s)*2

dic={}
for idx,i in enumerate(s*2):
  if i in dic.keys():
    dic[i].append(idx)
  else:
    dic[i]=[idx]

#print(dic)
    
ans=k=0
before='-1'
for i in t:
  if i not in dic.keys():
    print(-1)
    exit()
  t=bisect.bisect_left(dic[i], ans%n)
  if before==i:
    t+=1
  if len(dic[i])==t:
    t=0
    k+=n
  ans=dic[i][t]+k
  before=i
  
print(ans+1)

Measured memory_bytes: 18148
#include <stdio.h>
#include <stdlib.h>
int main(){
  char a;
scanf("%c",&a);
switch (a) {
  case 'A':printf("T\n");break;
  case 'T':printf("A\n");break;
  case 'C':printf("G\n");break;
  case 'G':printf("C\n");break;
}
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long int lli;
#define tc int t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define mx 1000000


int main() {
    fastio;
    int r,c;
    cin>>r>>c;
    string s[r];
    int dp[r][c];
    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
         dp[i][j]=mx;
    for(int i=0;i<r;i++)
        cin>>s[i];
    if(s[0][0]=='.')
        dp[0][0]=0;
    else
        dp[0][0]=1;
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            if(s[i][j]=='#')
            {

                if(i-1>=0)
                {
                if(s[i-1][j]=='#')
                    dp[i][j]=dp[i-1][j];
                else
                    dp[i][j]=dp[i-1][j]+1;
                }
                if(j-1>=0)
                {
                    if(s[i][j-1]=='#')
                    dp[i][j]=min(dp[i][j],dp[i][j-1]);
                    else
                    dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
                }
            }
            else
            {
                if(i-1>=0)
                    dp[i][j]=dp[i-1][j];
                if(j-1>=0)
                    dp[i][j]=min(dp[i][j],dp[i][j-1]);
            }
        }
    }

    cout<<dp[r-1][c-1]<<"\n";
    return 0;
}


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

int INF=1e7+1;
int h, w;
int bfs(int k, int l, vector<vector<int> > v){
    queue<pair<int, int> > que;
    vector<vector<int > > d(h, vector<int>(w));
    rep(i, h)rep(j, w) d[i][j]=-1;
    d[k][l]=0;
    que.push(pair<int, int>(k, l));
    vector<pair<int, int> >move(4);
    move[0]=(make_pair(1, 0));
    move[1]=(make_pair(-1, 0));
    move[2]=(make_pair(0, 1));
    move[3]=(make_pair(0, -1));
    while(que.size()){
        pair<int, int> p=que.front();
        que.pop();
        rep(mi, 4){
            int nexti=p.first+move[mi].first;
            int nextj=p.second+move[mi].second;
            if(nexti<0||nexti>=h||nextj<0||nextj>=w) continue;
            if(v[nexti][nextj]==0) continue;
            if(d[nexti][nextj]!=-1) continue;
            que.push(pair<int, int>(nexti, nextj));
            d[nexti][nextj]=d[p.first][p.second]+1;
            //cout<<d[nexti][nextj]<<endl;
        }
    }
    int maxi = 0;
    rep(i, h) maxi = max(maxi, (int)*max_element(d[i].begin(), d[i].end()));
    return maxi;
}

int main(void){
    cin>>h>>w;
    vector<vector<int> > v(h, vector<int>(w));
    rep(i, h){
        string s;
        cin>>s;
        rep(j, w){
            if(s[j]=='.') v[i][j]=1;
        }
    }
    int ans=0;
    rep(k, h)rep(l, w){
        if(v[k][l]==0) continue;
        int dist=bfs(k, l, v);
        ans=max(ans, dist);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,x ;
	cin >> n >> x ;
	vll b(n+1),p(n+1) ;
	b.at(0) = 1 ; p.at(0) = 1 ;
	for(int i=1;i<n+1;i++){
		b.at(i) = 2*b.at(i-1)+3 ;
		p.at(i) = 2*p.at(i-1)+1 ;
	}
	ll ans = 0 ;
	x-- ;
	for(int i=n;i>0;i--){
		if(i==1){
			if(x==1) ans++ ;
			if(x==2) ans += 2 ;
			if(x==3||x==4) ans += 3 ;
			break ;
		}
		if(x==0) break ;
		if(x>=b.at(i)-1){
			ans += 2*p.at(i-1)+1 ;
			break ;
		}
		if(x==1+b.at(i-1)){
			ans += p.at(i-1)+1 ;
			break ;
		}else{
			if(x>1+b.at(i-1)){
				ans += p.at(i-1)+1 ;
				x -= b.at(i-1)+2 ;
			}else{
				x -= 1 ;
			}
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] arg){
    	Scanner sc=new Scanner(System.in);
      int k=sc.nextInt();
      int n=sc.nextInt();
      int a[]=new int[n];
      for(int i=0;i<n;i++){
          a[i]=sc.nextInt();
          if(a[i]>=k){
              a[i]-=k;
          }
          
      }
      int max=Integer.MIN_VALUE;
      for(int i=1;i<n;i++){
          max=Math.max(max,Math.abs(a[i]-a[i-1]));
      }
      int m=k-a[n-1] + a[0];
      System.out.println(k-Math.max(max,m));
        
    }
}

Measured memory_bytes: 79272
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	c := getNextInt(scanner)
	s := getNextString(scanner)
	ll := make(ysp48, n)
	rr := make(ysp48, n)
	cd := 0
	for i := 0; i < n; i++ {
		if cd > 0 {
			cd--
			continue
		}
		if s[i] == 'x' {
			continue
		}
		ll[i] = 1
		cd = c
	}
	cd = 0
	for i := n - 1; i >= 0; i-- {
		if cd > 0 {
			cd--
			continue
		}
		if s[i] == 'x' {
			continue
		}
		rr[i] = 1
		cd = c
	}

	ssl := make([]int, n)
	iil := make([]int, n)
	ssr := make([]int, n)
	iir := make([]int, n)

	iil[0] = -1
	for i := 1; i < n; i++ {
		ssl[i] = ssl[i-1] + ll[i-1]
		iil[i] = iil[i-1]
		if ll[i-1] == 1 {
			iil[i] = i - 1
		}
	}

	iir[n-1] = n
	for i := n - 2; i >= 0; i-- {
		ssr[i] = ssr[i+1] + rr[i+1]
		iir[i] = iir[i+1]
		if rr[i+1] == 1 {
			iir[i] = i + 1
		}
	}

	ans := make([]int, 0)
	for i := 0; i < n; i++ {
		if s[i] == 'x' {
			continue
		}
		if ssl[i]+ssr[i] < k {
			ans = append(ans, i+1)
			continue
		}
		if ssl[i]+ssr[i] > k {
			continue
		}
		if iil[i] == -1 {
			continue
		}
		if iir[i] == n {
			continue
		}
		if iir[i]-iil[i] > c {
			continue
		}
		ans = append(ans, i+1)
	}

	for i := 0; i < len(ans); i++ {
		fmt.Fprintln(writer, ans[i])
	}
}

type ysp48 []int

func (y ysp48) lt(i int) int {
	if i == 0 {
		return -1
	}
	return y[i-1]
}
func (y ysp48) gt(i int) int {
	if i+1 >= len(y) {
		return -1
	}
	return y[i+1]
}


Measured memory_bytes: 19712
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def func(N, mod):
    F = [1]
    for i in range(1, N + 1):
        F.append(F[-1] * i % mod)
    return F


INV = {}


def inv(a, mod):
    if a in INV:
        return INV[a]
    r = pow(a, mod - 2, mod)
    INV[a] = r
    return r


def C(F, a, b, mod):
    return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod


def main():
    N, W = read_values()
    dp = [
        [[0 for _ in range(N * 3 + 10)] for __ in range(N + 10)]
        for ___ in range(N + 10)
    ]
    I = [tuple(read_values()) for _ in range(N)]

    w0 = I[0][0]
    if w0 > W:
        print(0)
        return

    for i, (w1, v) in enumerate(I):
        w = w1 - w0
        for k in range(N):
            for j in range(N * 3 + 5):
                dp[i + 1][k][j] = max(dp[i][k][j], dp[i + 1][k][j])
                dp[i + 1][k + 1][j + w] = max(dp[i][k][j] + v, dp[i + 1][k + 1][j + w])

    res = 0
    for k in range(N + 1):
        r = min(W - k * w0, 3 * N + 5)
        if r < 0:
            continue
        for i in range(r + 1):
            res = max(res, dp[N][k][i])
    print(res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 76764
N = int(input())
count = 0
baf = 0

if N <= 10:
    for i in range(1, N+1):
        for j in range(1, N+1):
            stri = str(i)
            strj = str(j)
            if stri[0] == strj[-1] and strj[0] == stri[-1]:
                #print(i, j)
                count += 1
    print(count)
else:
    num = (N // 10) ** 2
    if N % 10 == 0:

        print(num + 8)
    else:
        #print(num + 8)
        #print(num)
        for i in range(N // 10 * 10 ,N+1):
            for j in range(1, N+1):
                stri = str(i)
                strj = str(j)
                if stri[0] == strj[-1] and strj[0] == stri[-1]:
                    #print(i, j)
                    count += 1
                    #print(count)
        count *= 2
        for i in range(N // 10 * 10 + 1, N+1):
            for j in range(N // 10 * 10 + 1, N+1):
                stri = str(i)
                strj = str(j)
                if stri[0] == strj[-1] and strj[0] == stri[-1]:
                    #print(i, j)
                    count -= 1
                    #print(count)
        print(num+count + 8)





Measured memory_bytes: 40540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sn = new Scanner(System.in)) {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		}
	}

}


Measured memory_bytes: 21844
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

class TopologicalSort {
   bool cycle;
   VI dfs_color;
   void dfs(int u) {
      dfs_color[u] = 1;   // color gray
      for (int j = 0; j < (int) adj[u].size(); ++j) {
         int v = adj[u][j];
         if (dfs_color[v] == 0)
            dfs(v);
         else if (dfs_color[v] == 1) // back edge -> cycle
            cycle = true;
      }
      dfs_color[u] = 2;  // color black
      top_sort_list.push_back(u);
   }

public:
   VVI adj;

   VI top_sort_list;

   TopologicalSort(int _N) : adj(_N) {}

   void add_edge(int u, int v) {
      adj[u].push_back(v);
   }

   bool topological_sort_dfs() {
      int N = adj.size();
      top_sort_list.clear();
      cycle = false;
      dfs_color = VI(N, 0);
      for (int u = 0; u < N; ++u)
         if (dfs_color[u] == 0)
            dfs(u);
      if (cycle) {
         top_sort_list.clear();
         return false;
      }

      return true;
   }
};

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, M;
   cin >> N >> M;

   TopologicalSort ts(N);
   REP(j, M) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      ts.add_edge(u, v);
   }
   
   bool f = ts.topological_sort_dfs();
   assert(f);

   VI DP(N);

   for (int u : ts.top_sort_list) {
   //   cerr << u+1 << ' ';
      DP[u] = 0;
      for (int v : ts.adj[u]) {
         DP[u] = max(DP[u], 1+DP[v]);
      }
   }
   //cerr << endl;
   
   cout << *max_element(DP.begin(), DP.end()) << endl;

   return 0;
}


Measured memory_bytes: 7672
import math
def main():

    X = int(input())
    v = int(pow(X, 0.25)) + 1
    for A in range(-v, v+1):
        c = pow(A, 5)
        for B in range(-v, v+1):
            if c - pow(B, 5) == X:
                return " ".join(map(str, [A, B]))
    return -1


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 65176
import  java.io.*;

public class Main{ 
        public static void main(String[] args){
            int i=0,j;
            int b[];
            String line;
            b = new int[2000];
            try{
                //Scanner n = new Scanner(System.in);
                BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
                while(true){
                    line = k.readLine();
                    String suuti[] = line.split(" ");
                    if(suuti[1].equals("?")){
                        break;
                    }
                    int d = Integer.parseInt(suuti[0]);
                    int e = Integer.parseInt(suuti[2]);
                    if(suuti[1].equals("+")){
                        b[i]=d+e;
                    }else if(suuti[1].equals("-")){
                        b[i]=d-e;
                    }else if(suuti[1].equals("*")){
                        b[i]=d*e;
                    }else if(suuti[1].equals("/")){
                        b[i]=d/e;
                    }
                    i++;
                }
                for(j=0;j<i;j++){
                    System.out.println(b[j]);
                }
            }catch(IOException e) {
                System.out.println(e);
            } catch(NumberFormatException e){
                System.out.println(e);
            }
        }
    }


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
ll nxt(){ll x;cin>>x;return x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	ll  n,m;
	cin>>n>>m;
	cout<<(n)*(n-1)/2+m*(m-1)/2;
    return 0;
}



Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        s: proconio::marker::Chars,
        lr: [(usize, usize); q],
    }
    let mut cum = vec![0; n];
    for (i, (&p, &c)) in s.iter().tuple_windows().enumerate() {
        cum[i + 1] = cum[i] + (p == 'A' && c == 'C') as usize;
    }
    for (l, r) in lr {
        println!("{}", cum[r - 1] - cum[l - 1]);
    }
}


Measured memory_bytes: 6020
#include <bits/stdc++.h>
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 EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

int prime[1001001];
bool is_prime[1001001];

int sieve(int n) {
  int p = 0;
  for (int i = 0; i < n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i < n; i++){
    if (is_prime[i]){
      prime[p++] = i;
      for (int j = 2*i; j < n; j+=i) is_prime[j] = false;
    }
  }
  return p;
}

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

  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = MOD;
  if (X > Y) {
    swap(X,Y);
    swap(A,B);
  }
  chmin(ans, X*A+Y*B);
  chmin(ans, X*A+Y*2*C);
  chmin(ans, X*2*C+(Y-X)*B);
  chmin(ans, X*2*C+(Y-X)*2*C);

  cout << ans << endl;
}


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

int main() {
	
	int n;
	cin >> n;
	char a[n],b[n];
    cin >> a;
    cin >> b;
    int i;
    int m = 2*n;
    char c[m];
    int j = 0;
    for(i=0;i<n;i++)
    {
      
        
        c[j] = a[i];
        j = j + 1;
        c[j] = b[i];
        j = j+1;
    }
    for(i=0;i<m;i++)
    {
        cout << c[i];
    }
	return 0;
}


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

int main(){
  int a;
  string s;
  cin >> a;// >> b >> c;
  cin >> s;
  if(3200<=a) cout << s << endl;
  else cout << "red" << endl;
  //cout << c - (a-b))<0 ? 0 : b+c-a << endl;
  //else cout << b << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n, m, i, j, k, f[105];
int main(){
	scanf("%d%d", &n, &m);
	for(i=1; i<=m; i++){
		scanf("%d", &k);
		while(k--){
			scanf("%d", &j);
			if(++f[j] == 1) n--;
		}
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 1708
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        int N = cin.Nextint;
        var A = cin.Scanint;

        int mu = 0;
        int ni = 0;
        int yo = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] % 2 != 0)
            {
                mu++;
            }
            else if (A[i] % 4 != 0)
            {
                ni++;
            }
            else yo++;
        }
        if (mu == 0)
        {
            WriteLine("Yes");
        }
        else if (ni > 0)
        {
            if (yo >= mu)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
        else
        {
            if (yo >= 1 && yo >= mu - 1)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 18524
#include <cstdio>
int n;
char s[100001], r[100001];
bool c ( char a, char b )
{
	r[0] = a;
	r[1] = b;
	for ( int i = 2; i < n; ++i )
		r[i] = r[i - 1] == 'S' ? s[i - 1] == 'o' ? r[i - 2] : r[i - 2] == 'S' ? 'W' : 'S' : s[i - 1] == 'x' ? r[i - 2] : r[i - 2] == 'S' ? 'W' : 'S';
	return ! ( r[n - 1] == 'S' && ( ( s[n - 1] == 'o' && r[n - 2] != r[0] ) || ( s[n - 1] == 'x' && r[n - 2] == r[0] ) ) ) &&
	       ! ( r[0] == 'S' && ( ( s[0] == 'o' && r[1] != r[n - 1] ) || ( s[0] == 'x' && r[1] == r[n - 1] ) ) ) &&
	       ! ( r[n - 1] == 'W' && ( ( s[n - 1] == 'x' && r[n - 2] != r[0] ) || ( s[n - 1] == 'o' && r[n - 2] == r[0] ) ) ) &&
	       ! ( r[0] == 'W' && ( ( s[0] == 'x' && r[1] != r[n - 1] ) || ( s[0] == 'o' && r[1] == r[n - 1] ) ) );
}
int main()
{
	scanf ( "%d%s", &n, s );
	puts ( c ( 'S', 'W' ) || c ( 'W', 'S' ) || c ( 'W', 'W' ) || c ( 'S', 'S' ) ? r : "-1" );
	return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]

    AB = sorted(AB, key=lambda x: x[0])
    result = 0

    for a, b in AB:
        if M - b >= 0:
            result += a * b
        else:
            result += a * M
            break
        M -= b
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 29792
#include <algorithm>
 #include <iostream> 
using namespace std; 
int main(){
long n;
cin>>n;
string ans="";
if(!n)ans="0";
else{
while(n!=1){
n%(-2)?ans='1'+ans:ans='0'+ans;
if(abs(n)%2&&n<0)n=abs(n)/2+1;
else n/=-2;
}
ans='1'+ans;
}
cout<<ans<<endl;
return 0;
}

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

int main() {

	int n, m, x; cin >> n >> m >> x;

	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int ans = 2147483647;
	for (int bit = 0; bit < (1 << n); ++bit) {

		vector<int> point(m, 0);
		int c_sum = 0;
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				c_sum += c[i];
				for (int j = 0; j < m; j++) {
					point[j] += a[i][j];
				}				
			}
		}

		bool can = true;
		for (int i = 0; i < m; i++) {
			if (point[i] < x) can = false;
		}

		if (can) ans = min(ans, c_sum);

	}
	
	if (ans == 2147483647) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#define inf 1<<30
using namespace std;
char s[5];
int main(){
	scanf("%s",s);
	if(s[0]==s[1]&&s[1]==s[2]){
		printf("%s",s);
		return 0;
	}
	if(s[1]<=s[0]&&s[2]<=s[0]){
		printf("%c%c%c",s[0],s[0],s[0]);
		return 0;
	}
	s[0]++;
	printf("%c%c%c",s[0],s[0],s[0]);
	return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nd = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var (n, d) = (nd[0], nd[1]);
        var points = new (long X, long Y)[n];
        for (int i = 0; i < points.Length; ++i)
        {
            var xy = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            points[i] = (xy[0], xy[1]);
        }

        var k = 0;
        for (int i = 0; i < points.Length; ++i)
        {
            var p = points[i];
            var op = p.X * p.X + p.Y * p.Y;
            if (op <= d * d)
            {
                ++k;
            }
        }

        Console.WriteLine(k);
    }
}


Measured memory_bytes: 44440
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next().toLowerCase();

        System.out.println(cipher(s,n).toUpperCase());






    }
    public static String cipher(String msg, int shift){
        String s = "";
        int len = msg.length();
        for(int x = 0; x < len; x++){
            char c = (char)(msg.charAt(x) + shift);
            if (c > 'z')
                s += (char)(msg.charAt(x) - (26-shift));
            else
                s += (char)(msg.charAt(x) + shift);
        }
        return s;
    }
}

Measured memory_bytes: 148424
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

int a[N], b[N], c[N], dp[N][3];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i = 1; i < n; i ++)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

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

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

    long sum = 0;
    long cost1 = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum <= 0) {
                cost1 += -sum + 1;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                cost1 += sum + 1;
                sum = -1;
            }
        }
    }

    sum = 0;
    long cost2 = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 1) {
            if (sum <= 0) {
                cost2 += -sum + 1;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                cost2 += sum + 1;
                sum = -1;
            }
        }
    }

    cout << min(cost1,cost2) << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a<c&&c<b)||(b<c&&c<a)){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3604
package main

import "fmt"

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

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

func main() {
	var n int64
	fmt.Scan(&n)
	ts := make([]int64, n)
	for i := range ts {
		fmt.Scan(&ts[i])
	}

	ans := ts[0]
	for _, t := range ts {
		ans = lcm(ans, t)
	}
	fmt.Println(ans)
}


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

int main() {
  int x,y;
  vector<int> gp0={1,3,5,7,8,10,12};
  vector<int> gp1={4,6,9,11};
  vector<int> gp2={2};
  int xgp=-1, ygp=-1;
  
  // 画枠入力
  cin >> x >> y;

  //xのグループ判定
  for(int i=0; i<7; i++){
    if(x==gp0.at(i)){
      xgp=0;
      continue;
    }
  }
  
  if(xgp==-1){
    for(int i=0; i<4; i++){
      if(x==gp1.at(i)){
        xgp=1;
        continue;
       }
    }
  }
  
  if(xgp==-1){
    xgp=2; 
  }
    
  //yのグループ判定
  for(int i=0; i<7; i++){
    if(y==gp0.at(i)){
      ygp=0;
      continue;
    }
  }
  
  if(ygp==-1){
    for(int i=0; i<4; i++){
      if(y==gp1.at(i)){
        ygp=1;
        continue;
       }
    }
  }

  if(ygp==-1){
    ygp=2;
  }
  
  //グループ番号
  //cout << xgp << " " << ygp << endl;
  
  //判定結果出力
  if(xgp==ygp)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    string s;cin>>s;
    int n = s.length();
    int res = n,c = 0;
    for(int i=0;i<n;++i){
        if(s[i]=='S')c++;
        else{
            if(c>0){
                c--;
                res-=2;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

double p, e, t;

double solve(double l, double r, double k){
    double mid = (l+r)/2;
    if(k == 0) return 1.0*(abs(mid-t) < e);
    if(t - e <= l && r <= t + e) return 1.0;
    if(r < t - e || t + e < l) return 0.0;
    double ret = 0;
    if(mid <= t) ret += p*solve(l, mid, k-1)+(1-p)*solve(mid, r, k-1);
    else ret += (1-p)*solve(l, mid, k-1)+p*solve(mid, r, k-1);
    return ret;
}

int main() {
    double k, r, l;
    cin >> k >> l >> r >> p >> e >> t;
    printf("%.6f", solve(l, r, k));
    return 0;
}


Measured memory_bytes: 3284
import sys
input = sys.stdin.readline
def print_ans(A, B):
    """Test Case
    >>> print_ans(30, 100)
    100
    >>> print_ans(12, 100)
    50
    >>> print_ans(0, 100)
    0
    """
    if A > 12:
        ans = B
    elif 6 <= A <= 12:
        ans = B // 2
    else:
        ans = 0
    print(ans)

if __name__ == '__main__':
    A, B = map(int, input().rstrip().split())
    print_ans(A, B)




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

ll cnt;

ll f(ll n){
    cnt++;
    if(n % 2 == 0){
        return n / 2;
    }else{
        return 3 * n + 1;
    }
}

int main(){
    ll s;
    cnt = 1;
    cin >> s;
    vector<ll> d(10000, 0);
    d[s]++;

    while(1){
        s = f(s);
        if(d[s] == 0){
            d[s]++;
        }else{
            cout << cnt << endl;
            return 0;
        }
    }
}

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

int X[]={-1,-1,-1,0,0,1,1,1};
int Y[]={-1,0,1,-1,1,-1,0,1};

int m,n;
char a[55][55];

int main()
{
    cin>>m>>n;
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
            cin>>a[i][j];
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
            if(a[i][j]=='.')
            {
                int Count=0;
                for(int d=0;d<=7;d++)
                {
                    int u=i+X[d];
                    int v=j+Y[d];
                    if(u>0&&u<=m&&v>0&&v<=n&&a[u][v]=='#')
                        Count++;
                }
                a[i][j]=char(Count+'0');
            }
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
            cout<<a[i][j];
        cout<<"\n";
    }
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n;

	cin >> n;

	vector<ll> v(n);

	REP(i, n) {
		cin >> v[i];
	}

	ll ans = INF;
	ll sum;

	FOR(i, -100, 101) {
		sum = 0;

		REP(j, n) {
			sum += (v[j] - i) * (v[j] - i);
		}

		ans = min(ans, sum);
	}

	cout << ans << endl;
}

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

ans = "Yes"
a[0] -= 1
for i in range(1,n):
    if a[i-1] < a[i]:
        a[i] -= 1
    elif a[i-1] > a[i]:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 15020
#include <iostream>
#define MAX 500000
#define SENTINEL 2000000000

using namespace std;

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2 = right - mid;
	for(int i = 0;i<n1;i++){
		L[i] = A[left + i];
	}
	for(int i = 0;i<n2;i++){
		R[i] = A[mid+ i];
	}
	L[n1] = R[n2] = SENTINEL;
	int i=0,j=0;

	for(int k = left;k < right;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[],int n,int left,int right){
	if(left+1<right){
		int mid = (left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(){
	int A[MAX],n,i;
	cnt = 0;
	cin >> n;
	for(i = 0;i<n;i++){
		cin >> A[i];
	}
	mergeSort(A,n,0,n);

	for(i = 0;i<n;i++){
		if(i)cout<<" ";
		cout << A[i];
	}
	cout << endl;
	cout << cnt <<endl;
	return 0;
}


Measured memory_bytes: 6936
#include <stdio.h>
int main() {
	int n, a, odd = 1, all = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		all *= 3;
		scanf("%d", &a);
		if (a % 2 == 0) {
			odd *= 2;
		}
	}
	printf("%d", all - odd);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b, c, d;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> a >> b >> c >> d;
    if ((abs(b - a) <= d && abs(b - c) <= d)|| abs(c - a) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main(){
    int n,m,l;
    int i,j,k;
    long a[100][100];
    long b[100][100];
    long c[100][100];
    
    for (i=0;i<100;i++){
        for (j=0;j<100;j++){
            a[i][j]=0;
            b[i][j]=0;
            c[i][j]=0;
        }
    }
    
    cin >> n >> m >> l;
    
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    
    for (i=0;i<m;i++){
        for (j=0;j<l;j++){
            cin >> b[i][j];
        }
    }
    
    for (i=0;i<n;i++){
        for (j=0;j<l;j++){
            for (k=0;k<m;k++){
                c[i][j] = c[i][j]  + (a[i][k] * b[k][j]);
            }
        }
    }
    
    for (i=0;i<n;i++){
        for (j=0;j<l;j++){
            if(j==l-1){
                cout << c[i][j] << endl;
            }else{
                cout << c[i][j] << " ";
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
unordered_map<int, int> dpArr;
int dp(int arr[],int n, int k){
    if(n<=1){
        if( n == 0) return dpArr[0];
        return dpArr[1];
    }
    if(dpArr.count(n)){
        return dpArr[n];
    }
    for(int i=1;i <= min(k,n);i++){
        if(i == 1)dpArr[n] = dp(arr, n-1, k) + abs(arr[n-1] - arr[n]);
        else dpArr[n] = min(dpArr[n], dp(arr, n-i,k) + abs(arr[n-i] - arr[n]));
    }
    return dpArr[n];
}

signed main(){

#ifndef ONLINE_JUDGE
  //  freopen("input.txt","r", stdin);
#endif

    fastIO

    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    dpArr[0] = 0;
    dpArr[1] = abs(arr[0] - arr[1]);
    cout << dp(arr,n-1, k);

    return 0;
}


Measured memory_bytes: 15012
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
 
#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) ( (n % k) + k ) % k
#define isOn(S, j) (S & (1 << j) )
#define setBit(S, j) (S | (1 << j ) )
#define LSB(S) (S & (-S))
 
int main () {   
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    string s;
    cin >> s;
    const int tam = 'z' - 'a' + 1;

    bitset<tam+2> bs;
 
    for (char c : s)
        bs[c-'a'] = 1;

    for (int i = 0; i < tam; i++)
        if (bs[i] == 0) {
            cout << char(i+'a') << endl;
            return 0;
        }

    cout << "None" << endl;

    return 0;
}  

Measured memory_bytes: 640
parseInt(x) = parse(Int,x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)
function main()
  N = map(parseInt, split(readline()))[1]
  a = map(parseInt, split(readline()))
  g  = a[1]
  for i = 1:N-1
    g = gcd(g,a[i+1])
  end
  println(Int64(g))
end
main()

Measured memory_bytes: 127304
N,M = map(int,input().split())
a = [0]*M
b = [0]*M
c = [0]*N
for i in range(M):
  a[i],b[i] = map(int,input().split())
for i in range(N):
  for p in range(M):
    if a[p] == i+1 or b[p] == i+1:
      c[i] = c[i]+1
for i in range(N):
  print(c[i])

Measured memory_bytes: 38512
K=int(input())

if K%2==0:
    print(-1)
    exit(0)
    
ans=[0]*(pow(10,6)+1)
ans[0]=0

for i in range(1,pow(10,6)):
    ans[i]=(ans[i-1]*10+7)%K
    if ans[i]==0:
        print(i)
        exit(0)

print(-1)

Measured memory_bytes: 48468
N,K,Q=map(int,input().split())
mylist=[]
pointlist=[]
for i in range(Q):
    mylist.append(int(input()))
    
for i in range(N):
    #全員にKポイント与えるが、Qポイント引く
    pointlist.append(K-Q)
    
#正解者に1ぽいんとずつ足す。

for i in range(Q):
    #mylist[i]をjとしたら、j番目の人が勝者ということ。pointlist[j-1]に1を足す。
    j=mylist[i]
    pointlist[j-1]+=1
    
for i in range(N):
    if pointlist[i]>0:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 11864