akhauriyash/Code-Regression huggingface dataset:
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  [n, k] <- readInt
  l      <- readInt
  let l' = sortOn Down l in print $ sum $ take k l'


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <string>

int main() {
	long N, K, R, S, P;
	std::cin >> N >> K >> R >> S >> P;
	std::string s;
	std::cin >> s;
	long sum = 0L;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'r') {
			if (i >= K && s[i] == s[i - K]) {
				s[i] = 'a';
			}
			else {
				sum += P;
			}
		}
		else if (s[i] == 's') {
			if (i >= K && s[i] == s[i - K]) {
				s[i] = 'a';
			}
			else {
				sum += R;
			}
		}
		else {
			if (i >= K && s[i] == s[i - K]) {
				s[i] = 'a';
			}
			else {
				sum += S;
			}
		}
	}
	std::cout << sum << std::endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int n, m;
  cin >> n >> m;
  int a, b, ans[n] = {};
  rep(i, m)
  {
    cin >> a >> b;
    ans[a - 1]++;
    ans[b - 1]++;
  }
  rep(i, n)
  {
    c(ans[i]);
  }
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }

const string YES = "Yes";
const string NO = "No";



// ***************************************

int main(){

    string S;
    cin >> S;
    for(auto& s: S){
        if (s == '7'){
            cout << YES << endl;
            return 0;
        }
    }

    cout << NO << endl;

    return 0;
}


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

const int N = 1005;
int n, id[N][N], par[N*N], q[N*N], l, r, cnt;
vector<int> ke[N * N];

void add(int u,int v)
{
    //cout << u <<' ' << v << endl;
    ke[u].push_back(v);
    par[v] += 1;
}
int main()
{
    //freopen("a.inp","r",stdin);

    scanf("%d",&n);
    for(int i=1; i<=n; ++i) for(int j=1; j<=n; ++j) id[i][j] = (i<j ? ++cnt : id[j][i]);
    for(int i=1; i<=n; ++i) {
        int a, b;
        scanf("%d",&a);
        for(int j=2; j<n; ++j, a=b) {
            scanf("%d",&b);
            add(id[i][a], id[i][b]);
        }
    }

    l = 1; r = 0;
    for(int i=1; i<=cnt; ++i) if (par[i] == 0) q[++r] = i;
    int step = 0, rr; do{
        step += 1; rr = r;
        while (l <= rr) {
            int u = q[l++];
            for(int v: ke[u])
                if (--par[v] == 0)
                    q[++r] = v;
        }
    } while (l<=r);
    if (r != cnt) step = -1;
    cout << step;
}


Measured memory_bytes: 51328
from collections import deque
h,w = map(int,input().split())
S = [list(input()) for _ in range(h)]
cost = [[-1]*w for _ in range(h)]


sy,sx = 0,0
gy,gx = h-1, w-1
que = deque([(sy,sx,0)])

flg = False
ret = -1
while que:
    y,x,c = que.popleft()
    if y==gy and x==gx:
        flg = True
        ret = c
        break
    if cost[y][x] != -1:
        continue
    cost[y][x] = c
    for dy,dx in zip((-1, 1, 0, 0), (0, 0, -1, 1)):
        ny = y + dy
        nx = x + dx
        if 0<=ny<h and 0<=nx<w:
            if S[ny][nx]!='#':
                que.append((ny,nx,c+1))
if not flg:
    print(-1)
else:
    blk, wht = 0, 0
    for s in S:
        for ss in s:
            if ss=='#':
                blk += 1
            else:
                wht += 1
    print(h*w-ret-1-blk)

Measured memory_bytes: 40688
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    set<char> st;
    rall(c, s) {
        st.insert(c);
    }
    cout << (st.size() > 1 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
signed main(){
	int a,b,sum=0,sumsum=0;
	cin>>a;
	f(i,a){
		cin>>b;
		sumsum=max(sumsum,b);
		sum+=b;
	}
	cout<<sum-sumsum/2<<endl;
	return 0;
}


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


int main() {
  map<string,int> mp;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
      string s;
      cin >> s;
      mp[s]++;
  }
  int m;
  cin >> m;
  for(int i=0;i<m;i++){
      string t;
      cin >> t;
      mp[t]--;
  }
  int max1 = 0;
  for(const auto& value:mp){
      max1 = max(value.second,max1);
  }
  cout << max1 << endl;
}

Measured memory_bytes: 256
import sys

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b // gcd(a,b)

N = int(input())
if(N==1):
    print(int(input()))
    sys.exit()

T=[]
T.append(int(input()))

for i in range(N-1):
    T.append(int(input()))
    T[i+1]=lcm(T[i+1],T[i])
print(T[N-1])



Measured memory_bytes: 3064
N=int(input())
A=[int(input()) for i in range(N)]
P=0
B=sorted(list(set(A)))
C=0
E=dict()
for i in range(N):
  E[B[i]]=E.get(B[i],0)+1
D=dict()
for i in range(N):
  if E[B[i]]&1:
    D[B[i]]=C
    C+=1
  else:
    D[B[i]]=-1
for i in range(N):
  if (i&1)!=(D[A[i]]&1) and D[A[i]]!=-1:
    P+=1
print(P>>1)

Measured memory_bytes: 128780
# ABC067C - Splitting Pile
def main():
    n = int(input())
    lst = tuple(map(int, input().rstrip().split()))
    cur, total, ans = 0, sum(lst), float("inf")
    for i in lst[:-1]:
        cur += i
        ans = min(ans, abs(total - cur * 2))
    print(ans)


if __name__ == "__main__":
    main()

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,D[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll tot=0;
	ll ret=0;
	FOR(i,N) {
		cin>>D[i];
		ret+=D[i]*tot;
		tot+=D[i];
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        int p = 0;
        String all[] = new String[h * w];
        for (int i = 1; i <= n; i++) {
            int a = sc.nextInt();
            for (int j = 0; j < a; j++) {
                all[p++] = "" + i;
            }
        }

        p = 0;
        for (int i = 0; i < h; i++) {
            String c[] = new String[w];
            if (i % 2 == 0) {
                for (int j = 0; j < w; j++) {
                    c[j] = all[p++];
                }
            } else {
                for (int j = w - 1; j >= 0; j--) {
                    c[j] = all[p++];
                }
            }

            System.out.println(String.join(" ", c));
        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 31804
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.WebSockets;

class Test
{

    // Driver code 
    public static void Main()
    {
        ///var t = int.Parse(Console.ReadLine());

        //while (t > 0)
        {
          //  t--;

            //var ii = Console.ReadLine().Split(' ').Where(xx => !string.IsNullOrEmpty(xx)).Select(xx => int.Parse(xx)).ToArray();

           // var n = ii[0];
           // var x = ii[1];
           // var tt = ii[2];

            // var arr = Console.ReadLine().Split(' ').Where(x => !string.IsNullOrEmpty(x)).Select(xx => int.Parse(xx)).ToList();
            var str = Console.ReadLine();
            int sum = 0;

            for(int i=0;i<str.Length;i++)
            {
                sum = sum + (str[i] - '0');
            }
            if (sum % 9 == 0)
                Console.Write("Yes");
            else
                Console.Write("No");
            Console.WriteLine();
        }
    }

}




Measured memory_bytes: 17180
import java.util.*;

public class Main {
  static int h;
  static int w;
  static int[][] canvas;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    h = Integer.parseInt(sc.next());
    w = Integer.parseInt(sc.next());
    String str = "";
    canvas = new int[h][w];
    for(int i = 0; i < h; i++) {
      str = sc.next();
      for(int j = 0; j < w; j++) {
        canvas[i][j] = (str.charAt(j) == '#')? 1 : 0;
      }
    }
    boolean flag = true;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        if(canvas[i][j] == 1) {
          flag &= check(i, j);
        }
      }
      if(!flag) break;
    }
    System.out.println((flag)? "Yes" : "No");
  }

  static boolean check(int x, int y) {
    boolean flag = false;
    if(0 < x && canvas[x-1][y] == 1) flag |= true;
    if(x < h - 1 && canvas[x+1][y] == 1) flag |= true;
    if(0 < y && canvas[x][y-1] == 1) flag |= true;
    if(y < w - 1 && canvas[x][y+1] == 1) flag |= true;
    return flag;
  }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int compare_str(const void *a,const void *b)
{
	return strcmp((char*)a,(char*)b);
}

int main()
{
	int n,l,i,j;
	char s[101][101],t[101];

	scanf("%d%d",&n,&l);
	for(i=0;i<n;i++)
		scanf("%s",s[i]);
	
	qsort((void*)s,n,sizeof(s[0]),compare_str);
	for(i=0;i<n;i++)
		printf("%s",s[i]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N;
  cin>>N;
  if(N>999)
  {
    cout<<"ABD"<<endl;
  }
  else
  {
    cout<<"ABC"<<endl;
  }
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
import re
S = input()


if S[0] != "A":
    print("WA")
    exit()

S_3_end2 = S[2:-1]
if S_3_end2.count("C") != 1:
    print("WA")
    exit()

if len(re.findall("[A-Z]", S)) != 2:
    print("WA")
    exit()

print("AC")


Measured memory_bytes: 3188
<?php
$s = str();
for($i = 0; $i < 2**3;$i++){
    $sum = $s[0];
    $flags = sprintf("%03b", $i);
    $num = 0;
    for($j = 0; $j < 3; $j++){
        if($flags[$j]=="0"){
            $sum+=$s[$j+1];
        }else{
            $sum-=$s[$j+1];
        }
    }
    if($sum==7){
        echo $s[0];
        for($i = 0 ; $i < 3; $i++){
            echo $flags[$i] == 0 ? "+" : "-";
            echo $s[$i+1];
        }
        echo "=7\n";
        exit;
    }
}

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 4604
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  GVI(a, N);
  GVI(b, N);
  ll win = 0, lose = 0;
  FOR(i, N) {
    ll diff = a[i] - b[i];
    if (diff < 0) {
      lose += -diff / 2;
    } else if (diff > 0) {
      win += diff;
    }
  }
  print(lose >= win ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
ll inf=1e18;
string s;
ll K;
P dp[2000][2001][2];
int N;
void change(P& x,P y){
	y.fs+=2;
	if(x.fs>y.fs) x=y;
	else if(x.fs==y.fs) x.sc+=y.sc,chmin(x.sc,inf);
}
int main(){
	cin>>s>>K;
	N=s.size();
	rep(i,N) rep(j,N+1) rep(k,2) dp[i][j][k]=P(1e9,0);
	rep(i,N) dp[i][i][0]=P(0,1);
	rep(i,N) dp[i][i+1][1]=P(1,1);
	for(int d=2;d<=N;d++){
		rep(l,N+1-d) rep(e,2){
			int r=l+d;
			if(s[l]==s[r-1]){
				change(dp[l][r][e],dp[l+1][r-1][e]);
			}else{
				change(dp[l][r][e],dp[l][r-1][e]);
				change(dp[l][r][e],dp[l+1][r][e]);
			}
		}
	}
	int e=1;
	if(dp[0][N][0].fs<dp[0][N][1].fs) e=0;
	int l=0,r=N,len=dp[0][N][e].fs;
	if(dp[0][N][e].sc<K){
		puts("NONE");
		return 0;
	}
	string ans(len,'?');
	int i=0;
	while(true){
		if(r-l==1){
			ans[i++]=s[l];
			break;
		}
		if(r==l) break;
		len-=2;
		if(s[l]==s[r-1]){
			ans[i++]=s[l];
			l++,r--;
			continue;
		}else if(s[l]<s[r-1]){
			if(dp[l+1][r][e].fs==len){
				if(dp[l+1][r][e].sc>=K){
					ans[i++]=s[l];
					l++;
					continue;
				}else{
					ans[i++]=s[r-1];
					K-=dp[l+1][r][e].sc;
					r--;
					continue;
				}
			}else{
				ans[i++]=s[r-1];
				r--;
			}
		}else{
			if(dp[l][r-1][e].fs==len){
				if(dp[l][r-1][e].sc>=K){
					ans[i++]=s[r-1];
					r--;
					continue;
				}else{
					ans[i++]=s[l];
					K-=dp[l][r-1][e].sc;
					l++;
					continue;
				}
			}else{
				ans[i++]=s[l];
				l++;
			}
		}
	}
	int L=ans.size();
	rep(i,L) ans[L-1-i]=ans[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 128220
import sys
import numpy as np
input = sys.stdin.readline
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = np.zeros(n, dtype=int)
h = np.array(h)
for i in range(1, n):
    start = max(0, i-k)
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))
print(dp[n-1])

Measured memory_bytes: 23052
N = input()
s = input()
s1 = s
s2 = ''
while s1 != s2: 
    s2 = s1
    s1 = s1.replace('()','')
s2 = s1.replace('(','')

print(len(s2)*'(' + s + (len(s1)-len(s2))*')')


Measured memory_bytes: 2940
import math
import bisect
N, M = map(int, input().split())
rootM = math.sqrt(M)

factors = set()
for i in range(1, math.ceil(rootM)+1):
  if M % i == 0:
    factors.add(i)
    factors.add(M // i)
factarr = sorted(list(factors))
print(M // factarr[bisect.bisect_left(factarr, N)])

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

int main() {
  string s, t;
  cin >> s >> t;
  bool flag = false;
  for (int i = 0; i < s.size(); i++)
  {
    if (s == t) flag = true;
    s = s.back() + s.substr(0, s.size() - 1);
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
   
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int K;
string s;
set<string> st;
int main() {
	cin >> s >> K;
	int n = s.length();
	for(int i=0; i<n; i++) {
		for(int j=1; j<=K; j++) {
			string sub = s.substr(i, j);
			st.insert(sub);
		}
	}
	auto it = st.begin();
	while(--K) {
		it++;
	}
	cout << *it;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
  
#define fo(i, n) for (long long i = 0; i < n; i++)
#define sc(x) cin >> x
#define pr(x) cout << x << endl;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define br cout << endl
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
lli max(lli a, lli b){ return (a>b)?a:b; }
lli min(lli a, lli b){ return (a<b)?a:b; }

lli gcd(lli a, lli b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


lli n;
int a[100005], b[100005], c[100005];

int main()
{
    // Fast Input/Output
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // Test Cases
    int t = 1;
//    cin >> t;

    while (t--) {
        sc(n);
        int dp[n+1][3];
        dp[0][0] = dp[0][1] = dp[0][2] = 0;
        for(int i=1; i<=n; i++)
        {
            cin >> a[i] >> b[i] >> c[i];
            dp[i][0] = dp[i][1] = dp[i][2] = 0;
        }
        
        for(int i=1; i<=n; i++)
        {
            dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
            dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
            dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);
        }
        
        pr(max({dp[n][0], dp[n][1], dp[n][2]}));
    }
    return 0;
}







Measured memory_bytes: 5984
k, n = [0] * 2
a = []

def format_input(filename = None):
	global k, n
	global a
	if filename == None:
		k, n = list(map(int, input().split()))
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		from random import sample
		k = rng(2, 10**6)
		n = rng(2, 2 * 10**5)
		a = sample(range(k), n)
		a.sort()
		print(k, n)
		print(' '.join(list(map(str, a))))

def get_answer():
	deff_a = [a[i] - a[i-1] for i in range(1, n)]
	answer = k - max(max(deff_a), k - a[-1] + a[0])
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 26444
n = int(input())
s = list(input())

l = [0]*(n+1)
r = [0]*(n+1)

for i in range(1, n):
    l[i] += l[i-1]
    if s[i-1] == "W":
        l[i] += 1

for i in range(n-1, -1, -1):
    r[i] += r[i+1]
    if s[i] == "W":
        r[i] += 1
        
ans = 1001001001

for i in range(n):
    ans = min(ans, l[i]+(n-i-1-r[i+1]))
    
print(ans)

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

using ll = long long;

constexpr ll INF = 1e18;

int main() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    sort(begin(v), end(v));
    vector<ll> sum_value(N + 1);
    for(int i = 0; i < N; ++i) {
        sum_value[i + 1] = sum_value[i] + v[i].second;
    }
    ll min_left = INF;
    ll ans = 0;
    for(int i = 0; i < N; ++i) {
        min_left = min(min_left, sum_value[i] - v[i].first);
        ans = max(ans, sum_value[i + 1] - v[i].first - min_left);
    }
    cout << ans << endl;
}



Measured memory_bytes: 14456
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;




int main() {
	set<int> s;
	int n, k,count=0,a;
	cin >> n >> k;
	int b[200001] = { 0 };
	
	for (int i = 0; i < n; i++) {
		cin >> a;
		b[a]++;
		s.insert(a);
	}
	if (s.size() <= k) cout << "0" << endl;
	else {
		sort(b, b+200001);
		int index = lower_bound(b, b+200001, 1)- b;
		for (int i = index; i < index + s.size() - k; i++) count += b[i];
		cout << count << endl;
	}

	return 0;
}


Measured memory_bytes: 10368
def main():
    N, X = map(int, input().split())
    L = list(map(int, input().split()))
    D = 0

    for cnt in range(2, N + 2):
        D += L[cnt - 2]
        if D > X:
            cnt -= 1
            break

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61928
A=input()
if A[0]==A[1]==A[2]==A[3]:
  print("No")
elif (A[0]==A[1] and A[2]==A[3]) or (A[1]==A[2] and A[0]==A[3]) or (A[0]==A[2] and A[1]==A[3]):
  print("Yes")

else:
  print("No")


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

const int MOD = INF+7;
ll dp[105][10];
int main(){
    int h,w,k;cin>>h>>w>>k;
    k--;
    dp[0][0] = 1;
    rep(i,h){
        for(int bit = 0;bit < (1<<w-1);bit++){
            vector<int>S = bitSearch(bit,w-1);
            S.push_back(INF);
            const int len = S.size();
            bool flag = true;
            rep(l,len-1){
                if(S[l+1] == S[l]+1)flag = false;
            }
            if(!flag)continue;
            if(S.empty()){
                rep(jj,w){
                    dp[i+1][jj] = (dp[i+1][jj]+dp[i][jj])%MOD;
                    //dp[i+1][j] %= MOD;
                }
            }
            else {
                rep(j,w){
                    if(j == *lower_bound(ALL(S),j)){                
                        dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j])%MOD;
                        dp[i+1][j] = (dp[i+1][j]+dp[i][j+1])%MOD;
                        j++;
                        if(j >= w)continue;
                    }
                    else{
                        dp[i+1][j] = (dp[i+1][j]+dp[i][j])%MOD;
                        //dp[i+1][j] %= MOD;
                    }
                }
            }
        }
    }
    //rep(i,h+1){rep(j,w)cout<<dp[i][j]<<" ";cout<<endl;}
    cout<<dp[h][k]<<endl;;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	a--;b--;c--;d--;
	string s;cin>>s;
	bool ans=true;
	s[n]='#';
	for(ll i=b;i<=d;i++){
		if(s[i]=='#'&&s[i+1]=='#'){
			ans=false;
			break;
		}
	}
	for(ll i=a;i<=c;i++){
		if(s[i]=='#'&&s[i+1]=='#'){
			ans=false;
			break;
		}

	}
	if(c>d){
		ans = false;
		for(ll i=b;i<=d;i++){
			if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
				ans=true;
			}
		}
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n, m, x, y;cin>>n>>m>>x>>y;
  int max_a=-INF, min_b=INF;
  for(int i=0;i<n;i++){int a;cin>>a;max_a=max(max_a, a);}
  for(int i=0;i<n;i++){int b;cin>>b;min_b=min(min_b, b);}
  cout<<(((x<y&&max_a<min_b)&&(max_a<y&&x<min_b))?"No War":"War")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372037ll;
int n;
string s;
set<string> S;
void solve()
  {
   cin>>n;
   loop(i,0,n)
    {
      cin>>s;
      S.insert(s);
    }
  cout<<(int)S.size()<<END;

  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 19156
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF INT_MAX>>1 //要climits#includ

typedef long long ll;

using namespace std;

int main(void){
	int x, a; cin >> x >> a;
	if(x < a) cout << 0 << endl;
	else cout << 10 << endl;


	return 0;
}

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

int main(){
  string s;
  cin >> s;
  //string t;
  int x=0;
  x=s.length()-3;
  //cout << s.length() << endl;
  if(s.length()==3)
    cout << s << endl;
  else{
    for(int i=0; i<x; i++)
      s.pop_back();
    cout << s << endl;
  }
  /*t[0] = s[0];
  t[1] = s[1];
  t[2] = s[2];
  cout << s << endl;
  cout << t << endl;*/
  
}

Measured memory_bytes: 3588
#include <iostream>

#define SIZE 4

using namespace std;

int main() {
	int a[SIZE], b[SIZE], hit, blo;

	while (cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]) {
		hit = 0;
		blo = 0;
		for (int i = 0; i < SIZE; i++) {
			if (a[i] == b[i]) {
				hit++;
				a[i] = -1;
				b[i] = -1;
			}
		}

		for (int i = 0; i < SIZE; i++) {
			for (int j = 0; j < SIZE; j++) {
				if (a[i] == -1 || b[j] == -1) {
					continue;
				}

				if (a[i] == b[j]) {
					a[i] = -1;
					b[j] = -1;
					blo++;
				}
			}
		}
		cout << hit << " " << blo << endl;
	}

	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

int main() {
  ll N;
  cin >> N;


  vector<ll> x(N);
  rep(i, N) {
    cin >> x[i];
  }

  vector<mint> k(N - 1);
  k[0] = 1;
  repp(i, 1, N - 1) {
    k[0] *= i;
  }

  rep(i, N - 2) {
    k[i + 1] = k[i] + k[0] / (i + 2);
  }

  mint ans = 0;
  rep(i, N - 1) {
    ans += k[i] * (x[i + 1] - x[i]);
  }

  cout << ans.x << endl;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	cout<<n/3<<endl;
	return 0;
}

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

using namespace std;

const int INF = 1 << 30;

int N;
vector< int > g[100000];
bool v[100000][30];

int dfs(int idx, int par) {
  int ret = 0;
  vector< int > d(30);
  for(auto &to : g[idx]) {
    if(to != par) {
      ret = max(ret, dfs(to, idx));
      for(int i = 0; i < 30; i++) d[i] += v[to][i];
    }
  }
  int low = 0;
  for(int i = 29; i >= 0; i--) {
    if(d[i] >= 2) {
      low = i + 1;
      break;
    }
  }
  for(int i = low; i <= 30; i++) {
    if(i == 30) {
      throw 0;
    }
    bool correct = true;
    for(auto &to : g[idx]) {
      if(to != par) {
        if(v[to][i]) correct = false;
      }
    }
    if(correct) {
      //cout << idx+1 << " " << low << " " << i+1 << endl;
      ret = max(ret, i);
      v[idx][i] = true;
      for(auto &to : g[idx]) {
        if(to != par) {
          for(int j = i + 1; j < 30; j++) {
            v[idx][j] |= v[to][j];
          }
        }
      }
      break;
    }
  }
  return ret;
}

int main() {
  cin >> N;
  for(int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  cout << dfs(0, -1) << endl;
}


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

using namespace std;

int main()
{
    int a, n;
    cin >> n;
    a = n % 10;
    if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9)
        cout << "hon" << endl;
    else if (a == 0 || a == 1 || a == 6 || a == 8)
        cout << "pon" << endl;
    else
        cout << "bon" << endl;
    return 0;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int N,Z,W;
vector<vector<int>> dp(2010, vector<int>(2,-1));
vector<int> A;

int dfs(int pos, int t){
    if(dp[pos][t] != -1) return dp[pos][t];

    int ret;
    if(t==0) ret = 0;//先手なら最大化のため最小値
    else ret = INF;//後手なら最小化のため最大値

    FOR(i,pos+1,N+2){//前の人は必ずposを選んでいる
        int tmp;
        if(i==N+1) tmp = abs(A[pos] - A[N+1]);//最後を選ぶ場合
        else tmp = dfs(i,1-t);//そうでなければA[i]を選び、手番交代

        if(t==0) ret = max(ret,tmp);//先手なら最大値を
        else ret = min(ret,tmp);//後手なら最小値を
    }
    dp[pos][t] = ret;//計算結果はメモ
    return ret;
}

int main() {
    cin >> N >> Z >> W;
    A.assign(N+2,0);
    A[0] = Z;
    A[1] = W;
    FOR(i,2,N+2) cin >> A[i];

    


    cout << dfs(1,0) << endl;//後手がA[1] = Wを選択した場合なので初期条件と同じ
    //1個も取らないことはあり得ないので、先手が最初に持っていた値は実は無意味！！

    return 0;
}

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

ll pow2(ll r) {
    ll ans = 1, a = 2;
    while(r > 0) {
        if(r & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        r >>= 1;
    }
    return ans;
}

int main() {
    map<pair<ll,ll>,pair<ll,ll>> mp;
    int N;
    cin >> N;
    ll cnt = 0;
    rep(i, N) {
        ll A, B;
        cin >> A >> B;
        if(!A && !B) {
            cnt++;
        } else {
            ll g = __gcd(A,B);
            A /= g; B /= g;
            if(A < 0) { A = -A; B = -B; }
            if(B <= 0) mp[{-B,A}].second++;
            else mp[{A,B}].first++;
        }
    }

    ll ans = 1;
    for(auto p : mp) {
        ans = ans * ((pow2(p.second.first) + pow2(p.second.second) - 1 + MOD) % MOD) % MOD;
    }    
    cout << (ans + cnt - 1 + MOD) % MOD << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  long sum = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int k = 1; k <= n; ++k) {
        sum += gcd(gcd(i, j), k);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
    //mint(2).pow(n); 2^n
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



vector<vector<ll>> multmat(vector<vector<ll>> a, vector<vector<ll>> b,ll n){
  vector<vector<ll>> temp(n,vector<ll> (n,0));
  rep(i,n)rep(j,n)rep(k,n){
    ll now=a[i][j]*b[j][k];
    now%=mod;
    temp[i][k]+=now;
    temp[i][k]%=mod;
  }
  return temp;
}

int main() {
  ll n,k;
  cin>>n>>k;
vector <vector<ll>>  a(n,vector<ll>(n, ll(0)));
//a[n-1][n-1]=1;

rep(i,n)rep(j,n)cin>>a[i][j];
vector <vector<ll>>  p(n,vector<ll>(n, ll(0)));
rep(i,n)p[i][i]=1;

while(k){
  if (k%2==1)p=multmat(p,a,n);
k/=2;
    a=multmat(a,a,n);

  }

ll ans=0;
rep(i,n)rep(j,n){
  ans+=p[i][j];
  ans%=mod;
}
cout<<ans;

}


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

using namespace std;
typedef long long ll;

int main() {
  ll A; cin >> A;
  ll B; cin >> B;
  ll x = max(A, B);
  if (x == A) {
    A--;
  } else {
    B--;
  }
  x += max(A, B);
  cout << x << endl;
  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    if(a <= 8 and b <= 8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int a, b;
    cin >> a >> b;

    cout << (a % 2 && b % 2 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long q,a,b,i,s,t;
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d %d",&a,&b);
		s=a*b;
		t=(int)sqrt(s);
		if(t*t==s)
		{
			if(a==b)
			{
				printf("%lld\n",(a-1)*2);
			}
			else
			{
				printf("%lld\n",(t-1)*2-1);
			}
		}
		else
		{
			if(s<=t*(t+1))
			{
				printf("%lld\n",t*2-1-1);
			}
			else
			{
				printf("%lld\n",t*2-1);
			}
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll ret = B-A+1;
  ll cfirst = A%C==0 ? A : A+(C-A%C);
  ll dfirst = A%D==0 ? A : A+(D-A%D);
  ll diff = 0;
  if (B>=cfirst)
    ret -= (B-cfirst)/C+1;
  if (B>=dfirst) {
    ll a = (B - dfirst) / D + 1;
    if(ret<a) {
      diff = a-ret;
      ret = 0;
    }else
      ret -= a;
  }
  ll lcm =  C*D/__gcd(C,D);
  ll lcmfirst = A%lcm==0 ? A : A+(lcm-A%lcm);
  if (B>=lcmfirst)
    ret += (B-lcmfirst)/lcm+1;
  ret -= diff;
  cout << ret << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a + b >= c) { 
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
function Main (input) {
    var rows  = input.split("\n")
    var num = rows[0]
    var same_count = 1
    var just_before_loaded = ""

    num.split("").map( function (c, index) {

        if (just_before_loaded == c) {
            same_count += 1
        } else {
            if (same_count < 3 ) same_count = 1
        }
        
        just_before_loaded = c
    })

    if (same_count >= 3 ) {
        console.log("Yes")
    } else {
        console.log("No")
    }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 21064
def NextEnforcement(enfo1,enfo2):
    if(enfo1 == "AB") and (enfo2 == "AC"):
        return "1"
    elif (enfo1 == "AB") and (enfo2 == "BC"):
        return "2"
    elif (enfo1 == "BC") and (enfo2 == "AC"):
        return "2"
    elif (enfo1 == "BC") and (enfo2 == "AB"):
        return "1"
    elif (enfo1 == "AC") and (enfo2 == "AB"):
        return "1"
    elif (enfo1 == "AC") and (enfo2 == "BC"):
        return "2"
    else:
        return "0"


def Calculation(num1,num2,nextInfo):
    if num1 == num2 == 0:
        print("No")
        exit()
    elif num1 == 0:
        num1 += 1
        num2 -= 1
    elif num2 == 0:
        num1 -= 1
        num2 += 1
    elif nextInfo == "0":
        if num1 > num2:
            num1 -= 1
            num2 += 1
        elif num1 <= num2:
            num1 += 1
            num2 -= 1
    elif nextInfo == "1":
        num1 += 1
        num2 -= 1
    elif nextInfo == "2":
        num1 -= 1
        num2 += 1

    return num1,num2


n,a,b,c = map(int, input().split())

enforcement = ["NULL"]*n

for i in range(n):
    enforcement[i] = input()

ans = ["NULL"]*n

for i in range(n):
    tmpA = a
    tmpB = b
    tmpC = c
    if i != n-1:
        nextInfo = NextEnforcement(enforcement[i], enforcement[i + 1])
    else:
        nextInfo = "0"

    if enforcement[i] == "AC":
        a,c = Calculation(a,c,nextInfo)
        if tmpA < a :
            ans[i] = "A"
        else:
            ans[i] = "C"
    if enforcement[i] == "AB":
        a,b = Calculation(a,b,nextInfo)
        if tmpA < a :
            ans[i] = "A"
        else:
            ans[i] = "B"
    if enforcement[i] == "BC":
        b,c = Calculation(b,c,nextInfo)
        if tmpB < b :
            ans[i] = "B"
        else:
            ans[i] = "C"

print("Yes")

for i in range(n):
    print(ans[i])

Measured memory_bytes: 17044
#include <iostream>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>

int main(int argc, char* argv[])
{
  int n, m;
  std::map< int, int > path;
  std::cin >> n >> m;

  std::string judge = "IMPOSSIBLE";
  for (int i = 0; i < m; i++) {
    int a, b;
    std::cin >> a >> b;
    if (a == 1) {
      if (path.find(b) == path.end()) {
	path.insert(std::make_pair(b, 0x01));
      } else {
	path[b] |= 0x01;
      }
    }
    if (b == n) {
      if (path.find(a) == path.end()) {
	path.insert(std::make_pair(a, 0x02));
      } else {
	path[a] |= 0x02;
      }
    }
  }

  std::map< int, int >::iterator it;
  for (it = path.begin(); it != path.end(); it++) {
    //std::cout << "*" << it->first << " " << it->second << std::endl;
    if (path[it->first] == 0x03) {
      judge = "POSSIBLE";
    }
  }

  std::cout << judge << std::endl;
  return 0;
}



Measured memory_bytes: 9600