akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
      Scanner sc=new Scanner(System.in);
      boolean can=true;
      while(can){
          int a=sc.nextInt();
          String op=sc.next();
          int b=sc.nextInt();
          if(op.equals("+"))System.out.println(a+b);
          if(op.equals("-"))System.out.println(a-b);
          if(op.equals("*"))System.out.println(a*b);
          if(op.equals("/"))System.out.println(a/b);
          if(op.equals("?")){
              can=false;
          }
      }
    }
}


Measured memory_bytes: 26336
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int num0=0, num1=0;
    for(auto c : s)
        if(c=='0') num0++;
        else num1++;
    cout << 2*min(num0, num1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>

using namespace std;


int main() {
	int i, j, k;
	int n, m, x, y;
	string s, t;
	//map< string  , string > mp;
	map< char, char > mp, mp2;

	cin >> s >> t;

	bool flag = false;

	for (i = 0; i < s.length(); i++) {
		auto it = mp.find(s[i]);
		auto it2 = mp2.find(t[i]);

		if (it != mp.end() || it2 != mp2.end()) { // 見つかった
			//std::cout << it->second << std::endl;

			if (it != mp.end()) {
				char ch = it->second;
				if (ch != t[i]) {
					flag = true;
					break;
				}
			}

			if (it2 != mp2.end()) {
				char ch2 = it2->second;
				if (ch2 != s[i]) {
					flag = true;
					break;
				}
			}
		}
		else {
			mp.insert(make_pair(s[i], t[i]));
			mp2.insert(make_pair(t[i], s[i]));
		}

		/*
		if (mp.count(s[i]) == 0) {
			mp.insert(s[i], t[i]);
		}
		*/
		//else {
		//	if (mp[s[i]] != t[i]) {
		//		flag = true;
		//		break;
		//	}
		//}
	}

	/*
	for (i = 0; i < s.length(); i++) {
		if (s[i] == s[i + 1]) {
			if (t[i] != t[i + 1]) {
				flag = true;
				break;
			}
		}
	}*/

	if (flag == false) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 776
#include<stdio.h>

int main(void)
{

	char a[4];
	int c = 6;
	scanf("%s",&a);
	for (int i = 0; i < 3;i++) {
		
		if (a[i] == '7') {
			printf("Yes");
			return 0;
		}
	}
	printf("No");

	return 0;
}

Measured memory_bytes: 1728
#include <cstdio>
#include <algorithm>
using namespace std;

int n;
int m;
int dx[256];
int dy[256];
int xs[256];
int ys[256];
bool field[100][100];


int main() {
  dx['N'] = 0;
  dy['N'] = 1;
  dx['S'] = 0;
  dy['S'] = -1;
  dx['E'] = 1;
  dy['E'] = 0;
  dx['W'] = -1;
  dy['W'] = 0;

  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    fill(field[0], field[30], false);

    for (int i=0; i<n; i++) {
      scanf("%d%d", &xs[i], &ys[i]);
      field[ys[i]][xs[i]] = true;
    }
  
    scanf("%d", &m);

    int x = 10;
    int y = 10;
    int cnt = 0;
    for (int i=0; i<m; i++) {
      char d;
      int l;

      scanf(" %c %d", &d, &l);
      while (l--) {
        x += dx[d];
        y += dy[d];
        if (field[y][x]) {
          field[y][x] = false;
          cnt++;
        }
      }
    }

    if (cnt == n) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
}

Measured memory_bytes: 2536
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=1;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi LV(n);
  Vi RV(n);
  Vi ANS;
  REP(i,n) IN2(LV[i],RV[i]);
  REP(i,n){
    FOR(j,LV[i],RV[i]+1){
      ANS.pb(j);
    }
  }
  SORT(ANS);
  REP(i,ANS.size()-1){
    if(ANS[i] != ANS[i+1]) z++;
  }
  OUT(z);
}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main(void){
	
	llint N,ans=0;
	
	cin >> N;
	
	vector<llint> L(2*N);
	
	for(llint i=0;i<N*2;i++){
		cin >> L[i];
	}
	
	sort(L.begin(),L.end());
	
	for(llint i=0;i<N*2;i+=2){
		ans += L[i];
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <functional>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int main() {
    int n, m; scanf("%d%d", &n, &m);
    vector<int> xs(m), ys(m);
    repeat (i, m) {
        scanf("%d%d", &xs[i], &ys[i]);
        -- xs[i];
        -- ys[i];
    }
    auto rel = vectors(n, n, bool()); // xRy iff (if x alives, then y must be died)
    repeat (i, m) {
        int x = xs[i];
        int y = ys[i];
        repeat (z, n) {
            if (rel[y][z]) rel[x][z] = true;
            if (rel[x][z]) rel[y][z] = true;
            if (rel[z][y]) rel[z][x] = true;
            if (rel[z][x]) rel[z][y] = true;
        }
        if (rel[y][y]) rel[x][x] = true;
        if (rel[x][x]) rel[y][y] = true;
        rel[x][y] = true;
        rel[y][x] = true;
    }
    int result = 0;
    repeat (j, n) repeat (i, j) {
        if (rel[j][j]) continue;
        if (rel[i][i]) continue;
        result += not (rel[i][j] or rel[j][i]);
    }
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 1024
#include <string>
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int i;
  long long int A = 20000;
  long long int B = 1000000000;
  int N;
  cin >> N;
  int p[N];
  long long int a[N];
  long long int b[N];

  for(i=0; i<N; i++){
    cin >> p[i];
  }

  for(i=0; i<N; i++){
    b[i] = B-2*(i+1)*A;
    a[i] = 2*(i+1)*A;
  }
  int j=0;
  for(i=0; i<N; i++){
    j = p[i];
    a[j-1] += i+1;
    b[j-1] += i+1;
  }
  for(i=0; i<N-1; i++){
    cout << a[i] << " ";
  }
  cout << a[N-1] << endl;
  for(i=0; i<N-1; i++){
    cout << b[i] << " ";
  }
  cout << b[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define pf pop_front
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=3005;
const ll inf=1e9+7;
double dp[maxn][maxn];
double p[maxn];
string s;
int main()
{
    while(cin>>s)
    {
        bool flag=true;
        rep(i,s.size())
        {
            if(s[i]!=s[s.size()-i-1]) flag=false;
        }
        ll sz=(s.size()-3)/2;
        string s1="",s2="";
        for(int i=0;i<=sz;i++)
        {
            s1+=s[i];
        }
        for(int i=(s.size()+1)/2;i<s.size();i++)
        {
            s2+=s[i];
        }
        rep(i,s1.size())
        {
            if(s1[i]!=s1[s1.size()-i-1]) flag=false;
        }
        rep(i,s2.size())
        {
            if(s2[i]!=s2[s2.size()-i-1]) flag=false;
        }
        if(flag) cout<<"Yes\n";
        else cout<<"No\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    int k, n; cin >> k >> n;
    vector<int> A(n); rep(i, n) cin >> A.at(i);

    int min = k - (k - A.at(n - 1) + A.at(0));
    rep(i, n - 1) chmin(min, k - (A.at(i + 1) - A.at(i)));

    cout << min << "\n";
    return 0;
}

Measured memory_bytes: 1024
def gs() STDIN.gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
 
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

h,w = gsmi
ass = Array.new(h){ gsmi }

cnt = 0
ans = []
for y in 1..h
	for x in 1..w
		next if ass[y-1][x-1].even?
		cnt += 1 if y!=h || x!=w
		if y!=h
			ans << [y,x,y+1,x].join(" ")
			ass[y][x-1] += 1
		elsif x!=w
			ans << [y,x,y,x+1].join(" ")
			ass[y-1][x] += 1
		end
	end
end

puts cnt
puts ans

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

#define fi first
#define se second

const int N = 200200;
const long long mod = 1e9 + 7;

using namespace std;

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        string s;
        cin >> s;
        vector < string > v;
        v.push_back("dreamer");
        v.push_back("dream");
        v.push_back("eraser");
        v.push_back("erase");

        vector < int > good((int)s.size() + 1);
        good[0] = true;
        for(int i = 0; i < s.size(); i++){
                for(auto t: v){
                        if(i + t.size() - 1 >= s.size()){
                                continue;
                        }
                        bool bad = false;
                        for(int j = 0; j < t.size(); j++){
                                if(t[j] != s[i + j]){
                                        bad = true;
                                }
                        }
                        if(!bad){
                                good[i + t.size()] |= good[i];
                        }
                }
        }
        cout << (good[s.size()] ? "YES" : "NO") << "\n";
}


Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
#define pp pair<int, int> 
//int 2×10の9乗
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<long, long>> a(n);
    rep(i, n) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());
    ll ans=0;
    rep(i, n){
        if(m>=a[i].second){
            ans+=a[i].first*a[i].second;
            m-=a[i].second;
        }
        else{ans+=a[i].first*m, m=0;        }
   }
    cout << ans << endl;
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

struct C1 {
    vector<ll> v_{};
    explicit C1(vector<ll> v) : v_(move(v)){}
    explicit C1(ll N, vector<ll> r, vector<tuple<ll, ll, ll>> v) {}
    ll resolve() {
        return 0;
    }
};

int run(istream& in, ostream& out) {
    ll N, W;
    in >> N >> W;
    ll v[100] = {0};
    ll w[100] = {0};
    ll C{};
    REP(i, N) {
        in >> w[i] >> v[i];
        C += v[i];
    }
    vector<vector<ll>> dp{};
    dp.resize(N, vector<ll>(C+1, INF));
    REP(i, N) {
        RANGE(j, 0, C) {
            if(j == 0) {
                dp[i][j] = 0;
                continue;
            }
            if(i==0) {
                if(j <= v[0]) {
                    dp[0][j] = w[0];
                }
            } else {
                dp[i][j] = min(dp[i][j], dp[i-1][j]);
                if(j >= v[i]) {
                    dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i]);
                } else {
                    dp[i][j] = min(dp[i][j],w[i]);
                }
            }
        }
    }
    auto ind = upper_bound(dp[N-1].begin(), dp[N-1].end(), W);
    --ind;
    auto ans = distance(dp[N-1].begin(), ind);
    out << ans << endl;
    debug(ans);
    return 0;
}

int run2() {
    ll N, M, R;
    cin >> N >> M >> R;
    vector<ll> r{};
    for (int i=0; i < R; ++i) {
        ll x;
        cin >> x;
        r.emplace_back(x);
    }
    vector<tuple<ll,ll,ll>> v{};
    for (int i=0; i < M; ++i) {
        ll a,b,c;
        cin >> a >> b >> c;
        v.emplace_back(make_tuple(a,b,c));
    }
    C1 c{N, move(r), move(v)};
    cout << c.resolve() << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


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

#define int ll
#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}


int32_t main() {
	int n;
	cin >> n;
	bool ok = 0;
	while(n > 0) {
		if(n%10 == 7)
			ok = 1;
		n /= 10;
	}
	if(ok)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main() {
  int N;cin >> N;
  vint x(N);
  repeat(i,N) cin >> x[i];
  x.push_back(INF);
  ll L;cin >> L;
  vector<vint> rmax(20,vint(N,0));
  repeat(i,N){
    rmax[0][i] = upper_bound(x.begin(),x.end(),x[i]+L)-x.begin()-1;
  }
  repeat(k,18){
    repeat(i,N){
      rmax[k+1][i] = rmax[k][rmax[k][i]];
    }
  }
  debugArray(rmax[0],N);
  int Q;cin >> Q;
  repeat(q,Q){
    int a,b;cin >> a >> b;
    a--;b--;
    if(a>b) swap(a,b);
    ll ans = 0;
    for(int k=18;k>=0;k--){
      //debug(a);
      if(rmax[k][a] >= b) continue;
      ans |= 1<<k;
      a = rmax[k][a];
    }
    ans++;
    cout << ans <<endl;
  }
  //cerr << bitset<20>(524287) << endl;
  return 0;
}


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

//macro
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, n, m) for(int i = m; i < n; ++i)
#define LL long long

using namespace std;

typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int main(){
    string s;

    cin >> s;

    REP(i, s.size() - 1){
        FOR(j, s.size(), i + 1){
            if(s[i] == s[j]){
                cout << "no" << endl;
                return 0;
            }
        }
    }

    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,q,ans,num;
ll a,b;
ll aka,ao;
char s[300005];
ll color[100005]; //0=mada 1=aka 2=ao
bool kantan=false;

void dfs(ll node,ll c){
	if(color[node]!=c && color[node]>=1){
		kantan=true;
		return;
	}else if(color[node]>=1){
		return;
	}else{
		color[node]=c;
		if(c==1){
			aka++;
		}else{
			ao++;
		}
	}
	if(c==1){
		for(int i=0;i<G[node].size();i++){
			dfs(G[node][i],2);
		}
	}else{
		for(int i=0;i<G[node].size();i++){
			dfs(G[node][i],1);
		}
	}
}


int main(){
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(1,1);
	if(kantan){
		ans=n*(n-1)/2-m;
	}else{
		ans=max(aka*ao-m,0ll);
	}
	p(ans);
	return 0;
}

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

using namespace std;

using ll = long long;

const int N = 2e5 + 5;
const ll mod = 1e9 + 7;

ll mem[N][2][2][2];
char s[N];
int n;

ll dp(int i , bool f , bool a , bool b){
    if(i == n)return 1;

    ll &ret = mem[i][f][a][b];
    if(ret != -1)return ret;
       ret = 0;

    if(f){
        ret = ret + dp(i + 1 , f , 1 , 0);ret %= mod;
        ret = ret + dp(i + 1 , f , 0 , 1);ret %= mod;
        ret = ret + dp(i + 1 , f , 0 , 0);ret %= mod;
    }
    else {
        if(s[i] == '1'){
            ret = ret + dp(i + 1 , f , 1 , 0);ret %= mod;
            ret = ret + dp(i + 1 , f , 0 , 1);ret %= mod;
            ret = ret + dp(i + 1 , 1 , 0 , 0);ret %= mod;
        }
        else {
            ret = ret + dp(i + 1 , f , 0 , 0);ret %= mod;
        }
    }

    return ret;
}

main(){
    scanf("%s" , s);
    n = strlen(s);

    memset(mem , -1 , sizeof mem);
    printf("%lld\n" , dp(0 , 0 , 0 , 0));

    return 0;
}


Measured memory_bytes: 17536
#include  <iostream>
#include  <stdio.h>
using namespace std;

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int N_int;
    cin >> N_int;

    int H[N_int];
    for( int ni = 0 ; ni < N_int ; ni++ ){
        cin >> H[ni];
    }

    int ans_int = 0;
    int max = 0;

    for( int ni = 0 ; ni < N_int ; ni++ ){
        if(H[ni] >= max){
            ans_int = ans_int + 1;
            max = H[ni];
        }
    }

    cout << ans_int;
    

}

Measured memory_bytes: 256
k,s=[int(i) for i in input().split()]
ans=0
for a in range(k+1):
  for b in range(a+1):
    if 0<=s-a-b<=b:
      l=len(set([a,b,s-a-b]))
      if l==1:
        ans+=1
      elif l==2:
        ans+=3
      else:
        ans+=6
print(ans)
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	ll N, K;
	cin >> N >> K;
	ll ans = 0;
	for(ll i = K; i <= N+1; i++){
		//cout << i << ":" << endl;
		if(i%2 == 0){
			//cout << i/2*(2*N-i+1) << " " << i/2*(i-1) << endl;
			ans += i/2*(2*N-i+1) - i/2*(i-1) + 1;
		}
		else{
			//cout << (2*i-i+1)/2*i << " " << (i-1)/2*i << endl;;
			ans += (2*N-i+1)/2*i - (i-1)/2*i + 1;
		}
		//cout << ans << endl;
		ans %= MOD1097;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3600
import math
n = int(raw_input())
x = map(lambda l: int(l)*1.0, (raw_input()).split(" "))
y = map(lambda l: int(l)*1.0, (raw_input()).split(" "))

for p in range(1,4):
    d = [math.pow(math.fabs(x[i] - y[i]), p) for i in range(n)]
    print math.pow(sum(d), 1.0/p)

d = [math.fabs(x[i]-y[i]) for i in range(n)]
print max(d)

Measured memory_bytes: 6596
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7


n=I()
print((n*(n+1))//2)

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

int main(){
  int n, q;
  cin >> n >> q;
  vector<P> v;
  int s[n], t[n], x[n];
  rep(i,n) {
    cin >> s[i] >> t[i] >> x[i];
    v.push_back(P((s[i]-x[i])*2-1,i+1));
    v.push_back(P((t[i]-x[i])*2-1,n+i+1));
  }
  int d[q];
  rep(i,q) {
    cin >> d[i];
    v.push_back(P(d[i]*2,-i));
  }
  sort(v.begin(),v.end());
  vector<int> ans(q,-1);
  multiset<int> event;
  for(auto k : v) {
    if(k.second > 0 && k.second <= n) {
      event.insert(x[k.second-1]);
    } else if(k.second > n) {
      event.erase(event.find(x[k.second-n-1]));
    } else {
      if(!event.empty()) ans[-k.second] = *event.begin();
    }
  }
  for(auto k : ans) cout << k << endl;
  return 0;
}

Measured memory_bytes: 21096
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#include <bits/stdc++.h>

using namespace std;

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

#ifdef _MSC_VER
#define __builtin_popcount (int)__popcnt
#define __builtin_popcountll (int)__popcnt64
#define $ system("pause")
#else
#define $
#endif
#define MOD ll(998244353)
#define MAXN int(1e5 + 30)
#define lg 20
#define inf (ll)1e17

template <typename T, typename S>
inline T smin(T &a, const S &b) { return a > b ? a = b : a; }
template <typename T, typename S>
inline T smax(T &a, const S &b) { return a < b ? a = b : a; }
ll po(ll v, ll u) { return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1; }
inline void add(ll &l, const ll &r) { l = (1ll * l + r) % MOD; }
ll gcd(ll v, ll u) { return u ? gcd(u, v % u) : v; }

int n, arr[MAXN];
int h[2][MAXN];
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	for (int i = 1; i <= n; i++)
		h[i & 1][arr[i]]++;
	
	int aid = max_element(h[0], h[0] + MAXN) - h[0];
	int a = h[0][aid]; h[0][aid] = 0;
	int bid = max_element(h[0], h[0] + MAXN) - h[0];
	int b = h[0][bid]; h[0][bid] = 0;

	int cid = max_element(h[1], h[1] + MAXN) - h[1];
	int c = h[1][cid]; h[1][cid] = 0;
	int did = max_element(h[1], h[1] + MAXN) - h[1];
	int d = h[1][did]; h[1][did] = 0;

	if (aid != cid) cout << n - a - c << endl;
	else if (a + c == n) cout << n / 2 << endl;
	else
		cout << n - max(a + d, b + c) << endl;
	$;
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(n);
    each (i, a) cin >> i;
    cout << accumulate(a.begin(), a.end(), -n) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FIO;
    long long a,b;
    cin>>a>>b;
    cout<<(a*b)/__gcd(a,b)<<endl;
}


Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

vector<int> g[N], sorted_vertices;
bool seen[N];
int idx[N], parent[N];

void toposort(int u);
void recover(int u);

int main() {
	fast_cin();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n - 1 + m; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
	}
	for (int i = 1; i <= n; ++i) {
		if (!seen[i]) {
			toposort(i);
		}
	}
	reverse(sorted_vertices.begin(), sorted_vertices.end());
	for (int i = 0; i < n; ++i) {
		idx[sorted_vertices[i]] = i;
	}
	memset(seen, 0, sizeof(seen));
	for (auto &u : sorted_vertices) {
		if (!seen[u]) {
			recover(u);
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << parent[i] << '\n';
	}
}

void toposort(int u) {
	seen[u] = true;
	for (auto &v : g[u]) {
		if (!seen[v]) {
			toposort(v);
		}
	}
	sorted_vertices.pb(u);
}

void recover(int u) {
	seen[u] = true;
	vector<pii> children;
	for (auto &v : g[u]) {
		children.pb({idx[v], v});
	}
	sort(children.begin(), children.end());
	for (auto &p : children) {
		if (!seen[p.second]) {
			parent[p.second] = u;
			recover(p.second);
		}
	}
}

Measured memory_bytes: 20088
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

    int n;
    cin>>n;

    string s;
    cin>>s;


    if(n&1)
    {
		cout<<"No";
    }
    else
    {
    	string s1 = s.substr(0,n/2);
    	string s2 = s.substr(n/2,n/2);
    	if(s1 == s2)
    	{
    		cout<<"Yes";
    	}
    	else
    	{
    		cout<<"No";
    	}
    }






    return 0;
}

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

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		
		String[] strs = str.split(" ");
		if(strs[0].equals(strs[1])) {
			if(!strs[0].equals(strs[2])) {
				System.out.println("Yes");				
			}else {
				System.out.println("No");	
			}
			
		}else if(strs[1].equals(strs[2])) {
			if(!strs[1].equals(strs[0])) {
				System.out.println("Yes");
			}else {
				System.out.println("No");	
			}
		}else if(strs[0].equals(strs[2])) {
			if(!strs[0].equals(strs[1])) {
				System.out.println("Yes");
			}else {
				System.out.println("No");	
			}
		}else {
			System.out.println("No");
			
		}
		
	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c){
		int d=c-a;
		if(b>=d){
			cout<<"YES";
	    	return 0;
		}
	}
	cout<<"NO";
} 

Measured memory_bytes: 256
def e_league():
    import sys
    sys.setrecursionlimit(10**6)
    N = int(input())
    A = [[int(i) - 1 for i in input().split()] for j in range(N)]

    # 各試合に識別番号をつける
    match_num = 0
    identification = [[None] * N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if i < j:
                identification[i][j] = match_num
                match_num += 1

    vertex_max = N * (N - 1) // 2  # 試合数だけ頂点を作る
    # match_allocation[n]: n番の選手はこの要素で指定された試合をする必要がある
    match_allocation = [row for row in A]
    # next_match[n]: n番の試合の後に行わなければならない試合の番号
    next_match = [[] for _ in range(vertex_max)]

    def to_id(i, j):
        if i > j:
            i, j = j, i
        return identification[i][j]

    # 上で定義したリストの要件を満たすように値を入れていく
    for i in range(N):
        for j in range(N - 1):
            match_allocation[i][j] = to_id(i, match_allocation[i][j])
        for j in range(N - 2):
            next_match[match_allocation[i][j]].append(match_allocation[i][j + 1])

    # ここから、グラフはDAGか？　DAGなら最長パスはいくらか？
    # 最長パスの長さが解になるようにグラフを作っている
    is_visited = [False] * vertex_max
    is_calculated = [False] * vertex_max
    dp = [0] * vertex_max  # dp[v]: 頂点vからの最大パス長

    def dfs(v):
        if is_visited[v]:
            # 計算結果が確定していない頂点に再度訪れた→DAGじゃない
            if not is_calculated[v]:
                return -1
            return dp[v]

        is_visited[v] = True
        dp[v] = 1
        for u in next_match[v]:
            ret = dfs(u)
            if ret == -1:
                return -1  # vから先でDAGじゃないところがあった
            dp[v] = max(dp[v], ret + 1)  # v-u間の分、+1
        is_calculated[v] = True  # ここでようやく結果が確定
        return dp[v]

    ans = 0
    for v in range(match_num):
        res = dfs(v)
        if res == -1:
            return -1
        ans = max(ans, res)
    return ans

print(e_league())

Measured memory_bytes: 183348
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL)x = x->left;

  return x;
}

Node treeSearch(Node u, int k){
  if(u ==NIL || k == u->key)return u;
  if(k<u->key)return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL)return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL)x = y->left;
  else x = y->right;
  if(x != NIL)x->parent = y->parent;
  if(y->parent == NIL)root = x;
  else if(y == y->parent->left)y->parent->left = x;
  else y->parent->right = x;
  if(y != z)z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = 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(Node u){

  if (u!=NIL){

    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){

  if (u!=NIL){

    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    int p;
    pair<pair<string,int>,int> res[100];
    for(int i=0; i<n; i++) {
        cin >> s >> p;
        res[i]=make_pair(make_pair(s, -p), i);
    }

    sort(res,res+n);
    for(int i=0; i<n; i++) {
        cout << res[i].second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  ll n, m, min, minNum;
  pair<ll, ll> minP;
  cin >> n >> m;

  vector<pair<ll, ll>> stu(n);
  vector<pair<ll, ll>> p(m);
  REP(i, n)
  {
    cin >> stu[i].first >> stu[i].second;
  }
  REP(i, m)
  {
    cin >> p[i].first >> p[i].second;
  }

  REP(i, n)
  {
    min = abs(stu[i].first - p[0].first) + abs(stu[i].second - p[0].second);
    minP.first = p[0].first;
    minP.second = p[0].second;
    minNum = 1;
    REP(j, m)
    {

      if (min > (abs(stu[i].first - p[j].first) + abs(stu[i].second - p[j].second)))
      {
        min = abs(stu[i].first - p[j].first) + abs(stu[i].second - p[j].second);
        minP.first = p[j].first;
        minP.second = p[j].second;
        minNum = j + 1;
      }
      else if (min == (abs(stu[i].first - p[j].first) + abs(stu[i].second - p[j].second)))
      {
        if (p[j].first < minP.first || p[j].second < minP.second)
        {
          minP.first = p[j].first;
          minP.second = p[j].second;
          min = abs(stu[i].first - p[j].first) + abs(stu[i].second - p[j].second);
          minNum = j + 1;
        }
      }
    }
    cout << minNum << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a)
#define ALL(a) (a).begin(),(a).end()
#define fi first
#define se second

template<typename T>
void print_array(T* arr, int num) {
   FOR(i, 0, num) cout << arr[i] << ' ';
   cout << endl;
}

template<typename T> 
void print_vector(vector<T> vec) {
   FOR(i,0,vec.size()) cout << vec[i] << ' ';
   cout << endl;
}

const ll mx = 1e16 + 1000ll;
ll k;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
   // freopen("test.txt", "r", stdin);
    cin >> k;
    cout << 50 << endl;
    if (k < 50) {
    	FOR(i,0,49) cout << 0 << " ";
    	cout << k * 50ll;
    } else {
    	FOR(i,0,50) {
    		k--;
    		ll cur = 50ll + (k / 50ll) - i;
    		cout << cur << " ";
    	}
    }
    
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		vi v(24 * 60 * 60 + 1, 0);
		REP(i, n) {
			int h, m, s;
			char c;
			cin >> h >> c >> m >> c >> s;
			v[h * 60 * 60 + m * 60 + s]++;
			cin >> h >> c >> m >> c >> s;
			v[h * 60 * 60 + m * 60 + s]--;
		}
		REP(i, 24 * 60 * 60) {
			v[i + 1] += v[i];
		}
			cout << *max_element(ALL(v)) << endl;
	
	}
	return 0;
}

Measured memory_bytes: 3532
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1);flag=1
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
for i in range(N):
    a=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-t[i+1]+t[i]
    if a>0 or a%2:flag=0;break
print("Yes" if flag else "No")


Measured memory_bytes: 11636
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
typedef long long ll;
using namespace std;

int main(){
  ll n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  vector<int> p(n, k - q); //全員のポイントをあらかじめq引いておき、正解者に足す
  rep(i, q){ 
    cin >> a.at(i);
    p.at(a.at(i) - 1) += 1;
  }
  // 出力
  rep(i, n){
    if(p.at(i) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<climits>
using namespace std;

int main(){
	char pn[8][10] = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};
	int pR[8] = {0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff},
		pG[8] = {0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff},
		pB[8] = {0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff};
	char c;
	while(scanf(" %c",&c),c!='0'){
		int N; scanf("%x",&N);
		int R = N/(1<<16)%(16*16), G = N/(1<<8)%(16*16), B = N/(1<<0)%(16*16);
		int min_ = INT_MAX,ans;
		for(int i=0;i<8;i++){
			int dR = pR[i]-R, dG = pG[i]-G, dB = pB[i]-B;
			int d = dR*dR+dG*dG+dB*dB;
			if(d<min_){
				min_ = d; ans = i;
			}
		}
		printf("%s\n",pn[ans]);
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;

int n;
int a[N], b[N], c[N];
ll sum, sum1, ans;
bool fl;
int cc;

void putans(ll asd) {
  cout << asd;
  exit(0);
}

main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i], &b[i]);
    c[i] = a[i] - b[i];
    sum += a[i];
    if (c[i] <= 0) {
      sum1 -= c[i];
      ans += a[i];
    }
  }
  fl = 1;
  for (int i = 1; i <= n; i++)
    fl &= (a[i] == b[i]);
  if (fl) {
    putans(0);
  }
  int mn = inf;
  int mx = -1;
  for (int i = 1; i <= n; i++) {
    if (c[i] > 0) {
      if (b[i] < mn) {
        mn = b[i];
        mx = a[i];
      }
    }
  }
  putans(sum - mn);
}


Measured memory_bytes: 512
N=int(input())
ans=[0]*(N)
hani=int(N**(0.5))+2
for i in range(1,hani):
    for j in range(1,hani):
        for k in range(1,hani):
            v=i**2+j**2+k**2+i*j+j*k+k*i
            if(v<=N):
                ans[v-1]=ans[v-1]+1
for i in ans:
    print(i)


Measured memory_bytes: 75116
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  string s;
  int m;
  cin >> s >> m;
  int n=s.size();    
  
  vector<char> r={};
  vector<char> l={};
  
  bool muki=true;
  
  rep(i,m){
  int x;
  cin>>x;
    if(x==1) {
      if(muki) muki=false;
      else muki=true;
    }
    if(x==2) {
    int y;
    char z;
    cin>>y>>z;
      if((y==2 && muki)||(y==1 && !muki)) r.pb(z);
      if((y==2 && !muki)||(y==1 && muki)) l.pb(z);
    }
  }
  
  if(muki){
    for(int i=l.size()-1;i>=0;i--){
      cout << l[i];
    }
    cout << s;
    rep(i,r.size()){
      cout << r[i];
    }
  }
  
  
  if(!muki) {
    for(int i=r.size()-1;i>=0;i--){
      cout << r[i];
    }
    for(int i=s.size()-1;i>=0;i--){
      cout << s[i];
    }    
    rep(i,l.size()){
      cout << l[i];
    }
  }
  
}

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

int main(){
    int n,x; cin >> n >> x;
    vector<int> l(n);
    rep(i,n){
        cin >> l[i];
    }
    int d[n] = {0};
    int ans = 1;
    for(int i = 1; i < n+1 ;i++){
        d[i] = d[i-1] + l[i-1];
        // cout << d[i] << " " << i << endl;
        if(d[i] > x) {
            break;
        }
        ans = i+1;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n,i,j;
	double m,l,t[3005],x=0,y=0;
	double pi=3.141592653589793;
	cin >> n >> l;
	m=n;
	for(i=0;i<n;i++) cin >> t[i];
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			x+=(n-(j-i-1)-2)*cos(pi*(t[i]+t[j])/l);
			y+=(n-(j-i-1)-2)*sin(pi*(t[i]+t[j])/l);
			x+=(j-i-1)*cos(pi*(t[i]+t[j])/l+pi);
			y+=(j-i-1)*sin(pi*(t[i]+t[j])/l+pi);
		}
	}
	x=x/(m*(m-1)*(m-2)/6);
	y=y/(m*(m-1)*(m-2)/6);
	printf("%.13lf %.13lf\n",x,y);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int a[200000], dist[200000];

int main()
{
  int k, n, result = 0;
  cin >> k >> n;

  REP(i, n)
  {
    cin >> a[i];
  }
  dist[0] = k - a[n - 1] + a[0];
  FOR(i, 1, n)
  {
    dist[i] = a[i] - a[i - 1];
  }
  sort(dist, dist + n);
  REP(i, n - 1)
  {
    result += dist[i];
  }

  cout << result << endl;
}

Measured memory_bytes: 5164
a = int(input())
b = []
ppp = 0
for i in range(a):
	b.append(input())
	y = list(b[-1])
	s = y[0]
	e = y[-1]
	if i == 0:
		n = e
	else:
		for j in range(len(b)-1):
			if b[-1] == b[j]:
				ppp = 1
			if j == len(b)-2:
				yy = list(b[j])
				ss = yy[0]
				ee = yy[-1]
				if ee != s:
					ppp = 1
	if ppp == 1:
		break
if ppp == 1:
	print("No")
else:
	print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std; 
  
typedef long long int ll;
typedef set <int> se;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll gcd(ll a,ll b)
{
	if(a%b==0)
		return b;
	else
		return gcd(b,a%b);
}
// int solve()
// {
	
// 	return 0;
// }
int main()
{
	// SPEED;

	ll n,sum,r=0,g=0,b=0,k;
	string s;
	cin>>n;
	cin>>s;
	for (int i = 0; i < n; ++i)
	{
		if(s[i]=='R')
			r++;
		else if(s[i]=='G')
			g++;
		else
			b++;
	}
	sum=r*g*b;
	for (int i = 0; i < n-2; ++i)
	{
		for (int j = i+1; j < n-1; ++j)
		{
			if(s[i]==s[j])
				continue;

			k=2*j-i;
			if(k>=n)
				continue;

			if(s[j]==s[k] || s[i]==s[k])
				continue;

			sum--;
		}
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 3624