akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ll n; cin >> n;
	map<string, ll> a;
	fo(i, n)
	{
		string s; cin >> s;
		a[s]++;
	}
	cout << "AC x " << a["AC"] << "\n" << "WA x " << a["WA"] << "\n" << "TLE x " << a["TLE"] << "\n" << "RE x " << a["RE"];

}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}

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

string S, T;
int length;
int answer = 0;

bool isKakko( char c ) {
  char list[7] = "(){}[]";
  for ( int i = 0; i < 6; i++ ) if ( c == list[i] ) return true;
  return false;
}

int iwiCheck() {
  bool ok = false;
  int index = 0;
  string IWI = T;
  if ( ( index = IWI.find( "iwi" ) ) != string::npos ) {
    IWI.erase( index, 3 );
    ok = true;
  }
  if ( ok == false ) return false;
  for ( string ::iterator it = IWI.begin(); it != IWI.end(); it++ ) {
    if ( *it == 'i' || *it == 'w' ) return false;
  }
  return true;
}

bool check() {
  int l = T.size();
  int h = l/2;
  if ( l % 2 == 1 && isKakko( T[h] ) ) return false;
  for ( int i = 0; i < h; i++ ) {
    bool test = false;
    test = test || T[i] == '(' && T[l-i-1] == ')';
    test = test || T[i] == ')' && T[l-i-1] == '(';
    test = test || T[i] == '{' && T[l-i-1] == '}';
    test = test || T[i] == '}' && T[l-i-1] == '{';
    test = test || T[i] == '[' && T[l-i-1] == ']';
    test = test || T[i] == ']' && T[l-i-1] == '[';
    test = test || !isKakko( T[i] ) && T[i] == T[l-i-1];
    if ( !test ) return false;
  }
  return true;
}

void dfs( int i ) {
  if ( i >= length ) {
    if ( check() && iwiCheck() ) {
      answer = max( answer, (int)T.size() );
    }
    return;
  }
  dfs( i+1 );
  T.push_back( S[i] );
  dfs( i+1 );
  T = T.substr( 0, T.size()-1 );
}

int main( void ) {
  cin >> S;
  length = S.size();
  dfs( 0 );
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 0
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a.back()==b.front()&&b.back()==c.front()){
    cout <<"YES\n";
  }else{
    cout <<"NO\n";
  }
}


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

#define x first 
#define y second 

typedef pair<double,double> pdd;

bool inTriangle(pdd o, pdd tri0, pdd tri1, pdd pts) {
	pdd a, b, c;
	a.x = tri0.x - o.x;
	a.y = tri0.y - o.y;
	b.x = tri1.x - o.x;
	b.y = tri1.y - o.y;
	c.x = pts.x - o.x;
	c.y = pts.y - o.y;

	double s, t;
	t = (c.x * a.y - c.y * a.x) / (b.x * a.y - b.y * a.x);
	s = (c.x * b.y - c.y * b.x) / (b.y * a.x - b.x * a.y);

	if(s >= 0 && t >= 0 && s + t <= 1)
		return true;
	return false;
}

int main() {
	int n;
	cin >> n;
	for(int t = 0; t < n; t++) {
		pdd in[5];
		for(int i = 0; i < 5; i++) {
			cin >> in[i].x >> in[i].y;
		}

		bool flag;
		flag = inTriangle(in[0], in[1], in[2], in[3]) ^ inTriangle(in[0], in[1], in[2], in[4]);
		if(flag)
			cout << "OK" << endl;
		else
			cout << "NG" << endl;
	}
}

Measured memory_bytes: 1220
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    dp = [0] * (n + 1)  # dp[n] :: n円を引き出す最小の手数

    for i in range(1, n + 1):
        # 1円引き出す
        dp[i] = dp[i - 1] + 1
        # 6**n円引き出す
        j = 6
        while j <= i:
            dp[i] = min(dp[i], dp[i - j] + 1)
            j *= 6
        # 9**n円引き出す
        j = 9
        while j <= i:
            dp[i] = min(dp[i], dp[i - j] + 1)
            j *= 9
    print(dp[n])
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 68780
/* Author : bitshar */
// #pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
ll MOD = 1e9+7;
 
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=e; i>=s; i--)
#define ln "\n"
#define sp " "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define NEGINF -1e18
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
#define dbg(x) cout << #x << " = " << x << ln 
#define all(x) x.begin(), x.end()
 
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln
 
#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6
 
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;
 
void solve() {
 
    ll n,k;
    cin >> n >> k;
    cout << min(n%k,k-n%k) << ln;
}
 
int main() {
    
    #ifdef DEBUG_MODE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    fio;
    int t=1;
    //cin >> t;
    while(t--) {
        solve();
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,k;cin>>n>>k;
    vector<ll>p(n);
    vector<ll>inc(n);
    rep(i,n){
        cin>>p[i];
        if(i>0&&p[i]>p[i-1])inc[i]=inc[i-1];
        else inc[i]=inc[i-1]+1;
    }
    set<ll>st;
    priority_queue<ll,vector<ll>,greater<ll> >q;
    priority_queue<ll>pq;
    rep(i,k){
        st.insert(p[i]);
        q.push(p[i]);
        pq.push(p[i]);
    }
    bool f=0;
    ll ans=!(inc[k-1]==inc[0]);
    f=inc[k-1]==inc[0];
    REP(i,k,n){
        while(st.find(q.top())==st.end()){
            q.pop();
        }
        while(st.find(pq.top())==st.end()){
            pq.pop();
        }
        if(p[i-k]==q.top()&&pq.top()<p[i]);
        else if(inc[i]==inc[i-k+1])f=1;
        else{
            ans++;
        }
        st.erase(p[i-k]);
        st.insert(p[i]);
        pq.push(p[i]);
        q.push(p[i]);
    }
    if(f){
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 15840
def isprime(n):
  for i in range(2, n + 1):
    if n % i == 0:
      return False
    if i * i > n:
      break
  return True
n = int(input())
s = []
for i in range(2, 55556):
  if isprime(i) and i % 5 == 1:
    s.append(i)
    if len(s) == n:
      break
print(*s)


Measured memory_bytes: 2940
def count(n, y):
    for i in range(n + 1):
        for j in range(n + 1 - i):
            k = n - i - j
            total = i * 10000 + j * 5000 + k * 1000
            if total == y:
                return [i, j, k]                
    return [-1, -1, -1]


(n, y) = map(int, input().split())
ans = count(n, y)
print("{} {} {}".format(ans[0], ans[1], ans[2]))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int 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;
}

inline ll gl()
{
	ll 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;
}

int a[10], b[10], x[10], c[50004][10], tot, xx, yy;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n, m, k = 0;
	n = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi();
	for (int i = 1; i <= n; i+=1) b[i] = gi();
	for (int i = 1; i <= n; i+=1) x[i] = i;
	do
	{
		++tot;
		for (int i = 1; i <= n; i+=1) c[tot][i] = x[i];
	} while (next_permutation(x + 1, x + 1 + n));
	for (int i = 1; i <= tot; i+=1)
	{
		bool fl = true;
		for (int j = 1; j <= n; j+=1)
		{
			if (c[i][j] != a[j]) {fl = false; break;}
		}
		if (fl) xx = i; 
		bool fll = true;
		for (int j = 1; j <= n; j+=1)
		{
			if (c[i][j] != b[j]) {fll = false; break;}
		}
		if (fll) yy = i; 
	}
	cout << abs(xx - yy) << endl;
	return 0;
}



Measured memory_bytes: 1792
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;







//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        x: usize,
        t: usize,
    }



    println!("{}", ((n+x-1)/x)*t);
}


Measured memory_bytes: 2160
#include <iostream>
using namespace std;
int main(){
	char str1[200010] = {0}, str2[200010] = {0};
	int n = 0;
	cin >> str1 >> str2;
	for(int i = 0; i < 200010; i++){
		if(str1[i] != str2[i]){
			n++;
		}
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 4012
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
ans = 0

def janken(a):
    if a == 'r':
        return p
    elif a == 's':
        return r
    else:
        return s

for i in range(n):
    if i < k:
        ans += janken(t[i])
    elif i >= k and t[i] != t[i-k]:
        ans += janken(t[i])
    else:
        t[i] = ''
print(ans)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
class abcd
{
    public:
    ll day;
    ll vas;
};
bool fun1(abcd x,abcd y)
{
    return x.vas<y.vas;
}
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    ll n;
    cin>>n;
    ll a[n][3];
    rep(i,0,n)
    {
        rep(j,0,3)
        {
            cin>>a[i][j];
        }
    }
    ll dp[n][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];

    rep(i,1,n)
    {
        dp[i][0] = a[i][0] + max( dp[i-1][1] , dp[i-1][2] );
        dp[i][1] = a[i][1] + max( dp[i-1][0] , dp[i-1][2] );
        dp[i][2] = a[i][2] + max( dp[i-1][1] , dp[i-1][0] ); 
    }
    cout<< max( dp[n-1][0] , max( dp[n-1][1] , dp[n-1][2] ));
}


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

#define int long long

const int N = 1e2 + 10;
int n, ans, ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ar[i];
	
	for (int i = 1; i < n - 1; i++) {
		int tmp[3] = {ar[i - 1], ar[i], ar[i + 1]};
		sort(tmp, tmp + 3);
		if (tmp[1] == ar[i])
			ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(lambda: 0)
S = input()
for i in range(4):
  d[S[i]] += 1
keys = list(d.keys())
values = list(d.values())
if len(keys) == 2 and values[0] == 2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3316
N = int(input(''))
dict = {}
for i in range(N):
    S = input('')
    if S in dict:
        dict[S] += 1
    else:
        dict[S] = 1
M = max(dict.values())
out = [j for j in dict.keys() if dict[j] == M]
out.sort()
for k in out:
    print(k)

Measured memory_bytes: 32096
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	int n;
	cin >> n;
	long long ans = 0;
	for(int i = 1; i <= n; i++) if(i % 3 != 0 && i % 5 != 0) ans += i;
	cout << ans;
}      

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int N, K;
int d1;
int snacks[101];
int members[101];
int d;
int tmp;
int ans;

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

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

using namespace std;

const int MAXN = 1001;
const int MOD = 1e9 + 7;

int memo[MAXN][MAXN],R,C;
char table[MAXN][MAXN];

int dp(int i,int j){
	if(i >= R || j >= C)return 0;
	if(i == R - 1 && j == C - 1)return 1;
	if(table[i][j] == '#')return 0;
	if(memo[i][j] != -1)return memo[i][j];
	return memo[i][j] = (dp(i + 1,j) + dp(i,j + 1) ) % MOD;
}

int main(){
	#ifdef EVAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	cin >> R >> C;
	for(int i = 0; i < R; i++){
		for(int j = 0; j < C; j++){
			cin >> table[i][j];
		}
	}
	memset(memo,-1,sizeof(memo));
	cout << dp(0,0) << '\n';
}

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

int main() {
    ll q;
    cin>>q;
    rep(i,q){
        string a,b;
        cin>>a>>b;
        VV dp(a.size()+1,V(b.size()+1,0));
        rep(j,a.size()){
            rep(k,b.size()){
                if(a[j]==b[k]){
                    dp[j+1][k+1]=dp[j][k]+1;
                }else{
                    dp[j+1][k+1]=max(dp[j+1][k],max(dp[j][k+1],dp[j][k]));
                }
            }
        }
        cout<<dp[a.size()][b.size()]<<endl;
    }
}



Measured memory_bytes: 10808
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long M, long[] a, long[] b, long[] k, long g) {
    auto dp = new long[][](M + 1, 2 ^^ N);
    foreach (i; 0 .. M + 1)
        foreach (p; 0 .. 2 ^^ N)
            dp[i][p] = long.max;
    
    dp[0][0] = 0;
    foreach (i; 0 .. M) {
        foreach (p; 0 .. 2 ^^ N) {
            if (dp[i][p] == long.max)
                continue;
            
            dp[i + 1][p] = min(dp[i + 1][p], dp[i][p]);
            dp[i + 1][p | k[i]] = min(dp[i + 1][p | k[i]], dp[i][p] + a[i]);
        }
    }

    return dp[M][g] == long.max ? -1 : dp[M][g];
}


void main() {
    auto l1 = readln.chomp.split.map!(to!long).array;
    long N = l1[0];
    long M = l1[1];

    auto g = goalPattern(N);

    auto a = new long[](M);
    auto b = new long[](M);
    auto k = new long[](M);
    foreach (i; 0 .. M) {
        auto l2 = readln.chomp.split.map!(to!long).array;
        a[i] = l2[0];
        b[i] = l2[1];
        k[i] = readln.chomp.split.map!(to!long).array.keyPattern;
    }

    solve(N, M, a, b, k, g).writeln;
}


long keyPattern(long[] c) {
    long key;
    foreach (ci; c) {
        key += 2 ^^ (ci - 1);
    }
    return key;
}

long goalPattern(long N) {
    return 2 ^^ N - 1;
}


Measured memory_bytes: 38780
a,b,k=map(int,input().split())

lis=[]
for i in range(a, min(a+k,b+1)):
    lis.append(i)
for i in range(max(a,b-k+1), b+1):
    lis.append(i)


lis=list(set(lis)) #重複除去
lis.sort()
for i in lis:
    print(i)
    


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int a;
double b;
int main(){
    cin>>a;
    for(int i=a;i>=0;i--){
        b=sqrt(i);
        if(int(sqrt(i))==b){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll a[200100], b[200100];

int main() {
	cin >> n;
	ll ans = 0;
	bool ok = 1;
	ll MIN = INF;
	rep(i, n) {
		cin >> a[i] >> b[i];
		ans += a[i];
		if (a[i] > b[i])MIN = min(MIN, b[i]);
		if (a[i] != b[i])ok = false;
	}
	if (ok)cout << 0 << endl;
	else cout << ans - MIN << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  vector<int> count(1000000);
  REP(i, n){
    count[a[i]]++;
    if (a[i] > 0) count[a[i]-1]++;
    count[a[i] + 1]++;
  }
  int ans = 0;
  REP(i, 1000000){
    ans = max(count[i], ans);
  }
cout << ans << endl;
}



Measured memory_bytes: 7436
#include <bits/stdc++.h>
#define LL              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)

#define pb              push_back
#define ff              first
#define ss              second
#define mp              make_pair

#define ON(n,i)         (n|(1<<i))
#define OFF(n,i)        (n&(~(1<<i)))
#define CHK(n,i)        (n&(1<<i))

#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)

#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())

#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )

#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("out.txt","w",stdout)

using namespace std;

LL f[26];
char s[100005];

#define mod 1000000007

LL power( LL a, LL b ){
    LL r = 1;
    while(b){
        if(b%2==1) r = (r*a)%mod;
        b = b / 2;
        a = (a*a)%mod;
    }
    return r;
}

int main(){

    LL n;
    SL(n);
    scanf(" %s",s);
    LL ans = 0;
    for( LL i = 0 ; s[i] ; i++ ){
        LL sum = 1;
        FOR(j,0,25)
            if( j!=(s[i]-'a') ) sum = (sum*(f[j]+1))%mod;
            //cout<<sum<<endl;
        ans = ( ans + sum + mod )%mod;
        f[ s[i]- 'a' ]++;
    }
    //ans = (ans-1+mod)%mod;
    cout<<ans<<endl;

return 0;}




Measured memory_bytes: 384
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
1 < (I=(0..25).select{C[_1]==0}).size and S.each {|s;z|
  I.each {|i| if i!=(z||=i); s[z]<s[i] ? z = i+s[z]=0 : s[i]=0 end }
}
L,M,N = [-1]*27,5,5
def calc(d,n)
  s,x = S[d],0
  n = D-d  if n > D-d
  t = (0..25).map {s[_1] > 0 ? C[_1]*(d-L[_1])*n+s[_1] : 0}
  i = (0..25).max_by(M){t[_1]}.max_by {|i|
    0 == (c=t[i])*(n-1) and next c
    l,L[i] = L[i],d
    c += calc(d+1,n-1) >> 5
    L[i] = l
    x < c ? x=c : c
  }
  ((x>0 ? x : t[i]) << 5) + i
end
D.times { p 1 + i=calc(_1,N)&31; L[i]=_1 }

Measured memory_bytes: 15344
N = int(input())
lst_a = list(map(int, input().split()))
cnt_4times = 0
cnt_odd = 0
cnt_even = 0
ans = "No"


for a in lst_a:
    if a % 4 == 0:
        cnt_4times += 1
    elif a % 2 != 0:
        cnt_odd += 1
    else:
        cnt_even += 1


if cnt_even != 0:
    cnt_odd += 1


if cnt_odd <= cnt_4times + 1:
    ans = "Yes"


print(ans)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    sort(a, a+4);
    if(a[0]==a[1] && a[1]!=a[2] && a[2]==a[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  int a, min_abs = INF, minus_cnt = 0;
  i64 ans = 0;
  REP(i, n) {
    cin >> a;
    min_abs = min(min_abs, abs(a));
    ans += abs(a);
    if (a < 0) minus_cnt++;
  }
  if (minus_cnt % 2 != 0) {
    ans -= 2 * min_abs;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}
/*
100 100
9
10 20 70 150 50 275 325 100 9000
*/


Measured memory_bytes: 384
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
enum R_Way {
	R_Left,
	R_Front,
	R_Right,
	R_Back,

	R_Dummy,
};
struct Dice {
	int tp;
	int bo;
	int no;
	int so;
	int ea;
	int we;
	Dice(int tp_, int bo_, int no_, int so_, int ea_, int we_) :
		tp(tp_), bo(bo_), no(no_), so(so_), ea(ea_), we(we_) {

	}
	Dice(vector<int>pips_) {

	}

	Dice() {
		tp = 1;
		bo = 6;
		no = 2;
		so = 5;
		ea = 4;
		we = 3;
	}

	int rotate(const R_Way way) {
		switch (way) {
		case R_Right: {
			int c = tp;
			tp = we;
			we = bo;
			bo = ea;
			ea = c;
		}
					  break;
		case R_Back: {
			int c = tp;
			tp = so;
			so = bo;
			bo = no;
			no = c;
		}
					 break;
		case R_Left: {
			int c = tp;
			tp = ea;
			ea = bo;
			bo = we;
			we = c;
		}
					 break;
		case R_Front: {
			int c = tp;
			tp = no;
			no = bo;
			bo = so;
			so = c;
		}
					  break;
		default:
			assert(false);
		}
		return tp;
	}
	int rotate(const int way) {
		return rotate(static_cast<R_Way>(way));
	}
	void spin(const int  clockwise) {
		if (!clockwise) {

			rotate(R_Way::R_Left);
			rotate(R_Way::R_Back);
			rotate(R_Way::R_Right);
		}
		else {

			rotate(R_Way::R_Left);
			rotate(R_Way::R_Front);
			rotate(R_Way::R_Right);
		}
	}
	int hash()const {
		return tp + we * 6 + no * 36;
	}
};
int geteast(int top, int south) {
	map<pair<int, int>, int>mp;
	mp[make_pair(1, 2)] = 3;
	mp[make_pair(1, 3)] = 5;
	mp[make_pair(2, 3)] = 1;
	mp[make_pair(2, 4)] = 6;
	bool rev = false;
	if (top >= 4) {
		rev = !rev; top = 7 - top;
	}
	if (south >= 4) {
		rev = !rev; south = 7 - south;
	}
	if (top > south) {
		rev = !rev; swap(top, south);
	}
	return mp[make_pair(top, south)];
}

int gettop(int south, int east) {
	return geteast(south, east);
}
int getsouth(int east, int top) {
	return 7 - geteast(top, east);
}
bool operator==(const Dice&l, const Dice&r) {
	return l.hash() == r.hash();
}
vector<vector<int>>rotate_l(vector<vector<int>>vs) {
	vector<vector<int>>afvs(vs.size(), vector<int>(vs.size()));
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			afvs[2 - j][i] = vs[i][j];
		}
	}
	return afvs;
}
vector<vector<int>>rotate_r(vector<vector<int>>vs) {
	vs = rotate_l(vs);
	vs = rotate_l(vs);
	vs = rotate_l(vs);
	return vs;
}
vector<vector<int>>rotate_2(vector<vector<int>>vs) {
	vs = rotate_l(vs);
	vs = rotate_l(vs);
	return vs;
}


int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		Dice dice;
		map<string, int>mp;
		mp["north"] = 3;
		mp["south"] = 1;
		mp["west"] = 0;
		mp["east"] = 2;
		while (N--) {

			string st; cin >> st;
			dice.rotate(mp[st]);

		}
		cout << dice.tp << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n;
  char a[100],b[100];
  int ai=0;
  int bi=0;
  scanf("%d",&n);
  scanf("%s %s",a,b);
  for(int i=0;i<2*n;i++){
    if(i%2==0){
      printf("%c",a[ai]);
      ai++;
    }
    else{
      printf("%c",b[bi]);
      bi++;
    }
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = (1<<30);

void Warshall_Floyd (vector<vector<ll>>& distance){
    ll n = distance.size();
    for(ll i = 0; i < n; i++) distance[i][i] = 0;
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < n; j++){
            for(ll k = 0; k < n; k++){
                distance[j][k] = min(distance[j][i]+distance[i][k],distance[j][k]);
            }
        }
    }
}

ll Factorial (ll n){
    ll res = 1;
    for(ll i = 0; i < n; i++) res *= i+1;
    return res;
}

int main(){
    ll n,m,r;
    cin >> n >> m >> r;
    vector<ll> g(r);
    for(ll i = 0; i < r; i++){
        ll d;
        cin >> d;
        d--;
        g[i] = d;
    }
    vector<vector<ll>> dist(n,vector<ll>(n,INF));
    for(ll i = 0; i < m; i++){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        dist[a][b] = min(c,dist[a][b]);
        dist[b][a] = min(c,dist[b][a]);
    }
    Warshall_Floyd(dist);
    ll ans = INF;
    for(ll i = 0; i < Factorial(r); i++){
        ll can = 0;
        for(ll i = 0; i < r-1; i++){
            can += dist[g[i]][g[i+1]];
        }
        if(ans > can) ans = can;
        next_permutation(g.begin(),g.end());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3952
n,w_limit = map(int,input().split())

item_ls = [[0,0]]
total_value = 0
for i in range(n):
    cost, value = map(int,input().split())
    item_ls.append([cost, value])
    total_value += value


dp = [[float('inf')] * (total_value+1) for _ in range(n+1)]
dp[0][0] = 0
for i in range(1,n+1):
    item_cost, item_value = item_ls[i]
    for sum_value in range(0,total_value+1):
        if sum_value-item_value >= 0:
            dp[i][sum_value] = min(dp[i][sum_value], dp[i-1][sum_value-item_value] + item_cost)
        dp[i][sum_value] = min(dp[i][sum_value], dp[i-1][sum_value])

ans = 0
for value, cost in enumerate(dp[n]):
    if cost <= w_limit:
        ans = max(ans, value)
print(ans)


Measured memory_bytes: 328528
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};

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

int main(){

    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll W = B - A + 1;
    ll C_OK = B / C - (A - 1) / C;
    ll D_OK = B / D - (A - 1) / D;
    ll CD_OK = B / (lcm(C, D)) - (A - 1) / (lcm(C, D));
    cout << W - C_OK - D_OK + CD_OK << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
/*
 * memo!!
 * "while" is less memory than "for".
 */
int main()
{
    int i = 1;
    while(i<=9)
    {
        int j = 1;
        while(j<=9)
        {
            cout << i << "x" << j  << "=" << i*j << endl;
            j++;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 3056
import java.util.Scanner;

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

		for(int i=0; i<S.length()-1; i++) {
			if(S.charAt(i)==S.charAt(i+1)) {
				System.out.println("Bad");
				return;
			}
		}
		System.out.println("Good");
	}
}


Measured memory_bytes: 23252
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int, p: "List[int]"):
    p.sort()
    ret = sum(p[:K])
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62636
N, K = map(int,input().split())
H = []
for _ in range(N):
    H.append(int(input()))

H.sort()
ans = H[N-1] - H[0]
for i in range(N-K+1):
    min_h = H[K+i-1] - H[i]
    if min_h < ans:
        ans = min_h

print(ans)

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	string s1 , s2 ;
	cin>>s1>>s2 ;
	int x , y ;
	cin>>x>>y ;
	string s ;
	cin>>s ;
	if(s == s1)
		x-- ;
	else
		y-- ;
	return cout<<x<<" "<<y<<"\n" , 0 ;
}		

Measured memory_bytes: 256
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll mn=a[0], ans = 0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1])
            ans += a[i-1]-a[i], a[i]=a[i-1];
    }
    cout<<ans<<"\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> height(N);
  for(int i = 0; i < N; i++) {
    cin >> height.at(i);
  }
  int64_t ans = 0;
  int64_t max = height.at(0);
  for(int i = 1; i < N; i++) {
    if(height.at(i) < max) {
      ans += max - height.at(i);
    }
    else {
      max = height.at(i);
    }
  }
  cout << ans << endl;                           
}

Measured memory_bytes: 4784
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  auto c = new int[](9);
  foreach (ai; a) {
    if (ai >= 3200) c[8]++;
    else c[ai/400]++;
  }

  auto b = c[0..8].count!"a>0";
  write(b == 0 ? 1 : b, " ", b+c[8]);
}


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

int main() {
    vector<int> v;
    int n;
    for (int i = 0;i < 3;i++) {
        cin >> n;
        v.push_back(n);
    }
    sort(v.rbegin(), v.rend());

    cout << v[0]*10 + v[1] + v[2] << endl;

}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    int N;
    cin >> N;
    for(int i = N; i <= 999; i++){
        if(i/100 == (i%100/10) && i/100 == i%10) {
            cout << i << endl;
            break;
        }

    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class D {
	vvi g;
	int n;
	vi col;
	vi from;
	deque<int> sf;
public:
	D()
	{
		cin >> n;
		g.resize(n);
		from.resize(n, -1);
		col.resize(n, -1);

		REP(i, n - 1)
		{
			int a, b;
			cin >> a >> b;
			a--; b--;
			g[a].PB(b);
			g[b].PB(a);
		}
	}

	void dfs_path(int v, int frm)
	{

		from[v] = frm;

		if (v == n - 1)
			return;

		for (int nxt : g[v])
			if (nxt != frm)
				dfs_path(nxt, v);
	}


	void dfs(int v, bool p, int frm)
	{
		col[v] = p;

		for (int nxt : g[v])
			if (nxt != frm && col[nxt] != (!p) )
				dfs(nxt, p, v);
	}

	void solve()
	{
		dfs_path(0, -1);

		int v = n - 1;
		while (v != 0)
		{
			sf.push_front(v);
			v = from[v];

		}
		sf.push_front(0);

		bool p = false;
		while (!sf.empty())
		{
			if (!p)
			{
				col[sf.front()] = p;
				sf.pop_front();
			}

			else
			{
				col[sf.back()] = p;
				sf.pop_back();
			}

			p = !p;
		}


		dfs(0, 0, -1);
		dfs(n - 1, 1, -1);

		int cnt0, cnt1;
		cnt0 = cnt1 = 0;

		REP(i, n)
		{
			if (col[i] == 0)
				++cnt0;
			else
				++cnt1;
		}

		if (cnt0 > cnt1)
			cout << "Fennec" << endl;
		else
			cout << "Snuke" << endl;
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 9344
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 505
#define P 998244353
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, k, c[MAXN][MAXN];

int main()
{
    scanf("%d", &k);
    if(k==1)
    {
        printf("1\n1\n");
        return 0;
    }
    n=(k+3)/4*2;
    for(rint i=0; i<n; ++i)
        for(rint j=0; j<n; ++j)
        {
            if(j&1) c[i][j]=(i+j)%n+n;
            else c[i][j]=(i+j)%n;
            if(c[i][j]>=k) c[i][j]-=n;
        }
    printf("%d\n", n);
    for(rint i=0; i<n; ++i)
    {
        for(rint j=0; j<n; ++j) printf("%d ", c[i][j]+1);
        printf("\n");
    }
    return 0;
}

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

bool solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    int a, b;
    vector<vector<int>> G(N);
    for ( int i = 0; i < N-1; i++ ) {
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    function<ll(int,int)> dfs = [&](int v, int p) {
        if ( p != -1 && G[v].size() == 1 ) {
            return A[v];
        } else {
            // x = 2*A - sum(ch),  x >= 0, A <= sum(ch)
            ll s = 0;
            for ( int u : G[v] ) {
                if ( u == p ) continue;
                ll y = dfs(u, v);
                if ( y < 0 ) return -1LL;
                if ( y > A[v] ) return -1LL;
                s += y;
            }
            if ( A[v] > s ) return -1LL;
            ll x;
            if ( p == -1 && G[v].size() == 1 ) {
                x = A[v] - s;
            } else {
                x = 2*A[v] - s;
            }
            if ( x < 0 ) return -1LL;
            return x;
        }
    };
    
    bool ans = (dfs(0,-1) == 0LL);
    return ans;
}

int main() {
    string ans = solve() ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  int n;
  cin >> n;

  int a[n+1];  
  for(int i=0;i<n;i++)
    cin >> a[i];

  int64_t sum = 0;
  int c = 1;
  int64_t ans0 = 0, ans1 = 0;
  
  for(int i=0;i<n;i++) {
    sum += a[i];
    if(sum * c < 1) {
      ans0 += 1 - sum * c;
      sum = c;
    }
    c *= -1;
  }

  c = -1;
  sum = 0;
  for(int i=0;i<n;i++) {
    sum += a[i];
    if(sum * c < 1) {
      ans1 += 1 - sum * c;
      sum = c;
    }
    c *= -1;
  }

  if(ans0 < ans1)
    cout << ans0 << endl;
  else
    cout << ans1 << endl;
  
  return 0;
}


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

using namespace std;

int main()
{
    vector<int> a(10000,0);
    for(int i=0;i<10000;i++)
    {
        cin >> a.at(i);
        if(a.at(i)==0)
        {
            return(0);
        }        
        cout << "Case " << i+1 << ": " << a.at(i) << endl;

    }
    return(0);
}


Measured memory_bytes: 3064
# 解説動画視聴

s = input()

a = [0]*(len(s)+1)
if len(s) == 1:
    print(1)
    exit()
for i in range(len(s)):
    if s[i] == '<':
        a[i+1] = max(a[i+1],a[i]+1)
for i in range(len(s)-1,-1,-1):
    if s[i] == '>':
        a[i] = max(a[i],a[i+1]+1)

print(sum(a))

Measured memory_bytes: 29120
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define inf -(1LL<<51)
#define int long long
typedef long long ll;
#define ld long double
#define N 701


int32_t main()
{
    IOS;
   
    
    int a[4];
    for(int i = 0;i < 4;i++)
    {
        cin>>a[i];
    }
    sort(a,a+4);
    if(a[0] == 1 and a[1] == 4 and a[2] == 7 and a[3] == 9)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

struct Team
{
	int solved, penalty, no;
	bool operator < (const Team &a) const
	{
		if(solved != a.solved) return solved > a.solved;
		if(penalty != a.penalty) return penalty < a.penalty;
		return no > a.no;
	}
	int compareTo(Team a)
	{
		if(solved != a.solved) 
		{
			if(solved > a.solved) return 1;
			else return -1;
		}
		if(penalty != a.penalty) 
		{
			if(penalty < a.penalty) return 1;
			else return -1;
		}
		return 0;
	}
} team[50];

int wrongCnt[50][10];

int main(void)
{
	int m, t, p, r;
	while(scanf("%d %d %d %d", &m, &t, &p, &r), m)
	{
		memset(wrongCnt, 0, sizeof(wrongCnt));
		for(int i=0;i<t;i++) 
		{
			team[i].solved = team[i].penalty = 0;
			team[i].no = i;
		}

		for(int i=0;i<r;i++)
		{
			int mk, tk, pk, jk;
			scanf("%d %d %d %d", &mk, &tk, &pk, &jk);
			tk--, pk--;
			if(jk == 0) 
			{
				team[tk].penalty += mk + wrongCnt[tk][pk] * 20;
				team[tk].solved++;
			}
			else wrongCnt[tk][pk]++;
		}

		sort(team, team + t);
		for(int i=0;i<t;i++)
		{
			int e = i;
			while(e < t && team[i].compareTo(team[e]) == 0) e++;
			if(i) printf(",");
			for(int j=i;j<e;j++)
			{
				if(j != i) printf("=");
				printf("%d", team[j].no + 1);
			}
			i = e - 1;
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1056
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007LL;
vector<int> G[100000];
int dp[100000][11];
int v[100000], d[100000], c[100000];
void solve(int x, int dist, int t) {
	if (dp[x][dist] != -1) return;
	dp[x][dist] = t;
	if (dist == 0) return;
	solve(x, dist - 1, t);
	for (int to : G[x]) {
		solve(to, dist - 1, t);
	}
}
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}
	memset(dp, -1, sizeof(dp));
	for (int i = Q - 1; i >= 0; i--) {
		solve(v[i], d[i], i);
	}
	for (int i = 0; i < N; i++) {
		if (dp[i][0] == -1) cout << 0 << endl;
		else cout << c[dp[i][0]] << endl;
	}
}

Measured memory_bytes: 12024