akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int cnt = 1;
		while (true) {
			int w = in.nextInt();
			if(w == 0) return;
			int n = in.nextInt();

			int[] value = new int[n];
			int[] weight = new int[n];

			for (int i=0; i<n; i++) {
				String[] s = in.next().split(",");
				value[i] = Integer.parseInt(s[0]);
				weight[i] = Integer.parseInt(s[1]);
			}

			int[][] dp = new int[n+1][w+1];

			for (int i=0; i<n; i++) {
				for (int j=0; j<=w; j++) {
					if (j + weight[i] <= w) {
						dp[i+1][j+weight[i]] = Math.max(dp[i+1][j], dp[i][j] + value[i]);
					}
					dp[i+1][j] = Math.max(dp[i+1][j], dp[i][j]);
				}
			}

			out.println("Case "+(cnt++)+":");

			int ans1 = -1, ans2 = -1;
			for (int i=0; i<=w; i++) {
				if (ans1 < dp[n][i]) {
					ans1 = dp[n][i];
					ans2 = i;
				}
			}

			out.println(ans1);
			out.println(ans2);
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 38400
a, v = [int(i) for i in input().split()]
b, w = [int(i) for i in input().split()]
t = int(input())

l = b-a
v_l = v-w
if l > 0:
  if l <=( v_l * t):
    print("YES")
  else:
    print("NO")
else:
  if -l <= (v_l * t):
    print("YES")
  else:
    print("NO")


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

using namespace std;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  string str;
  cin >> str;
  
  int found=0;
  
  if(str[0]=='A'|| str[1]=='A' || str[2]=='A') found++;
  
  if(str[0]=='B' || str[1]=='B' || str[2]=='B') found++;
  
  if(found == 2) printf("Yes");
  else printf("No");
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

void swap(int *x,int *y){
    int data;
    *x=data;
    *x=*y;
    *y=data;
}
int main(void){
    int X,Y,Z;
    cin>>X>>Y>>Z;
    swap(X,Y);
    swap(X,Z);
    cout<<X<<' '<<Y<<' '<<Z<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

const int Cmax=40;

int d[Cmax][Cmax];
int k[3][Cmax];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,c;
    cin>>n>>c;
    for(int i=1;i<=c;i++)
        for(int j=1;j<=c;j++)
            cin>>d[i][j];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            int t;
            cin>>t;
            k[(i+j)%3][t]++;
        }
    int ans=1e18;
    int r[3];
    #define FOR(x) for(r[x]=1;r[x]<=c;r[x]++)
    FOR(0)FOR(1)FOR(2)
    {
        if(r[0]==r[1]||r[0]==r[2]||r[1]==r[2])
            continue;
        int t=0;
        for(int i=0;i<3;i++)
            for(int j=1;j<=c;j++)
                t+=d[j][r[i]]*k[i][j];
        //cout<<r[0]<<r[1]<<r[2]<<" -> "<<t<<"\n";
        ans=min(ans,t);
    }
    cout<<ans;
}


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

int main() {
  int N;
  cin >> N;
  int i = 0;
  while(i < N){
    string s;
    cin >> s;
    if(s == "Y"){
      cout << "Four" << endl;
      break;
    }
    i = i + 1;
}
  if(i == N){
      cout << "Three" << endl;}
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

long long  MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    long long ans = 1;
    for (int i = 1; i <= N; i++) {
        ans = (ans*i)%MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = gets.chomp
key = "keyence"

if s[0] != "k" || s[-1] != "e"
    puts s =~ /#{key}/ ? "YES" : "NO"
else
    i = 0
    i += 1 while i < 8 && s[i] == key[i]
    j = 0
    j += 1 while j < 8 && s[-j] == key[-j]

    puts i + j >= 8 ? "YES" : "NO"
end

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
    int n, x;
    string s;
    cin >> n;
    list<int> l;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s[0] == 'i') {
            cin >> x;
            l.push_front(x);
        }
        else if (s[6] == 'F') {
            l.pop_front();
        }
        else if (s[6] == 'L') {
            l.pop_back();
        }
        else {
            cin >> x;
            for (list<int>::iterator it = l.begin();it != l.end();it++) {
                if (*it == x) {
                    l.erase(it);
                    break;
                }
            }
        }
    }
    for (list<int>::iterator it = l.begin();it != l.end();it++) {
        if (it != l.begin()) cout << " ";
        cout << *it;
    }
    cout << endl;
}


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

// プロセスを表す構造体
typedef struct pp{
    string name;
    int t;
}P;

// グローバル変数
const int len = 100005;
P Q[len];
int head, tail, n;

void enqueue(P x){
    // tailが指す場所にxを追加し、要素が増えたのでtailをincrement
    // lenで割って余りを求める = キューが満杯でないかどうか
    Q[tail] = x;
    tail = (tail + 1) % len;
}

P dequeue(){
    // headが指す先頭の要素を返す．要素を一つ取り出したのでheadをincrement
    // lenで割って余りを求める = キューが満杯でないかどうか
    P x = Q[head];
    head = (head + 1) % len;
    return x;
}

int min(int a, int b){
    // 最小値を返す
    return a < b ? a : b;
}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    cin >> n >> q;

    // 全プロセスを順にqueueに追加（準備）
    for(int i = 1; i <= n; i++){
        cin >> Q[i].name >> Q[i].t;
    }
    head = 1;
    tail = n + 1;

    // シミュレーション開始
    while(head != tail){
        u = dequeue();
        c = min(q, u.t); // qまたは，必要な時間(u.t)だけ処理を行う
        u.t -= c; // 残り時間を計算
        elaps += c; // 経過時間を加算

        if(u.t > 0){
            // 処理が完了していなければqueueに追加
            enqueue(u);
        }else{
            cout << u.name << " " << elaps << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()

int main(){
  ll A,B,N;cin>>A>>B>>N;
  ll tmp = min(B-1,N);
  cout << ll(A*tmp/B)-A*ll(tmp/B) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

int pow_(int a, int x) {
    int val = 1;
    for(int i = 0; i < x; ++i) val *= a;
    return val;
}

int main() {
    while(true) {
        int N, M;
        cin >> N >> M;
        if(!N && !M) break;

        vector<vector<int> > goal(3);
        for(int i = 0; i < 3; ++i) {
            int n;
            cin >> n;
            while(n--) {
                int idx;
                cin >> idx;
                goal[i].push_back(idx-1);
            }
        }

        vector<vector<int> > field(3);
        for(int i = 0; i < N; ++i) {
            field[0].push_back(i);
        }

        int turn = 0;
        int prev_from = -1;
        int prev_to = -1;
        while(true) {
            if(field == goal) {
                break;
            }
            ++turn;
            for(int from = 0; from < 3; ++from) {
                if(field[from].size() == 0) continue;
                const int glass = field[from].back();
                const int to_1 = from-1;
                const int to_2 = from+1;
                if(!(from == prev_to && to_1 == prev_from) && to_1 >= 0 && (field[to_1].size() == 0 || field[to_1].back() < glass)) {
                    field[to_1].push_back(glass);
                    field[from].pop_back();
                    prev_from = from;
                    prev_to = to_1;
                    break;
                }
                else if(!(from == prev_to && to_2 == prev_from) && to_2 < 3 && (field[to_2].size() == 0 || field[to_2].back() < glass)) {
                    field[to_2].push_back(glass);
                    field[from].pop_back();
                    prev_from = from;
                    prev_to = to_2;
                    break;
                }
                else {
                }
            }
        }
        const int MAXTURN = pow_(3, N) - 1;
        turn = min(turn, MAXTURN-turn);
        if(turn > M) turn = -1;
        cout << turn << endl;
    }
    return 0;
}

Measured memory_bytes: 908
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int A = GetInt();
		int B = GetInt();
		int C = GetInt();
		Console.WriteLine(Math.Max(0, C - (A - B)));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

int main(){
	string S,T;
	cin >> S >> T;
	int loop,ans=0;
	for(loop=0;loop<3;loop++){
		if(S[loop]==T[loop]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s, t;


int main()
{
	cin >> n;
	int a[100001] = {};
	a[0] = 0;
	for (int i = 1; i < 10;i++)
		a[i] = 1;
	for (int i = 100; i < 1000; i++)
		a[i] = 1;
	for (int i = 10000; i < 100000; i++)
		a[i] = 1;

	int64_t sum = 0;
	rep(i, n+1)
		sum += a[i];
	cout << sum << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll N,M;
    cin>>N>>M;
    vpii ba(M);
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        ba[i].first=a;
        ba[i].second=b;
    }
    sort(ba.begin(),ba.end());
    vpii cut;
    rep(i,0,M){
        if(cut.empty()){
            cut.push_back(ba[i]);
        }
        else{
            bool c=false;
            rep(j,0,cut.size()){
                if(cut[j].second>ba[i].first){
                    chmin(cut[j].second,ba[i].second);
                    c=true;
                    break;
                }
            }
            if(!c){
                cut.push_back(ba[i]);
            }
        }
    }
    cout<<cut.size()<<endl;
    return 0;
}




Measured memory_bytes: 4024
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int t; cin>>t;while(t--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

int main (void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	lli x, k, d;
	
	cin>>x>>k>>d;
	x=abs(x);
	
	if (x/d>=k)
		cout<<x-d*k<<endl;
		
	else
	{
		k=k-x/d;
		x=x%d;
		k=k%2;
		x=x-k*d;
		cout<<abs(x)<<endl;
	}

	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int M = stdIn.nextInt();
		if(N - M > 0){
			System.out.println("No");
		}
		else{
			System.out.println("Yes");
		}
		stdIn.close();
	}
}

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

using namespace std;

int main(){
    long long N,M,C;
    cin>>N>>M>>C;
    vector<long long> B(M);
    for(auto& x:B)cin>>x;

    long long ans=0;

    for(long long i=0;i<N;++i){
        long long now=C;
        vector<long long > tmp(M);
        for(long long k=0;k<M;++k){
            cin>>tmp[k];
            now+=tmp[k]*B[k];
        }
        if(now>0)ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
/**/
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compile and get accepted.
 *      ____________
 *     /            \
 *    /  /\      /\  \
 *   /  /  \    /  \  \
 *   \                /
 *    \     \___/    /
 *     \____________/
 */
const long long mod = 1000000007;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	long long a,b;
	cin>>a>>b;
	if(a <= 0 && b >= 0){
		cout<<"Zero\n";
		return 0;
	}
	if(a > 0){
		cout<<"Positive\n";
		return 0;
	}
	if((b - a + 1)&1){
		cout<<"Negative\n";
		return 0;
	}
	cout<<"Positive\n";
	return 0;
}
/**/


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

int main()
{
	int a[6];
	for (int i = 0; i < 6; i++) cin >> a[i];
	cout << accumulate(a, a + 6, 0) - *min_element(a, a + 4) - *min_element(a + 4, a + 6) << endl;

	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(a>0 || c>0){
        c -= b;
        if(c <= 0){
            cout << "Yes";
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No";
            break;
        }
    }
    return 0;
}

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

// aoj 2313
class max_flow {
public:
    struct edge {
        int to, cap, rev;
        edge(int t, int c, int r) : to(t), cap(c), rev(r) {}
    };
private:
    vector<vector<edge>> g;
    vector<int> lev, itr;

    void bfs(int s) {
        int n = g.size();
        lev = vector<int>(n, -1);
        queue<int> q;
        lev[s] = 0;
        q.push(s);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (edge& e : g[v]) {
                if (e.cap > 0 && lev[e.to] < 0) {
                    lev[e.to] = lev[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (; itr[v] < (int)g[v].size(); ++itr[v]) {
            edge &e = g[v][itr[v]];
            if (e.cap > 0 && lev[v] < lev[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    max_flow(int n) {
        g = vector<vector<edge>>(n);
    }
    void add_edge(int frm, int to, int cap, bool isdir = true) {
        g[frm].push_back(edge(to, cap, g[to].size()));
        g[to].push_back(edge(frm, isdir ? 0 : cap, (int)g[frm].size() - 1));
    }

    int run(int s, int t, int lim = INT_MAX) {
        int ret = 0;
        bfs(s);
        while (true) {
            bfs(s);
            if (lev[t] < 0) return ret;
            itr = vector<int>(g.size());
            int f;
            while ((f = dfs(s, t, lim - ret)) > 0) ret += f;
            if (lim == ret) return ret;
        }
    }

};

int main() {
    int v, e;
    cin >> v >> e;
    max_flow mf(v);
    for (int i = 0; i < e; ++i) {
        int s, t, c;
        cin >> s >> t >> c;
        mf.add_edge(s, t, c);
    }
    cout << mf.run(0, v - 1) << "\n";
    return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = 1234567890;
    if (a <= b)ans = min(ans, b - a);
    if (-a <= b)ans = min(ans, b + a + 1);
    if (a <= -b)ans = min(ans, -b - a + 1);
    if (-a <= -b)ans = min(ans, -b + a + 2);
    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> ae(n+1,0);
  vector<int> aw(n+1,0);
  vector<int> a(n,0);
  rep(i,n){
    if(s[i]=='W') a[i]=1;
    else a[i]=0;
    aw[i+1]=aw[i]+a[i];
  }
  rep(i,n){
    if(s[i]=='E') a[i]=1;
    else a[i]=0;
    ae[i+1]=ae[i]+a[i];
  }
  vector<int> ans(n);
  rep(i,n) ans[i]=aw[i]+ae[n]-ae[i+1];
  sort(ans.begin(), ans.end());
  cout << ans[0] << endl;
}

Measured memory_bytes: 8268
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define mp     make_pair
#define cont   continue
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 1e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll a[MAXN],b[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
ll n,m,k,cnt,sum,ans,mx,mn=INF;
bool y;

void freopen(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}
vector<int>dp(3);

void solve(){
	cin>>n;
    for(int i=1;i<=n;i++){
        vector<int>c(3),newdp(3,0);
        for(int j=0;j<3;j++){
            cin>>c[j];
        }
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k){
                    newdp[k]=max(newdp[k],dp[j]+c[k]);
                }
            }
        }
        dp=newdp;
    }
    cout<<max(dp[0],max(dp[1],dp[2]));
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




Measured memory_bytes: 2560
n = int(input())
p = [0] + list(map(int, input().split()))
num = 0
for i in range(1, n + 1):
    if i == n:
        if i == p[i]:
            num += 1
            break
    if i == p[i]:
        num += 1
        p[i], p[i + 1] = p[i + 1], p[i]

print(num)

Measured memory_bytes: 13880
#include<cstdio>
#include<cstring>
#include<algorithm>
const int MAXN=110;
long long w[5][MAXN],tot[5],base;

int main(){
	long long n,c;scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++){
		int x,v;scanf("%d%d",&x,&v);
		if(i==1)
			base=x;
		w[x-base][++tot[x-base]]=-v;
	}
	std::sort(w[0]+1,w[0]+tot[0]+1);
	std::sort(w[1]+1,w[1]+tot[1]+1);
	std::sort(w[2]+1,w[2]+tot[2]+1);
	std::sort(w[3]+1,w[3]+tot[3]+1);
	for(int i=0;i<4;i++)
		for(int j=1;j<=n;j++)
			w[i][j]+=w[i][j-1];
	long long ans=1;
	for(int i=0;i<=tot[0];i++)
		for(int j=0;j<=tot[1];j++)
			for(int k=0;k<=tot[2];k++)
				for(int l=0;l<=tot[3];l++){
					if(i*base+j*(base+1ll)+k*(base+2ll)+l*(base+3ll)>c)
						continue;
					ans=std::min(ans,(long long)w[0][i]+w[1][j]+w[2][k]+w[3][l]);
				}
	printf("%lld\n",-ans);
	return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b; cin >> a >> b;

  if(b%a==0) cout << a+b << endl;
  else cout << b-a << endl;
  
  return 0;
}


Measured memory_bytes: 3616
n, m = map(int, input().split())
can_open = []
cost = []
for _ in range(m):
    a, b = map(int, input().split())
    cost.append(a)
    it = map(int, input().split())
    x = 0
    for c in it:
        x += 1 << (c-1)
    can_open.append(x)

n_bit = 1 << n
INF = 10**18
dp = [[INF]*n_bit for _ in range(m+1)]
dp[0][0] = 0

# 配る
for i in range(m):
    for j in range(n_bit):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

        if (j | can_open[i]) <= n_bit:
            dp[i+1][j | can_open[i]
                    ] = min(dp[i+1][j | can_open[i]], dp[i+1][j]+cost[i])

print(dp[-1][-1] if dp[-1][-1] != INF else -1)


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

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

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

  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int h = h2 - h1;
  int m = h*60 + m2 - m1;
  cout << m - k << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int rui(int a, int b) {
    if(b == 0) {
        return 1;
    }
    return rui(a, b - 1) * a;
}
int main() {
    int X;
    cin >> X;
    int beki[1100];
    rep(i,0,1100){
        beki[i]=0;
    }
    beki[1] = 1;
    rep(i, 2, X) {
        int v = i * i;
        while(v < 1100) {
            beki[v] = 1;
            v *= i;
        }
    }
    rep(i, 0, X) {
        int t = X - i;
        if(beki[t] == 1) {
            cout << t << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)

typedef unsigned long ul;
using namespace std;

int n;
int t;
int min0 = 100000;

int main() {
    cin >> n >> t;
    for (int i = 0; i < n; ++i) {
        int c, t0;
        cin >> c >> t0;
        if (t0 <= t) {
            min0 = min(min0, c);
        }
    }
    if (min0 == 100000) {
        cout << "TLE";
    }else {
        cout << min0;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
#define MAXN 200010
#define INF 0x3f3f3f3f
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
int Bdj[MAXN],Vb[MAXN*2],nxtb[MAXN*2],cb;
void Add(int u,int v)
{
	cb++;Vb[cb]=v,nxtb[cb]=Bdj[u];Bdj[u]=cb;
}
int n,rt,s,ans;
int dep[MAXN],fa[MAXN],e[MAXN][2],lon[MAXN],vis[MAXN];
void dfs(int u)
{
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=fa[u])
		{
			dep[V[i]]=dep[u]+1;
			fa[V[i]]=u;
			dfs(V[i]);
		}
}
int dis[MAXN];
queue<int>Q;
void bfs()
{
	dis[s]=0;
	vis[s]=1;
	Q.push(s);
	while(!Q.empty())
	{
		int u=Q.front();Q.pop();
		for(int i=Bdj[u];i;i=nxtb[i])
			if(!vis[Vb[i]])
			{
				dis[Vb[i]]=dis[u]+1;
				if(dis[Vb[i]]<dep[Vb[i]])
				{
					vis[Vb[i]]=1;
					Q.push(Vb[i]);
				}
			}
	}
}
int check(int u,int v)
{
	if(dep[u]<dep[v]) swap(u,v);
	int k=dep[u]-dep[v];
	if(k==0) return fa[u]!=fa[v];
	if(k==1) return fa[u]!=v;
	if(k==2) return fa[fa[u]]!=v;
	return 1;
}
void Clear()
{
	for(int i=1;i<=n;i++)
		Adj[i]=Bdj[i]=vis[i]=lon[i]=0;
	c=cb=0;
	ans=0;
}
void Read(int &x)
{
	x=0;
	char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
}
int main()
{
//	freopen("coalesce.in","r",stdin);
//	freopen("coalesce.out","w",stdout);
	scanf("%d%d%d",&n,&s,&rt);
	int u,v,flag=0;
	for(int i=1;i<n;i++)
	{
		Read(e[i][0]);
		Read(e[i][1]);
	}
	for(int i=1;i<n;i++)
	{
		Read(u);Read(v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	if(s==rt)
	{
		printf("0\n");
		return 0;
	}
	dfs(rt);
	for(int i=1;i<n;i++)
		if(check(e[i][0],e[i][1]))
			lon[e[i][0]]=lon[e[i][1]]=1;
		else Add(e[i][0],e[i][1]),Add(e[i][1],e[i][0]);
	bfs();
	for(int i=1;i<=n;i++)
		if(vis[i]&&lon[i])
		{
			flag=1;
			break;
		}
		else if(vis[i])
			ans=max(ans,dep[i]);
	if(flag) printf("-1\n");
	else printf("%d\n",ans*2);
}

Measured memory_bytes: 19200
#include<stdio.h>
int main(void){
  int n,k,x,y,sum=0;
  scanf("%d %d %d %d",&n,&k,&x,&y);
  if((n-k)>0)
  sum = (k*x)+(n-k)*y;
  else
    sum= n*x;
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,1,1,0,0,-1,-1,-1};
const vector<ll> dy{1,0,-1,1,-1,1,0,-1};


int main() {
    ll H,W;
    cin >>H>>W;
    vector<vector<bool>>S(H+2,vector<bool>(W+2));

    rep2(i,H){
        rep2(j,W){
            char c;
            cin>>c;
            if(c=='#'){
                S[i][j]=1;
            }
        }
    }

    rep2(i,H){
        rep2(j,W){
            if(S[i][j]==1){
                cout<<"#";
            }else{
                ll cnt=0;
                rep(k,8){
                    ll ny=i+dy[k];
                    ll nx=j+dx[k];
                    cnt+=S[ny][nx];
                }
                cout<<cnt;
            }
        }
        cout<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#include <tuple>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef pair<int,int> P;
typedef tuple<int,int,int,int> T;
const int MAX=1e3+4;


int main(){
	int N,M;
	cin>>N>>M;
	lli x[MAX][3];
	rep(i,N)rep(j,3)cin>>x[i][j];
	
	lli ans=0;
	rep(p,2)rep(q,2)rep(r,2){
		lli v[MAX];
		rep(i,N){
			lli xa=pow(-1,p)*x[i][0];
			lli ya=pow(-1,q)*x[i][1];
			lli za=pow(-1,r)*x[i][2];
			v[i]=xa+ya+za;
		}
		sort(v,v+N,greater<lli>());
		lli sum=0;
		rep(i,M)sum+=v[i];
		ans=max(ans,sum);
	}
	cout<<ans;
}

Measured memory_bytes: 256
X = int(input())
red = 0
if X ==2:
    red = 1
while red == 0:
    red = 1
    for i in range(2,X):
        #print('i='+str(i)+' X='+str(X)+' X%i='+str(X % i)+' red ='+str(red))
        red =min(red, X % i)
    if red ==0:
        X = X+1
    
print(X)


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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 2000011

signed main()
{
  int n;
  cin >> n;
  lli sum = 0;
  for (int i = 1; i <= n; i++)
  {
    if (i % 3 != 0 && i % 5 != 0)
    {
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
    int main() {
        long l, n, x1[222222], x2[222222],sum1[222222],sum2[222222], ans = 0, i, j;
        scanf("%ld%ld", &l, &n);
        x1[0] = 0;
        x2[0] = 0;
        for (i = 1; i <= n; i++) {
            scanf("%ld", &x1[i]);
            x2[n - i+1] = l - x1[i];
        }
        sum1[0] = 0;
        sum2[0] = 0;
        for (i = 1; i <= n; i++) {
            sum1[i] = sum1[i - 1] + x1[i];
            sum2[i] = sum2[i - 1] + x2[i];
        }
        long p;
        for (i = 0; i <= n; i++) {
            if (i == 0) {
                p = x1[n];
                if (p > ans)
                    ans = p;
            }
            else if (i == n) {
                p = x2[n];
                if (p > ans)
                    ans = p;
            }
            else if (n - i > i) {
                p = x1[n - i] + x2[i];
                p += (sum1[n - i - 1] - sum1[n - i * 2 - 1]) * 2 + sum2[i] * 2 - x2[i];
                if (p > ans)
                    ans = p;
                p = x1[n - i] + x2[i];
                p += (sum1[n - i ] - sum1[n - i * 2]) * 2 + sum2[i-1] * 2 - x1[n-i];
                if (p > ans)
                    ans = p;
            }
            else if (n - i < i) {
                p = x1[n - i] + x2[i];
                p += (sum2[i - 1] - sum2[i * 2 - 1-n]) * 2 + sum1[n-i] * 2 - x1[n-i];
                if (p > ans)
                    ans = p;
                p = x1[n - i] + x2[i];
                p += (sum2[i] - sum2[i * 2-n]) * 2 + sum1[n-i - 1] * 2 - x2[i];
                if (p > ans)
                    ans = p;
            }
            else {
                p = x1[n - i] + x2[i];
                p += sum1[n - i - 1] * 2 + sum2[i] * 2 - x2[i];
                if (p > ans)
                    ans = p;
                p = x1[n - i] + x2[i];
                p += sum1[n - i]* 2 + sum2[i - 1] * 2 - x1[n - i];
                if (p > ans)
                    ans = p;
            }
        }
        printf("%ld\n", ans);
        return 0;
    }

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<vector<int>> a(n, vector<int> (2,0));
	int minval = 100000;
	for (int i = 0; i < n; i++) {
		cin >> a[i][0];
		minval = min(minval, a[i][0]);
	}

	bool finflg = false;
	int total = 0;
	vector < vector<int>> b(n, vector<int>(2, 0));
	b = a;
	vector < vector<int>> c(n, vector<int>(2, 0));
	c = a;

	sort(b.begin(), b.end());

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (c[i][0] == b[j][0]) {
				a[i][0] = j + 1;
			}
		}
	}

	while (1) {
		int i = 0;
		for (i = 0; i < n; i++) {
			if (a[i][1] == 0) {
				break;
			}
			if (i == n - 1) { finflg = true; }
		}
		if (finflg == true) { break; }


		vector<int> subar;
		subar.push_back(c[i][0]);
		int j;
		j= a[i][0]-1;
		if (j != 0 && j+1!=a[j][0]) {
			while (subar[0] !=c[j][0]) {
				subar.push_back(c[j][0]);
				j = a[j][0]-1;
			}
			sort(subar.begin(), subar.end());

			int cand1= accumulate(subar.begin(), subar.end(), 0) + subar[0] * (subar.size() - 2);
			int cand2 = accumulate(subar.begin(), subar.end(), 0) + subar[0] + (subar.size() + 1)*minval;
			total += min(cand1, cand2);
		}

		for (i = 0; i < n; i++) {
			for (j = 0; j < subar.size(); j++) {
				if (c[i][0] == subar[j]) {
					a[i][1] = 1;
				}
			}
		}

	}
	cout << total << endl;
}


Measured memory_bytes: 3344
n = int(input())
a_list = list(map(int,input().split()))
dp = [[0] * 2 for _ in range(n-1)]
dp[0][0] = a_list[0] + a_list[1]
dp[0][1] = -1*(a_list[0] + a_list[1])

for i in range(1,n-1):
    dp[i][0] = max(dp[i-1][0] + a_list[i+1] , dp[i-1][1] + a_list[i+1])
    dp[i][1] = max(dp[i-1][0] - a_list[i+1] -2*a_list[i], dp[i-1][1] - a_list[i+1]+2*a_list[i])
    
print(max(dp[n-2][0] ,dp[n-2][1]))

Measured memory_bytes: 25200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int  a;
    string b;
    cin >> a >> b;
    int x = 0,y = 0;
    reverse(b.begin(),b.end());
    int i;
    int pr = 1;
    for(i = 0;b[i] != '.';i++){
        y += (b[i] - '0')*pr;
        pr *= 10;
    }
    i++;
    pr = 1;
    for(;i < b.size();i++){
        x += (b[i] - '0')*pr;
        pr *= 10;
    }

    //cout << i << endl;
 
    //x -= y;
    cout << a*x + (a*y)/100 << endl;
    //cout << x <<" " << y <<  endl;

    
    //cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

int a[3][3];
bool o[3][3];

bool chk_row(int i){
	rep(j, 3) if(!o[i][j]) return false;
	return true;
}

bool chk_col(int j){
	rep(i, 3) if(!o[i][j]) return false;
	return true;
}

bool chk_diag1(){
	rep(i, 3) if(!o[i][i]) return false;
	return true;
}

bool chk_diag2(){
	rep(i, 3) if(!o[i][3-i-1]) return false;
	return true;
}

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

	rep(i, 3) rep(j, 3) cin >> a[i][j];
	rep(i, 3) rep(j, 3) o[i][j] = false;

	int n;
	cin >> n;
	
	rep(i, n){
		int b;
		cin >> b;

		rep(i, 3) rep(j, 3){
			if(a[i][j] == b){
				o[i][j] = true;
				break;
			}
		}
	}

	if(chk_row(0)){
		cout << "Yes" << endl;
		return 0;
	}

	if(chk_row(1)){
		cout << "Yes" << endl;
		return 0;
	}

	if(chk_row(2)){
		cout << "Yes" << endl;
		return 0;
	}

	if(chk_col(0)){
		cout << "Yes" << endl;
		return 0;
	}

	if(chk_col(1)){
		cout << "Yes" << endl;
		return 0;
	}

	if(chk_col(2)){
		cout << "Yes" << endl;
		return 0;
	}

	if(chk_diag1()){
		cout << "Yes" << endl;
		return 0;
	}

	if(chk_diag2()){
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;

string s;
int l = -1, r = -1;

void solve() {
	int w = min(3, (int)s.size());
	for (int i = 0; i <= s.size() - w; i++) {
		map<char, int> freq;
		for (int j = 0; j < w; j++) {
			freq[s[i + j]] += 1;
		}
		for (map<char, int>::iterator itr = freq.begin(); itr != freq.end(); itr++) {
			if (itr->second >= 2) {
				if (w == 3) {
					l = i + 1;
					r = i + 3;
				} else {
					l = i + 1;
					r = i + 2;
				}
				break;
			}
		}
		if (l != -1) {
			break;
		}
	}
	cout << l << " " << r << endl;
}

int main() {
	cin >> s;
	solve();
}


Measured memory_bytes: 512
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    print(a+b+c+9*max(a,b,c))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
n, k =  map(int,input().split())

p = list(map(int,input().split()))
counter_li = []
first = 0
for i in range(k):
    first+=p[i]
counter_li.append(first)
for i in range(1,len(p)-k+1):
    counter_li.append(counter_li[i-1]+ p[i+k-1] - p[i-1])
print(max(counter_li)/2+k/2)


Measured memory_bytes: 24804
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int[] cost = new int[n];
		int[] time = new int[n];
		for(int i=0; i<n; i++) {
			cost[i] = sc.nextInt();
			time[i] = sc.nextInt();
		}
		int ans=0;
		for(int i=0; i<n; i++) {
			if(time[i]<=t && cost[ans]>cost[i]) {
				ans=i;
			}
		}
		if(time[ans]<=t) {
			System.out.println(cost[ans]);
		}else {
			System.out.println("TLE");
		}
	}
}

Measured memory_bytes: 23124
<?php
list($a, $b) = ints();
for($i = 0; $i < 100000; $i++){
    if($i*8 >= $a * 100 && $i*8 <= $a * 100 + 99 && $i * 10 >= $b * 100 && $i * 10 <= $b * 100 + 99){
        echo $i;
        exit;
    }
}
echo -1;

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}

Measured memory_bytes: 4856
#include <cstdio>

int main(){
    unsigned long long int k, a, b;
    scanf("%lld %lld %lld", &k, &a, &b);

    unsigned long long int n = 1;

    if(k == 1){
        n++;
    }else if(a >= b){
        n += k;
    }else if(a > k - 1){
        n += k;
    }else if(b - a <= 2){
        n += k;
    }else{
        unsigned long long x = (k - (a - 1)) / 2;
        unsigned long long y = k - 2 * x;
        n = (b - a) * x + y + 1;
    }
    
    printf("%lld\n",n);

    return 0;
}

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

#define ll long long
#define pii pair<int, int>
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> H(N);
    vector<bool> A(N-1, false);

    REP(i, N) cin >> H.at(i);
    REP(i, N-1) {
        if (H.at(i) >= H.at(i+1)) A.at(i) = true;
    }
    int ans = 0;
    int tmp = 0;
    REP(i, N-1) {
        if (A.at(i)) {
            tmp += 1;
        } else {
            if (ans < tmp) ans = tmp;
            tmp = 0;
        }
    }
    if (ans < tmp) ans = tmp;
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 640
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
    ld val;
    cin>>val;
    cout<<((ceil(val/1000.0)*1000) - val);

}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3796