akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
  while(true){
    int t[5];
    int cnt[3] = {0, 0, 0};

    for(int i = 0; i < 5; i++){
      cin >> t[i];
      if(t[i] == 0) return 0;
      cnt[t[i] - 1]++;
    }

    for(int i = 0; i < 5; i++){
      //ツつ?つ「ツつア
      if(cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0 ||
         cnt[0] == 5 || cnt[1] == 5 || cnt[2] == 5){
        cout << 3 << endl;
      }
      //ツ渉淞つソ
      else if(cnt[t[i] % 3] > 0){
        cout << 1 << endl;
      }
      //ツ閉可つッ
      else{
        cout << 2 << endl;
      }
    }
  }
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        string[] line = Console.ReadLine().Split(' ');
        int n = int.Parse(line[0]);
        int t = int.Parse(line[1]);

        var ct = new CostTime[n];
        for (int i = 0; i < ct.Length; i++)
        {
            line = Console.ReadLine().Split(' ');
            ct[i] = new CostTime(int.Parse(line[0]), int.Parse(line[1]));
        }
        var ict = ct.Where(v => v.time <= t);

        Console.WriteLine(ict.Any() ? ict.Min(v => v.cost).ToString() : "TLE");
        Console.ReadLine();
    }

    public struct CostTime
    {
        public int cost;
        public int time;

        public CostTime(int cost, int time)
        {
            this.cost = cost;
            this.time = time;
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
typedef long long int lli;
const lli inf = 1e18;

struct info{
	int v;
	lli x, y;
	info(int v, lli x, lli y):v(v),x(x),y(y){}
	info(){}
	bool operator < (const info &a) const{
		return (x == a.x)? y<a.y : x<a.x;
	}
};
lli dist(const info &a, const info &b){
	return min(abs(a.x -b.x), abs(a.y -b.y));
}

int main(){
	int n;
	cin >> n;
	vector<info> a(n);
	REP(i, n){
		lli x,y;
		cin >> x >> y;
		a[i] = info(i, x, y);
	}
	
	vector<vector<pair<int, lli> > > adj(n);
	REP(r, 2){
		sort(a.begin(), a.end());
		REP(i, n-1){
			adj[a[i].v].push_back( make_pair(a[i+1].v, dist(a[i], a[i+1])) );
			adj[a[i+1].v].push_back( make_pair(a[i].v, dist(a[i], a[i+1])) );
		}
		REP(i, n){
			swap(a[i].x, a[i].y);
		}
	}
	
	vector<bool> used(n, false);
	lli ans = 0;
	priority_queue<pair<int, int> > wait;
	wait.push(make_pair(0, 0));
	while(!wait.empty()){
		lli cost = -wait.top().first;
		int v = wait.top().second;
		wait.pop();
		if(used[v]) continue;
		used[v] = true;
		ans += cost;
		REP(i, (int)adj[v].size()){
			int next = adj[v][i].first;
			lli ncost = adj[v][i].second;
			if(!used[next]){
				wait.push(make_pair(-ncost, next));
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )

#define INF 1000000000

void swap(int* x, int *y)
{
	int t;

	t = *x;
	*x = *y;
	*y = t;
}

int binary_search(int p[], int n, int key)
{
	int left, right, middle;

	left = 0;
	right = n-1;


	while (left <= right)
	{
		middle = (left + right) / 2;

		if (p[middle] == key)
			return middle;
		else if (p[middle] > key)
		{
			right = middle - 1;
		}
		else if (p[middle] < key)
		{
			left = middle + 1;
		}
	}

	return -1;

}

void bubble_sort(int p[], int n)
{
	int i, j;

	for (i = 0; i < n-1; i++)
	{
		for (j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[i], &p[i + 1]);
		}
	}
}

int main()
{
	int x[3000], y[3000];
	int i, j,count=0;

	for (i = 0;; i++)
	{
		scanf("%d%d", &x[i], &y[i]);
		if (x[i] == 0 && y[i] == 0)
			break;
		count++;
	}

	for (i = 0; i < count; i++)
	{
		printf("%d %d\n", MIN(x[i], y[i]), MAX(x[i], y[i]));
	}


}


Measured memory_bytes: 1992
n, m = map(int, input().split())
g = [[]for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b) 
    g[b].append(a)

ret = 0
def walk(node, visited):
    global ret
    tmp = visited + [node]
    if len(tmp) == n:
        ret += 1 
    for nd in g[node]:
        if nd not in tmp:
            walk(nd, tmp)
walk(1, [])
print(ret)


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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

int sq,n,m;

int main(){
	cin>>n>>m;
	for (int i=m/n;i>=1;i--){
		if (m%i==0){
			cout<<i;
			re 0;
		}
	}
}

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

int a[1010];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int q;
	scanf("%d", &q);
	for(int i = 0; i < q; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		reverse(a+x, a+y);
	}
	for(int i = 0; i < n-1; i++)
		printf("%d ", a[i]);
	printf("%d\n", a[n-1]);
}



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

bool isOutOfStr(int ind, string str){
  return ind >= str.length();
}

int main(void){
  int n;
  cin >> n;
  while(n--){
    string str; cin >> str;
    if(!isOutOfStr(1, str) &&str[0] == '>' && str[1] == '\''){
      int sharp_cnt = 0;
      int ind;
      ind = 2;

      if(isOutOfStr(ind, str) || str[ind] != '='){
        cout << "NA" << endl;
        continue;
      }

      for(;;ind++){
        if(isOutOfStr(ind, str) || str[ind] != '='){
          break;
        }
        sharp_cnt++;
      }

      if(isOutOfStr(ind, str) || str[ind] != '#'){
        cout << "NA" << endl;
        continue;
      }
      ind++;

      bool flg = true;
      for(int i=0; i < sharp_cnt; i++, ind++){
        if(isOutOfStr(ind, str) || str[ind] != '='){
          cout << "NA" << endl;
          flg = false;
          break;
        }
      }
      if(!flg) continue;

      if(!isOutOfStr(ind, str) && str[ind] == '~' && ind == str.length() - 1)
        cout << "A" << endl;
      else{
        cout << "NA" << endl;
      }



    }else if(str[0] == '>' && str[1] == '^'){
      int ind;
      ind=2;

      if(isOutOfStr(ind, str) || !(str[ind] == 'Q' && str[ind+1] == '=')){
        cout << "NA" << endl;
      }else{
        int flg = true;
        for(;;ind+=2){
          if(isOutOfStr(ind, str) || !(str[ind] == 'Q' && str[ind+1] == '=')){
            break;
          }
        }

        if(!isOutOfStr(ind, str) && !isOutOfStr(ind+1, str) && str[ind] == '~' && str[ind+1] == '~' && ind+1 == str.length() - 1){
          cout << "B" << endl;
        }else{
          cout << "NA" << endl;
        }
      }
    }else{
      cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1208
import scala.io.StdIn.{readInt, readLine}
object Main {
    def main(args: Array[String]): Unit = {
        val cnt = readInt;
        val binTree = new BinaryTree[Long,Boolean]((k1, k2) => if (k1 < k2) -1 else if (k1 > k2) 1 else 0);
        (0 until cnt).foreach { i =>
            readLine.split(" ") match {
                case Array("insert", key) => binTree.insert(key.toLong, true);
                case Array("find", key) => {
                    if (binTree.find(key.toLong)) println("yes") else println("no");
                }
                case Array("print") => {
                    println(" " + binTree.fetchInorder.map(_._1).mkString(" "));
                    println(" " + binTree.fetchPreoder.map(_._1).mkString(" "));
                }
            }
        }
    }
}
class BinaryTree[A,B](val compare: (A,A) => Int) {
    case class TreeNode(key: A, value: B, var left: TreeNode, var right: TreeNode);
    var tree: TreeNode = null;
    
    def isEmpty(): Boolean = if (tree == null) true else false;
    
    def insert(key: A, value: B): Unit = {
        def _insert(curr: TreeNode): Unit = {
            if (compare(key, curr.key) < 0) { // 追加対象ノードのほうが小さい
                if (curr.left == null) curr.left = TreeNode(key, value, null, null) else _insert(curr.left);
            } else if (compare(key, curr.key) > 0) { // 追加対象ノードのほうが大きい
                if (curr.right == null) curr.right = TreeNode(key, value, null, null) else _insert(curr.right);
            }
        }
        if (isEmpty) tree = TreeNode(key, value, null, null) else _insert(tree);
    }
    
    def find(key: A): Boolean = {
        def _find(curr: TreeNode): Boolean = {
            if (compare(key, curr.key) == 0) {
                true;
            } else if (compare(key, curr.key) < 0) {
                if (curr.left == null) false else _find(curr.left);
            } else {
                if (curr.right == null) false else _find(curr.right);
            }
        }
        if (isEmpty) false else _find(tree);
    }

    // 先行巡回で要素を返す
    def fetchPreoder(): List[(A, B)] = {
        def _fetchPreoder(curr: TreeNode, ret: List[(A, B)]): List[(A, B)] = {
            if (curr == null) {
                ret;
            } else {
                val ret1 = (curr.key, curr.value) :: ret;
                val ret2 = _fetchPreoder(curr.left, ret1);
                val ret3 = _fetchPreoder(curr.right, ret2);
                ret3;
            }
        }
        _fetchPreoder(tree, Nil).reverse;
    }
    
    // 中間巡回で要素を返す
    def fetchInorder(): List[(A, B)] = {
        def _fetchInorder(curr: TreeNode, ret: List[(A, B)]): List[(A, B)] = {
            if (curr == null) {
                ret;
            } else {
                val ret1 = _fetchInorder(curr.left, ret);
                val ret2 = (curr.key, curr.value) :: ret1;
                val ret3 = _fetchInorder(curr.right, ret2);
                ret3;
            }
        }
        _fetchInorder(tree, Nil).reverse;
    }
}


Measured memory_bytes: 474240
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 2e5 + 5;

int n, a[N], bz[N];

void build_mx() {
	int mx = 0;
	fo(i, 1, n) {
		if(a[i] > mx) {
			mx = a[i]; bz[i] = 1;
		}
	}
}

struct tree {
	int l, r, x;
} t[N * 60]; int tot;
#define i0 t[i].l
#define i1 t[i].r
int pl, pr, px;
void add(int &i, int x, int y) {
	t[++ tot] = t[i], i = tot;
	if(x == y) {
		t[i].x = max(px, t[i].x); return;
	}
	int m = x + y >> 1;
	if(pl <= m) add(i0, x, m); else add(i1, m + 1, y);
	t[i].x = max(t[i0].x, t[i1].x);
}
void ft(int &i, int x, int y) {
	if(y < pl || x > pr) return;
	if(x >= pl && y <= pr) {
		px = max(px, t[i].x);
		return;
	}
	int m = x + y >> 1;
	ft(i0, x, m); ft(i1, m + 1, y);
}

int g[2][N];
void build() {
	t[0].x = -1e9;
	fo(i, 1, n) {
		pl = pr = i; px = 0;
		add(g[0][n + 1], 1, n);
	}
	fd(i, n, 1) {
		fo(j, 0, 1) g[j][i] = g[j][i + 1];
		if(!bz[i]) {
			fo(j, 0, 1) {
				pl = a[i] + 1, pr = n; px = -1e9;
				ft(g[!j][i + 1], 1, n);
				px ++;
				if(px <= 0 && j == 1) px = 1;
				pl = pr = a[i];
				if(px >= 0) add(g[j][i], 1, n);
			}
		} else {
			fo(j, 0, 1) {
				pl = a[i] + 1, pr = n; px = -1e9;
				ft(g[j][i + 1], 1, n);
				px += 2; pl = pr = a[i];
				if(px <= 0 && j == 0) px = 2;
				if(px >= 0) add(g[j][i], 1, n);
			}
		}
	}
}

int ans[N];
int mx[2];

void End() {
	int u1 = 0, u2 = 0, q = 0;
	fo(i, 1, n) q += bz[i];
	fo(i, 1, n) {
		q -= bz[i];
		u1 += a[i] > mx[0];
		int l = u1 - u2 + q;
		pl = mx[1] + 1, pr = n;
		px = -1e9; ft(g[0][i + 1], 1, n);
		int l0 = px;
		px = -1e9; ft(g[1][i + 1], 1, n);
		int l1 = px;
		if(l >= 0) {
			if(l1 >= l || (l % 2 == 0 && l0 >= l)) {
				mx[0] = max(mx[0], a[i]);
				continue;
			}
		}
		l = u2 - u1 + q;
		pl = mx[0] + 1, pr = n;
		px = -1e9; ft(g[0][i + 1], 1, n);
		l0 = px;
		px = -1e9; ft(g[1][i + 1], 1, n);
		l1 = px;
		if(l >= 0) {
			if(l1 >= l || (l % 2 == 0 && l0 >= l)) {
				mx[0] = max(mx[0], a[i]);
				continue;
			}
		}
		u1 -= a[i] > mx[0];
		u2 += a[i] > mx[1];
		mx[1] = max(mx[1], a[i]);
		ans[i] = 1;
	}
	int c[2]; c[0] = c[1] = 0;
	mx[0] = mx[1] = 0;
	fo(i, 1, n) {
		if(a[i] > mx[ans[i]]) {
			c[ans[i]] ++;
			mx[ans[i]] = a[i];
		}
	}
	if(c[0] != c[1]) {
		pp("-1\n"); return;
	}
	fo(i, 1, n) pp("%d", ans[i]); hh;
}

int main() {
	scanf("%d", &n);
	fo(i, 1, n) scanf("%d", &a[i]);
	build_mx();
	build();
	End();
}


Measured memory_bytes: 138496
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int ans[4];
    memset(ans,0,sizeof(ans));
    for(int i=0;i<n;i++)
    {
        string s;cin>>s;
        if(s=="AC")
            ans[0]++;
        if(s=="WA")
            ans[1]++;
        if(s=="TLE")
            ans[2]++;
        if(s=="RE")
            ans[3]++;
    }
    for(int i=0;i<4;i++)
    {
        if(i==0)
            cout<<"AC x "<<ans[i]<<nl;
        if(i==1)
            cout<<"WA x "<<ans[i]<<nl;
        if(i==2)
            cout<<"TLE x "<<ans[i]<<nl;
        if(i==3)
            cout<<"RE x "<<ans[i]<<nl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w; cin >> h >> w;
    vector<string> s(h);
    vector<vector<ll>> c1(h, vector<ll>(w, 0)), c2(h, vector<ll>(w, 0));
    for(ll i = 0; i < h; i++) cin >> s[i];
    for(ll i = 0; i < h; i++){
        ll c = 0, f = w - 1, e = w - 1;
        for(ll j = 0; j <= w; j++){
            if(j == w || s[i][j] == '#'){
                e = j;
                for(ll k = f; k < e; k++){
                    c1[i][k] = c;
                }
                f = e; c = 0;
            }
            else if(s[i][j] == '.'){
                if(f == e) f = j;
                c++;
            }
        }
    }
    for(ll i = 0; i < w; i++){
        ll c = 0, f = h - 1, e = h - 1;
        for(ll j = 0; j <= h; j++){
            if(j == h || s[j][i] == '#'){
                e = j;
                for(ll k = f; k < e; k++){
                    c2[k][i] = c;
                }
                f = e; c = 0;
            }
            else if(s[j][i] == '.'){
                if(f == e) f = j;
                c++;
            }
        }
    }
    ll ans = 0;
    rep(i, h){
        rep(j, w){
            chmax(ans, c1[i][j] + c2[i][j] - 1);
        }
    }
    cout << ans;
    cout << endl;
    return 0;
}



Measured memory_bytes: 67200
//
//AtCoder Beginner Contest 170
//A - Five Variables
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

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

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int x[5];
    int ans=-1;
    REP(i,5) {
        cin >> x[i];
        if (x[i] == 0) ans=i+1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<n;i++)
using namespace std;
long long n,k,a[20],r=1ll<<60,c,t;

int main(){
    cin>>n>>k;rep(i,n)cin>>a[i];
    rep(b,1<<n){
        if (b%2==0||__builtin_popcount(b)!=k)continue;
        c=a[0]-1,t=0;
        rep(i,n){
            if (b&(1<<i)){
                if(c>=a[i])c++,t+=c-a[i];
                else c=a[i];
            }
            else c=max(c,a[i]);
        }
        r=min(r,t);
    }
    cout<<r<<'\n';
}

Measured memory_bytes: 3616
D = int(input())

C = list(map(int, input().split()))

S = [list(map(int, input().split())) for i in range(D)]

L = [0 for i in range(26)]

T = [int(input()) for i in range(D)]

score=0

for d in range(D):
  score += S[d][T[d]-1]
  
  L[T[d]-1] = d+1
  down = 0
  for i in range(26):
    down+=C[i] * ((d+1) - L[i])

  score -=down
  
  print(score)

Measured memory_bytes: 9400
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 
#define pi 3.14159265358979323846

int solve(){
    int n;
    rep(i,1,6){
        cin>>n;
        if(n==0) cout<<i;
    }
    return 0;
}
 
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3640
import std.stdio, std.array, std.conv, std.algorithm, std.string, std.numeric, std.range;
void main() {
        int n;
        while ((n=readln.strip.to!int) != 0){
                int[int] t;
                int[] order;
                for(int i=0; i<n; i++){
                        auto l = readln.strip.split(' ').map!(to!int).array;
                        if(!(l[0] in t)){
                                t[l[0]] = 0;
                                order ~= l[0];
                        }
                        t[l[0]] += l[1] * l[2];
                }
                bool flag = true;
                foreach (int key; order)
                {
                        if(t[key] >= 1000000)
                        {
                                writefln("%d", key);
                                flag = false;
                        }
                }
                if(flag) writefln("NA");
        }
}

Measured memory_bytes: 2712
#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 f(int x,int y,int z){
  return x*x + y*y + z*z + x*y + y*z + z*x;
}

void output_ans(int n) {

  int s = (int)sqrt(2*n);
  int m = (int)sqrt(n/3);
  //cout << s << m<< endl;

  int ans = 0;
  for(int x=1; x<=m; x++){
    for(int y=x; x+2*y<=s; y++){
      for(int z=y; x+y+z<=s; z++){
        //out << "x,y,z = (" << x << "," << y << "," << z << ")" << endl; 
        //cout << f(x,y,z) << endl;
        if(f(x,y,z)==n) {
          if(x==y && y==z) ans++;
          else if(x==y || y==z || z==x)  ans+=3;
          else  ans += 6;
        } 
      }
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  int n;
  cin >> n;
  for(int i=1; i<=n; i++)  output_ans(i);
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int K;
    cin >> K;

    for (int i=0; i<K; ++i) cout << "ACL";
    cout << '\n';
}

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

    solve();

    return 0;
}


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

int main()
{
    ll r;
    cin >> r;
    ll ans = 3 * r * r;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main() {
  string s = "ACL";
  int k;
  cin >> k;
  rep(i,k) cout << s;
  cout << endl;
  return 0; 
}

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

namespace ABC163D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = ReadInt();
            long N = NK[0];
            long K = NK[1];

            long mod = 1000000000 + 7;

            long ans = 1; //最後の分
            for (long k = K; k <= N; k++)
            {
                ans += k * (N + 1 - k) + 1;
                ans %= mod;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 18928
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto abq = readln.split.to!(int[]);
    auto A = abq[0];
    auto B = abq[1];
    auto Q = abq[2];
    long[] ss = [long.min/5], ts = [long.min/5];
    foreach (_; 0..A) ss ~= readln.chomp.to!long;
    foreach (_; 0..B) ts ~= readln.chomp.to!long;
    ss ~= long.max/5;
    ts ~= long.max/5;

    foreach (_; 0..Q) {
        auto x = readln.chomp.to!long;
        int l, r = A+1;
        while (l+1 < r) {
            auto m = (l+r)/2;
            if (ss[m] <= x) {
                l = m;
            } else {
                r = m;
            }
        }
        auto al = ss[l], ar = ss[r];
        l = 0, r = B+1;
        while (l+1 < r) {
            auto m = (l+r)/2;
            if (ts[m] <= x) {
                l = m;
            } else {
                r = m;
            }
        }
        auto bl = ts[l], br = ts[r];
        writeln(min(
            max(x - al, x - bl),
            max(ar - x, br - x),
            (x - al) * 2 + br - x,
            (x - bl) * 2 + ar - x,
            (ar - x) * 2 + x - bl,
            (br - x) * 2 + x - al
        ));
    }
}

Measured memory_bytes: 5372
h, w = map(int, input().split())
s = [input() for _ in range(h)]

front_is_air = False
count = 0


left = [[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if front_is_air:
            if s[i][j] == ".":
                count += 1
                left[i][j] = count
            else:
                front_is_air = False
                count = 0

        else:
            if s[i][j] == ".":
                front_is_air = True
                count += 1
                left[i][j] = count

        if j == w-1:
            front_is_air = False
            count = 0


right = [[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w-1, -1, -1):
        if front_is_air:
            if s[i][j] == ".":
                count += 1
                right[i][j] = count
            else:
                front_is_air = False
                count = 0

        else:
            if s[i][j] == ".":
                front_is_air = True
                count += 1
                right[i][j] = count

        if j == 0:
            front_is_air = False
            count = 0


up = [[0]*w for _ in range(h)]

for i in range(w):
    for j in range(h):
        if front_is_air:
            if s[j][i] == ".":
                count += 1
                up[j][i] = count
            else:
                front_is_air = False
                count = 0

        else:
            if s[j][i] == ".":
                count += 1
                front_is_air = True
                up[j][i] = count

        if j == h-1:
            front_is_air = False
            count = 0


down = [[0]*w for _ in range(h)]

for i in range(w):
    for j in range(h-1, -1, -1):
        if front_is_air:
            if s[j][i] == ".":
                count += 1
                down[j][i] = count
            else:
                front_is_air = False
                count = 0

        else:
            if s[j][i] == ".":
                count += 1
                front_is_air = True
                down[j][i] = count

        if j == 0:
            front_is_air = False
            count = 0


memo = []

for i in range(h):
    for j in range(w):
        memo.append(left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3)

print(max(memo))

Measured memory_bytes: 314248
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=4999999996000000001;



int main(){
    int n;
    cin>>n;
    bool f=true;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a%2==0){
            if(a%3>0 && a%5>0){
                f=false;
            }
        }
    }
    if(f){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
    }
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int A,B,C,D,E,F; cin>>A>>B>>C>>D>>E>>F;
  int P=A*(C-E),Q=B*(D-F);
  Q+=P;
  Q*=-1;
  if(P<0){
    P=-P;
    Q=-Q;
  }
  if(Q==0){
    cout<<"infinity"<<endl;
  }
  else if(Q>0){
    int ans=0;
    ans=P/Q*2+1;
    if(P%Q==0) ans--;
    cout<<ans<<endl;
  }
  else cout<<0<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct P { lli x, y, d; 
  P(lli x, lli y, lli d) : x(x), y(y), d(d) {}
};

lli n;
unordered_set<char> s;
int main() {
  cin >> n;
  for (lli i=0; i<n; ++i) {
    char c; cin >> c;
    s.insert(c);
  }
  const char* p[] = { "Zero", "One", "Two", "Three", "Four" };
  cout << p[s.size()] << endl;
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

int main() {
    int N, K;
    string s;
    cin >> N >> K;
    cin >> s;
    vector<int> v(N);
    char p = '\0';
    REP(i, N) {
        v[i] = s[i] - '0';
    }
    int pre = v[0];
    vector<int> a(1, 1);
    for(int i = 1, j = 0;i < N;i++) {
        if(pre != v[i]) {
            a.push_back(0);
            j++;
            pre = v[i];
        }
        a[j]++;
    }
    int sum = 0;
    int res = 0;
    int i;
    for(i = 0;i < min<int>(a.size(), 2*K);i++) {
        sum += a[i];
    }
    if(v[0] == 1) {
        sum += i < a.size() ? a[2*K] : 0;
        i++;
    }
    res = sum;
    if(v[0] == 0) {
        sum += i < a.size() ? a[i] : 0;
        sum += i + 1 < a.size() ? a[i + 1] : 0;
        sum -= 0 <= i - 2*K ? a[i - 2*K] : 0;
        i += 2;
        res = max(res, sum);
    }

    for(;i < a.size();i += 2) {
        sum += a[i];
        sum += i + 1 < a.size() ? a[i + 1] : 0;
        sum -= 0 <= i - 2*K ? a[i - 2*K] : 0;
        sum -= 0 <= i - 2*K - 1 ? a[i - 2*K - 1] : 0;
        res = max(sum, res);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1404
a;b;main(t){
    scanf("%d%d",&a,&b);
    t=b;
    while(t){
        t/=10;
        a*=10;
    }
    int s=a+b;    
    
    if( pow( (int)sqrt((double)s) ,2)==(double)s   ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    
}

Measured memory_bytes: 2068
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define sum(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class ELeague {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    vector<deque<int>> A(N, deque<int>(N - 1));
    rep(i, N) {
      rep(j, N - 1) {
        cin >> A[i][j];
        A[i][j]--;
      }
    }
    map<pair<int, int>, bool> one;
    deque<pair<int, int>> possible;
    rep(i, N) {
      pair<int, int> temp = {min(i, A[i][0]), max(i, A[i][0])};
      if (one[temp]) {
        one.erase(temp);
        possible.emplace_back(temp);
      } else {
        one[temp] = true;
      }
      A[i].pop_front();
    }
    int days = 0;
    int did  = 0;
    while (true) {
      days++;
      deque<int> task;
      while (possible.size()) {
        did++;
        task.emplace_back(possible[0].first);
        task.emplace_back(possible[0].second);
        possible.pop_front();
      }
      while (task.size()) {
        pair<int, int> temp = {min(task[0], A[task[0]][0]), max(task[0], A[task[0]][0])};
        A[task[0]].pop_front();
        if (one[temp]) {
          one.erase(temp);
          possible.emplace_back(temp);
        } else {
          one[temp] = true;
        }
        task.pop_front();
      }
      if (possible.empty()) break;
    }
    if (did != N * (N - 1) / 2) {
      cout << -1 << endl;
    } else {
      cout << days << endl;
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  ELeague solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main(){
    string a,b;
    cin>>a>>b;
    int m,n,i = a.size(), j = b.size();
    vector<vector<int>> lcs(i+1,vector<int> (j+1,0));
    for(m = 0;m<=i;m++){
        for(n=0;n<=j;n++){
            if(m==0 || n ==0 )
                lcs[m][n] = 0;
            else if (a[m-1]==b[n-1])
                lcs[m][n] = lcs[m-1][n-1] + 1;
            else
                lcs[m][n] = max(lcs[m-1][n],lcs[m][n-1]);
        }
    }
    string ans = "";
    while(i>0 && j>0){
        if(a[i-1] == b[j-1]){
            ans+= a[i-1];
            i--;j--;
        }
        else if(lcs[i-1][j]>lcs[i][j-1])
            i--;
        else
            j--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;

}


Measured memory_bytes: 35584
N = int(input())
rec = []
num = 0
for i in range(N):
    a, b = map(int, input().split())
    rec.append(a + b)
    num -= b

rec = sorted(rec, reverse=True)
for i in range(N):
    if i % 2 == 0:
        num += rec[i]
print(num)

Measured memory_bytes: 8284
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<pi, int> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll D[MAX_N];
vector<ppi> vec;
bool used[MAX_N];

void solve() {
	cin >> N;
	ll d = linf;
	rep(i, 0, N) {
		ll a, b; cin >> a >> b;
		vec.pb(make_pair(pi(a, i), 0));
		vec.pb(make_pair(pi(b, i), 1));
		MIN(d, abs(a - b));
	}
	int cnt = 0;
	sort(all(vec));
	ll res = 0;
	rep(i, 0, N) {
		res += vec[i].fst.fst;
		cnt += vec[i].sec;
		used[vec[i].fst.sec] = true;
	}
		// debug("yes");
	if(accumulate(used, used + N, 0) == N && cnt != 0 && cnt != N) {
		if(vec[N].fst.sec != vec[N - 1].fst.sec) {
			res += vec[N].fst.fst - vec[N - 1].fst.fst;
		}
		else {
			res += min(vec[N + 1].fst.fst - vec[N - 1].fst.fst,
					vec[N].fst.fst - vec[N - 2].fst.fst);
		}
	}
	cout << res<< "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    h[i] = -h[i];
  }
  int hmax = 0;
  int ans = hmax - h[0];

  for (int i = 1; i < n; i++) {
    if (h[i] < h[i - 1]) {
      ans += h[i - 1] - h[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# 写経
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, u, v = map(int, readline().split())
m = map(int, read().split())
AB = zip(m, m)

graph = [[] for _ in range(n + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)


def dfs(v):
    dist = [-1] * (n + 1)
    # 初期化
    stack = [v]
    # 初期位置を記憶
    dist[v] = 0
    # 初期位置の距離を0に
    while stack:
        # stackの中身がなくなるまで頑張る
        v = stack.pop()
        # stackから1つ要素を取り出す
        dw = dist[v] + 1
        # その要素の周りを考えるので、距離としてはその要素の距離に1を加えたものを考える
        for w in graph[v]:
            # 考えている要素に対して隣接している点に対して
            if dist[w] >= 0:
                # もし今まで訪れたことがあったら無視
                continue
            dist[w] = dw
            # 訪れたことがなかったら距離を更新
            stack.append(w)
            # 訪れたことがないところだったらstackに訪れる点リストとして保存
    return dist


answer = 0
du, dv = dfs(u), dfs(v)
for u, v in zip(du[1:], dv[1:]):
    if v - u > 0:
        x = v - 1
        if answer < x:
            answer = x
print(answer)


Measured memory_bytes: 30840
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    ll K;cin>>K;
    str S;cin>>S;
    if(S.size()>K){rep0(i,K){cout<<S[i];}cout<<"..."<<endl;}
    else{cout<<S<<endl;}
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;


int main() {
    int L, R;
    cin >> L >> R;
    int ans = 2018;
    if ((R - L + 1) > 2018) {
        cout << 0 << endl;
    }else{
        vector<int> num(R-L+1);
        for (int i = 0; i < R-L+1; i++) {
            num[i] = (L+i) % 2019;
        }
        for (int i = 0; i < R-L; i++) {
            for (int j = i+1; j < R-L+1; j++) {
                if (((num[i] * num[j]) % 2019) < ans) {
                    ans = ((num[i] * num[j]) % 2019);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d)){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


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


int main() {

    int a, b, c;
    cin >> a >> b >> c;
    if ((100*a+10*b+c) % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = int(input())
cards = [0] * 74

for i in range(1, n + 1):
   marks ,num = map(str, input().split())
   num = int(num)
   

   if marks == "S":
      cards[num + 0] += 1
   elif marks == "H":
      cards[num + 20] += 1
   elif marks == "C":
      cards[num + 40] += 1
   else:
      cards[num + 60] += 1
   
for i in range(1, 14):
   if cards[i] == 0:
      print("S", i)
for i in range(21, 34):
   if cards[i] == 0:
      print("H", i - 20)
for i in range(41, 54):
   if cards[i] == 0:
      print("C", i - 40)   
for i in range(61, 74):
   if cards[i] == 0:
      print("D", i - 60)   




Measured memory_bytes: 5612
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;

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

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

    int n, x, d;
    cin >> n >> x >> d;

    if (d == 0) {
        cout << (x == 0 ? 1 : n + 1) << endl;
        return 0;
    }

    int t = gcd(abs(x), abs(d));
    x /= t;
    d /= t;

    if (d < 0) {
        x *= -1;
        d *= -1;
    }

    vp sg[n+1];
    for (int i = 0; i <= n; i++) {
        ll l = 1ll * (0 + (i - 1)) * i / 2 + 1ll * x * (i / d);
        ll r = 1ll * ((n - i) + (n - 1)) * i / 2 + 1ll * x * (i / d) + 1;
        sg[i%d].push_back({l, r});
    }

    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        sort(sg[i].begin(), sg[i].end());

        ll l = -1e14, r = -1e14;
        for (pll p : sg[i]) {
            if (p.first > r) {
                ans += r - l;
                l = p.first;
                r = p.second;
            } else {
                r = max(r, p.second);
            }
        }
        ans += r - l;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11264
def main():
  n = input()
  ls = list(map(int, input().split(' ')))
  for item in ls:
    if item % 2 == 0:
      if (item % 3) * (item % 5) != 0:
        print('DENIED')
        break
  else:
    print('APPROVED')
 
 
if __name__ == '__main__':
  main()

Measured memory_bytes: 38416
using System;

class Practice
{
    static bool Inc3(int n)
    {
        return n % 10 == 3 ? true : n > 0 ? Inc3(n / 10) : false;
    }
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 1; i <= n; ++i)
        {
            if (Inc3(i) || i % 3 == 0) Console.Write(" {0}", i);
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 17976
#include<stdio.h>
int main(void) {
	char s[1001];
	int bafs,bafw,w,i,a=0;
	bafs = scanf(" %s", s);
	if (bafs == EOF) {
		return -1;
	}
	bafw = scanf(" %d", &w);
	if (bafw == EOF) {
		return -1;
	}
	for (i = 0; s[i] !='\0'; i++) {
		a++;
	}
	for (i = 0; i<a; i += w) {
		printf("%c", s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
def root(uf,i):
    if uf[i] == i:
        return i
    else:
        uf[i] = root(uf,uf[i])
        return uf[i]

n,m = map(int,input().split())
edge = [list(map(int,input().split())) for _ in range(m)]
ctr = 0
for i in edge:
    uf = [i for i in range(n+1)]
    for j in edge:
        if i==j: continue
        x = root(uf,j[0])
        y = root(uf,j[1])
        uf[x] = y
    for j in range(1,n+1):
        root(uf,j)
    for j in range(1,n):
        if uf[j] != uf[j+1]:
            break
    else:
        ctr += 1
print(m-ctr)


Measured memory_bytes: 3064
n,m=map(int,input().split())
up=float('inf')
dp=[[up]*(1<<n) for i in range(m)]

dp[0][0]=0
buy=[]
a=[]
b=[]
for cnt in range(m):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
    c=list(map(int,input().split()))
    tmp=0
    for w in c:
        tmp+=1<<(w-1)
    buy.append(tmp)

for i in range(m-1):
    for j in range(1<<n):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|buy[i]]=min(dp[i][j]+a[i],dp[i+1][j|buy[i]])

if dp[m-1][-1]==float('inf'):
    print(-1)
else:
    print(dp[m-1][-1])

Measured memory_bytes: 129688
uses math;
var
	ans,n,Ma,Mb,i,j,a,b,c,x,mp,mm:Longint;
	p,m:array[0..200]of Longint;
begin
	read(n,Ma,Mb);
	ans:=10000;
	for i:=1 to 200 do begin
		p[i]:=ans;
		m[i]:=ans;
	end;
	for i:=1 to n do begin
		read(a,b,c);
		x:=Ma*b-Mb*a;
		if x>0 then begin
			mp:=min(mp+x,200);
			for j:=mp-x downto 0 do p[j+x]:=min(p[j+x],p[j]+c);
		end else if x<0 then begin
			mm:=min(mm-x,200);
			for j:=mm+x downto 0 do m[j-x]:=min(m[j-x],m[j]+c);
		end else ans:=min(ans,c);
	end;
	for i:=1 to 100 do ans:=min(ans,p[i]+m[i]);
	if ans<10000 then writeln(ans)else writeln(-1);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int sum = 0;
  for(int i = 0; i<n ;i++){
    int l,r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum;
}


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << '\n';
	return 0;
}


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

int main(){
	ll n; int x, m; cin>>n>>x>>m;
	int mn = min(n, (ll)m);
	vector<int> P; // value of pre & cycle
	ll sum_p = 0; // sum of pre + cycle
	vector<bool> X(m, false); // for cycle check
	rep(_i, mn){
		if(X[x]){
			int pre_len = find(P.begin(), P.end(), x) - P.begin();
			int cyc_len = P.size() - pre_len;
			int nxt_len = (n - pre_len) % cyc_len;
			ll remain = 0; rep(i, pre_len + nxt_len) remain += P[i];
			ll cyc = sum_p; rep(i, pre_len) cyc -= P[i];
			cyc *= (n - pre_len) / cyc_len;
			cout<< cyc + remain <<endl;
			return 0;
		}
		X[x] = true;
		P.push_back(x);
		sum_p += x;
		x = (ll)x*x % m;
	}
	cout<< sum_p <<endl;
}


Measured memory_bytes: 3736
#include <iostream>

using namespace std;

int main(){
  int a, b, c, ave;

  cin >> a >> b >> c;

  if((a+b+c) % 2 != 0){
    cout << "No" << endl;
    return 0;
  }else{
    ave = (a + b + c)/2;
  }

  if(a+b == ave || a+c == ave || b+c == ave){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256