akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int data[5],cnt=0;
char s[5],ss[5];
void gen(int lv)
{
	if(lv==3)
	{
		cnt=s[0]-48;
		for(int i=0;i<3;i++)
		{
			if(data[i]==0)
			{
				cnt+=s[i+1]-48;
			}else
			{
				cnt-=s[i+1]-48;
			}
		}
		if(cnt==7)
		{
			for(int i=0;i<4;i++)
			{
				if(data[i]==0)
				{
					ss[i]='+';
				}else
				{
					ss[i]='-';
				}
			}
		}
		return;
	}
	for(int i=0;i<=1;i++)
	{
		data[lv]=i;
		gen(lv+1);
	}
}
int main()
{
	
	scanf("%s",s);
	gen(0);
	printf("%c",s[0]);
	printf("%c",ss[0]);
	printf("%c",s[1]);
	printf("%c",ss[1]);
	printf("%c",s[2]);
	printf("%c",ss[2]);
	printf("%c",s[3]);
	printf("=7");
}

Measured memory_bytes: 256
// Problem : D - Redistribution
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 2003, M = N << 1, mod = 1000000007;

int s;
int dp[N][N];

int main()
{
	//File("");
    s = gi <int> ();
    dp[0][0] = 1;
    for (int i = 1; i <= s / 3; i+=1)
    	for (int j = (i - 1) * 3; j <= s; j+=1)
    		for (int k = 3; k + j <= s; k+=1)
    			dp[i][k + j] = (dp[i][k + j] + dp[i - 1][j]) % mod;
    int ans = 0;
    for (int i = 1; i <= s / 3; i+=1) ans = (ans + dp[i][s]) % mod;
    printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8352
<?php
    while(1){
        fscanf(STDIN,"%d %s %d",$a,$op,$b);
        if( $op == "+" ){
            $x = $a + $b;
            echo $x."\n";
        }
        else if( $op == "-" ){
            $x = $a - $b;
            echo $x."\n";
        }
        else if( $op == "*" ){
            $x = $a * $b;
            echo $x."\n";
        }
        else if( $op == "/" ){
            $x = floor( $a / $b );
            echo $x."\n";
        }
        else if( $op == "?" ){
            break;
        }
    }

Measured memory_bytes: 15268
#include<bits/stdc++.h>
using namespace std;
const long double PI =(acos(-1));

int main(){
    int n;
    cin >> n;
    vector<vector<int> > A(3,vector<int> (10));
    vector<vector<int> > B(3,vector<int> (10));
    vector<vector<int> > C(3,vector<int> (10));
    vector<vector<int> > D(3,vector<int> (10));

    for(int i=0;i<n;++i){
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        if(b==1){
            A.at(f-1).at(r-1)+=v;
        }
        if(b==2){
            B.at(f-1).at(r-1)+=v;
        }
        if(b==3){
            C.at(f-1).at(r-1)+=v;
        }
        if(b==4){
            D.at(f-1).at(r-1)+=v;
        }
    }

    for(int i=0;i<=3;++i){
        for(int j=0;j<10;++j){
            if(i==3){
                cout << "##";
            }else{
                cout << " " << A.at(i).at(j);
            }
        }cout << endl;
    }
    for(int i=0;i<=3;++i){
        for(int j=0;j<10;++j){
            if(i==3){
                cout << "##";
            }else{
                cout << " " << B.at(i).at(j);
            }
        }cout << endl;
    }
    for(int i=0;i<=3;++i){
        for(int j=0;j<10;++j){
            if(i==3){
                cout << "##";
            }else{
                cout << " " << C.at(i).at(j);
            }
        }cout << endl;
    }
    for(int i=0;i<3;++i){
        for(int j=0;j<10;++j){
            cout << " " << D.at(i).at(j);
        }cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A = INT()
B = INT()

ans = [1, 2, 3]

for i in ans:
	if i not in [A, B]:
		print(i)


Measured memory_bytes: 3892
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N,ans = 0,ma=-1,k,hako;
    cin >> N;

    for(int i = 1;i <= N;i++){
        ans = 0;
        k = i;
        while(k > 0){
            if(k % 2 == 0)
                ans++;
            k /= 2;
        }
        if(ans > ma){
            ma = ans;
            hako = i;
        }

    }

    cout << hako << endl;
}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0) break;
			Integer[] point = new Integer[n];
			for(int i=0;i<n;++i){
				point[i]=sc.nextInt();
			}
			Arrays.sort(point);
			int dis=10000000;
			for(int i=0;i<n-1;++i){
				if(point[i+1]-point[i]<dis) dis=point[i+1]-point[i];
			}
			System.out.println(dis);
		}
	}
}


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

int main(){
	int N;
	int A[110];
	int tmp = 0;
	int ans = 1;
	cin >> N;
	
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
	tmp = A[0];
	for(int i=1; i<N; i++){
		if(tmp<=A[i]){
			ans++;
			tmp = A[i];
		}
	}
		cout << ans << endl;
	return 0;
}
	 

Measured memory_bytes: 256
S=input()
line=[]
word=list(S)
for i in range(len(word)):
    if word[i]=="?":
        word[i]="D"
        # if i+1==len(word):
        #     word[i]="D"
        # else:
        #     if word[i+1]=="D":
        #         word[i]="P"
        #     else:word[i]="D"



print("".join(word))

Measured memory_bytes: 10700
#include<stdio.h>
int main(){
  int N,i,k=1,hight=0;
  int a[200]={};
  scanf("%d",&N);
  for(i=0;i<N;i++){
  scanf("%d",&a[i]);
  }
  //printf("%d\n",N);
  //printf("%d\n",a[1]);
  hight=a[0];
    for(i=1;i<N;i++){
      if(hight<=a[i]){
        hight=a[i];
        k=k+1;
      }
    }
  printf("%d",k);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(void){
int i;
char s[100];
int x[10];
int sum[8];
int sa[10];
int a=999;
int b;
scanf("%s",s);
b=strlen(s);
for(i=0;i<b;i++){
x[i]=s[i]-'0';
}
for(i=0;i<b-2;i++){
sum[i]=x[i]*100;
sum[i]+=x[i+1]*10;
sum[i]+=x[i+2];
}
for(i=0;i<b-2;i++){
sa[i]=753-sum[i];
if(sa[i]<0){
sa[i]=sa[i]*-1;
}
}
for(i=1;i<b-2;i++){
if(sa[0]>sa[i]){
sa[0]=sa[i];
}
}
printf("%d",sa[0]);
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
	double a,b,c,d,e,f,x,y;
	while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)==6){
        double y=(double)(c*d-a*f)/(double)(b*d-a*e);
        if(a!=0)
			printf("%.3f %.3f\n",(c-b*y)/a,y);
        else
			printf("%.3f %.3f\n",(f-e*y)/d,y);}
	return 0;}


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

int main(void){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    
    string ans = "";
    for(int i = 0; i < n; i++) {
        ans += s.at(i);
        ans += t.at(i);
    }
    
    cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k;
	cin>>n>>k;
	vector<int> h(n);
	for(auto &x : h){
		cin>>x;
	}
	sort(h.begin(), h.end());
	int ans = h[k - 1] - h[0];
	for(int i = k; i < n; i++){
		ans = min(ans, h[i] - h[i - k + 1]);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
INF = float("inf")


class Acc2D:
    def __init__(self, grid):
        self.h, self.w = len(grid), len(grid[0])
        self.acc2D = self._build(self.h, self.w, grid)

    def _build(self, h, w, grid):
        ret = [[0] * (w + 1) for _ in range(h + 1)]
        for r in range(h):
            for c in range(w):
                ret[r + 1][c + 1] = ret[r][c + 1] + ret[r + 1][c] - ret[r][c] + grid[r][c]
        return ret

    def get(self, r1, r2, c1, c2):
        if r1 < 0:
            r1 = 0
        if r2 >= self.h:
            r2 = self.h
        if c1 < 0:
            c1 = 0
        if c2 >= self.w:
            c2 = self.w
        cnt = self.acc2D
        return cnt[r2][c2] - cnt[r1][c2] - cnt[r2][c1] + cnt[r1][c1]


def main():
    n, k = map(int, input().split())
    g = [[0] * (2 * k) for _ in range(2 * k)]
    for _ in range(n):
        x, y, c = input().split()
        x = int(x) % (2 * k)
        y = int(y) % (2 * k)
        if c == 'B':
            y = (y + k) % (2 * k)
        g[y][x] += 1
    acc2d = Acc2D(g)
    ans = 0
    for r in range(k):
        for c in range(k):
            tmp = acc2d.get(0, r, 0, c)
            tmp += acc2d.get(0, r, c + k, c + k * 2)
            tmp += acc2d.get(r, r + k, c, c + k)
            tmp += acc2d.get(r + k, r + k * 2, 0, c)
            tmp += acc2d.get(r + k, r + k * 2, c + k, c + k * 2)
            ans = max(ans, tmp, n - tmp)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 107228
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
a = []

for i in range(k):
    d = ni()
    a.append(na())

l = [0] * n
for i in range(k):
    for j in range(len(a[i])):
        l[a[i][j] - 1] += 1

ans = 0
for i in range(n):
    if l[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9232
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let ab = lines.shift().split(/\s/).map((v) => v - 0);
    let A = ab[0], B = ab[1];
    let set = [[A, A-1], [A, B], [B, B-1]];
    let sum = set.map((v) => v[0] + v[1]);
    let ans = Math.max(...sum);
    console.log(ans);
}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>

int main()
{
  int A[100],n,i,minj,j,k,c=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  for(i=0;i<n-1;i++)
    {
      minj = i;
      for(j=i;j<=n-1;j++)
	{
	  if(A[j] < A[minj])minj=j;
	}
      if(A[i]>A[minj]){
      k=A[i];
      A[i]=A[minj];
      A[minj]=k;
      c++;
      }
    }
   for(i=0;i<n-1;i++)printf("%d ",A[i]);
   printf("%d\n",A[i]);
   printf("%d\n",c);
   return 0;
}



Measured memory_bytes: 2104
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.text.Segment;

public class Main {

	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final char[] S = sc.next().toCharArray();
			final char[] T = sc.next().toCharArray();
			
			String answer = null;
			
			LOOP:
			for(int start = 0; start <= (S.length - T.length); start++){
				for(int index = 0; index < T.length; index++){
					final char S_ch = S[start + index];
					final char T_ch = T[index];
					
					if(!(S_ch == '?' || S_ch == T_ch)){ continue LOOP; }
				}
				
				StringBuilder sb = new StringBuilder();
				for(int i = 0; i < start; i++){ 
					if(S[i] == '?'){
						sb.append('a');
					}else{
						sb.append(S[i]);
					}
				}
				for(int i = 0; i < T.length; i++){ sb.append(T[i]); }
				for(int i = start + T.length; i < S.length; i++){
					if(S[i] == '?'){
						sb.append('a');
					}else{
						sb.append(S[i]);
					}
				}
				
				final String curr = sb.toString();
				if(answer == null || answer.compareTo(curr) > 0){
					answer = curr;
				}
			}
			
			if(answer != null){
				System.out.println(answer);
			}else{
				System.out.println("UNRESTORABLE");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21460
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll tmp = lcm(c, d);
    //cout << tmp << endl;
    ll num1 = b - (b / c + b / d - b / tmp);
    ll num2 = (a-1LL) - ((a-1LL) / c + (a-1LL) / d - (a-1LL)/tmp);
    //cout << num1 << " " << num2 << endl;
    cout << num1 - num2 << endl; 
    return 0;
}


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

int n, x, y, z;
vector<int> v;

int dfs(int a, int b, int c, int dep) {
  if(n == dep) {
    return min({a, b, c}) > 0
      ? (abs(a - x) + abs(b - y) + abs(c - z) - 30)
      : 2e9;
  }
  int t = v[dep++];
  int t1 = dfs(a + t, b, c, dep) + 10;
  int t2 = dfs(a, b + t, c, dep) + 10;
  int t3 = dfs(a, b, c + t, dep) + 10;
  int t4 = dfs(a, b, c, dep);
  return min({t1, t2, t3, t4});
}

int main() {
  cin >> n >> x >> y >> z;
  
  v.resize(n);
  for(int i = 0; i < n; i++) {
    cin >> v[i];
  }
  
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int K = int.Parse (str[0]);

            long ans = 0;
            for (int a = 1; a <= K; a++)
            {
                for (int b = 1; b <= K; b++)
                {
                    for (int c = 1; c <= K; c++)
                    {
                        ans += GCD (GCD (a, b), c);
                    }
                }
            }

            Console.Write (ans);
        }

        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27508
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[1]*(n+1)
for i in a:
    dp[i]=0
    
k=10**9+7
for i in range(2,n+1):
    if dp[i]!=0:
        dp[i]=(dp[i-1]+dp[i-2])%k
        
print(dp[-1])


Measured memory_bytes: 7848
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    long n,k;
    cin >> n >> k;
    if(k%2 == 0){
        long a = n/k;
        k = k/2;
        long b = n/k;
        b -= a;
        long long ans = a*a*a+b*b*b;
        cout << ans << endl;
    }
    else{
        long a = n/k;
        long long ans = a*a*a;
        cout << ans << endl;
    }
    return 0;
    
}

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

int main(){
  int n;
  cin>>n;
  for(int i=0;i<=25;i++){
    for(int j=0;j<=15;j++){
      if(4*i+7*j==n){
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
//              |----------------------------|
//              | BISMILLAHIR RAHMANIR RAHIM |
//              |----------------------------|

//      /\      ||  //      /\      /______  ||     ||
//     //\\     || //      //\\    ||------  ||     ||
//    //__\\    ||/|      //__\\   ||______\ ||_____||
//   //----\\   ||\|     //----\\   \-----|| ||-----||
//  //      \\  || \\   //      \\  ______|| ||     ||
// //        \\ ||  \\ //        \\ ------|/ ||     ||



#include<bits/stdc++.h>
#include<stdlib.h>
#include<math.h>

using namespace std;

#define   ll            long long int
#define   mxx           200005
#define   pb            push_back
#define   rep(i,n)      for(int i=0;i<n;i++)
#define   rep1(i,n)     for(int i=1;i<=n;i++)
#define   mod           1000000007


int main()
{
    ll t,n,a,b,c,d,i,j,k,l,m,cnt;

    cin>>a>>b>>c>>d;
    ll mx;
    mx=a*c;
    mx=max(mx,a*d);
    mx=max(mx,b*c);
    mx=max(mx,b*d);
    cout<<mx<<endl;



    return 0;
}





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

namespace abc176.b
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] paramArray = getStringParam().ToCharArray();

            int mod = 0;
            for (int c = 0; c < paramArray.Length; c++)
            {
                mod = (mod + int.Parse(paramArray[c].ToString())) % 9;
            }
            Console.WriteLine(mod == 0 ? "Yes" : "No");
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


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

using namespace std;

int s[2005][2005], s2[2005][2005];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		string a;
		cin >> a;
		for (int j = 0; j < W; j++) {
			s[i][j] = (a[j] == '.' ? 0 : 1);
		}
	}

	for (int i = 0; i < H - 1; i++) {
		for (int j = 0; j < W - 1; j++) {
			s2[i][j] = (s[i][j] + s[i + 1][j] + s[i][j + 1] + s[i + 1][j + 1] + 1) % 2;
		}
		for (int j = 1; j < W - 1; j++) {
			s2[i][j] = (s2[i][j] == 0 ? 0 : s2[i][j - 1] + 1);
		}
	}

	int ans = max(H, W);
	for (int j = 0; j < W - 1; j++) {
		vector<int> L(H - 1), R(H - 1);
		stack<int> st;
		for (int i = 0; i < H - 1; i++) {
			while (!st.empty() && s2[st.top()][j] >= s2[i][j]) st.pop();
			L[i] = (st.empty() ? 0 : (st.top() + 1));
			st.push(i);
		}

		stack<int> st2;
		for (int i = H - 2; i >= 0; i--) {
			while (!st2.empty() && s2[st2.top()][j] >= s2[i][j]) st2.pop();
			R[i] = (st2.empty() ? H - 1 : st2.top());
			st2.push(i);
		}

		for (int i = 0; i < H - 1; i++) {
			ans = max(ans, (s2[i][j] + 1) * (R[i] - L[i] + 1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31616
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

inline double calc(ll n) {
  double res = 0;
  while(n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main(void) {
  ll K;
  scanf("%lld", &K);

  set<ll> res;
  REP(i, 9) {
    res.insert(i+1);
  }
  ll t = 10;
  for(int d = 1; d <= 15; ++d, t *= 10) { // 下d桁が9のやつ
    for(ll i = 1; ; ++i) {
      ll v1 = t*i + (t-1);
      ll v2 = t*(i+1) + (t-1);
      // cerr << v1 << " " << v2 << endl;
      if(v1 / calc(v1) > v2 / calc(v2)) {
        break;
      }
      res.insert(v1);
    }
  }

  for(ll v : res) {
    if(K-- > 0) {
      printf("%lld\n", v);
    }
  }
  return 0;
}


Measured memory_bytes: 256
def calc(l,n,arr):
  cum1=[0]
  cum2=[0]
  for i in range(n):
    cum1.append(cum1[-1]+arr[i])
  for i in range(n-1,-1,-1):
    cum2.append(cum2[-1]+(l-arr[i]))
  ans=0
  for i in range(n):
    if (n-i-1)%2==0:
      lm=(n-i-1)//2
      rm=(n-i-1)//2
      end=i+rm
      tmp=2*(cum1[rm+i]-cum1[i])+2*cum2[lm]+arr[end]
    else:
      lm=(n-i-1)//2+1
      rm=(n-i-1)//2
      end=n-lm
      tmp=2*(cum1[rm+i+1]-cum1[i])+2*cum2[lm-1]+(l-arr[end])
    ans=max(ans,tmp)
  return ans

l,n=map(int,input().split())
arr=[int(input()) for _ in range(n)]
ans1=calc(l,n,arr)
for i in range(n):
  arr[i]-=l
  arr[i]*=-1
ans2=calc(l,n,arr[::-1])
print(max(ans1,ans2))

Measured memory_bytes: 31580
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[200010];
int main()
{
	int N;
	ll K;
	cin >> N >> K;
	ll MAX = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		MAX = max(MAX, A[i]);
	}
	ll ok = MAX;
	ll ng = 0;
	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;
		ll cnt = 0;
		for (int i = 0; i < N; i++) {
			cnt += A[i] / mid;
			if (A[i] % mid == 0) cnt--;
		}
		if (cnt <= K) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

const double pie = acos(-1.0);
const ll MOD = 1e9 + 7;

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a / gcd(a, b) * b;
}

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

void solve() {
    ll n, m; cin >> n >> m;
    ll ans = 0;
    if(n*2 >= m){ // cがなくなる場合
        ans = m/2;
    }else{ // cが余る場合
        ans += n;
        m -= n*2;
        ans += m/4;
    }
    cout << ans << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    pr(S[1]=='B'?"ARC":"ABC");
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a = fetch_vec<ll>(x);
    vector<ll> b = fetch_vec<ll>(y);
    vector<ll> c = fetch_vec<ll>(z);

    std::sort(a.begin(), a.end(), std::greater<ll>());
    std::sort(b.begin(), b.end(), std::greater<ll>());
    std::sort(c.begin(), c.end(), std::greater<ll>());

    vector<ll> ab;

    for (int i = 0; i < x; ++i)
    {
        for (int j = 0; j < y; ++j)
        {
            for (int l = 0; l < z; ++l)
            {
                if ((i+1)*(j+1)*(l+1) > k + 1)
                    break;

                ab.push_back(a[i] + b[j] + c[l]);
            }
        }
    }

    std::sort(ab.begin(), ab.end(), std::greater<ll>());

    for (int i = 0; i < k; ++i)
        cout << ab[i] << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int MAXINT = 2147483647;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

ll n, k;
int ans, tot, cnt;

int a[MAXN];
ll cost[MAXN];

inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}

map<ll, ll> m;

ll dfs(ll x) {
	if (!x) return 0;
	if (m.count(x)) return m[x];
	ll num[6] = {x/2, x/2+1, x/3, x/3+1, x/5, x/5+1};
	ll t[6] = {2, 2, 3, 3, 5, 5};
	ll res = 1e18;
	for (int i = 0; i < 6; i++) {
		if (num[i] < x) res = min(res, dfs(num[i]) + (ll)min((double)abs(num[i] - x) * cost[0], abs(num[i] * t[i] - x) * (double)cost[0] + cost[t[i]])); 
	}
	return m[x] = res;
}

int main(){
	int T;
	cin >> T;
	while (T--) {
		m.clear();
		scanf("%lld%lld%lld%lld%lld", &n, &cost[2], &cost[3], &cost[5], &cost[0]);
		printf("%lld\n", dfs(n));
		
	}
	return 0;
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e5+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}


lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}

int dx[4]={0,0,1,-1}, dy[4]={1,-1,0,0};

vvi graph(int n, int m){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	return v;
}

// ---- コーディングはここから！ ('-')7

void solve(){
	int n,m,x; cin>>n>>m>>x;
	int xx = 1<<n;
	vv(lli,v,n,m);
	vl c(n);
	fore(i,0,n){
		cin>>c[i];
		fore(j,0,m)cin>>v[i][j];
	}
	lli mx = INF;
	fore(i,0,xx){
		vi s(m);
		lli k = 0;
		fore(j,0,n)if(i & (1<<j)){
			k+=c[j];
			fore(jj,0,m)s[jj]+=v[j][jj];
		}
		bool can = 1;
		fore(j,0,m)can&=(s[j]>=x);
		if(can)mx=min(mx,k);
	}
	cout<<(mx==INF?-1:mx)<<ENDL;

}

int main(){_
//	int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 10005;
vector<int> G[MAX_N],c;
int ans[MAX_N];
bool visited[MAX_N];
int idx = 0;

void dfs(int n)
{
	if (visited[n]) return;
	visited[n] = true;
	ans[n] = c[idx];
	idx++;
	rep(i,G[n].size())
	{
		dfs(G[n][i]);
	}
	return;
}

int main()
{
	int N;
	cin >> N;
	rep(i,N-1)
	{
		int a,b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i,N)
	{
		int p;
		cin >> p;
		c.push_back(p);
	}
	sort(c.begin(), c.end());
	reverse(c.begin(), c.end());
	dfs(0);
	ll M = 0;
	rep(i,N-1)
	{
		M += c[i+1];
	}
	cout << M << endl;
	rep(i,N)
	{
		if (i != 0) cout << " ";
		cout << ans[i];
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long i=0;i<(long)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=1e10+7;

int main(void){
    long n;
    cin>>n;
    int m=0;
    int a[4];
    a[0]=n/25;
    n%=25;
    a[1]=n/10;
    n%=10;
    a[2]=n/5;
    a[3]=n%5;
   for(int i=0;i<4;i++){
       m+=a[i];
   }
    cout<<m<<endl;
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

int n, a, b, c;

vector<int> l;
vector<int> x;

int ans = 10000000;

void dfs(int i) {
    if (i == n) {
        int a_sum = 0, b_sum = 0, c_sum = 0;
        int a_cnt = 0, b_cnt = 0, c_cnt = 0;
        for (int j = 0; j < n; j++) {
            if (x[j] == 1) {
                a_sum += l[j];   
                a_cnt++;
            } else if (x[j] == 2) {
                b_sum += l[j];
                b_cnt++;
            } else if (x[j] == 3) {
                c_sum += l[j];
                c_cnt++;
            }
        }
        
        if (a_cnt == 0 || b_cnt == 0 || c_cnt == 0) {
            return;
        }
        
        int cost = ((a_cnt - 1) + (b_cnt - 1) + (c_cnt - 1)) * 10;
        
        cost += abs(a_sum - a);
        cost += abs(b_sum - b);
        cost += abs(c_sum - c);
        
        ans = min(ans, cost);
        
        return;
    }
    
    for (int j = 0; j < 4; j++) {
        x[i] = j;
        
        dfs(i + 1);
    }
}

int main()
{    
    cin >> n >> a >> b >> c;
    
    l.resize(n);
    
    for (int i = 0; i < n; i++) {
        cin >> l[i];   
    }
    
    x.resize(n);
    
    dfs(0);
    
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string n;
    cin >> n;
    long long int sum = 0;

    for (int i = 0; i < n.size(); i++)
    {
        sum = sum + ((int)n[i] - 48);
    }
    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
using namespace std;
const int MAXN = 305;
const int MAXC = MAXN * 305;
const int INF = (LL)1e9 + 5;
const LL MOD = 998244353;

int N;
LL ans = 0, sum = 0, dp[MAXC], dp2[MAXC];

LL qpow(LL a, LL pw) {
	LL res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> N;
	dp[0] = dp2[0] = 1;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		sum += a;
		for (int j = sum; j >= 0; j--) {
			dp2[j] = (dp2[j] * 2) % MOD;
			if (j >= a) {
				dp[j] = (dp[j] + dp[j - a]) % MOD;
				dp2[j] = (dp2[j] + dp2[j - a]) % MOD;
			}
		}
	}
	
	ans = (qpow(3, N) - qpow(2, N) * 3 + 3) % MOD;
	LL minus = 0;
	for (int i = sum / 2 + sum % 2; i <= sum; i++) {
//		cout << i << " -> " << dp2[i] << ' ' << dp[i] << '\n';
		minus = minus + dp2[i] - 2 * dp[i];
		if (i == sum) minus++;
	}
	
	cout << ((ans - minus * 3) % MOD + MOD) % MOD << '\n';

	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x)) 
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
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; }

using namespace std;
int main() {
  string s;
  cin >>s;
  char pre = s[0];
  reps(i, 3){
    if(pre == s[i]){
      cout << "Bad" << endl;
    return 0;
    }
    pre = s[i];
  }
  cout << "Good" << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

void printMatrix(int s,int[s][s]);
void fillMatrix(int s,int[s][s]);
void getBreadth(int s, int[s][s], int[]);
void findBreadth(int s, int[s][s], int[], int, int);
int min(int,int);

int main(int argc, char** argv) {
    int size;
    scanf("%d", &size);
    int matrix[size][size];
    int breadth[size];
    for(int i = 0; i < size; i++){
        for(int j = 0; j < size; j++)
            matrix[i][j] = 0;
        breadth[i] = INT_MAX;
    }
    fillMatrix(size,matrix);
    getBreadth(size, matrix, breadth);
    for(int i = 0; i < size; i++){
        if(breadth[i] == INT_MAX)
            breadth[i] = -1;
        printf("%d %d\n",i+1,breadth[i]);
    }
    return (EXIT_SUCCESS);
}

void printMatrix(int size, int mat[size][size]){
    for(int i = 0; i < size; i++){
        for(int j = 0; j < size; j++){
            printf("%d", mat[i][j]);
            if(j != size-1)
                printf(" ");
        }
        printf("\n");
    }
}

void fillMatrix(int size, int mat[size][size]){
    int loc, count, adjacent;
    for(int i = 0; i < size; i++){
        scanf("%d %d",&loc, &count);
        if(count > 0)
            for(int j = 0; j < count; j++){
                scanf("%d", &adjacent);
                mat[loc-1][--adjacent] = 1;
            }
    }
}

void getBreadth(int size, int mat[size][size], int bread[size]){
    int brdth = 0;
    bread[0] = 0;
    findBreadth(size,mat,bread,0,brdth);
}

void findBreadth(int size, int mat[size][size], int bread[size], int current, int brdth){
    bread[current] = min(bread[current],brdth);
    for(int i = 0; i < size; i++)
        if(mat[current][i] && current != i && bread[i] > brdth)
            findBreadth(size,mat,bread,i,brdth+1);
}

int min (int a, int b){
    if(a < b) return a;
    return b;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
char a[1005];
bool N=0,S=0,W=0,E=0;
int main()
{
cin>>a+1;
int n=strlen(a+1);
  for(int i=1;i<=n;i++) 
    if (a[i]=='N')
	  N=1;
    else if (a[i]=='S') 
	  S=1;
    else if (a[i]=='W')
	  W=1;
    else 
	  E=1;
    if (N^S or W^E) 
      cout<<"No"<<endl;
    else
	  cout<<"Yes"<<endl;
return 0;
}

Measured memory_bytes: 256
#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 <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d;
    cin >> d;
    vector<int> c(26);
    for(int i=0; i<26; i++) cin >> c[i];
    vector<vector<int>> G(d,vector<int> (26));
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++){
            cin >> G[i][j];
        }
    }
    vector<int> t(d);
    for(int i=0; i<d; i++){
        t[i] = rand() % 26;
    }
    int sum = 0;
    for(int k=0; k<100000; k++){
        int a = rand() % d;
        int b = rand() % 26;
        int pre = t[a];
        t[a] = b;
        vector<int> now(26,0);
        vector<int> last(26,0);
        for(int i=0; i<d; i++){
            last[t[i]] = i+1;
            now[t[i]] += G[i][t[i]];
            for(int j=0; j<26; j++){
                now[t[i]] -= c[j] * (i+1 - last[j]);
            }
        }
        int s = 0;
        for(int j=0; j<26; j++){
            s += now[j];
        }
        if(s > sum){
            sum = pre;
        }else{
            t[a] = pre;
        }
    }
    for(int i=0; i<d; i++){
        cout << t[i]+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
using namespace std;
#define N 10000000
bool P[N+1];

void eratos(){
  for(int i=0;i<=N;i++)
    P[i]=true;
  P[0]=P[1]=false;
  for(int i=2;i*i<=N;i++)
    if (P[i])
      for(int j=2;i*j<=N;j++)
        P[i*j] = false;
}
int getQuads(int n){
  for (int i=n; i>=13;i--)
    if (P[i] && P[i-2] && P[i-6] && P[i-8] )
      return i;
}
int main(){
  eratos();
  int n;
  while(cin >> n && n )
    cout << getQuads(n) << endl;
  return 0;
}

Measured memory_bytes: 10924
#include<bits/stdc++.h>
#define max1(a,b) a > b ? a : b;
using namespace std;
typedef long long ll;
int a, b, x, y,sum;
int main()
{
	ios::sync_with_stdio(false);
	int k;
	cin >> k;
	cin >> a >> b;
	int i;
	for ( i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			printf("OK");
			break;
		}
	}
	if (i > b)
		printf("NG");
	return 0;

}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// typedef pair<ll,ll> Pair;
// ll mod=1000000007;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j,k,temp,temp2,n,m,x,y;
    string a;
    cin >> i >> j >> k;
    swap(i,j);
    swap(i,k);
    cout << i << " " << j << " " << k;
}

Measured memory_bytes: 256
/**
 * 全点対間最短経路
 * ベルマン・フォード法
 * https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_1_C
 * */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//#define INF 1LL<<60 //使いやすい無限(ll)
#define INF 1'000'000'000'000'000'000

using Node = long long; //頂点
using Distance = long long; //距離
using Weight = long long; //重み

using Edge = tuple<Node, Node, Weight>;

ll V,E;
vector<Edge> Edges;
vector<Distance> dist;

bool BellmanFord(ll start){
  dist.assign(V, INF);
  dist[start] = 0;

  for(int i=1; i<V; i++){
    for(Edge x: Edges){
      Node s,t; Weight d;
      tie(s,t,d) = x;
      if(dist[s]==INF)continue; //距離無限ノードからの辺は考えない
      
      if(dist[s]+d < dist[t]){
        dist[t] = dist[s] + d;
      }

    }
  }

  bool NC = false;
  for(Edge x: Edges){
    Node s,t; Weight d;
    tie(s,t,d) = x;
    if(dist[s]==INF)continue; //距離無限ノードからの辺は考えない
    if(dist[s]+d < dist[t]){
      NC = true;
    }
  }

  return NC;
}

int main(){
  cin>>V>>E;

  for(int i=0; i<E; i++){
    ll s,t,d;
    cin>>s>>t>>d;
    Edges.push_back(make_tuple(s,t,d));
  }

  for(ll r=0; r<V; r++){
    bool isNcycle = BellmanFord(r);

    if(isNcycle){
      cout<<"NEGATIVE CYCLE"<<endl;
      return 0;
    }

    ll x = dist[0];
    if(x==INF){
      cout<<"INF";
    }else{
      cout<<x;
    }
    for(int i=1; i<V; i++){
      x = dist[i];
      if(x==INF){
        cout<<" INF";
      }else{
        cout<<" "<<x;
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3344
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

#define mod 1000000007

int main() {
    int n = 0;
    cin >> n;
    vector<int > a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    bool flag = false;
    sort(a.begin(), a.end());
    int now = (n%2 == 0) ? 1 : 0;
    for (int i=1; i<n; i+=2) {
        if (now == 0) {
            if (a.at(i-1) != now) {
                flag = true;
                break;
            }
            i--;
        }
        else {
            if (a.at(i) != now || a.at(i) != a.at(i-1)) {
                flag = true;
                break;
            }
        }
        now += 2;
    }
    if (flag) {
        cout << 0 << endl;
    }
    else {
        ll ans = 1;
        for (int i=0; i<n/2; i++) {
            ans *= 2;
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 640