akhauriyash/Code-Regression huggingface dataset:
//======================================================================
// Contents    : AOJ ITP1_5_C
//               たてH cm よこ W cm のチェック柄の長方形を描く(例参照)
// Input       : H , W
// Output      : '#'と'.'
//             : exp) "5 6"の入力時、以下のように出力される
//             :        #.#.#.
//             :        .#.#.#
//             :        #.#.#.
//             :        .#.#.#
//             :        #.#.#.
// Constraints : 1 ≤ H,W ≤ 300
//             : "0 0" 入力で終了
// Author      : 廣部智也
// LastUpdate  : 2020/06/05
// Since       : 2020/06/05
//======================================================================

#include <stdio.h>
#include <stdlib.h>                                                 // exit 関数を使用するため

#define LOWER_LIMIT   1
#define UPPER_LIMIT 300

int Input_error( int number, int Lower_limit, int Upper_limit );    // 入力エラーを判断する関数

void Drawing_plaids( int H, int W );

int main(){

    int H = 0, W = 0;

    while(1){
        
        // データの入力
		scanf("%d %d", &H , &W );

        if( H == 0 && W == 0 ){
            break;
        }

        // 入力エラーの判断
        Input_error( H, LOWER_LIMIT, UPPER_LIMIT );
        Input_error( W, LOWER_LIMIT, UPPER_LIMIT );

        // データの出力

        Drawing_plaids( H, W );

	}

	return 0;
}



//============================================================
// Contents    : 入力エラーを判断
// Input       : 調べる変数, 下限, 上限
// Output      : エラーなら強制終了
// Author      : 廣部智也
// LastUpdate  : 2020/06/05
// Since       : 2020/06/05
//============================================================

int Input_error( int number, int Lower_limit, int Upper_limit ){
    
    if( number < Lower_limit || number > Upper_limit ){ 
        printf("Input error\n");
        exit(1);
    }

    return 0;
}



//============================================================
// Contents    : たてH cm よこ W cm のチェック柄の長方形を描く
// Input       : H , W
// Output      : '#'と'.'
// Author      : 廣部智也
// LastUpdate  : 2020/06/05
// Since       : 2020/06/05
//============================================================

void Drawing_plaids( int H, int W ){

    int i = 0, j = 0;

    for( i = 0; i < H; i++ ){

		for( j = 0; j < W; j++ ){

            if( ( i % 2 == 0 && j % 2 == 0 ) || ( i % 2 == 1 && j % 2 == 1 ) ){
                putchar('#');
            }
            else{
                putchar('.');
            }
            
        }

		putchar('\n');                               
    }

    putchar('\n');                                                  // データセット間の空行

    return;  
}                                            


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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<(int)n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=(int)n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()

const int N = 2000100;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

int _;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int m, d; cin >> m >> d;
	int counter=0;
	rep(i,20,d+1,1){
		string s = to_string(i);
		if((s[1]-'0')<2) continue;
		if((s[0]-'0')*(s[1]-'0')>=1 && (s[0]-'0')*(s[1]-'0')<=m)
		++counter;
	}
	cout << counter << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines  

from fractions import gcd

def lcm(x, y):
  return (x*y)//gcd(x, y)

A, B = map(int, input().split())

print(lcm(A, B))

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

int N,K;
int MAX = 0,GDC = 0;

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

int main()
{
    scanf("%d%d",&N,&K);
    for(int i = 0; i < N; i++)
    {
        int a;
        scanf("%d",&a);
        MAX = max(MAX,a);
        GDC = gdc(a,GDC);
    }
    if(K % GDC == 0 && K <= MAX)printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};


void solve() {
    string n;
    int k;
    cin >> n >> k;
    Radix r;
    string ans = r.to(n, 10, k);
    cout << sz(ans) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    
    // Input
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Card[] c1 = new Card[n];
    Card[] c2 = new Card[n];
    
    for(int i = 0; i < n; ++i) {
    	String s = sc.next();
    	c1[i] = new Card(s);
    	c2[i] = new Card(s);
    }

	// Sort
  	Sort.BubbleSort(c1);
  	Sort.SelectionSort(c2);
  	
  	// Output
  	for(int i = 0; i < n; ++i) {
  		System.out.print(i == 0 ? c1[i] : " " + c1[i]);
  	}
  	System.out.println();
 	System.out.println("Stable");
 	
 	Boolean eq = true;
  	for(int i = 0; i < n; ++i) {
  		System.out.print(i == 0 ? c2[i] : " " + c2[i]);
  		if(!c2[i].equals(c1[i])) {
  			eq = false;
  		}
  	}
  	System.out.println();
  	if(eq){
  		System.out.println("Stable");
  	}else{
  		System.out.println("Not stable");
	}
  }
  
}

class Sort {
	public static void BubbleSort(Card[] c) {
		for(int i = 0; i < c.length; ++i) {
			for(int j = c.length - 1; j > i; --j) {
				if(c[j - 1].isGreaterThan(c[j])) {
					Card tmp = c[j];
					c[j] = c[j-1];
					c[j-1] = tmp;
				}
			}
		}
	}
	
	public static void SelectionSort(Card[] c) {
		for(int i = 0; i < c.length; ++i) {
			int minj = i;
			for(int j = i; j < c.length; ++j) {
				if(c[minj].isGreaterThan(c[j])){
					minj = j;
				}
			}
			Card tmp = c[minj];
			c[minj] = c[i];
			c[i] = tmp;
		}
		
	}
}

class Card implements Comparable<Card>{
	private char suit;
	private int value;
	
	public Card(String s) {
		set(s);
	}
	public void set(String s) {
		this.suit = s.charAt(0);
		this.value = Character.getNumericValue(s.charAt(1));
	}

	@Override
	public int compareTo(Card c) {
		return this.value - c.value;
	}
	
	public boolean isGreaterThan(Card c) {
		return compareTo(c) > 0;	
	}
	
	@Override
	public boolean equals(Object c) {
		return (this.suit == ((Card)c).suit) && (this.value == ((Card)c).value);
	}
	
	@Override
	public String toString(){
		return(this.suit + String.valueOf(this.value));
	}
	
}

Measured memory_bytes: 26432
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,m,k,ans;
void solve()
{
    cin>>n>>m>>k;
    ll chk=min(n,m);
    map<ll,ll>mp;
    ll j=0;
    for(ll i=1;i<=chk;i++)
    {
        //cout<<i<<" "<<k<<endl;
        if((n%i==0)&&(m%i==0))
        {
            mp[++j]=i;
        }
    }
    j++;
    j-=k;
    cout<<mp[j]<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int A[200000+100];
int f[200000+100];
int d[200000+100];

int main()
{
    int n;

    cin>>n;

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

    f[n] = A[n];
    for(int i=n-1;i>0;i--)
        f[i] = max(f[i+1],A[i]);

    d[1] = A[1];
    for(int i=2;i<=n;i++)
        d[i] = max(d[i-1],A[i]);
    d[0] = 0;
    f[n+1] = 0;
    for(int i=1;i<=n;i++)
        cout<<max(d[i-1],f[i+1])<<endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> white(n,0), black(n,0);
    if(s[0]=='.'){white[0]++;}
    else{black[0]++;}
    for(int i = 1; i < n; i++){
        if(s[i]=='.'){
            white[i] = white[i-1]+1;
            black[i] = black[i-1];
        }else{
            white[i] = white[i-1];
            black[i] = black[i-1]+1;
        }
    }
    ll ans = min(black[n-1], white[n-1]);
    for(int i = 0; i < n; i++){
        ll num = black[i] + white[n-1] - white[i];
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 60;

void solve() {
	int n;
	cin >> n;
	
	vector<vector<int>> a(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	vector<int> sum(1 << n);
	for (int mask = 1; mask < (1 << n); mask++) {
		for (int i = 0; i < n; i++) {
			if ((mask >> i) & 1) {
				for (int j = i + 1; j < n; j++) {
					if ((mask >> j) & 1) {
						sum[mask] += a[i][j];
					}
				}
			}
		}
	}

	vector<int> dp(1 << n);
	for (int mask = 1; mask < (1 << n); mask++) {
		for (int i = mask; i > 0; i = (i - 1) & mask) {
			dp[mask] = max(dp[mask], dp[mask ^ i] + sum[i]);
		}
	}
	cout << dp[(1 << n) - 1];
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}


Measured memory_bytes: 1280
/*It’s going to be hard,
but hard does not mean impossible.*/

#include <bits/stdc++.h>

// definitions
#define __Imperial_Lord__ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _cps CLOCKS_PER_SEC
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define acc(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"
#define p2(a, b) cout << a << " " << b << "\n"
#define p3(a, b, c) cout << a << " " << b << " " << c <<"\n"
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d <<"\n"
#define exec cerr<<"Time taken : "<<(ld)(clock())/_cps<<"s"<<"\n"
#define mod1 998244353
#define mod 1000000007
#define pi 3.1415926535897932384

using namespace std;

// alias name for common data types
typedef vector<long long> vl;
typedef vector<long double> vld;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF = 1e18;

template <class ...Args>
istream &read_args(Args &...args) {return (cin >> ... >> args);}
#define read(...)   __VA_ARGS__; read_args(__VA_ARGS__)

// cin and cout overloaded for vectors
template<typename T>    istream& operator>>(istream& is,  vector<T>& v)
{
    for (auto& i : v)
        is >> i;
    return is;
}
template<typename T>    ostream& operator<<(ostream& os,  vector<T>& v)
{
    for (auto& i : v)
        os << i << ' ';
    return os;
}

// code beigns in main
int main()
{
    __Imperial_Lord__
    ll t = 1;
    // cin >> t;
    
    while (t--)
    {
        ll read(n,k);
        vl a(n); cin>> a;

        dql temp;
        rep(i,0,k) temp.pb(a[i]);

        rep(i,k,n)
        {
            ll val=temp.front();
            temp.pop_front();
            ll newval=a[i];
            temp.pb(a[i]);
            if(newval>val) p1("Yes");
            else p1("No");
        }
    }   
    exec;
}





Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 

int main()
{
	ll a,va,b,vb,t;
	cin>>a>>va>>b>>vb>>t;
	cout<<((va*t>=abs(a-b)+vb*t)?("YES"):("NO"));
	return 0;
}

Measured memory_bytes: 3524
import java.util.*;
  
class Main{
   public static void main(String[] args){
     Scanner stdId = new Scanner(System.in);
     int a = stdId.nextInt(); 
		 int b = stdId.nextInt();
     if(a<b) System.out.println("a < b");
     if(a>b) System.out.println("a > b");
     if(a==b) System.out.println("a == b");
  }
}

Measured memory_bytes: 17300
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pil = pair<int, long>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007
#define INF 1e17

struct edge{
  int from;
  int to;
  long cost;
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<edge> edges(m);
  rep(i,m){
    cin >> edges.at(i).from >> edges.at(i).to >> edges.at(i).cost;
    edges.at(i).from--;
    edges.at(i).to--;
    edges.at(i).cost *= -1;
  }
  vector<long> d(n,INF);
  d.at(0) = 0;
  rep(i,n){
    rep(j,m){
      struct edge e;
      e = edges.at(j);
      if(d.at(e.to) > d.at(e.from) + e.cost){
        d.at(e.to) = d.at(e.from) + e.cost;
        if(i == n-1 && e.to == n-1){
          cout << "inf" << endl;
          return 0;
        }
      }
    }
  }
  cout << -1*d.at(n-1) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# F: 2次元での三分探査
# 最小包含円を探索する（中心と半径）

import math

N = int(input())
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)


def calc_r(x0, y0):
    # 全ての点の中で最も遠いところまでの距離を返す
    res = 0
    for i in range(N):
        res = max(res, ((X[i] - x0)**2 + (Y[i] - y0)**2))

    return res


# lb_x, ub_x = min(X), max(X)
lb_x, ub_x = 0.0, 1000.0


def g(x):
    # lb_y, ub_y = min(Y), max(Y)
    lb_y, ub_y = 0.0, 1000.0

    # yを探索する
    for _ in range(100):
        y1 = lb_y + (ub_y - lb_y) / 3
        y2 = ub_y - (ub_y - lb_y) / 3

        if calc_r(x, y1) > calc_r(x, y2):
            lb_y = y1
        else:
            ub_y = y2
    return calc_r(x, lb_y)


for _ in range(100):
    # あるxにおいて半径が最小となる円を求める
    x1 = lb_x + (ub_x - lb_x) / 3
    x2 = ub_x - (ub_x - lb_x) / 3

    if g(x1) > g(x2):
        lb_x = x1
    else:
        ub_x = x2

print(math.sqrt(g(lb_x)))



Measured memory_bytes: 45660
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
 
LL n;
 
int main(){
	scanf("%lld",&n);
	LL ans = 0LL;
	for(LL i = 1;i*i<n;i++){
		if(n%i == 0 && (n%(n/i -1) != 0)){
			ans+= n/i-1;
		}
	}
	printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    int n;
    Edge[] g;

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        n = sc.nextInt();
        int m = sc.nextInt();
        g = new Edge[n];

        for (int i = 0; i < n; i++) {
            g[i] = new Edge();
        }

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1, b = sc.nextInt() - 1;
            g[a].add(b);
            g[b].add(a);
        }

        int[] ar = new int[n];
        Arrays.fill(ar, -1);
        LinkedList<Integer> q = new LinkedList<>();
        q.add(0);
        ar[0] = 0;
        while (!q.isEmpty()) {
            int cur = q.removeFirst();
            debug(cur);

            for (int next: g[cur]) {
                if (ar[next] == -1) {
                    ar[next] = cur;
                    q.addLast(next);
                }
            }
        }

        boolean ok = true;
        for (int i = 0; i < n; i++) {
            ok &= ar[i] >= 0;
        }

        if (ok) {
            out.println("Yes");
            for (int i = 1; i < n; i++) {
                out.println(ar[i] + 1);
            }
        } else {
            out.println("No");
        }

        out.flush();
    }

    class Edge extends ArrayList<Integer> {}


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 89568
#include <iostream>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
using namespace std;
using ll = long long;
int main(){
  ll A,B;
  cin>>A>>B;
  if(B%A==0){
    cout<<A+B<<endl;
  }else{
    cout<<B-A<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N+2,0);
  for(int i = 1;i <= N;i++)cin >> A[i];

  ll ans = 0;
  for(int i = 1;i <= N+1;i++)ans += abs(A[i] - A[i-1]);

  for(int i = 1;i <= N;i++){
    if((A[i] >= A[i-1] && A[i+1] >= A[i]) || (A[i] <= A[i-1] && A[i] >= A[i+1]))cout << ans << endl;
    else cout << ans - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1]) << endl;
  }


}


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

int main() {
	string s;
	cin >> s;
	int ans = 700;
	for (int i = 0;i < 3;i++) {
		if (s[i] == 'o')
			ans += 100;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int h,w; cin >> h >> w;
  string a[h];
  REP(i,h) cin >> a[i];

  vector<bool> he(h,1),we(w,1);
  REP(i,h) REP(j,w) {
    if (a[i][j] == '#') he[i] = false;
  }

  REP(i,w) REP(j,h) {
    if (a[j][i] == '#') we[i] = false;
  }

  REP(i,h) {
    if (he[i]) continue;
    REP(j,w) if (!we[j]) cout << a[i][j];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  int t;
  cin >> t;
  for (int q=0; q<t; q++){
      long long a, b, c, d;
      cin >> a >> b >> c >> d;
      if (a < b){
          cout << "No\n";
          continue;
      }
      long long x = max(0LL, b-d);
      if (x > c){
          cout << "No\n";
          continue;
      }
      long long plus = a%b; // 4
      long long gcdd = __gcd(b, d);
      long long maxx = ((b-1)-plus)/gcdd;
      maxx *= gcdd;
      maxx = (maxx+plus)%b;
      long long minn = b-plus;
      minn = minn/gcdd+(minn%gcdd != 0);
      minn = (minn*gcdd+plus)%b;
      //cout << "maxx: " << maxx << " minn: " << minn << " x: " << x << " c: " << c << endl;
      if (maxx < x || maxx > c || minn < x || minn > c){
          cout << "No\n";
      }else{
          cout << "Yes\n";
      }
  }
  return 0; 
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
#include <stdio.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)
#pragma GCC optimize("Ofast")



int main() {
	int d, s, t;
	cin >> d >> s >> t;
	if (s * t >= d) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];
char field[200][200];

bool prime[123456 * 2 + 10];
short ans[123456 * 2 + 10];
void hurui(){
  prime[0] = prime[1];
  for(int i = 2;i <= 123456 * 2;i++){
    if(!prime[i]){
      for(int j = 2;i * j <= 123456 * 2;j++)prime[i * j] = true;
    }
  }
  lep(i,1,123456 * 2)ans[i] = ans[i-1] + int(!prime[i]);
}

int main(){
  clr(prime,false);
  clr(ans,0);
  hurui();
  while(1){
    cin >> n;
    if(!n)break;
    print(ans[n * 2] - ans[n]);
  }
  return 0;
}


Measured memory_bytes: 3868
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n)ans = gcd(ans, a[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
map<int,int>d;
inline int read()
{
    char ch=getchar();
    int x=0,q=1;
    while(ch>'9' || ch<'0')q=ch==45?-1:q,ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
    return x*q;
}
inline int solve(int x)
{
    if(d[x]!=0)
        return d[x];
    else
    return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main()
{
    d[0]=1;
    d[1]=2;
    int n;
    n=read(); 
    int ans=solve(n);
    printf("%lld\n",ans);
    return 0;
}

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

typedef long long ll;

 
int main(){
  ll x, a, b;
  cin >> x >> a >> b;
  string ans;
  if(a>=b) ans = "delicious";
  else if(b-a>x) ans = "dangerous";
  else ans = "safe";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		String[] str = br.readLine().split(" ");
		int k = Integer.parseInt(str[0]);
		int t = Integer.parseInt(str[1]);
		if(t==1){
			int n = Integer.parseInt(br.readLine());
			sb.append(n-1);
			System.out.println(sb);
			return;
		}

		String[] str2 = br.readLine().split(" ");
		int[] a = new int [t];
		int max = -1;
		int min = 99999;
		int num = -1;
		for(int i = 0; i < t; i++){
			int cake = Integer.parseInt(str2[i]);
			a[i] = cake;
			if(cake>max){
				max = cake;
				num = i;
			}
		}
		a[num]--;
		int past = num;
		while(true){
			max = -1;
			int maxnum = -1;
			boolean rest = false;
			for(int i = 0; i < t; i++){
				if(i==past || a[i]==0)
					continue;
				if(a[i]>max){
					rest = true;
					max = a[i];
					maxnum = i;
				}
			}
			if(max!=-1){
				a[maxnum]--;
				past = maxnum;
			}
			if(!rest){
				sb.append(a[past]);
				System.out.println(sb);
				break;
			}
		}
	}
}

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

i64 a, b;

int main()
{
  cin >> a >> b;
  if (a == b) {
    cout << 1 << endl;
    return 0;
  }
  i64 c = 0;
  int i = 60;
  while ((a & (1LL << i)) == (b & (1LL << i))) i--;
  a &= (1LL << (i+1)) - 1;
  b &= (1LL << (i+1)) - 1;
  c += (1LL << i) - a;
  int k = i-1;
  while (k >= 0 && (b & (1LL << k)) == 0) k--;
  c += 1LL << (k+1);
  c += (1LL << (i+1)) - ((1LL << i) + a);
  c -= (1LL << (k+1)) - 1 >= a ? (1LL << (k+1)) - a : 0;

  cout << c << endl;

  return 0;
}


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

signed main() {
    int n;
    cin >> n;

    vector<int> t(n), a(n);
    rep(i,n) cin >> t[i] >> a[i];

    int l = t[0], r = a[0];
    for(int i = 1; i < n; i++){
        int d = 1;
        bool flag = false;
        if(t[i] < l) {
            flag = true;
            d = (l + t[i] - 1) / t[i];
        }
        if(a[i] < r){
            flag = true;
            d = max(d, (r + a[i] - 1) / a[i]);
        }
        if(flag) {
            t[i] *= d;
            a[i] *= d;
        }
        l = t[i];
        r = a[i];
    }
    cout << t[n-1] + a[n-1] << endl;
}

Measured memory_bytes: 256
/*Remember: The Struggle Is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     fast() 	     ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,MOD=1e9+7;

void solve()
{
 int n;

 cin>>n;

 vector<int> v(n);

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

 int cnt=0;
 for(int i=0;i<n;++i)
 {
  if(v[i]<0)
  ++cnt;
 }

 int sum=0,mn=inf;
 for(int i=0;i<n;++i)
 {
  sum+=abs(v[i]);
  mn=min(mn,abs(v[i]));
 }

 if(cnt%2)
 sum-=2*mn;

 cout<<sum;
}

int32_t main()
{
 fast();

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

 return 0;
}



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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 100005;

ll v[N], w[N];

int main(){
	fastio;
    int n;
	ll p, total = 0;
	cin >> n >> p;
	for(int i = 0; i < n; i++){
		cin >> w[i] >> v[i];
		total += v[i];
	}
	vector<ll> dp(total+1, INF);
	dp[0] = 0;
	for(int i = 0; i < n; i++){ // put the ith element
		for(int j = total - v[i]; j >= 0; j--){ // iterate over all possible values i can have to add v[i]
			dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
		}
	}
	int ans = 0;
	for(int i = 0; i <= total; i++){
		if(dp[i] <= p){
			ans = i;
		}
	}
	cout << ans << endl;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> L(n);
  int maxL = 0, sum = 0;
  for (int i = 0; i < n; ++i)
  {
    cin >> L[i];
    maxL = max(maxL, L[i]);
    sum += L[i];
  }
  
  sum -= maxL;
  if (sum > maxL) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
double maxfirst(vector<double>,int);
double minfirst(vector<double>,int);
double zeti(double);
int main() {
	int n;
	vector<double>a(1001);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int mi = 100000001,at;
	for (int i = 0; i < n; ++i) {
		for (int j = i; j < n; ++j) {
			if (a[j] < mi) {
				mi = a[j];
				at = j;
			}
		}
		swap(a[i], a[at]);
		mi = 100000001;
	}
	printf("%.5lf\n", max(maxfirst(a, n), minfirst(a, n)));
	return 0;
}
double maxfirst(vector<double>a,int n) {
	int ma = -1, mi = 100000001, atma, atmi;
	double ans;
	for (int i = 0; i < n - 1; ++i) {
		if (a[i] + a[i + 1] > ma) {
			ma = a[i] + a[i + 1];
			atma = i;
		}
	}
	for (int i = 0; i < n-1; ++i) {
		if (i == atma || i + 1 == atma)continue;
		if (zeti(a[i] - a[i + 1])<mi) {
			mi = zeti(a[i] - a[i + 1]);
			atmi = i;
		}
	}
	ans = (a[atma] + a[atma + 1]) / (zeti(a[atmi] - a[atmi + 1]));
	return ans;
}
double minfirst(vector<double>a,int n) {
	int ma = -1, mi = 100000001, atma, atmi;
	double ans;
	for (int i = 0; i < n - 1; ++i) {
		if (zeti(a[i] - a[i + 1])<mi) {
			mi = zeti(a[i] - a[i + 1]);
			atmi = i;
		}
	}
	for (int i = 0; i < n - 1; ++i) {
		if (i == atmi || i + 1 == atmi)continue;
		if (a[i] + a[i + 1] > ma) {
			ma = a[i] + a[i + 1];
			atma = i;
		}
	}

	ans = (a[atma] + a[atma + 1]) / (zeti(a[atmi] - a[atmi + 1]));
	return ans;
}
double zeti(double a) {
	if (a < 0)a *= -1;
	return a;
}


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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

ll H, W;

int main(void)
{
    cin >> H >> W;

    ll ans = (H * W) / 2;
    if (H % 2 == 1 && W % 2 == 1) ans++;

    if (W == 1 || H == 1) ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;
ll digit(ll x){
    ll cnt=1;
    while(x/10>0){
        cnt++;
        x/=10;
    }
    return cnt;
}
int main(){
    ll N; cin>>N;
    for(ll i=sqrt(N);1<=i;i--){
        if(N%i==0){
            cout<<digit(N/i)<<endl;
            return 0;
        }
    }
}




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

int main(){
int n;
while(~scanf("%d",&n)){
int res = 0;
for(int a=0;a<=9;a++)
for(int b=0;b<=9;b++)
for(int c=0;c<=9;c++)
for(int d=0;d<=9;d++)
if(a+b+c+d == n) res++;
printf("%d\n",res);
}

}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 15, M = 1010;

int n, m, k;
int a[N][M], g[N][M];
char s[M];

bool check(int n, int l, int r)
{
	for (int i = 1; i <= n; i ++ )
		if (g[i][r] - g[i][l - 1] > k)
			return false;
	return true;
}

int main()
{
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i ++ )
	{
		cin >> s + 1;
		for (int j = 1; j <= m; j ++ )
			a[i][j] = s[j] - '0';
	}
	
	int res = 0x3f3f3f3f;
	for (int t = 0; t < 1 << n; t ++ )
	{
		int cnt = 0, row = 1;
		bool flag = true;
		memset(g, 0, sizeof g);
		
		for (int i = 1; i <= n; i ++ )
		{
			for (int j = 1; j <= m; j ++ )
			{
				g[row][j] += a[i][j];
				if (g[row][j] > k)
				{
					flag = false;
					break;
				}
				
			}
			if ((t >> (i - 1)) & 1) cnt ++ , row ++ ;
		}
			
		if (!flag) continue;
		
		for (int i = 1; i <= row; i ++ )
			for (int j = 1; j <= m; j ++ )
				g[i][j] += g[i][j - 1];
		
		for (int i = 1; i <= m; i ++ )
		{
			int j = i;
			while (j <= m && check(row, i, j)) j ++ ;
			
			if (j <= m) cnt ++ ;
			i = j - 1;
		}
		
		res = min(res, cnt);
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const int INF = 1e+9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int dp[100010];

int main () {
  dp[0] = 0;
  for (int n = 1; n <= 100000; n++) {
    dp[n] = INF;

    int power = 1;
    while (power <= n) {
      dp[n] = min(dp[n], dp[n-power]+1);
      power *= 6;
    }

    power = 1;
    while (power <= n) {
      dp[n] = min(dp[n], dp[n-power]+1);
      power *= 9;
    }
  }

  int N; cin >> N;
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 640
from bisect import bisect_right
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sa=[0]*(n+1)
sb=[0]*(m+1)
for i in range(1,n+1):
    sa[i]=sa[i-1]+a[i-1]
for j in range(1,m+1):
    sb[j]=sb[j-1]+b[j-1]
ans=0
for x in range(n+1):
    if k-sa[x]>=0:
        k2=k-sa[x]
        l=bisect_right(sb,k2)-1
        if x+l>ans:
            ans=x+l
print(ans)


Measured memory_bytes: 47364
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	int bit[400010] = { 0 };
	cin >> N;
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		bit[a + b]++;
	}
	REP(i, 400009) {
		bit[i + 1] += bit[i] / 2;
		bit[i] %= 2;
	}
	int ans = 0;
	REP(i, 400010) {
		if (bit[i])
			cout << i << " " << 0 << endl;
	}
	

	return 0;
}




Measured memory_bytes: 6348
/*
    In the name of
        "ALLAH"
    And say "AL-HAM-DU-LILLAH"
*/

#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long

int take() {
    int n;
    scanf("%d",&n);
    return n;

}
double ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define Int take()
#define Dnt ttake()
#define LL takes()
#define done {return 0;}
#define fr(n) for(int i=1;i<=n;i++)
#define FR(a,b,x) for(int i=(a);i<=(b);i+=(x))
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)

using namespace std;

bool approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define STR {struct info}
#define dbg(x) {cout<<"ekhane"<<x<<endl;}
#define  SS second
#define  FF first
#define PQ priority_queue
#define great greatest
#define less lesser
#define mii map<int,int>
#define mil map<int,ll>
#define mll map<ll,ll>
#define msb map<string,bool>
#define M 100005
//////////////////////////////////////////

int x[3][105];

int main(){

    int c=Int,r=2;

    fr(r){
        for(int k=1;k<=c;k++){
            x[i][k]=x[i][k-1]+Int;
        }
    }

    int mx=0;

    for(int i=1;i<=c;i++){
        mx=max(mx,x[1][i]+x[2][c]-x[2][i-1]);
    }

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

    done;
}




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

#define rep(i,n) for(int i=0; i<(int)n; ++i)

const int inf = 1<<29;
int n,e,t;
int w[301], memo[301];
bool seen[301];

vector<pair<int,vector<int> > > production;

int main() {
    ios::sync_with_stdio(false);
    memset(seen, false, sizeof(seen));

    cin>>n>>e>>t;
    rep(i,301) memo[i] = -1;
    rep(i,n) cin>>w[i];
    rep(i,e) {
        int g,c;
        cin>>g>>c;
        vector<int> v(c);
        rep(j,c) {
            cin>>v[j];
            v[j]--;
        }
        production.push_back(make_pair(g-1,v));
    }

    rep(i,n) if(w[i] == 1) memo[i] = 1;

    while(true) {
        bool update = false;

        rep(i,production.size()) {
            bool ok = true;
            vector<int> &vs = production[i].second, h;
            rep(j,vs.size()) {
                if(memo[vs[j]] == -1) {
                    ok = false;
                    break;
                }
                h.push_back(memo[vs[j]]);
            }

            if(ok) {
                sort(h.begin(), h.end(), greater<int>());
                int r = 0;
                rep(j,h.size()) r = max(r,j+h[j]);

                if(memo[production[i].first] == -1 ||
                   memo[production[i].first] > r) {
                    memo[production[i].first] = r;
                    update = true;
                }
            }
        }

        if(!update) break;
    }

    cout<<memo[t-1]<<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF (1<<29)
#define all(c) (c).begin(),(c).end()
#define pb(c) push_back(c)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int dis[111][111];
int c, n, m, s, d;
int next[111][111];

void dfs(int cur, int sum, int cost){
  if(next[cur][sum] < cost) return;
  next[cur][sum] = cost;
  for(int i = 0; i < n; i++){
    if(dis[cur][i] == (1<<29)) continue;
    if(sum > 0) dfs(i, sum-1, cost+(dis[cur][i]/2));
    dfs(i, sum, cost+dis[cur][i]);
  }
}

int main(){
  ios::sync_with_stdio(false);

  while(cin >> c >> n >> m >> s >> d && (c||n||m||s||d)){

    for(int i = 0; i < 111; i++){
      for(int j = 0; j < 111; j++){
        dis[i][j] = next[i][j] = (1<<29);
      }
    }

    for(int i = 0; i < m; i++){
      int a, b, f;
      cin >> a >> b >> f;
      a--; b--;
      dis[a][b] = f;
      dis[b][a] = f;
    }

    dfs(s-1,c,0);
    int ans = (1<<29);
    for(int i =0; i < c; i++){
      ans = min(ans, next[d-1][i]);
    }
    cout << ans << endl;
  }


}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const int INF=1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  char s;
  std::cin >> s;
  if(s=='A') std::cout << "T" << '\n';
  else if(s=='T') std::cout << "A" << '\n';
  else if(s=='C') std::cout << "G" << '\n';
  else std::cout << "C" << '\n';
  


  return 0;
}


Measured memory_bytes: 256
/*/ Author: KaySeeKay /*/

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

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    if(n>0)
    s << arr[n - 1] ;
    s<< "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];

signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		int ans = 0;
		vector<pair<int,int>>v(n);
		fn{
			cin >> v[i].fi >> v[i].se;
			if(i>=2){
				int ok =1,cnt = 3;
				for(int j=i;cnt;cnt--,j--){
					ok&=(v[j].fi==v[j].se);
				}
				if(ok){
					ans = 1;
				}
			}
			
		}
		cout<<(ans?"Yes\n":"No");

		
	
	}
	return 0;
}

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

int main(){
    long long int n,num;
    long long int cont = 1;
    long long int ladrillos_rotos = 0;
    cin >> n;
    long long int limit = n-1;
    for (int i=1;i<=n;i++){
        cin >> num;
        if(num==cont){
            cont++;
        }else{
            ladrillos_rotos++;
        }
    }
    if(ladrillos_rotos<=limit){
        cout << ladrillos_rotos << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 384