akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 550;

int c[MAXN], s[MAXN], f[MAXN], ans[MAXN];

int main ()
{
    int n;
    scanf ("%d", &n);
    memset (s, 0, sizeof (s));
    memset (c, 0, sizeof (c));
    memset (f, 0, sizeof (f));
    for (int i = 1; i < n; i ++)
    {
        scanf ("%d%d%d", &c[i], &s[i], &f[i]);
    }
    for (int i = n; i >= 1; i --)
    {
        ans[i] = s[i] + c[i];
        for (int j = i + 1; j < n; j ++)
        {
            if (ans[i] > s[j])
            {
                int tmp = ans[i] - s[j];
                int num = tmp / f[j];
                if (tmp % f[j])
                {
                    num ++;
                }
                ans[i] = s[j] + num * f[j] + c[j];
            }
            else
            {
                ans[i] = s[j] + c[j];
            }
        }
    }
    for (int i = 1; i <= n; i ++)
    {
        printf ("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 256
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
/*void calc()
{
	for(int i=0;i<2005;i++)
	{
		a[i][0]=1;
		a[i][i]=1;
		for(int j=1;j<i;j++)
		{
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%MOD;	
		}
	}
}*/
int main()
{
	ll l,r;
	cin>>l>>r;
	if((r-l+1)>=2019)
	{
		cout<<0;
		return 0;
	}
	l%=2019;
	r%=2019;
	if(r<=l)
	{
		cout<<0;
		return 0;
	}
	ll min1=INT_MAX;
	for(ll i=l;i<r;i++)
	{
		for(ll j=i+1;j<=r;j++)
		{
			min1=min(min1,((i%2019)*(j%2019))%2019);
		}
	}
	cout<<min1;
	return 0;
}





Measured memory_bytes: 256
class UnionFindTree:
    """Disjoint-Set Data Structure
       Union-Find Tree
       complexity:
          init: O(n)
          find, unite, same: O(alpha(n))
       used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ)
    """
    def __init__(self, n):
        self.par = list(range(n))  # parent
        self.rank = [0] * n  # depth of tree

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

H, W = map(int, input().split())
uft = UnionFindTree(H * W)
board = [input() for _ in range(H)]
drc = [(1, 0), (0, 1)]
for r in range(H):
    for c in range(W):
        if r < H - 1 and board[r + 1][c] != board[r][c]:
            uft.unite(r * W + c, (r + 1) * W + c)
        if c < W - 1 and board[r][c + 1] != board[r][c]:
            uft.unite(r * W + c, r * W + c + 1)
par_dict_w, par_dict_b = dict(), dict()
for r in range(H):
    for c in range(W):
        par = uft.find(r * W + c)
        if board[r][c] == "#":
            par_dict_b[par] = par_dict_b.get(par, 0) + 1
        else:
            par_dict_w[par] = par_dict_w.get(par, 0) + 1
print(sum(par_dict_w[k] * par_dict_b.get(k, 0) for k in par_dict_w.keys()))


Measured memory_bytes: 21868
#include<bits/stdc++.h>
using namespace std;
long long max(long long a,long long b){
  if(a>b) return a;
  else return b;}
int main(){
  int n,w;
  cin>>n>>w;
  vector<long long> dp(w+1);
  for(int i=0;i<n;i++)
  {
    long long a,b;
    cin>>a>>b;
    for(int j=w-a;j>=0;j--)
      dp[j+a]=max(dp[j+a],dp[j]+b);
  	}

  cout<<dp[w]<<endl;
}  


Measured memory_bytes: 4028
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int a[10000], b[10000],i=0,j;
	char op[10000];

	while (1){
		scanf("%d %c %d", &a[i], &op[i], &b[i]);
		if (op[i] == '?'){
			break;
		}
		i++;
	}

	for (j = 0; j < i; j++){
		if (op[j] == '+'){
			printf("%d\n", a[j] + b[j]);
		}
		else if (op[j] == '-'){
			printf("%d\n", a[j] - b[j]);
		}
		else if (op[j] == '*'){
			printf("%d\n", a[j] * b[j]);
		}
		else if (op[j] == '/'){
			printf("%d\n", a[j] / b[j]);
		}
	}

	return 0;
}

Measured memory_bytes: 1048
//Projection
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

static const double ESP = 1e-10;

bool equals(double a, double b) { return fabs(a - b) < ESP; }

class Point {
public:
    double x, y;

    explicit Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (const Point &p) const { return Point(x + p.x, y + p.y); }
    Point operator - (const Point &p) const { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(a / x, a / y); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < ESP && fabs(y - p.y) < ESP;
    }
};

typedef Point Vector;

struct Segment {
    Point p1, p2;
    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

bool isParallel(Vector v1, Vector v2) {
    return equals(cross(v1, v2), 0.0);
}

bool isOrthogonal(Vector v1, Vector v2) {
    return equals(dot(v1, v2), 0.0);
}

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    return s.p1 + (base * (dot(base, p - s.p1) / base.norm()));
}

int main() {
    int q;
    double x, y, x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    Point p1 = Point(x1, y1), p2 = Point(x2, y2);
    Segment s = Segment(p1, p2);
    for(int i = 0; i < q; i++) {
        cin >> x >> y;
        Point p = Point(x, y);
        Point x = project(s, p);
        cout << setprecision(15) << x.x << " " << x.y << endl;
    }
}


Measured memory_bytes: 3288
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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

ll K,N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>N;
 ll  sum = 0;


 for(ll i = 1 ; i<=N ; i++){
  if(i%3 != 0 && i%5 != 0)
    sum+=i;
 }


cout<<sum<<'\n';


   

}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
   solve();

  return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<string.h>
#include<map>
#include<set>
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;

using namespace std;

struct Point { double x, y; };

void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;
	s.x = (2.0*a.x + 1.0*b.x) / 3.0;
	s.y = (2.0*a.y + 1.0*b.y) / 3.0;
	t.x = (1.0*a.x + 2.0*b.x) / 3.0;
	t.y = (1.0*a.y + 2.0*b.y) / 3.0;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}
int main() {
	Point a, b;
	int n;
	scanf("%d", &n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	
	return 0;
}










Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    
    vector<int> U(26);
    rep(i, 26) U[i] = 'a' + i;
    rep(i, S.size()) rep(j, 26) {
        if (T[i] == U[j]) {
            swap(U[S[i] - 'a'], U[j]);
        }
    }
    rep(i, S.size()) S[i] = U[S[i] - 'a'];
    if (S == T) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 776
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

#include<atcoder/fenwicktree>
using namespace atcoder;

int n,q;

int main(){
	cin>>n>>q;
	fenwick_tree<ll> fw(n);
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		fw.add(i,x);
	}
	for(int i=0;i<q;i++){
		int t;
		cin>>t;
		if(t==0){
			int p,x;
			cin>>p>>x;
			fw.add(p,x);
		}
		else{
			int l,r;
			cin>>l>>r;
			cout<<fw.sum(l,r)<<endl;
		}
	}
}

Measured memory_bytes: 8212
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 1e6+2;
ll fact[inf];
void factfill()
{
    fact[0]=1;
    for(ll i=1; i<inf; i++)
        fact[i] = ( fact[i-1]*i ) % mod;
}

ll powmod(ll a, ll b)
{
    ll res = 1;
    while(b){
        if(b%2) res = ( res*a )%mod;
        a = (a*a)%mod;
        b/=2;
    }
    return res;
}

ll inv(ll x)
{
    return powmod(x,mod-2) % mod;
}

ll choose(ll n, ll r)
{
    return ( (fact[n]* inv(fact[n-r] ) )%mod *inv(fact[r]))%mod;
}
void solve()
{   

    ll h,w,a,b; cin >> h >> w >> a >> b;
    
    ll ans = 0;
    for(ll i=b+1; i<=w; i++ ){

        ans = (ans + choose(h-a-1+i-1,i-1)*choose( a-1+w-i, w-i ) )%mod ;

    }

    cout << ans;
}

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


        factfill();
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 11404
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n, m;
    cin >> n >> m;
    vector<pii> vs;
    set<int> st;
    if(n%2){
        for(int a=1, b= n; b-a>0; a++, b--){
            vs.emplace_back(a, b);
    
        }
    }else{
        bool fg = false;
          for(int a=1, b= n; b-a>0; a++, b--){
            if(!fg && b-a <= n/2) b--, fg = true;
            vs.emplace_back(a,b);
        }
    }

    rep(i, m){
        cout << vs[i].first << " " << vs[i].second << ln;
    }

}


Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i,j=-1,m=0;
    
  cin >> N;
  
  int A[N],B[N];
  
   for(i=0;i<N-1;i++){
      cin >> B[i];
  }
  
  B[N-1]=100001;
  A[0] = B[0];
  
  for(i=1;i<N;i++){
      A[i]=min(B[i-1],B[i]);
  }
  
   for(i=0;i<N;i++){
      m += A[i];
  }

 

  cout << m << endl;
  

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        Card[] cards = new Card[n];

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            char suit = s.charAt(0);
            int value = Integer.parseInt(s.substring(1));

            cards[i] = new Card(suit, value);
        }

        Card[] A = cards.clone();
        BubbleSort(A, n);
        PrintArray(A);
        System.out.println(CheckStableSort(cards, A));

        Card[] B = cards.clone();
        SelectionSort(B, n);
        PrintArray(B);
        System.out.println(CheckStableSort(cards, B));
    }

    static class Card {
        char suit;
        int value;

        Card(char suit, int value) {
            this.suit = suit;
            this.value = value;
        }
    }

    // 配列内の指定された2インデックスの要素を交換する
    static void Swap(Card[] C, int a, int b) {
        Card tmp = new Card(C[a].suit, C[a].value);
        C[a] = C[b];
        C[b] = tmp;
    }

    // バブルソート
    static void BubbleSort(Card[] C, int N) {
        for (int i = 0; i < N; i++) {
            for (int j = N-1; j > i; j--) {
                if (C[j].value < C[j-1].value)
                    Swap(C, j, j-1);
            }
        }
    }

    // セレクトソート
    static void SelectionSort(Card[] C, int N) {
        for (int i = 0; i < N; i++) {
            int minj = i;
            for (int j = i; j < N; j++) {
                if (C[j].value < C[minj].value)
                    minj = j;
            }
            Swap(C, i, minj);
        }
    }

    // 配列を表示する
    static void PrintArray(Card[] C) {
        for (int i = 0; i < C.length; i++) {
            System.out.print(C[i].suit);
            System.out.print(C[i].value);
            if (i != C.length-1)
                System.out.print(" ");
        }
        System.out.println();
    }

    // ソートされた配列が安定かどうか判断する(B:Before, A:After)
    static String CheckStableSort(Card[] B, Card[] A) {
        int indexB = 0;
        for (int i = 0; i < A.length; i++) {
            if (i > 0 && A[i].value != A[i - 1].value)
                indexB = 0;
            for (int j = indexB; j < B.length; j++) {
                if (A[i].value == B[j].value) {
                    if (A[i].suit != B[j].suit) {
                        return "Not stable";
                    } else {
                        indexB = j + 1;
                        break;
                    }
                }
            }
        }

        return "Stable";
    }
}


Measured memory_bytes: 26352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int h,w,n,a[10005];
vector<P>vec;
void go(int p,int q,int r,int s){
	for(int i=q;i<=s;i++) vec.pb(mp(p,i));
	for(int i=p+1;i<=r;i++) vec.pb(mp(i,s));
	for(int i=s-1;i>=q;i--) vec.pb(mp(r,i));
	for(int i=r-1;i>p;i--) vec.pb(mp(i,q));
	if(p+1<=r-1&&q+1<=s-1) go(p+1,q+1,r-1,s-1);
}
int ans[105][105];
int main(){
	cin >> h >> w >> n;
	for(int i=1;i<=n;i++) cin >> a[i];
	go(1,1,h,w);
	int s = 0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<a[i];j++){
			ans[vec[s].fi][vec[s].sc] = i;
			s++;
		}
	}
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) printf("%d%c",ans[i][j],j==w?'\n':' ');
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int X;
    cin>>X;
    int day=X%7;
    if (day==1){
        cout<<"fri"<<endl;
    }else if (day==2){
        cout<<"sat"<<endl;
    }else if (day==3){
        cout<<"sun"<<endl;
    }else if (day==4){
        cout<<"mon"<<endl;
    }else if (day==5){
        cout<<"tue"<<endl;
    }else if (day==6){
        cout<<"wed"<<endl;
    }else if (day==0){
        cout<<"thu"<<endl;
    }
}


Measured memory_bytes: 3124
#include<stdio.h>
#include<stdlib.h>
#define MAX 100005
 
typedef struct{
  char name[10];
  int time;
}Q;
 
Q data[MAX+1];
int head=0, tail=0, n;
 
void enqueue(Q);
Q dequeue(void);
 
int main(){
  int q, sum_t=0, i;
  Q p;
   
  scanf("%d%d",&n,&q);
  for( i=0 ; i<n ; i++ ){
    scanf("%s%d",data[i].name, &data[i].time);
    enqueue(data[i]);
  }
  i=0;
 
  while(i!=n){
    p = dequeue();
    if(p.time>q) {
      p.time = p.time-q;
      enqueue(p);
      sum_t += q;
    }
    else{
      sum_t += p.time;
      p.time = sum_t;
      data[i]=p;
      printf("%s %d\n",data[i].name,data[i].time);
      i++;
    }
  }
 
  return 0;
}
 
void enqueue(Q x){
  data[tail] = x;
  if(tail+1==MAX) tail=0;
  else tail++;
}
 
Q dequeue(void){
  Q x;
  x = data[head];
  if(head+1==MAX) head = 0;
  else head++;
  
  return x;
}

Measured memory_bytes: 2160
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main() {
	int a = 0;
	int b = 0;
	string op;
	while (1)
	{
		cin >> a >> op >> b;
		if (op=="?")
		{
			break;
		}
		else
		{
			if (op=="+")
			{
				cout << a + b << endl;
			}
			else if(op == "*")
			{
				cout << a * b << endl;
			}
			else if (op == "/")
			{
				cout << a / b << endl;
			}
			else if (op == "-")
			{
				cout << a - b << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll


int l,k;
int dp[1000]={};

signed main(){
  cin>>l>>k;

  for(int i=0;i<l+1;i++){
    if(i==0){
      dp[i+1]=1;
      dp[i+k]=1;
    }
    else{
      dp[i+2]+=dp[i];
      dp[i+k+1]+=dp[i];
    }
  }

  int ans=0;
  for(int i=0;i<l+1;i++){
    ans+=dp[i];
  }

  cout<<ans<<endl;
}


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

int main() {

	int a, b, c;
	int ans = 0;
	scanf("%d %d %d", &a, &b, &c);
	if(a == b && b == c && a % 2 == 0) {
		printf("%d\n", -1);
	}else {
	    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
	    	int x = a;
	    	int y = b;
	    	int z = c;
		    a = y / 2 + z / 2;
		    b = x / 2 + z / 2;
		    c = x / 2 + y / 2;
		    ans++;
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 256
while line = gets
  m, f, r = line.split(/\s+/).map(&:to_i)
  t = m + f

  exit if m == -1 && f == -1 && r == -1 

  r = if m == -1 || f == -1
    "F"
  else
    case t
    when 80..100
      "A"
    when 65..79
      "B"
    when 50..64
      "C"
    when 30..49
      r >= 50 ? "C" : "D"
    else
      "F"
    end
  end

  puts r
end


Measured memory_bytes: 6876
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<pll> P;
unordered_map<ll,unordered_map<ll,int>> mp;
void input(){
    fast_io();
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        ll x,y; cin >> x >> y;
        mp[x][y] = i+1;
        P.emplace_back(x,y);
    }
}

vector<bool> seen;
void dfs(int i,ll p, ll q){
    if(seen[i]) return;
    seen[i] = true;
    ll x = P[i].first;
    ll y = P[i].second;
    if(mp[x+p][y+q]!=0) dfs(mp[x+p][y+q]-1,p,q);
    if(mp[x-p][y-q]!=0) dfs(mp[x-p][y-q]-1,p,q);
}

int solve(){
    int ans = 1e5;
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++)
    {
        ll p,q;
        p = P[i].first-P[j].first;
        q = P[i].second-P[j].second;
        seen.assign(N,false);
        int connected = 0;
        for (int k = 0; k < N; k++)
        {
            if(!seen[k]){
                connected++;
                dfs(k,p,q);
            }
        }
        ans = min(ans,connected);
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 9356
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define INF ((int)1e9+5)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

int MOD;

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

}
LL exp(int a, int b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum) % MOD;
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int>> count(N+1, vector<int>(N+1, 0));
	REP(i, M){
		int r, l;
		cin >> r >> l;
		++count[r][l];
	}
	PER(i, N){
		REP(j, N+1){
			count[i][j]+=count[i+1][j];
		}
	}
	REP(i, N+1){
		REP(j, N){
			count[i][j+1]+=count[i][j];
		}
	}

	REP(i, Q){
		int r, l;
		cin >> r >> l;
		cout << count[r][l] << endl;
	}
	return 0;
}


Measured memory_bytes: 1920
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/12/20 07:29:17
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<pair<int, bool>> com[n];
  for (int i = 0; i < n; i++) {
    int k; cin>>k;
    for (int j = 0; j < k; j++) {
      int x,y; cin>>x>>y; x--;
      com[i].emplace_back(x, y);
    }
  }
  int ans = 0;
  for (int mask = 0; mask < (1<<n); mask++) {
    int cnt = __builtin_popcount(mask);
    if (cnt <= ans) continue;
    bool ok = true;
    for (int i = 0; i < n and ok; i++) {
      if ((mask&(1<<i)) == 0) continue;
      for (auto p : com[i]) {
        if (bool(mask&(1<<p.first)) != p.second) {
          ok = false;
          break;
        }
      }
    }
    if (ok)
      ans = cnt;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] a = new int[n];
			int[] b = new int[m];
			for(int i=0;i<n;i++) a[i] = sc.nextInt();
			for(int i=0;i<m;i++) b[i] = sc.nextInt();
			
			int count = 0;
			int max = 0;
			for(int i=0;i<m;i++){
				for(int j=0;j<n;j++){
					if(a[j]==b[i]){
						count = 0;
						for(int k=j;k<n;k++){
							if(a[k]==b[i+count]) count++;
							if(i+count==m) break;
						}
						max = Math.max(max, count);
					}
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 37992
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0, A+1):
    for j in range(0, B+1):
        for k in range(0, C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
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>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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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 N,Q;
  cin>>N>>Q;
  vector<tuple<int,int,int>> L(N);
  REP(i,N) cin>>get<1>(L[i])>>get<2>(L[i])>>get<0>(L[i]);
  SORT(L);
  
  set<pair<int,int>> S;
  REP(i,Q){
    int x;
    cin>>x;
    S.emplace(x,i);
  }
  
  vector<int> ANS(Q,-1);
  REP(i,N){
    auto FI=S.lower_bound(MP(get<1>(L[i])-get<0>(L[i]),0));
    auto SE=S.upper_bound(MP(get<2>(L[i])-get<0>(L[i])-1,Q));
    for(auto it=FI; it!=SE; ++it) ANS[it->second]=get<0>(L[i]);
    S.erase(FI,SE);
  }
  
  REP(i,Q) co(ANS[i]);
  return 0;
}

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

int main() {
	int n,a=0,b=0,c=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int m;
		cin>>m;
		if(m%4==0){
			a++;
		}
		else if(m%2==0){
			b++;
		}
		else{
			c++;
		}
	}
	if(b>0){
		cout<< (a>=c?"Yes":"No")<<endl;
	}
	else{
		cout <<(a>=c-1?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 10
void swap(int *x,int *y){
  *x^=*y;
  *y^=*x;
  *x^=*y;
}
int main(){
  int h[N];
  int i,j;
  for(i = 0; i < N; i++)
    scanf("%d",h+i);
  for(i = 0; i < 3 ; i++)
    for(j = i+1; j < N; j++)
      if(h[i] < h[j])
        swap(h+i,h+j);
  printf("%d\n%d\n%d\n",h[0],h[1],h[2]);
  return 0;
}

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

int main(){
    long long h,w; cin>>h>>w;
    long long ans=INF;
    for(long long i=1;i<h;i++){
        long long s1=i*w;
        long long s2,s3;
        if(w%2==0||(h-i)%2==0){
            s2=(h-i)*w/2;
            s3=h*w-s1-s2;
            ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
        }else{
            s2=(h-i)/2*w;
            s3=h*w-s1-s2;
            ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
            s2=w/2*(h-i);
            s3=h*w-s1-s2;
            ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
        }
    }
    for(long long i=1;i<w;i++){
        long long s1=i*h;
        long long s2,s3;
        if(h%2==0||(w-i)%2==0){
            s2=(w-i)*h/2;
            s3=h*w-s1-s2;
            ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
        }else{
            s2=(w-i)/2*h;
            s3=h*w-s1-s2;
            ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
            s2=h/2*(w-i);
            s3=h*w-s1-s2;
            ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N = int(input())
ans = 0
fn = factorization(N)
for i in range(len(fn)):
  if 0 < fn[i][1] <= 2:
    ans += 1
  elif 2 < fn[i][1] < 6:
    ans += 2
  elif 5 < fn[i][1] < 10:
    ans += 3
  elif 10 <= fn[i][1] < 15:
    ans += 4
  elif 15 <= fn[i][1] < 21:
    ans += 5
  elif 21 <= fn[i][1] < 28:
    ans += 6
  elif 28 <= fn[i][1] < 36:
    ans += 7
  elif 36 <= fn[i][1] < 45:
    ans += 8
  elif 45 <= fn[i][1] < 55:
    ans += 9

if N == 1:
  print(0)
else:
  print(ans)

  

Measured memory_bytes: 63524
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline, 4);

A = line[1].split(' ').map(Number);
m = line[3].split(' ').map(Number);

comb = [0];
for (i in A) {
  comb_i = [];
  for (j in comb) {
    if (comb.indexOf(A[i] + comb[j]) === -1) comb_i.push(A[i] + comb[j]);
  }
  comb = comb.concat(comb_i);
}

for (i in m) {
  if (comb.indexOf(m[i]) !== -1) console.log('yes');
  else console.log('no');
}

Measured memory_bytes: 17112
S = input()
if S[0] == S[1] and S[2] == S[3] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and len(set(S)) == 2:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and len(set(S)) == 2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9080
#include<cstdio>
#include<algorithm>

typedef long long int lli;

lli a[200000];
lli min[200000], max[200000];

int main(void) {
    lli n,t;
    scanf("%lld%lld",&n,&t);
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);

    min[0] = a[0];
    max[n-1] = a[n-1];
    lli maxprof = 0;
    for(int i=1; i<n; i++) {
        min[i] = std::min(min[i-1], a[i]);
        max[n-1-i] = std::max(max[n-i], a[n-1-i]);
    }
    for(int i=0; i<n; i++)
        maxprof = std::max(maxprof, max[i]-min[i]);

    lli maxres=0,minres=0;
    for(int i=0; i<n; i++) {
        if(max[i]-min[i] == maxprof) {
            if(max[i] == a[i]) maxres++;
            if(min[i] == a[i]) minres++;
        }
    }
    printf("%lld\n", std::min(maxres,minres));
    return 0;
}

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

struct Node {
    uint64_t root_counter = 0;
    uint64_t counter = 0;

    std::set<Node *> neighbors;
};

void dfs(Node &node, const Node *parent) {
    node.counter += node.root_counter;

    for(auto n: node.neighbors) {
        if(parent != n) {
            n->root_counter += node.root_counter;
            dfs(*n, &node);
        }
    }
}

int main() {
    int n, q;
    std::cin >> n >> q;

    auto nodes = std::vector<Node>(n, Node());

    for(int i = 0; i < n - 1; ++i) {
        int a, b;
        std::cin >> a >> b;
        --a;
        --b;

        nodes[a].neighbors.insert(&nodes[b]);
        nodes[b].neighbors.insert(&nodes[a]);
    }

    for(int i = 0; i < q; ++i) {
        int p, x;
        std::cin >> p >> x;
        --p;

        nodes[p].root_counter += x;
    }

    dfs(nodes[0], nullptr);

    for(const auto node: nodes) {
        std::cout << node.counter << " ";
    }

    return 0;
}


Measured memory_bytes: 43008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;
static const uint64_t MOD = 1000000007LL;
// uint64_t dp[100005][13];
//

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

    vector<long> a(n);
    vector<long> ab(n);
    long x = 1000000007LL;
    int nr_neg = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            nr_neg++;
            ab[i] = - a[i];
        } else {
            ab[i] = a[i];
        }
    }

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

    if (nr_neg % 2 == 0) {
        x = 0;
    }

    long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += ab[i];
    }
    ans -= x;
    ans -= x;

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

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

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/

map<ll, ll>mp;

int main()
{
	//FASTIO
// 	///*
//  #ifndef ONLINE_JUDGE
//  	freopen("in.txt", "r", stdin);
//  	freopen("out.txt", "w", stdout);
//  	freopen("error.txt", "w", stderr);
//  #endif
// //*/
	ll n, k, q;
	cin >> n >> k >> q;
	if(k > q){
		for(int i = 1; i <= n; i++)
			printf("Yes\n");
		return 0;
	}
	for (int i = 0; i < q; i++) {
		ll x;
		cin >> x;
		mp[x]++;
	}
	for (int i = 1; i <= n; i++) {
		dbg(k - (q - mp[i]));
		if (k - (q - mp[i]) > 0)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 6912
W, H, x, y = map(int, input().split())
if x == W/2.0 and y == H/2.0:
   print("%f %d" % (W*H/2.0, 1))
elif x == W/2.0 or y == H/2.0 or y == 1.0*H/W*x or y == H-1.0*H/W*x or y == 0 or y == H or x == 0 or x == W:
  print("%f %d" % (W*H/2.0, 0))
else:
  print("%f %d" % (W*H/2.0, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 100005;
int par[MAX_N];//親
int pank[MAX_N];//木の深さ

//n要素で初期化
void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        pank[i]=1;
    }
}

//木の根を求める
long long find(long long x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(long long x,long long y){
    x = find(x);
    y = find(y);
    if(x==y)return;
    if(pank[x]<pank[y]){
        par[x]=y;
        pank[y]+=pank[x];
    }else{
        par[y]=x;
        pank[x]+=pank[y];
    }
}

//xとyが同じ集合に属するか否か
bool same(long long x,long long y){
    return find(x)==find(y);
}

int main(){
    ll n,m;cin>>n>>m;
    vector<pair<ll,ll>> E(m);
    for(int i=0;i<m;i++){
        ll a,b;cin>>a>>b;a--;b--;
        E.push_back(make_pair(a,b));
    }
    reverse(E.begin(),E.end());
    init(n);
    ll res=n*(n-1)/2;
    vector<ll> ans(m);
    for(int i=0;i<m;i++){
        auto P=E[i];
        ll a=P.first,b=P.second;
        if(same(a,b)){
            ans[i]=res;
            continue;
        }
        ll now=pank[find(a)]*pank[find(b)];//cout<<pank[find(a)]<<endl;
        unite(a,b);
        ans[i]=res;
        res-=now;
        //aとbが属する集合がどのくらいのサイズかを求める
    }
    reverse(ans.begin(),ans.end());
    for(int i=0;i<m;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1; ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int a[N],b[N];
bool check(int l,int r){
	int al=0,ar=0;
	for (int i=l;i<=r;i++){
		if (b[i]<i){
			if (al>b[i]||(b[i]<l||b[i]>r)) return 0;
			al=b[i];
		} else{
			if (b[i]>i){
				if (ar>b[i]||(b[i]<l||b[i]>r)) return 0;
				ar=b[i];
			}
		}
	}
	return 1;
}
int main(){
	int n=read();
	for (int i=1;i<=n;i++) b[i]=read(),a[i]=(b[i]==i);
	for (int i=1;i<=n-2;i++)
	if (a[i]==0&&a[i+1]==0&&a[i+2]==0){
		printf("No\n"); return 0;
	}
	int las=0;
	for (int i=1;i<=n;i++){
	int l=i,r=i,now=1;
	if (a[i]==0){
	while ((a[r]^now)&&r<=n) r++,now^=1;
	r--;
	if (check(l,r)==0){printf("No\n"); return 0;}
	las=r+1; i=r;
	}
	}
	if (check(las,n)==0){printf("No\n"); return 0;}
	printf("Yes\n"); 
	return 0;
}

Measured memory_bytes: 2560
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader bf = new BufferedReader(is);
		String[] strAry = bf.readLine().split(" ");
		int a = Integer.parseInt(strAry[0]);
		int b = Integer.parseInt(strAry[1]);
		if (a == b) {
			System.out.println("a == b");
		} else if (a > b) {
			System.out.println("a > b");
		} else if (a < b) {
			System.out.println("a < b");
		}
	}
}

Measured memory_bytes: 24348
s=str(input())
if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
using namespace std;
 
int main() {

    string s,p;
    cin>>s>>p;
        
    s+=s;

    int sagasu = s.find(p);
 
    if (sagasu == string::npos) {
        cout << "No\n";
    }else {
        cout << "Yes\n";
    }
    return 0;
}


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b ;
  char s ;
  
  cin >> a >> s >> b ;
  
  if(s=='+'){
    cout <<a+b<<endl ;
  }
  else{
    cout <<a-b<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
using Pc=pair<char,char>;
ll dp[300][200000];
map<int,ll> mp;
int main() {
  ll n,k,q;
  cin>>n>>k>>q;
  ll tmp=k-q;
  vector<ll> a(n,tmp);
  for(int i=0;i<q;i++){
     int m;cin>>m;m--;
     a[m]++;
  }
  for(int i=0;i<n;i++){
      if(a[i]<=0)cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
  }
}

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

#define task "C"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (ll i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((ll)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
ll X, K, D;
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> X >> K >> D;
    ll right = (X % D + D) % D, left = right - D;
    if (X > 0)
    {
        ll step = (X - left) / D;
        if (step >= K)
        {
            cout << abs(X - D * K);
        } else
        {
            K -= step;
            if (K & 1) cout << abs(right);
            else cout << abs(left);
        }
    } else if (X < 0)
    {
        ll step = (right - X) / D;
        if (step >= K)
        {
            cout << abs(X + D * K);
        } else
        {
            K -= step;
            if (K & 1) cout << abs(left);
            else cout << abs(right);
        }
    } else
    {
        if (K & 1) cout << abs(D);
        else cout << 0;
    }
    return 0;
}


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

struct Node {
  int v;
  Node(int v) : v(v) {}

  Node operator*(const Node &r) const {
    return Node(min(v, r.v));
  }
} e((1ll << 31) - 1);

struct SegmentTree {
  size_t n;
  vector<Node> v;

  SegmentTree(size_t size) : n(1 << (32 - __builtin_clz(size - 1))), v(2 * n - 1, e) {}

  void update(int k, const Node &x) {
    k += n - 1;
    v[k] = x;
    while (k) {
      k = (k - 1) / 2;
      v[k] = v[2 * k + 1] * v[2 * k + 2];
    }
  }

  Node query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return e;
    if (a <= l && r <= b) return v[k];
    return query(a, b, 2 * k + 1, l, (l + r) / 2) * query(a, b, 2 * k + 2, (l + r) / 2, r);
  }

  void update(int k, int x) {
    update(k, Node(x));
  }

  int query(int a, int b) {
    return query(a, b, 0, 0, n).v;
  }
};

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

  SegmentTree seg(n);
  while (q--) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c)
      cout << seg.query(x, y + 1) << endl;
    else
      seg.update(x, y);
  }
}

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

int N;
int X[111];
int M;
int A[11],B[11],C[11];

int dp[111][111][11];
int solve(int l,int r,int id){
  if( dp[l][r][id]!=-1) return dp[l][r][id];
  int fl = 0;
  if( r-l == 1 ) {
    if(A[id] ==X[l]) return dp[l][r][id] = 1;
    return dp[l][r][id] = 0;
  }
  for(int i=l+1;i<r;i++){
    if( solve( l,i,B[id] ) && solve( i, r, C[id] ) ){
      fl = 1; continue;
    }
  }
  return dp[l][r][id] = fl;
}

int main(){
  memset( dp,-1,sizeof(dp));
  cin >> N;
  for(int i=0;i<N;i++) cin >> X[i];
  cin >> M;
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i] >> C[i];
    --B[i]; --C[i];
  }
  if( solve(0,N,0) ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624