akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll func(vector<vector<ll>>&arr, ll n){
    vector<vector<ll>>dp(n, vector<ll>(3, 0));
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    for(ll i = 1 ; i < n ; i++){
        for(ll j = 0 ; j < 3 ; j++){
            dp[i][j] = arr[i][j] + max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
        }
    }
    return max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

int main(){
    ll n;
    cin>>n;
    vector<vector<ll>>arr(n, vector<ll>(3, 0));
    for(ll i =0; i < n; i++){
        for(ll j = 0 ; j < 3 ; j++){
            cin>>arr[i][j];
        }
    }
    cout<<func(arr, n);
}

Measured memory_bytes: 11136
n, a, b, c, d = map(int, input().split())
l = list(input())
ans = ''

if (a > b and c > d) or (a < b and c < d):
  rock = 0
  for i in range(a-1, c):
    if l[i] == '#':
      rock += 1
      if rock == 2:
        ans = 'No'
        break
    else:
      rock = 0
  rock = 0
  for i in range(b-1, d):
    if l[i] == '#':
      rock += 1
      if rock == 2:
        ans = 'No'
        break
    else:
      rock = 0
  if ans == '':
    ans = 'Yes'
else:
  rock = 0
  for i in range(a-1, c):
    if l[i] == '#':
      rock += 1
      if rock == 2:
        ans = 'No'
        break
    else:
      rock = 0
  rock = 0
  for i in range(b-1, d):
    if l[i] == '#':
      rock += 1
      if rock == 2:
        ans = 'No'
        break
    else:
      rock = 0
  blank = 0
  for i in range(max(a, b)-2, min(c, d)+1):
    if l[i] == '.':
      blank += 1
      if blank == 3:
        ans = 'Yes'
        break
    else:
      blank = 0    
  if ans == '':
    ans = 'No'

print(ans)

Measured memory_bytes: 4924
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, k;
  ll r, s, p;
  string t;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;

  vector<char> record(n);
  ll ans = 0;

  rep(i, k) {
    for(int j = i; j < n; j += k) {
      if (t[j] == 'r') {
        if (j -k >= 0) {
          if(record[j-k] == t[j]) {
            record[j] = 'z';
            continue;
          }
        }
        ans += p;
        record[j] = 'r';
      }
      if (t[j] == 's') {
        if (j - k >= 0) {
          if(record[j-k] == t[j]) {
            record[j] = 'z';
            continue;
          }
        }
        ans += r;
        record[j] = 's';
      }
      if (t[j] == 'p') {
        if (j - k >= 0) {
          if(record[j-k] == t[j]) {
            record[j] = 'z';
            continue;
          }
        }
        ans += s;
        record[j] = 'p';
      }
      // cout << i << " " << j << " " << ans << endl;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
N=int(input())
H=list(map(int,input().split()))

dp=[[0,0] for i in range(N)]
for i in range(1,N):
  if H[i]<=H[i-1]:
    dp[i][1]=dp[i-1][1]+1
    dp[i][0]=max(dp[i-1][0],dp[i][1])
  else:
    dp[i][1]=0
    dp[i][0]=dp[i-1][0]

print(max([i[0] for i in dp]))

Measured memory_bytes: 21600
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    n <- getInt
    putStrLn $ solve n

solve n | length [() | a <- [1..9], b <- [1..9], a*b == n] == 0 = "No"
        | otherwise = "Yes"

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

int dp[(1<<10)+10][1010];

void solve(){
  dp[0][0] = 1;
  for(int i = 0 ; i < (1<<10) ; i++){
    int m = __builtin_popcount(i) + 1;
    for(int j = 0 ; j <= 500 ; j++){
      if(dp[i][j] == 0) continue;
      for(int k = 0 ; k < 10 ; k++){
	if((i >> k) & 1) continue;
	int nex = (i | (1<<k));
	int nexv = j + k * m;
	dp[nex][nexv] += dp[i][j];
      }
    }
  }
}

bool isValid(int n, int s){
  return (0 <= n && n <= 10) && (0 <= s && s <= 1000);
}

int main(){
  solve();
  int n, s;
  while(cin >> n >> s){
    if(!isValid(n, s)){
      cout << 0 << endl;
      continue;
    }
    
    int ans = 0;
    for(int i = 0 ; i < (1<<10) ; i++){
      int m = __builtin_popcount(i);
      if(n == m) ans += dp[i][s];
    }
    cout << ans << endl;
  }  
  return 0;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int d[101][200001];
int main() {
    int N, W;
    cin >> N >> W;
    int w[N], v[N];
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    int l = 100001;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < l; j++) {
            d[i][j] = INT32_MAX;
        }
    }
    d[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < l; j++) {
            if (d[i][j] == INT32_MAX) continue;
            d[i + 1][j] = min(d[i + 1][j], d[i][j]);
            if (d[i][j] + w[i] > W) continue;
            d[i + 1][j + v[i]] = min(d[i + 1][j + v[i]], d[i][j] + w[i]);
        }
    }
    int ans = 0;
    for (int i = 0; i < l; i++) {
        if (d[N][i] <= W) {
            ans = i;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 77696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		if(N % 2 == 0) {
			System.out.println(0.5000000000);
		}else if(N == 1) {
			System.out.println(1.0000000000);
		}else {
			int s = (N / 2) + 1;
			double ans =(double) s / N;
			 System.out.println(String.format("%.10f", ans));
		}
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

bool comp(P p1, P p2){
    return p1.second < p2.second;
}

int main(){

    int n, m; cin >> n >> m;

    P dislike[m];
    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;

        dislike[i] = {a, b};
    }

    sort(dislike, dislike+m, comp);

    // rep(i, m){
    //     cout << dislike[i].first << " " << dislike[i].second << endl;
    // }

    int cut = -1;
    int ans = 0;

    rep(i, m){
        int a = dislike[i].first;
        int b = dislike[i].second;

        if(a <= cut){
            continue;
        }

        cut = b-1;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;
const int N=2e5+5;


int main(){
    int N; cin >> N;
    vi arr(N);
    for(auto &x: arr) cin >> x;
    int cur=1;
    for(int i=0; i<N; i++){
        if(arr[i] == cur){
            cur++;
        }
    }
    cur--;
    int res= cur == 0 ? -1:N-cur;
    cout << res << endl;
    return 0;
}

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

int land[50][50], flag[50][50];
int w, h;
int xroot[] = {0,0,1,1,1,-1,-1,-1};
int yroot[] = {1,-1,0,-1,1,0,1,-1};
int cnt = 1;


void dfs(int x, int y){


  if(land[y][x] != 1) return;
  land[y][x] = cnt;

  for(int i = 0; i < 8; i++){
    int nx = x + xroot[i], ny = y + yroot[i];
    if(ny >= h || nx >= w || ny < 0 || nx < 0) continue;
    // cout << nx << " " << ny << endl;
    dfs(nx,ny);
  }
}

int main(){

  while(cin >> w >> h && (w || h)){
    cnt = 1;
    memset(flag,0,sizeof(flag));

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){ 
	cin >> land[i][j];
      }
    }



    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){ 
	if(land[i][j] == 1){
	  cnt++;
	  dfs(j,i);
	}
      }
    }
    cout << cnt - 1 << endl;

  }



  return 0;
}

Measured memory_bytes: 1256
#include <iostream>
using namespace std;
int main(){
  int i;
  char str[5];
  cin >> str;
  for(i=0;i<4;i++){
    if(str[i]==str[i+1]){i=-1;break;}
  }
  if(i>0)cout << "Good" << endl;
  else cout << "Bad" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<iostream>
#include<stdlib.h>
using namespace std;
typedef long long ll;

int main() {
	ll N, K, num = 0, count = 0,part=0;
	cin >> N >> K;
	ll a;
	for (ll i = 0;i < N;i++) {
		cin >> a;
		if (a == 1) {
			num = i + 1;
			if (num > (ll)N / 2)num = N - num + 1;
			break;
		}
	}
	if (N == K) {
		cout << 1 << endl;
		return 0;
	}
	part = N - 1;
	while (true) {
		if (part <= 0)break;
		count++;
		part = part - (K - 1);
	}
	cout << count << endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	int cs=pow(10,9)+7;
	long long sum=1;
	int i=1;
	while(n--){
		sum*=i;
		sum%=cs;
		i++;
	}
	cout<<sum%cs;
	return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int k; cin >> k;
    string s; cin >> s;
    if (s.size() <= k) cout << s;
    else {
        string z = s.substr(0,k);
        cout << z + "..." << endl;
    } 
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) v.begin(), v.end()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

class DGatheringChildren {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string S;
	    in>>S;
	    int N = S.size();
	    vector<int> l, r, ans(N);
	    REP(i, N){
	        if(S[i]=='L') l.pb(i);
	        else r.pb(i);
	    }
	    REP(i, N){
	        //DUMP(S[0])
	        if(S[i]=='R'){
	            auto itr = lower_bound(ALL(l), i);
	            int dist = *itr - i;
	            if(dist%2) ans[*itr-1]++;
	            else ans[*itr]++;
	        } else {
	            auto itr = lower_bound(ALL(r), i);
	            itr--;
	            int dist = i - *itr;
	            if(dist%2) ans[*itr+1]++;
	            else ans[*itr]++;
	        }
	    }
	    for(auto u : ans) out<<u<<' ';
	    out<<endl;
	}
};


int main() {
	DGatheringChildren solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1532
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>

typedef long long ll;
const ll INF = 1e18;

int main(int argc, char* argv[])
{
  ll N;
  ll x = 111;

  ll ans = 999;
  std::cin >> N;
  for (int i = N; i <= 999; i++) {
    if (i % x == 0) {
      ans = i;
      break;
    }
  }

  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> a(3 * N);
	for (auto &x : a) cin >> x;
	sort(a.begin(), a.end());

	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += a[3 * N - 2 - 2 * i];
	}

	cout << ans << endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	rep(i, N) cin >> d.at(i);

	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += d.at(i) * d.at(j);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	ll r;
	cin>>r;
	cout<<(double)2*3.14159265358*r<<"\n";
	return 0;
}

Measured memory_bytes: 3800
n=int(input())
c=0
d=[list(map(int,input().split())) for _ in range(n)]
for i in reversed(range(n)):
  a=d[i][0]
  b=d[i][1]
  if (a+c)%b!=0:
    c+=b-(a+c)%b
print(c)

Measured memory_bytes: 27408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    string s;
    cin >> s;
    ll z = 0;
    ll o = 0;

    rep(i, s.size()) {
        if(s.at(i) == '0')
            z++;
        else if(s.at(i) == '1')
            o++;
    }

    cout << z + o - (abs(z - o));
}


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

int main()
{
	string left = "qwertasdfgzxcvb";
	sort(left.begin(), left.end());

	string s;
	while (cin >> s) {
		if (s == "#")
			break;

		int ans = 0;
		bool l = false;
		if (binary_search(left.begin(), left.end(), s[0]))
			l = true;

		for (int i = 1; i < s.size(); ++i) {
			if (l) {
				if (!binary_search(left.begin(), left.end(), s[i])) {
					l = false;
					++ans;
				}
			} else {
				if (binary_search(left.begin(), left.end(), s[i])) {
					l = true;
					++ans;
				}
			}
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        var s1 = Console.ReadLine().Trim();
        var s2 = Console.ReadLine().Trim();
        var ans = goDP(s1, s2);
        Console.WriteLine(ans);
    }
    static int goDP(string s1, string s2)
    {
        var s1L = s1.Length;
        var s2L = s2.Length;
        var dp = new int[s2L + 1, s1L + 1];
        for (int i = 0; i < s2L + 1; i++) dp[i, 0] = i;
        for (int i = 0; i < s1L + 1; i++) dp[0, i] = i;
        for (int i = 1; i <= s2L; i++)
            for (int j = 1; j <= s1L; j++)
            {
                var c = s2[i - 1] == s1[j - 1] ? 0 : 1;
                dp[i, j] = Min(dp[i - 1, j - 1] + c, Min(dp[i, j - 1] + 1, dp[i - 1, j] + 1));
            }
        return dp[s2L, s1L];
    }
}



Measured memory_bytes: 19176
#include<bits/stdc++.h>
using namespace std;
const int N=1*1e5+10,Mod=1e9+7;
typedef long long ll;
#define pb push_back
int main()
{
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200) cout<<s<<endl;
  else cout<<"red\n";
  return 0;
}


Measured memory_bytes: 256
function Main(input){

  var N = input.split('\n')[0].split(' ')[0];
  var K = input.split('\n')[0].split(' ')[1];
  var Q = input.split('\n')[0].split(' ')[2];

  N = parseInt(N,10);
  K = parseInt(K,10);
  Q = parseInt(Q,10);

  var A = input.split('\n');
  A.shift();

  var C = [];
  for(i=0;i<Q;i++){
    A[i] = parseInt(A[i],10);
  }

  for(i=0;i<N;i++){
    C[i] = 0;
  }

  //

  for(i=0;i<Q;i++){
    C[A[i]-1] += 1; 
  }

  C = C.map((x)=>{
    var a;
    a = x - Q;
    a += K;
    return a;
  });

  var count = 0;
  for(i=0;i<N;i++){
    if(C[i]>0){
      C[i] = 'Yes';
    }else{
      C[i] = 'No';
    }
  }

  console.log(C.join('\n'));


}
  




Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32716
/// Coded by Dhiman Sarker Bappi (Dhimanda) - RMSTU

#include<bits/stdc++.h>
using namespace std;
#define    in_file     freopen("input.txt", "r", stdin)
#define    out_file    freopen("output.txt", "w", stdout)
#define    fast        ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define    F           first
#define    S           second
#define    pb          push_back
#define    popb        pop_back
#define    pf          push_front
#define    popf        pop_front
#define    lcm(a,b)    (a*b)/gcd(a,b)
#define    gcd(a,b)    __gcd(a,b)
#define    pi          2*acos(0)
#define    elif        else if
#define    ll          long long
#define    nl          '\n'
#define    endl        '\n'
#define    fori(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define    for0(i,n)   for(int (i)=0; (i) < (n); (i)++)
#define    sp          fixed << setprecision
#define    all(x)      x.begin(),x.end()

// ===================== DEBUG  ==========================

vector<string>vec_spltr(string s){s+=',';vector<string>res;while(!s.empty())
res.push_back(s.substr(0, s.find(','))),s=s.substr(s.find(',')+1);return res;}
void dbg_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,
__attribute__((unused))int LINE_NUM){cerr<<endl;}template<typename Head,typename... Tail>
void dbg_out ( vector <string> args, int idx, int LINE_NUM, Head H, Tail... T)
{if(idx>0)cerr<<", ";else cerr << "Line(" << LINE_NUM << ") ";stringstream ss;ss<<H;
cerr<<args[idx]<<" = "<<ss.str();dbg_out(args,idx+1,LINE_NUM, T...);}
#define debug(...) dbg_out(vec_spltr(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

// ===================== custom function ==========================
ll pow_mod(ll nn, ll pp, ll mm) { ll res = 1; while(pp > 0) { if(pp&1) res = (res * nn) % mm; pp = pp >> 1; nn = (nn * nn) % mm; } return res; }
void dhimanda();
// ===================== Main function ==========================
int main()
{
    //in_file;
    //out_file;
    int t=1;
    //cin >> t;
    fori(i,1,t){
        //printf("Case %d: ", i);
        dhimanda();
    }
    return 0;
}
void dhimanda(){
    char a;
    cin >> a;
    if(a>='a' and a<='z') cout << 'a' <<endl;
    else cout << 'A' <<endl;
}

// Contact : chessdhiman@gmail.com


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int X,k,t,f[200005],d[200005],e[200005],m,n; char S[200005];
long long ans;
vector <int> o[26];
int main(){
	scanf("%s",S+1); n=strlen(S+1);
	for (int i=1;i<=n;++i) o[S[i]-'a'].push_back(i);
	for (int i=0;i<26;++i){
		for (int j=0;j<o[i].size()>>1;++j) f[o[i][j]]=1;
		if (o[i].size()&1){
			if (X) {puts("-1"); return 0;}
			X=o[i][o[i].size()>>1];
		}
		o[i].clear();
	}
	for (int i=1;i<=n;++i) if (f[i]) d[++t]=S[i]-'a',ans+=i-t;
	if (X) for (int i=1;i<X;++i) if (!f[i]) ++ans;
	for (int i=n;i;--i) if (!f[i]&&i!=X) e[++k]=S[i]-'a';
	for (int i=t;i;--i) o[d[i]].push_back(i);
	for (int i=1;i<=t;++i){
		d[i]=o[e[i]][o[e[i]].size()-1];
		o[e[i]].pop_back();
	}
	memset(f,0,sizeof f);
	for (int i=t;i;--i){
		for (int j=d[i];j;j-=j&-j) ans+=f[j];
		for (int j=d[i];j<=t;j+=j&-j) ++f[j];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N;
  cin >> N;
  set<int> S;
  int a;
  rep(i,N){
    cin >> a;
    S.insert(a);
  }
  cout << S.size() << endl;
  
  
}

Measured memory_bytes: 256
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

l = []
for i in range(3):
  n,m = IL()
  l.append(n)
  l.append(m)

a = l.count(1)
b = l.count(2)
c = l.count(3)
d = l.count(4)

if a == 1 and b == 2 and c == 2 and d == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 21668
#include <stdio.h>

int main(){
	int a;
	int n[100];
	double rev[100];
  	double sum=0;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",&n[i]);
      	rev[i]=1.0/(double)n[i];
      	sum=sum+rev[i];
	}
	sum=1/sum;
  	printf("%f",sum);
	return 0;
}

Measured memory_bytes: 128
N=int(input())
A=[int(x) for x in input().split()]
Q=int(input())
M=[int(x) for x in input().split()]
flag=[0]*2000

for m in range(1<<N):
    n=0
    for i in range(N):
        if 1&(m>>i)==1:
            n+=A[i]
    flag[n]=1

for m in M:
    print('yes' if flag[m] else 'no')



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

using namespace std;

string s, t;
int lens, lent, maxn;

int main () {
	cin >> s >> t;
	lens = s.size ();
	lent = t.size ();
	for (int i = 0; i < lens - lent + 1; i ++ ) {
		int tot = 0, k = i;
		for (int j = 0; j < lent; j ++ ) {
			if (s[k] == t[j]) tot ++ ;
			k ++ ;
		}
		maxn = max (maxn, tot);
	}
	cout << lent - maxn << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}

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


int main() {
    ll n;
    cin >> n;
    ll b;
    map<ll,ll> a;
    rep(i,n){cin >> b;a[b]++;}
    ll ans = 0;
    if(n == 1){cout << 1 << endl;return 0;}
    rep(i,n-1){
        ans = max(ans,a[i-1]+a[i]+a[i+1]);
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 6528
#include<stdio.h>

int main()
{
    int i,j,n;
    double a;
    int count[7]={0};

    scanf("%d",&n);
    for(;n>0;n--){
        scanf("%lf",&a);
        if(a<165) count[1]++;
        else if(a>=185) count[6]++;
        else count[(int)(a-155)/5]++;
    }
    for(i=1;i<7;i++){
        printf("%d:",i);
        for(j=0;j<count[i];j++){
            printf("*");
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 644
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int target = n & 1 ? n : n + 1;
  vector<pair<int, int>> ans;
  for (int i = 1; i <= n; i++) {  
    for (int j = i + 1; j <= n; j++) {
      if (i + j == target) continue;
      ans.emplace_back(i, j);
    }
  }
  cout << (int) ans.size() << endl;
  for (int i = 0; i < (int) ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))

#include <unordered_map>
using namespace std;
int main()
{
    unordered_map<string, int> mp;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      string str;
      cin >> str;
      auto itr = mp.find(str);
      if( itr != mp.end() ) {
        itr->second++;
      } else {
        mp[str] = 1;
      }
    }
    cout << mp.size();
}


Measured memory_bytes: 17056
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,k=parseMap(split(readline()))
    println(ifelse(n-(k-1)>=k,"YES","NO"))
end
main()

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N, M; cin >> N >> M;
	if(N % 2 == 0) N--;
	int even = N/2, odd = N-even;
	if(even & 1) swap(even, odd);
	vector<pint> ans;
	int tmp = even;
	REP(i, tmp/2){
		ans.eb(i, i+even-1);
		even -= 2;
	}
	even = tmp;
	tmp = odd;
	RANGE(i, even, even+tmp/2){
		ans.eb(i, i+odd-1);
		odd -= 2;
	}
	REP(i, M){
		cout << ans[i].first+1 << ' ' << ans[i].second+1 << ln;
	}
}

Measured memory_bytes: 4288
S = list(input())
T = list(input())
S.sort()
T.sort(reverse=True)
A = "abcdefghijklmnopqrstuvwxyz"

for a, b in zip(S, T):
    if A.index(a) < A.index(b):
        print("Yes")
        exit()
    elif A.index(b) < A.index(a):
        print("No")
        exit() 

if len(S) <len(T):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

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

  int cnt = 0, now = 1;
  for (int i = 1; i <= n; i++) {
    cnt++;
    now = a[now];
    if (now == 2) {
      cout << cnt << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define looplt(i,x) for(i=0; i<x; ++i)
#define bsrch(v,x) binary_search(v.begin(), v.end(), x)
#define vecl vector <long long int>
#define pb(x) push_back(x)
const long long int MAX_INT =  10e+10;
typedef long long int ll;

void pvec(vector <ll> &inp)
{
    ll n;
    looplt(n, inp.size()) cout << inp[n] << " ";
    cout << endl;
}

void parr(ll inp[], ll size)
{
    ll n;
    looplt(n, size) cout << inp[n] << " ";
    cout << endl;

}

ll pw(ll a, ll b)
{
    if(b == 0)
        return (1);
    
    ll ans = 1;
    for(ll i=0; i<b; ++i) 
        ans *= a;

    return (ans);
}

bool arrsearch(ll arr[], ll size, ll val)
{
    for(ll i=0; i<size; ++i){
        if(arr[i] == val)
            return true;
    }
    return false;
}

int main()
{   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll t=1, i, k, inp, j, n, m;
    string s;
    //cin >> t;
    looplt(i, t){
        cin >> n;
        ll arr[n], ans=0;
        
        looplt(k, n){
            cin >> arr[k];
        }
        
        for(k=0; k<n-1; ++k){
            if(arr[k] > arr[k+1]){
                ans += arr[k] - arr[k+1];
                arr[k+1] += arr[k] - arr[k+1]; 
            }
        }

        cout << ans <<"\n";
    }
}   



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

int main(void)
{
    int n, r;

    while (scanf("%d %d", &n, &r), n){
        int card[64];
        int i;

        for (i = 0; i < n; i++){
            card[i] = n - i;
        }

        while (r-- > 0){
            int p, c;
            int tmp[64];

            scanf("%d %d", &p, &c);
            for (i = p - 1; i < p + c - 1; i++){
                tmp[i - p + 1] = card[i];
            }
            for (i = p + c - 2; i > c - 1; i--){
                card[i] = card[i - c];
            }
            for (i = 0; i < c; i++){
                card[i] = tmp[i];
            }
        }

        printf("%d\n", card[0]);
    }

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int c1,c2,c3;
  while(cin>>c1>>c2>>c3){
    int ans[11]={};
    ans[c1]=1;ans[c2]=1;ans[c3]=1;
    int I=c1+c2;
    int anscnt=0;
    for(int i=1;i<=10;i++){
      if(!ans[i]){
	if(I+i<=20){
	  anscnt++;
	  //cout<<"!"<<endl;
	}
      }
    }
    if(anscnt>=4)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3060
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    handle.read_line(&mut buf).unwrap();
    let info: Vec<isize> = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
    buf.clear();
    let n = info[0];
    let t = info[1];
    let mut exist_way = false;
    let mut min_c = 10000;
    for _ in 0..n {
        handle.read_line(&mut buf).unwrap();
        let way: Vec<isize> = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
        if (way[1] <= t) && (way[0] < min_c) {
            min_c = way[0];
            exist_way = true;
        }
        buf.clear();
    }
    if exist_way {
        println!("{}", min_c);
    } else {
        println!("TLE");
    }
}

Measured memory_bytes: 4352
#include<iostream>

using namespace std;

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

	if (R < 1200) {
		cout << "ABC" << endl;
	}
	else if (R >= 1200 && R < 2800) {
		cout << "ARC" << endl;
	}
	else cout << "AGC" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
bool kai(string s){
    string t = s;
    reverse(all(t));
    return s == t;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin >> h >> w;
    vector<string> grid(h+2);
    string s = "";
    rep(i,w+2) s += '.';
    grid[0] = grid[h+1] = s;
    rep(i,h){
        cin >> s;
        grid[i+1] = '.'+s+'.';
    }
    rep(i,1,h+1){
        rep(j,1,w+1){
            if (grid[i][j] == '#') continue;
            ll c = 0;
            rep(k,8){
                ll xn = i+nx[k];
                ll yn = j+ny[k];
                if (grid[xn][yn] == '#') c++;
            }
            grid[i][j] = c+'0';
        }
    }
    rep(i,1,h+1){
        PRINT(grid[i].substr(1,w));
    }
}


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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		int Max = 0, Min = 500;
		rep(i, n) {
			int a[5]; rep(j, 5)scanf("%d", &a[j]);
			int cnt = accumulate(a, a + 5, 0);
			Max = max(Max, cnt); Min = min(Min, cnt);
		}
		printf("%d %d\n", Max, Min);
	}
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9+7 ;


int pw(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n/2;
    }
    return result;
}


int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,k;
    cin >> n >> k;

    vector<ll> count(k+1,0);
    count[k] = 1;
    ll ans = k;
    for(ll i=k-1;i>=1;--i){
    	count[i] = pw(k/i,n);

    	for( ll j = i+i ; j<=k ;j+=i){
    		count[i] = count[i] + mod - count[j];
    		count[i]%=mod;
    	}

    	ans = (ans+(count[i]*i)%mod)%mod;

    }

    cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3976
n = int(input())
if n >= 400 and n <= 599:
  kyu = 8
elif n >= 600 and n <= 799:
  kyu = 7
elif n >= 800 and n <= 999:
  kyu = 6
elif n >= 1000 and n <= 1199:
  kyu = 5
elif n >= 1200 and n <= 1399:
  kyu = 4
elif n >= 1400 and n <= 1599:
  kyu = 3
elif n >= 1600 and n <= 1799:
  kyu = 2
elif n >= 1800 and n <= 1999:
  kyu = 1
print(kyu)

Measured memory_bytes: 9080
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

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

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

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

int main() {
  while (1) {
    string input = "";

    getline(cin, input);

    bool endflag = true;
    rep(i, input.size()) {
      if (input[i] != '.') endflag = false;
    }
    if (endflag) break;

    stack<char> st;
    bool flag1 = true, flag2 = true;
    bool c1 = true, c2 = true;
    rep(i, input.size()) {
      if (input[i] == '(') {
        st.push(input[i]);
        flag1 = false;
      }
      if (input[i] == ')') {
        if (st.empty())
          c1 = false;
        else {
          char tmp = st.top();
          st.pop();
          if (tmp == '(') {
            flag1 = true;
          } else
            c1 = false;
        }
      }

      if (input[i] == '[') {
        st.push(input[i]);
        flag2 = false;
      }
      if (input[i] == ']') {
        if (st.empty())
          c2 = false;
        else {
          char tmp = st.top();
          st.pop();
          if (tmp == '[')
            flag2 = true;
          else
            c2 = false;
        }
      }
    }

    if (flag1 && flag2 && c1 && c2 && st.empty())
      cout << "yes\n";
    else
      cout << "no\n";
  }

  return 0;
}


Measured memory_bytes: 3164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 課題1
{
    class Program
    {
        static void Main(string[] args)
        {
            //文字列を取得する
            string str = Console.ReadLine();

            //文字列を変換する
            int strLen = str.Length;

            //式を配列に格納する
            string[] strArray = new string[strLen];

            for (int i = 0; i < strLen; i++)
            {
                strArray[i] = str.Substring(i, 1);
            }

            int intSum = 0;

            for (int i = 0; i < strLen; i++)
            {
                if(strArray[i]=="-")
                {
                    intSum = intSum - 1;
                }
                else
                {
                    intSum = intSum + 1;
                }
            }

            Console.WriteLine(intSum);

        }


    }

    
}


Measured memory_bytes: 27416
#include <cmath>
#include <iostream>
#include <iomanip>

int main() {
    double r;
    std::cin >> r;

    std::cout << std::fixed << std::setprecision(20);
    std::cout << r * r * std::acos(-1) << " " << 2 * r * std::acos(-1) << std::endl;
}


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

using namespace std;

const int INF = 1 << 29;

int main()
{
  int N, D, P[50][50], V[50];
  int dp[50][50];
  int rev[50][50];

  cin >> N >> D;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < D; j++) {
      cin >> P[i][j];
    }
  }


  for(int i = 0; i < D; i++) {
    V[i] = INF;
    for(int j = 0; j < N; j++) V[i] = min(V[i], P[j][i]);
  }

  fill_n(*dp, 50 * 50, INF);
  for(int i = 0; i < N; i++) {
    if(V[D - 1] == P[i][D - 1]) {
      dp[D - 1][i] = 0;
      rev[D - 1][i] = -1;
    }
  }
  for(int i = D - 2; i >= 0; i--) {
    for(int j = 0; j < N; j++) {
      for(int k = 0; k < N; k++) {
        if(V[i] == P[k][i]) {
          if(dp[i][k] > dp[i + 1][j] + (j != k)) {
            dp[i][k] = dp[i + 1][j] + (j != k);
            rev[i][k] = j;
          }
        }
      }
    }
  }
  int p = min_element(dp[0], dp[1]) - dp[0];
  cout << accumulate(V, V + D, 0) << " " << dp[0][p] << endl;
  vector< int > vs;
  for(int i = 0; i < D; i++) {
    cout << p + 1 << endl;
    p = rev[i][p];
  }
}

Measured memory_bytes: 1192
import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	ArrayList<Double> list = new ArrayList<Double>();
      	list.add((double)(sc.nextInt()));
      	for(int i=1;i<n;i++){
        	double a = (double)(sc.nextInt());
          	for(int j=0;j<=list.size();j++){
              	if(list.size()==j){
                	list.add(a);
                  	break;
                }
            	if(a<list.get(j)){
                	list.add(j,a);
                  	break;
                }
            }
        }
      	while(list.size()!=1){
          double a = list.get(0);
          double b = list.get(1);
          list.remove(0);list.remove(0);
          list.add(0,(a+b)/2);
        }
      	System.out.println(list.get(0));
    }
}

Measured memory_bytes: 23892
#include <iostream>
using namespace std;
using ll = long long;

int main(){
    ll x;
    cin >> x;
    if(x % 11 > 6) cout << 2 * (x / 11) + 2 << endl;
    else if(x % 11 > 0) cout << 2 * (x / 11) + 1 << endl;
    else if(x % 11 == 0) cout << 2 * (x / 11) << endl;
    return 0;
}

Measured memory_bytes: 256
/* 
 * シカのAtCoDeerくんは二次元平面上で旅行をしようとしています。 AtCoDeerくんの旅行プランでは、時刻 0 に 点 (0,0) を出発し、 1 以上 N 以下の各 i に対し、時刻 ti に 点 (xi,yi) を訪れる予定です。
 * 
 * AtCoDeerくんが時刻 t に 点 (x,y) にいる時、 時刻 t+1 には 点 (x+1,y), (x−1,y), (x,y+1), (x,y−1) のうちいずれかに存在することができます。 その場にとどまることは出来ないことに注意してください。
 * AtCoDeerくんの旅行プランが実行可能かどうか判定してください。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            
            int t = 0;
            int ti = 0;
            int x = 0;
            int xi = 0;
            int y = 0;
            int yi = 0;
            // 連続する二点間の距離d
            int d = 0;
            
            // 各連続する二点間について考える
            for(int i=0; i<n; i++){
            	ti = Integer.parseInt(sc.next());
            	xi = Integer.parseInt(sc.next());
            	yi = Integer.parseInt(sc.next());
            	
            	d = (int)(Math.abs(xi-x) + Math.abs(yi-y));
            	
            	// dが時間より長い、またdと時間の差が奇数(ちょうど目的地に着けない)ならばNoを出力してreturn
            	if(ti-t < d || (d-ti+t)%2 != 0){
            		System.out.println("No");
                    sc.close();
                    return;
            	}
            	t = ti;
            	x = xi;
            	y = yi;
            }
            
            // どの二点間も旅行可能ならばYesを出力
            System.out.println("Yes");
            sc.close();
        }
    }
	

Measured memory_bytes: 61520
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int area;

		while (sc.hasNext()) {
			n = sc.nextInt();
			area = 1;
			for (int i = 0; i < n; i++) {
				area = area + i + 1;
			}
			System.out.println(area);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	char s_;
	cin >> s_;
	rep(i,0,3){
		char s;
		cin >> s;
		if (s_ == s){
			cout << "Bad" << endl;
			return 0;
		}
		s_ = s;
	}
	cout << "Good\n";
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

int main(){
	int n;
	int arr[100010]={};
	for(int i=0; i<100001; i++) arr[i]=0;
	cin>> n;
	for(int i=0; i<n; i++){
		int x;
		cin>> x;
		arr[x]++;
		if(x>0) arr[x-1]++;
		arr[x+1]++;
	}
	int mm=0;
	for(int i=0; i<100001; i++){
		mm=max(mm, arr[i]);
	}
	cout<<mm;
}

Measured memory_bytes: 640
from sys import stdin
input = stdin.readline

board = [list(map(int, input().split())) for _ in range(3)]

n = int(input())
for _ in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if board[i][j] == num:
                board[i][j] = True
                break

# check bingo
bingo_count = 0
for i in range(3):
    if board[i][0] == board[i][1] == board[i][2] == True:
        bingo_count += 1
    elif board[0][i] == board[1][i] == board[2][i] == True:
        bingo_count += 1

if board[0][0] == board[1][1] == board[2][2] == True:
    bingo_count += 1
if board[0][2] == board[1][1] == board[2][0] == True:
    bingo_count += 1

print('Yes' if bingo_count else 'No')


Measured memory_bytes: 3064
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int A, B, AB;
	cin >> A >> B;
	AB = A + B;
	if (A % 3 == 0 || B % 3 == 0 || AB % 3 == 0) {
		OUT("Possible");
	}
	else {
		OUT("Impossible");
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(x) fprintf(stderr, "[%s = %d]\n", #x, x)
#else
	#define errp(...)
	#define dbg(x) 
#endif

ll c, sum_max, sum_min;
priority_queue<int> mx;
priority_queue<int, vi, greater<int>> mn;

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q, t, a, b;
	scanf("%d", &q);
	c = sum_max = sum_min = 0;
	while (q--) {
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d%d", &a, &b);
			c += b;
			if (mx.size() == mn.size()) {
				if (!mn.empty() && a > mn.top()) {
					int tp = mn.top();
					mn.pop();
					mn.push(a);
					mx.push(tp);
					sum_min += (a - tp);
					sum_max += tp;
				}
				else {
					mx.push(a);
					sum_max += a;
				}
			}
			else {
				int tp = mx.top();
				if (a < tp) {
					mx.pop();
					mx.push(a);
					mn.push(tp);
					sum_max += (a - tp);
					sum_min += tp;
				}
				else {
					mn.push(a);
					sum_min += a;
				}
			}

			errp("mx size = %d\n", mx.size());
			errp("mn size = %d\n", mn.size());

		}
		else {
			ll xmin = mx.top();
			ll val = sum_min - sum_max;

			if (mx.size() != mn.size()) val += xmin;
			printf("%lld %lld\n", xmin, val + c);
		}
	}
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
 
int n,s;
lld dp[10][111][1111];
 
lld solve(int idx,int now,int sum){
  if(idx == n){
    if(sum == s) return 1;
    else return 0;
  }
  if(dp[idx][now][sum] != -1) return dp[idx][now][sum];
  lld ret = 0;
  for(int i=now;i<=100;i++){
    if(sum+i > s) break;
    ret += solve(idx+1,i+1,sum+i);
  }
  return dp[idx][now][sum] = ret;
}
 
int main(){
  while(cin >> n >> s, n || s){
    memset(dp,-1,sizeof(dp));
    cout << solve(0,0,0) << endl;
  }
}

Measured memory_bytes: 10796