akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c);
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))

ans = 10**15
for t in range(1,N):
    a = []
    b = []
    for i in range(N):
        if i > t:
            a.append(W[i])
        else:
            b.append(W[i])
    ans = min(ans , abs(sum(a) - sum(b)))
print(ans)


Measured memory_bytes: 39536
#include<bits/stdc++.h>
using namespace std;
#define data_type long long

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    data_type t,n,k,a;
    cin>>k>>n;
    vector<data_type> arr(n),clw(n);
    for(auto &i:arr)
        cin>>i;

    for(int i=0; i<n; i++)
        {
            data_type x=arr[(i+1)%n];
            if(x<arr[i])
                x+=k;
            clw[i]=x-arr[i];
        }



    data_type sum=0,in=n-1,max_sum=LLONG_MAX;
    for(int i=0; i<n; i++)
        sum+=clw[i];

    for(int i=0; i<n; i++,in++)
        max_sum=min(max_sum,sum-clw[in%n]);


    cout<<max_sum<<endl;




    return 0;
}


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

int X, N;
set<int> P;

int main(){
  cin >> X >> N;
  rep(i, N){
    int p;
    cin >> p;
    P.insert(p);
  }

  // Xとの差は大きくても50程度
  int diff = 110;
  int ans = 0;
  // 0から101までを全探索する
  rep(i, 102){
    // setの存在判定
    if (!P.count(i)){
      // Xとの差分の更新
      if (diff > abs(X-i)){
        diff = abs(X-i);
        ans = i;
      }
    }
  }
  cout<< ans << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    long long a[n];
    long long sum = 0, mi = 1e9;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += abs(a[i]);
        mi = min(mi, abs(a[i]));
        if(a[i] < 0) cnt++;
    }
    long long ans;
    if(cnt%2 == 0) ans = sum;
    else ans = sum - 2*mi;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
Sd = list(input())
A = list(input()) #部分文字列


def check(Sd, A):
    ans = -1
    for i in range(len(Sd)-1, -1, -1): #リストSd内の文字を後ろから順に呼び出すため
        count = 0
#        print ('i=', i)
        for j in range(len(A)): #後ろから何文字目か
#            print ('j=', j)
#            print ('Sd[i-j]', Sd[i-j])
            if Sd[i - j] == A[len(A)-1 - j] or Sd[i - j] == '?':
                count += 1
                if count == len(A):
                    ans = i-j #全て変わる時の一番最初の文字
                    return ans
    return ans

a = check(Sd, A)

if a == -1:
    print ('UNRESTORABLE')
else:
    i = a
    while i < a + len(A):
        Sd[i] = A[i-a]
        i += 1
    for j in range(len(Sd)):
        if Sd[j] == '?':
            Sd[j] = 'a'
    print (''.join(Sd))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


signed main(){ 
    long double a,b;
    cin>>a>>b;

    long double c=a*b;
    int res=floorl(c);
    cout<<res<<endl;
}  

Measured memory_bytes: 3788
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 10;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	if (*ci == '-') ci++;
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}


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


	ll N = getint(), D = getint();
	D = D * D;

	int kotae = 0;
	rep(i, N) {
		ll X = getint(), Y = getint();
		kotae += (D >= X * X + Y * Y);
	}
	printf("%lld\n", kotae);


	Would you please return 0;
}

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

int main(){
    int N, n1,n2,n3,n4;
    int a,b,c;
    
    cin >> N;
    
    n1 = N / 1000;
    a = N - n1*1000;
    n2 = a / 100;
    b = a - n2*100;
    n3 = b / 10;
    c = b - n3*10;
    n4 = c;
    
    if ((n1==n2 && n2==n3) || (n2==n3 && n3==n4) || (n1==n2 && n2==n3 && n3==n4))
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n,m,c = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for _ in range(n)]

ans=0
for i in range(n):
    tmp=0
    for j in range(m):
        tmp += a[i][j]*b[j]
    
    if tmp + c > 0:
        ans+=1

print(ans)
    

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, k;

signed main() {
    cin >> n >> k;
    cout << n-k+1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] aa = new long[n];
		long a = 0;
		long g = 0;
		long k = 0;
		for (int i = 0; i < n; i++) {
			aa[i] = sc.nextLong();
			if (i % 2 == 0) {
				g += aa[i];
			} else {
				k += aa[i];
			}
		}

		System.out.print(g - k);
		for (int i = 1; i < n; i++) {
			if (i % 2 == 0) {
				k -= aa[i - 1];
				g += aa[i - 1];
				System.out.print(" " + (g - k));
			} else {
				k += aa[i - 1];
				g -= aa[i - 1];
				System.out.print(" " + (k - g));
			}
		}
	}
}


Measured memory_bytes: 71460
#include <stdio.h>
#include <stdlib.h>
int main(){
  int sum = 0;
  int *cache = malloc(sizeof(int));
  int *n = malloc(sizeof(int));
  scanf("%d", n);
  int *t = malloc(*n * sizeof(int));
  for(int i = 0;i < *n;++i){
    scanf("%d", &t[i]);
  }
  int *m = malloc(sizeof(int));
  scanf("%d", m);
  int **drink = malloc(*m * sizeof(int *));
  for(int i = 0;i < *m;++i){
    drink[i] = malloc(2 * sizeof(int));
    scanf("%d%d", &drink[i][0], &drink[i][1]);
    *cache = t[drink[i][0] - 1];
    t[drink[i][0] - 1] = drink[i][1];
    for(int j = 0;j < *n;++j) sum+=t[j];
    printf("%d\n", sum);
    t[drink[i][0] - 1] = *cache;
    sum = 0;
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vi p(n);
    for (int& i : p)
        cin >> i;
    vector<ld> e;
    for (int i : p)
        e.push_back((1 + i) / 2.);
    vector<ld> pref(n);
    pref[0] = e[0];
    for (int i = 1; i < n; i++)
        pref[i] = pref[i - 1] + e[i];
    ld res = pref[k - 1];
    for (int i = k; i < n; i++)
        res = max(res, pref[i] - pref[i - k]);
    cout << fixed << setprecision(20) << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 8940
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	int n;
	cin >> n;
	double res = 0;
	for (int i = 0; i < n; i++) {
		int c;
		cin >> c;
		res += (1.0 / (double)c);
	}
	cout << setprecision(20) << (1.0 / res) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S,T;
    cin >> S >> T;
    ll count=0;
    for(size_t i=0;i<S.size(); i++)
    {
        if(S[i]!=T[i]) count++;
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3856
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		while(true){
			var d=int.Parse(Console.ReadLine());
			if(d==0)break;
			Sol mySol=new Sol(d);
			Console.WriteLine("{0,10:F8}",mySol.Ans);
		}
	}
}

class Sol{
	double ans;
	public double Ans{
		get{return ans;}
	}
	
	
	public Sol(int d){
		double[,][] P=new double[3,3][];
		for(int i=0;i<9;i++)P[i%3,i/3]=new double[d+1];
		
		var ss=Console.ReadLine().Split(' ');
		int posS;
		int posT;
		int posB;
		
		for(int i=0;i<9;i++)P[i%3,i/3][0]=0;
		posS=(int)(ss[0][0]-'A');
		posT=(int)(ss[1][0]-'A');
		posB=(int)(ss[2][0]-'A');
		
		P[posS%3,posS/3][0]=1.0;
		
		double[,][] Pd=new double[3,3][];
		for(int i=0;i<9;i++){
			int x=i%3;
			int y=i/3;
			Pd[x,y]=new double[5]{0.0,0.25,0.25,0.25,0.25};// 0:pause,1:Left,2:Right,3:Down,4:Up
			
			if(x==0 || (x==posB%3+1 && y==posB/3  ) ){Pd[x,y][0]+=0.25;Pd[x,y][1]-=0.25;}
			if(x==2 || (x==posB%3-1 && y==posB/3  ) ){Pd[x,y][0]+=0.25;Pd[x,y][2]-=0.25;}
			if(y==0 || (x==posB%3   && y==posB/3+1) ){Pd[x,y][0]+=0.25;Pd[x,y][4]-=0.25;}
			if(y==2 || (x==posB%3   && y==posB/3-1) ){Pd[x,y][0]+=0.25;Pd[x,y][3]-=0.25;}
			
		}
		
		for(int j=1;j<=d;j++){
			for(int k=0;k<9;k++){
				int xx=k%3;
				int yy=k/3;
				P[xx,yy][j] =P[xx,yy][j-1]*Pd[xx,yy][0];
				if(xx+1<=2)P[xx,yy][j]+=P[xx+1,yy][j-1]*Pd[xx+1,yy][1];
				if(xx-1>=0)P[xx,yy][j]+=P[xx-1,yy][j-1]*Pd[xx-1,yy][2];
				if(yy-1>=0)P[xx,yy][j]+=P[xx,yy-1][j-1]*Pd[xx,yy-1][3];
				if(yy+1<=2)P[xx,yy][j]+=P[xx,yy+1][j-1]*Pd[xx,yy+1][4];
			}
		}
		
		ans=P[posT%3,posT/3][d];
	
	}
}

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

list = [input().split() for _ in range(n)]
for i in range(n):
    list[i].append(i+1)
for i in range(n):
    list[i][1] = int(list[i][1])

list = sorted(list, key=lambda x:(x[0],-x[1]))

for i in range(n):
    print(list[i][2])


Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn main() {
    let (n, a, b) = get!(isize, isize, isize);

    if (a - b).abs() % 2 == 0 {
        println!("Alice");
    } else {
        println!("Borys");
    }
}


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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
 
int main(){
   string s,t;
   cin>>s>>t;
   int count=0;
   for(int i=0;i<s.length();i++){
     if(s[i]!=t[i])count++;
   }cout<<count<<"\n";

}

Measured memory_bytes: 3852
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Minesweeper
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 50;
const int MAX_W = 50;

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

/* typedef */

/* global variables */

string flds[MAX_H];

/* subroutines */

/* main */

int main() {
  int h, w;
  cin >> h >> w;
  for (int y = 0; y < h; y++) cin >> flds[y];

  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++)
      if (flds[y][x] == '.') {
	int cnt = 0;
	for (int di = 0; di < 8; di++) {
	  int vx = x + dxs[di], vy = y + dys[di];
	  if (vx >= 0 && vx < w && vy >= 0 && vy < h && flds[vy][vx] == '#')
	    cnt++;
	}
	flds[y][x] = '0' + cnt;
      }

  for (int y = 0; y < h; y++) cout << flds[y] << endl;
  return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n,m;
  cin >> n >> m;
  int64 ans = min(n, m/2);
  m -= ans * 2;
  ans += m / 4;
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long A,B,K;
  cin >> A >> B >> K;
  if(A<K){K-=A;A=0;}
  else{A-=K;K=0;}
  if(B<K){K-=B;B=0;}
  else{B-=K;K=0;}
  cout << A << " " << B << endl;
  return 0;
}

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

int main(void) {
    i64 h, w, ans = 0;
    cin >> h >> w;
    vector<vector<bool>> grid(h, vector<bool>(w, false));
    vector<vector<i64>> u(h, vector<i64>(w)),
                        d(h, vector<i64>(w)),
                        l(h, vector<i64>(w)),
                        r(h, vector<i64>(w));
    for (i64 i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (i64 j = 0; j < w; j++) {
            if (s[j] == '#') grid[i][j] = true;
        }
    }
    for (i64 j = 0; j < w; j++) {
        i64 nu = -1;
        for (i64 i = 0; i < h; i++) {
            if (grid[i][j]) nu = i;
            u[i][j] = nu;
        }
    }
    for (i64 j = 0; j < w; j++) {
        i64 nd = h;
        for (i64 i = h - 1; i >= 0; i--) {
            if (grid[i][j]) nd = i;
            d[i][j] = nd;
        }
    }
    for (i64 i = 0; i < h; i++) {
        i64 nl = -1;
        for (i64 j = 0; j < w; j++) {
            if (grid[i][j]) nl = j;
            l[i][j] = nl;
        }
    }
    for (i64 i = 0; i < h; i++) {
        i64 nr = w;
        for (i64 j = w - 1; j >= 0; j--) {
            if (grid[i][j]) nr = j;
            r[i][j] = nr;
        }
    }
    for (i64 i = 0; i < h; i++) {
        for (i64 j = 0; j < w; j++) {
            if (grid[i][j]) continue;
            ans = max(ans,
                d[i][j] - u[i][j] - 1 + r[i][j] - l[i][j] - 1 - 1);
        }
    }
    cout << ans << endl;
}

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



int main()
{
	int A1,A2,A3,ans;
	cin >> A1 >> A2 >> A3;
	if (A1 >= A2&&A1 >= A3){
		if (A2 >= A3){
			ans = (A2 - A3) + (A1 - A2);
		}
		else{
			ans = (A3 - A2) + (A1 - A3);
		}
	}
	else if (A2 >= A1&&A2 >= A3){
		if (A1 >= A3){
			ans = (A1 - A3) + (A2 - A1);
		}
		else{
			ans = (A3 - A1) + (A2 - A3);
		}
	}
	else{
		if (A1 >= A2){
			ans = (A1 - A2) + (A3 - A1);
		}
		else{
			ans = (A2 - A1) + (A3 - A2);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long INF = 1e18;

int main(){

    int n;
    cin>>n;
    int a,b,c;

    

    long long dp[100010][5];

    for(int i=1;i<3;i++){
        dp[1][i] = 0;
    }

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

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

int main(){
    int k;
    char s[101], t[101];

    scanf("%d %s", &k, s);

    if(strlen(s) <= k){
        puts(s);
        return 0;
    }
    else{
        int i;
        for(i = 0; i < k + 3; ++i){
            if(i < k) t[i] = s[i];
            else t[i] = '.';
        }
        t[i] = '\0';
    }

    puts(t);

    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N, Ma, Mb;
vector<int> a, b, c;
int dp[41][441][441];

const int INF = 1e9;

void init()
{
	cin >> N >> Ma >> Mb;
	a.RS(N);
	b.RS(N);
	c.RS(N);
	rep(i, N) cin >> a[i] >> b[i] >> c[i];
	rep(i, 41) rep(j, 441) rep(k, 441) dp[i][j][k] = INF;
	dp[0][0][0] = 0;
}

void solve()
{
	reps(i, 1, N+1) {
		rep(j, N*10+1) {
			rep(k, N*10+1) {
				dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k]);
				dp[i][j+a[i-1]][k+b[i-1]] = min(dp[i][j+a[i-1]][k+b[i-1]], dp[i-1][j][k] + c[i-1]);
			}
		}
	}
	int res = INF;
	reps(i, 1, N*10+1) {
		reps(j, 1, N*10+1) {
			if (i * Mb != j * Ma) continue;
			res = min(res, dp[N][i][j]);
		}
	}
	if (res == INF) cout << -1 << endl;
	else cout << res << endl;
}


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

int n,k;
int w[1000000];

int main(){
   int n;
   cin >> n;
   string s;
   cin >>s;
   if(n%2==1){
      cout <<"No" << endl;
      return 0;
   }
   bool judge = true;
   for(int i=0;i<n/2;i++){
      if(s[i] != s[n/2+i]){
         judge = false;
         break;
      }
   }
   if(judge) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  long long  n,d,i,x,y,c=0;
  cin>>n>>d;
  for(i=0;i<n;i++)
  {
      cin>>x>>y;
      if(x*x+y*y<=d*d)
        c++;

  }

    cout<<c;


}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void) {
	long int N, K, p, q;
	scanf("%ld %ld", &N, &K);
	p = N % K;
	q = K - p;
	if (p > q)
		printf("%ld", q);
	else
		printf("%ld", p);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <unordered_set>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

using ll = long long;

struct Edge {
  ll v;
  ll m;
  ll cost;
};

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

  ll N, M, S; std::cin >> N >> M >> S;
  if ( S > 2500 ) S = 2500;

  std::vector<Edge> G[N][2501];
  for(int i=0; i<M; i++) {
    ll u, v, a, b; std::cin >> u >> v >> a >> b; u--, v--;
    for(int s=a; s<=2500; s++) {
      G[u][s].push_back( Edge({v, s-a, b}) );
      G[v][s].push_back( Edge({u, s-a, b}) );
    }
  }

  for(int i=0; i<N; i++) {
    int c, d; std::cin >> c >> d;
    for(int s=0; s+c<=2500; s++) {
      G[i][s]  .push_back( {i, s+c, d} );
    }
  }


  // dijkstra
  std::vector<std::vector<ll>> D(N, std::vector<ll>(2501, std::numeric_limits<ll>::max()));
  auto comp = [](const Edge &x, const Edge &y) -> bool { return x.cost > y.cost; };
  std::priority_queue<Edge, std::vector<Edge>, decltype(comp) > pq(comp);
  pq.push( Edge( { 0, S, 0 } ) );
  D[0][S] = 0;
  while( !pq.empty() ) {
    auto cur = pq.top(); pq.pop();
    ll d = cur.cost;
    if ( D[cur.v][cur.m] < d ) continue;
    for(auto&& e : G[cur.v][cur.m]) {
      if ( D[e.v][e.m] > D[cur.v][cur.m] + e.cost ) {
        D[e.v][e.m] = D[cur.v][cur.m] + e.cost;
        pq.push( Edge( {e.v, e.m, D[e.v][e.m]} ) );
      }
    }
  }

  for(int i=1; i<N; i++) {
    ll ans = std::numeric_limits<ll>::max();
    for(int s=0; s<=2500; s++) ans = std::min<ll>(ans,D[i][s]);
    std::cout << ans << std::endl;
  }

  return 0;
}


Measured memory_bytes: 31160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
vi dy = { 0,0,1,-1 };
vi dx = { 1,-1,0,0 };
constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

int n;
vi a,b,c;
vvi memo;

int dp(int x, int y) {

	if (memo[x][y] != INF)return memo[x][y];

	if (x == 0) {
		if (y == 0) { memo[0][0] = a[0];return a[0]; }
		if (y == 1) { memo[0][1] = b[0];return b[0]; }
		if (y == 2) { memo[0][2] = c[0];return c[0]; }
	}

	int re;
	if (y == 0) re = max(dp(x - 1, 1) + a[x], dp(x - 1, 2) + a[x]);
	else if (y == 1) re = max(dp(x - 1, 0) + b[x], dp(x - 1, 2) + b[x]);
	else re = max(dp(x - 1, 1) + c[x], dp(x - 1, 0) + c[x]);
	memo[x][y] = re;
	return re;
}

int main() {
	cin >> n;
	a.resize(n);
	b.resize(n);
	c.resize(n);
	rep(i, n)cin >> a[i] >> b[i] >> c[i];

	memo.assign(n,vi(3,INF));
	
	int ans = 0;
	ans = max(ans, dp(n - 1, 0));
	ans = max(ans, dp(n - 1, 1));
	ans = max(ans, dp(n - 1, 2));

	cout << ans << endl;
}

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

const int M = 998244353;

long long modinv(long long a, long long m) {
    long long x = m, y = a, p = 1, q = 0, r = 0, s = 1;
    while (y != 0) {
        long long u = x / y;
        long long x0 = y; y = x - y * u; x = x0;
        long long r0 = p - r * u, s0 = q - s * u;
        p = r; r = r0; q = s; s = s0;
    }
    return q < 0 ? q + m : q;
}

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int n, k; cin >> n >> k;
    int p[n]; for (int i = 0; i < n; i++) cin >> p[i];
    vector<long long> ft(n+1, 0);
    long long ans = 0;
    long long b = (long long)(k - 1) * modinv(k, M) % M;
    long long total = 0;
    for (int i = 0; i < n; i++) {
        long long sum = 0;
        for (int x = p[i]; x > 0; x -= x&-x) sum += ft[x];
        ans += (2 * sum - total) % M * modexp(b, max(i, k-1), M) % M;
        long long add = modexp(b, M - max(i, k-1) - 1, M) * ((M + 1) / 2) % M;
        // cerr << "add " << i << " " << add << endl;
        for (int x = p[i]; x <= n; x += x&-x) ft[x] += add;
        total += add;
        // for (int i = 0; i < n; i++) cerr << ft[i+1] << ' ' ; cerr << endl;
        // cerr << "total = " << total << endl;
    }
    fill(ft.begin(), ft.end(), 0);
    for (int i = 0; i < n; i++) {
        int s = 0;
        for (int x = p[i]; x <= n; x += x&-x) s += ft[x];
        for (int x = p[i]; x > 0; x -= x&-x) ft[x]++;
        ans += s;
    }
    cout << (ans % M + M) % M << endl;
}


Measured memory_bytes: 5636
#include<iostream>

using namespace std;

char A[55][55], B[55][55];

int main(){
    int n, m; cin >> n >> m;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            cin >> B[i][j];
        }
    }

    bool yes = false;

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            bool match = true;

            for(int k = 0; k < m; ++k){
                for(int l = 0; l < m; ++l){
                    if(i + k >= n || j + l >= n){ // Kasus keluar batas
                        match = false;
                        break;
                    }
                    if(A[i + k][j + l] == B[k][l])continue;
                    match = false;
                }
            }

            if(match) yes = true;
        }
    }

    if(yes)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{

    long long N;
    cin >> N;

    vector<int> v;
    int cnt = 0;
    int tmp = 0;

    if (N==1){
        
    cout << 1 << endl;

    return 0;
    } 

    while (1)
    {
        tmp = pow(2, cnt);
        if (tmp > 100)
        {
            break;
        }
        else
        {
            v.push_back(tmp);

            cnt++;
        }
    }

    int imax =0;
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] <= N){
            imax = max(imax,v[i]);
        }
            
    }

    cout << imax << endl;

}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mx = 1e7+1;
 int n,c[mx];
int main(){
cin>>n;
for(int i=1; i<=n; ++i)
		for(int j=0; (j+=i)<=n; )
			++c[j];
ll ans = 0;

for(int i = 1;i<=n;i++){
     ans+=(ll)i*c[i];
}
cout<<ans<<endl;


}


Measured memory_bytes: 42620
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int X, Y;
void calc(vector<pair<int,int>> &v, char c, int d) {
  int x = X, y = Y;
  switch (c) {
    case 'N':
      Y += d;
      break;
    case 'W':
      X -= d;
      break;
    case 'S':
      Y -= d;
      break;
    case 'E':
      X += d;
      break;
  }
  for (int i = 0; i < v.size(); i++) {
    if ((x <= v[i].first && v[i].first <= X) || (X <= v[i].first && v[i].first <= x)) {
      if ((y <= v[i].second && v[i].second <= Y) || (Y <= v[i].second && v[i].second <= y)) {
        v.erase(v.begin() + i);
        i--;
      }
    } 
  }
}

signed main() {
  int N;
  while(cin >> N, N) {
    vector<pair<int,int>> gems(N);
    for (int i = 0; i < N; i++) {
      int x, y;
      cin >> x >> y;
      gems[i] = make_pair(x, y);
    }
    
    int M;
    cin >> M;
    Y = 10, X = 10;
    for (int i = 0; i < M; i++) {
      char c; int d;
      cin >> c >> d;
      calc(gems, c, d);
    }

    if (gems.size() == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }  
}




Measured memory_bytes: 2988
#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
long long n,k,vis[5005];
long long p[5005],c[5005],sum[5005],ans=-1e18;
int main(){
	cin >> n >> k;
	for(int i=1; i<=n; i++) cin >> p[i];
	for(int i=1; i<=n; i++) cin >> c[i];
	for(int i=1; i<=n; i++){

	long long s=c[i];

	vector<long long>ti;
	ti.push_back(s);

	for(int j=p[i];j!=i;j=p[j])
    {
    s+=c[j];
    ti.push_back(s);
    }
	int len=ti.size();
	for(int j=0;j<len;j++){

        long long rest=k-j-1;
        if(rest<0)
            break;
        ans=max(ans,rest/len*max(0LL,s)+ti[j]);

	}


	}


	cout << ans;
}


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

int main() {
    int a,b;cin>>a>>b;
    int c[3];
    c[0]=a+b;
    c[1]=a-b;
    c[2]=a*b;
    sort(c,c+3);
    cout<<c[2]<<endl;
	return 0;
}

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

int w, n, a, b, r[30];

int main() {
	scanf("%d %d",&w,&n);
	rep(i,w) r[i] = i+1;
	rep(i,n) {
		scanf("%d,%d",&a,&b);
		swap(r[a-1], r[b-1]);
	}
	rep(i,w) printf("%d\n",r[i]);
}


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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	auto iter = s.begin();
	const std::string find_word("ABC");
	rep(i, n) {
		iter = search(iter,s.end(), find_word.begin(),find_word.end());
		if (iter != s.end()) {
			ans++;

			iter += 3;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

N,K=map(int, sys.stdin.readline().split())
R,S,P=map(int, sys.stdin.readline().split())
T=raw_input()

max_T=[]
for x in T:
    if x=="r": max_T.append("p")
    elif x=="s": max_T.append("r")
    elif x=="p": max_T.append("s")

for i,x in enumerate(max_T):
    if i+K<N:
        if max_T[i]==max_T[i+K]:
            max_T[i+K]=None

ans=0
for x in max_T:
    if x=="r": ans+=R
    elif x=="s": ans+=S
    elif x=="p": ans+=P
print ans


Measured memory_bytes: 41756
#D
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
win={"r":"p","s":"r","p":"s"}
score={"r":R,"s":S,"p":P}

ans=0
dp=[0 for i in range(N)]
for i in range(K):
    dp[i]=win[T[i]]
    ans+=score[dp[i]]
        
for i in range(K,N):
    if T[i-K]==T[i] and dp[i-K]==win[T[i]]:
        dp[i]=T[i]
    elif T[i-K]==T[i]:
        dp[i]=win[T[i]]
        ans+=score[dp[i]]
    else:
        dp[i]=win[T[i]]
        ans+=score[dp[i]]
print(ans)
    

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる
//std::binary_search(v.bgn,v.en,a);
//abs(a,b)   pow(a,n)  to_string  stoll
//auto Iter=lower_bound(v.bgn,v.en,a);
//lower//upper  co(*Iter)co(Iter-v.bgn);

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n;
  cin>>n;
  ll a;
  ll count=0;
  for(ll i=n;i>0;i--){
    if((100000>i&&i>=10000)||(1000>i&&i>=100)||(10>i&&i>0)){
      count++;
    }
  }
  co(count);
}
  

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[100001];
int main() {
	scanf("%s", s);
	int g = 0, p = 0;
	for (int i = 0; i < strlen(s); i++) {
		if (s[i] == 'g') {
			g++;
		}
		else {
			p++;
		}
	}
	printf("%d", (g - p) / 2);
	return 0;
}

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

using namespace std;

using uif=uint_fast64_t;

int main(void){

  string s;
  cin>>s;

  char name[]="keyence";

  //cout << s.substr(0,7) << endl;
  //cout << s.substr(s.size()-7,7) << endl;

  if( s.substr(0,7) == "keyence" || s.substr(s.size()-7,7) == "keyence" ){
    cout << "YES"<< endl;
    return 0;
  }
  else{
    uif f=0;
    uif b=0;

    for(uif i=0;i<7;i++){
      //cout << s[i] << "," << name[i] << endl;
      if( s[i] == name[i] ){
        f++;
      }
      else{
        break;
      }
    }
    //cout << f << endl;
    for(uif i=0;i<7;i++){
      //cout << s[s.size()-1-i] << "," << name[6-i] << endl;
      if( s[s.size()-1-i ] == name[6-i] ){
        b++;
      }
      else{
        break;
      }
    }
    //cout << b << endl;
    if(f+b>=7){
      cout << "YES"<< endl;
    }
    else{
      cout << "NO"<< endl;
    }

  }


  return 0;
}


Measured memory_bytes: 384
def dfs(ver, p):
    global visited, ans
    if p == N:
        ans += 1
        return
    for i in range(N):
        if graph[ver][i] == 1 and visited[i] != 1:
            visited[i] = 1
            dfs(i, p+1)
            visited[i] = 0

N, M = map(int,input().split())

graph = [[0] * N for _ in range(N)]

for i in range(M):
    a, b = map(int,input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1

ans = 0
visited = [0] * N
visited[0] = 1

dfs(0, 1)

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

stack<double> st;

int main() {
	char str[100];
	char ch;
	double buf1,buf2;
	while(~scanf("%s",str)){
		if(isdigit(str[0])||str[0]=='-'&&strlen(str)>1&&isdigit(str[1])){
			st.push(atof(str));
//cout<<atof(str)<<endl;
		}else{
			if(str[0]=='+'){
				buf1=st.top();
				st.pop();
				buf2=st.top();
				st.pop();
				st.push(buf1+buf2);
//cout<<st.top()<<endl;
			}
			if(str[0]=='-'){
				buf1=st.top();
				st.pop();
				buf2=st.top();
				st.pop();
				st.push(buf2-buf1);
//cout<<st.top()<<endl;
			}
			if(str[0]=='*'){
				buf1=st.top();
				st.pop();
				buf2=st.top();
				st.pop();
				st.push(buf1*buf2);
//cout<<st.top()<<endl;
			}
			if(str[0]=='/'){
				buf1=st.top();
				st.pop();
				buf2=st.top();
				st.pop();
				st.push(buf2/buf1);
//cout<<st.top()<<endl;
			}
		}
		ch=getchar();
		if(ch!=' '){
			buf1=st.top();
			printf("%.10f\n",buf1);
			st.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 0
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,a[N],j,ans=1e3,num;
void solve(){
	cin>>n;
	rep(i,1,n)cin>>a[i];
	rep(i,1,n){
		num=ans/a[i];
		for(j=i+1;j<=n;j++){
			if(a[j]<a[j-1])break;
		}
		j--;
		ans=max(ans,(a[j]-a[i])*num+ans);
		i=j;
	}
	cout<<ans;
}
int32_t main()
{
  // ibs;cti;
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int A, B, K;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int i,j,k,cnt;
		
		while(true){
			cnt=0;
		    int n=scan.nextInt();
		    int x=scan.nextInt();
		    if(n==0 && x==0)break;
			
		    for(i=n;i>=3;i--){
			    for(j=i-1;j>=2;j--){
				    for(k=j-1;k>=1;k--){
					    if(i+j+k==x)cnt++;
				    }
			    }
		    }
			System.out.println(cnt);
		}
	}
}


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


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ld A;
    cin >> A;
    ld B;
    cin >> B;
    ld K=A*B;
    prt((ll)K)

    
    return 0;
}


Measured memory_bytes: 3748
main :-	read_num(A),
        read_num(B),
        C is A * B,
        write(C),
        nl.


read_str(S) :-
        read_string(current_input, ' \n', '', _, S).
read_num(N) :-
        read_str(S),
        number_string(N, S).

:- main.

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

long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

int main() {
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << (B - B / C - B / D + B / (C * D / GCD(C, D))) - ((A - 1) - (A - 1) / C - (A - 1) / D + (A - 1) / (C * D / GCD(C, D))) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		int a[] = new int[3];
		int max = 0;

		for(int i = 0 ; i < 3; i++) {
			a[i] = sc.nextInt();
			if(max < a[i]) max = i;
		}
		int ans = 1;
		for(int i = 0; i < 3; i++) {
			if(i != max)ans *= a[i];
		}
		System.out.println(ans / 2);
	}


	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const int MAX = 30;

class node {
  public:
  int p, l, r;

  node(int p = -1, int l = -1, int r = -1): p(p), l(l), r(r) {}
};

int h[MAX];
node t[MAX];

int getsibling(int id) {
  int p = t[id].p;
  if (p == -1) return -1;
  else if (t[p].l != id) return t[p].l;
  else return t[p].r;
}

int getdegree(int id) {
  int cnt = 0;
  if (t[id].l != -1) cnt++;
  if (t[id].r != -1) cnt++;
  return cnt;
}

int getdepth(int id) {
  int d = 0;
  while (t[id].p != -1) {
    d++;
    id = t[id].p;
  }
  return d;
}

int getheight(int id) {
  if (h[id] != -1) return h[id];
  if (t[id].l == -1 && t[id].r == -1) {
    h[id] = 0;
    return 0;
  }
  h[id] = max(getheight(t[id].l)+1, getheight(t[id].r)+1);
  return h[id];
}

void gettype(int id) {
  if (t[id].p == -1) cout << "root" << endl;
  else if (t[id].l == -1 && t[id].r == -1) cout << "leaf" << endl;
  else cout << "internal node" << endl;
}

int main() {
  int n, id, l, r;
  cin >> n;
  rep(i, n) {
    cin >> id >> l >> r;
    t[id].l = l;
    t[id].r = r;
    if (l != -1) t[l].p = id;
    if (r != -1) t[r].p = id;
    h[id] = -1;
  }

  rep(i, n) {
    cout << "node " << i << ": ";
    cout << "parent = " << t[i].p << ", ";
    cout << "sibling = " << getsibling(i) << ", ";
    cout << "degree = " << getdegree(i) << ", ";
    cout << "depth = " << getdepth(i) << ", ";
    cout << "height = " << getheight(i) << ", ";
    gettype(i);
  }

  
  return 0;
}


Measured memory_bytes: 3124
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        System.out.println(c >= a && c <= b ? "Yes" : "No");
    }
}

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

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  
  	sort(a.rbegin(), a.rend()); //降順
  	ll ans = 0;
  	int t = n-1;
  	rep(i, n){
    	int lim = 2;
      	if(i == 0) lim = 1;
      	rep(j, lim){
        	if(t > 0){
            	ans += a[i];
              	t--;
            }
        }
    }
  	
  	cout << ans << endl;
}

Measured memory_bytes: 4056