akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  string s;
  cin>>s;
  int n = sz(s);
  int ans = INF;
  for (char c = 'a'; c <= 'z'; ++c) {
    vi a(n);
    rep(i,n) a[i] = s[i] == c;
    while (a != vi(sz(a),1)) {
      vi p(sz(a)-1); swap(a,p);
      rep(i,sz(a)) a[i] = p[i]|p[i+1];
    }
    mins(ans, n-sz(a));
  }
  cout<<ans<<endl;
  return 0;
}






















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

int main(void)
{
    int64_t R;

    std::cin >> R;

    std::cout << (double)(2*M_PI*R) << std::endl;

    return 0;
}

Measured memory_bytes: 3772
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	var ans int
	// 1はすべての約数なのでどこかで足す
	// wg := new(sync.WaitGroup)
	// wg.Add(1)
	// go func() {
	for i := 2; i <= N; i++ {
		for j := 1; i*j <= N; j++ {
			ans += i * j
		}
	}
	// 	wg.Done()
	// }()
	// wg.Wait()
	ans += N * (N + 1) / 2
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1828
def main():
  n = int(input())
  a = list(input_list())
  ans = 10**9
  a1 = a[0]
  if all([v == a1 for v in a]):
    print(0)
    exit()
  for i in range(-100, 101):
    ta = 0
    for ai in a:
      ta += (ai-i)*(ai-i)
    ans = min(ans, ta)
  print(ans)
  
def input_list():
  return map(int, input().split())

import math
main()

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 
 if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <=H)
  printf("Yes\n");
 
 else printf("No\n");
 
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int x, a;
	cin >> x >> a;

	if (x < a) {
		cout << 0 << endl;
	} else {
		cout << 10 << endl;
	}
	return 0;
}


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

typedef long long ll;

int main()
{
	vector<int> vi;
	vi.push_back(1);
	
	for(int i=2;i<34;i++)
	{
		int curr = i*i;
		while(curr<=1e3)
		{
			vi.push_back(curr);
			curr*=i;
		}
	}
	sort(vi.begin(),vi.end());
	
	//for(auto i:vi)
	//	cout<<i<<"\n";
	
	
	int x;
	cin>>x;
	
	int ind = lower_bound(vi.begin(),vi.end(),x) - vi.begin();
	if(vi[ind]==x)
		cout<<x;
	else
		cout<<vi[ind-1];
	
	
}

Measured memory_bytes: 256
/*
~Like a small boat
~On the ocean
~Sending big waves
~Into motion
!Like how a single word
!Can make a heart open
!I might only have one match
!But I can make an explosion
#And all those things I didn't say
#Wrecking balls inside my brain
#I will scream them loud tonight
#Can you hear my voice this time?
@This is my fight song
@Take back my life song
@Prove I'm alright song
@My power's turned on
$Starting right now I'll be strong
$I'll play my fight song
$And I don't really care if nobody else believes
$'Cause I've still got a lot of fight left in me!!!
*/

#include "bits/stdc++.h"
using namespace std;

#define  F  first
#define  S  second
#define  pb push_back
#define  mp make_pair
#define  sz(s) (int)s.size()
typedef long long int ll;
const int N = 3e3+5;

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

    ll n,m;cin>>n>>m;
    ll prv = 0,Cnt = 0;
    map<ll,ll>M;
    while(n--)
    {
        ll x;cin>>x;
        prv += x;
        M[prv%m]++;
    }
    ll Res = 0;
    Res += M[0];
    for(auto x:M)
    {
        Cnt += ( (x.S*(x.S-1))/2LL );
    }
    cout<<Res+Cnt<< "\n";



    return 0;
}


Measured memory_bytes: 4224
import java.util.*;
public class Main {
	static final Scanner stdin = new Scanner(System.in);
	static final int INF = Integer.MAX_VALUE/2, X = 0, Y = 1, D = 2, HEX = 6;
	static final int dx[][] = { {-1, 0, 1, 0,-1,-1}, {0,  1, 1, 1, 0,-1} };
	static final int dy[][] = { {-1,-1, 0, 1, 1, 0}, {-1,-1, 0, 1, 1, 0} };
	static int m, n;
	static int[][] d;
	public static void main(String[] args) {
		while(true){
			m = stdin.nextInt(); n = stdin.nextInt();
			if((m|n) == 0) break;
			d = new int[n][m]; for(int i = 0; i < n; ++i) Arrays.fill(d[i], INF);
			int s = stdin.nextInt();
			for(int i = 0; i < s; ++i) BFS(stdin.nextInt()-1, stdin.nextInt()-1, true);
			int ans = 0, t = stdin.nextInt();
			for(int i = 0; i < t; ++i) ans = Math.max(ans, BFS(stdin.nextInt()-1, stdin.nextInt()-1, false));
			System.out.println(ans);		
		}
	}
	static int BFS(int x, int y, boolean calcMinDist){
		int res = 0;
		Queue<int[]> q = new LinkedList<int[]>();
		boolean[][] closed = new boolean[n][m]; for(int i = 0; i < n; ++i) Arrays.fill(closed[i], false); 
		q.add(new int[]{x, y, 0});
		while(!q.isEmpty()){
			int[] e = q.poll();
			if(closed[e[Y]][e[X]]) continue;
			closed[e[Y]][e[X]] = true;
			if(d[e[Y]][e[X]] > e[D]){
				if(calcMinDist) d[e[Y]][e[X]] = e[D];
				res++;
			}
			for(int i = 0; i < HEX; ++i){
				int nx = e[X] + dx[e[Y]%2][i], ny = e[Y] + dy[e[Y]%2][i];
				if(0 <= nx && nx < m && 0 <= ny && ny < n) q.add(new int[]{nx, ny, e[D]+1});
			}
		}
		return res;
	}
}

Measured memory_bytes: 34464
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

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

long long lcm(long long a, long long b) {
	long long g = gcd(a, b);
	return a / g * b;
}

int t;

LL a, b, c, d;

int main() {
	cin >> t;
	REP(qqq, t) {
		cin >> a >> b >> c >> d;
		if (b > a || b > d ) {
			cout << "No" << endl;
			continue;
		}
		if (c >= b) {
			cout << "Yes" << endl;
			continue;
		}
		if (b - gcd(b, d) + (a%gcd(b, d)) > c) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i < n; ++i)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}


void solve() {
  // main coding
  int n,m; cin>>n>>m;
  vector<vector<int>> E(n);
  vector<int> indeg(n);
  int x,y;
  rep(_,m) {
    cin>>x>>y;
    x--; y--;
    E[x].push_back(y);
    indeg[y]++;
  }
  queue<int> q;
  vector<int> dp(n);
  rep(i,n) if(indeg[i]==0) q.push(i);
  while(!q.empty()) {
    int u=q.front(); q.pop();
    for(int v: E[u]) { // u to v:
      dp[v]=max(dp[v],dp[u]+1);
      indeg[v]--;
      if(indeg[v]==0) q.push(v);
    }
  }
  cout<<*max_element(dp.begin(),dp.end())<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int a[310][310];
signed main()
{
    int h, w, d;
    cin >> h >> w >> d;
    map<int, pair<int, int>> mp;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
            mp[a[i][j]] = {i, j};
        }
    }
    vector<int> v(h*w+1);
    for (int i = 1; i <= d; i++)
    {
        int c = i;
        v[c] = 0;
        while (1)
        {
            int tmp = c;
            c += d;
            if(c>h*w){
                break;
            }
            v[c] = v[tmp]+ abs(mp[c].first - mp[tmp].first) + abs(mp[c].second - mp[tmp].second);
        }
    }
    int q;
    cin >> q;
   // show(v);
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << v[r] - v[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}
class G{
	long long node;
	long long w;
	
};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	vector<long long>A(N);
	vector<long long>B(N);
	vector<long long>C(N);
	
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>B[i];
	for(int i=0;i<N;i++)cin>>C[i];
	
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());
	long long ans=0;
	for(int i=0;i<N;i++){
		long long low= lower_bound(A.begin(),A.end(),B[i])-A.begin();
		long long up = C.end()-upper_bound(C.begin(),C.end(),B[i]);
		ans+=(low*up);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String n = scan.nextLine();
    int len = n.length();
    int sum=0;
    char[] arr = new char[len];
    
    for(int i=0;i<len;i++){
      arr[i] = (n.charAt(i));
    }
    for(int i=0;i<len;i++){
      sum = sum + Character.getNumericValue(arr[i]);
    }
    if(sum%9 == 0 || n.equals("0")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
  
}

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

ll ans, n, l, i;

void upd(ll x, ll y) {
  if ((i = __gcd(x,y) > 1 ? 0 : inv_mod(x,y)) > 0)
    ans = min({ans, i * x - 1, (y-i) * x});
}

int main() {
  cin >> n; ans = n + (n % 2 == 0);
  for (ll d = 1; d * d <= n; d++)
    if (n % d == 0)
      upd(2 * d, n / d), upd(2 * n / d, d);
  cout << ans << "\n";
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>  
using namespace std;  
typedef long long ll;  
   
int main()  
{  
    int n;  
    cin >> n;  
    ll a, b, pr;  
    ll ans;  
    for(int i = 1;i <= n; i++)  
    {  
        cin >> a >> b;  
        pr = a * b;  
        ll t = sqrt(pr);  
        if(t * (t + 1) < pr)  
            ans = t * 2 - 1;  
        else if(t * t == pr)  
        {  
            if(a == b)  
                ans = (t - 1) * 2;  
            else  
                ans = (t - 1) * 2 - 1;  
        }  
        else  
            ans = (t - 1) * 2;  
        cout << ans << endl;  
    }  
    return 0;  
}  

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

int main(){
  int T;cin>>T;
  for (int i=0;i<T;++i){
    ll A, B, C, D;cin>>A>>B>>C>>D;
    if(A<B) {cout << "No" << endl;}
    else if(B>D){cout << "No" << endl;}
    else if(C>=B){cout << "Yes" << endl;}
    else{
      ll g=__gcd(D, B);
      if(B-g+A%g>C){cout << "No"<< endl;}
      else{cout << "Yes" << endl;}
    }
    
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define pii pair<int64_t,int64_t>
#define mp make_pair
#define whole(v) begin(v),end(v)
#define print(c,n) for(int64_t i=0;i<n;i++) cout << c[i] << " ";
#define MOD 1000000007
int n,m;
int start,ed;
vector<int> v[400005];
int visited[400005];
int dis[400005];
void bfs(int u){
	bool b=true;
	queue<int> q;
	visited[u] =1;
	q.push(u);
	dis[u] = 0;
	while(!q.empty() && b){
		auto it = q.front();
		q.pop();
		for(auto i : v[it]){
			if(!visited[i]){
				visited[i] = true;
				dis[i] = dis[it]+1;
				
				q.push(i);
			}
		}
	}
}
void solve(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		v[a].eb(b+n);
		v[a+n].eb(b+2*n);
		v[a+2*n].eb(b);
	}
	cin >> start >> ed;
	start--,ed--;
	for(int i=0;i<3*n+1;i++){
		dis[i] = INT_MAX;
		visited[i] = 0;
	}
	bfs(start);
// 	for(int i=0;i<3*n+1;i++){
// 		cout << dis[i] << " ";
// 	}
	if(dis[ed]==INT_MAX) cout << -1;
	else cout << dis[ed]/3;
}
int main(){
	
	solve();
}

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

int main(){
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;

    bool ans = false;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            ans = true;
            break;
        }
        
    }
    

    if (ans)
    {
        cout << "OK" << endl;
    } else
    {
        cout << "NG" << endl;
    }

    return 0;

}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	int a[n];
	for(long long i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int b[n]={0};
	int count=1;
	int p=a[0];
	b[0]=1;
	while(p!=2)
	{
		b[p]=1;
		p=a[p-1];
		count++;
		if(b[p]==1)
		{
			cout<<"-1";
			return 0;
		}
	}
	cout<<count;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int comp_int(const void *x, const void *y){
  return *(int*)x - *(int*)y;
}

int main(){
  int N, M, X, Y;
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  int x[N], y[M];
  for(int i = 0; i < N; i++) scanf("%d", &x[i]);
  for(int i = 0; i < M; i++) scanf("%d", &y[i]);
  qsort(x, N, sizeof(int), comp_int);
  qsort(y, M, sizeof(int), comp_int);
  int flag = 0;
  for(int i = X + 1; i < Y + 1; i++){
    if(x[N - 1] < i && i <= y[0]) flag = 1;
  }
  if(flag) printf("No War");
  else printf("War");
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int moves[100000];
int main(){
  int H, N;
  cin>>H>>N;
  for(int i=0; i<N ;i++){
    cin>>moves[i];
    H-=moves[i];
  }
  if (H<=0){
    cout<<"Yes";
  }else{
    cout<<"No";
  }



  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#include <cmath>
int main(void){
    // Your code here!
    int x,a,b;
    cin >> x >> a >> b;
    if(a>=b){
        cout << "delicious" << endl;
    }else if(b-a <= x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
}


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

using namespace std;
int dp[10][100001];

int main()
{
	int n, d, x;
	int p[11][11], diff[11][11][11];

	scanf("%d %d %d", &n, &d, &x);

	memset(diff, 0, sizeof(diff));

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

	
	for (int i = 0; i < d - 1; i++){
		memset(dp, 0, sizeof(dp));
		
		for (int j = i + 1; j < d; j++){
			for (int k = 0; k < n; k++){
				for (int l = 0; l + p[i][k] <= x; l++){
					dp[j][l + p[i][k]] = max(dp[j][l + p[i][k]], dp[j][l] + p[j][k] - p[i][k]);
				}
			}
		}

		x = x + dp[i + 1][x];
	}

	printf("%d\n", x);

	return (0);
}

Measured memory_bytes: 5108
import java.util.Scanner;

// 足し引きを繰り返すときは最大公約数を疑う
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] arr = new long[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        long res = arr[0];
        for(int i = 1; i < N; i++) {
            res = gcd(res, arr[i]);
        }
        System.out.println(res);

    }
    public static long gcd(long a, long b) {
        if(b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }
}


Measured memory_bytes: 60480
k = gets.to_i
queue = [1,2,3,4,5,6,7,8,9]

x = 1
k.times do
  x = queue[0]
  queue.shift
  queue.push(x*10 + x%10 - 1) if x%10 != 0
  queue.push(x*10 + x%10)
  queue.push(x*10 + x%10 + 1) if x%10 != 9
end

puts x

Measured memory_bytes: 16560
#include<iostream>
using namespace std;
int main(){
  int N, ans;
  int V[21],C[21];
  cin >> N;
  
  for(int i = 0; i < N; ++i) cin >> V[i];
  for(int i = 0; i < N; ++i) cin >> C[i];
  for(int i = 0; i < N; ++i) {
    if(V[i] > C[i]){ ans += V[i] - C[i];}
  }

  cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    static int N;
    static int M;
    static int count;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        int[] k = new int[M];
        int[][] s = new int[M][N];
        for(int i = 0; i < M; i++){
            for(int j = 0; j < N; j++)
                s[i][j] = -1; 
        }
        int[] p = new int[M];
        for(int i = 0; i < M; i++){
            k[i] = sc.nextInt();
            for(int j = 0; j < k[i]; j++){
                int n = sc.nextInt();
                s[i][n-1] = 0;
            }
        }
        for(int i = 0; i < M; i++)
            p[i] = sc.nextInt();
        sc.close();
        count = 0;
        int pos = 0;
        dfs(pos, s, p);
        System.out.println(count);
    }
    static void dfs(int pos, int[][] s, int[] p){
            switch0(pos, s);
            if(pos < N-1)
                dfs(pos+1, s, p);
            if(pos == N-1){
                /*for(int i = 0; i < M; i++){
                    for(int j = 0; j < N; j++)
                        System.out.print("s["+i+"]["+j+"]="+s[i][j]+" " );
                    System.out.println();
                }*/
                if(sumjudge(s,p))
                    count++;
            }
            
            switch1(pos, s);
            if(pos < N-1)
                dfs(pos+1, s, p);
            if(pos == N-1){
                /*for(int i = 0; i < M; i++){
                    for(int j = 0; j < N; j++)
                        System.out.print("s["+i+"]["+j+"]="+s[i][j]+" " );
                    System.out.println();
                }*/
                if(sumjudge(s,p))
                    count++;
            }
    }

    static void switch0(int j, int[][] s){
        for(int i = 0; i < M; i++) {
            if(s[i][j] != -1)
                s[i][j] = 0;
        }
        return;
    }
    static void switch1(int j, int[][] s){
        for(int i = 0; i < M; i++) {
            if(s[i][j] != -1)
                s[i][j] = 1;
        }
        return;
    }
    static boolean sumjudge(int[][] s, int[] p){
        for(int i = 0; i < M; i++){
            int sum = 0;
            for(int j = 0; j < N; j++){
                if(s[i][j] == 1){
                    sum += 1;
                }
            }
            if(sum % 2 != p[i])
                return false;
        }
        return true;
    }

}


Measured memory_bytes: 22100
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }
    return 0;
}


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

int v[101];

int main(){
  int a, b;
  bool ng;
  while(cin >> a >> b){
    v[a]++, v[b]++;
    if(a == 0){
      ng = false;
      if(v[1] % 2 == 0 || v[2] % 2 == 0){
	ng = true;
      }
      for(int i=3; i<101; ++i){
	if(v[i] % 2 == 1){
	  ng = true;
	}
      }
      if(ng){
	cout << "NG" << endl;
      } else { 
	cout << "OK" << endl;
      }
      memset(v, 0, sizeof(v));
    }
  }
    
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int ans=0,n,k,box[100005]={0},sum=0;;
        cin >> n >> k;
        if(n==0&&k==0)break;
        for(int i=0;i<k;i++){
            cin >> box[i];
            sum+=box[i];
            }
            ans=sum;
          for(int i=k;i<n;i++){
                cin >> box[i];
                sum+=box[i]-box[i-k];
                if(sum>ans)ans=sum;
        }
    cout << ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 1556
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







int main(){
	ll h, w, n, y, x;
	string s, t;
	cin >> h >> w >> n >> y >> x >> s >> t;
	ll yu = 1, yd = h, xl = 1, xr = w;
	for(ll i = n - 1; i >= 0; i--){
		if (t[i] == 'L') xr = min(xr + 1, w);
		if (t[i] == 'R') xl = max(xl - 1, 1LL);
		if (t[i] == 'U') yd = min(yd + 1, h);
		if (t[i] == 'D') yu = max(yu - 1, 1LL);

		if (s[i] == 'L') xl++;
		if (s[i] == 'R') xr--;
		if (s[i] == 'U') yu++;
		if (s[i] == 'D') yd--;

		if (yu > yd || xl > xr) {
			break;
		}
	}
	if (xl > x || x > xr || yu > y || y > yd) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1LL<<31)-1;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

const int MAX_N=1<<20;

int n;ll dat[2*MAX_N-1];

void init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++)dat[i]=INF;
}

void update(int k,ll a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
}

ll query(int a, int b, int k, int l, int r){
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return dat[k];
    else{
        ll vl=query(a,b,k*2+1,l,(l+r)/2);
        ll vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}

int main(){
    int m,q;
    cin>>m>>q;
    init(m);
    int x,y,z;
    ll u;
    REP(i,q){
        cin>>x;
        if(x==0){
            cin>>y>>u;
            update(y,u);
        }else{
            cin>>y>>z;
            cout<<query(y,z+1,0,0,n)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5152
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
 string a,b;
 cin>>a>>b;
 int flag=0;
 for(int i=0;i<a.length();i++){
 	if(a[i]!=b[i]){
 		flag=1;
 		break;
	 }
 }
 if(flag==1)
 cout<<"No\n";
 else
 cout<<"Yes\n";
}

Measured memory_bytes: 3628
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);

        int ans = 0;

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        for (int i = 1; i <= n; i++) {
            int x = 0;
            int d = i;
            while (d > 0) {
                x += d % 10;
                d /= 10;
            }
            if (a <= x && x <= b)
                ans += i;
        }

        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 23252
import java.util.Scanner;

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


		while(true){
			int x = scan.nextInt();
			int y = scan.nextInt();

			if(x==0 & y==0){break;}

			String result = x < y ? x + " " + y : y + " " + x;

			System.out.println(result);

		}

		scan.close();
	}
}

Measured memory_bytes: 36292
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
        int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        
        bool ok = false;
        if(nums[0]+nums[1] == nums[2]) ok = true;
        if(nums[1]+nums[2] == nums[0]) ok = true;
        if(nums[0]+nums[2] == nums[1]) ok = true;
        
        if(ok) Console.WriteLine("Yes");
        else Console.WriteLine("No");
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    
    int res = 0;

    RREP(i ,1, n) {
        res += (n-1) / i;
    }

    cout << res << endl;

    return 0;
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int n,m,i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

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

int n,m,dp[1000005][2][2];

int fn(int pos,int f,int q)
{
    if(pos==0)
    {
        return (f&&q);
    }
    int &z = dp[pos][f][q];
    if(z!=-1)return z;
    z=0;
    for(int i=0;i<10;i++)
    {
        z+= fn(pos-1,f|(i==0),q|(i==9));
        z%=MOD;

    }
    return z;
}

int main()
{
    sf(n);
    mem(dp,-1);
    if(n==1)
    {
        cout<<0<<endl;return 0;
    }

    int ans = fn(n,0,0);

    cout<<ans<<endl;
}


Measured memory_bytes: 81632
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    for (ll i = K + 1; i <= N; i++) {
        ans += (i - K) * (N / i);
        ans += max(ll(0), N % i - K + 1);
        // cout << i << ":" << ans << "\n";
    }

    if (K == 0) ans = N * N;

    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;


int main() {
	string S;
	cin >> S ;
	
	int aindex, cindex;
	if (S[0] == 'A') {
		aindex = 0;
		int cnt = 0;
		repk(i,2, S.length()-1) {
			if (S[i] == 'C') {
				cindex = i;
				cnt++;
			}
		}
		if (cnt == 1) {
			rep(i, S.length()) {
				if (i == aindex || i == cindex) {
					continue;
				}
				else if ((S[i] < 'a') || (S[i] > 'z')) {
					cout << "WA" << endl;
					return 0;
				}
			}
			cout << "AC" << endl;
			return 0;
		}
	}

	cout << "WA" << endl;
	return 0;
}


Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll n,i,j;
    cin>>n;
    ll p[n+2];
    for(i=0;i<n;i++) cin>>p[i];
    ll dp[n+2]={0};
    dp[0] = 0;
    for(i=1;i<n;i++)
    {
    	dp[i] = dp[i-1] + abs(p[i] - p[i-1]);
    	if(i-2>=0) dp[i] = min(dp[i] , dp[i-2] + abs(p[i] - p[i-2]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007


int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(3000, vector<char>(3000,0));
  rep(i, H) {
    rep(j, W) {
      cin >> S[i][j];
    }
  }

  vvi a(3000, vi(3000, 0)), hashx(3000, vi(3000, 0));
  rep(i, H) {
    int res = 0;
    rep(j, W) {
      if (S[i][j] == '#') {
        res++;
      }
      else if (S[i][j] == '.') {
        a[i][j] = res;
        hashx[i][res]++;
      }
    }
  }

  vvi b(3000, vi(3000, 0)), hashy(3000, vi(3000, 0));
  rep(j, W) {
    int res = 0;
    rep(i, H) {
      if (S[i][j] == '#') {
        res++;
      }
      else if (S[i][j] == '.') {
        b[i][j] = res;
        hashy[res][j]++;
      }
    }
  }
  int ans = 1;
  rep(i, H) {
    rep(j, W) {
      if (S[i][j] == '.') {
        int tmp = hashx[i][a[i][j]] + hashy[b[i][j]][j] - 1;
        ans = max(tmp, ans);
      }
    }
  }
  cout << ans << endl;

}





Measured memory_bytes: 150272
from heapq import heappop,heappush
n,k = (int(i) for i in input().split())
x,y,z,q = [],set(),[0]*n,[]
for _ in range(n):
	t,d = (int(i) for i in input().split())
	x.append((d,t-1))
x,p = sorted(x)[::-1],0
for i in range(k):
	p+=x[i][0]
	z[x[i][1]]+=1
	y.add(x[i][1])
	heappush(q,x[i])
ans,m,l,F = p+len(y)**2,k,len(y),1
while F:
	F = 0
	while q:
		d,t = heappop(q)
		if z[t]!=1:
			f,F,z[t] = 1,1,z[t]-1
			for j in range(m,n):
				if z[x[j][1]]==0:
					z[x[j][1]],m,f,l = 1,j,0,l+1
					p = p-d+x[j][0]
					break
			if f: F = 0
			else: ans = max(ans,p+l**2)
			break
print(ans)

Measured memory_bytes: 20336
#include<iostream>
#include<vector>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int w=1;
int h=1;
char map_data[21][21];
bool reacher[21][21];
int count=0;
char a;
int sx,sy;

void searth(int x,int y){
//cout<<w<<","<<y<<endl;
if(x<0 or x>w-1 or y<0 or y>h-1 or map_data[y][x]=='#' ){return;}


if (reacher[y][x]){return;}
//cout<<count;
reacher[y][x]=true;
count++;


searth(x+1,y);
searth(x,y+1);
searth(x-1,y);
searth(x,y-1);
//cout<<count;



}



int main(){

   

    while(w>0 and h>0){
        cin>>w>>h;
        if(w==0 and h==0){
            break;

        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>a;
                map_data[i][j]=a;
                
                reacher[i][j]=0;

                if(a=='@'){
                 
                    sx=j;
                    sy=i;
                } 
    
            }
        }
        //cout<<"sx"<<sx<<"sy"<<sy<<endl;
        //rep(i,h)rep(j,w)cout<<map_data[i][j];
        //rep(i,h)rep(j,w)cout<<reacher[i][j];
        searth(sx,sy);
        cout<<count<<endl;
        count=0;
        //rep(i,h)rep(j,w)cout<<map_data[i][j];
    }

   


    return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int dp[20200][2][2];
bitset<200200> bs[2];
int cs[2] = {9,4};
int main() {
	int n,m;
	scanf("%d %d ",&n,&m);
	memset(dp,0,sizeof(dp));
	m /= 1000;
	m -= n;
	if(m < 0) {printf("-1 -1 -1\n");return 0;}
	int cu = 0;
	bs[0].set(0);
	bs[1].set(0);
	for(int i=0;i<n;i++) {
		for(int j=m;j>=0;j--) {
			for(int k=0;k<2;k++) {
				if(j >= cs[k] && bs[cu][j-cs[k]]) {
					bs[1-cu].set(j);
					for(int l=0;l<2;l++) {
						dp[j][1-cu][l] = dp[j-cs[k]][cu][l];
					}
					dp[j][1-cu][k]++;
				}
			}
		}
		cu = 1-cu;
	}
	if(bs[cu][m]) {
		int a = dp[m][cu][0],b = dp[m][cu][1];
		int c = n-a-b;
		printf("%d %d %d\n",a,b,c);
	} else {
		printf("-1 -1 -1\n");
	}
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define v(T) vector<T>

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef vector<pii> vpii;
typedef set<int> si;
typedef multiset<int> msi;
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename ...Args>inline ostream& operator<<(ostream&o,const tiii&t)
{o<<get<0>(t)<<' '<<get<1>(t)<<' '<<get<2>(t);return o;}

int  L;

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

  cin >> L;

  int N = 0;
  vi Ns;
  int LL = L;
  while (LL) {
    int d = 1 << N;
    if (LL&d) {
      Ns.pb(N);
      LL -= d;
    }
    ++N;
  }
  v(tiii) anss;
  rep(i, N-1) {
    anss.pb(tiii(i+1, i+2, 0));
    anss.pb(tiii(i+1, i+2, 1<<i));
  }
  drep(i, sz(Ns)) {
    if (Ns[i]+1 != N) {
      anss.pb(tiii(Ns[i]+1, N, LL));
    }
    LL += (1<<Ns[i]);
  }
  cout << N << " " << sz(anss) << "\n";
  for (auto ans : anss) cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	string str;
	cin >> str;
	int n = str.length();
	int c[2] = { 0, };
	REP(i, n) c[str[i] - '0']++;
	cout << min(c[0], c[1]) * 2 << endl;
	return 0;
}

Measured memory_bytes: 512
// 最初の一行さえ決め打ちしてしまえば、あとは必然的に決まる
// 全探索2^10 * 9
#include<iostream>
#include<vector>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)
int di[5] = {0,0,1,-1,0};
int dj[5] = {1,-1,0,0,0};

int main(){
    int n;
    cin >> n;
    while(n-- > 0){
        vector<vector<int>> mat(10, vector<int>(10));
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                cin >> mat[i][j];
            }
        }
        for(int s = 0; s < 1<<10; s++){
            vector<vector<int>> cp = mat, ans(10, vector<int>(10, 0));
            for(int j = 0; j < 10; j++){
                if((s>>j)&1)    continue;
                ans[0][j] = 1;
                for(int k = 0; k < 5; k++){
                    int ni = 0+di[k], nj = j+dj[k];
                    if(inRange(ni,0,10)&&inRange(nj,0,10)){
                        cp[ni][nj] = 1-cp[ni][nj];
                    }
                }
            }
            for(int i = 1; i < 10; i++){
                for(int j = 0; j < 10; j++){
                    if(cp[i-1][j] == 0) continue;
                    ans[i][j] = 1;
                    for(int k = 0; k < 5; k++){
                        int ni = i+di[k], nj = j+dj[k];
                        if(inRange(ni,0,10)&&inRange(nj,0,10)){
                            cp[ni][nj] = 1-cp[ni][nj];
                        }
                    }
                }
            }
            bool valid = true;
            for(int j = 0; j < 10; j++) valid &= !cp[9][j];
            if(valid){
                // answer.
                for(int i = 0; i < 10; i++){
                    for(int j = 0; j < 10; j++){
                        cout << ans[i][j] << " \n"[j==9];
                    }
                }
                break;
            }
        }
    }
    return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  if (x >= 30) {cout << "Yes\n";}
  else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename Int>
class LazySegmentTree {
private:
    int N;
public:
    vector<Int> base, lazy;
    // sz: size of array size
    LazySegmentTree(int sz) {
        N = 1;
        while (N < sz) N *= 2;
        base.resize(2 * N - 1, 0);
        lazy.resize(2 * N - 1, 0);
    }
    
    // propagate k-th lazy node [l, r)
    // inner state does not change if repeating this >= 1 times
    void propagate(int k, int l, int r) {
        base[k] += lazy[k] * (r - l);
        if(r - l > 1) {
            lazy[2 * k + 1] += lazy[k];
            lazy[2 * k + 2] += lazy[k];
        }
        lazy[k] = 0;
    }
    
    // update
    void add(int a, int b, Int x, int k=0, int l=0, int r=-1) {
        if(r == -1) r = N;
        propagate(k, l, r);
        
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += x;
            propagate(k, l, r);
        }
        else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            base[k] = base[2 * k + 1] + base[2 * k + 2];
        }
    }
    
    // query
    ll get_sum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r == -1) r = N;
        propagate(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return base[k];
        Int vl = get_sum(a, b, 2 * k + 1, l, (l + r) / 2);
        Int vr = get_sum(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, Q;
    cin >> N >> Q;
    LazySegmentTree<ll> lst(N);
    rep(i, Q) {
        int q;
        cin >> q;
        if(q == 0) { // add
            int s, t, x;
            cin >> s >> t >> x;
            s--;
            lst.add(s, t, x);
        }
        else { // getsum
            int s, t;
            cin >> s >> t;
            s--;
            cout << lst.get_sum(s, t) << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 7084