akhauriyash/Code-Regression huggingface dataset:
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
//#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define FZ(n) memset((n),0,sizeof())
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
}
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }

// global parameters here:

void solve() {
	int n; cin >> n;
	vi d(n+1); FORE(i, 1, n) cin >> d[i];
	vi a(n+1);
	int m1=0;
	FORD(i, n, 1) {
		if(i%2==1) m1+= d[i];
		else m1-= d[i];
	}
	a[1]=m1;
	FORE(i, 2, n) {
		a[i] = 2*d[i-1] - a[i-1];
	}
	FORE(i, 1, n) cout << a[i] << " ";
	cout << endl;
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

// int t, test=0; cin >> t;
//  while(t--)
  {
		solve();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
int main(void)
{
  long long a,b,k;
  scanf("%lld %lld %lld",&a,&b,&k);
  if(a+b<=k){
    puts("0 0");
    return 0;
  }else{
    if(a<=k){
      k-=a;
      a=0;
      b-=k;
    }else{
      a-=k;
    }
  }


  printf("%lld %lld\n",a,b);
  return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int blank = a-b;
      if(blank>c){
        System.out.println(0);
        System.exit(0);
      }
      System.out.println(c-blank);
  }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i] %= M;
    }
    vector<ll> S(N+1,0);
    for(int i=0; i<N; i++){
        S[i+1] = S[i] + A[i];
        S[i+1] %= M;
    }
    map<ll,ll> mp;
    for(int i=0; i<=N; i++){
        mp[S[i]]++;
    }
    ll ans = 0;
    for(auto m: mp){
        ans += m.second*(m.second-1)/2;
    }
    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 5376
//解説見た
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

// [  [@] ]
// [  [  ] [] ]
// 1 2 3 4 7
// 5 6 7 8 9

// 1 1 1 1 2 2 2 3 3 4
// 2 3 3 4 4 4 5 5 5 5

// 1 2 2 2 1
// 123443321
int main() {
    int n,m; cin >> n >> m;
    pair<int,int> ba[100000]; rep(i,m) cin >> ba[i].second >> ba[i].first;
    sort(ba, ba+m);
    int prev = -1;
    int ans = 0;
    rep(i,m) {
        if (ba[i].second > prev) {
            ans ++;
            prev = ba[i].first-1;
        }
    } 
    cout << ans << endl;

}

Measured memory_bytes: 4384
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

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

#define MAX 1001000

signed main(){
    int sosuu[MAX]={0};
    vector<int> pri;

    for(int i=2;i<sqrt(MAX)+10;i++){
        if(sosuu[i]==0){
            pri.push_back(i);
            for(int j=i;j<sqrt(MAX)+10;j+=i){
                sosuu[j]=1;
            }
        }
    }

    int N;
    int A[MAX];

    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    \
    //pairwise coprime
    bool f=true;
    set<int> s;
    set<int> s2;
    s.insert(-1);
    for(int i=0;i<N;i++){
        int n=A[i];
        for(int j=0;j<pri.size();j++){
            if(pri[j]==-1) continue;
            if(n%pri[j]==0){
                if(s2.find(pri[j])!=s2.end()){
                    n=-1;
                    break;
                }
                while(n%pri[j]==0) n/=pri[j];
                s2.insert(pri[j]);
            }
        }
        //cout<<n<<endl;
        if(n!=1&&s.find(n)!=s.end()){
            f=false;
            break;
        }
        s.insert(n);
    }
    if(f){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }

    int g=A[0];
    for(int i=1;i<N;i++){
        g=gcd(g,A[i]);
    }
    if(g==1){
        cout<<"setwise coprime"<<endl;
        return 0;
    }

    cout<<"not coprime"<<endl;
}


Measured memory_bytes: 18780
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, r;
    cin >> n >> r;
    if (n < 10)
    {
        r += 100 * (10 - n);
    }
    cout << r << endl;
}

int main()
{
    solve();
    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 all(v) v.begin(), v.end()

int main(){
    string s,t;
    cin >> s;
    cin >> t;

    int ans = 0;

    for(int i=0; i<=s.size()-t.size(); i++){
        int cnti = 0;
        for(int j=i; j<=i + t.size() - 1 ; j++){
            if(s[j] == t[j-i]){
                cnti++;
            }
        }
        if(cnti > ans) ans = cnti;
    }

    cout << t.size() - ans << endl;
}

Measured memory_bytes: 3628
module UnionFind : sig
  type t
  val make : int -> t
  val find : t -> int -> int
  val size : t -> int -> int
  val unite : t -> int -> int -> unit
  val is_same : t -> int -> int -> bool
end = struct
  type t = { rank: int array; parent: int array; size: int array }

  let make n = 
    { rank = Array.make n 0; 
      parent = Array.init n (fun i -> i);
      size = Array.make n 1 }

  let rec find uf i = 
    if uf.parent.(i) = i then i
    else begin
      let j = find uf uf.parent.(i) in 
      uf.parent.(i) <- j; j
    end
  
  let size uf i = uf.size.(find uf i)

  let unite uf i j =
    let x = find uf i in
    let y = find uf j in
    if x = y then ()
    else if uf.rank.(x) < uf.rank.(y) then begin
      uf.parent.(x) <- y;
      uf.size.(y) <- uf.size.(y) + uf.size.(x)
    end
    else begin
      uf.parent.(y) <- x;
      uf.size.(x) <- uf.size.(x) + uf.size.(y);
      if uf.rank.(x) = uf.rank.(y) then uf.rank.(x) <- uf.rank.(y) + 1
    end

  let is_same uf i j = find uf i = find uf j
end

let (n, m) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n m -> (n, m)
let ab = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> (a - 1, b - 1)

let () =
  let ans = Array.make (m + 1) 0 in
  let uf = UnionFind.make n in
  ans.(m) <- (n * (n - 1)) / 2;
  for i = m - 1 downto 0 do
    let (a, b) = ab.(i) in
    if UnionFind.is_same uf a b then
      ans.(i) <- ans.(i + 1)
    else begin
      ans.(i) <- ans.(i + 1) - (UnionFind.size uf a) * (UnionFind.size uf b);
      UnionFind.unite uf a b;
    end
  done;
  for i = 1 to m do
    Printf.printf "%d\n" ans.(i)
  done

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<string> a(10);

int main(void) {
    int h, w;
    cin >> h >> w;
    rep (i, h) cin >> a[i];

    int cnt = 0;
    rep (i, h) rep (j, w) if (a[i][j] == '#') cnt++;

    
    cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
    return 0;
}


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

using namespace std;

const int MAX = 1000;
int ary[MAX][MAX];

int getVal(int n, int m) {

	if (m >= 0 && n >= 0 && m < MAX && n < MAX) {
		return ary[n][m];
	}
	else {
		return 0;
	}
}

int LCS(string s1, string s2) {

	int m, n;
	m = s1.length();
	n = s2.length();
	const char* c1 = s1.c_str();
	const char* c2 = s2.c_str();

	for (int i = 0;i < n;i++) {
		for (int k = 0;k < m;k++) {

			if (c1[k] != c2[i]) {
				ary[i][k] = max(getVal(i - 1, k), getVal(i, k - 1));
			}
			else if (c1[k] == c2[i]) {
				ary[i][k] = getVal(i - 1, k- 1) + 1;
			}
		}
	}

	return ary[n - 1][m - 1];
}


int main() {


	int num;
	cin >> num;

	string str1, str2;

	for (int i = 0;i < num;i++) {
		cin >> str1 >> str2;

		cout << LCS(str1, str2) << endl;
	}
	return 0;
}








Measured memory_bytes: 7076
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

void warshall_floyd(ll N, vvll& d) {
  rep(k, N) rep(i, N) rep(j, N) chmin(d[i][j], d[i][k] + d[k][j]);
}

signed main() {
  init();
  ll N, M;
  cin >> N >> M;

  vvll d(N, vll(N, INF));
  rep(i, N) d[i][i] = 0;

  vll A(M), B(M), C(M);
  rep(i, M) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--;
    B[i]--;
    d[A[i]][B[i]] = C[i];
    d[B[i]][A[i]] = C[i];
  }

  warshall_floyd(N, d);

  ll ans = 0;

  rep(m, M) {
    bool ok = false;
    rep(i, N) {
      rep(j, N) {
        if (d[i][j] == d[i][A[m]] + C[m] + d[B[m]][j]) ok = true;
      }
    }
    if (!ok) ans++;
  }
  ANS;

  return 0;
}

Measured memory_bytes: 3688
a, b, c, d = map(int,input().split())
import fractions
ans = (b - b//c - b//d + b//(c*d // fractions.gcd(c, d))) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//(c*d // fractions.gcd(c, d)))
print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a[5];
    rep(i,0,5) cin >> a[i];
    ll k;
    cin >> k;
    if(a[4] - a[0] > k){
        print(":(");
    }else{
        print("Yay!");
    }

    
}

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

using namespace std;

int main(void){
    int K , S , ans = 0;
    cin >> K >> S;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if(i+j<=S && S-i-j<=K)ans++;
        }
    }
    cout<<ans<<endl;
}


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

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

    int n; cin >> n;
    int m = 0;
    vector<int> a, b;    
    if(n%2){
        for(int i = 1; i < n; ++i){
            for(int j = i+1; j <= n; ++j){
                if(i+j != n){
                    a.push_back(i);
                    b.push_back(j);
                    ++m;
                }
            }
        }
    }else{
        for(int i = 1; i < n; ++i){
            for(int j = i+1; j <= n; ++j){
                if(i + j != n + 1){
                    a.push_back(i);
                    b.push_back(j);
                    ++m;
                }
            }
        }
    }

    cout << m << "\n";
    rep(i,m) cout << a[i] << " " << b[i] << "\n";

}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int d, x, y, p;
  char a[16];
  vector<int> D, DD;
  scanf("%d", &d);
  scanf("%d", &x);
  rep(i, x){
    scanf("%s%d", a, &p);
    if(a[0] == 'D') D.push_back(p);
  }
  scanf("%d", &y);
  rep(i, y){
    scanf("%s%d", a, &p);
    if(a[0]=='D' && a[1]=='D') DD.push_back(p);
  }
  sort(D.begin(), D.end(), greater<int>());
  sort(DD.begin(), DD.end(), greater<int>());
  int res = 0;
  //  fprintf(stderr, "input\n");
  while(d){
    int f = true;
    //    fprintf(stderr, "%d\n", d);
    if(DD.empty() && D.empty()) break;
    if(d >= 2 && !DD.empty()){
      if((D.size() > 1 && D[0] + D[1] < DD[0]) || (D.size() == 1 && D[0] < DD[0]) || D.empty()){
	res += DD[0];
	DD.erase(DD.begin());
	d -= 2;
	f = false;
      }
    }
    if(f && !D.empty()){
      res += D[0];
      D.erase(D.begin());
      d--;
      f = false;
    }
    if(f) break;
    //    if(DD.empty() && D.empty()) break;
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 1212
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int result,x,result2,y;
        int mov = 0;
        int go[][] = new int[n][2];
        for(int i = 0; i < n; i++){
            for(int k = 0; k < 2; k++){
               go[i][k] = sc.nextInt();
            }
        }
        for(int i = 1; i < n; i++){
            result = go[i][0] - go[i-1][0];
            x = Math.abs(result);
            result2 = go[i][1] - go[i-1][1];
            y = Math.abs(result2);
            mov = mov + x + y;
            if(result > 0 && result2 > 0 || result < 0 && result2 < 0){
                if(x <= y){
                    mov = mov - x;
                }else{
                    mov = mov - y;
                }
            }
        }
        System.out.println(mov);
    }
}

Measured memory_bytes: 25152
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
const int INF = 1e9;

int dp [MAX_N];

int main() {
  vector<int> A(3);
  cin>>A[0]>>A[1]>>A[2];
  int ans=0;
  while(A[0]!=A[1]||A[1]!=A[2]){
    ans++;
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    if(A[1]==A[2]){
      A[1]++;
      A[2]++;
    }
    else if(A[0]-A[1]>1){
      A[1]+=2;
    }
    else{
      A[2]+=2;
    }
    //cout<<A[0]<<A[1]<<A[2]<<endl;
  }
  cout<<ans;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,n,mn=1e4;
  cin>>h>>n;
  int a[n],b[n];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  vector<int> dp(h+1,1e8+1);
  dp[0]=0;
  for(int i=1;i<=h;i++){
    for(int j=0;j<n;j++){
      int x;
      if(i>=a[j]){
        x=dp[i-a[j]]+b[j];
      }
      else{
        x=b[j];
      }
      dp[i]=min(dp[i],x);
    }
  }
  cout<<dp[h]<<'\n';
  // for(int i=0;i<=h;i++){
  //   cout<<dp[i]<<' ';
  // }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N, a, b;
    int count = 0;

    scanf("%d", &N);

    for(int i=0; i<N; i++){
        scanf("%d %d", &a, &b);
        if(a == b){
            count++;
            if(count >= 3){
                printf("Yes\n");
                return 0;
            }
        } else count = 0;
    }

    printf("No\n");

    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        boolean[] used = new boolean[10000];
        int i = 0;
        while(true) {
            i++;
            if(used[s]) {
                System.out.println(i);
                return;
            }
            used[s] = true;
            if(s % 2 == 0) {
                s /= 2;
            } else {
                s = 3 * s + 1;
            }
        }
    }
}

Measured memory_bytes: 22732
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  [scanElem,scanElem,scanElem].sort().uniq().count.writeln();end("");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b) && b != c) puts("Yes");
	else if ((a == c) && b != c) puts("Yes");
	else if ((c == b) && a != c) puts("Yes");
	else puts("No");
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,M; cin >> N >> M;
    VI n(N, 0);
    REP(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        n[a] ^= 1; n[b] ^= 1;
    }
    REP(i,N){
        if(n[i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)
template <typename T>
T _gcd(T a, T b) {
    return b ? _gcd(b, a % b) : a;
}

template <typename T>
T _gcd_vector(vector<T> a) {
    T res = a[0];
    for (T i = 1; i < a.size(); i++) {
        res = _gcd(a[i], res);
    }
    return res;
}

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

    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    ll ans = _gcd_vector(a);

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include <vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
    int n,m,i,j,x,y,sum=0,lim=1;
    cin>>n>>m;
    for(i=1;i<n;i++)
        lim*=10;
    int flag=1;
    vector<int> a(n,-1);
    for(i=0;i<m;i++){
        cin>>x>>y;
        if(!(a[x-1]==-1||a[x-1]==y)){
            flag=0;
        }
        a[x-1]=y;
    }
    if(flag==0){
        cout<<-1;
    }
    else{
    	if(n==1)
    	{
    		if(a[0]==-1){
    			a[0]=0;
    			}
    		cout<<a[0];
    		exit(0);
    			
    	}
        if(a[0]==-1){
            a[0]=1;
        }
        sum=a[0];
        for(i=1;i<n;i++){
            if(a[i]==-1){
                a[i]=0;
            }
            sum=sum*10+a[i];
        }

        if(sum<lim){
            cout<<-1;
        }
        else
            cout<<sum;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

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

	ll ans = 1e12;

	for (int i = 1; i <= n; ++i){//hi
		if(b % i == 0){
			for (int j = 1; j <= n; ++j){//hi
				ll t = j * b / i;
				ans = min(ans, abs(t - a));
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3212
/*
Problem :
Algorithm :
Status :
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG printf("Passing Line %d in Function [%s].\n",__LINE__,__FUNCTION__);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const ll INF = 1e18;

int T;
ll A,B,C,D,N;
map<ll,ll> mp;

ll Solve(ll x){
    if(!x)
        return 0;
    if(x == 1)
        return D;
    if(mp.find(x) != mp.end())
        return mp[x];
    ll res = INF;
    if(x < res / D)
        res = x * D;
    res = min(res,x % 2 * D + Solve(x / 2) + A);
    res = min(res,(2 - x % 2) * D + Solve((x + 1) / 2) + A);
    res = min(res,x % 3 * D + Solve(x / 3) + B);
    res = min(res,(3 - x % 3) * D + Solve((x + 2) / 3) + B);
    res = min(res,x % 5 * D + Solve(x / 5) + C);
    res = min(res,(5 - x % 5) * D + Solve((x + 4) / 5) + C);
    mp[x] = res;
    return res;
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%lld",&N);
        scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
        mp.clear();
        printf("%lld\n",Solve(N));
    }
    return 0;
}

Measured memory_bytes: 4612
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)




int main() {
	ll N;
	std::cin >> N;

	if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) {
		std::cout << "hon" << endl;
	}
	else if (N % 10 == 3) {
		std::cout << "bon" << endl;
	}
	else {
		std::cout << "pon" << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;

void solve(){
    double a,b,x;
    cin>>a>>b>>x;
    if(x/a<=a*b/2){
        cout<<atan((a*b*b)/(2*x))*180/acos(-1)<<"\n";
    }
    else cout<<atan(2*(a*a*b-x)/(a*a*a))*180/acos(-1)<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

now = False
count = 1
for i in range(N-1):
    if A[i] < A[i+1]:
        if now == 1:
            pass
        elif now == -1:
            count += 1
            now = False
        else:
            now = 1
    elif A[i] > A[i+1]:
        if now == 1:
            count += 1
            now = False
        elif now == -1:
            pass
        else:
            now = -1

print(count)

Measured memory_bytes: 20260
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[4];//LRDW
  int w,h,q;
  cin>>w>>h>>q;
  a[0]=0;a[1]=w;a[2]=0;a[3]=h;
  for(int i=0;i<q;i++){
  	int x,y,j;
    cin>>x>>y>>j;
    j--;
    if(j==0){a[j]=max(a[j],x);}
    if(j==1){a[j]=min(a[j],x);}
        if(j==2){a[j]=max(a[j],y);}
        if(j==3){a[j]=min(a[j],y);}
  }
  cout<<(max(a[1]-a[0],0)*max(a[3]-a[2],0))<<endl;
         return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    ll res=1;
    ll mod=1e9+7;
    rep(i,n){
        res*=i+1;
        res%=mod;
    }
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main(){
	double r0, w0, c, r,rate;
	int i;
	while (~fscanf(stdin, "%lf%lf%lf%lf", &r0, &w0, &c, &r), r0 || w0 || r || c) {
		rate = r0 / w0;
		if (rate > c||c-rate<0.000001) { puts("0"); continue; }
		for(i=1;;i++)
			if ((r0 + i*r) / w0 >= c) {
				P(d, i);
				break;
			}
	}
	return 0;
}

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

int main(){
  long n,a,b;
  cin >> n >> a >> b;
  long i = 0;
  if(n>a+b){
    long syou = n/(a+b);
    long amari = n%(a+b);
    if(amari<a){
      cout << a*syou+amari;
    }else{
      cout << a*syou+a;
    }
  }else{
    if(n<a){
      cout << n;
    }else{
      cout << a;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
char get(int x) {
	return (x + 'a' - 1);
}
int main(void)
{
	FIO
	ll n;
	cin >> n;
	string ans = "";
	while (n > 0) {
		n--;
		ans += (char)'a' + n % 26;
		n /= 26;
	}
	reverse(all(ans));
	cout << ans << '\n';
	return 0;
}

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

struct Team {
  string name;
  int game[3];
  
  bool operator<(const Team &t) const {
    if( game[0] != t.game[0] ) return game[0] > t.game[0];
    if( game[1] != t.game[1] ) return game[1] < t.game[1];
    return false;
  }
};

int main() {
  for( int N; cin >> N, N;  ) {
    
    Team team[N];

    for(int i = 0; i < N; i++) {
      cin >> team[i].name;
      for(int j = 0; j < 3; j++) team[i].game[j] = 0;

      for(int j = 0; j < N - 1; j++) {
        int x; cin >> x;
        team[i].game[x]++;
      }
    }
    
    sort( team, team + N );
    for(int i = 0; i < N; i++) cout << team[i].name << endl;

  }
}

Measured memory_bytes: 0
N = int(input())
if N <= 6:
    print(1)
elif N <= 11:
    print(2)
elif N % 11 == 0:
    print((N//11)*2)
elif N % 11 > 6:
    print(((N//11)*2)+2)
else:
    print(((N//11)*2)+1)

Measured memory_bytes: 3060
n=int(input())
s=input()
a=[]
p=10**9+7
for c in s:
    if(c=="B"):
        a.append(-1)
    else:
        a.append(1)

kako=[]

mi=0
kanou=True

for i in range(2*n):
    temp=1
    if(mi%2==1):
        if(a[i]==-1):
            temp=-1
    if(mi%2==0):
        if(a[i]==1):
            temp=-1
    mi+=temp
    if(mi<0):
        kanou=False
    kako.append(temp)

if(mi!=0):
    kanou=False
ans=1
rui=0
if(kanou):
    for i in range(2*n):
        if(kako[i]==1):
            rui+=1
        else:
            ans*=rui
            rui-=1
            ans=ans%p
    for i in range(1,n+1):
        ans*=i
        ans=ans%p
    print(ans)
else:
    print(0)

Measured memory_bytes: 6760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF 1LL<<60
#define pi 3.14159265358979323846
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;}

int main(){
    ll x,y;cin>>x>>y;
    
    ll ans=0;

    if(x==y){cout<<0<<endl;return 0;}//ｘ yが一致する場合

    if(x==0){//x==0の場合
        if(y>0){
            cout<<y<<endl;
            return 0;
        }else{
            cout<<abs(y)+1<<endl;
            return 0;
        }
    }

    if(y==0){//y==0の場合
        if(x>0){
            cout<<x+1<<endl;
            return 0;
        }else{
            cout<<abs(x)<<endl;
            return 0;
        }
    }

    if(x>=0 && y>=0){//x yの正負で場合わけ
        if(abs(y)>=abs(x)){
            ans=abs(y)-abs(x);
        }else{
            ans=abs(x)-abs(y)+2;
        }
    }else if(x>=0 && y<0){
        if(abs(y)>=abs(x)){
            ans=abs(y)-abs(x)+1;
        }else{
            ans=abs(x)-abs(y)+1;
        }
    }else if(x<0 && y>=0){
        if(abs(y)>=abs(x)){
            ans=abs(y)-abs(x)+1;
        }else{
            ans=abs(x)-abs(y)+1;
        }
    }else if(x<0 && y<0){
        if(abs(y)>=abs(x)){
            ans=abs(y)-abs(x)+2;
        }else{
            ans=abs(x)-abs(y);
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (ll i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main(){
    ll n, k;
    cin >> n >> k;
    vll a(n);
    REP(i,n){
        cin >> a[i];
    }

    vll s;  // 行先遷移をメモする
    vll vec(n+1,-1); // 何晩目に訪れたかメモする、同じところに二度目ならループ抜け
    ll mae = 0;
    ll ato = 0;

    ll v = 1; // 行先（1からはじまる） 

    while(vec[v] == -1){
        vec[v] = s.size();  // size = 0,1,2,,,
        // cout << "vec[v]: " << vec[v] << endl; //
        s.push_back(v);
        v = a[v-1];
    }
    ato = s.size() - vec[v];
    mae = vec[v];

    /*
     cout << "mae: " << mae << endl; // 
     cout << "ato: " << ato << endl; //
     cout << "vec "; //
     REP(i,n) cout << vec[i] << " "; //
     cout << endl; //
    */

    if(mae > k){
        cout << s[k] << endl;
    }else{
        k -= mae;
        k %= ato;
        cout << s[mae+k] << endl;
    }

    return 0;
}

Measured memory_bytes: 8496
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <iomanip>
using namespace std;

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

ll gcd(ll u, ll v){
  while(u > 0){
    if(v > u) swap(u, v);
    u %= v;
  }
  return v;
}

ll lcm(ll u, ll v){
  return u / gcd(u, v) * v;
}

int main(){
  ll n, m;
  vector<int> nums;
  while(cin >> n >> m && (n || m)){
    rep(i, m) {
      int a;
      cin >> a;
      nums.push_back(a);
    }

    sort(nums.begin(), nums.end());
    nums.erase(unique(nums.begin(), nums.end()), nums.end());
    
    ll rest = n;
    ll sum = n * (n + 1) / 2;
    int cnt = 0;
    m = nums.size();
    rep(i,1 << m){
      if(i == 0) continue;
      ll num = 1;
      cnt = 0;
      rep(j, m){
	if(i & (1 << j)){
	  cnt++;
	  num = lcm(num, nums[j]); 
	  if(num > n) break;
	}
      }
      //   cout << i << " " << num << endl;
      ll p = n / num;
      if(cnt % 2){
	rest -= p;
	sum -= num * p * (p + 1) / 2;
      }else{
	rest += p;
	sum += num * p * (p + 1) / 2;
      }
      
    }
    
    if(rest > 0){
      cout << sum / rest << ".";
      sum %= rest;
      sum *= 10;
      for(int i = 0; i< 10; i++) {
	cout << sum / rest;
	sum = (sum % rest) * 10;
      }
      cout << endl;
    }
    else cout << 0.00000000 << endl;
    nums.clear();
  }
  return 0;
}

Measured memory_bytes: 0
from numpy import zeros, int64
from numba import njit

R, C, K, *RCV = map(int64, open(0).read().split())
V = zeros((R + 1, C + 1), int64)
for r, c, v in zip(*[iter(RCV)] * 3):
    V[r][c] = v

@njit
def main():
    dp = zeros((R + 1, C + 1, 4), int64)
    for i in range(1, R + 1):
        for j in range(1, C + 1):

            vij = V[i][j]

            for k in range(4):
                dp[i][j][k] = max(
                    dp[i][j - 1][k],
                    dp[i - 1][j][3]
                )
            for k in range(3, 0, -1):
                dp[i][j][k] = max(
                    dp[i][j][k],
                    vij + dp[i][j][k - 1]
                )

    print(dp[R][C][3])

main()

Measured memory_bytes: 503776
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>


using namespace std;
int main(){
	int N;
	cin>>N;
	for(int II=0;II<N;II++){
	int C,A,N;
	cin>>C>>A>>N;
	int su=0;
	if(C>0&&N>0&&A>0){
		int min=N;if(min>A)min=A;if(min>C)min=C;
		C-=min;A-=min;N-=min;su+=min;
	}
	
	if(C>1&&A>0){
		int min=A;if(min>C/2)min=C/2;
		C-=min*2;A-=min;su+=min;
	}
	if(C>2){
		int min=C/3;
		C-=min*3;su+=min;
	}
	cout<<su<<endl;
	}
	return 0;
}
		
		

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

struct Node{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root;
struct Node *NIL;


struct Node *find(struct Node *u, int k){
  while (u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){

  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x-> key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y -> right = z;
  }
}

void inorder(struct Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
 
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){

  int n;
  int i,j;
  int x;
  
int count=0;
int cnt[10];
int tmp=0;

  struct Node *t;
  char *com;
  char *comin = "insert";
  char *compr = "print";

  com = (char*)malloc(7*sizeof(char));  

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", com);
    if(com[0] == 'f'){
      scanf("%d", &x);
      t = find(root, x);
      if(t != NIL){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
      else if(strncmp(com,comin,6)==0){
	scanf("%d",&x);
	insert(x);
      }
      else if(strncmp(com,compr,5)==0){

	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
    }

    return 0;
  }



Measured memory_bytes: 20440
a = int(input().strip())
b = list(input().strip())
r_count = 0
b_count = 0

for i in range(a):
     if b[i] == 'R':
          r_count += 1
     else:
          b_count +=1

if r_count > b_count:
     print('Yes')
else:
     print('No')

Measured memory_bytes: 3064
N = int(input())
b = list(map(int, input().split()))
MOD = 1000000007
sum_n = 0
a = []
for i in b:
  a.append(i%MOD)
sum_sum = sum(a[1:])
for i in range(N):

  sum_n = (sum_n + (a[i] * sum_sum) % MOD) % MOD
  if i+1 < N:
  	sum_sum = sum_sum - a[i+1]
print(sum_n % MOD)

Measured memory_bytes: 31516
#include <iostream>
#include <vector>



using namespace std;

int main(void){
int n;
cin >>n;
vector<int> a(n);
vector<int> b(n);
vector<int> c(n - 1);

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

for(int i = 0;i < n;i++){
cin >> b[i];
}
for(int i = 0;i < n;i++){
cin >> c[i];
}

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

cout << ans;

  return 0;    
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		HashMap<String, Boolean> hm = new HashMap<>();
		for(int i = 0; i < n; i++) {
			String tmp = sc.next();
			if(hm.containsKey(tmp)) {
				hm.remove(tmp);
			}else {
				hm.put(tmp, Boolean.TRUE);
			}
		}
		System.out.println(hm.size());
	}
}


Measured memory_bytes: 52700
N, K = [int(x) for x in input().split()]
s = set()
for i in range(K):
    d = int(input())
    if d == 1:
        s.add(int(input()))
    else:
        for a in input().split():
            s.add(int(a))
ans = sum([a not in s for a in range(1, N+1)])
print(ans)


Measured memory_bytes: 67784
use std::io::*;
use std::str::FromStr;
use std::cmp::*;

fn func(g: &Vec<Vec<usize>>, dp: &mut Vec<i64>, now: usize) -> i64 {
    if dp[now] == -1 {
        let mut cnt: i64 = 0;
        for i in &g[now] {
            cnt = max(cnt, func(&g, dp, *i) + 1);
        }
        dp[now] = cnt;
    }
    dp[now]
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut g: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut dp: Vec<i64> = vec![-1; n];
    for _ in 0..m {
        let (a, b) = (read::<usize>() - 1, read::<usize>() - 1);
        g[a].push(b);
    }
    let mut ans: i64 = 0;
    for i in 0..n {
        ans = max(ans, func(&g, &mut dp, i));
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 15228
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

signed main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> amari(K+1, 0);
  for( int i = 1; i <= N; i++ ) amari.at(i%K)++;
  
  int ans = 0;
  for( int A = 0; A < K; A++ ){
    int B = (K-A)%K;
    if( 2*B % K != 0 ) continue;
    else{
      ans += amari.at(A)*amari.at(B)*amari.at(B);
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1792
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import deque
mod=10**9+7
n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edges[x-1].append(y-1)
    edges[y-1].append(x-1)
root=-1
l=-1
for i in range(n):
    if len(edges[i])>l:
        root=i
        l=len(edges[i])
children=[[] for _ in range(n)]
V=[]
q=deque([root])
used=[False]*n
used[root]=True
while q:
    par=q.popleft()
    C=children[par]
    V.append(par)
    for v in edges[par]:
        if used[v]:
            continue
        C.append(v)
        used[v]=True
        q.append(v)
DP=[None for _ in range(n)]
for par in V[::-1]:
    white,black=1,1
    for c in children[par]:
        w,b=DP[c]
        white*=w+b
        white%=mod
        black*=w
        black%=mod
    DP[par]=(white,black)
print(sum(DP[root])%mod)

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

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

  if (A*N<B) {
    cout << A*N << endl;
  }
  else if (A*N>B) {
    cout << B << endl;
  }
  else if (A*N==B) {
    cout << B << endl;
  }
}


Measured memory_bytes: 256
# coding: utf-8


def solve():
    N, *al = map(int, open(0).read().split())
    a_dic = {}
    
    for i in range(N):
        a_dic[i+1] = al[i]
    
    a_dic_soted = sorted(a_dic.items(), key=lambda x:x[1])
    
    for i in a_dic_soted:
        print(i[0], end=' ')


if __name__ == '__main__':
    solve()

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

int main(){
  int n, a;
  set<int> A;

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    A.insert(a);
  }

  if (A.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 9728
import java.util.Scanner;
public class Main {
	//?????°
	static int x;
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		System.out.println(x*x*x);
		
	}
	public static void main(String[] args){
		solve();
	}
	

}

Measured memory_bytes: 26156
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repp(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define repd(i, n) for(ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

const ll M = 1e9 + 7;



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

    ll k;
    cin >> k;

    string s = "ACL";

    rep(i, k) cout << s;

    cout << endl;
}

Measured memory_bytes: 3612
N, M = map(int, input().split())
L = []
R = []
ans = 0

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
L_max = max(L)
L_min = min(R)

for i in range(N):
    if L_max <= i+1 <= L_min:
        ans += 1
print(ans)

Measured memory_bytes: 10996