akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
	int n, m;
	scanf("%d %d",&n,&m);
	int e[n][m];
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			scanf("%d",&e[i][j]);
		}
	}
	vector<int> a, b, c, d;
	for (int i = 0; i < n; i++){
		for (int j = m - 1; j > 0; j--){
			if (e[i][j] % 2 == 1){
				a.push_back(i);
				b.push_back(j);
				c.push_back(i);
				d.push_back(j - 1);
				e[i][j - 1]++;
			}
		}
	}
	for (int i = n - 1; i > 0; i--){
		if (e[i][0] % 2 == 1){
			a.push_back(i);
			b.push_back(0);
			c.push_back(i - 1);
			d.push_back(0);
			e[i - 1][0]++;
		}
	}
	printf("%d\n",a.size());
	for (int i = 0; i < a.size(); i++){
		printf("%d %d %d %d\n",a[i] + 1,b[i] + 1,c[i] + 1,d[i] + 1);
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int,int> > team(N);
    for (int i = 0; i < N; i++) {
        team[i].second = i + 1;
    }

    for (int i = 0; i < N * (N - 1) / 2; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if (c < d) team[b-1].first+=3;
        if (c > d) team[a-1].first+=3;
        if (c == d) {
            team[a-1].first++;
            team[b-1].first++;
        }
    }

    sort(team.begin(), team.end());
    reverse(team.begin(), team.end());

    vector<int> rank(N);
    rank[team[0].second-1] = 1;
    for (int i = 1, count = 1, r = 1; i < N; i++) {
        if (team[i].first == team[i-1].first) {
            rank[team[i].second-1] = r;
            count++;
        }
        else {
            r += count;
            rank[team[i].second-1] = r;
            count = 1;
        }
    }

    for (auto i : rank) cout << i << endl;

    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;

int main(void){
    ll result = 1;
    
    string S;
    ll K;
    cin >> S >> K;
    
    rep(i, min((ll)S.size(), K)){
        if(S[i] == '1'){
            continue;
        }else{
            result = S[i] - '0';
            break;
        }
    }
    
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ALDS1_1_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.WriteLine(gcd(a[0],a[1]));
        }

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

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
 
const int N=110;
int n,m,a[N];
 
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	int s=0;
	for(int i=1;i<=n;i++) {
		s+=a[i];
		if(s>m) return printf("%d\n",i-1),0;
	}
	printf("%d\n",s==m?n:n-1);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var X = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Enumerable.Range(0, 101).Select(x => X.Sum(y => (x - y) * (x - y))).Min());
    }
}

Measured memory_bytes: 13396
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    while (true) {
        val h = sc.nextInt()
        val w = sc.nextInt()
        if (h == 0 && w == 0) break
        print("${"#".repeat(w)}\n")
        print("#${".".repeat(w-2)}#\n".repeat(h-2))
        print("${"#".repeat(w)}\n\n")
    }
}


Measured memory_bytes: 29876
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include <functional>
#include<queue>
using namespace std;
static const int MAX = 100000;
typedef long long llong;

int n, m;
priority_queue<int> v;

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

    int x;
    for (int i = 0; i < n;i++){
        scanf("%d", &x);
        v.push(x);
    }

    int z;
    for (int i = 0; i < m; i++){
        z = v.top() / 2; v.pop();
        //v[0]を二分探索で挿入
        v.push(z);
    }

    llong ans = 0;
    while (!v.empty()){
        ans += v.top();
        v.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
a = list(map(int,input().split()))
counter = 0
for i in range (101):
  if a[0] <= i <= a[1] and a[2] <= i <= a[3]:
    counter += 1
if counter > 0:
  print ('{0}'.format(counter - 1))
else:
  print ('{0}'.format(0))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a>>b>>c;
    cout << (a+b)*c/2 << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
A_list = set([int(input()) for _ in range(M)])
Dp_list = [0] * (N+1)
Dp_list[0] = 1

if 1 in A_list:
    Dp_list[1] = 0
else:
    Dp_list[1] = 1

if N != 1:
    for i in range(2, N + 1):
        if i in A_list:
            continue

        Dp_list[i] = Dp_list[i-2] + Dp_list[i-1]
        Dp_list[i] %= 1000000007
    print(Dp_list[N])
else:
    print(1)

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

int main()
{
    int X, Y;
    cin >> X >> Y;
    for(int x = 0; x <= X; x++) {
        if((2*x + 4*(X-x)) == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll n;
    char last;
    string  w;
    cin >> n;
    string words[n];
    rep(i, n){
        cin >> words[i];
        if(i){
            if(words[i][0] != last){
                cout << "No" << endl;
                return 0;
            }
        }
        rep(j, i){
            if(words[j] == words[i]){
                cout << "No" << endl;
                return 0;
            }
        }
        last = words[i][words[i].length() - 1];
    }
    cout << "Yes" << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			int n = cin.nextInt();
			if(n==0){
				break;
			}
			int[][] a  = new int[n+1][n+1];
			for(int i =0;i<n;i++){
				for(int j = 0;j < n;j++){
					a[i][j]=cin.nextInt();
				}
			}
			int sum1=0;
			int sum2=0;
			int sum3=0;
			for(int i = 0;i<n;i++){
				for(int j = 0;j < n;j++){
					sum1+=a[i][j];
					sum2+=a[j][i];
				}
				a[i][n]=sum1;
				a[n][i]=sum2;
				sum3+=sum1;
				sum1=sum2=0;
			}
			a[n][n]=sum3;
			for(int i = 0;i<=n;i++){
				for(int j = 0;j <= n;j++){
					System.out.printf("%5d",a[i][j]);
				}
				System.out.println();
			}
		}

	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a+b==15)
        cout<<"+"<<endl;
    else if(a*b==15)
            cout<<"*"<<endl;
        else
            cout<<"x"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200;
const int MOD=998244353;
typedef struct P { int x,y; P() {} P(int x,int y):x(x),y(y) {} } P;
const P operator-(const P &a,const P &b) { return P(a.x-b.x,a.y-b.y); }
const ll operator^(const P &a,const P &b) { return (ll)a.x*b.y-(ll)a.y*b.x; }
bool online(const P &a,const P &b,const P &c) { return ((b-a)^(c-a))==0; }

int n;
P p[MAXN];

int p2[MAXN+1];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d%d",&p[i].x,&p[i].y);

	p2[0]=1; REP(i,n) p2[i+1]=(ll)2*p2[i]%MOD;
	int ret=(p2[n]+MOD-1)%MOD;
	REP(i,n) {
		ret=(ret+MOD-1)%MOD;
		FOR(j,i+1,n) {
			int cnt=0;
			FOR(k,j+1,n) if(online(p[i],p[j],p[k])) ++cnt;
			//printf("%d and %d -> %d (%d)\n",i,j,cnt,p2[cnt]);
			ret=(ret+MOD-p2[cnt])%MOD;
		}
	}
	printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int A,B;
  string S;
  cin>>A>>B>>S;
  bool flag=true;
  for(int i=0;i<A;i++){
    int x=S.at(i)-'0';
    //cout<<x<<endl;
    if(!(0<=x&&x<10)){
      flag=false;
    }
  }
  if(S.at(A)!='-'){
    flag=false;
  }
  for(int i=0;i<B;i++){
    int x=S.at(A+1+i)-'0';
    //cout<<x<<endl;
    if(!(0<=x&&x<10)){
      flag=false;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main()
{
    int a, b, c, x, y;
    cin>>a>>b>>c>>x>>y;

    int res=INT_MAX;
    for(int i=0; i<=x; ++i) res=min(res, a*i+c*2*(x-i)+b*max(0, y-(x-i)));
    for(int i=0; i<=y; ++i) res=min(res, b*i+c*2*(y-i)+a*max(0, x-(y-i)));
    cout<<res<<endl;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<char, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int N; cin >> N;
    vector<int> a( N );
    REP( i, N ) cin >> a[i];

    int ans = 0;
    int right = 0, sum = 0;
    REP( left, N ){
        while( right < N && ( sum & a[right] ) == 0 ){
            sum += a[right++];
        }

        ans += right - left;

        if( right != left ) sum -= a[left];
        else right++;
    }

    cout << ans << endl;
}


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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define pai pair<int,int> 
#define For(i,a,n) for(i=a;i<n;i++)
#define all(ar) ar.begin(),ar.end() 
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
const ll mod = 1000000007;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    int i,j,h,w;
    cin>>h>>w;
    string ar[h];
    set<pai> hash;
    set<int> row,col;
    For(i,0,h) cin>>ar[i];
    For(i,0,h){
        For(j,0,w){
            if(ar[i][j] == '#'){
                hash.insert({i,j});
                row.insert(i); col.insert(j);
            }
        }
    }
    For(i,0,h){
        if(row.count(i)){
            For(j,0,w){
                if(col.count(j)){
                    if(hash.count({i,j})) cout<<"#";
                    else cout<<".";
                }
            }
            cout el;
        }
    }
    return 0;
}

Measured memory_bytes: 768
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String s = in.readLine();
		String[] tokens = in.readLine().split(" ");
		int x = Integer.parseInt(tokens[0]);
		int y = Integer.parseInt(tokens[1]);
		Deque<Integer> vertical = new ArrayDeque<>();
		Deque<Integer> horizontal = new ArrayDeque<>();
		vertical.addLast(0);
		horizontal.addLast(0);

		boolean isHorizontal = true;
		for (int i = 0; i < s.length(); ++i) {
			if (s.charAt(i) == 'F') {
				if (isHorizontal) {
					int val = horizontal.pollLast();
					horizontal.addLast(val + 1);
				} else {
					int val = vertical.pollLast();
					vertical.addLast(val + 1);
				}
			} else {
				if (isHorizontal) {
					isHorizontal = false;
					vertical.addLast(0);
				} else {
					isHorizontal = true;
					horizontal.addLast(0);
				}
			}
		}

		List<Integer> horizontalMoves = new ArrayList<>();
		List<Integer> verticalMoves = new ArrayList<>();
		int initY = 0;
		int initX = horizontal.isEmpty() ? 0 : horizontal.pollFirst();
		horizontalMoves.addAll(horizontal);
		verticalMoves.addAll(vertical);
		Comparator<Integer> comp = new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return -1 * Integer.compare(o1, o2);
			}
		};
		Collections.sort(horizontalMoves, comp);
		Collections.sort(verticalMoves, comp);
		boolean movableHorizontal = isMovable(horizontalMoves, x - initX);
		boolean movableVertical = isMovable(verticalMoves, y - initY);
		if (movableHorizontal && movableVertical) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	static boolean isMovable(List<Integer> moves, int dist) {
		int current = 0;
		for (int i = 0; i < moves.size(); ++i) {
			Integer move = moves.get(i);
			if (current < dist) {
				current += move;
			} else {
				current -= move;
			}
		}
		if (dist == current) {
			return true;
		} else {
			return false;
		}
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;

# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
# define pb push_back
 
ll A,B,M;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> A >> B >> M;
    vector<ll> a(A);
    vector<ll> b(B);
    
    vector<ll> x(M);
    vector<ll> y(M);
    vector<ll> c(M);
    map<pair<ll,ll>,ll> values {};
    
    rep(i,A) {
        cin >> a[i];
    }
    rep(i,B) {
        cin >> b[i];
    }
    rep(i,M) {
        cin >> x[i];
        cin >> y[i];
        cin >> c[i];
    }
    
    ll m = INF;
    
    rep(i,M) {
        ll sum = a[x[i]-1] + b[y[i]-1] - c[i];
        if (sum < m) {
            m = sum;
        }
    }
    
    sort(all(a));
    sort(all(b));
    ll l = a[0]+b[0];
    cout << min(l, m) << endl;
    
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<string, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>>sw(m);
	rep(i, m) {
		int k;
		cin >> k;
		rep(j, k) {
			int s;
			cin >> s;
			s--;
			sw[i].push_back(s);
		}
	}
	vector<int>p(m);
	int ans(0);
	rep(i, m)cin >> p[i];
	for (int i = 0; i <(1<< n); ++i) {
		bool ok(true);
		rep(j, m) {
			int cnt(0);
			for (auto c : sw[j]) {
				if ((i >> c) & 1)cnt++;
			}
			if (cnt % 2 != p[j]) {
				ok = false;
				//cout << i;
			}
		}
		if (ok) {
			ans++;
			//cout << i << endl;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define il inline
#define rg register
using namespace std;
typedef long long LL;
const LL m_63=1061109567;
const LL m_127=2139062143;
const LL inf=2147483647;
const double pi=atan(1.0)*4.0;
const LL llf=9223372036854775807;
const LL mod=998244353;
const LL N=1e6+7;
const LL M=5007;
LL n,m,a[N],b[N],p[N],bz[M][M],flag,sum;
il LL read(){
	LL x(0),ff(1);char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
il void write(LL x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
il void fre(){
	freopen("c.in","r",stdin);
	freopen("c.out","w",stdout);
}
int main(){
//	fre();
	n=read(),m=read();
	for(rg int i=1;i<=m;++i)a[i]=read(),b[i]=read();
	for(rg int i=1;i<=n;++i){
		p[i]=1;bz[i][i]=1;
		for(rg int j=m;j>=1;--j){
			int x=a[j],y=b[j];
			if(!bz[i][x]&&!bz[i][y])continue;
			if(bz[i][x]&&bz[i][y]){p[i]=0;break;}
			bz[i][x]=bz[i][y]=1;
		}
	}
	for(rg int i=1;i<n;++i){
		for(rg int j=i+1;j<=n;++j){
			if(p[i]&&p[j]){
				flag=0;
				for(rg int k=1;k<=n;++k){
					if(bz[i][k]&&bz[j][k]){flag=1;break;}
				}
				if(!flag)++sum;
			}
		}
	}
	printf("%lld\n",sum);
	return 0;
}
/*
4 3
1 2
3 4
2 3

*/

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

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

int main(){
  int n;
  ll X;
  cin >> n >> X;
  vector<ll> x(n);
  REP(i,n){
    cin >> x[i];
  }
  if(n==1){
    cout << abs(X-x[0]) << endl;
  }else{
    ll tmp = gcd(abs(X-x[0]), abs(X-x[1]));
    FOR(i,2,n){
      tmp = gcd(tmp, abs(X-x[i]));
    }
    cout << tmp << endl;
  }

}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		double r1, r2;
		double x1, x2, y1, y2;
		double length;

		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			x1 = sc.nextDouble();
			y1 = sc.nextDouble();
			r1 = sc.nextDouble();
			x2 = sc.nextDouble();
			y2 = sc.nextDouble();
			r2 = sc.nextDouble();
			length = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
			if (length < Math.abs(r2 - r1)) {
				if (r2 < r1) {
					System.out.println("2");
				} else {
					System.out.println("-2");
				}
			} else if (length <= r1 + r2) {
				System.out.println("1");
			} else {
				System.out.println("0");
			}
		}
	}
}

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

int main() {
  int64_t N,D;
  cin>>N>>D;
  int64_t kai=0;
  for(int i=0;i<N;i++){
    int64_t X,Y;
    cin>>X>>Y;
    if(X*X+Y*Y<=D*D) kai++;
  }
  cout<<kai<<endl;
  

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define ggr getchar();getchar();return 0
using namespace std;
signed main(){
	string s;
	cin>>s;
	string t;
	rep(i,s.size()){
		if(i%2)t+='0';
		else t+='1';
	}
	int cnt=0;
	rep(i,s.size()){
		if(s[i]!=t[i])cnt++;
	}
	rep(i,s.size()){
		if(t[i]=='0')t[i]='1';
		else t[i]='0';
	}
	int ans=0;
	rep(i,s.size()){
		if(s[i]!=t[i])ans++;
	}
	cout<<min(cnt,ans)<<endl;
	ggr;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int mcxi_int(const char mcxi[])
{
  int i,sum=0,p=1;

  for(i=0;mcxi[i];i++){
    if(mcxi[i]=='m'){
      sum+=p*1000; p=1;
    } else if(mcxi[i]=='c'){
      sum+=p*100; p=1;
    } else if(mcxi[i]=='x'){
      sum+=p*10; p=1;
    } else if(mcxi[i]=='i'){
      sum+=p; p=1;
    } else {
      p=mcxi[i]-'0';
    }
  }
  
  return sum;
}

int main(void)
{
  int n,i,j,num;
  char mcxi[]="mcxi";

  scanf("%d", &n);
  for(i=0;i<n;i++){
    char mcxi1[9],mcxi2[9];
    scanf("%s %s", mcxi1, mcxi2);
    num=mcxi_int(mcxi1)+mcxi_int(mcxi2);
    for(j=num;;){
      if(j/1000>1) printf("%d", j/1000);
      if(j/1000) printf("m");
      j%=1000;
      if(j/100>1) printf("%d", j/100);
      if(j/100) printf("c");
      j%=100;
      if(j/10>1) printf("%d", j/10);
      if(j/10) printf("x");
      j%=10;
      if(j>1) printf("%d", j);
      if(j) printf("i");
      break;
    }
    printf("\n");
  }

  return 0;
}


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

tmp = 0
for i in range(N):
    a1 = A[i]
    for j in range(N):
        a2 = A[j]
        if tmp < abs(a1 - a2):
            tmp = abs(a1 - a2)

print(tmp)


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

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

  int sum = 0;
  int minv = INT_MAX;
  for (int i = 1; i < n; ++i) {
    sum = 0;
    sum += i % 10 + (n - i) % 10;
    sum += i / 10 % 10 + (n - i) / 10 % 10;
    sum += i / 100 % 10 + (n - i) / 100 % 10;
    sum += i / 1000 % 10 + (n - i) / 1000 % 10;
    sum += i / 10000 % 10 + (n - i) / 10000 % 10;
    if (i == 0)
      minv = sum;
    else
      minv = min(minv, sum);
  }

  cout << minv << endl;
}

Measured memory_bytes: 256
o,f=998244353,[1]
for i in range(1,2500100):f.append(f[-1]*i%o)
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
n,m=map(int,input().split())
w,u=3*m,n-1
a=c(w+u,u)-n*c(n+m-2,u)
if u>m:
 for i in range(m+1,min(w,n)+1):
  if w-i+1&1:a-=c(n,i)*c((w-i)//2+u,u) 
print(a%o)

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

int main() {
    int N; cin >> N;
    int L[2 * N];
    for (int i = 0; i < 2 * N; i++) cin >> L[i];
    sort(L, L + 2 * N);
    int ans = 0;
    for (int i = 0; i < 2 * N; i+=2) {
        ans += L[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N, K, C = map(int, input().split())
    S = input()
    L, R = [-C], [N + C]
    i, k = 0, 0
    while i < N and k < K:
        if S[i] == 'o':
            L.append(i)
            k += 1
            i += C
        i += 1
    L.append(N)
    i, k = N - 1, 0
    while 0 <= i and k < K:
        if S[i] == 'o':
            R.append(i)
            k += 1
            i -= C
        i -= 1
    R.append(N)

    l = 0
    for i, s in enumerate(S):
        if s == 'x':
            continue
        r = K - l
        if R[r] <= i or R[r] - L[l] < C:
            print(i + 1)
        if L[l + 1] == i:
            l += 1


main()


Measured memory_bytes: 20540
using System;

class AOJ
{
	public static void Main()
	{
		var input = Console.ReadLine().Trim().Split(' ');
		int[] list = new int[3]{int.Parse(input[0]), int.Parse(input[1]), int.Parse(input[2])};

		while(true)
		{
			bool end = true;
			for(int i = 0; i <= 1; i++)
			{
				if(list[i] > list[i + 1])
				{
					int tmp = list[i];
					list[i] = list[i + 1];
					list[i + 1] = tmp;
					end = false;
				}
			}
			if(end){ break; }
		}
		Console.WriteLine(string.Format("{0} {1} {2}", list[0], list[1], list[2]));
	}
}

Measured memory_bytes: 5624
n = int(input())

for four_multiplier in range(0, n // 4 + 1):
    for seven_multiplier in range(0, n // 7 + 1):
        num = 0
        if four_multiplier == 0:
            num = 7 * seven_multiplier
        elif seven_multiplier == 0:
            num = 4 * four_multiplier
        else:
            num = 4 * four_multiplier + 7 * seven_multiplier
        if num == n:
            print("Yes")
            exit(0)
print("No")


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

#define INF 1000000000

vector<int> dp;

int solve(int a[], int b[], int H, int N){
    if(H<=0)
        return 0;
    
    int m = INF;
    if(dp[H]!=-1)
        return dp[H];
    
    for(int i=0; i<N; ++i){
        m = min(m, solve(a, b, H-a[i], N) + b[i]);
    }

    return dp[H] = m;
}

int main(){
    int H, N;
    cin >> H >> N;

    dp.assign(H+5, -1);
    int a[N], b[N], aI, bI;
    for(int i=0;i<N;++i){
        cin >> aI >> bI;
        a[i] = aI; b[i] = bI;
    }

    cout << solve(a, b, H, N) << endl;
    return 0;
}

Measured memory_bytes: 1024
def prime_factor(n):
    p = {}
    for i in range(2,n):
        if n % i == 0:
            p[i] = 0
        while n % i == 0:
            n //= i
            p[i] += 1
        if i * i > n: break
    if n != 1:
        p[n] = 1
    return p

N = int(input())
if N == 1:
    print(0)
else:
    
    pN = {}
    for i in range(2,N+1):
        p = prime_factor(i)
        for x in p:
            if x not in pN:
                pN[x] = p[x]
            else:
                pN[x] += p[x]
    
    # 75 = 3 * 5 * 5
    res = 0
    for x in pN:
        for y in pN:
            for z in pN:
                if (x < y and y < z):
                    if(pN[x]>=2 and pN[y]>=4 and pN[z]>=4):
                        res+=1
                    if(pN[x]>=4 and pN[y]>=2 and pN[z]>=4):
                        res+=1
                    if(pN[x]>=4 and pN[y]>=4 and pN[z]>=2):
                        res+=1
    
    # 75 = 3 * 25
    for x in pN:
        for y in pN:
            if x < y:
                if(pN[x]>=24 and pN[y]>= 2):
                    res+=1
                if(pN[x]>= 2 and pN[y]>=24):
                    res+=1
    
    # 75 = 15 * 5
    for x in pN:
        for y in pN:
            if x < y:
                if(pN[x]>=14 and pN[y]>= 4):
                    res+=1
                if(pN[x]>= 4 and pN[y]>=14):
                    res+=1
    
    if pN[2] >= 74:
        res += 1
        
    print(res)   

Measured memory_bytes: 3188
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

# import numpy as np
# import scipy as scp

# 入力の受け取り
n,k = map(int,input().split())

ans = k * (k-1)**(n-1)
print(ans)
# print("{:.10f}".format(ans))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A;
  cin >> A;
  vector<pair<pair<string,int>,int>>P(A);
  for(int i=0;i<A;i++){
    cin >> P[i].first.first >> P[i].first.second;
    P[i].second=i+1;
    P[i].first.second*=-1;
  }
  sort(P.begin(),P.end());
  for(int i=0;i<A;i++)cout << P[i].second << endl;
}
  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    char c1[n/2];
    char c2[n/2];
    int x=0;
    string no;
    if(n%2==0)
    {
        for(int i=0;i<n/2;i++)
        {
            cin>>c1[i];
        }
        for(int i2=0;i2<n/2;i2++)
        {
            cin>>c2[i2];
        }
        for(int i3=0;i3<n/2;i3++)
        {
            if(c1[i3]==c2[i3])
            {
                x++;
            }
            else
            {
                x=x;
            }
        }
        if(x==n/2)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    else
    {
        cin>>no;
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

using LONG = long long;
using LVEC = vector<long long>;

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


pair<long long, long long> integer_coeff(long long min_v, long long max_v, long long A, long long B){
    bool swaped = false;
    if(B < A){
        swap(A, B);
        swaped = true;
    }

    pair<long long, long long> ret = {-1, -1};
    pair<long long, long long> sub;

    sub.first = ceil((double)min_v/ A);
    sub.second = 0;

    long long res = min_v;

    do{
        long long sub_res = A * sub.first + B *sub.second - min_v;

        if(sub_res < res && min_v + sub_res <= max_v){
            ret = sub;
            res = sub_res;
        }

        --sub.first;
        sub.second = ceil((double)(min_v - A * sub.first) / B);

    }while(sub.first >= 0 && res != 0);

    if(swaped){
        swap(ret.first, ret.second);
    }

    return ret;
}


//int main(){
//    LONG A, B, C, D, E, F;
//    cin >> A >> B >> C >> D >> E >> F;

//    LONG max_s = (F * E) / (100 + E);
//    double max_dens = 0;

//    LONG water = A;
//    LONG sugar = 0;

//    pair<LONG, LONG> coeffs;

//    for(int s = 1; s <= max_s; ++s){
//        if(s == 934){
//            int a = 0;
//        }

//        coeffs = integer_coeff(s, s, C, D);
//        if(coeffs.second == -1){
//            continue;
//        }

//        LONG min_w = ceil(s / (double)E);
//        LONG max_w = (F - s) / 100;

//        coeffs = integer_coeff(min_w, max_w, A, B);

//        if(coeffs.second == -1){
//            continue;
//        }

//        LONG temp_water = 100 * (coeffs.first * A + coeffs.second * B);
//        double temp_dens = (double)s / (temp_water + s);

//        if(temp_dens > max_dens){
//            water = temp_water;
//            sugar = s;
//            max_dens = temp_dens;
//        }
//    }

//    cout << water + sugar << " " << sugar;

//}


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

    cout << N * N - A;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  double W, H, x, y;

  std::cin >> W >> H >> x >> y;

  double ans = W * H / 2;

  std::cout << ans << ' '
            << (x == W/2 && y == H/2 ? 1 : 0) << std::endl;

  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
ans = (ty - sy) * 'U' + (tx - sx) * 'R'
ans += (ty - sy) * 'D' + (tx - sx) * 'L'
ans += 'L' + (ty - sy + 1) * 'U' + (tx - sx + 1) * 'R' + 'D'
ans += 'R' + (ty - sy + 1) * 'D' + (tx - sx + 1) * 'L' + 'U'
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n == 3){
        cout << "2\n";
        cout << "1 3\n";
        cout << "2 3\n";
        return 0;
    }
    if(n % 2){
        cout << (n-2)*n/2 + 1 << "\n";
        srep(i,1,n+1){
            srep(j,i+1,n+1){
                if(j == n-i) continue;
                cout << i << " " << j << "\n";
            }
        }
    }else{
        cout << (n-2)*n/2 << "\n";
        srep(i,1,n+1){
            srep(j,i+1,n+1){
                if(j == n+1-i) continue;
                cout << i << " " << j << "\n";
            }
        }
    }
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  int a;
  int four=0,two=0;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a%4==0) four++;
    else if(a%2==0) two++;
  }
  if(four*2+max(two-1,0)>=n-1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  int i = 0;
  char S[60];
  int sum_ABC = 0;
  cin >> N;
  while(i < N) cin >> S[i++];
  for(i = 0; i< N-2;i++){
    if(S[i] != 'A') continue;
    if(S[i + 1] != 'B') continue;
    if(S[i + 2] != 'C'){i ++; continue;}
    i += 2;
    sum_ABC++;
  }
  cout << sum_ABC << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int sum = r * 100 + g * 10 + b;
  if (sum % 4 == 0) YES;
  else NO;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
      while(a[i]%2==0){
        a[i]/=2;
        sum++;
      }
  }
  cout << sum << endl;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define fore(i, x) for (auto &i : n)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

char field[2001][2001];
int left_cnt[2001][2001], right_cnt[2001][2001], up_cnt[2001][2001], down_cnt[2001][2001];

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

    string s;
    cin >> s;
    const llong n = s.size();
    map<char, llong> m;
    rep(i, n) {
        ++m[s[i]];
    }

    llong ans = n * (n - 1) / 2 + 1;
    stl_rep(itr, m) {
        ans -= itr->second * (itr->second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main()
{
    int M;cin >> M;
    ll sumd=0,sumc=0;
    ll c,d;
    for (int i=0;i<M;i++)
    {
        cin >> d >> c;
        sumd+=d*c;
        sumc+=c;
    }
    if (sumd%9==0) cout << sumc-1+sumd/9-1 << endl;
    else cout << sumc-1+sumd/9 << endl;
    return 0;
}

Measured memory_bytes: 3600
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n = int(input())
    if n % 2 == 0 or n % 5 == 0:
        print('-1')
        return 0
    #mod表を作る
    time = 0
    mod_n = [7 % n]
    while(time < n + 5):
        next_mod_n = mod_n[time] * 10 % n
        if next_mod_n == mod_n[0]:
            break
        mod_n.append(next_mod_n)
        time += 1
    #print(mod_n)
    
    ans = 1
    time = 0
    x = mod_n[time]
    while(x % n != 0):
        time += 1
        if time == len(mod_n):
            time = 0
        ans += 1
        x += mod_n[time]
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 66576
import java.util.Scanner;

public class Main {
	static int n;
	static int[] a = new int[50];
	static int[] b = new int[50];

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		n = sc.nextInt();

		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		for (int i = 0; i < n; i++)
			b[i] = sc.nextInt();

		long ans = (1L << 51) - 1;

		if (!DrawEdge(ans)) {
			System.out.println(-1);
			return;
		}

		for (int i = 51; i >= 0; i--) {
			Long tmp = ans & ~(1L << i);
			if (DrawEdge(tmp)) {
				ans = tmp;
			}
		}

		System.out.println(ans);
	}

	static boolean DrawEdge(long bit) {
		boolean[][] arr = new boolean[51][51];

		for (int i = 0; i <= 50; i++) {
			arr[i][i] = true;
		}

		for (int k = 1; k <= 50; k++) {
			if ((bit & (1L << k)) != 0) {
				for (int v1 = 0; v1 <= 50; v1++) {
					arr[v1][v1 % k] = true;
				}
			}
		}

		for (int k = 0; k <= 50; k++) {
			for (int i = 0; i <= 50; i++) {
				for (int j = 0; j <= 50; j++) {
					arr[i][j] |= arr[i][k] & arr[k][j];
				}
			}
		}

		for (int i = 0; i < n; i++) {
			if (!arr[a[i]][b[i]]) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 22808
#include<iostream>
using namespace std;
int main()
{
  int n;
  int t[100001];
  int x[100001];
  int y[100001];

  t[0] = 0;
  x[0] = 0;
  y[0] = 0;

  scanf("%d", &n);
  for(int i=1; i<=n; ++i){
    scanf("%d %d %d", &t[i], &x[i], &y[i]);
  }
  
  for(int i=1; i<=n; ++i){
    int dt, dx, dy;
    dt = t[i] - t[i-1];
    dx = abs(x[i] - x[i-1]);
    dy = abs(y[i] - y[i-1]);
    
    if( dx + dy > dt ){
      printf("No");
      return 0;
    }
    
    if( (dx + dy)%2 != dt%2 ){
      printf("No");
      return 0;
    }
  }
  
  printf("Yes");
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for(int i = 0; i < n; i++)
#define DUMP(range) do{for(auto& x:range){cout<<x<<' ';}cout<<endl;}while(0)
int N = 0;
int cnt = 0;
void recur(int n, Int k, int a, int b, int c)
{
    if (n == 0) {
        if (k <= N && a && b && c) {
            cnt++;
        }
    } else {
        recur(n-1, 10*k+7, 1, b, c);
        recur(n-1, 10*k+5, a, 1, c);
        recur(n-1, 10*k+3, a, b, 1);
        if (k <= N && a && b && c) cnt++;
    }
}
int main()
{
    cin >> N;
    recur(9, 0, 0, 0, 0);
    cout << cnt << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#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, m, n) for (int i = m; i < n; i++)


int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[2]-a[0] << endl;
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	sort(ALL(S));
	T=S;
	S.erase(unique(ALL(S)),S.end());
	if(S==T) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool ok(string s)
{
    static bool vis[11];
    memset(vis,0,sizeof vis);
    int num = 0;
    char big = 'a';
    char small = 'z';
    for(char c:s)
    {
        if(!vis[c-'a'])
        {
            vis[c-'a'] = 1;
            num++;
        }
        big = max(big,c);
        small = min(small,c);
    }
    return small == 'a' && big - 'a' + 1 == num;
}
bool next(string& s)
{
    for(int i=s.size()-1;i>=0;--i)
    {
        string tmp = s;
        tmp[i]++;
        for(int j=i+1;j<s.size();++j)tmp[j]='a';
        if(ok(tmp)) {
            s = tmp;
            return true;
        }
    }
    return false;
}
void solve(ll N)
{
    string s;
    for(int i=0;i<N;++i)s+='a';
    string t;
    for(int i=0;i<N;++i)t+='a'+i;
    cout<<s<<" ";
    while(s!=t){
        next(s);
        cout<<s<<" ";
    }
}


int main()
{
    ll N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()
n = int(input())
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

mod = 10**9+7

def dfs(i=0, r=-1):
    b = w = 1
    for j in e[i]:
        if j == r:
            continue
        bb, ww = dfs(j, i)
        b = b * ww % mod
        w = w * (bb + ww) % mod
    return b, w

print(sum(dfs())%mod)


Measured memory_bytes: 116528
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, c; cin >> n >> k >> c;
    string s; cin >> s;
    V<int> oidx;
    for (int i = 0; i < n; i++) if (s[i] == 'o') oidx.emplace_back(i);

    V<int> edges(n, -1);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'o') {
            auto it = upper_bound(ALL(oidx), i + c);
            if (it == oidx.end()) continue;
            else {
                int idx = *it;
                edges[i] = idx;
            }
        }
    }

    V<int> dist(n, 0); dist[0] = 1;
    for (int i = 0; i < n; i++) {
        if (i > 0) chmax(dist[i], dist[i - 1]);
        if (s[i] == 'o') {
            if (edges[i] == -1) {
                continue;
            } else dist[edges[i]] = dist[i] + 1;
        }
    }

    reverse(ALL(s));
    V<int> oidx2;
    for (int i = 0; i < n; i++) if (s[i] == 'o') oidx2.emplace_back(i);

    V<int> edges2(n, -1);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'o') {
            auto it = upper_bound(ALL(oidx2), i + c);
            if (it == oidx2.end()) continue;
            else {
                int idx = *it;
                edges2[i] = idx;
            }
        }
    }

    V<int> dist2(n, 0); dist2[0] = 1;
    for (int i = 0; i < n; i++) {
        if (i > 0) chmax(dist2[i], dist2[i - 1]);
        if (s[i] == 'o') {
            if (edges2[i] == -1) {
                continue;
            } else dist2[edges2[i]] = dist2[i] + 1;
        }
    }

    // DEBUG_VLL(dist)
    reverse(ALL(dist2));
    reverse(ALL(s));
    // DEBUG_VLL(dist2)

    if (dist.back() == k) {
        V< V<int> > distidx(k + 1);
        for (int i = 0; i < n; i++) {
            if (s[i] == 'o' && dist[i] + dist2[i] == k + 1) {
                distidx[dist[i]].emplace_back(i);
            }
        }

        for (int i = 1; i <= k; i++) if (distidx[i].size() == 1) cout << distidx[i][0] + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 17420
<?php
fscanf(STDIN, '%s', $weather);
switch ($weather) {
    case 'Sunny':
        echo "Cloudy\n";
        break;
    
    case 'Cloudy':
        echo "Rainy\n";
        break;

    case 'Rainy':
        echo "Sunny\n";
        break;

    default:
        break;
}

Measured memory_bytes: 4604