akhauriyash/Code-Regression huggingface dataset:
//B - Shift only:
//Assunto: 
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, ans, aux;
    bool odd = false;
    cin >> n;
    vector<int> nums(n);
    loop(i, 0, n) {
        cin >> nums[i];
        if(nums[i] % 2 != 0) odd = true;
    }
    if(odd) ans = 0;
    else {
        ans = INF;
        loop(i, 0, n) {
            aux = 0;
            while(nums[i] % 2 == 0) {
                aux++;
                nums[i] /= 2;
            }
            ans = min(ans, aux);
        }
    }
    cout << ans << "\n";
}

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

int main (){
  int x,y,z1,z2,z3,z4;
  cin >> x >>y;
  if ( x == 0 && 1868<=y && y<=1911 ){ z1 = y - 1867, cout<< "M" << z1 <<endl;}
  else if ( x == 0 && 1912<=y && y<=1925){ z1 = y - 1911,cout<< "T" << z1 <<endl;}
  else if ( x == 0 && 1926<=y && y<=1988){ z1 = y - 1925,cout<< "S" << z1 <<endl;}
  else if ( x == 0 && 1989<=y && y<=2016){ z1 = y - 1988,cout<< "H" << z1 <<endl;}
  else if ( x == 1){z1=y-1+1868,cout<< z1<<endl;}
  else if ( x == 2){z1=y-1+1912,cout<< z1<<endl;}
  else if ( x == 3){z1=y-1+1926,cout<< z1<<endl;}
  else{z1=y-1+1989,cout<<z1<<endl;}
  return 0;
}



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

int main(){
    int R,G,B,N;
    cin>>R>>G>>B>>N;

    int ans=0;
    rep(r,N+1){
        rep(g,N+1){
            if(r==0 && g==0){
                if(N%B==0) ans++;
                continue;
            }
            int tmp=N-r*R-g*G;
            if(tmp%B!=0) continue;
            if(tmp/B>=0) ans++;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1e9;
int N, A, B, C;
vector<int> l;

int dfs(int cur, int a, int b, int c) {
  if(cur == N) {
    if(min(a, min(b, c)) > 0) {
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    } else {
      return INF;
    }
  }
  int ret0 = dfs(cur + 1, a, b, c);
  int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
  int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
  int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
  int res = min(ret0, min(ret1, min(ret2, ret3)));
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> A >> B >> C;
  l.resize(N);
  REP(i, N) cin >> l[i];
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    if(x==1){
        cout << 1  << endl;
        return 0;
    }
    int ans(0);
    for(int i=1;i<=x;i++){
        for(int j=2;j<=x;j++){
            int t = pow(i,j);
            if(t>x){
                break;
            }else{
                ans = max(ans,t);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4028
#!/usr/bin/env py

log = lambda *x: print(*x)

def no_c(f,s,t):
    if f==1 and t==2: return True
    if f==1 and s==2: return True
    if s==1 and t==2: return True
    if s==2 and t==1: return True
    return False

def no_g(f,s,t):
    if s==1 and t==3: return True
    return False

def solve(k):
    dp = [[ [([0]*5) for i in range(5)] for i in range(5) ] for i in range(k+1)]

    for l in range(k, 0, -1):
        for f in range(0,5):
            for s in range(0,5):
                for t in range(0,5):
                    if l == k:
                        dp[l][f][s][t] = 1
                        continue

                    if l == 1:
                        dp[l][f][s][t] = dp[l+1][s][t][1] + dp[l+1][s][t][2] + dp[l+1][s][t][3] + dp[l+1][s][t][4]

                    if l == 2:
                        if (s==1 and t==2) or (s==2 and t==1): dp[l][f][s][t] = dp[l+1][s][t][1] + dp[l+1][s][t][2] + dp[l+1][s][t][4]
                        if (s==1 and t==3): dp[l][f][s][t] = dp[l+1][s][t][1] + dp[l+1][s][t][3] + dp[l+1][s][t][4]
                        else: dp[l][f][s][t] = dp[l+1][s][t][1] + dp[l+1][s][t][2] + dp[l+1][s][t][3] + dp[l+1][s][t][4]

                    if no_c(f,s,t): dp[l][f][s][t] = dp[l+1][s][t][1] + dp[l+1][s][t][2] + dp[l+1][s][t][4]
                    elif no_g(f,s,t): dp[l][f][s][t] = dp[l+1][s][t][1] + dp[l+1][s][t][3] + dp[l+1][s][t][4]
                    else: dp[l][f][s][t] = dp[l+1][s][t][1] + dp[l+1][s][t][2] + dp[l+1][s][t][3] + dp[l+1][s][t][4]

    return sum(dp[1][0][0][t] for t in (1,2,3,4)) % 1000000007

log(solve(int(input())))


Measured memory_bytes: 3924
program nuske_vs_phantom_thnook
  implicit none
  integer :: n, m, q, a(0:2000,0:2000), x1, y1, x2, y2, i, j, k
  integer :: x(0:2000,0:2000), y(0:2000,0:2000), z(0:2000,0:2000)
  character(2000) :: s
  a = 0
  x = 0
  y = 0
  z = 0
  read(*,*) n, m, q
  do i = 1, n
    read(*,*) s
    s = trim(adjustl(s))
    do j = 1, m
      if (s(j:j).eq."1") a(i,j) = 1
    end do
  end do
  do i = 1, n
    do j = 1, m
      x(i,j) = x(i,j-1)+x(i-1,j)-x(i-1,j-1)+a(i,j)
      y(i,j) = y(i,j-1)+y(i-1,j)-y(i-1,j-1)+a(i,j)*a(i,j-1)
      z(i,j) = z(i,j-1)+z(i-1,j)-z(i-1,j-1)+a(i,j)*a(i-1,j)
    end do
  end do
  do k = 1, q
    read(*,*) x1, y1, x2, y2
    write(*,'(i0)') f(x,x1,y1,x2,y2)-f(y,x1,y1+1,x2,y2)-f(z,x1+1,y1,x2,y2)
  end do
  stop
contains
  integer function f(x,i1,j1,i2,j2)
    implicit none
    integer, intent(in) :: x(0:2000,0:2000), i1, j1, i2, j2
    f = x(i2,j2)-x(i2,j1-1)-x(i1-1,j2)+x(i1-1,j1-1)
    return
  end function f
end program nuske_vs_phantom_thnook

Measured memory_bytes: 64384
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 1000000000000000000
#define vll vector<ll>
using namespace std;
const int N=5005;

void solve()
{
	ll n,m,k,u[N],v[N],w[N],dis[N],i,j,neg[N];
	memset(neg,0,sizeof neg);
	cin>>n>>m>>k;
	dis[1]=0;
	for(i=2;i<=n;i++)
		dis[i]=inf;
	for(i=1;i<=m;i++)
	{
		cin>>u[i]>>v[i]>>w[i];
		w[i]-=k;
		w[i]=-w[i];
	}
	for(i=1;i<=n-1;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(dis[u[j]]==inf)
				continue;
			dis[v[j]]=min(dis[v[j]],dis[u[j]]+w[j]);
		}
	}

	

	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(dis[u[j]]==inf)
				continue;
			if(dis[v[j]]>dis[u[j]]+w[j] || neg[u[j]])
				neg[v[j]]=1;
			dis[v[j]]=min(dis[v[j]],dis[u[j]]+w[j]);
		}
	}

	if(neg[n])
		cout<<-1;
	else
		cout<<max(0LL,-dis[n]);


	
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 384
A,B,C = map(int, input().split())

def func(A, B, C):
    i = 1
    sum = 0
    while(True):
        if i%100 == 0:
            break
        sum += A
        i+=1
        if sum%B==C:
            print('YES')
            return
    print('NO')

func(A,B,C)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> w(n), e(n);
    for (int i = 1; i < n; i++)
    {
        w[i] = w[i-1];
        if (s[i-1] == 'W') w[i]++;
    }
    for (int i = n-2; i >= 0; i--)
    {
        e[i] = e[i+1];
        if (s[i+1] == 'E') e[i]++;
    }
    int ans = INT_MAX;
    rep(i,n) {
        ans = min(ans, w[i]+e[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
    int i,n,ans,box;
    cin >> n;

    if(n == 1){
        ans = 1;
    }

    for(i = 1; i <= n;i++){
        box = i;
        while(1){
            if(box % 2 == 1){
                break;
            }
            box /= 2;
            if(box == 1){
                ans = i;
            }
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m,l,k,i;
  cin>>n>>m;
  if(n%2==1) {
    l=(n-1)/2;
    for(i=0;i<m;i++) cout<<l-i<<' '<<l+1+i<<endl;
  }
  else if(n%2==0) {
    l=n/2;
    if (l%2==0) {
      k=l/2;
      for(i=0;i<min(m,k);i++) cout<<k-i<<' '<<k+1+i<<endl;
      if (m>k) for(i=0;i<m-k;i++) cout<<l+1+i<<' '<<n-1-i<<endl;
    }
    if (l%2==1) {
      k=(l-1)/2;
      for(i=0;i<min(m,k);i++) cout<<k-i<<' '<<k+1+i<<endl;
      if (m>k) for(i=0;i<m-k;i++) cout<<l+i<<' '<<n-1-i<<endl;
    }
  }
}

Measured memory_bytes: 3628
package main

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

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,m := input.NextInts()
  a := make([]int,n-1+m)
  b := make([]int,n-1+m)
  g := make([][]int,n)
  for i:=0;i<n-1+m;i++ {
    a[i],b[i] = input.NextInts()
    a[i],b[i] = a[i]-1,b[i]-1
    g[a[i]] = append(g[a[i]],b[i])
  }
  s := topologicalSort(g)
  r := make([]int,n)
  for i:=0;i<len(s);i++ { r[s[i]] = i }
  x := make([]int,n)
  fill(&x,s[0])
  for i:=0;i<n-1+m;i++ {
    if r[x[b[i]]] < r[a[i]] { x[b[i]] = a[i] }
  }
  x[s[0]] = -1
  fmt.Println(x[0]+1)
  for i:=1;i<n;i++ { fmt.Println(x[i]+1) }
}
func fill(a *[]int,n int) {
  for i:=0;i<len(*a);i++ { (*a)[i] = n }
}

func topologicalSort(g [][]int) []int {
  n := len(g)
  s := []int{}
  u := make([]bool,n)
  var dfs func(int)
  dfs = func(i int) {
    if u[i] { return }
    u[i] = true
    for _,e := range g[i] { dfs(e) }
    s = append(s,i)
  }
  for i:=0;i<n;i++ { dfs(i) }
  m := len(s)
  for i:=0;i<m-1-i;i++ { s[i],s[m-1-i] = s[m-1-i],s[i] }
  return s
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

Measured memory_bytes: 41600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <queue>
#include <stack>

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define vb vector<bool>
#define vvb vector<vb>
#define vstr vector<string>
#define pll pair<ll, ll>
#define pb pair<bool, bool>

using namespace std;



int main()
{
	ll h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	ll start = 60 * h1 + m1;
	ll end = 60 * h2 + m2;
	ll dif = end - start;
	//cout << "start: " << start << endl;
	//cout << "end: " << end << endl;
	//cout << "dif: " << dif << endl;
	if (dif <= k)
	{
		cout << "0" << endl;
		return 0;
	}
	ll ans = dif - k;
	cout << ans << endl;
}


Measured memory_bytes: 3164
def find(x):
    '''
    xの根を求める
    '''
    if par[x] < 0:
        return x
    else:
        p = find(par[x])
        diff_w[x] += diff_w[par[x]]
        par[x] = p
        return p


def weight(x):
    '''
    xの根からの距離を求める
    '''
    find(x)
    return diff_w[x]


def union(x, y, w):
    '''
    w[y] = w[x] + w となるようにxとyの属する集合を併合する
    '''
    w += diff_w[x] - diff_w[y]
    x = find(x)
    y = find(y)
    
    if x == y:
        return False

    if par[x] > par[y]:
        x, y = y, x
        w = -w
    par[x] += par[y]
    par[y] = x
    diff_w[y] = w
    return True


def same(x, y):
    '''
    xとyが同じ集合に属するかを判定する
    '''
    return find(x) == find(y)


def size(x):
    '''
    xが属する集合の個数を求める
    '''
    return -par[find(x)]


def diff(x, y):
    '''
    xとyが同じ集合に属するときの w[y] - w[x] を求める
    '''
    return weight(y) - weight(x)


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

par = [-1] * n
diff_w = [0] * n

for _ in range(m):
    l, r, d = map(int, input().split())

    if same(l-1, r-1):
        if diff(l-1, r-1) != d:
            print('No')
            exit()
    else:
        union(l-1, r-1, d)

print('Yes')

Measured memory_bytes: 83352
import numpy as np
ans = []
H, W = map(int, input().split())
S = []
S.append('.'*(W+2))
for i in range(H):
    S.append('.'+input() + '.')
S.append('.'*(W+2))

for y in range(1, H+1):
    for x in range(1, W+1):
        if S[y][x] == '.':
            cnt = S[y][x-1].count('#')+S[y][x+1].count('#')+S[y-1][x-1:x+2].count('#')+S[y+1][x-1:x+2].count('#')
            ans.append(str(cnt))
        else:
            ans.append('#')
np_ans = np.array(ans)
re_ans = np.reshape(np_ans, (H, W))
for i in re_ans:
    print(''.join(i))

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

int yes(){
	cout << "YES" << endl;
	return 0;
}

int no(){
	cout << "NO" << endl;
	return 0;
} 

int main(){
	string s; cin >> s;
	if( s.l_ength() == 1 || s == "ab" || s == "bc" || s == "ca" || s == "ba" || s == "cb" || s == "ac" ) return yes();
	map<char, int> mp;
	for( char k : s ) ++mp[k];
	int a = mp['a'], b = mp['b'], c = mp['c'];
	if( a == 0 || b == 0 || c == 0 ) return no();
	int m = min({a, b, c});
	a -= m;
	b -= m;
	c -= m;
	if( a <= 1 && b <= 1 && c <= 1 ) return yes(); 
	return no();
}

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

int D;
double V[100];

double absd( double x ) {

	if ( x < 0 ) { return -x; }
	
	return x;

}

double interpolate( int n, int E ) {

	double sum = 0.0;
	
	for ( int k = 0; k < D + 3; k++ ) {
	
		if ( k == n || k == E ) { continue; }
		
		double p = V[k];
		
		for ( int i = 0; i < D + 3; i++ ) {
		
			if ( i != k && i != n && i != E ) { p *= ( n - i ) / (double) ( k - i ); }
		
		}
		
		sum += p;
	
	}
	
	return sum;

}

bool outlier( int E ) {

	for ( int i = 0; i < D + 3; i++ ) {
	
		if ( i == E ) { continue; }
		
		double p = interpolate( i, E );
		
		if ( absd( p - V[i] ) > 0.1 ) { return false; }
	
	}
	
	return true;

}

int main() {

	while ( cin >> D && D != 0 ) {
	
		for ( int i = 0; i < D + 3; i++ ) { cin >> V[i]; }
		
		for ( int i = 0; i < D + 3; i++ ) {
		
			if ( outlier( i ) ) {
			
				cout << i << endl;
				break;
			
			}
		
		}
	
	}

}

Measured memory_bytes: 1232
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  int fi = -1, ed = -1;
  for (int i = 0; i < s.size() - 1; ++i)
  {
    if (s[i] == s[i + 1])
      fi = i + 1, ed = i + 2;
  }
  for (int i = 0; i < s.size() - 2; ++i)
  {
    if (s[i] == s[i + 2])
      fi = i + 1, ed = i + 3;
  }
  cout << fi << ' ' << ed << endl;

  return 0;
}


Measured memory_bytes: 512
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

string s;
ll ct=0,n;
bool ii,jj,kk;
void det(int i,int j,int k){
    ii = false;
    jj = false;
    kk = false;
    char i1 = '0'+i;
    char j1 = '0'+j;
    char k1 = '0'+k;
    rep(m,n){
        if ((ii==false)&&(s[m]==i1)){
            ii = true;
            continue;
        }
        if ((ii==true)&&(jj==false)&&(s[m]==j1)){
            jj = true;
            continue;
        }
        if ((ii==true)&&(jj==true)&&(kk==false)&&(s[m]==k1)){
            kk = true;
            continue;
        }
    }
    if((ii==true)&&(jj==true)&&(kk==true)) ct++;
}

signed main(){
    cin >>n>>s;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                det(i,j,k);
            }
        }
    }
    cout<<ct<<endl;
}


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

int a[101],b[101],n=100,l,len=3,ans;
char s[101];
bool k;

int main(void)
{
    cin>>s;
    l=strlen(s);
    for(int i=l-1,j=1;i>=0;i--,j++)
    {
        a[j]=s[i]-'0';
    }
    
    b[3]=1;
    while(1)
    {
        ans++;
        for(int i=3;i<=len;i++)
        {
            b[i-2]+=b[i];
        }
        
        for(int i=1;i<=len;i++)
        {
            if(b[i]>=10)
            {
                b[i+1]+=b[i]/10;
                b[i]%=10;
            }
            
            if(i==len)
            {
                if(b[i+1]) len++;
            }
        }
        
        if(len>l) break;
        else
        {
            if(len==l)
            {
                k=true;
                for(int i=len;i>=1;i--)
                {
                    if(a[i]<b[i])
                    {
                        k=true;
                        break;
                    }
                    if(a[i]>b[i])
                    {
                        k=false;
                        break;
                    }
                }
                if(k==true) break;
            }
        }
        
    }
    
    printf("%d",ans);
    
    return 0;
}

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

#define PB push_back
#define MP make_pair
#define LL long long
#define LLU usinged long long
#define SZ(a) ((int)a.size())

using namespace std;

typedef pair<int,int> PII;

int main() {
	
	int N;
	scanf("%d", &N);
	
	vector<PII> ids;
	
	for(int i = 1; i <= N; i++) {
		int a;
		scanf("%d", &a);
		ids.emplace_back(a,i);
	}
	
	sort(ids.begin(), ids.end());
	
	for(PII p : ids) {
		printf("%d ", p.second);
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 1780
n = int(input())
H = list(map(int, input().split()))

now = H[0]
cnt = 0
ans = 0

for i in range(1,n):
    if now >= H[i]:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0

    now = H[i]

print(max(ans,cnt))

Measured memory_bytes: 20268
x1,y1,x2,y2 = tuple(map(int,input().split()))

x3,y3,x4,y4=0,0,0,0

x3 = x2+(y1-y2)
y3 = y2+(x2-x1)

x4 = x3+x1-x2
y4 = y3+y1-y2

print(x3,y3,x4,y4)

Measured memory_bytes: 38384
import java.io.*;

class Researcher {
	int mat[][] = new int[3][3];
	String index = "oxs";

	Researcher(String s) {
		for (int i=0;i<9;i++) {
			mat[i/3][i%3] = index.indexOf(s.charAt(i)); 
		}
	}

	char Research() {
		if (mat[1][1]<=1) {
			if (mat[0][0]==mat[1][1]&&mat[1][1]==mat[2][2]) return index.charAt(mat[0][0]);
			else if (mat[2][0]==mat[1][1]&&mat[1][1]==mat[0][2]) return index.charAt(mat[2][0]);
		}

		for (int i=0;i<3;i++) {
			if (mat[i][0]<=1) {
				if (mat[i][0]==mat[i][1]&&mat[i][1]==mat[i][2]) return index.charAt(mat[i][0]);
			}
			if (mat[0][i]<=1) {
				if (mat[0][i]==mat[1][i]&&mat[1][i]==mat[2][i]) return index.charAt(mat[0][i]);
			}
		}
		return 'd';
	}
}

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				System.out.println(new Researcher(buf).Research());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17060
N = int(input())
A = [0]

A_0 = map(int, input().split())
for i in A_0:
    A.append(i)
A.append(0)
    
sum_A = 0
for i in range(N + 1):
    sum_A += abs(A[i] - A[i + 1])

for i in range(1, N + 1):
    if (A[i+1] - A[i]) * (A[i] - A[i-1]) >= 0:
        print(sum_A)
    else:
        print(sum_A - min(abs(A[i+1] - A[i]), abs(A[i] - A[i-1])) * 2)



Measured memory_bytes: 14048
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
*/

main:-
    get_string(S),
    get_string(T),
    write(T),
    writeln(S).


Measured memory_bytes: 8060
#include <stdio.h>

#define N 2500

int solve(int ,int);

int n;
int A[N];

int main(){

  int i;
  int m;
  int q;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)==1){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
    return 0;
}

int solve(int i, int m){

  int res;
  
  if(m==0) return 1;
  if(i>=n) return 0;

  res = solve(i+1,m) || solve(i+1,m-A[i]);

  return res;
}

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


int main() {
    int n, k;
    cin >> n >> k;
    int p[n];
    int sum[n+1];
    for(int i=0; i<n; i++)cin >> p[i];
    sum[0] = 0;
    for(int i=0; i<n; i++)sum[i+1] = sum[i]+p[i];
    int max = 0;
    for(int i=0; i<=n-k; i++){
        int val = sum[k+i] - sum[i];
        if (max < val) max = val;
    }
    double ans = ((max + k) / 2.0);
    printf("%.16f", ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<int> factorize(int x){
  vector<int> ret;
  int d, q;
  while(x>=4 && x%2==0){ret.push_back(2); x/=2;}
  d = 3; q = x/d;
  while(q>=d){
    if(x%d==0){ ret.push_back(d); x=q; }else{ d+=2; }
    q=x/d;
  }
  ret.push_back(x);
  return ret;
}

int main(){
  int N;
  cin >> N;
  map<int,int> m;
  REP(i,2,N+1){
    vector<int> fac = factorize(i);
    rep(j,fac.size()){
      m[fac[j]]++;
    }
  }

  vector<vector<int>> dp(m.size()+1, vector<int>(100, 0));
  
  dp[0][1] = 1;
  int k=0;
  FOR(it,m){
    rep(i,100){
      REP(j,1,(it->second)+2){
        if(i*j<100) dp[k+1][i*j] += dp[k][i];
      }
    }
    k++;
  }

  cout << dp[k][75] << endl;
  
  return 0;
}


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

int main(){
 int N,M,C; cin >> N >> M >> C;
  int cnt =0;
  int B[M];
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  
  for(int i=0;i<N;i++){
    int sum=0;
    for(int j=0;j<M;j++){
      int A; cin >> A;
      sum += A*B[j];
    }
    if(sum + C > 0){
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

public class Main {

    private double sq(double x) {
        return Math.sqrt(x);
    }

    private double p2(double x) {
        return x * x;
    }

    private void solve() {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        H %= 12;
        M %= 60;

        double x1 = 0, y1 = B;
        double b1 = Math.PI * 2 * M / 60;
        double x3 = x1 * Math.cos(b1) + y1 * Math.sin(b1);
        double y3 = y1 * Math.cos(b1) - x1 * Math.sin(b1);

        double x2 = 0, y2 = A;
        double b2 = Math.PI * 2 * (1.0 * H / 12 + 1.0 * M / 720);
        double x4 = x2 * Math.cos(b2) + y2 * Math.sin(b2);
        double y4 = y2 * Math.cos(b2) - x2 * Math.sin(b2);

        double dist = sq(p2(x3 - x4) + p2(y3 - y4));
        out.println(dist);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 25564
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    
    
    for h in range(1,3501):
        for n in range(1,3501):
            temp=(4*h*n-(n+h)*N)
            if temp>0:
                if ((N*h*n)%temp)==0:
                    print(h,n,(N*h*n)//temp)
                    exit()
    
                    
                    

main()


Measured memory_bytes: 64760
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	int a[31];
	cin>>n>>m;
	memset(a,0,sizeof(a));
	for(int i=1;i<=n;i++)
	{
		int k;
		cin>>k;
		for(int j=1;j<=k;j++)
		{
			int t;
			cin>>t;
			a[t]++;
		}
	}
	int num=0;
	for(int i=1;i<=m;i++)
	   if(a[i]==n)num++;
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,K;
  cin>>N>>K;
vector<bool> vec(N,false);
  for (ll i=0;i<K;i++) {
ll d;
    cin>>d;
    for(ll i=0;i<d;i++) {
ll A;
      cin>>A;
      vec[A-1]=true;
    }
  }
  
  ll count=0;
  for(auto x:vec) {
if(!x) {
count++;
}
  }
  
  cout<<count<<endl;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
#include<map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
const int MOD = 1000000007;
int main(void) {
	int N, M, p, y, c;
	map<pair<int, int>, int> num;
	vector<pair<int, int> > data, data2;
	scanf("%d%d", &N, &M);
	rep(i, 0, M) {
		scanf("%d%d", &p, &y);
		data.push_back(make_pair(p, y));
		data2.push_back(make_pair(p, y));
	}
	sort(all(data2));
	p = 0;
	for (auto v : data2) {
		if (v.first == p)c++;
		else c = 1, p = v.first;
		num[v] = c;
	}
	for (auto v : data) {
		printf("%06d%06d\n", v.first, num[v]);
	}
	return 0;
}

Measured memory_bytes: 9324
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
int main(){
int N;
cin>>N;
vi a(N);
for(int &x:a)cin>>x;
if(N%2!=0){
    cout<<0;
    return 0;
}
sort(a.begin(),a.end());
cout<<a[N/2]-a[(N/2)-1];
return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	static int ans = 1;
	static int min;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		min = a[0];
		for (int i = 1; i < n; i++) {
			check(n, a, i);
		}

		System.out.println(ans);
	}

	public static void check(int n, int[] a, int i) {
		if (a[i] < min) {
			min = a[i];
			ans++;
		}
	}

}


Measured memory_bytes: 51216
# 3_5 stable_sort
#ALDS_1_2_C stable_sort

N = gets.to_i
a = gets.split
#
# N = 5
# a = %w(H4 C9 S4 D2 C3)

def bubble_sort(n,a)
  for i in 0..(n-1)
    (n-1).downto(i+1) do |j|
      a[j],a[j-1] = a[j-1],a[j] if a[j][-1] < a[j-1][-1]
    end
  end
end

def selection_sort(n,a)
  for i in 0..(n-1)
    minj = i
    i.upto(n-1) do |j|
      minj = j  if a[minj][-1] > a[j][-1]
    end
    a[i],a[minj] = a[minj],a[i] if a[i] != a[minj]
  end
end

def stable_sorted?(a_in, a_out)
  n = a_in.length
  for i in 0..(n-1)
    for j in (i+1)..(n-1)
      for a in 0..(n-1)
        for b in (a+1)..(n-1)
          if a_in[i][-1] == a_in[j][-1] and
            a_in[i] == a_out[b] and
            a_in[j] == a_out[a]
            return false
          end
        end
      end
    end
  end
  return true
end

b = Marshal.load(Marshal.dump(a))
bubble_sort(N,b)
puts b.join(' ')
puts stable_sorted?(a,b) ? "Stable" : "Not stable"

c = Marshal.load(Marshal.dump(a))
selection_sort(N,c)
puts c.join(' ')
puts stable_sorted?(a,c) ? "Stable" : "Not stable"


Measured memory_bytes: 8940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt();
			int t = scanner.nextInt();
			System.out.println(((x - t) > 0) ? (x - t) : 0);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

string cvt = "TJQKA";
string sts = "SHDC";
int board[5][15];
int kind[5][15];

string detail[] = {"North", "East", "South", "West"};

signed main() {
    string trump;
    while(cin >> trump, trump != "#") {
        int target = sts.find(trump);
        rep(i,0,4) rep(j,0,13) {
            string inp; cin >> inp;
            string val  = inp.substr(0, 1);
            string suit = inp.substr(1, 1);

            int f = cvt.find(val);
            if(f == string::npos) board[i][j] = val[0] - '0';
            else board[i][j] = f + 15;

            kind[i][j] = sts.find(suit);
        }

        int leader = 1;
        int pns = 0, pew = 0;
        rep(i,0,13) {
            int ma = -1, winner = 0;
            rep(j,0,4) {
                int k = (j+leader) % 4;
                int temp = 0;
                if(kind[k][i] == target) temp += 100;
                else if(kind[k][i] != kind[leader][i]) continue;
                temp += board[k][i];

                if(ma < temp) {
                    ma = temp;
                    winner = k;
                }
            }
            if(winner == 0 || winner == 2) pns++;
            else pew++;

            // cout << "winner: " << detail[winner] << endl;
            leader = winner;
        }
        if(pns < pew) {
            cout << "EW " << pew - 6 << endl;
        }
        else cout << "NS " << pns - 6 << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Node
    {
        internal List<int> children;
        internal int parent, preorder, lowest;
        internal bool isVisit;

        public Node()
        {
            children = new List<int>();
            parent = -1;
        }
    }

    class Program
    {
        static int timer;

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);

            Node[] NL = Enumerable.Range(0, V).Select(a => new Node()).ToArray();

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);

                NL[s].children.Add(t);
                NL[t].children.Add(s);
            }

            ArtPoints(NL);
        }

        static void ArtPoints(Node[] NL)
        {
            timer = 1;

            DFS(NL, 0, -1);

            int len = NL.Length;
            int[] result = new int[len];
            for (int i = 0; i < len; i++)
            {
                int p = NL[i].parent;

                if (p == -1) continue;
                if (NL[p].preorder <= NL[i].lowest) result[p]++;
            }
            result[0]--;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < len; i++)
            {
                if (result[i] > 0) sb.AppendLine(i.ToString());
            }
            Console.Write(sb);
        }

        static void DFS(Node[] NL, int current, int prev)
        {
            NL[current].preorder = timer;
            NL[current].lowest = timer;
            timer++;

            NL[current].isVisit = true;

            int len = NL[current].children.Count;
            for (int i = 0; i < len; i++)
            {
                int next = NL[current].children[i];

                if (!NL[next].isVisit)
                {
                    NL[next].parent = current;

                    DFS(NL, next, current);

                    NL[current].lowest = Math.Min(NL[current].lowest, NL[next].lowest);
                }
                else if (next != prev)
                {
                    NL[current].lowest = Math.Min(NL[current].lowest, NL[next].preorder);
                }
            }
        }
    }
}

Measured memory_bytes: 13012
s = str(input())

if len(s) % 2 != 0:
    ans = ' No'
else:
    ans = 'Yes'
    for i in range(0, len(s), 2):
        if s[i] == 'h' and s[i+1] == 'i':
            pass
        else:
            ans = 'No'

print(ans)

Measured memory_bytes: 2940
// https://www.youtube.com/watch?v=jQjnQJ9NPOY&list=PLn8m49B2OVF4kVTE0TK1PT-R0R9QhTVyS&index=1
#include<bits/stdc++.h>
using namespace std;
#define inf 1e18
#define int long long
#define ll long long
#define nl cout<<"\n";
#define all(v) v.begin(),v.end()
#define input(v) for(auto &i:v) cin>>i;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define forr(i , l , r) for(int i = int(l) ; i >= int(r); i--)
#define vi vector<int>
#define vii vector<vector<int>>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0);
void print(ll a)                  {              cout<<a<<'\t'<<'\n';}
void print(ll a,ll b)                {          cout<<a<<'\t'<<b<<'\t'<<'\n';}
void print(ll a,ll b,ll  c)             {      cout<<a<<'\t'<<b<<'\t'<<c<<'\n';}
void print(ll a,ll  b,ll  c,ll  d)         {   cout<<a<<'\t'<<b<<'\t'<<c<<'\t'<<d<<'\n';}
void print(ll a,ll  b,ll  c,ll  d,ll  e)      { cout<<a<<'\t'<<b<<'\t'<<c<<'\t'<<d<<'\t'<<e<<'\n';}
void print(vector<int> &a)  {for(auto i:a)  cout<<i<<" ";   nl;}
void print(string s)   {cout<<s, nl;}
void print(string s , ll a) { cout<<s<<"\t"<<a; nl;};
void print(string s , ll a , string ss , ll b) { cout<<s<<'\t'<<a<<'\t'<<ss<<'\t'<<b; nl;};


void sub(vector<int> &wt , vector<int> val , int idx , int tsum)
{

}


int32_t main()
{
    int n,weight,ans = 0;
    cin>>n>>weight;

    vi wt(n);
    vi val(n);

    for(int i=0 ; i<n ; i++)
        cin>>wt[i]>>val[i];

    vector<vector<int>> dp(n+1 , vector<int> (weight+1));

    dp[0][0] = 0;
    dp[0][wt[0]] = val[0];
    
//    dp[index][weight] = maxweight; 

    for(int i=1 ; i<n ; i++)
    {
        dp[i][0] = 0;
        for(int j=1 ; j<= weight ; j++)
        {
            // selected
            if(j >= wt[i])
                dp[i][j] = max(
                               dp[i][j],
                               dp[i-1][j-wt[i]] + val[i]
                               );

            // not selected;
            dp[i][j] = max(dp[i-1][j] , dp[i][j]);
        }
    }
    for(int i=0 ; i<= weight ; i++)
        ans = max(ans , dp[n-1][i]);

//    for(auto i : dp)
//    {
//        for(auto j : i)
//            cout<<j<<" ";
//        cout<<endl;
//    }
    cout<<ans;
}










// Connected Sum

/*

nodes edges
f   t   w

8 14
0 1 4
0 7 8
1 7 11
7 6 1
7 8 7
8 6 6
8 2 2
1 2 8
2 3 7
2 5 4
6 5 2
3 5 14
3 4 9
5 10 4

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

ans = 3;

*/






















Measured memory_bytes: 83096
#include<iostream>
#include<algorithm>

using namespace std;

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


int banboo(int s[], int w, int n, int l[], int a, int b, int c){
    if (w == n){
        int d[3] = {0,0,0};
        int cost = 0;
        for(int i = 0; i < n; i++){
            if (s[i] != 0) {
                if (d[s[i]-1] != 0) {
                    cost += 10;
                }
                d[s[i]-1] += l[i];
            }
        }
        cost += abs(a - d[0]) + abs(b - d[1]) + abs(c - d[2]);
        if (d[0] == 0 || d[1] == 0 || d[2] == 0) {
            cost = 1000000000;
        }
        
        return cost;
    }
    int mn = 1000000000;
    int s1[n];
    for(int i = 0; i < n; i++){
        s1[i] = s[i];
    }
    for(int i = 0; i < 4; i++){
        s1[w] = i;
        mn = min(mn, banboo(s1, w + 1, n, l, a, b, c));
    }
    return mn;
}

int main(){
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    int l[n];
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    int s[n];
    fill(s, s + n, 0);
    int ans = banboo(s, 0, n, l, a, b, c);
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

double mx_con;
double calc(int ws, int s) {
    if (s == 0) return 0.0;
    double con = 1.0 * s / ws;
    if (con <= mx_con) return con;
    else return -1.0;
}

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;
    mx_con = e / (e + 100.0);

    set<int> s, w;
    rep(i, f+1) rep(j, f+1) {
        int wa = a*i + b*j;
        int su = c*i + d*j;
        if (wa <= f && wa > 0) w.insert(wa);
        if (su <= f) s.insert(su);
    }
    double mx = -1;
    int WS = 0, S = 0;
    for (auto wi : w) {
        for (auto si : s) {
            int ws = wi + si;
            if (ws > f) continue;
            double con = calc(ws, si);
            if (con > mx) {
                mx = con;
                WS = ws;
                S = si;
            }
        }
    }
    cout << WS << " " << S << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define build 4
#define floor 3
#define room 10

int main(void) {
  int n,b,f,r,v,i,j,k;
  int house[build][floor][room]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    house[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<build;i++){
    for(j=0;j<floor;j++){
      for(k=0;k<room;k++)
	printf(" %d",house[i][j][k]);
      printf("\n");
    }
    if(i!=3){
      for(k=0;k<20;k++)
	printf("#");
      printf("\n");
    }
  }
  return(0);
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  int a,b;
  //vi a(n),b(n);
  int flag=0;
  REP(i,n){
    cin>>a>>b;
    if (a==b){
      flag++;
      if (flag==3)ans=1;
    }else{
      flag=0;
    }
  }

  if (ans==1){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define REP(i,n) for (ll i = 0; i < n; ++i)

const ll MAX = 1e5+10;
const ll MOD = 1e9+10;

string pass;

bool check() {
    REP (i, 3) {
        if (pass[i] == pass[i+1]) return false;
    }
    return true;
}

int main() {
    cin >> pass;
    if (check()) cout << "Good" << endl;
    else cout << "Bad" << endl;
}

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

using namespace std;

const int N = 1e5+100;

long long int dp[N], h[N];

int main () {
    long long int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++ ) {cin >> h[i];}
    dp[1]=0, dp[2]=abs(h[1]-h[0]);
    for(int i = 3 ; i <= n ; i++ ) {
        dp[i]=dp[i-1]+abs(h[i-1]-h[i-2]);
        dp[i]=min(dp[i],dp[i-2]+abs(h[i-1]-h[i-3]));
    }
    cout << dp[n];
}


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

x = []

for i in range(n):
	xi = [int(i) for i in input().split()]
	x.append(xi)

c = 0
for i in range(n):
	for j in range(i,n):
		tmp = 0.0
		for k in range(d):
			tmp += (x[i][k] - x[j][k])**2
		tmp = tmp**0.5
		if tmp != 0 and tmp.is_integer():
			c+=1
print(c)

Measured memory_bytes: 3188
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, m;
  while (cin >> n >> m, n) {
    vi v(n), q(m);
    rep(i, n) cin >> v[i];
    rep(i, m) cin >> q[i];
    int pos = 0;
    rep(i, m) {
      pos += q[i];
      if (pos >= n - 1) {
        cout << i + 1 << endl;
        break;
      }
      pos += v[pos];
      if (pos >= n - 1) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3076
def main():
    from collections import Counter
    n=int(input())
    A=list(map(int,input().split()))

    even=Counter(A[::2]).most_common()
    odd=Counter(A[1::2]).most_common()
    
    if even[0][0]!=odd[0][0]:
        ans=n-even[0][1]-odd[0][1]
    else:
        ans=0
        if len(even)>1:
            ans=max(even[1][1]+odd[0][1],ans)
        if len(odd)>1:
            ans=max(even[0][1]+odd[1][1],ans)
        else:
            ans=max(even[0][1],odd[0][1],ans)
        ans=n-ans
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 20700
import numpy as np
# 締切が早いものから処理
N = int(input())
AB = np.array([[int(x) for x in input().split()] for _ in range(N)])
A = AB[:,0]
B = AB[:,1]
idx = B.argsort()
A = A[idx]
B = B[idx]
np.cumsum(A, out = A)
bl = (A <= B).all()
answer = 'Yes' if bl else 'No'
print(answer)

Measured memory_bytes: 49964
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int a,b,q;
  cin>>a>>b>>q;
  vector<ll> s(a), t(b), x(q);
  rep(i,a) cin>>s[i];
  rep(i,b) cin>>t[i];
  rep(i,q) cin>>x[i];
  ll ans[q];
  rep(i,q) {
    auto ps = lower_bound(s.begin(), s.end(), x[i]);
    auto pt = lower_bound(t.begin(), t.end(), x[i]);
    int ids = ps - s.begin();
    int idt = pt - t.begin();
    vector<ll> nexts, nextt;
    if(ids == 0) {
      nexts.push_back(s[0]);
    } else if (ids == a) {
      nexts.push_back(s[a-1]);
    } else {
      nexts.push_back(s[ids]);
      nexts.push_back(s[ids-1]);
    }
    if(idt == 0) {
      nextt.push_back(t[0]);
    } else if (idt == b) {
      nextt.push_back(t[b-1]);
    } else {
      nextt.push_back(t[idt]);
      nextt.push_back(t[idt-1]);
    }
    ll mi = LINF;
    for (const auto& es : nexts) {
      for(const auto& et: nextt) {
        if((es-x[i]) * (et-x[i]) <= 0) {
          mi = min(mi, max(es,et) - min(es,et) + min(abs(es-x[i]), abs(et-x[i])));
        } else {
          mi = min(mi, max(abs(es-x[i]), abs(et-x[i])));
        }
      }
    }
    ans[i] = mi;
  }
  rep(i,q) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4480