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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX_LIMIT 1100
#define MAX 110

using namespace std;

int pre[MAX_LIMIT][3],pre2[MAX_LIMIT][MAX],LIMIT,N,M,X,SEC_E[MAX],SEC_S[MAX],E[MAX],S[MAX];
string tmp;


int main(){
  while(cin >> LIMIT >> N >> M >> X, LIMIT|N|M|X){
    rep(i,N)cin >> tmp >> SEC_E[i] >> SEC_S[i];
    rep(i,M)cin >> tmp >> E[i] >> S[i];
    rep(i,MAX_LIMIT)rep(j,3)pre[i][j] = -1;
    rep(i,MAX_LIMIT)rep(j,MAX)pre2[i][j] = -1;
    pre[0][0] = pre2[0][0] = 0;

    rep(i,N)for(int j=1;j>=0;j--){
      rep(k,LIMIT+1){
	if( pre[k][j] == -1 ) continue;
	int total_money = k + SEC_E[i];
	if( total_money > LIMIT ) continue;
	pre[total_money][j+1] = max(pre[total_money][j+1],pre[k][j]+SEC_S[i]);
      }
      rep(k,LIMIT+1)if( k ) pre[k][j+1] = max(pre[k][j+1],pre[k-1][j+1]);
    }

    rep(i,3)rep(j,LIMIT+1)if( j ) pre[j][i] = max(pre[j][i],pre[j-1][i]);

    rep(i,M)for(int j=M-1;j>=0;j--){
      rep(k,LIMIT+1){
	if( pre2[k][j] == -1 ) continue;
	int total_money = k + E[i];
	if( total_money > LIMIT ) continue;
	pre2[total_money][j+1] = max(pre2[total_money][j+1],pre2[k][j]+S[i]);
      }
      rep(k,LIMIT+1)if( k ) pre2[k][j+1] = max(pre2[k][j+1],pre2[k-1][j+1]);
    }

    rep(i,M+1)rep(j,LIMIT+1)if( j ) pre2[j][i] = max(pre2[j][i],pre2[j-1][i]);

    int ans = 0;

    REP(i,X,M+1)REP(j,1,3)rep(k,LIMIT+1){
      if( pre2[k][i] == -1 || pre[LIMIT-k][j] == -1 ) continue;
      int points = pre2[k][i] + pre[LIMIT-k][j];
      ans = max(ans,points);
    }

    cout << ans << endl;

  }
  return 0;
}

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

#define mp make_pair
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FOD(i, a, b) for(int i = a; i >= b; i--)

using namespace std;

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

const int N = 1e5 + 10;

int n, m, res[N], deg[N];
vector <int> adj[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    FOR(i, 1, m + n - 1){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        deg[v]++;
    }
    int root = 0;
    FOR(i, 1, n)
        if (deg[i] == 0)
            root = i;
    queue <int> Q;
    Q.push(root);
    while (!Q.empty()){
        int u = Q.front();
        Q.pop();
        for(int v : adj[u])
            if (--deg[v] == 0){
                Q.push(v);
                res[v] = u;
            }
    }
    FOR(i, 1, n)
        cout << res[i] << endl;
}


Measured memory_bytes: 7040
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            var splited = Console.ReadLine().Split(" ")
                                            .Select(s => int.Parse(s))
                                            .ToList();
            var (a, b) = (splited[0], splited[1]);
            Console.Write(a * b);
        }
    }
}


Measured memory_bytes: 28316
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

Node * treeMinimum(Node *x) {
    while (x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u,int k){
    while(u != NIL && k != u->key){
        if( k < u->key ) u= u->left;
        else u = u->right;
    }
    return u;
}



Node * treeSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y!=NIL && x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}

Node * treeDelete(Node *z){
    Node *y;
    Node *x;

    if( z->left == NIL || z->right ==NIL) y=z;
    else y=treeSuccessor(z);

    if(y->left != NIL) x=y->left;
    else x= y->right;


    if(x!=NIL) x->parent = y->parent;

    if(y->parent ==NIL) root=x;
    else {
        if (y == y->parent->left) y->parent->left = x;
        else y->parent->right = x;
    }
    if(y!=z) z->key = y->key;
    free(y);
}



void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while( x!=NIL) {
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }

    z->parent = y;
    if( y==NIL ) root = z;
    else if (z->key < y->key) y->left = z;
    else y->right = z;


}


void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
    int n,i,x;
    string com;

    scanf("%d",&n);

    for(i=0; i<n; i++){
        cin >> com;
        if(com[0]=='f'){
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        }else if(com == "insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }else if( com=="delete"){
            scanf("%d",&x);
            treeDelete(find(root,x));
        }
    }
    return 0;
}











Measured memory_bytes: 21996
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

void coch(double sx,double sy,double tx,double ty,int i,int n){
	if(i == n){
		return;
	}else{
		double xx = (tx-sx) / 3.0;	double yy = (ty-sy) / 3.0;
		double a = sqrt(3.0) * xx / 2.0;	double b = xx / 2.0;
		double c = sqrt(3.0) * yy / 2.0;	double d = yy / 2.0;
		coch(sx,sy,sx+xx,sy+yy,i+1,n);
		printf("%.8lf %.8lf\n",sx+xx,sy+yy);
		coch(sx+xx,sy+yy,sx+xx + b - c,sy + yy + a + d,i+1,n);
		printf("%.8lf %.8lf\n",sx+xx + b - c,sy+yy + a + d);
		coch(sx+xx + b - c,sy +yy + a + d,sx + 2.0*xx ,sy + 2.0*yy,i+1,n);
		printf("%.8lf %.8lf\n",sx + 2.0*xx ,sy + 2.0*yy);
		coch(sx + 2.0*xx ,sy + 2.0*yy,tx,ty,i+1,n);
	}
}

int main()
{
	int n;
	cin >> n;
	printf("0.00000000 0.00000000\n");
	coch(0.0,0.0,100.0,0.0,0,n);
	printf("100.00000000 0.00000000\n");
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#pragma clang diagnostic ignored "-Wcomma"
#pragma clang diagnostic ignored "-Wpadded"
#pragma clang diagnostic ignored "-Wundef"
#pragma clang diagnostic ignored "-Wshadow"
#pragma clang diagnostic ignored "-Wglobal-constructors"
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic ignored "-Wweak-vtables"
#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
#pragma clang diagnostic ignored "-Wextra-semi"
#pragma clang diagnostic ignored "-Wswitch-enum"
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
#pragma clang diagnostic ignored "-Wdocumentation"
#pragma clang diagnostic ignored "-Wredundant-parens"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic warning "-Wreserved-id-macro"
#pragma clang diagnostic warning "-Wcomma"
#pragma clang diagnostic warning "-Wpadded"
#pragma clang diagnostic warning "-Wundef"
#pragma clang diagnostic warning "-Wshadow"
#pragma clang diagnostic warning "-Wglobal-constructors"
#pragma clang diagnostic warning "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic warning "-Wweak-vtables"
#pragma clang diagnostic warning "-Wdisabled-macro-expansion"
#pragma clang diagnostic warning "-Wextra-semi"
#pragma clang diagnostic warning "-Wswitch-enum"
#pragma clang diagnostic warning "-Wdeprecated-dynamic-exception-spec"
#pragma clang diagnostic warning "-Wexit-time-destructors"
#pragma clang diagnostic warning "-Wdocumentation-unknown-command"
#pragma clang diagnostic warning "-Wdocumentation"
#pragma clang diagnostic warning "-Wredundant-parens"

using namespace std;

int solve(int64_t n, int64_t t, std::vector<int64_t> hs) {
  int ret = 0;
  int64_t diff = INT64_MAX;
  for (int i = 0; i < n; ++i) {
    int64_t const average = abs(t - hs[i] * 6);
    if (average >= diff) {
      continue;
    }
    diff = average;
    ret = i + 1;
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  int64_t t;
  std::cin >> t;
  t *= 1000;
  int64_t a;
  std::cin >> a;
  a *= 1000;
  t -= a;
  std::vector<int64_t> hs(n);
  for (int i = 0; i < n; i++) {
    std::cin >> hs[i];
  }
  auto const res = solve(n, t, std::move(hs));
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int n,a,b;cin >> n >> a >>  b;
    cout << min(a,b) << ' ' << max(a+b-n,0) << endl;
    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  long long ans=1;
  if(abs(N-M)>1) ans=0;
  else if(N==M){
    for(int i=1; i<=N; i++){
      ans=ans*i%INF;
    }
    for(int i=1; i<=M; i++){
      ans=ans*i%INF;
    }
    ans=ans*2%INF;
  }
  else{
    for(int i=1; i<=N; i++){
      ans=ans*i%INF;
    }
    for(int i=1; i<=M; i++){
      ans=ans*i%INF;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0137

"""
import sys
from sys import stdin
input = stdin.readline


def solve(i, n):
    result = []
    while len(result) < 10:
        i = i ** 2
        i //= 100  #  n???4??\?????????????
        i %= 10**n
        result.append(i)
    return result


def main(args):
    n = 4
    d = int(input())
    for i in range(1, d+1):
        init_value = int(input())
        result = solve(init_value, n)
        print('Case {}:'.format(i))
        print('\n'.join(map(str, result)))


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7644
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// A - Something on It
int main(){
    char S[3];
    cin >> S;
    
    int ans=700;
    for(int i=0;i<=2;++i){
        if(S[i] == 'o') ans+= 100;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
import java.lang.Math.PI
import java.lang.Math.atan

fun main(args: Array<String>) {
    var (a,b,x) = readLine()!!.split(" ").map { it.toDouble() }
    var xHeight = x / (a * a)
    if (a * a * b / 2 > x){
        println(90 - atan(2 * a * xHeight / (b * b)) * 180 / PI)
    }else{
        println(90 - atan(a / (2 * (b - xHeight))) * 180 / PI )
    }
}

Measured memory_bytes: 37996
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
int main(){

    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<ctime>
const  int N = 3e5 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef long double lw;
#define  pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
int n;
int main()
{
	int x, a;
	int cnt = 1;
	int sum = 0;
	cin >> n >> x;
	fo(i, 0, n)
	{
		cin >> a;
		sum += a;
		if (sum <= x)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "5", "3 2 4 1 2" ].solve == 2 );
	assert( [ "10", "10 71 84 33 6 47 23 25 52 64" ].solve == 36 );
	assert( [ "7", "1 2 3 1000000000 4 5 6" ].solve == 999999994 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	auto ts = new long[ 1 + as.length ];
	foreach( i, a; as )
	{
		ts[ i + 1 ] = ts[ i ] + a;
	}
	
	auto ans = long.max;
	auto ps = [ 0L, 1L, 2L, 3L, as.length.signed ];
	for( ; ps[ 2 ] < as.length.signed - 1; ps[ 2 ]++ )
	{
		if( ps[ 3 ] <= ps[ 2 ] ) ps[ 3 ] = ps[ 2 ] + 1;
		
		auto p = ts[ ps[ 1 ] ] - ts[ ps[ 0 ] ];
		auto q = ts[ ps[ 2 ] ] - ts[ ps[ 1 ] ];
		while( ps[ 1 ] + 1 < ps[ 2 ] )
		{
			auto da = abs( p - q );
			auto db = abs( ( p + as[ ps[ 1 ] ] ) - ( q - as[ ps[ 1 ] ] ) );
			if( da < db ) break;
			p += as[ ps[ 1 ] ];
			q -= as[ ps[ 1 ] ];
			ps[ 1 ]++;
		}
		
		auto r = ts[ ps[ 3 ] ] - ts[ ps[ 2 ] ];
		auto s = ts[ ps[ 4 ] ] - ts[ ps[ 3 ] ];
		while( ps[ 3 ] + 1 < ps[ 4 ] )
		{
			auto da = abs( r - s );
			auto db = abs( ( r + as[ ps[ 3 ] ] ) - ( s - as[ ps[ 3 ] ] ) );
			if( da < db ) break;
			r += as[ ps[ 3 ] ];
			s -= as[ ps[ 3 ] ];
			ps[ 3 ]++;
		}
		
		auto ms = [ p, q, r, s ].reduce!( min, max );
		ans = min( ans, ms[ 1 ] - ms[ 0 ] );
	}
	return ans;
}


Measured memory_bytes: 14200
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

x1, y1, x2, y2 = map(int, input().rstrip().split())

mv_x = x2 - x1
mv_y = y2 - y1

x3, y3 = x2 - mv_y, y2 + mv_x
x4, y4 = x1 - mv_y, y1 + mv_x
	
print(x3, y3, x4, y4)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;

    if(n==1){
            cout<<1<<endl;
    }


    else {
        for(int i=1;i<=n;i++){
        if(i*i>n){
            cout<<(i-1)*(i-1)<<endl;
            break;
        }
        }

    }
}

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

int main(){
  string s;
  cin >> s;
  bool bad = false;
  rep(i, 3){
    if (s.at(i) == s.at(i + 1)) bad = true;
  }
  if (bad) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

Measured memory_bytes: 256
def solve2():
    H, W = [int(_) for _ in raw_input().split()]
    S = []
    for i in range(H):
        Si = [_ for _ in raw_input()]
        S.append(Si)
    L = [[0] * W for i in range(H)]
    R = [[0] * W for i in range(H)]
    D = [[0] * W for i in range(H)]
    U = [[0] * W for i in range(H)]
    # Left
    for i in range(H):
        if S[i][0] == '.':
            L[i][0] = 1
    for i in range(H):
        for j in range(1,W):
            if S[i][j] == '.':
                L[i][j] = L[i][j-1] + 1
            else:
                L[i][j] = 0
    # Right
    for i in range(H):
        if S[i][W-1] == '.':
            R[i][W-1] = 1
    for i in range(H):
        for j in range(W-2,-1,-1):
            if S[i][j] == '.':
                R[i][j] = R[i][j+1] + 1
            else:
                R[i][j] = 0
    # Down
    for j in range(W):
        if S[0][j] == '.':
            D[0][j] = 1
    for j in range(W):
        for i in range(1,H):
            if S[i][j] == '.':
                D[i][j] = D[i-1][j] + 1
            else:
                D[i][j] = 0
    # Up
    for j in range(W):
        if S[H-1][j] == '.':
            U[H-1][j] = 1
    for j in range(W):
        for i in range(H-2,-1,-1):
            if S[i][j] == '.':
                U[i][j] = U[i+1][j] + 1
            else:
                U[i][j] = 0
    ans = 1
    for i in range(H):
        for j in range(W):
            ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3)
    print ans

if __name__ == '__main__':
    solve2()


Measured memory_bytes: 318620
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        int inpt = int.Parse(Reader.ReadLine());

        long mod = 1000000000 + 7;

        long ans = 1;
        for(int i=2; i<=inpt; i++) {
            ans = ans*i;
            ans = ans % mod;
        }
        Console.WriteLine(ans);

    }


    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"



100000


";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}


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

int n;
vector<vector<int> > test;

bool isValid(int x) {
	for (int i = 0; i < n; i++) {
		int cur = x & (1 << i);
		if (cur) {
			for (int j = 0; j < n; j++) {
				if (test[i][j] != -1 && test[i][j] != (x & (1 << j)) >> j) {
					return false;
				}
			}
		}
	}
	return true;
}

int main() {
	int a, x, y;
	cin >> n;

	test = vector<vector<int> >(n, vector<int>(n, -1));
	for (int i = 0; i < n; i++) {
		cin >> a;
		for (int j = 0; j < a; j++) {
			cin >> x >> y;
			test[i][x - 1] = y;
		}
	}

	int mx = (1 << n) - 1;
	int res = 0, temp;
	for (int i = 1; i <= mx; i++) {
		if (isValid(i)) {
			temp = 0;
			int num = i;
			while (num) {
				temp += num & 1;
				num = num >> 1;
			}

			res = max(res, temp);
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
N,M,Q = map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q

for i in range(Q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -=1
    b[i] -=1
def score(A):
    tmp=0
    for ai,bi,ci,di in zip(a,b,c,d):
        if A[bi]-A[ai] == ci:
            tmp+=di
    return tmp
def dfs(A):
    if len(A) == N:
        return score(A)
    res = 0
    last = A[-1] if len(A)>0 else 0
    for i in range(last,M):
        A.append(i)
        res=max(res,dfs(A))
        A.pop()
    return res
print(dfs([]))      

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

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

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

Measured memory_bytes: 256
n = int(input())
s = int(input())
def sub(n, b):
  r = 0
  while n > 0:
    r += n%b
    n = n//b
  return r
if s > n:
  print(-1)
  exit()
if s == n:
  b = n+1
  print(b)
  exit()
for b in range(2, n+1):
  if b*b > n:
    break
  s2 = sub(n, b)
  if s2 == s:
    print(b)
    exit()
bs = []
for p in range(1, n+1):
  if p*p > n:
    break
  if (n-s)%p == 0:
    b = (n-s)//p+1
    bs.append(b)
bs.sort()
for b in bs:
  s2 = sub(n, b)
  if s2 == s:
    print(b)
    exit()
print(-1)


Measured memory_bytes: 3064
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0

int main () {
    ll n,k;
    cin>>n>>k;
    if(n*500<k)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    End;
}
/* pray for me
All is well
*/


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

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;
    return 0;

}

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

int main() {
  int n; cin >> n;
  int win[n];
  fill(win, win + n, 0);
  for(int i = 0; i < n*(n-1)/2; i++) {
    int a, b, c, d; cin >> a >> b >> c >> d;
    a--, b--;
    if(c > d) {
      win[a] += 3;
    }
    if(c == d) {
      win[a] += 1;
      win[b] += 1;
    }
    if(c < d) {
      win[b] += 3;
    }
  }
  for(int i = 0; i < n; i++) {
    int k = 0;
    for(int j = 0; j < n; j++) {
      if(win[j] > win[i]) k++;
    }
    cout << k + 1 << endl;
  }
}

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

ll gcd(int a,int b){
  return b ? gcd(b , a%b) : a; 
}
ll lcm(int a,int b){
  return a/gcd(a,b)*b;
}

int main(){
  int a, b;
  cin >> a >> b;
  if(a > b) swap(a,b);
  ll ans = lcm(a,b);
  cout << ans << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N; cin >> N;
	vi H(N);
	rep(i, N) cin >> H[i];
	bool ans = true, f = true;
	if (N > 1) {
		rep(i, N - 1) {
			if (H[i] - H[i+1] > 1) {
				ans = false;
			}
			else if (H[i] - H[i+1] == 1) {
				if (f) f = false;
				else ans = false;
			}
			else if (H[i] - H[i+1] < 0) {
				f = true;
			} 
		}
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

Measured memory_bytes: 1024
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A&lang=ja
//ALDS1_5_A
//Exhaustive Search
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main(){
    ll n; cin>>n;
    vector<ll> an(n);
    for(auto&& a:an){
        cin>>a;
    }
    ll q; cin>>q;
    vector<ll> mq(q);
    for(auto&& m:mq){
        cin>>m;
    }

    function<ll(ll,ll)> solve = [&](ll i,ll m)->bool{
        if (m==0)return true;
        if(i>=n) return false;
        return solve(i+1,m) | solve(i+1, m-an.at(i));
    };

    for(const auto& m:mq){
        cout<<(solve(0,m)?"yes":"no")<<endl;
    }
}
int main_() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll n; cin>>n;
    vector<ll> an(n);
    for(auto&& a:an){
        cin>>a;
    }
    ll q; cin>>q;
    vector<ll> mq(q);
    for(auto&& m:mq){
        cin>>m;
    }

    auto solve = [&](ll m)->bool{
        ll max=1LL<<n;
        FOR(i,0,max){
            ll v=0;
            FOR(j,0,n){
                if(i&(1LL<<j)) v+=an.at(j);
            }
            dump(i,v);
            if(v==m) return true;
        }
        return false;
    };

    for(const auto& m:mq){
        cout<<(solve(m)?"yes":"no")<<endl;
    }
    return 0;
}


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

int X;
int A;
int B;

int main()
{
	cin >> X >> A >> B;
	if(B <= A)
	{
		cout << "delicious";
	}
	else if(B - A <= X)
	{
		cout << "safe";
	}
	else if(B - A > X)
	{
		cout << "dangerous";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int H,A;
    cin >> H >> A;
    cout << (H+A-1)/A << endl;
}

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

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

int main()
{
    int K;
    cin >> K;
    cout << (K % 2 == 0 ? (K / 2) * (K / 2) : (K / 2) * (K / 2 + 1)) << endl;
}

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

int main(){
  stack<int>A;
  int a,b;
  char c[20];
  while(cin>>c){
    if(c[0]=='+'){
      b=A.top();A.pop();
      a=A.top();A.pop();
      A.push(a+b);
    }
    else if(c[0]=='-'){
      b=A.top();A.pop();
      a=A.top();A.pop();
      A.push(a-b);
    }
    else if(c[0]=='*'){
      b=A.top();A.pop();
      a=A.top();A.pop();
      A.push(a*b);
    }
    else{
      A.push(atoi(c));
    }
  }
  printf("%d\n",A.top());
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long                   
#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 
#define IOS ios_base::sync_with_stdio(0);

using namespace std;                    

const int maxn=2e5+123,inf=1e9,mod=1e9+7;

int n,x,ans,a[maxn];
int main(){
    cin>>n>>x;
    for(int i=0;i<n;i++)
    	cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    	if( a[i]<=x )
    		x-=a[i],ans++;
    if(x!=0 && ans==n)
    	ans--;
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    ll n; cin>>n;
    set<ll> box;
    rep(i,0,n){
        ll x; cin>>x;
        if(!box.count(x)) box.insert(x);
        else box.erase(x);
    
    }
    cout<<box.size()<<endl;
}

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

bool BinarySearch(int*A, int key, int n) {
	int left = 0;
	int right = n;
	
	while (left < right) {
		int mid = (left + right) / 2;

		if (A[mid] == key) {
			return true;
		}
		else if (A[mid] > key) {
			right = mid;
		}
		else {
			left = mid + 1;
		}
	}

	return false;
}

int main() {
	int A[100000];
	int n = 0;
	int q = 0;
	int x = 0;
	int cnt = 0;

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

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> x;
		if (BinarySearch(A, x, n)) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;

}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl

const long long MOD = 1000000007;


int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    ll b[n];
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll result = 0;
    for(int i = n-1; i >= 0; i--){
        if(a[i+1] >= b[i]){
            result += b[i];
        }else{
            result += a[i+1];
            b[i] -= a[i+1];
            if(a[i] >= b[i]){
                a[i] -= b[i];
                result += b[i];
            }else{
                result += a[i];
                a[i] = 0;
            }
        }
    }
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    ll mx = a[0];
    ll ans = 0;
    rep(i,n) {
        if (mx > a[i]) {
            ans += (mx-a[i]);
        }
        chmax(mx, a[i]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <cstring>
#include <vector>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;
typedef long long int ll;
ll dp[100001];

ll frog(vector<int> height,int n,int k){
	for(int i=0;i<k;i++){
		dp[i]=abs(height[i]-height[0]);
	}
	for(int i=k;i<n;i++){
		dp[i]=INT_MAX;
		for(int j=i-k;j<i;j++){
			dp[i]=min(dp[i],dp[j]+abs(height[j]-height[i]));
		}
	}
	return dp[n-1];
}

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


    memset(dp,0,sizeof(dp));
    int n;cin>>n;
    int k;cin>>k;
    vector<int> height;
    for(int i=0;i<n;i++){
    	int p;cin>>p;
    	height.push_back(p);
    }
    ll res=frog(height,n,k);
    cout<<res<<endl;

}

Measured memory_bytes: 4836
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int x, y, z;
    cin >> x >> y >> z;

    swap(x, y);
    swap(x, z);

    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int k;
    string s;
    int num;
    cin >> k;
    cin >> s;
    num=s.size();
    if(num<=k){
        cout << s << endl;
    }else{
        for(int i=0; i<k; i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    
    return 0;
}


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

int main(){
    string S;
    cin >> S;
    int A,B,C,D;
    A = S[0] - '0';
    B = S[1] - '0';
    C = S[2] - '0';
    D = S[3] - '0';

    bool result = false;
    string op1,op2,op3;
    for(int bit=0;bit < (1<<3);bit++){
        int sum = A;

        if(bit & (1<<0)){
            sum += B; 
            op1 = "+";
        }
        else{
            sum -= B; 
            op1 = "-";
        }

        if(bit & (1<<1)){
            sum += C;
            op2 = "+";
        }
        else{
            sum -= C;
            op2 = "-";
        }

        if(bit & (1<<2)){
            sum += D;
            op3 = "+";
        }
        else{
            sum -= D;
            op3 = "-";
        }

        if(sum == 7) {
            cout << A << op1 << B << op2 << C << op3 << D << "=" << 7 << endl;
            return 0;
        }
    }

    
}

Measured memory_bytes: 256
import sys
nq = int(input())
lines = sys.stdin.readlines()
ans = [None] * nq
s = {}
for i in range(nq):
    q, x = lines[i].split()
    if q == '0':    # insert x
        s[x] = ''
        ans[i] = str(len(s))
    elif q == '1':   # find x
        ans[i] = str(int(x in s))
    else:           # delete x
        if x in s:
            del s[x]

[print(x) for x in ans if x]


Measured memory_bytes: 56064
a=[]
n=int(input())
for i in range(10):
        a.append(-1)
while(n!=0):
    n-=1
    b=[]
    c=[]
    a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]=map(int,input().split())
    for i in range(10):
        b.append(-1)
        c.append(-1)
    j=1
    k=0
    lenb=0
    lenc=0
    b[0]=a[0]
    for i in range(1,10):
        if(a[i]>b[j-1]):
            b[j]=a[i]
            j+=1
        else:
            if(k==0):
                c[0]=a[i]
                k+=1
            elif(a[i]>c[k-1]):
                c[k]=a[i]
                k+=1
    for i in range(10):
        if(b[i]!=-1):
            lenb+=1
        if(c[i]!=-1):
            lenc+=1
    if(len(a)==(lenb+lenc)):
        print("YES")
    else:
        print("NO")

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

priority_queue<int> q1,q2,q3;
vector<int> r,g,l;
int main () {
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    for(int i=0;i<a;i++){
        int k;
        cin>>k;
        r.push_back(k);
    }
    sort(r.begin(),r.end(),greater<>());
    for(int i=0;i<x;i++){
        q1.push(r[i]);
        //cout<<r[i]<<' ';
    }
       // cout<<'\n';

    for(int i=0;i<b;i++){
        int k;
        cin>>k;
        g.push_back(k);
    }
    sort(g.begin(),g.end(),greater<>());
    for(int i=0;i<y;i++){
        q2.push(g[i]);
        //cout<<g[i]<<' ';
    }
    //cout<<'\n';


    for(int i=0;i<c;i++){
        int k;
        cin>>k;
        q3.push(k);
    }
    ll t = x+y,ans=0;
    while(t>0){
        int r =0,g=0,m=0;
        if(!q1.empty())
            r = q1.top();
        if(!q2.empty())
            g = q2.top();
        if(!q3.empty())
            m = q3.top();

        int mx = max({r,g,m});
        if(mx==r){
            q1.pop();
            t--;
            ans+=r;
        }else if(mx==g){
            q2.pop();
            t--;
            ans+=g;
        }else {
            q3.pop();
            ans+=m;
            t--;
        }
    }

    cout<<ans;


}

Measured memory_bytes: 2552
import sys

b = [ list(0 for i in range(14)) for j in range(14)]

def s(b,x,y):
    b[x][y]   += 1
    b[x+1][y] += 1
    b[x-1][y] += 1
    b[x][y+1] += 1
    b[x][y-1] += 1

def m(b,x,y):
    b[x-1][y-1] += 1
    b[x  ][y-1] += 1
    b[x+1][y-1] += 1
    b[x-1][y  ] += 1
    b[x  ][y  ] += 1
    b[x+1][y  ] += 1
    b[x-1][y+1] += 1
    b[x  ][y+1] += 1
    b[x+1][y+1] += 1

def l(b,x,y):
    b[x  ][y-2] += 1

    b[x-1][y-1] += 1
    b[x  ][y-1] += 1
    b[x+1][y-1] += 1

    b[x-2][y  ] += 1
    b[x-1][y  ] += 1
    b[x  ][y  ] += 1
    b[x+1][y  ] += 1
    b[x+2][y  ] += 1

    b[x-1][y+1] += 1
    b[x  ][y+1] += 1
    b[x+1][y+1] += 1

    b[x  ][y+2] += 1

for line in sys.stdin:
    d = list(map(int,line.split(",")))

    c = d[2]
    x = d[0] + 2
    y = d[1] + 2

    if c == 1:
        s(b,x,y)
    elif c == 2:
        m(b,x,y)
    elif c == 3:
        l(b,x,y)

ttl = 0
num = 0
max = 0
for x in range(2,12):
    for y in range(2,12):
        ttl += 1
        if b[x][y] == 0:
            num += 1
        if b[x][y] > max:
            max = b[x][y]
            
print(num)
print(max)

Measured memory_bytes: 7824
#include <bits/stdc++.h>
using namespace std;
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    string s;
    cin >> s;
    rep(i, 8) {
        if(s.substr(0,i) + s.substr(s.size()-(7-i)) == "keyence") {
            cout << "YES\n";
            return 0;
        }
        else continue;
    }
    cout << "NO\n";
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
vector<int>G[100001];
int A[100001];
int B[100001];
int C[100001];
bool used[100001];
void dfs(int x, int c){
	//cout<<x<<" "<<c<<endl;
	used[x]=true;
	int cc=1;
	REP(i,G[x].size()){
		int t=G[x][i];
		int now=A[t]^B[t]^x;
		if(used[now]==false){
			if(cc==c){
				cc++;
			}
			dfs(now,cc);
			C[t]=cc;
			cc++;
		}
	}
}

int main(){
	cin>>N;
	REP(i,N-1){
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
		G[A[i]].push_back(i);
		G[B[i]].push_back(i);
	}
	REP(i,100001){
		used[i]=false;
	}
	dfs(0,0);
	int ans=0;
	REP(i,N-1){
		ans=max(ans,C[i]);
	}
	cout<<ans<<endl;
	REP(i,N-1){
		cout<<C[i]<<endl;
	}
}

Measured memory_bytes: 9856
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		if(a.equals(b)) System.out.println("H");
		else System.out.println("D");
	}
}

Measured memory_bytes: 21716
import java.util.*;

class Main {
    public static void main(String[] args) {
        final long MOD = 1_000_000_007L;
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        final String S = sc.next();
        sc.close();

        int cnt = 0;
        for (int i=0; i<10; i++) {
            int a = S.indexOf(Integer.toString(i));
            if (a<0 || a>=S.length()-2) continue;
            for (int j=0; j<10; j++) {
                int b = S.substring(a+1).indexOf(Integer.toString(j));
                if (b<0 || b>=S.substring(a+1).length()-1) continue;
                for (int k=0; k<10; k++) {
                    int c = S.substring(a+1).substring(b+1).indexOf(Integer.toString(k));
                    if (c<0 || c>=S.substring(a+1).substring(b+1).length()) continue;
                    cnt++;
                    cnt %= MOD;
                }
            }
        }
        
        System.out.println(cnt);
    }
}

Measured memory_bytes: 92116
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll hito[17][17];//[nanninme][hito] [N][A[i]]made
    bool ok[17][17];//onaji
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            cin >> hito[i][j] >> ok[i][j];
        }
    }
    ll ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        ll cnt = 0;
        bool OK = true;
        vector<bool> usotuki(N, false);
        rep(j, N) {
            if (i >> j & 1) {
                usotuki[j] = true;
                cnt++;
            }
        }
        rep(k, N) {
            if (usotuki[k]) {
                rep(l, A[k]) {
                    if (usotuki[hito[k][l] - 1] != ok[k][l])OK = false;
                }
            }
        }
        if (OK)ans = max(cnt, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int D,N;
  cin>>D>>N;
  if(N==100) N++;
  if(D==0){
    cout<<N;
  }
  else if(D==1){
    cout<<100*N;
  }
  else if(D==2){
    cout<<10000*N;
  }
}

Measured memory_bytes: 256
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int a[5],k;
	for(int i=0; i<5; i++)cin >> a[i];
	cin >> k;
	sort(a,a+5);
	if(a[4]-a[0]>k)cout << ":(" << endl;
	else cout << "Yay!" << endl;
}	


Measured memory_bytes: 256
vals = []
for line in range(3):
  s = input().split()
  val = []
  for v in s:
    val.append(int(v))
  vals.append(val)

info = True

a = [0,]
b = vals[0]
a.append(vals[1][0]-b[0])
a.append(vals[2][0]-b[0])

for i in range(3):
  for j in range(3):
    if vals[i][j] != a[i] + b[j]:
      info = False
print('Yes' if info else 'No')

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int x, n;
    cin >> x >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        mp[p]++;
    }
    
    vector<int> q;
    for (int i = -10; i < 110; i++) {
        if (mp[i] == 0)
            q.push_back(i);
    }
    
    int ans = 0;
    int mi = 1000;
    for (int r : q) {
        int d = abs(x - r);
        if (d < mi) {
            mi = d;
            ans = r;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#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 rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=3e3+10;
const int INF=1e9+7;

string S,T;
int ls, lt;
void input(){
  cin>>S>>T;
  ls=sz(S);
  lt=sz(T);
}

int dp[MAX][MAX];
void solve(){
  rep1(i,ls)rep1(j,lt){
    if(S[i-1]==T[j-1])dp[i][j]=dp[i-1][j-1]+1;
    else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
  }
}

string ans;
void output(){ 
  int ti=ls, tj=lt;
  int ct=dp[ti][tj];
  while(ct>0){
    if(S[ti-1]==T[tj-1]){
      ans.pb(S[ti-1]);
      ti--;tj--;ct--;
    }
    else if(dp[ti][tj]==dp[ti-1][tj]) ti--;
    else tj--;
  }
  reverse(all(ans));
  cout<<ans<<endl;
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 35584